diff --git a/rpmbuild/BUILD/acpi_call-master/Makefile b/rpmbuild/BUILD/acpi_call-master/Makefile new file mode 100644 index 0000000..0094f7e --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/Makefile @@ -0,0 +1,41 @@ +obj-m := acpi_call.o + +KVER ?= $(shell uname -r) +KDIR ?= /lib/modules/$(KVER)/build +VERSION ?= $(shell cat VERSION) + +default: + $(MAKE) -C $(KDIR) M=$(CURDIR) modules + +clean: + $(MAKE) -C $(KDIR) M=$(CURDIR) clean + +install: + $(MAKE) -C $(KDIR) M=$(CURDIR) modules_install + +load: + -/sbin/rmmod acpi_call + /sbin/insmod acpi_call.ko + +dkms.conf: dkms.conf.in + sed "s/@@VERSION@@/$(VERSION)/" $^ > $@ + +dkms-add: dkms.conf + /usr/sbin/dkms add $(CURDIR) + +dkms-build: dkms.conf + /usr/sbin/dkms build acpi_call/$(VERSION) + +dkms-install: dkms.conf + /usr/sbin/dkms install acpi_call/$(VERSION) + +dkms-remove: dkms.conf + /usr/sbin/dkms remove acpi_call/$(VERSION) --all + +modprobe-install: + modprobe acpi_call + +modprobe-remove: + modprobe -r acpi_call + +dev: modprobe-remove dkms-remove dkms-add dkms-build dkms-install modprobe-install diff --git a/rpmbuild/BUILD/acpi_call-master/Module.symvers b/rpmbuild/BUILD/acpi_call-master/Module.symvers new file mode 100644 index 0000000..e69de29 diff --git a/rpmbuild/BUILD/acpi_call-master/README.md b/rpmbuild/BUILD/acpi_call-master/README.md new file mode 100644 index 0000000..9e92039 --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/README.md @@ -0,0 +1,78 @@ +# acpi\_call +This is a fork of [acpi_call](https://github.com/mkottman/acpi_call) maintained by the NixOS community. +Patches also for non-NixOS related fixes are welcome! + +A simple kernel module that allows one to call ACPI methods by writing the +method name followed by its arguments to `/proc/acpi/call`. + +## Notes on dkms and Secure Boot + +If that is the way you want to install this module, you can follow +[this guide](https://web.archive.org/web/20210215173902/https://gist.github.com/dop3j0e/2a9e2dddca982c4f679552fc1ebb18df) ([mirror](https://gist.github.com/s-h-a-d-o-w/53c2215e955c3326c6ec8f812a0d2f27)) +to have dkms automatically sign the module after building. + +## Usage + + echo '' | sudo tee /proc/acpi/call + +You can then retrieve the result of the call by checking your dmesg or: + + sudo cat /proc/acpi/call + +An example to turn off the discrete graphics card in a dual graphics +environment (like NVIDIA Optimus): + + # turn off discrete graphics card + echo '\_SB.PCI0.PEG1.GFX0.DOFF' > /proc/acpi/call + # turn it back on + echo '\_SB.PCI0.PEG1.GFX0.DON' > /proc/acpi/call + +These work on my ASUS K52J notebook, but may not work for you. For a list of +methods to try, see http://linux-hybrid-graphics.blogspot.com/ or try running +the provided script `examples/turn_off_gpu.sh` + +It SHOULD be ok to test all of the methods, until you see a drop in battery +drain rate (`grep rate /proc/acpi/battery/BAT0/state`), however it comes +with NO WARRANTY - it may hang your computer/laptop, fail to work, etc. + +You can pass parameters to `acpi_call` by writing them after the method, +separated by single space. Currently, you can pass the following parameter +types: + +* ACPI_INTEGER - by writing NNN or 0xNNN, where NNN is an integer/hex +* ACPI_STRING - by enclosing the string in quotes: "hello, world" +* ACPI_BUFFER - by writing bXXXX, where XXXX is a hex string without spaces, + or by writing { b1, b2, b3, b4 }, where b1-4 are integers + +The status after a call can be read back from `/proc/acpi/call`: + +* 'not called' - nothing to report +* 'Error: ' - the call failed +* '0xNN' - the call succeeded, and returned an integer +* '"..."' - the call succeeded, and returned a string +* '{0xNN, ...}' - the call succeeded, and returned a buffer +* '[...]' - the call succeeded, and returned a package which may contain the + above types (integer, string and buffer) and other package types + + +## GUI Alternatives + +Found this too difficult? Try to use these programs provided by Marco Dalla Libera and do it via graphic interface. **Note that they is not suitable for arbitrary +APCI calls but intended for turning off discrete graphics only**. + +* [acpi_call_GUI (Ubuntu and his derivates)](https://github.com/marcoDallas/acpi_call_GUI) +* [acpi_call_GUI_systemd (all linux distros that support systemd: Ubuntu 16.04+, Fedora, Arch, Mandriva etc.)](https://github.com/marcoDallas/acpi_call_GUI_systemd) + +*** + +Copyright (c) 2010: Michal Kottman + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. diff --git a/rpmbuild/BUILD/acpi_call-master/VERSION b/rpmbuild/BUILD/acpi_call-master/VERSION new file mode 100644 index 0000000..23aa839 --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/VERSION @@ -0,0 +1 @@ +1.2.2 diff --git a/rpmbuild/BUILD/acpi_call-master/acpi_call.build b/rpmbuild/BUILD/acpi_call-master/acpi_call.build new file mode 100644 index 0000000..2bd04c2 --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/acpi_call.build @@ -0,0 +1,22 @@ +#!/bin/sh + +PACKAGE=acpi_call +ORIGPATH=$PWD + +cd $SLACKTRACKSCRATCHDIR +cp -r $ORIGPATH/* . + +KERNEL=${KERNEL:-"$(uname -r)"} +VERSION=3.17 +chown -R root:root . +chmod -R og-w . + +make clean && make && make install + +mkdir -vpm755 /usr/doc/${PACKAGE}-${VERSION} +cp -favv README.md examples support /usr/doc/${PACKAGE}-${VERSION} + +rm -fr /install +mkdir -vpm755 /install +cat ${ORIGPATH}/slack-desc > /install/slack-desc +sed "s%@KERNEL@%$KERNEL%" ${ORIGPATH}/doinst.sh > /install/doinst.sh diff --git a/rpmbuild/BUILD/acpi_call-master/acpi_call.c b/rpmbuild/BUILD/acpi_call-master/acpi_call.c new file mode 100644 index 0000000..15ddc4e --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/acpi_call.c @@ -0,0 +1,451 @@ +/* Copyright (c) 2010: Michal Kottman */ + +#define BUILDING_ACPICA + +#include +#include +#include +#include +#include +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) +#include +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) +#include +#else +#include +#endif + +MODULE_LICENSE("GPL"); + +/* Uncomment the following line to enable debug messages */ +/* +#define DEBUG +*/ + +#define BUFFER_SIZE 4096 +#define INPUT_BUFFER_SIZE (2 * BUFFER_SIZE) +#define MAX_ACPI_ARGS 16 + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) +#define HAVE_PROC_CREATE +#endif + +extern struct proc_dir_entry *acpi_root_dir; + +static char input_buffer[INPUT_BUFFER_SIZE]; +static char result_buffer[BUFFER_SIZE]; +static char not_called_message[11] = "not called"; + +static u8 temporary_buffer[BUFFER_SIZE]; + +static size_t get_avail_bytes(void) { + return BUFFER_SIZE - strlen(result_buffer); +} +static char *get_buffer_end(void) { + return result_buffer + strlen(result_buffer); +} + +/** Appends the contents of an acpi_object to the result buffer +@param result An acpi object holding result data +@returns 0 if the result could fully be saved, a higher value otherwise +*/ +static int acpi_result_to_string(union acpi_object *result) { + if (result->type == ACPI_TYPE_INTEGER) { + snprintf(get_buffer_end(), get_avail_bytes(), + "0x%x", (int)result->integer.value); + } else if (result->type == ACPI_TYPE_STRING) { + snprintf(get_buffer_end(), get_avail_bytes(), + "\"%*s\"", result->string.length, result->string.pointer); + } else if (result->type == ACPI_TYPE_BUFFER) { + int i; + // do not store more than data if it does not fit. The first element is + // just 4 chars, but there is also two bytes from the curly brackets + int show_values = min((size_t)result->buffer.length, get_avail_bytes() / 6); + + snprintf(get_buffer_end(), get_avail_bytes(), "{"); + for (i = 0; i < show_values; i++) + sprintf(get_buffer_end(), + i == 0 ? "0x%02x" : ", 0x%02x", result->buffer.pointer[i]); + + if (result->buffer.length > show_values) { + // if data was truncated, show a trailing comma if there is space + snprintf(get_buffer_end(), get_avail_bytes(), ","); + return 1; + } else { + // in case show_values == 0, but the buffer is too small to hold + // more values (i.e. the buffer cannot have anything more than "{") + snprintf(get_buffer_end(), get_avail_bytes(), "}"); + } + } else if (result->type == ACPI_TYPE_PACKAGE) { + int i; + snprintf(get_buffer_end(), get_avail_bytes(), "["); + for (i=0; ipackage.count; i++) { + if (i > 0) + snprintf(get_buffer_end(), get_avail_bytes(), ", "); + + // abort if there is no more space available + if (!get_avail_bytes() || acpi_result_to_string(&result->package.elements[i])) + return 1; + } + snprintf(get_buffer_end(), get_avail_bytes(), "]"); + } else { + snprintf(get_buffer_end(), get_avail_bytes(), + "Object type 0x%x\n", result->type); + } + + // return 0 if there are still bytes available, 1 otherwise + return !get_avail_bytes(); +} + +/** +@param method The full name of ACPI method to call +@param argc The number of parameters +@param argv A pre-allocated array of arguments of type acpi_object +*/ +static void do_acpi_call(const char * method, int argc, union acpi_object *argv) +{ + acpi_status status; + acpi_handle handle; + struct acpi_object_list arg; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Calling %s\n", method); +#endif + + // get the handle of the method, must be a fully qualified path + status = acpi_get_handle(NULL, (acpi_string) method, &handle); + + if (ACPI_FAILURE(status)) + { + snprintf(result_buffer, BUFFER_SIZE, "Error: %s", acpi_format_exception(status)); + printk(KERN_ERR "acpi_call: Cannot get handle: %s\n", result_buffer); + return; + } + + // prepare parameters + arg.count = argc; + arg.pointer = argv; + + // call the method + status = acpi_evaluate_object(handle, NULL, &arg, &buffer); + if (ACPI_FAILURE(status)) + { + snprintf(result_buffer, BUFFER_SIZE, "Error: %s", acpi_format_exception(status)); + printk(KERN_ERR "acpi_call: Method call failed: %s\n", result_buffer); + return; + } + + // reset the result buffer + *result_buffer = '\0'; + acpi_result_to_string(buffer.pointer); + kfree(buffer.pointer); + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Call successful: %s\n", result_buffer); +#endif +} + +/** Decodes 2 hex characters to an u8 int +*/ +u8 decodeHex(char *hex) { + char buf[3] = { hex[0], hex[1], 0}; + return (u8) simple_strtoul(buf, NULL, 16); +} + +/** Parses method name and arguments +@param input Input string to be parsed. Modified in the process. +@param nargs Set to number of arguments parsed (output) +@param args +*/ +static char *parse_acpi_args(char *input, int *nargs, union acpi_object **args) +{ + char *s = input; + int i; + + *nargs = 0; + *args = NULL; + + // the method name is separated from the arguments by a space + while (*s && *s != ' ') + s++; + // if no space is found, return 0 arguments + if (*s == 0) + return input; + + *args = (union acpi_object *) kmalloc(MAX_ACPI_ARGS * sizeof(union acpi_object), GFP_KERNEL); + if (!*args) { + printk(KERN_ERR "acpi_call: unable to allocate buffer\n"); + return NULL; + } + + while (*s) { + if (*s == ' ') { + if (*nargs == 0) + *s = 0; // change first space to nul + ++ *nargs; + ++ s; + } else { + union acpi_object *arg = (*args) + (*nargs - 1); + if (*s == '"') { + // decode string + arg->type = ACPI_TYPE_STRING; + arg->string.pointer = ++s; + arg->string.length = 0; + while (*s && *s++ != '"') + arg->string.length ++; + // skip the last " + if (*s == '"') + ++s; + } else if (*s == 'b') { + // decode buffer - bXXXX + char *p = ++s; + int len = 0, i; + u8 *buf = NULL; + + while (*p && *p!=' ') + p++; + + len = p - s; + if (len % 2 == 1) { + printk(KERN_ERR "acpi_call: buffer arg%d is not multiple of 8 bits\n", *nargs); + --*nargs; + goto err; + } + len /= 2; + + buf = (u8*) kmalloc(len, GFP_KERNEL); + if (!buf) { + printk(KERN_ERR "acpi_call: unable to allocate buffer\n"); + --*nargs; + goto err; + } + for (i=0; itype = ACPI_TYPE_BUFFER; + arg->buffer.pointer = buf; + arg->buffer.length = len; + } else if (*s == '{') { + // decode buffer - { b1, b2 ...} + u8 *buf = temporary_buffer; + arg->type = ACPI_TYPE_BUFFER; + arg->buffer.pointer = buf; + arg->buffer.length = 0; + while (*s && *s++ != '}') { + if (buf >= temporary_buffer + sizeof(temporary_buffer)) { + printk(KERN_ERR "acpi_call: buffer arg%d is truncated because the buffer is full\n", *nargs); + // clear remaining arguments + while (*s && *s != '}') + ++s; + break; + } + else if (*s >= '0' && *s <= '9') { + // decode integer into buffer + arg->buffer.length ++; + if (s[0] == '0' && s[1] == 'x') + *buf++ = simple_strtol(s+2, 0, 16); + else + *buf++ = simple_strtol(s, 0, 10); + } + // skip until space or comma or '}' + while (*s && *s != ' ' && *s != ',' && *s != '}') + ++s; + } + // store the result in new allocated buffer + buf = (u8*) kmalloc(arg->buffer.length, GFP_KERNEL); + if (!buf) { + printk(KERN_ERR "acpi_call: unable to allocate buffer\n"); + --*nargs; + goto err; + } + memcpy(buf, temporary_buffer, arg->buffer.length); + arg->buffer.pointer = buf; + } else { + // decode integer, N or 0xN + arg->type = ACPI_TYPE_INTEGER; + if (s[0] == '0' && s[1] == 'x') { + arg->integer.value = simple_strtol(s+2, 0, 16); + } else { + arg->integer.value = simple_strtol(s, 0, 10); + } + while (*s && *s != ' ') { + ++s; + } + } + } + } + + return input; + +err: + for (i=0; i<*nargs; i++) + if ((*args)[i].type == ACPI_TYPE_BUFFER && (*args)[i].buffer.pointer) + kfree((*args)[i].buffer.pointer); + kfree(*args); + return NULL; +} + +/** procfs write callback. Called when writing into /proc/acpi/call. +*/ +#ifdef HAVE_PROC_CREATE +static ssize_t acpi_proc_write( struct file *filp, const char __user *buff, + size_t len, loff_t *data ) +#else +static int acpi_proc_write( struct file *filp, const char __user *buff, + unsigned long len, void *data ) +#endif +{ + union acpi_object *args; + int nargs, i; + char *method; + + memset(input_buffer, 0, INPUT_BUFFER_SIZE); + if (len > sizeof(input_buffer) - 1) { +#ifdef HAVE_PROC_CREATE + printk(KERN_ERR "acpi_call: Input too long! (%zu)\n", len); +#else + printk(KERN_ERR "acpi_call: Input too long! (%lu)\n", len); +#endif + return -ENOSPC; + } + + if (copy_from_user( input_buffer, buff, len )) { + return -EFAULT; + } + input_buffer[len] = '\0'; + if (input_buffer[len-1] == '\n') + input_buffer[len-1] = '\0'; + + method = parse_acpi_args(input_buffer, &nargs, &args); + if (method) { + do_acpi_call(method, nargs, args); + if (args) { + for (i=0; i count) { + // user buffer is too small + ret = 0; + } else if(*off == len + 1) { + // we're done + ret = 0; + result_buffer[0] = '\0'; + } else { + // output the current result buffer + ret = simple_read_from_buffer(buff, count, off, result_buffer, len + 1); + *off = ret; + } + + return ret; +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) +static struct proc_ops proc_acpi_operations = { + .proc_read = acpi_proc_read, + .proc_write = acpi_proc_write, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 13, 0) + .proc_lseek = default_llseek, +#endif +}; +#else +static struct file_operations proc_acpi_operations = { + .owner = THIS_MODULE, + .read = acpi_proc_read, + .write = acpi_proc_write, +}; +#endif + +#else +static int acpi_proc_read(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = 0; + + if (off > 0) { + *eof = 1; + return 0; + } + + // output the current result buffer + len = strlen(result_buffer); + memcpy(page, result_buffer, len + 1); + + // initialize the result buffer for later + strcpy(result_buffer, "not called"); + + return len; +} +#endif + +/** module initialization function */ +static int __init init_acpi_call(void) +{ +#ifdef HAVE_PROC_CREATE + struct proc_dir_entry *acpi_entry = proc_create("call", + 0660, + acpi_root_dir, + &proc_acpi_operations); +#else + struct proc_dir_entry *acpi_entry = create_proc_entry("call", 0660, acpi_root_dir); +#endif + + strcpy(result_buffer, "not called"); + + if (acpi_entry == NULL) { + printk(KERN_ERR "acpi_call: Couldn't create proc entry\n"); + return -ENOMEM; + } + +#ifndef HAVE_PROC_CREATE + acpi_entry->write_proc = acpi_proc_write; + acpi_entry->read_proc = acpi_proc_read; +#endif + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Module loaded successfully\n"); +#endif + + return 0; +} + +static void __exit unload_acpi_call(void) +{ + remove_proc_entry("call", acpi_root_dir); + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Module unloaded successfully\n"); +#endif +} + +module_init(init_acpi_call); +module_exit(unload_acpi_call); + + diff --git a/rpmbuild/BUILD/acpi_call-master/acpi_call.ko b/rpmbuild/BUILD/acpi_call-master/acpi_call.ko new file mode 100644 index 0000000..2e41bb1 Binary files /dev/null and b/rpmbuild/BUILD/acpi_call-master/acpi_call.ko differ diff --git a/rpmbuild/BUILD/acpi_call-master/acpi_call.mod b/rpmbuild/BUILD/acpi_call-master/acpi_call.mod new file mode 100644 index 0000000..292f08d --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/acpi_call.mod @@ -0,0 +1 @@ +/home/mimillie/rpmbuild/BUILD/acpi_call-master/acpi_call.o diff --git a/rpmbuild/BUILD/acpi_call-master/acpi_call.mod.c b/rpmbuild/BUILD/acpi_call-master/acpi_call.mod.c new file mode 100644 index 0000000..29e5a8e --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/acpi_call.mod.c @@ -0,0 +1,36 @@ +#include +#define INCLUDE_VERMAGIC +#include +#include +#include +#include +#include + +#ifdef CONFIG_UNWINDER_ORC +#include +ORC_HEADER; +#endif + +BUILD_SALT; +BUILD_LTO_INFO; + +MODULE_INFO(vermagic, VERMAGIC_STRING); +MODULE_INFO(name, KBUILD_MODNAME); + +__visible struct module __this_module +__section(".gnu.linkonce.this_module") = { + .name = KBUILD_MODNAME, + .init = init_module, +#ifdef CONFIG_MODULE_UNLOAD + .exit = cleanup_module, +#endif + .arch = MODULE_ARCH_INIT, +}; + +#ifdef CONFIG_RETPOLINE +MODULE_INFO(retpoline, "Y"); +#endif + +MODULE_INFO(depends, ""); + +MODULE_INFO(rhelversion, "9.99"); diff --git a/rpmbuild/BUILD/acpi_call-master/acpi_call.mod.o b/rpmbuild/BUILD/acpi_call-master/acpi_call.mod.o new file mode 100644 index 0000000..4525ad1 Binary files /dev/null and b/rpmbuild/BUILD/acpi_call-master/acpi_call.mod.o differ diff --git a/rpmbuild/BUILD/acpi_call-master/acpi_call.o b/rpmbuild/BUILD/acpi_call-master/acpi_call.o new file mode 100644 index 0000000..2d680d0 Binary files /dev/null and b/rpmbuild/BUILD/acpi_call-master/acpi_call.o differ diff --git a/rpmbuild/BUILD/acpi_call-master/dkms.conf b/rpmbuild/BUILD/acpi_call-master/dkms.conf new file mode 100644 index 0000000..b86e841 --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/dkms.conf @@ -0,0 +1,7 @@ +PACKAGE_NAME="acpi_call" +PACKAGE_VERSION="1.2.2" +MAKE="KDIR=/lib/modules/${kernelver}/build make" +CLEAN="make clean" +BUILT_MODULE_NAME[0]="acpi_call" +AUTOINSTALL="yes" +DEST_MODULE_LOCATION[0]="/extra" diff --git a/rpmbuild/BUILD/acpi_call-master/dkms.conf.in b/rpmbuild/BUILD/acpi_call-master/dkms.conf.in new file mode 100644 index 0000000..b927370 --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/dkms.conf.in @@ -0,0 +1,7 @@ +PACKAGE_NAME="acpi_call" +PACKAGE_VERSION="@@VERSION@@" +MAKE="KDIR=/lib/modules/${kernelver}/build make" +CLEAN="make clean" +BUILT_MODULE_NAME[0]="acpi_call" +AUTOINSTALL="yes" +DEST_MODULE_LOCATION[0]="/extra" diff --git a/rpmbuild/BUILD/acpi_call-master/doinst.sh b/rpmbuild/BUILD/acpi_call-master/doinst.sh new file mode 100644 index 0000000..6510094 --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/doinst.sh @@ -0,0 +1,4 @@ +# Re-generate modules.dep and map files. +if [ -x sbin/depmod ]; then + chroot . /sbin/depmod -a @KERNEL@ 1> /dev/null 2> /dev/null +fi diff --git a/rpmbuild/BUILD/acpi_call-master/examples/asus1215n.sh b/rpmbuild/BUILD/acpi_call-master/examples/asus1215n.sh new file mode 100644 index 0000000..aedf10e --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/examples/asus1215n.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Power control for Asus 1215N Optimus +# by Pete Eberlein + +if ! lsmod | grep -q acpi_call; then + echo "Error: acpi_call module not loaded" + exit +fi + +acpi_call () { + echo "$*" > /proc/acpi/call + cat /proc/acpi/call +} + + +case "$1" in +off) + echo _DSM $(acpi_call "\_SB.PCI0.P0P4.GFX0._DSM" \ + "{0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47," \ + "0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0}" \ + "0x100 0x1A {0x1,0x0,0x0,0x3}") + # ok to turn off: Buffer {0x59 0x0 0x0 0x11} + # is already off: Buffer {0x41 0x0 0x0 0x11} + echo _PS3 $(acpi_call "\_SB.PCI0.P0P4.GFX0._PS3") +;; +on) + echo _PS0 $(acpi_call "\_SB.PCI0.P0P4.GFX0._PS0") +;; +*) + echo "Usage: $0 [on|off]" +esac + + +echo P3MO $(acpi_call "\_SB.PCI0.P0P4.GFX0.P3MO") +echo DGPS $(acpi_call "\_SB.PCI0.P0P4.GFX0.DGPS") +PSC=$(acpi_call "\_SB.PCI0.P0P4.GFX0._PSC") +echo _PSC ${PSC} +case "$PSC" in +0x0) + PSC="on" +;; +0x3) + PSC="off" +;; +esac +echo "Asus 1215N Optimus appears to be ${PSC}" + + diff --git a/rpmbuild/BUILD/acpi_call-master/examples/dellL702X.sh b/rpmbuild/BUILD/acpi_call-master/examples/dellL702X.sh new file mode 100644 index 0000000..b4a8a1c --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/examples/dellL702X.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# Power control for Dell L702X +# by Jos Hickson +# adapted from "Power control for DELL XPS L702X by Pete Eberlein" + +if ! lsmod | grep -q acpi_call; then + echo "Error: acpi_call module not loaded" + exit +fi + +acpi_call () { + echo "$*" > /proc/acpi/call + cat /proc/acpi/call +} + + +case "$1" in +off) + echo _DSM $(acpi_call "\_SB.PCI0.PEG0.PEGP._DSM" \ + "{0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47," \ + "0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0}" \ + "0x100 0x1A {0x1,0x0,0x0,0x3}") + # ok to turn off: Buffer {0x59 0x0 0x0 0x11} + # is already off: Buffer {0x41 0x0 0x0 0x11} + echo _PS3 $(acpi_call "\_SB.PCI0.PEG0.PEGP._PS3") +;; +on) + echo _PS0 $(acpi_call "\_SB.PCI0.PEG0.PEGP._PS0") +;; +*) + echo "Usage: $0 [on|off]" +esac + + +PSC=$(acpi_call "\_SB.PCI0.PEG0.PEGP._PSC") +#echo _PSC ${PSC} +case "$PSC" in +0x0) + PSC="on" +;; +0x3) + PSC="off" +;; +esac +echo "Dell L702X Optimus appears to be ${PSC}" + diff --git a/rpmbuild/BUILD/acpi_call-master/examples/graphic_card.sh b/rpmbuild/BUILD/acpi_call-master/examples/graphic_card.sh new file mode 100644 index 0000000..289fc66 --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/examples/graphic_card.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +usage="Usage: ./graphic_card [option] \nOPTION: \n- off \n- on \n- show" + +if [ $# -ne 1 ]; then + echo -e $usage +else + if lsmod | grep -q acpi_call; then + echo 'acpi_call found' + else + echo 'acpi_call found, importing it' + sudo insmod /home/sush/dev/c/acpi_call/acpi_call.ko + fi + if [ $1 = 'on' ]; then + echo '\_SB.PCI0.P0P2.PEGP._ON' > /proc/acpi/call + echo 'Discrete graphic card ENABLED !' + elif [ $1 = 'off' ]; then + echo '\_SB.PCI0.P0P2.PEGP._OFF' > /proc/acpi/call + echo 'Discrete graphic card DISABLED !' + elif [ $1 = 'show' ]; then + grep rate /proc/acpi/battery/BAT1/state + else + echo -e $usage + fi +fi diff --git a/rpmbuild/BUILD/acpi_call-master/examples/m11xr2.sh b/rpmbuild/BUILD/acpi_call-master/examples/m11xr2.sh new file mode 100644 index 0000000..08eafb7 --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/examples/m11xr2.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Based on m11xr2hack by George Shearer + +if ! lsmod | grep -q acpi_call; then + echo "Error: acpi_call module not loaded" + exit +fi + +acpi_call () { + echo "$*" > /proc/acpi/call + cat /proc/acpi/call +} + + +case "$1" in +off) + echo NVOP $(acpi_call "\_SB.PCI0.P0P2.PEGP.NVOP 0 0x100 0x1A {255,255,255,255}") + echo _PS3 $(acpi_call "\_SB.PCI0.P0P2.PEGP._PS3") +;; +on) + echo _PS0 $(acpi_call "\_SB.PCI0.P0P2.PEGP._PS0") +;; +*) + echo "Usage: $0 [on|off]" +;; +esac + diff --git a/rpmbuild/BUILD/acpi_call-master/examples/turn_off_gpu.sh b/rpmbuild/BUILD/acpi_call-master/examples/turn_off_gpu.sh new file mode 100644 index 0000000..019d25d --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/examples/turn_off_gpu.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +if lsmod | grep -q acpi_call; then +methods=" +\_SB_.PCI0.GFX0.ATPX +\_SB.PCI0.P0P1.VGA._OFF +\_SB.PCI0.P0P2.VGA._OFF +\_SB_.PCI0.OVGA.ATPX +\_SB_.PCI0.OVGA.XTPX +\_SB.PCI0.P0P3.PEGP._OFF +\_SB.PCI0.P0P2.PEGP._OFF +\_SB.PCI0.P0P1.PEGP._OFF +\_SB.PCI0.MXR0.MXM0._OFF +\_SB.PCI0.PEG1.GFX0._OFF +\_SB.PCI0.PEG0.GFX0.DOFF +\_SB.PCI0.PEG1.GFX0.DOFF +\_SB.PCI0.PEG0.PEGP._OFF +\_SB.PCI0.XVR0.Z01I.DGOF +\_SB.PCI0.PEGR.GFX0._OFF +\_SB.PCI0.PEG.VID._OFF +\_SB.PCI0.PEG0.VID._OFF +\_SB.PCI0.P0P2.DGPU._OFF +\_SB.PCI0.P0P4.DGPU.DOFF +\_SB.PCI0.IXVE.IGPU.DGOF +\_SB.PCI0.RP00.VGA._PS3 +\_SB.PCI0.RP00.VGA.P3MO +\_SB.PCI0.GFX0.DSM._T_0 +\_SB.PCI0.LPC.EC.PUBS._OFF +\_SB.PCI0.P0P2.NVID._OFF +\_SB.PCI0.P0P2.VGA.PX02 +\_SB_.PCI0.PEGP.DGFX._OFF +\_SB_.PCI0.VGA.PX02 +\_SB.PCI0.PEG0.PEGP.SGOF +\_SB.PCI0.AGP.VGA.PX02 +\_SB.PCI0.RP05.PXSX._OFF +\_SB.PCI0.GPP0.PG00._OFF +\_SB_.PC00.PEG1.PEGP._PS3 +\_SB_.PCI0.RP05.PEGP._OFF +" + +for m in $methods; do + printf "Trying %s: " "$m" + echo "$m" > /proc/acpi/call + result=$(cat /proc/acpi/call) + case "$result" in + Error*) + echo "failed" + ;; + *) + echo "works!" + # break # try out outher methods too + ;; + esac +done + +else + echo "The acpi_call module is not loaded, try running 'modprobe acpi_call' or 'insmod acpi_call.ko' as root" + exit 1 +fi diff --git a/rpmbuild/BUILD/acpi_call-master/modules.order b/rpmbuild/BUILD/acpi_call-master/modules.order new file mode 100644 index 0000000..292f08d --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/modules.order @@ -0,0 +1 @@ +/home/mimillie/rpmbuild/BUILD/acpi_call-master/acpi_call.o diff --git a/rpmbuild/BUILD/acpi_call-master/slack-desc b/rpmbuild/BUILD/acpi_call-master/slack-desc new file mode 100644 index 0000000..55493d8 --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +acpi_call: acpi_call (enable ACPI method calls through /proc) +acpi_call: +acpi_call: A kernel simple module that enables you to call ACPI methods +acpi_call: by writing the method name followed by arguments to /proc/acpi/call. +acpi_call: +acpi_call: WARNING: +acpi_call: This driver uses undocumented features and direct hardware access. +acpi_call: It thus cannot be guaranteed to work, and may cause arbitrary damage +acpi_call: (especially to models on which it wasn't tested). +acpi_call: +acpi_call: Homepage: https://github.com/teleshoes/acpi_call diff --git a/rpmbuild/BUILD/acpi_call-master/support/query_dsdt.pl b/rpmbuild/BUILD/acpi_call-master/support/query_dsdt.pl new file mode 100644 index 0000000..8dcd674 --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/support/query_dsdt.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl +use strict; +use Getopt::Long; +use Data::Dumper; + +my ($dir,$debug,$mytokens); +$dir = '.'; +GetOptions( + 'd|dir:s' => \$dir, + 'debug:s' => \$debug, + 't|tokens:s' => \$mytokens, + ); + +my $models; + +my @tokens = ( + 'MXMX','MXDS','_DSM', + '0xA6, 0xFA, 0xDD, 0x3D, 0x1B, 0x36, 0xB4, 0x4E', + '0xA4, 0x24, 0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53'); + +if (defined $mytokens) { + @tokens = (); + foreach my $mytoken (split(":",$mytokens)) { + push @tokens, $mytoken; + } +} + +opendir DIR,$dir or die $!; +my $file; +my $count = 0; +while (( defined($file = readdir(DIR)) )) { + if ($file =~ /\.dsl$/) { + analyse_file($dir,$file); + } + last if ($count++ > $debug && defined($debug)); +} + +foreach my $file (sort keys %$models) { + my $num = scalar keys %{$models->{$file}}; $num = sprintf("%02d",$num); + print "$num $file \{"; + foreach my $token (sort keys %{$models->{$file}}) { + my $value = $models->{$file}{$token}; + print "\t$token => $value "; + } + print "\}\n"; +} +$DB::single=1;1; +print STDERR Dumper($models) if ($debug); + +######################################## + +sub analyse_file { + my $dir = shift; + my $file = shift; + my $param = shift; + + open FILE, "$dir/$file" or die $!; + while () { + foreach my $token (@tokens) { + my $regexp = qr/${token}/; + if ($_ =~ /$regexp/g) { + $models->{$file}{$token}++; + } + } + } + close FILE; +} diff --git a/rpmbuild/BUILD/acpi_call-master/support/windump_hack/windump.c b/rpmbuild/BUILD/acpi_call-master/support/windump_hack/windump.c new file mode 100644 index 0000000..6246f06 --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/support/windump_hack/windump.c @@ -0,0 +1,285 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int format = ZPixmap; + +XImage * +CaptRoot(Display * dpy, int screen) +{ + unsigned long swaptest = 1; + XColor *colors; + unsigned buffer_size; + int win_name_size; + int header_size; + int ncolors, i; + char *win_name; + Bool got_win_name; + XWindowAttributes win_info; + XImage *image; + int absx, absy, x, y; + unsigned width, height; + int dwidth, dheight; + int bw; + Window dummywin; + +#if 0 + int transparentOverlays , multiVis; + int numVisuals; + XVisualInfo *pVisuals; + int numOverlayVisuals; + OverlayInfo *pOverlayVisuals; + int numImageVisuals; + XVisualInfo **pImageVisuals; + list_ptr vis_regions; /* list of regions to read from */ + list_ptr vis_image_regions ; + Visual vis_h,*vis ; +#endif + int allImage = 0 ; + + Window window=RootWindow (dpy, screen); + + if (!XGetWindowAttributes(dpy, window, &win_info)) + { fprintf(stderr,"Can't get target window attributes."); exit(1); } + + absx=0; absy=0; + win_info.x = 0; + win_info.y = 0; + width = win_info.width; + height = win_info.height; + bw = 0; + + dwidth = DisplayWidth (dpy, screen); + dheight = DisplayHeight (dpy, screen); + + XFetchName(dpy, window, &win_name); + if (!win_name || !win_name[0]) { + win_name = "xwdump"; + got_win_name = False; + } else { + got_win_name = True; + } + + /* sizeof(char) is included for the null string terminator. */ + win_name_size = strlen(win_name) + sizeof(char); + + /* + * Snarf the pixmap with XGetImage. + */ + + x = absx - win_info.x; + y = absy - win_info.y; +#if 0 + multiVis = GetMultiVisualRegions(dpy,RootWindow(dpy, screen),absx,absy, + width,height,&transparentOverlays,&numVisuals,&pVisuals, + &numOverlayVisuals,&pOverlayVisuals,&numImageVisuals, + &pImageVisuals,&vis_regions,&vis_image_regions,&allImage) ; + if (on_root || multiVis) + { + if (!multiVis) + image = XGetImage (dpy, RootWindow(dpy, screen), absx, absy, + width, height, AllPlanes, format); + else + image = ReadAreaToImage(dpy, RootWindow(dpy, screen), absx, absy, + width, height, + numVisuals,pVisuals,numOverlayVisuals,pOverlayVisuals, + numImageVisuals, pImageVisuals,vis_regions, + vis_image_regions,format,allImage); + } + else +#endif + image = XGetImage (dpy, window, x, y, width, height, + AllPlanes, format); + if (!image) { + fprintf (stderr, "unable to get image at %dx%d+%d+%d\n", + width, height, x, y); + exit (1); + } + + //if (add_pixel_value != 0) XAddPixel (image, add_pixel_value); + + return image; +} + +Window CreateWindow(Display * dpy, int screen, int width, int height) +{ + Window win = 0; + win = XCreateWindow(dpy, RootWindow(dpy, screen), + 0, 0, width, height, + 0, + 24, + InputOutput, + DefaultVisual(dpy, screen), + //CWBorderPixel|CWBackPixel|CWColormap|CWEventMask|CWBitGravity, + 0, + 0); + + XSelectInput(dpy, win, StructureNotifyMask|ButtonPressMask|ButtonReleaseMask); + + XMapWindow(dpy, win); + return win; +} + +void DrawImage(Display * dpy, Window win, XImage * image) +{ + static GC gc; + if(win!=0) + { + if(gc==0) + { + XGCValues gc_val; + gc = XCreateGC (dpy, win, GCForeground|GCBackground, &gc_val); + } + /*for(i=0;i<100;i++) + { + image->data*/ + XPutImage (dpy, win, gc, image, 0, 0, 0, 0, 1024, 768); + } +} + +void createShmImage(int w, int h, XShmSegmentInfo * sinfo, XShmSegmentInfo * tinfo, Display * sdpy, Display * tdpy, int sscr, int tscr, XImage ** simage, XImage ** timage) +{ + sinfo->shmid=tinfo->shmid=shmget(IPC_PRIVATE,w*h*sizeof(unsigned),IPC_CREAT|0666 ); + sinfo->shmaddr=tinfo->shmaddr=(char*)shmat(sinfo->shmid,0,0); + sinfo->readOnly=tinfo->readOnly=False; + printf("%d %d\n",DefaultDepth(sdpy,sscr),DefaultDepth(tdpy,tscr)); + *simage = XShmCreateImage( + sdpy, DefaultVisual(sdpy,sscr), DefaultDepth(sdpy,sscr), + ZPixmap/*format*/, + (char *)sinfo->shmaddr, sinfo, + w,h /*width,height*/ + ); + *timage = XShmCreateImage( + tdpy, DefaultVisual(tdpy,tscr), DefaultDepth(tdpy,tscr), + ZPixmap/*format*/, + (char *)tinfo->shmaddr, tinfo, + w,h /*width,height*/ + ); + XShmAttach(sdpy, sinfo); + XShmAttach(tdpy, tinfo); +} + +void drawMouse(XImage * img, int xm, int ym) +{ + int x,y,x1,y1,x2,y2,w,h; + + unsigned * data = (unsigned *)(img->data); + + w=img->width; + h=img->height; + + x=xm; if(x<0) x=0; if(x>w) x=w-1; + y=ym; if(y<0) y=0; if(y>h) y=h-1; + x1=xm-5; if(x1<0) x1=0; if(x1>w) x1=w; + x2=xm+6; if(x2<0) x2=0; if(x2>w) x2=w; + for(x=x1;xw) x=w-1; + y=ym; if(y<0) y=0; if(y>h) y=h-1; + y1=ym-5; if(y1<0) y1=0; if(y1>h) y1=h; + y2=ym+6; if(y2<0) y2=0; if(y2>h) y2=h; + for(y=y1;ywidth, simage->height, simage->depth); + //printf("timage: w:%d h:%d d:%d\n",timage->width, timage->height, timage->depth); + if(!emulate_events) + { + Window rwin,cwin; + int xmouse,ymouse,x,y,mask; + XQueryPointer(sdpy,swin,&rwin,&cwin,&xmouse,&ymouse,&x,&y,&mask); + drawMouse(timage, xmouse, ymouse); + } + + XShmPutImage (tdpy, twin, tgc, timage, 0, 0, 0, 0, timage->width, timage->height, False); + //XPutImage (tdpy, twin, tgc, timage, 0, 0, 0, 0, timage->width, timage->height); + } + //XFlush(sdpy); + XFlush(tdpy); +// getchar(); + } +} diff --git a/rpmbuild/BUILD/acpi_call-master/support/windump_hack/xorg.conf b/rpmbuild/BUILD/acpi_call-master/support/windump_hack/xorg.conf new file mode 100644 index 0000000..21c0090 --- /dev/null +++ b/rpmbuild/BUILD/acpi_call-master/support/windump_hack/xorg.conf @@ -0,0 +1,83 @@ +# nvidia-xconfig: X configuration file generated by nvidia-xconfig +# nvidia-xconfig: version 270.41.06 (buildmeister@swio-display-x86-rhel47-08.nvidia.com) Mon Apr 18 15:14:00 PDT 2011 + +Section "ServerLayout" + Identifier "Layout0" + Screen "Screen0" + Screen "Screen1" RightOf "Screen0" + InputDevice "Keyboard0" "SendCoreEvents" + #InputDevice "Keyboard0" "CoreKeyboard" + InputDevice "Mouse0" "SendCoreEvents" + #InputDevice "Mouse0" "CorePointer" +EndSection + +#Section "ServerFlags" +# Option "AllowEmptyInput" "no" +#EndSection + +Section "Files" +EndSection + +Section "InputDevice" + # generated from default + Identifier "Mouse0" + Driver "mouse" + Option "Protocol" "auto" + Option "Device" "/dev/psaux" + Option "Emulate3Buttons" "no" + Option "ZAxisMapping" "4 5" +EndSection + +Section "InputDevice" + # generated from default + Identifier "Keyboard0" + Driver "kbd" +EndSection + +Section "Monitor" + Identifier "Monitor0" + VendorName "Unknown" + ModelName "Unknown" + HorizSync 28.0 - 73.0 + VertRefresh 43.0 - 72.0 + Option "DPMS" +EndSection + +Section "Device" + Identifier "Device1" + Driver "nvidia" + VendorName "NVIDIA Corporation" + BusID "PCI:1:0:0" + Option "IgnoreEDID" + #Screen 0 +EndSection + +Section "Device" + Identifier "Device0" + Driver "intel" + VendorName "onboard" + BusID "PCI:0:2:0" + #Screen 1 +EndSection + +Section "Screen" + Identifier "Screen1" + Device "Device0" + Monitor "Monitor0" + DefaultDepth 24 + SubSection "Display" + Depth 24 + EndSubSection +EndSection + +Section "Screen" + Identifier "Screen0" + Device "Device1" + Monitor "Monitor0" + DefaultDepth 24 + SubSection "Display" + Depth 24 + Modes "1024x768" + EndSubSection +EndSection + diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.1.0/Makefile b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/Makefile new file mode 100644 index 0000000..f9fe03d --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/Makefile @@ -0,0 +1,18 @@ +obj-m := acpi_call.o + +KVERSION := $(shell uname -r) +KDIR := /lib/modules/$(KVERSION)/build +PWD := $(shell pwd) + +default: + $(MAKE) -C $(KDIR) M=$(PWD) modules + +clean: + $(MAKE) -C $(KDIR) M=$(PWD) clean + +install: + $(MAKE) -C $(KDIR) M=$(PWD) modules_install + +load: + -/sbin/rmmod acpi_call + /sbin/insmod acpi_call.ko diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.1.0/README.md b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/README.md new file mode 100644 index 0000000..3090843 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/README.md @@ -0,0 +1,73 @@ +A kernel simple module that enables you to call ACPI methods by writing the +method name followed by arguments to `/proc/acpi/call`. + +This module is to be considered a proof-of-concept and has been superseeded by +projects like [bbswitch](https://github.com/Bumblebee-Project/bbswitch). It +allows you to tamper with your system and should be used with caution. + +Want to use acpi_call via graphic interface? [Click here](https://github.com/mkottman/acpi_call/#graphic-interface) + +Usage: + + echo '' | sudo tee /proc/acpi/call + +You can then retrieve the result of the call by checking your dmesg or: + + sudo cat /proc/acpi/call + +An example to turn off discrete graphics card in a dual graphics environment +(like NVIDIA Optimus): + + # turn off discrete graphics card + echo '\_SB.PCI0.PEG1.GFX0.DOFF' > /proc/acpi/call + # turn it back on + echo '\_SB.PCI0.PEG1.GFX0.DON' > /proc/acpi/call + +These work on my ASUS K52J notebook, but may not work for you. For a list of +methods to try, see http://linux-hybrid-graphics.blogspot.com/ or try running +the provided script `examples/turn_off_gpu.sh` + +It SHOULD be ok to test all of the methods, until you see a drop in battery +drain rate (`grep rate /proc/acpi/battery/BAT0/state`), however it comes +with NO WARRANTY - it may hang your computer/laptop, fail to work, etc. + +You can pass parameters to `acpi_call` by writing them after the method, +separated by single space. Currently, you can pass the following parameter +types: + +* ACPI_INTEGER - by writing NNN or 0xNNN, where NNN is an integer/hex +* ACPI_STRING - by enclosing the string in quotes: "hello, world" +* ACPI_BUFFER - by writing bXXXX, where XXXX is a hex string without spaces, + or by writing { b1, b2, b3, b4 }, where b1-4 are integers + +The status after a call can be read back from `/proc/acpi/call`: + +* 'not called' - nothing to report +* 'Error: ' - the call failed +* '0xNN' - the call succeeded, and returned an integer +* '"..."' - the call succeeded, and returned a string +* '{0xNN, ...}' - the call succeeded, and returned a buffer +* '[...]' - the call succeeded, and returned a package which may contain the + above types (integer, string and buffer) and other package types + + +#### Graphic interface + +Found this too difficult? Try to use these programs provided by Marco Dalla Libera and do it via graphic interface: + +* [acpi_call_GUI (Ubuntu and other debian-based distributions)](http://marcodallas.github.io/acpi_call_GUI/) +* [acpi_call_GUI_Fedora (Fedora version)](https://github.com/marcoDallas/acpi_call_GUI_Fedora) + +*** + +Copyright (c) 2010: Michal Kottman + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.1.0/acpi_call.c b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/acpi_call.c new file mode 100644 index 0000000..3025d97 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/acpi_call.c @@ -0,0 +1,391 @@ +/* Copyright (c) 2010: Michal Kottman */ + +#include +#include +#include +#include +#include +#include +#include + +MODULE_LICENSE("GPL"); + +/* Uncomment the following line to enable debug messages */ +/* +#define DEBUG +*/ + +#define BUFFER_SIZE 256 +#define MAX_ACPI_ARGS 16 + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) +#define HAVE_PROC_CREATE +#endif + +extern struct proc_dir_entry *acpi_root_dir; + +static char result_buffer[BUFFER_SIZE]; + +static u8 temporary_buffer[BUFFER_SIZE]; + +static size_t get_avail_bytes(void) { + return BUFFER_SIZE - strlen(result_buffer); +} +static char *get_buffer_end(void) { + return result_buffer + strlen(result_buffer); +} + +/** Appends the contents of an acpi_object to the result buffer +@param result An acpi object holding result data +@returns 0 if the result could fully be saved, a higher value otherwise +*/ +static int acpi_result_to_string(union acpi_object *result) { + if (result->type == ACPI_TYPE_INTEGER) { + snprintf(get_buffer_end(), get_avail_bytes(), + "0x%x", (int)result->integer.value); + } else if (result->type == ACPI_TYPE_STRING) { + snprintf(get_buffer_end(), get_avail_bytes(), + "\"%*s\"", result->string.length, result->string.pointer); + } else if (result->type == ACPI_TYPE_BUFFER) { + int i; + // do not store more than data if it does not fit. The first element is + // just 4 chars, but there is also two bytes from the curly brackets + int show_values = min((size_t)result->buffer.length, get_avail_bytes() / 6); + + sprintf(get_buffer_end(), "{"); + for (i = 0; i < show_values; i++) + sprintf(get_buffer_end(), + i == 0 ? "0x%02x" : ", 0x%02x", result->buffer.pointer[i]); + + if (result->buffer.length > show_values) { + // if data was truncated, show a trailing comma if there is space + snprintf(get_buffer_end(), get_avail_bytes(), ","); + return 1; + } else { + // in case show_values == 0, but the buffer is too small to hold + // more values (i.e. the buffer cannot have anything more than "{") + snprintf(get_buffer_end(), get_avail_bytes(), "}"); + } + } else if (result->type == ACPI_TYPE_PACKAGE) { + int i; + sprintf(get_buffer_end(), "["); + for (i=0; ipackage.count; i++) { + if (i > 0) + snprintf(get_buffer_end(), get_avail_bytes(), ", "); + + // abort if there is no more space available + if (!get_avail_bytes() || acpi_result_to_string(&result->package.elements[i])) + return 1; + } + snprintf(get_buffer_end(), get_avail_bytes(), "]"); + } else { + snprintf(get_buffer_end(), get_avail_bytes(), + "Object type 0x%x\n", result->type); + } + + // return 0 if there are still bytes available, 1 otherwise + return !get_avail_bytes(); +} + +/** +@param method The full name of ACPI method to call +@param argc The number of parameters +@param argv A pre-allocated array of arguments of type acpi_object +*/ +static void do_acpi_call(const char * method, int argc, union acpi_object *argv) +{ + acpi_status status; + acpi_handle handle; + struct acpi_object_list arg; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Calling %s\n", method); +#endif + + // get the handle of the method, must be a fully qualified path + status = acpi_get_handle(NULL, (acpi_string) method, &handle); + + if (ACPI_FAILURE(status)) + { + snprintf(result_buffer, BUFFER_SIZE, "Error: %s", acpi_format_exception(status)); + printk(KERN_ERR "acpi_call: Cannot get handle: %s\n", result_buffer); + return; + } + + // prepare parameters + arg.count = argc; + arg.pointer = argv; + + // call the method + status = acpi_evaluate_object(handle, NULL, &arg, &buffer); + if (ACPI_FAILURE(status)) + { + snprintf(result_buffer, BUFFER_SIZE, "Error: %s", acpi_format_exception(status)); + printk(KERN_ERR "acpi_call: Method call failed: %s\n", result_buffer); + return; + } + + // reset the result buffer + *result_buffer = '\0'; + acpi_result_to_string(buffer.pointer); + kfree(buffer.pointer); + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Call successful: %s\n", result_buffer); +#endif +} + +/** Decodes 2 hex characters to an u8 int +*/ +u8 decodeHex(char *hex) { + char buf[3] = { hex[0], hex[1], 0}; + return (u8) simple_strtoul(buf, NULL, 16); +} + +/** Parses method name and arguments +@param input Input string to be parsed. Modified in the process. +@param nargs Set to number of arguments parsed (output) +@param args +*/ +static char *parse_acpi_args(char *input, int *nargs, union acpi_object **args) +{ + char *s = input; + + *nargs = 0; + *args = NULL; + + // the method name is separated from the arguments by a space + while (*s && *s != ' ') + s++; + // if no space is found, return 0 arguments + if (*s == 0) + return input; + + *args = (union acpi_object *) kmalloc(MAX_ACPI_ARGS * sizeof(union acpi_object), GFP_KERNEL); + + while (*s) { + if (*s == ' ') { + if (*nargs == 0) + *s = 0; // change first space to nul + ++ *nargs; + ++ s; + } else { + union acpi_object *arg = (*args) + (*nargs - 1); + if (*s == '"') { + // decode string + arg->type = ACPI_TYPE_STRING; + arg->string.pointer = ++s; + arg->string.length = 0; + while (*s && *s++ != '"') + arg->string.length ++; + // skip the last " + ++s; + } else if (*s == 'b') { + // decode buffer - bXXXX + char *p = ++s; + int len = 0, i; + u8 *buf = NULL; + + while (*p && *p!=' ') + p++; + + len = p - s; + if (len % 2 == 1) { + printk(KERN_ERR "acpi_call: buffer arg%d is not multiple of 8 bits\n", *nargs); + return NULL; + } + len /= 2; + + buf = (u8*) kmalloc(len, GFP_KERNEL); + for (i=0; itype = ACPI_TYPE_BUFFER; + arg->buffer.pointer = buf; + arg->buffer.length = len; + } else if (*s == '{') { + // decode buffer - { b1, b2 ...} + u8 *buf = temporary_buffer; + arg->type = ACPI_TYPE_BUFFER; + arg->buffer.pointer = buf; + arg->buffer.length = 0; + while (*s && *s++ != '}') { + if (buf >= temporary_buffer + sizeof(temporary_buffer)) { + printk(KERN_ERR "acpi_call: buffer arg%d is truncated because the buffer is full\n", *nargs); + // clear remaining arguments + while (*s && *s != '}') + ++s; + break; + } + else if (*s >= '0' && *s <= '9') { + // decode integer into buffer + arg->buffer.length ++; + if (s[0] == '0' && s[1] == 'x') + *buf++ = simple_strtol(s+2, 0, 16); + else + *buf++ = simple_strtol(s, 0, 10); + } + // skip until space or comma or '}' + while (*s && *s != ' ' && *s != ',' && *s != '}') + ++s; + } + // store the result in new allocated buffer + buf = (u8*) kmalloc(arg->buffer.length, GFP_KERNEL); + memcpy(buf, temporary_buffer, arg->buffer.length); + arg->buffer.pointer = buf; + } else { + // decode integer, N or 0xN + arg->type = ACPI_TYPE_INTEGER; + if (s[0] == '0' && s[1] == 'x') { + arg->integer.value = simple_strtol(s+2, 0, 16); + } else { + arg->integer.value = simple_strtol(s, 0, 10); + } + while (*s && *s != ' ') { + ++s; + } + } + } + } + + return input; +} + +/** procfs write callback. Called when writing into /proc/acpi/call. +*/ +#ifdef HAVE_PROC_CREATE +static ssize_t acpi_proc_write( struct file *filp, const char __user *buff, + size_t len, loff_t *data ) +#else +static int acpi_proc_write( struct file *filp, const char __user *buff, + unsigned long len, void *data ) +#endif +{ + char input[2 * BUFFER_SIZE] = { '\0' }; + union acpi_object *args; + int nargs, i; + char *method; + + if (len > sizeof(input) - 1) { + printk(KERN_ERR "acpi_call: Input too long! (%lu)\n", len); + return -ENOSPC; + } + + if (copy_from_user( input, buff, len )) { + return -EFAULT; + } + input[len] = '\0'; + if (input[len-1] == '\n') + input[len-1] = '\0'; + + method = parse_acpi_args(input, &nargs, &args); + if (method) { + do_acpi_call(method, nargs, args); + if (args) { + for (i=0; i 0) { + *eof = 1; + return 0; + } + + // output the current result buffer + len = strlen(result_buffer); + memcpy(page, result_buffer, len + 1); + + // initialize the result buffer for later + strcpy(result_buffer, "not called"); + + return len; +} +#endif + +/** module initialization function */ +static int __init init_acpi_call(void) +{ +#ifdef HAVE_PROC_CREATE + struct proc_dir_entry *acpi_entry = proc_create("call", + 0660, + acpi_root_dir, + &proc_acpi_operations); +#else + struct proc_dir_entry *acpi_entry = create_proc_entry("call", 0660, acpi_root_dir); +#endif + + strcpy(result_buffer, "not called"); + + if (acpi_entry == NULL) { + printk(KERN_ERR "acpi_call: Couldn't create proc entry\n"); + return -ENOMEM; + } + +#ifndef HAVE_PROC_CREATE + acpi_entry->write_proc = acpi_proc_write; + acpi_entry->read_proc = acpi_proc_read; +#endif + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Module loaded successfully\n"); +#endif + + return 0; +} + +static void __exit unload_acpi_call(void) +{ + remove_proc_entry("call", acpi_root_dir); + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Module unloaded successfully\n"); +#endif +} + +module_init(init_acpi_call); +module_exit(unload_acpi_call); + + diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.1.0/acpi_call.mod b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/acpi_call.mod new file mode 100644 index 0000000..c810bf5 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/acpi_call.mod @@ -0,0 +1 @@ +/home/mimillie/rpmbuild/BUILD/akmod-acpi_call-1.1.0/acpi_call.o diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.1.0/examples/asus1215n.sh b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/examples/asus1215n.sh new file mode 100644 index 0000000..aedf10e --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/examples/asus1215n.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Power control for Asus 1215N Optimus +# by Pete Eberlein + +if ! lsmod | grep -q acpi_call; then + echo "Error: acpi_call module not loaded" + exit +fi + +acpi_call () { + echo "$*" > /proc/acpi/call + cat /proc/acpi/call +} + + +case "$1" in +off) + echo _DSM $(acpi_call "\_SB.PCI0.P0P4.GFX0._DSM" \ + "{0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47," \ + "0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0}" \ + "0x100 0x1A {0x1,0x0,0x0,0x3}") + # ok to turn off: Buffer {0x59 0x0 0x0 0x11} + # is already off: Buffer {0x41 0x0 0x0 0x11} + echo _PS3 $(acpi_call "\_SB.PCI0.P0P4.GFX0._PS3") +;; +on) + echo _PS0 $(acpi_call "\_SB.PCI0.P0P4.GFX0._PS0") +;; +*) + echo "Usage: $0 [on|off]" +esac + + +echo P3MO $(acpi_call "\_SB.PCI0.P0P4.GFX0.P3MO") +echo DGPS $(acpi_call "\_SB.PCI0.P0P4.GFX0.DGPS") +PSC=$(acpi_call "\_SB.PCI0.P0P4.GFX0._PSC") +echo _PSC ${PSC} +case "$PSC" in +0x0) + PSC="on" +;; +0x3) + PSC="off" +;; +esac +echo "Asus 1215N Optimus appears to be ${PSC}" + + diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.1.0/examples/dellL702X.sh b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/examples/dellL702X.sh new file mode 100644 index 0000000..8f29cbf --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/examples/dellL702X.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# Power control for Dell L702X +# by Jos Hickson +# adapted from "Power control for Asus 1215N Optimus by Pete Eberlein" + +if ! lsmod | grep -q acpi_call; then + echo "Error: acpi_call module not loaded" + exit +fi + +acpi_call () { + echo "$*" > /proc/acpi/call + cat /proc/acpi/call +} + + +case "$1" in +off) + echo _DSM $(acpi_call "\_SB.PCI0.PEG0.PEGP._DSM" \ + "{0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47," \ + "0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0}" \ + "0x100 0x1A {0x1,0x0,0x0,0x3}") + # ok to turn off: Buffer {0x59 0x0 0x0 0x11} + # is already off: Buffer {0x41 0x0 0x0 0x11} + echo _PS3 $(acpi_call "\_SB.PCI0.PEG0.PEGP._PS3") +;; +on) + echo _PS0 $(acpi_call "\_SB.PCI0.PEG0.PEGP._PS0") +;; +*) + echo "Usage: $0 [on|off]" +esac + + +PSC=$(acpi_call "\_SB.PCI0.PEG0.PEGP._PSC") +#echo _PSC ${PSC} +case "$PSC" in +0x0) + PSC="on" +;; +0x3) + PSC="off" +;; +esac +echo "Dell L702X Optimus appears to be ${PSC}" + diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.1.0/examples/m11xr2.sh b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/examples/m11xr2.sh new file mode 100644 index 0000000..08eafb7 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/examples/m11xr2.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Based on m11xr2hack by George Shearer + +if ! lsmod | grep -q acpi_call; then + echo "Error: acpi_call module not loaded" + exit +fi + +acpi_call () { + echo "$*" > /proc/acpi/call + cat /proc/acpi/call +} + + +case "$1" in +off) + echo NVOP $(acpi_call "\_SB.PCI0.P0P2.PEGP.NVOP 0 0x100 0x1A {255,255,255,255}") + echo _PS3 $(acpi_call "\_SB.PCI0.P0P2.PEGP._PS3") +;; +on) + echo _PS0 $(acpi_call "\_SB.PCI0.P0P2.PEGP._PS0") +;; +*) + echo "Usage: $0 [on|off]" +;; +esac + diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.1.0/examples/turn_off_gpu.sh b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/examples/turn_off_gpu.sh new file mode 100644 index 0000000..a18daa7 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/examples/turn_off_gpu.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +if lsmod | grep -q acpi_call; then +methods=" +\_SB.PCI0.P0P1.VGA._OFF +\_SB.PCI0.P0P2.VGA._OFF +\_SB_.PCI0.OVGA.ATPX +\_SB_.PCI0.OVGA.XTPX +\_SB.PCI0.P0P3.PEGP._OFF +\_SB.PCI0.P0P2.PEGP._OFF +\_SB.PCI0.P0P1.PEGP._OFF +\_SB.PCI0.MXR0.MXM0._OFF +\_SB.PCI0.PEG1.GFX0._OFF +\_SB.PCI0.PEG0.GFX0.DOFF +\_SB.PCI0.PEG1.GFX0.DOFF +\_SB.PCI0.PEG0.PEGP._OFF +\_SB.PCI0.XVR0.Z01I.DGOF +\_SB.PCI0.PEGR.GFX0._OFF +\_SB.PCI0.PEG.VID._OFF +\_SB.PCI0.PEG0.VID._OFF +\_SB.PCI0.P0P2.DGPU._OFF +\_SB.PCI0.P0P4.DGPU.DOFF +\_SB.PCI0.IXVE.IGPU.DGOF +\_SB.PCI0.RP00.VGA._PS3 +\_SB.PCI0.RP00.VGA.P3MO +\_SB.PCI0.GFX0.DSM._T_0 +\_SB.PCI0.LPC.EC.PUBS._OFF +\_SB.PCI0.P0P2.NVID._OFF +\_SB.PCI0.P0P2.VGA.PX02 +\_SB_.PCI0.PEGP.DGFX._OFF +\_SB_.PCI0.VGA.PX02 +\_SB.PCI0.PEG0.PEGP.SGOF +\_SB.PCI0.AGP.VGA.PX02 +" + +for m in $methods; do + echo -n "Trying $m: " + echo $m > /proc/acpi/call + result=$(cat /proc/acpi/call) + case "$result" in + Error*) + echo "failed" + ;; + *) + echo "works!" + # break # try out outher methods too + ;; + esac +done + +else + echo "The acpi_call module is not loaded, try running 'modprobe acpi_call' or 'insmod acpi_call.ko' as root" + exit 1 +fi diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.1.0/support/query_dsdt.pl b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/support/query_dsdt.pl new file mode 100644 index 0000000..8dcd674 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/support/query_dsdt.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl +use strict; +use Getopt::Long; +use Data::Dumper; + +my ($dir,$debug,$mytokens); +$dir = '.'; +GetOptions( + 'd|dir:s' => \$dir, + 'debug:s' => \$debug, + 't|tokens:s' => \$mytokens, + ); + +my $models; + +my @tokens = ( + 'MXMX','MXDS','_DSM', + '0xA6, 0xFA, 0xDD, 0x3D, 0x1B, 0x36, 0xB4, 0x4E', + '0xA4, 0x24, 0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53'); + +if (defined $mytokens) { + @tokens = (); + foreach my $mytoken (split(":",$mytokens)) { + push @tokens, $mytoken; + } +} + +opendir DIR,$dir or die $!; +my $file; +my $count = 0; +while (( defined($file = readdir(DIR)) )) { + if ($file =~ /\.dsl$/) { + analyse_file($dir,$file); + } + last if ($count++ > $debug && defined($debug)); +} + +foreach my $file (sort keys %$models) { + my $num = scalar keys %{$models->{$file}}; $num = sprintf("%02d",$num); + print "$num $file \{"; + foreach my $token (sort keys %{$models->{$file}}) { + my $value = $models->{$file}{$token}; + print "\t$token => $value "; + } + print "\}\n"; +} +$DB::single=1;1; +print STDERR Dumper($models) if ($debug); + +######################################## + +sub analyse_file { + my $dir = shift; + my $file = shift; + my $param = shift; + + open FILE, "$dir/$file" or die $!; + while () { + foreach my $token (@tokens) { + my $regexp = qr/${token}/; + if ($_ =~ /$regexp/g) { + $models->{$file}{$token}++; + } + } + } + close FILE; +} diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.1.0/support/windump_hack/windump.c b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/support/windump_hack/windump.c new file mode 100644 index 0000000..6246f06 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/support/windump_hack/windump.c @@ -0,0 +1,285 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int format = ZPixmap; + +XImage * +CaptRoot(Display * dpy, int screen) +{ + unsigned long swaptest = 1; + XColor *colors; + unsigned buffer_size; + int win_name_size; + int header_size; + int ncolors, i; + char *win_name; + Bool got_win_name; + XWindowAttributes win_info; + XImage *image; + int absx, absy, x, y; + unsigned width, height; + int dwidth, dheight; + int bw; + Window dummywin; + +#if 0 + int transparentOverlays , multiVis; + int numVisuals; + XVisualInfo *pVisuals; + int numOverlayVisuals; + OverlayInfo *pOverlayVisuals; + int numImageVisuals; + XVisualInfo **pImageVisuals; + list_ptr vis_regions; /* list of regions to read from */ + list_ptr vis_image_regions ; + Visual vis_h,*vis ; +#endif + int allImage = 0 ; + + Window window=RootWindow (dpy, screen); + + if (!XGetWindowAttributes(dpy, window, &win_info)) + { fprintf(stderr,"Can't get target window attributes."); exit(1); } + + absx=0; absy=0; + win_info.x = 0; + win_info.y = 0; + width = win_info.width; + height = win_info.height; + bw = 0; + + dwidth = DisplayWidth (dpy, screen); + dheight = DisplayHeight (dpy, screen); + + XFetchName(dpy, window, &win_name); + if (!win_name || !win_name[0]) { + win_name = "xwdump"; + got_win_name = False; + } else { + got_win_name = True; + } + + /* sizeof(char) is included for the null string terminator. */ + win_name_size = strlen(win_name) + sizeof(char); + + /* + * Snarf the pixmap with XGetImage. + */ + + x = absx - win_info.x; + y = absy - win_info.y; +#if 0 + multiVis = GetMultiVisualRegions(dpy,RootWindow(dpy, screen),absx,absy, + width,height,&transparentOverlays,&numVisuals,&pVisuals, + &numOverlayVisuals,&pOverlayVisuals,&numImageVisuals, + &pImageVisuals,&vis_regions,&vis_image_regions,&allImage) ; + if (on_root || multiVis) + { + if (!multiVis) + image = XGetImage (dpy, RootWindow(dpy, screen), absx, absy, + width, height, AllPlanes, format); + else + image = ReadAreaToImage(dpy, RootWindow(dpy, screen), absx, absy, + width, height, + numVisuals,pVisuals,numOverlayVisuals,pOverlayVisuals, + numImageVisuals, pImageVisuals,vis_regions, + vis_image_regions,format,allImage); + } + else +#endif + image = XGetImage (dpy, window, x, y, width, height, + AllPlanes, format); + if (!image) { + fprintf (stderr, "unable to get image at %dx%d+%d+%d\n", + width, height, x, y); + exit (1); + } + + //if (add_pixel_value != 0) XAddPixel (image, add_pixel_value); + + return image; +} + +Window CreateWindow(Display * dpy, int screen, int width, int height) +{ + Window win = 0; + win = XCreateWindow(dpy, RootWindow(dpy, screen), + 0, 0, width, height, + 0, + 24, + InputOutput, + DefaultVisual(dpy, screen), + //CWBorderPixel|CWBackPixel|CWColormap|CWEventMask|CWBitGravity, + 0, + 0); + + XSelectInput(dpy, win, StructureNotifyMask|ButtonPressMask|ButtonReleaseMask); + + XMapWindow(dpy, win); + return win; +} + +void DrawImage(Display * dpy, Window win, XImage * image) +{ + static GC gc; + if(win!=0) + { + if(gc==0) + { + XGCValues gc_val; + gc = XCreateGC (dpy, win, GCForeground|GCBackground, &gc_val); + } + /*for(i=0;i<100;i++) + { + image->data*/ + XPutImage (dpy, win, gc, image, 0, 0, 0, 0, 1024, 768); + } +} + +void createShmImage(int w, int h, XShmSegmentInfo * sinfo, XShmSegmentInfo * tinfo, Display * sdpy, Display * tdpy, int sscr, int tscr, XImage ** simage, XImage ** timage) +{ + sinfo->shmid=tinfo->shmid=shmget(IPC_PRIVATE,w*h*sizeof(unsigned),IPC_CREAT|0666 ); + sinfo->shmaddr=tinfo->shmaddr=(char*)shmat(sinfo->shmid,0,0); + sinfo->readOnly=tinfo->readOnly=False; + printf("%d %d\n",DefaultDepth(sdpy,sscr),DefaultDepth(tdpy,tscr)); + *simage = XShmCreateImage( + sdpy, DefaultVisual(sdpy,sscr), DefaultDepth(sdpy,sscr), + ZPixmap/*format*/, + (char *)sinfo->shmaddr, sinfo, + w,h /*width,height*/ + ); + *timage = XShmCreateImage( + tdpy, DefaultVisual(tdpy,tscr), DefaultDepth(tdpy,tscr), + ZPixmap/*format*/, + (char *)tinfo->shmaddr, tinfo, + w,h /*width,height*/ + ); + XShmAttach(sdpy, sinfo); + XShmAttach(tdpy, tinfo); +} + +void drawMouse(XImage * img, int xm, int ym) +{ + int x,y,x1,y1,x2,y2,w,h; + + unsigned * data = (unsigned *)(img->data); + + w=img->width; + h=img->height; + + x=xm; if(x<0) x=0; if(x>w) x=w-1; + y=ym; if(y<0) y=0; if(y>h) y=h-1; + x1=xm-5; if(x1<0) x1=0; if(x1>w) x1=w; + x2=xm+6; if(x2<0) x2=0; if(x2>w) x2=w; + for(x=x1;xw) x=w-1; + y=ym; if(y<0) y=0; if(y>h) y=h-1; + y1=ym-5; if(y1<0) y1=0; if(y1>h) y1=h; + y2=ym+6; if(y2<0) y2=0; if(y2>h) y2=h; + for(y=y1;ywidth, simage->height, simage->depth); + //printf("timage: w:%d h:%d d:%d\n",timage->width, timage->height, timage->depth); + if(!emulate_events) + { + Window rwin,cwin; + int xmouse,ymouse,x,y,mask; + XQueryPointer(sdpy,swin,&rwin,&cwin,&xmouse,&ymouse,&x,&y,&mask); + drawMouse(timage, xmouse, ymouse); + } + + XShmPutImage (tdpy, twin, tgc, timage, 0, 0, 0, 0, timage->width, timage->height, False); + //XPutImage (tdpy, twin, tgc, timage, 0, 0, 0, 0, timage->width, timage->height); + } + //XFlush(sdpy); + XFlush(tdpy); +// getchar(); + } +} diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.1.0/support/windump_hack/xorg.conf b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/support/windump_hack/xorg.conf new file mode 100644 index 0000000..21c0090 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.1.0/support/windump_hack/xorg.conf @@ -0,0 +1,83 @@ +# nvidia-xconfig: X configuration file generated by nvidia-xconfig +# nvidia-xconfig: version 270.41.06 (buildmeister@swio-display-x86-rhel47-08.nvidia.com) Mon Apr 18 15:14:00 PDT 2011 + +Section "ServerLayout" + Identifier "Layout0" + Screen "Screen0" + Screen "Screen1" RightOf "Screen0" + InputDevice "Keyboard0" "SendCoreEvents" + #InputDevice "Keyboard0" "CoreKeyboard" + InputDevice "Mouse0" "SendCoreEvents" + #InputDevice "Mouse0" "CorePointer" +EndSection + +#Section "ServerFlags" +# Option "AllowEmptyInput" "no" +#EndSection + +Section "Files" +EndSection + +Section "InputDevice" + # generated from default + Identifier "Mouse0" + Driver "mouse" + Option "Protocol" "auto" + Option "Device" "/dev/psaux" + Option "Emulate3Buttons" "no" + Option "ZAxisMapping" "4 5" +EndSection + +Section "InputDevice" + # generated from default + Identifier "Keyboard0" + Driver "kbd" +EndSection + +Section "Monitor" + Identifier "Monitor0" + VendorName "Unknown" + ModelName "Unknown" + HorizSync 28.0 - 73.0 + VertRefresh 43.0 - 72.0 + Option "DPMS" +EndSection + +Section "Device" + Identifier "Device1" + Driver "nvidia" + VendorName "NVIDIA Corporation" + BusID "PCI:1:0:0" + Option "IgnoreEDID" + #Screen 0 +EndSection + +Section "Device" + Identifier "Device0" + Driver "intel" + VendorName "onboard" + BusID "PCI:0:2:0" + #Screen 1 +EndSection + +Section "Screen" + Identifier "Screen1" + Device "Device0" + Monitor "Monitor0" + DefaultDepth 24 + SubSection "Display" + Depth 24 + EndSubSection +EndSection + +Section "Screen" + Identifier "Screen0" + Device "Device1" + Monitor "Monitor0" + DefaultDepth 24 + SubSection "Display" + Depth 24 + Modes "1024x768" + EndSubSection +EndSection + diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/Makefile b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/Makefile new file mode 100644 index 0000000..0094f7e --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/Makefile @@ -0,0 +1,41 @@ +obj-m := acpi_call.o + +KVER ?= $(shell uname -r) +KDIR ?= /lib/modules/$(KVER)/build +VERSION ?= $(shell cat VERSION) + +default: + $(MAKE) -C $(KDIR) M=$(CURDIR) modules + +clean: + $(MAKE) -C $(KDIR) M=$(CURDIR) clean + +install: + $(MAKE) -C $(KDIR) M=$(CURDIR) modules_install + +load: + -/sbin/rmmod acpi_call + /sbin/insmod acpi_call.ko + +dkms.conf: dkms.conf.in + sed "s/@@VERSION@@/$(VERSION)/" $^ > $@ + +dkms-add: dkms.conf + /usr/sbin/dkms add $(CURDIR) + +dkms-build: dkms.conf + /usr/sbin/dkms build acpi_call/$(VERSION) + +dkms-install: dkms.conf + /usr/sbin/dkms install acpi_call/$(VERSION) + +dkms-remove: dkms.conf + /usr/sbin/dkms remove acpi_call/$(VERSION) --all + +modprobe-install: + modprobe acpi_call + +modprobe-remove: + modprobe -r acpi_call + +dev: modprobe-remove dkms-remove dkms-add dkms-build dkms-install modprobe-install diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/Module.symvers b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/Module.symvers new file mode 100644 index 0000000..e69de29 diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/README.md b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/README.md new file mode 100644 index 0000000..9e92039 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/README.md @@ -0,0 +1,78 @@ +# acpi\_call +This is a fork of [acpi_call](https://github.com/mkottman/acpi_call) maintained by the NixOS community. +Patches also for non-NixOS related fixes are welcome! + +A simple kernel module that allows one to call ACPI methods by writing the +method name followed by its arguments to `/proc/acpi/call`. + +## Notes on dkms and Secure Boot + +If that is the way you want to install this module, you can follow +[this guide](https://web.archive.org/web/20210215173902/https://gist.github.com/dop3j0e/2a9e2dddca982c4f679552fc1ebb18df) ([mirror](https://gist.github.com/s-h-a-d-o-w/53c2215e955c3326c6ec8f812a0d2f27)) +to have dkms automatically sign the module after building. + +## Usage + + echo '' | sudo tee /proc/acpi/call + +You can then retrieve the result of the call by checking your dmesg or: + + sudo cat /proc/acpi/call + +An example to turn off the discrete graphics card in a dual graphics +environment (like NVIDIA Optimus): + + # turn off discrete graphics card + echo '\_SB.PCI0.PEG1.GFX0.DOFF' > /proc/acpi/call + # turn it back on + echo '\_SB.PCI0.PEG1.GFX0.DON' > /proc/acpi/call + +These work on my ASUS K52J notebook, but may not work for you. For a list of +methods to try, see http://linux-hybrid-graphics.blogspot.com/ or try running +the provided script `examples/turn_off_gpu.sh` + +It SHOULD be ok to test all of the methods, until you see a drop in battery +drain rate (`grep rate /proc/acpi/battery/BAT0/state`), however it comes +with NO WARRANTY - it may hang your computer/laptop, fail to work, etc. + +You can pass parameters to `acpi_call` by writing them after the method, +separated by single space. Currently, you can pass the following parameter +types: + +* ACPI_INTEGER - by writing NNN or 0xNNN, where NNN is an integer/hex +* ACPI_STRING - by enclosing the string in quotes: "hello, world" +* ACPI_BUFFER - by writing bXXXX, where XXXX is a hex string without spaces, + or by writing { b1, b2, b3, b4 }, where b1-4 are integers + +The status after a call can be read back from `/proc/acpi/call`: + +* 'not called' - nothing to report +* 'Error: ' - the call failed +* '0xNN' - the call succeeded, and returned an integer +* '"..."' - the call succeeded, and returned a string +* '{0xNN, ...}' - the call succeeded, and returned a buffer +* '[...]' - the call succeeded, and returned a package which may contain the + above types (integer, string and buffer) and other package types + + +## GUI Alternatives + +Found this too difficult? Try to use these programs provided by Marco Dalla Libera and do it via graphic interface. **Note that they is not suitable for arbitrary +APCI calls but intended for turning off discrete graphics only**. + +* [acpi_call_GUI (Ubuntu and his derivates)](https://github.com/marcoDallas/acpi_call_GUI) +* [acpi_call_GUI_systemd (all linux distros that support systemd: Ubuntu 16.04+, Fedora, Arch, Mandriva etc.)](https://github.com/marcoDallas/acpi_call_GUI_systemd) + +*** + +Copyright (c) 2010: Michal Kottman + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/VERSION b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/VERSION new file mode 100644 index 0000000..23aa839 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/VERSION @@ -0,0 +1 @@ +1.2.2 diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.build b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.build new file mode 100644 index 0000000..2bd04c2 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.build @@ -0,0 +1,22 @@ +#!/bin/sh + +PACKAGE=acpi_call +ORIGPATH=$PWD + +cd $SLACKTRACKSCRATCHDIR +cp -r $ORIGPATH/* . + +KERNEL=${KERNEL:-"$(uname -r)"} +VERSION=3.17 +chown -R root:root . +chmod -R og-w . + +make clean && make && make install + +mkdir -vpm755 /usr/doc/${PACKAGE}-${VERSION} +cp -favv README.md examples support /usr/doc/${PACKAGE}-${VERSION} + +rm -fr /install +mkdir -vpm755 /install +cat ${ORIGPATH}/slack-desc > /install/slack-desc +sed "s%@KERNEL@%$KERNEL%" ${ORIGPATH}/doinst.sh > /install/doinst.sh diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.c b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.c new file mode 100644 index 0000000..15ddc4e --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.c @@ -0,0 +1,451 @@ +/* Copyright (c) 2010: Michal Kottman */ + +#define BUILDING_ACPICA + +#include +#include +#include +#include +#include +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) +#include +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) +#include +#else +#include +#endif + +MODULE_LICENSE("GPL"); + +/* Uncomment the following line to enable debug messages */ +/* +#define DEBUG +*/ + +#define BUFFER_SIZE 4096 +#define INPUT_BUFFER_SIZE (2 * BUFFER_SIZE) +#define MAX_ACPI_ARGS 16 + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) +#define HAVE_PROC_CREATE +#endif + +extern struct proc_dir_entry *acpi_root_dir; + +static char input_buffer[INPUT_BUFFER_SIZE]; +static char result_buffer[BUFFER_SIZE]; +static char not_called_message[11] = "not called"; + +static u8 temporary_buffer[BUFFER_SIZE]; + +static size_t get_avail_bytes(void) { + return BUFFER_SIZE - strlen(result_buffer); +} +static char *get_buffer_end(void) { + return result_buffer + strlen(result_buffer); +} + +/** Appends the contents of an acpi_object to the result buffer +@param result An acpi object holding result data +@returns 0 if the result could fully be saved, a higher value otherwise +*/ +static int acpi_result_to_string(union acpi_object *result) { + if (result->type == ACPI_TYPE_INTEGER) { + snprintf(get_buffer_end(), get_avail_bytes(), + "0x%x", (int)result->integer.value); + } else if (result->type == ACPI_TYPE_STRING) { + snprintf(get_buffer_end(), get_avail_bytes(), + "\"%*s\"", result->string.length, result->string.pointer); + } else if (result->type == ACPI_TYPE_BUFFER) { + int i; + // do not store more than data if it does not fit. The first element is + // just 4 chars, but there is also two bytes from the curly brackets + int show_values = min((size_t)result->buffer.length, get_avail_bytes() / 6); + + snprintf(get_buffer_end(), get_avail_bytes(), "{"); + for (i = 0; i < show_values; i++) + sprintf(get_buffer_end(), + i == 0 ? "0x%02x" : ", 0x%02x", result->buffer.pointer[i]); + + if (result->buffer.length > show_values) { + // if data was truncated, show a trailing comma if there is space + snprintf(get_buffer_end(), get_avail_bytes(), ","); + return 1; + } else { + // in case show_values == 0, but the buffer is too small to hold + // more values (i.e. the buffer cannot have anything more than "{") + snprintf(get_buffer_end(), get_avail_bytes(), "}"); + } + } else if (result->type == ACPI_TYPE_PACKAGE) { + int i; + snprintf(get_buffer_end(), get_avail_bytes(), "["); + for (i=0; ipackage.count; i++) { + if (i > 0) + snprintf(get_buffer_end(), get_avail_bytes(), ", "); + + // abort if there is no more space available + if (!get_avail_bytes() || acpi_result_to_string(&result->package.elements[i])) + return 1; + } + snprintf(get_buffer_end(), get_avail_bytes(), "]"); + } else { + snprintf(get_buffer_end(), get_avail_bytes(), + "Object type 0x%x\n", result->type); + } + + // return 0 if there are still bytes available, 1 otherwise + return !get_avail_bytes(); +} + +/** +@param method The full name of ACPI method to call +@param argc The number of parameters +@param argv A pre-allocated array of arguments of type acpi_object +*/ +static void do_acpi_call(const char * method, int argc, union acpi_object *argv) +{ + acpi_status status; + acpi_handle handle; + struct acpi_object_list arg; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Calling %s\n", method); +#endif + + // get the handle of the method, must be a fully qualified path + status = acpi_get_handle(NULL, (acpi_string) method, &handle); + + if (ACPI_FAILURE(status)) + { + snprintf(result_buffer, BUFFER_SIZE, "Error: %s", acpi_format_exception(status)); + printk(KERN_ERR "acpi_call: Cannot get handle: %s\n", result_buffer); + return; + } + + // prepare parameters + arg.count = argc; + arg.pointer = argv; + + // call the method + status = acpi_evaluate_object(handle, NULL, &arg, &buffer); + if (ACPI_FAILURE(status)) + { + snprintf(result_buffer, BUFFER_SIZE, "Error: %s", acpi_format_exception(status)); + printk(KERN_ERR "acpi_call: Method call failed: %s\n", result_buffer); + return; + } + + // reset the result buffer + *result_buffer = '\0'; + acpi_result_to_string(buffer.pointer); + kfree(buffer.pointer); + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Call successful: %s\n", result_buffer); +#endif +} + +/** Decodes 2 hex characters to an u8 int +*/ +u8 decodeHex(char *hex) { + char buf[3] = { hex[0], hex[1], 0}; + return (u8) simple_strtoul(buf, NULL, 16); +} + +/** Parses method name and arguments +@param input Input string to be parsed. Modified in the process. +@param nargs Set to number of arguments parsed (output) +@param args +*/ +static char *parse_acpi_args(char *input, int *nargs, union acpi_object **args) +{ + char *s = input; + int i; + + *nargs = 0; + *args = NULL; + + // the method name is separated from the arguments by a space + while (*s && *s != ' ') + s++; + // if no space is found, return 0 arguments + if (*s == 0) + return input; + + *args = (union acpi_object *) kmalloc(MAX_ACPI_ARGS * sizeof(union acpi_object), GFP_KERNEL); + if (!*args) { + printk(KERN_ERR "acpi_call: unable to allocate buffer\n"); + return NULL; + } + + while (*s) { + if (*s == ' ') { + if (*nargs == 0) + *s = 0; // change first space to nul + ++ *nargs; + ++ s; + } else { + union acpi_object *arg = (*args) + (*nargs - 1); + if (*s == '"') { + // decode string + arg->type = ACPI_TYPE_STRING; + arg->string.pointer = ++s; + arg->string.length = 0; + while (*s && *s++ != '"') + arg->string.length ++; + // skip the last " + if (*s == '"') + ++s; + } else if (*s == 'b') { + // decode buffer - bXXXX + char *p = ++s; + int len = 0, i; + u8 *buf = NULL; + + while (*p && *p!=' ') + p++; + + len = p - s; + if (len % 2 == 1) { + printk(KERN_ERR "acpi_call: buffer arg%d is not multiple of 8 bits\n", *nargs); + --*nargs; + goto err; + } + len /= 2; + + buf = (u8*) kmalloc(len, GFP_KERNEL); + if (!buf) { + printk(KERN_ERR "acpi_call: unable to allocate buffer\n"); + --*nargs; + goto err; + } + for (i=0; itype = ACPI_TYPE_BUFFER; + arg->buffer.pointer = buf; + arg->buffer.length = len; + } else if (*s == '{') { + // decode buffer - { b1, b2 ...} + u8 *buf = temporary_buffer; + arg->type = ACPI_TYPE_BUFFER; + arg->buffer.pointer = buf; + arg->buffer.length = 0; + while (*s && *s++ != '}') { + if (buf >= temporary_buffer + sizeof(temporary_buffer)) { + printk(KERN_ERR "acpi_call: buffer arg%d is truncated because the buffer is full\n", *nargs); + // clear remaining arguments + while (*s && *s != '}') + ++s; + break; + } + else if (*s >= '0' && *s <= '9') { + // decode integer into buffer + arg->buffer.length ++; + if (s[0] == '0' && s[1] == 'x') + *buf++ = simple_strtol(s+2, 0, 16); + else + *buf++ = simple_strtol(s, 0, 10); + } + // skip until space or comma or '}' + while (*s && *s != ' ' && *s != ',' && *s != '}') + ++s; + } + // store the result in new allocated buffer + buf = (u8*) kmalloc(arg->buffer.length, GFP_KERNEL); + if (!buf) { + printk(KERN_ERR "acpi_call: unable to allocate buffer\n"); + --*nargs; + goto err; + } + memcpy(buf, temporary_buffer, arg->buffer.length); + arg->buffer.pointer = buf; + } else { + // decode integer, N or 0xN + arg->type = ACPI_TYPE_INTEGER; + if (s[0] == '0' && s[1] == 'x') { + arg->integer.value = simple_strtol(s+2, 0, 16); + } else { + arg->integer.value = simple_strtol(s, 0, 10); + } + while (*s && *s != ' ') { + ++s; + } + } + } + } + + return input; + +err: + for (i=0; i<*nargs; i++) + if ((*args)[i].type == ACPI_TYPE_BUFFER && (*args)[i].buffer.pointer) + kfree((*args)[i].buffer.pointer); + kfree(*args); + return NULL; +} + +/** procfs write callback. Called when writing into /proc/acpi/call. +*/ +#ifdef HAVE_PROC_CREATE +static ssize_t acpi_proc_write( struct file *filp, const char __user *buff, + size_t len, loff_t *data ) +#else +static int acpi_proc_write( struct file *filp, const char __user *buff, + unsigned long len, void *data ) +#endif +{ + union acpi_object *args; + int nargs, i; + char *method; + + memset(input_buffer, 0, INPUT_BUFFER_SIZE); + if (len > sizeof(input_buffer) - 1) { +#ifdef HAVE_PROC_CREATE + printk(KERN_ERR "acpi_call: Input too long! (%zu)\n", len); +#else + printk(KERN_ERR "acpi_call: Input too long! (%lu)\n", len); +#endif + return -ENOSPC; + } + + if (copy_from_user( input_buffer, buff, len )) { + return -EFAULT; + } + input_buffer[len] = '\0'; + if (input_buffer[len-1] == '\n') + input_buffer[len-1] = '\0'; + + method = parse_acpi_args(input_buffer, &nargs, &args); + if (method) { + do_acpi_call(method, nargs, args); + if (args) { + for (i=0; i count) { + // user buffer is too small + ret = 0; + } else if(*off == len + 1) { + // we're done + ret = 0; + result_buffer[0] = '\0'; + } else { + // output the current result buffer + ret = simple_read_from_buffer(buff, count, off, result_buffer, len + 1); + *off = ret; + } + + return ret; +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) +static struct proc_ops proc_acpi_operations = { + .proc_read = acpi_proc_read, + .proc_write = acpi_proc_write, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 13, 0) + .proc_lseek = default_llseek, +#endif +}; +#else +static struct file_operations proc_acpi_operations = { + .owner = THIS_MODULE, + .read = acpi_proc_read, + .write = acpi_proc_write, +}; +#endif + +#else +static int acpi_proc_read(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = 0; + + if (off > 0) { + *eof = 1; + return 0; + } + + // output the current result buffer + len = strlen(result_buffer); + memcpy(page, result_buffer, len + 1); + + // initialize the result buffer for later + strcpy(result_buffer, "not called"); + + return len; +} +#endif + +/** module initialization function */ +static int __init init_acpi_call(void) +{ +#ifdef HAVE_PROC_CREATE + struct proc_dir_entry *acpi_entry = proc_create("call", + 0660, + acpi_root_dir, + &proc_acpi_operations); +#else + struct proc_dir_entry *acpi_entry = create_proc_entry("call", 0660, acpi_root_dir); +#endif + + strcpy(result_buffer, "not called"); + + if (acpi_entry == NULL) { + printk(KERN_ERR "acpi_call: Couldn't create proc entry\n"); + return -ENOMEM; + } + +#ifndef HAVE_PROC_CREATE + acpi_entry->write_proc = acpi_proc_write; + acpi_entry->read_proc = acpi_proc_read; +#endif + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Module loaded successfully\n"); +#endif + + return 0; +} + +static void __exit unload_acpi_call(void) +{ + remove_proc_entry("call", acpi_root_dir); + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Module unloaded successfully\n"); +#endif +} + +module_init(init_acpi_call); +module_exit(unload_acpi_call); + + diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.ko b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.ko new file mode 100644 index 0000000..2fc9dfc Binary files /dev/null and b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.ko differ diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.mod b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.mod new file mode 100644 index 0000000..e6551ea --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.mod @@ -0,0 +1 @@ +/home/mimillie/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.o diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.mod.c b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.mod.c new file mode 100644 index 0000000..29e5a8e --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.mod.c @@ -0,0 +1,36 @@ +#include +#define INCLUDE_VERMAGIC +#include +#include +#include +#include +#include + +#ifdef CONFIG_UNWINDER_ORC +#include +ORC_HEADER; +#endif + +BUILD_SALT; +BUILD_LTO_INFO; + +MODULE_INFO(vermagic, VERMAGIC_STRING); +MODULE_INFO(name, KBUILD_MODNAME); + +__visible struct module __this_module +__section(".gnu.linkonce.this_module") = { + .name = KBUILD_MODNAME, + .init = init_module, +#ifdef CONFIG_MODULE_UNLOAD + .exit = cleanup_module, +#endif + .arch = MODULE_ARCH_INIT, +}; + +#ifdef CONFIG_RETPOLINE +MODULE_INFO(retpoline, "Y"); +#endif + +MODULE_INFO(depends, ""); + +MODULE_INFO(rhelversion, "9.99"); diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.mod.o b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.mod.o new file mode 100644 index 0000000..fe450cc Binary files /dev/null and b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.mod.o differ diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.o b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.o new file mode 100644 index 0000000..2393e44 Binary files /dev/null and b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.o differ diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/dkms.conf.in b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/dkms.conf.in new file mode 100644 index 0000000..b927370 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/dkms.conf.in @@ -0,0 +1,7 @@ +PACKAGE_NAME="acpi_call" +PACKAGE_VERSION="@@VERSION@@" +MAKE="KDIR=/lib/modules/${kernelver}/build make" +CLEAN="make clean" +BUILT_MODULE_NAME[0]="acpi_call" +AUTOINSTALL="yes" +DEST_MODULE_LOCATION[0]="/extra" diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/doinst.sh b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/doinst.sh new file mode 100644 index 0000000..6510094 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/doinst.sh @@ -0,0 +1,4 @@ +# Re-generate modules.dep and map files. +if [ -x sbin/depmod ]; then + chroot . /sbin/depmod -a @KERNEL@ 1> /dev/null 2> /dev/null +fi diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/asus1215n.sh b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/asus1215n.sh new file mode 100644 index 0000000..aedf10e --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/asus1215n.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Power control for Asus 1215N Optimus +# by Pete Eberlein + +if ! lsmod | grep -q acpi_call; then + echo "Error: acpi_call module not loaded" + exit +fi + +acpi_call () { + echo "$*" > /proc/acpi/call + cat /proc/acpi/call +} + + +case "$1" in +off) + echo _DSM $(acpi_call "\_SB.PCI0.P0P4.GFX0._DSM" \ + "{0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47," \ + "0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0}" \ + "0x100 0x1A {0x1,0x0,0x0,0x3}") + # ok to turn off: Buffer {0x59 0x0 0x0 0x11} + # is already off: Buffer {0x41 0x0 0x0 0x11} + echo _PS3 $(acpi_call "\_SB.PCI0.P0P4.GFX0._PS3") +;; +on) + echo _PS0 $(acpi_call "\_SB.PCI0.P0P4.GFX0._PS0") +;; +*) + echo "Usage: $0 [on|off]" +esac + + +echo P3MO $(acpi_call "\_SB.PCI0.P0P4.GFX0.P3MO") +echo DGPS $(acpi_call "\_SB.PCI0.P0P4.GFX0.DGPS") +PSC=$(acpi_call "\_SB.PCI0.P0P4.GFX0._PSC") +echo _PSC ${PSC} +case "$PSC" in +0x0) + PSC="on" +;; +0x3) + PSC="off" +;; +esac +echo "Asus 1215N Optimus appears to be ${PSC}" + + diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/dellL702X.sh b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/dellL702X.sh new file mode 100644 index 0000000..b4a8a1c --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/dellL702X.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# Power control for Dell L702X +# by Jos Hickson +# adapted from "Power control for DELL XPS L702X by Pete Eberlein" + +if ! lsmod | grep -q acpi_call; then + echo "Error: acpi_call module not loaded" + exit +fi + +acpi_call () { + echo "$*" > /proc/acpi/call + cat /proc/acpi/call +} + + +case "$1" in +off) + echo _DSM $(acpi_call "\_SB.PCI0.PEG0.PEGP._DSM" \ + "{0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47," \ + "0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0}" \ + "0x100 0x1A {0x1,0x0,0x0,0x3}") + # ok to turn off: Buffer {0x59 0x0 0x0 0x11} + # is already off: Buffer {0x41 0x0 0x0 0x11} + echo _PS3 $(acpi_call "\_SB.PCI0.PEG0.PEGP._PS3") +;; +on) + echo _PS0 $(acpi_call "\_SB.PCI0.PEG0.PEGP._PS0") +;; +*) + echo "Usage: $0 [on|off]" +esac + + +PSC=$(acpi_call "\_SB.PCI0.PEG0.PEGP._PSC") +#echo _PSC ${PSC} +case "$PSC" in +0x0) + PSC="on" +;; +0x3) + PSC="off" +;; +esac +echo "Dell L702X Optimus appears to be ${PSC}" + diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/graphic_card.sh b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/graphic_card.sh new file mode 100644 index 0000000..289fc66 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/graphic_card.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +usage="Usage: ./graphic_card [option] \nOPTION: \n- off \n- on \n- show" + +if [ $# -ne 1 ]; then + echo -e $usage +else + if lsmod | grep -q acpi_call; then + echo 'acpi_call found' + else + echo 'acpi_call found, importing it' + sudo insmod /home/sush/dev/c/acpi_call/acpi_call.ko + fi + if [ $1 = 'on' ]; then + echo '\_SB.PCI0.P0P2.PEGP._ON' > /proc/acpi/call + echo 'Discrete graphic card ENABLED !' + elif [ $1 = 'off' ]; then + echo '\_SB.PCI0.P0P2.PEGP._OFF' > /proc/acpi/call + echo 'Discrete graphic card DISABLED !' + elif [ $1 = 'show' ]; then + grep rate /proc/acpi/battery/BAT1/state + else + echo -e $usage + fi +fi diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/m11xr2.sh b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/m11xr2.sh new file mode 100644 index 0000000..08eafb7 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/m11xr2.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Based on m11xr2hack by George Shearer + +if ! lsmod | grep -q acpi_call; then + echo "Error: acpi_call module not loaded" + exit +fi + +acpi_call () { + echo "$*" > /proc/acpi/call + cat /proc/acpi/call +} + + +case "$1" in +off) + echo NVOP $(acpi_call "\_SB.PCI0.P0P2.PEGP.NVOP 0 0x100 0x1A {255,255,255,255}") + echo _PS3 $(acpi_call "\_SB.PCI0.P0P2.PEGP._PS3") +;; +on) + echo _PS0 $(acpi_call "\_SB.PCI0.P0P2.PEGP._PS0") +;; +*) + echo "Usage: $0 [on|off]" +;; +esac + diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/turn_off_gpu.sh b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/turn_off_gpu.sh new file mode 100644 index 0000000..019d25d --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/examples/turn_off_gpu.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +if lsmod | grep -q acpi_call; then +methods=" +\_SB_.PCI0.GFX0.ATPX +\_SB.PCI0.P0P1.VGA._OFF +\_SB.PCI0.P0P2.VGA._OFF +\_SB_.PCI0.OVGA.ATPX +\_SB_.PCI0.OVGA.XTPX +\_SB.PCI0.P0P3.PEGP._OFF +\_SB.PCI0.P0P2.PEGP._OFF +\_SB.PCI0.P0P1.PEGP._OFF +\_SB.PCI0.MXR0.MXM0._OFF +\_SB.PCI0.PEG1.GFX0._OFF +\_SB.PCI0.PEG0.GFX0.DOFF +\_SB.PCI0.PEG1.GFX0.DOFF +\_SB.PCI0.PEG0.PEGP._OFF +\_SB.PCI0.XVR0.Z01I.DGOF +\_SB.PCI0.PEGR.GFX0._OFF +\_SB.PCI0.PEG.VID._OFF +\_SB.PCI0.PEG0.VID._OFF +\_SB.PCI0.P0P2.DGPU._OFF +\_SB.PCI0.P0P4.DGPU.DOFF +\_SB.PCI0.IXVE.IGPU.DGOF +\_SB.PCI0.RP00.VGA._PS3 +\_SB.PCI0.RP00.VGA.P3MO +\_SB.PCI0.GFX0.DSM._T_0 +\_SB.PCI0.LPC.EC.PUBS._OFF +\_SB.PCI0.P0P2.NVID._OFF +\_SB.PCI0.P0P2.VGA.PX02 +\_SB_.PCI0.PEGP.DGFX._OFF +\_SB_.PCI0.VGA.PX02 +\_SB.PCI0.PEG0.PEGP.SGOF +\_SB.PCI0.AGP.VGA.PX02 +\_SB.PCI0.RP05.PXSX._OFF +\_SB.PCI0.GPP0.PG00._OFF +\_SB_.PC00.PEG1.PEGP._PS3 +\_SB_.PCI0.RP05.PEGP._OFF +" + +for m in $methods; do + printf "Trying %s: " "$m" + echo "$m" > /proc/acpi/call + result=$(cat /proc/acpi/call) + case "$result" in + Error*) + echo "failed" + ;; + *) + echo "works!" + # break # try out outher methods too + ;; + esac +done + +else + echo "The acpi_call module is not loaded, try running 'modprobe acpi_call' or 'insmod acpi_call.ko' as root" + exit 1 +fi diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/modules.order b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/modules.order new file mode 100644 index 0000000..e6551ea --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/modules.order @@ -0,0 +1 @@ +/home/mimillie/rpmbuild/BUILD/akmod-acpi_call-1.2.2/acpi_call.o diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/slack-desc b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/slack-desc new file mode 100644 index 0000000..55493d8 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +acpi_call: acpi_call (enable ACPI method calls through /proc) +acpi_call: +acpi_call: A kernel simple module that enables you to call ACPI methods +acpi_call: by writing the method name followed by arguments to /proc/acpi/call. +acpi_call: +acpi_call: WARNING: +acpi_call: This driver uses undocumented features and direct hardware access. +acpi_call: It thus cannot be guaranteed to work, and may cause arbitrary damage +acpi_call: (especially to models on which it wasn't tested). +acpi_call: +acpi_call: Homepage: https://github.com/teleshoes/acpi_call diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/support/query_dsdt.pl b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/support/query_dsdt.pl new file mode 100644 index 0000000..8dcd674 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/support/query_dsdt.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl +use strict; +use Getopt::Long; +use Data::Dumper; + +my ($dir,$debug,$mytokens); +$dir = '.'; +GetOptions( + 'd|dir:s' => \$dir, + 'debug:s' => \$debug, + 't|tokens:s' => \$mytokens, + ); + +my $models; + +my @tokens = ( + 'MXMX','MXDS','_DSM', + '0xA6, 0xFA, 0xDD, 0x3D, 0x1B, 0x36, 0xB4, 0x4E', + '0xA4, 0x24, 0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53'); + +if (defined $mytokens) { + @tokens = (); + foreach my $mytoken (split(":",$mytokens)) { + push @tokens, $mytoken; + } +} + +opendir DIR,$dir or die $!; +my $file; +my $count = 0; +while (( defined($file = readdir(DIR)) )) { + if ($file =~ /\.dsl$/) { + analyse_file($dir,$file); + } + last if ($count++ > $debug && defined($debug)); +} + +foreach my $file (sort keys %$models) { + my $num = scalar keys %{$models->{$file}}; $num = sprintf("%02d",$num); + print "$num $file \{"; + foreach my $token (sort keys %{$models->{$file}}) { + my $value = $models->{$file}{$token}; + print "\t$token => $value "; + } + print "\}\n"; +} +$DB::single=1;1; +print STDERR Dumper($models) if ($debug); + +######################################## + +sub analyse_file { + my $dir = shift; + my $file = shift; + my $param = shift; + + open FILE, "$dir/$file" or die $!; + while () { + foreach my $token (@tokens) { + my $regexp = qr/${token}/; + if ($_ =~ /$regexp/g) { + $models->{$file}{$token}++; + } + } + } + close FILE; +} diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/support/windump_hack/windump.c b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/support/windump_hack/windump.c new file mode 100644 index 0000000..6246f06 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/support/windump_hack/windump.c @@ -0,0 +1,285 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int format = ZPixmap; + +XImage * +CaptRoot(Display * dpy, int screen) +{ + unsigned long swaptest = 1; + XColor *colors; + unsigned buffer_size; + int win_name_size; + int header_size; + int ncolors, i; + char *win_name; + Bool got_win_name; + XWindowAttributes win_info; + XImage *image; + int absx, absy, x, y; + unsigned width, height; + int dwidth, dheight; + int bw; + Window dummywin; + +#if 0 + int transparentOverlays , multiVis; + int numVisuals; + XVisualInfo *pVisuals; + int numOverlayVisuals; + OverlayInfo *pOverlayVisuals; + int numImageVisuals; + XVisualInfo **pImageVisuals; + list_ptr vis_regions; /* list of regions to read from */ + list_ptr vis_image_regions ; + Visual vis_h,*vis ; +#endif + int allImage = 0 ; + + Window window=RootWindow (dpy, screen); + + if (!XGetWindowAttributes(dpy, window, &win_info)) + { fprintf(stderr,"Can't get target window attributes."); exit(1); } + + absx=0; absy=0; + win_info.x = 0; + win_info.y = 0; + width = win_info.width; + height = win_info.height; + bw = 0; + + dwidth = DisplayWidth (dpy, screen); + dheight = DisplayHeight (dpy, screen); + + XFetchName(dpy, window, &win_name); + if (!win_name || !win_name[0]) { + win_name = "xwdump"; + got_win_name = False; + } else { + got_win_name = True; + } + + /* sizeof(char) is included for the null string terminator. */ + win_name_size = strlen(win_name) + sizeof(char); + + /* + * Snarf the pixmap with XGetImage. + */ + + x = absx - win_info.x; + y = absy - win_info.y; +#if 0 + multiVis = GetMultiVisualRegions(dpy,RootWindow(dpy, screen),absx,absy, + width,height,&transparentOverlays,&numVisuals,&pVisuals, + &numOverlayVisuals,&pOverlayVisuals,&numImageVisuals, + &pImageVisuals,&vis_regions,&vis_image_regions,&allImage) ; + if (on_root || multiVis) + { + if (!multiVis) + image = XGetImage (dpy, RootWindow(dpy, screen), absx, absy, + width, height, AllPlanes, format); + else + image = ReadAreaToImage(dpy, RootWindow(dpy, screen), absx, absy, + width, height, + numVisuals,pVisuals,numOverlayVisuals,pOverlayVisuals, + numImageVisuals, pImageVisuals,vis_regions, + vis_image_regions,format,allImage); + } + else +#endif + image = XGetImage (dpy, window, x, y, width, height, + AllPlanes, format); + if (!image) { + fprintf (stderr, "unable to get image at %dx%d+%d+%d\n", + width, height, x, y); + exit (1); + } + + //if (add_pixel_value != 0) XAddPixel (image, add_pixel_value); + + return image; +} + +Window CreateWindow(Display * dpy, int screen, int width, int height) +{ + Window win = 0; + win = XCreateWindow(dpy, RootWindow(dpy, screen), + 0, 0, width, height, + 0, + 24, + InputOutput, + DefaultVisual(dpy, screen), + //CWBorderPixel|CWBackPixel|CWColormap|CWEventMask|CWBitGravity, + 0, + 0); + + XSelectInput(dpy, win, StructureNotifyMask|ButtonPressMask|ButtonReleaseMask); + + XMapWindow(dpy, win); + return win; +} + +void DrawImage(Display * dpy, Window win, XImage * image) +{ + static GC gc; + if(win!=0) + { + if(gc==0) + { + XGCValues gc_val; + gc = XCreateGC (dpy, win, GCForeground|GCBackground, &gc_val); + } + /*for(i=0;i<100;i++) + { + image->data*/ + XPutImage (dpy, win, gc, image, 0, 0, 0, 0, 1024, 768); + } +} + +void createShmImage(int w, int h, XShmSegmentInfo * sinfo, XShmSegmentInfo * tinfo, Display * sdpy, Display * tdpy, int sscr, int tscr, XImage ** simage, XImage ** timage) +{ + sinfo->shmid=tinfo->shmid=shmget(IPC_PRIVATE,w*h*sizeof(unsigned),IPC_CREAT|0666 ); + sinfo->shmaddr=tinfo->shmaddr=(char*)shmat(sinfo->shmid,0,0); + sinfo->readOnly=tinfo->readOnly=False; + printf("%d %d\n",DefaultDepth(sdpy,sscr),DefaultDepth(tdpy,tscr)); + *simage = XShmCreateImage( + sdpy, DefaultVisual(sdpy,sscr), DefaultDepth(sdpy,sscr), + ZPixmap/*format*/, + (char *)sinfo->shmaddr, sinfo, + w,h /*width,height*/ + ); + *timage = XShmCreateImage( + tdpy, DefaultVisual(tdpy,tscr), DefaultDepth(tdpy,tscr), + ZPixmap/*format*/, + (char *)tinfo->shmaddr, tinfo, + w,h /*width,height*/ + ); + XShmAttach(sdpy, sinfo); + XShmAttach(tdpy, tinfo); +} + +void drawMouse(XImage * img, int xm, int ym) +{ + int x,y,x1,y1,x2,y2,w,h; + + unsigned * data = (unsigned *)(img->data); + + w=img->width; + h=img->height; + + x=xm; if(x<0) x=0; if(x>w) x=w-1; + y=ym; if(y<0) y=0; if(y>h) y=h-1; + x1=xm-5; if(x1<0) x1=0; if(x1>w) x1=w; + x2=xm+6; if(x2<0) x2=0; if(x2>w) x2=w; + for(x=x1;xw) x=w-1; + y=ym; if(y<0) y=0; if(y>h) y=h-1; + y1=ym-5; if(y1<0) y1=0; if(y1>h) y1=h; + y2=ym+6; if(y2<0) y2=0; if(y2>h) y2=h; + for(y=y1;ywidth, simage->height, simage->depth); + //printf("timage: w:%d h:%d d:%d\n",timage->width, timage->height, timage->depth); + if(!emulate_events) + { + Window rwin,cwin; + int xmouse,ymouse,x,y,mask; + XQueryPointer(sdpy,swin,&rwin,&cwin,&xmouse,&ymouse,&x,&y,&mask); + drawMouse(timage, xmouse, ymouse); + } + + XShmPutImage (tdpy, twin, tgc, timage, 0, 0, 0, 0, timage->width, timage->height, False); + //XPutImage (tdpy, twin, tgc, timage, 0, 0, 0, 0, timage->width, timage->height); + } + //XFlush(sdpy); + XFlush(tdpy); +// getchar(); + } +} diff --git a/rpmbuild/BUILD/akmod-acpi_call-1.2.2/support/windump_hack/xorg.conf b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/support/windump_hack/xorg.conf new file mode 100644 index 0000000..21c0090 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call-1.2.2/support/windump_hack/xorg.conf @@ -0,0 +1,83 @@ +# nvidia-xconfig: X configuration file generated by nvidia-xconfig +# nvidia-xconfig: version 270.41.06 (buildmeister@swio-display-x86-rhel47-08.nvidia.com) Mon Apr 18 15:14:00 PDT 2011 + +Section "ServerLayout" + Identifier "Layout0" + Screen "Screen0" + Screen "Screen1" RightOf "Screen0" + InputDevice "Keyboard0" "SendCoreEvents" + #InputDevice "Keyboard0" "CoreKeyboard" + InputDevice "Mouse0" "SendCoreEvents" + #InputDevice "Mouse0" "CorePointer" +EndSection + +#Section "ServerFlags" +# Option "AllowEmptyInput" "no" +#EndSection + +Section "Files" +EndSection + +Section "InputDevice" + # generated from default + Identifier "Mouse0" + Driver "mouse" + Option "Protocol" "auto" + Option "Device" "/dev/psaux" + Option "Emulate3Buttons" "no" + Option "ZAxisMapping" "4 5" +EndSection + +Section "InputDevice" + # generated from default + Identifier "Keyboard0" + Driver "kbd" +EndSection + +Section "Monitor" + Identifier "Monitor0" + VendorName "Unknown" + ModelName "Unknown" + HorizSync 28.0 - 73.0 + VertRefresh 43.0 - 72.0 + Option "DPMS" +EndSection + +Section "Device" + Identifier "Device1" + Driver "nvidia" + VendorName "NVIDIA Corporation" + BusID "PCI:1:0:0" + Option "IgnoreEDID" + #Screen 0 +EndSection + +Section "Device" + Identifier "Device0" + Driver "intel" + VendorName "onboard" + BusID "PCI:0:2:0" + #Screen 1 +EndSection + +Section "Screen" + Identifier "Screen1" + Device "Device0" + Monitor "Monitor0" + DefaultDepth 24 + SubSection "Display" + Depth 24 + EndSubSection +EndSection + +Section "Screen" + Identifier "Screen0" + Device "Device1" + Monitor "Monitor0" + DefaultDepth 24 + SubSection "Display" + Depth 24 + Modes "1024x768" + EndSubSection +EndSection + diff --git a/rpmbuild/BUILD/akmod-acpi_call/Makefile b/rpmbuild/BUILD/akmod-acpi_call/Makefile new file mode 100644 index 0000000..f9fe03d --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call/Makefile @@ -0,0 +1,18 @@ +obj-m := acpi_call.o + +KVERSION := $(shell uname -r) +KDIR := /lib/modules/$(KVERSION)/build +PWD := $(shell pwd) + +default: + $(MAKE) -C $(KDIR) M=$(PWD) modules + +clean: + $(MAKE) -C $(KDIR) M=$(PWD) clean + +install: + $(MAKE) -C $(KDIR) M=$(PWD) modules_install + +load: + -/sbin/rmmod acpi_call + /sbin/insmod acpi_call.ko diff --git a/rpmbuild/BUILD/akmod-acpi_call/README.md b/rpmbuild/BUILD/akmod-acpi_call/README.md new file mode 100644 index 0000000..3090843 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call/README.md @@ -0,0 +1,73 @@ +A kernel simple module that enables you to call ACPI methods by writing the +method name followed by arguments to `/proc/acpi/call`. + +This module is to be considered a proof-of-concept and has been superseeded by +projects like [bbswitch](https://github.com/Bumblebee-Project/bbswitch). It +allows you to tamper with your system and should be used with caution. + +Want to use acpi_call via graphic interface? [Click here](https://github.com/mkottman/acpi_call/#graphic-interface) + +Usage: + + echo '' | sudo tee /proc/acpi/call + +You can then retrieve the result of the call by checking your dmesg or: + + sudo cat /proc/acpi/call + +An example to turn off discrete graphics card in a dual graphics environment +(like NVIDIA Optimus): + + # turn off discrete graphics card + echo '\_SB.PCI0.PEG1.GFX0.DOFF' > /proc/acpi/call + # turn it back on + echo '\_SB.PCI0.PEG1.GFX0.DON' > /proc/acpi/call + +These work on my ASUS K52J notebook, but may not work for you. For a list of +methods to try, see http://linux-hybrid-graphics.blogspot.com/ or try running +the provided script `examples/turn_off_gpu.sh` + +It SHOULD be ok to test all of the methods, until you see a drop in battery +drain rate (`grep rate /proc/acpi/battery/BAT0/state`), however it comes +with NO WARRANTY - it may hang your computer/laptop, fail to work, etc. + +You can pass parameters to `acpi_call` by writing them after the method, +separated by single space. Currently, you can pass the following parameter +types: + +* ACPI_INTEGER - by writing NNN or 0xNNN, where NNN is an integer/hex +* ACPI_STRING - by enclosing the string in quotes: "hello, world" +* ACPI_BUFFER - by writing bXXXX, where XXXX is a hex string without spaces, + or by writing { b1, b2, b3, b4 }, where b1-4 are integers + +The status after a call can be read back from `/proc/acpi/call`: + +* 'not called' - nothing to report +* 'Error: ' - the call failed +* '0xNN' - the call succeeded, and returned an integer +* '"..."' - the call succeeded, and returned a string +* '{0xNN, ...}' - the call succeeded, and returned a buffer +* '[...]' - the call succeeded, and returned a package which may contain the + above types (integer, string and buffer) and other package types + + +#### Graphic interface + +Found this too difficult? Try to use these programs provided by Marco Dalla Libera and do it via graphic interface: + +* [acpi_call_GUI (Ubuntu and other debian-based distributions)](http://marcodallas.github.io/acpi_call_GUI/) +* [acpi_call_GUI_Fedora (Fedora version)](https://github.com/marcoDallas/acpi_call_GUI_Fedora) + +*** + +Copyright (c) 2010: Michal Kottman + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. diff --git a/rpmbuild/BUILD/akmod-acpi_call/acpi_call.c b/rpmbuild/BUILD/akmod-acpi_call/acpi_call.c new file mode 100644 index 0000000..3025d97 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call/acpi_call.c @@ -0,0 +1,391 @@ +/* Copyright (c) 2010: Michal Kottman */ + +#include +#include +#include +#include +#include +#include +#include + +MODULE_LICENSE("GPL"); + +/* Uncomment the following line to enable debug messages */ +/* +#define DEBUG +*/ + +#define BUFFER_SIZE 256 +#define MAX_ACPI_ARGS 16 + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) +#define HAVE_PROC_CREATE +#endif + +extern struct proc_dir_entry *acpi_root_dir; + +static char result_buffer[BUFFER_SIZE]; + +static u8 temporary_buffer[BUFFER_SIZE]; + +static size_t get_avail_bytes(void) { + return BUFFER_SIZE - strlen(result_buffer); +} +static char *get_buffer_end(void) { + return result_buffer + strlen(result_buffer); +} + +/** Appends the contents of an acpi_object to the result buffer +@param result An acpi object holding result data +@returns 0 if the result could fully be saved, a higher value otherwise +*/ +static int acpi_result_to_string(union acpi_object *result) { + if (result->type == ACPI_TYPE_INTEGER) { + snprintf(get_buffer_end(), get_avail_bytes(), + "0x%x", (int)result->integer.value); + } else if (result->type == ACPI_TYPE_STRING) { + snprintf(get_buffer_end(), get_avail_bytes(), + "\"%*s\"", result->string.length, result->string.pointer); + } else if (result->type == ACPI_TYPE_BUFFER) { + int i; + // do not store more than data if it does not fit. The first element is + // just 4 chars, but there is also two bytes from the curly brackets + int show_values = min((size_t)result->buffer.length, get_avail_bytes() / 6); + + sprintf(get_buffer_end(), "{"); + for (i = 0; i < show_values; i++) + sprintf(get_buffer_end(), + i == 0 ? "0x%02x" : ", 0x%02x", result->buffer.pointer[i]); + + if (result->buffer.length > show_values) { + // if data was truncated, show a trailing comma if there is space + snprintf(get_buffer_end(), get_avail_bytes(), ","); + return 1; + } else { + // in case show_values == 0, but the buffer is too small to hold + // more values (i.e. the buffer cannot have anything more than "{") + snprintf(get_buffer_end(), get_avail_bytes(), "}"); + } + } else if (result->type == ACPI_TYPE_PACKAGE) { + int i; + sprintf(get_buffer_end(), "["); + for (i=0; ipackage.count; i++) { + if (i > 0) + snprintf(get_buffer_end(), get_avail_bytes(), ", "); + + // abort if there is no more space available + if (!get_avail_bytes() || acpi_result_to_string(&result->package.elements[i])) + return 1; + } + snprintf(get_buffer_end(), get_avail_bytes(), "]"); + } else { + snprintf(get_buffer_end(), get_avail_bytes(), + "Object type 0x%x\n", result->type); + } + + // return 0 if there are still bytes available, 1 otherwise + return !get_avail_bytes(); +} + +/** +@param method The full name of ACPI method to call +@param argc The number of parameters +@param argv A pre-allocated array of arguments of type acpi_object +*/ +static void do_acpi_call(const char * method, int argc, union acpi_object *argv) +{ + acpi_status status; + acpi_handle handle; + struct acpi_object_list arg; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Calling %s\n", method); +#endif + + // get the handle of the method, must be a fully qualified path + status = acpi_get_handle(NULL, (acpi_string) method, &handle); + + if (ACPI_FAILURE(status)) + { + snprintf(result_buffer, BUFFER_SIZE, "Error: %s", acpi_format_exception(status)); + printk(KERN_ERR "acpi_call: Cannot get handle: %s\n", result_buffer); + return; + } + + // prepare parameters + arg.count = argc; + arg.pointer = argv; + + // call the method + status = acpi_evaluate_object(handle, NULL, &arg, &buffer); + if (ACPI_FAILURE(status)) + { + snprintf(result_buffer, BUFFER_SIZE, "Error: %s", acpi_format_exception(status)); + printk(KERN_ERR "acpi_call: Method call failed: %s\n", result_buffer); + return; + } + + // reset the result buffer + *result_buffer = '\0'; + acpi_result_to_string(buffer.pointer); + kfree(buffer.pointer); + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Call successful: %s\n", result_buffer); +#endif +} + +/** Decodes 2 hex characters to an u8 int +*/ +u8 decodeHex(char *hex) { + char buf[3] = { hex[0], hex[1], 0}; + return (u8) simple_strtoul(buf, NULL, 16); +} + +/** Parses method name and arguments +@param input Input string to be parsed. Modified in the process. +@param nargs Set to number of arguments parsed (output) +@param args +*/ +static char *parse_acpi_args(char *input, int *nargs, union acpi_object **args) +{ + char *s = input; + + *nargs = 0; + *args = NULL; + + // the method name is separated from the arguments by a space + while (*s && *s != ' ') + s++; + // if no space is found, return 0 arguments + if (*s == 0) + return input; + + *args = (union acpi_object *) kmalloc(MAX_ACPI_ARGS * sizeof(union acpi_object), GFP_KERNEL); + + while (*s) { + if (*s == ' ') { + if (*nargs == 0) + *s = 0; // change first space to nul + ++ *nargs; + ++ s; + } else { + union acpi_object *arg = (*args) + (*nargs - 1); + if (*s == '"') { + // decode string + arg->type = ACPI_TYPE_STRING; + arg->string.pointer = ++s; + arg->string.length = 0; + while (*s && *s++ != '"') + arg->string.length ++; + // skip the last " + ++s; + } else if (*s == 'b') { + // decode buffer - bXXXX + char *p = ++s; + int len = 0, i; + u8 *buf = NULL; + + while (*p && *p!=' ') + p++; + + len = p - s; + if (len % 2 == 1) { + printk(KERN_ERR "acpi_call: buffer arg%d is not multiple of 8 bits\n", *nargs); + return NULL; + } + len /= 2; + + buf = (u8*) kmalloc(len, GFP_KERNEL); + for (i=0; itype = ACPI_TYPE_BUFFER; + arg->buffer.pointer = buf; + arg->buffer.length = len; + } else if (*s == '{') { + // decode buffer - { b1, b2 ...} + u8 *buf = temporary_buffer; + arg->type = ACPI_TYPE_BUFFER; + arg->buffer.pointer = buf; + arg->buffer.length = 0; + while (*s && *s++ != '}') { + if (buf >= temporary_buffer + sizeof(temporary_buffer)) { + printk(KERN_ERR "acpi_call: buffer arg%d is truncated because the buffer is full\n", *nargs); + // clear remaining arguments + while (*s && *s != '}') + ++s; + break; + } + else if (*s >= '0' && *s <= '9') { + // decode integer into buffer + arg->buffer.length ++; + if (s[0] == '0' && s[1] == 'x') + *buf++ = simple_strtol(s+2, 0, 16); + else + *buf++ = simple_strtol(s, 0, 10); + } + // skip until space or comma or '}' + while (*s && *s != ' ' && *s != ',' && *s != '}') + ++s; + } + // store the result in new allocated buffer + buf = (u8*) kmalloc(arg->buffer.length, GFP_KERNEL); + memcpy(buf, temporary_buffer, arg->buffer.length); + arg->buffer.pointer = buf; + } else { + // decode integer, N or 0xN + arg->type = ACPI_TYPE_INTEGER; + if (s[0] == '0' && s[1] == 'x') { + arg->integer.value = simple_strtol(s+2, 0, 16); + } else { + arg->integer.value = simple_strtol(s, 0, 10); + } + while (*s && *s != ' ') { + ++s; + } + } + } + } + + return input; +} + +/** procfs write callback. Called when writing into /proc/acpi/call. +*/ +#ifdef HAVE_PROC_CREATE +static ssize_t acpi_proc_write( struct file *filp, const char __user *buff, + size_t len, loff_t *data ) +#else +static int acpi_proc_write( struct file *filp, const char __user *buff, + unsigned long len, void *data ) +#endif +{ + char input[2 * BUFFER_SIZE] = { '\0' }; + union acpi_object *args; + int nargs, i; + char *method; + + if (len > sizeof(input) - 1) { + printk(KERN_ERR "acpi_call: Input too long! (%lu)\n", len); + return -ENOSPC; + } + + if (copy_from_user( input, buff, len )) { + return -EFAULT; + } + input[len] = '\0'; + if (input[len-1] == '\n') + input[len-1] = '\0'; + + method = parse_acpi_args(input, &nargs, &args); + if (method) { + do_acpi_call(method, nargs, args); + if (args) { + for (i=0; i 0) { + *eof = 1; + return 0; + } + + // output the current result buffer + len = strlen(result_buffer); + memcpy(page, result_buffer, len + 1); + + // initialize the result buffer for later + strcpy(result_buffer, "not called"); + + return len; +} +#endif + +/** module initialization function */ +static int __init init_acpi_call(void) +{ +#ifdef HAVE_PROC_CREATE + struct proc_dir_entry *acpi_entry = proc_create("call", + 0660, + acpi_root_dir, + &proc_acpi_operations); +#else + struct proc_dir_entry *acpi_entry = create_proc_entry("call", 0660, acpi_root_dir); +#endif + + strcpy(result_buffer, "not called"); + + if (acpi_entry == NULL) { + printk(KERN_ERR "acpi_call: Couldn't create proc entry\n"); + return -ENOMEM; + } + +#ifndef HAVE_PROC_CREATE + acpi_entry->write_proc = acpi_proc_write; + acpi_entry->read_proc = acpi_proc_read; +#endif + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Module loaded successfully\n"); +#endif + + return 0; +} + +static void __exit unload_acpi_call(void) +{ + remove_proc_entry("call", acpi_root_dir); + +#ifdef DEBUG + printk(KERN_INFO "acpi_call: Module unloaded successfully\n"); +#endif +} + +module_init(init_acpi_call); +module_exit(unload_acpi_call); + + diff --git a/rpmbuild/BUILD/akmod-acpi_call/examples/asus1215n.sh b/rpmbuild/BUILD/akmod-acpi_call/examples/asus1215n.sh new file mode 100644 index 0000000..aedf10e --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call/examples/asus1215n.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Power control for Asus 1215N Optimus +# by Pete Eberlein + +if ! lsmod | grep -q acpi_call; then + echo "Error: acpi_call module not loaded" + exit +fi + +acpi_call () { + echo "$*" > /proc/acpi/call + cat /proc/acpi/call +} + + +case "$1" in +off) + echo _DSM $(acpi_call "\_SB.PCI0.P0P4.GFX0._DSM" \ + "{0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47," \ + "0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0}" \ + "0x100 0x1A {0x1,0x0,0x0,0x3}") + # ok to turn off: Buffer {0x59 0x0 0x0 0x11} + # is already off: Buffer {0x41 0x0 0x0 0x11} + echo _PS3 $(acpi_call "\_SB.PCI0.P0P4.GFX0._PS3") +;; +on) + echo _PS0 $(acpi_call "\_SB.PCI0.P0P4.GFX0._PS0") +;; +*) + echo "Usage: $0 [on|off]" +esac + + +echo P3MO $(acpi_call "\_SB.PCI0.P0P4.GFX0.P3MO") +echo DGPS $(acpi_call "\_SB.PCI0.P0P4.GFX0.DGPS") +PSC=$(acpi_call "\_SB.PCI0.P0P4.GFX0._PSC") +echo _PSC ${PSC} +case "$PSC" in +0x0) + PSC="on" +;; +0x3) + PSC="off" +;; +esac +echo "Asus 1215N Optimus appears to be ${PSC}" + + diff --git a/rpmbuild/BUILD/akmod-acpi_call/examples/dellL702X.sh b/rpmbuild/BUILD/akmod-acpi_call/examples/dellL702X.sh new file mode 100644 index 0000000..8f29cbf --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call/examples/dellL702X.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# Power control for Dell L702X +# by Jos Hickson +# adapted from "Power control for Asus 1215N Optimus by Pete Eberlein" + +if ! lsmod | grep -q acpi_call; then + echo "Error: acpi_call module not loaded" + exit +fi + +acpi_call () { + echo "$*" > /proc/acpi/call + cat /proc/acpi/call +} + + +case "$1" in +off) + echo _DSM $(acpi_call "\_SB.PCI0.PEG0.PEGP._DSM" \ + "{0xF8,0xD8,0x86,0xA4,0xDA,0x0B,0x1B,0x47," \ + "0xA7,0x2B,0x60,0x42,0xA6,0xB5,0xBE,0xE0}" \ + "0x100 0x1A {0x1,0x0,0x0,0x3}") + # ok to turn off: Buffer {0x59 0x0 0x0 0x11} + # is already off: Buffer {0x41 0x0 0x0 0x11} + echo _PS3 $(acpi_call "\_SB.PCI0.PEG0.PEGP._PS3") +;; +on) + echo _PS0 $(acpi_call "\_SB.PCI0.PEG0.PEGP._PS0") +;; +*) + echo "Usage: $0 [on|off]" +esac + + +PSC=$(acpi_call "\_SB.PCI0.PEG0.PEGP._PSC") +#echo _PSC ${PSC} +case "$PSC" in +0x0) + PSC="on" +;; +0x3) + PSC="off" +;; +esac +echo "Dell L702X Optimus appears to be ${PSC}" + diff --git a/rpmbuild/BUILD/akmod-acpi_call/examples/m11xr2.sh b/rpmbuild/BUILD/akmod-acpi_call/examples/m11xr2.sh new file mode 100644 index 0000000..08eafb7 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call/examples/m11xr2.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Based on m11xr2hack by George Shearer + +if ! lsmod | grep -q acpi_call; then + echo "Error: acpi_call module not loaded" + exit +fi + +acpi_call () { + echo "$*" > /proc/acpi/call + cat /proc/acpi/call +} + + +case "$1" in +off) + echo NVOP $(acpi_call "\_SB.PCI0.P0P2.PEGP.NVOP 0 0x100 0x1A {255,255,255,255}") + echo _PS3 $(acpi_call "\_SB.PCI0.P0P2.PEGP._PS3") +;; +on) + echo _PS0 $(acpi_call "\_SB.PCI0.P0P2.PEGP._PS0") +;; +*) + echo "Usage: $0 [on|off]" +;; +esac + diff --git a/rpmbuild/BUILD/akmod-acpi_call/examples/turn_off_gpu.sh b/rpmbuild/BUILD/akmod-acpi_call/examples/turn_off_gpu.sh new file mode 100644 index 0000000..a18daa7 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call/examples/turn_off_gpu.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +if lsmod | grep -q acpi_call; then +methods=" +\_SB.PCI0.P0P1.VGA._OFF +\_SB.PCI0.P0P2.VGA._OFF +\_SB_.PCI0.OVGA.ATPX +\_SB_.PCI0.OVGA.XTPX +\_SB.PCI0.P0P3.PEGP._OFF +\_SB.PCI0.P0P2.PEGP._OFF +\_SB.PCI0.P0P1.PEGP._OFF +\_SB.PCI0.MXR0.MXM0._OFF +\_SB.PCI0.PEG1.GFX0._OFF +\_SB.PCI0.PEG0.GFX0.DOFF +\_SB.PCI0.PEG1.GFX0.DOFF +\_SB.PCI0.PEG0.PEGP._OFF +\_SB.PCI0.XVR0.Z01I.DGOF +\_SB.PCI0.PEGR.GFX0._OFF +\_SB.PCI0.PEG.VID._OFF +\_SB.PCI0.PEG0.VID._OFF +\_SB.PCI0.P0P2.DGPU._OFF +\_SB.PCI0.P0P4.DGPU.DOFF +\_SB.PCI0.IXVE.IGPU.DGOF +\_SB.PCI0.RP00.VGA._PS3 +\_SB.PCI0.RP00.VGA.P3MO +\_SB.PCI0.GFX0.DSM._T_0 +\_SB.PCI0.LPC.EC.PUBS._OFF +\_SB.PCI0.P0P2.NVID._OFF +\_SB.PCI0.P0P2.VGA.PX02 +\_SB_.PCI0.PEGP.DGFX._OFF +\_SB_.PCI0.VGA.PX02 +\_SB.PCI0.PEG0.PEGP.SGOF +\_SB.PCI0.AGP.VGA.PX02 +" + +for m in $methods; do + echo -n "Trying $m: " + echo $m > /proc/acpi/call + result=$(cat /proc/acpi/call) + case "$result" in + Error*) + echo "failed" + ;; + *) + echo "works!" + # break # try out outher methods too + ;; + esac +done + +else + echo "The acpi_call module is not loaded, try running 'modprobe acpi_call' or 'insmod acpi_call.ko' as root" + exit 1 +fi diff --git a/rpmbuild/BUILD/akmod-acpi_call/support/query_dsdt.pl b/rpmbuild/BUILD/akmod-acpi_call/support/query_dsdt.pl new file mode 100644 index 0000000..8dcd674 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call/support/query_dsdt.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl +use strict; +use Getopt::Long; +use Data::Dumper; + +my ($dir,$debug,$mytokens); +$dir = '.'; +GetOptions( + 'd|dir:s' => \$dir, + 'debug:s' => \$debug, + 't|tokens:s' => \$mytokens, + ); + +my $models; + +my @tokens = ( + 'MXMX','MXDS','_DSM', + '0xA6, 0xFA, 0xDD, 0x3D, 0x1B, 0x36, 0xB4, 0x4E', + '0xA4, 0x24, 0x8D, 0x10, 0x08, 0x9D, 0x16, 0x53'); + +if (defined $mytokens) { + @tokens = (); + foreach my $mytoken (split(":",$mytokens)) { + push @tokens, $mytoken; + } +} + +opendir DIR,$dir or die $!; +my $file; +my $count = 0; +while (( defined($file = readdir(DIR)) )) { + if ($file =~ /\.dsl$/) { + analyse_file($dir,$file); + } + last if ($count++ > $debug && defined($debug)); +} + +foreach my $file (sort keys %$models) { + my $num = scalar keys %{$models->{$file}}; $num = sprintf("%02d",$num); + print "$num $file \{"; + foreach my $token (sort keys %{$models->{$file}}) { + my $value = $models->{$file}{$token}; + print "\t$token => $value "; + } + print "\}\n"; +} +$DB::single=1;1; +print STDERR Dumper($models) if ($debug); + +######################################## + +sub analyse_file { + my $dir = shift; + my $file = shift; + my $param = shift; + + open FILE, "$dir/$file" or die $!; + while () { + foreach my $token (@tokens) { + my $regexp = qr/${token}/; + if ($_ =~ /$regexp/g) { + $models->{$file}{$token}++; + } + } + } + close FILE; +} diff --git a/rpmbuild/BUILD/akmod-acpi_call/support/windump_hack/windump.c b/rpmbuild/BUILD/akmod-acpi_call/support/windump_hack/windump.c new file mode 100644 index 0000000..6246f06 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call/support/windump_hack/windump.c @@ -0,0 +1,285 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int format = ZPixmap; + +XImage * +CaptRoot(Display * dpy, int screen) +{ + unsigned long swaptest = 1; + XColor *colors; + unsigned buffer_size; + int win_name_size; + int header_size; + int ncolors, i; + char *win_name; + Bool got_win_name; + XWindowAttributes win_info; + XImage *image; + int absx, absy, x, y; + unsigned width, height; + int dwidth, dheight; + int bw; + Window dummywin; + +#if 0 + int transparentOverlays , multiVis; + int numVisuals; + XVisualInfo *pVisuals; + int numOverlayVisuals; + OverlayInfo *pOverlayVisuals; + int numImageVisuals; + XVisualInfo **pImageVisuals; + list_ptr vis_regions; /* list of regions to read from */ + list_ptr vis_image_regions ; + Visual vis_h,*vis ; +#endif + int allImage = 0 ; + + Window window=RootWindow (dpy, screen); + + if (!XGetWindowAttributes(dpy, window, &win_info)) + { fprintf(stderr,"Can't get target window attributes."); exit(1); } + + absx=0; absy=0; + win_info.x = 0; + win_info.y = 0; + width = win_info.width; + height = win_info.height; + bw = 0; + + dwidth = DisplayWidth (dpy, screen); + dheight = DisplayHeight (dpy, screen); + + XFetchName(dpy, window, &win_name); + if (!win_name || !win_name[0]) { + win_name = "xwdump"; + got_win_name = False; + } else { + got_win_name = True; + } + + /* sizeof(char) is included for the null string terminator. */ + win_name_size = strlen(win_name) + sizeof(char); + + /* + * Snarf the pixmap with XGetImage. + */ + + x = absx - win_info.x; + y = absy - win_info.y; +#if 0 + multiVis = GetMultiVisualRegions(dpy,RootWindow(dpy, screen),absx,absy, + width,height,&transparentOverlays,&numVisuals,&pVisuals, + &numOverlayVisuals,&pOverlayVisuals,&numImageVisuals, + &pImageVisuals,&vis_regions,&vis_image_regions,&allImage) ; + if (on_root || multiVis) + { + if (!multiVis) + image = XGetImage (dpy, RootWindow(dpy, screen), absx, absy, + width, height, AllPlanes, format); + else + image = ReadAreaToImage(dpy, RootWindow(dpy, screen), absx, absy, + width, height, + numVisuals,pVisuals,numOverlayVisuals,pOverlayVisuals, + numImageVisuals, pImageVisuals,vis_regions, + vis_image_regions,format,allImage); + } + else +#endif + image = XGetImage (dpy, window, x, y, width, height, + AllPlanes, format); + if (!image) { + fprintf (stderr, "unable to get image at %dx%d+%d+%d\n", + width, height, x, y); + exit (1); + } + + //if (add_pixel_value != 0) XAddPixel (image, add_pixel_value); + + return image; +} + +Window CreateWindow(Display * dpy, int screen, int width, int height) +{ + Window win = 0; + win = XCreateWindow(dpy, RootWindow(dpy, screen), + 0, 0, width, height, + 0, + 24, + InputOutput, + DefaultVisual(dpy, screen), + //CWBorderPixel|CWBackPixel|CWColormap|CWEventMask|CWBitGravity, + 0, + 0); + + XSelectInput(dpy, win, StructureNotifyMask|ButtonPressMask|ButtonReleaseMask); + + XMapWindow(dpy, win); + return win; +} + +void DrawImage(Display * dpy, Window win, XImage * image) +{ + static GC gc; + if(win!=0) + { + if(gc==0) + { + XGCValues gc_val; + gc = XCreateGC (dpy, win, GCForeground|GCBackground, &gc_val); + } + /*for(i=0;i<100;i++) + { + image->data*/ + XPutImage (dpy, win, gc, image, 0, 0, 0, 0, 1024, 768); + } +} + +void createShmImage(int w, int h, XShmSegmentInfo * sinfo, XShmSegmentInfo * tinfo, Display * sdpy, Display * tdpy, int sscr, int tscr, XImage ** simage, XImage ** timage) +{ + sinfo->shmid=tinfo->shmid=shmget(IPC_PRIVATE,w*h*sizeof(unsigned),IPC_CREAT|0666 ); + sinfo->shmaddr=tinfo->shmaddr=(char*)shmat(sinfo->shmid,0,0); + sinfo->readOnly=tinfo->readOnly=False; + printf("%d %d\n",DefaultDepth(sdpy,sscr),DefaultDepth(tdpy,tscr)); + *simage = XShmCreateImage( + sdpy, DefaultVisual(sdpy,sscr), DefaultDepth(sdpy,sscr), + ZPixmap/*format*/, + (char *)sinfo->shmaddr, sinfo, + w,h /*width,height*/ + ); + *timage = XShmCreateImage( + tdpy, DefaultVisual(tdpy,tscr), DefaultDepth(tdpy,tscr), + ZPixmap/*format*/, + (char *)tinfo->shmaddr, tinfo, + w,h /*width,height*/ + ); + XShmAttach(sdpy, sinfo); + XShmAttach(tdpy, tinfo); +} + +void drawMouse(XImage * img, int xm, int ym) +{ + int x,y,x1,y1,x2,y2,w,h; + + unsigned * data = (unsigned *)(img->data); + + w=img->width; + h=img->height; + + x=xm; if(x<0) x=0; if(x>w) x=w-1; + y=ym; if(y<0) y=0; if(y>h) y=h-1; + x1=xm-5; if(x1<0) x1=0; if(x1>w) x1=w; + x2=xm+6; if(x2<0) x2=0; if(x2>w) x2=w; + for(x=x1;xw) x=w-1; + y=ym; if(y<0) y=0; if(y>h) y=h-1; + y1=ym-5; if(y1<0) y1=0; if(y1>h) y1=h; + y2=ym+6; if(y2<0) y2=0; if(y2>h) y2=h; + for(y=y1;ywidth, simage->height, simage->depth); + //printf("timage: w:%d h:%d d:%d\n",timage->width, timage->height, timage->depth); + if(!emulate_events) + { + Window rwin,cwin; + int xmouse,ymouse,x,y,mask; + XQueryPointer(sdpy,swin,&rwin,&cwin,&xmouse,&ymouse,&x,&y,&mask); + drawMouse(timage, xmouse, ymouse); + } + + XShmPutImage (tdpy, twin, tgc, timage, 0, 0, 0, 0, timage->width, timage->height, False); + //XPutImage (tdpy, twin, tgc, timage, 0, 0, 0, 0, timage->width, timage->height); + } + //XFlush(sdpy); + XFlush(tdpy); +// getchar(); + } +} diff --git a/rpmbuild/BUILD/akmod-acpi_call/support/windump_hack/xorg.conf b/rpmbuild/BUILD/akmod-acpi_call/support/windump_hack/xorg.conf new file mode 100644 index 0000000..21c0090 --- /dev/null +++ b/rpmbuild/BUILD/akmod-acpi_call/support/windump_hack/xorg.conf @@ -0,0 +1,83 @@ +# nvidia-xconfig: X configuration file generated by nvidia-xconfig +# nvidia-xconfig: version 270.41.06 (buildmeister@swio-display-x86-rhel47-08.nvidia.com) Mon Apr 18 15:14:00 PDT 2011 + +Section "ServerLayout" + Identifier "Layout0" + Screen "Screen0" + Screen "Screen1" RightOf "Screen0" + InputDevice "Keyboard0" "SendCoreEvents" + #InputDevice "Keyboard0" "CoreKeyboard" + InputDevice "Mouse0" "SendCoreEvents" + #InputDevice "Mouse0" "CorePointer" +EndSection + +#Section "ServerFlags" +# Option "AllowEmptyInput" "no" +#EndSection + +Section "Files" +EndSection + +Section "InputDevice" + # generated from default + Identifier "Mouse0" + Driver "mouse" + Option "Protocol" "auto" + Option "Device" "/dev/psaux" + Option "Emulate3Buttons" "no" + Option "ZAxisMapping" "4 5" +EndSection + +Section "InputDevice" + # generated from default + Identifier "Keyboard0" + Driver "kbd" +EndSection + +Section "Monitor" + Identifier "Monitor0" + VendorName "Unknown" + ModelName "Unknown" + HorizSync 28.0 - 73.0 + VertRefresh 43.0 - 72.0 + Option "DPMS" +EndSection + +Section "Device" + Identifier "Device1" + Driver "nvidia" + VendorName "NVIDIA Corporation" + BusID "PCI:1:0:0" + Option "IgnoreEDID" + #Screen 0 +EndSection + +Section "Device" + Identifier "Device0" + Driver "intel" + VendorName "onboard" + BusID "PCI:0:2:0" + #Screen 1 +EndSection + +Section "Screen" + Identifier "Screen1" + Device "Device0" + Monitor "Monitor0" + DefaultDepth 24 + SubSection "Display" + Depth 24 + EndSubSection +EndSection + +Section "Screen" + Identifier "Screen0" + Device "Device1" + Monitor "Monitor0" + DefaultDepth 24 + SubSection "Display" + Depth 24 + Modes "1024x768" + EndSubSection +EndSection + diff --git a/rpmbuild/BUILDROOT/akmod-acpi_call-1.2.2-1.x86_64/usr/lib/modules/6.4.11-200.fc38.x86_64/extra/acpi_call/acpi_call.ko b/rpmbuild/BUILDROOT/akmod-acpi_call-1.2.2-1.x86_64/usr/lib/modules/6.4.11-200.fc38.x86_64/extra/acpi_call/acpi_call.ko new file mode 100644 index 0000000..2e41bb1 Binary files /dev/null and b/rpmbuild/BUILDROOT/akmod-acpi_call-1.2.2-1.x86_64/usr/lib/modules/6.4.11-200.fc38.x86_64/extra/acpi_call/acpi_call.ko differ diff --git a/rpmbuild/SOURCES/acpi_call-master.zip b/rpmbuild/SOURCES/acpi_call-master.zip new file mode 100644 index 0000000..c1734af Binary files /dev/null and b/rpmbuild/SOURCES/acpi_call-master.zip differ diff --git a/rpmbuild/SOURCES/akmod-acpi_call-1.1.0.tar.gz b/rpmbuild/SOURCES/akmod-acpi_call-1.1.0.tar.gz new file mode 100644 index 0000000..84673e5 Binary files /dev/null and b/rpmbuild/SOURCES/akmod-acpi_call-1.1.0.tar.gz differ diff --git a/rpmbuild/SOURCES/akmod-acpi_call-1.2.2-1.src.rpm b/rpmbuild/SOURCES/akmod-acpi_call-1.2.2-1.src.rpm new file mode 100644 index 0000000..b0ea38b Binary files /dev/null and b/rpmbuild/SOURCES/akmod-acpi_call-1.2.2-1.src.rpm differ diff --git a/rpmbuild/SOURCES/akmod-acpi_call-1.2.2.tar.xz b/rpmbuild/SOURCES/akmod-acpi_call-1.2.2.tar.xz new file mode 100644 index 0000000..f52bab2 Binary files /dev/null and b/rpmbuild/SOURCES/akmod-acpi_call-1.2.2.tar.xz differ diff --git a/rpmbuild/SPECS/acpi_call.spec b/rpmbuild/SPECS/acpi_call.spec new file mode 100644 index 0000000..128c8b7 --- /dev/null +++ b/rpmbuild/SPECS/acpi_call.spec @@ -0,0 +1,44 @@ + +Name: acpi_call +Version: 1.2.2 +Release: 1 +Summary: A kernel module to call ACPI methods + +License: GPL +URL: https://github.com/nix-community/acpi_call +Source0: acpi_call-master.zip + +BuildRequires: dkms +Requires: akmods +Requires(post): dkms +Requires(preun): dkms + +%define debug_package %{nil} + +%description +ACPI_CALL est un module du noyau Linux qui permet de faire des appels à des méthodes ACPI directement depuis l'espace utilisateur. Ceci est particulièrement utile pour des scripts ou autres programmes qui souhaitent obtenir ou définir des informations ACPI. + +%prep +%setup -q -n acpi_call-master + +%build +# La phase de construction est gérée par DKMS + +%install +mkdir -p %{buildroot}/usr/src/acpi_call-%{version} +cp -a * %{buildroot}/usr/src/acpi_call-%{version} + +%post +dkms add -m acpi_call -v %{version} +dkms build -m acpi_call -v %{version} +dkms install -m acpi_call -v %{version} + +%preun +dkms remove -m acpi_call -v %{version} --all + +%files +/usr/src/acpi_call-%{version} + +%changelog +* Mon Aug 21 2023 MiMillie mimillie290@gmail.com> - 1.1.0-1 +- Initial RPM release for fedora akmod diff --git a/rpmbuild/SPECS/acpi_call.spec.ak b/rpmbuild/SPECS/acpi_call.spec.ak new file mode 100644 index 0000000..f2765b7 --- /dev/null +++ b/rpmbuild/SPECS/acpi_call.spec.ak @@ -0,0 +1,46 @@ +Name: akmod-acpi_call +Version: 1.2.2 +Release: 1 +Summary: Akmod package for the acpi_call kernel module + +License: GPL +URL: https://github.com/nix-community/acpi_call +Source0: acpi_call-master.zip +BuildRequires: akmods +BuildRequires: kernel-devel +Requires(post): akmods +Requires(postun): akmods + +%define debug_package %{nil} + +%description +ACPI_CALL est un module du noyau Linux qui permet de faire des appels à des méthodes ACPI directement depuis l'espace utilisateur. Ceci est particulièrement utile pour des scripts ou autres programmes qui souhaitent obtenir ou définir des informations ACPI. + +%prep +%setup -q -n acpi_call-master + +%build +# Construction du module pour le noyau actuel +make -C /lib/modules/$(uname -r)/build M=$(pwd) + +%install +# Installation du module dans le répertoire approprié pour akmods +install -D -m 644 acpi_call.ko %{buildroot}/usr/lib/modules/$(uname -r)/extra/acpi_call/acpi_call.ko + +mkdir -p %{buildroot}/usr/src/akmods/ +cp %{_sourcedir}/%{name}-%{version}.src.rpm %{buildroot}/usr/src/akmods/ +echo %{name}-%{version}.src.rpm > %{buildroot}/usr/src/akmods/%{name}.latest + +%post +/sbin/akmodsbuild %{_rpmfilename} + +%postun +/sbin/akmodsbuild %{_rpmfilename} + +%files +/usr/lib/modules/*/extra/acpi_call/acpi_call.ko +/usr/src/akmods/%{name}-%{version}.src.rpm +/usr/src/akmods/%{name}.latest +%changelog +* Mon Aug 21 2023 MiMillie mimillie290@gmail.com> - 1.1.0-1 +- Initial RPM release for fedora akmod diff --git a/rpmbuild/SPECS/acpi_call.spec.old b/rpmbuild/SPECS/acpi_call.spec.old new file mode 100644 index 0000000..aa9aa1c --- /dev/null +++ b/rpmbuild/SPECS/acpi_call.spec.old @@ -0,0 +1,39 @@ +Name: akmod-acpi_call +Version: 1.2.2 +Release: 1%{?dist} +Summary: A tool for calling ACPI methods + +License: GPLv2+ +URL: https://github.com/mkottman/acpi_call +Source0: akmod-acpi_call-1.2.2.tar.xz + +BuildRequires: kernel-devel +BuildRequires: gcc + +%description +ACPI Call is a utility for invoking ACPI methods from user space. This can be useful for debugging ACPI issues or for changing hardware settings that are otherwise not exposed in the BIOS or by the kernel. + +%prep +%setup -q -n %{name}-%{version} + +%build +make %{?_smp_mflags} + +%install +make install DESTDIR=%{buildroot} + +%post +/sbin/depmod -a %{KMODDIR} + +%postun +/sbin/depmod -a %{KMODDIR} + +%files +%defattr(-,root,root) +%doc README.md +%{_bindir}/acpi_call +%{KMODDIR}/%{version}/ + +%changelog +* Mon Aug 21 2023 MiMillie mimillie290@gmail.com> - 1.1.0-1 +- Initial RPM release for fedora akmod diff --git a/rpmbuild/SRPMS/akmod-acpi_call-1.2.2-1.src.rpm b/rpmbuild/SRPMS/akmod-acpi_call-1.2.2-1.src.rpm new file mode 100644 index 0000000..b0ea38b Binary files /dev/null and b/rpmbuild/SRPMS/akmod-acpi_call-1.2.2-1.src.rpm differ