updated on Tue Jan 17 08:05:08 UTC 2012
[aur-mirror.git] / nvidia-g210m-acpi / nvidia_g210m_acpi.c
blob9aaa88ae53c962bd8b6d562ce86b1f9ddb1cf808
1 /*
2 * Linux kernel module that disables the discrete graphics board
4 * Original version for Lenovo laptops by Sylvain Joyeux <sylvain.joyeux@m4x.org> Copyright (c) 2009
6 * mil2 added nVidia GeForce G210M support (for Asus UL30VT, UL50V, UL80V laptops)
7 * o8x8 added post hibernate support
9 * Marco Giorgi <blackmoon.105@gmail.com> packaged this module for debian/ubuntu
11 * Power down the nVidia card to save up to 4W of power.
16 /*
17 * Name: nvidia_g210m_acpi.c
18 * Source code for nvidia_g210m_acpi switch-off kernel module
20 * Licensed under the GNU GPL
25 #include <acpi/acpi.h>
26 #include <linux/suspend.h>
28 MODULE_LICENSE("GPL");
30 static acpi_handle root_handle;
32 static int kill_nvidia(void)
34 acpi_status status;
35 // The device handle
36 acpi_handle handle;
37 struct acpi_object_list args;
38 // For the return value
39 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
41 status = acpi_get_handle(root_handle, "\\_SB.PCI0.P0P1.VGA._OFF", &handle);
42 if (ACPI_FAILURE(status))
44 printk("%s: cannot get ACPI handle: %s\n", __func__, acpi_format_exception(status));
45 return -ENOSYS;
48 args.count = 0;
49 args.pointer = NULL;
51 status = acpi_evaluate_object(handle, NULL, &args, &buffer);
52 if (ACPI_FAILURE(status))
54 printk("%s: _OFF method call failed: %s\n", __func__, acpi_format_exception(status));
55 return -ENOSYS;
57 kfree(buffer.pointer);
59 printk("%s: disabled the discrete graphics card\n", __func__);
60 return 0;
63 static int power_event(struct notifier_block *this, unsigned long event, void *ptr)
65 switch (event) {
66 case PM_POST_HIBERNATION:
67 printk("%s: post hibernation\n",__FILE__);
68 kill_nvidia();
69 break;
70 case PM_POST_SUSPEND:
71 printk("%s: post suspend\n",__FILE__);
72 kill_nvidia();
73 break;
74 default:
75 break;
77 return NOTIFY_DONE;
80 static struct notifier_block power_notifier = { .notifier_call = power_event, };
82 static int __init nvidia_g210m_acpi(void)
84 int ret = register_pm_notifier(&power_notifier);
85 if (ret) return ret;
86 return kill_nvidia();
89 static void dummy(void)
93 module_init(nvidia_g210m_acpi);
94 module_exit(dummy);