hp-dm3 team mailing list archive
-
hp-dm3 team
-
Mailing list archive
-
Message #00000
possible solution to switch on/off discrete graphics card
Hi,
After inspecting the DSDT.dsl files from a HP Pavilion dm3 1020ec
model, it looks like we can modify one of the existing
modules to have switchable graphics for the dm3 series.
(infot taken from this URL:
http://ubuntuforums.org/showpost.php?p=7933876&postcount=11)
Save the following as dm3_acpi.c
==============================
/* Linux kernel module that disables the discrete graphics board for
* HP dm3 series laptops.
*
* Copyright (c) 2009: Sylvain Joyeux <sylvain.joyeux@xxxxxxx>
*/
#include <acpi/acpi.h>
MODULE_LICENSE("GPL");
static acpi_handle root_handle;
static int __init kill_ati(void)
{
int i;
acpi_status status;
// The device handle
acpi_handle handle;
// The package elements
union acpi_object package_elements[3];
// The arguments to ATPX
union acpi_object atpx_arg_elements[2];
struct acpi_object_list atpx_arg;
// For the return value of ATPX
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
status = acpi_get_handle(root_handle, "\\_SB_.PCI0.OVGA.ATPX", &handle);
if (ACPI_FAILURE(status))
{
status = acpi_get_handle(root_handle, "\\_SB_.PCI0.OVGA.XTPX", &handle);
if (ACPI_FAILURE(status))
{
printk("dm3_acpi: cannot get ACPI handle: %s\n",
acpi_format_exception(status));
return -ENOSYS;
}
printk("dm3_acpi: in discrete graphics mode\n");
return 0;
}
for (i = 0; i < 3; ++i)
{
package_elements[i].type = ACPI_TYPE_INTEGER;
package_elements[i].integer.value = 0;
}
atpx_arg.count = 2;
atpx_arg.pointer = &atpx_arg_elements[0];
atpx_arg_elements[0].type = ACPI_TYPE_INTEGER;
atpx_arg_elements[0].integer.value = 2;
atpx_arg_elements[1].type = ACPI_TYPE_PACKAGE;
atpx_arg_elements[1].package.count = 3;
atpx_arg_elements[1].package.elements = &package_elements[0];
status = acpi_evaluate_object(handle, NULL, &atpx_arg, &buffer);
if (ACPI_FAILURE(status))
{
printk("dm3_acpi: ATPX method call failed: %s\n",
acpi_format_exception(status));
return -ENOSYS;
}
kfree(buffer.pointer);
printk("dm3_acpi: disabled the discrete graphics card\n");
return 0;
}
static void dummy(void)
{
}
module_init(kill_ati);
module_exit(dummy);
=============================
Save the following as Makefile:
=============================
ifneq ($(KERNELRELEASE),)
obj-m := dm3_acpi.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) $(EXTRA_FLAGS) modules
clean:
$(MAKE) -C $(KERNELDIR) M=$(PWD) $(EXTRA_FLAGS) clean
endif
=============================
In the same folder, run the following commands:
make
sudo cp dm3_acpi.ko /lib/modules/`uname -r`/kernel/
sudo depmod
echo dm3_acpi | sudo tee -a /etc/modules > /dev/null
Can people report back if it works?
Cheers,
Albert.