diff options
author | Tejun Heo <tj@kernel.org> | 2010-04-04 22:37:28 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2010-04-04 22:37:28 -0400 |
commit | 336f5899d287f06d8329e208fc14ce50f7ec9698 (patch) | |
tree | 9b762d450d5eb248a6ff8317badb7e223d93ed58 /drivers/platform | |
parent | a4ab2773205e8b94c18625455f85e3b6bb9d7ad6 (diff) | |
parent | db217dece3003df0841bacf9556b5c06aa097dae (diff) |
Merge branch 'master' into export-slabh
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/Kconfig | 10 | ||||
-rw-r--r-- | drivers/platform/x86/Makefile | 1 | ||||
-rw-r--r-- | drivers/platform/x86/asus-laptop.c | 4 | ||||
-rw-r--r-- | drivers/platform/x86/eeepc-wmi.c | 157 |
4 files changed, 170 insertions, 2 deletions
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index e631dbeafd79..7bec4588c268 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig | |||
@@ -385,6 +385,16 @@ config EEEPC_LAPTOP | |||
385 | 385 | ||
386 | If you have an Eee PC laptop, say Y or M here. | 386 | If you have an Eee PC laptop, say Y or M here. |
387 | 387 | ||
388 | config EEEPC_WMI | ||
389 | tristate "Eee PC WMI Hotkey Driver (EXPERIMENTAL)" | ||
390 | depends on ACPI_WMI | ||
391 | depends on INPUT | ||
392 | depends on EXPERIMENTAL | ||
393 | ---help--- | ||
394 | Say Y here if you want to support WMI-based hotkeys on Eee PC laptops. | ||
395 | |||
396 | To compile this driver as a module, choose M here: the module will | ||
397 | be called eeepc-wmi. | ||
388 | 398 | ||
389 | config ACPI_WMI | 399 | config ACPI_WMI |
390 | tristate "WMI" | 400 | tristate "WMI" |
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 9cd9fa0a27e6..a906490e3530 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile | |||
@@ -4,6 +4,7 @@ | |||
4 | # | 4 | # |
5 | obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o | 5 | obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o |
6 | obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o | 6 | obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o |
7 | obj-$(CONFIG_EEEPC_WMI) += eeepc-wmi.o | ||
7 | obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o | 8 | obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o |
8 | obj-$(CONFIG_ACPI_CMPC) += classmate-laptop.o | 9 | obj-$(CONFIG_ACPI_CMPC) += classmate-laptop.o |
9 | obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o | 10 | obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o |
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index c2d4569aef3a..52262b012abb 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c | |||
@@ -140,7 +140,7 @@ MODULE_PARM_DESC(bluetooth_status, "Set the wireless status on boot " | |||
140 | 140 | ||
141 | /* Backlight */ | 141 | /* Backlight */ |
142 | static acpi_handle lcd_switch_handle; | 142 | static acpi_handle lcd_switch_handle; |
143 | static const char *lcd_switch_paths[] = { | 143 | static char *lcd_switch_paths[] = { |
144 | "\\_SB.PCI0.SBRG.EC0._Q10", /* All new models */ | 144 | "\\_SB.PCI0.SBRG.EC0._Q10", /* All new models */ |
145 | "\\_SB.PCI0.ISA.EC0._Q10", /* A1x */ | 145 | "\\_SB.PCI0.ISA.EC0._Q10", /* A1x */ |
146 | "\\_SB.PCI0.PX40.ECD0._Q10", /* L3C */ | 146 | "\\_SB.PCI0.PX40.ECD0._Q10", /* L3C */ |
@@ -154,7 +154,7 @@ static const char *lcd_switch_paths[] = { | |||
154 | #define METHOD_SWITCH_DISPLAY "SDSP" | 154 | #define METHOD_SWITCH_DISPLAY "SDSP" |
155 | 155 | ||
156 | static acpi_handle display_get_handle; | 156 | static acpi_handle display_get_handle; |
157 | static const char *display_get_paths[] = { | 157 | static char *display_get_paths[] = { |
158 | /* A6B, A6K A6R A7D F3JM L4R M6R A3G M6A M6V VX-1 V6J V6V W3Z */ | 158 | /* A6B, A6K A6R A7D F3JM L4R M6R A3G M6A M6V VX-1 V6J V6V W3Z */ |
159 | "\\_SB.PCI0.P0P1.VGA.GETD", | 159 | "\\_SB.PCI0.P0P1.VGA.GETD", |
160 | /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V S5A M5A z33A W1Jc W2V G1 */ | 160 | /* A3E A4K, A4D A4L A6J A7J A8J Z71V M9V S5A M5A z33A W1Jc W2V G1 */ |
diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c new file mode 100644 index 000000000000..2466b7b7fb0e --- /dev/null +++ b/drivers/platform/x86/eeepc-wmi.c | |||
@@ -0,0 +1,157 @@ | |||
1 | /* | ||
2 | * Eee PC WMI hotkey driver | ||
3 | * | ||
4 | * Copyright(C) 2010 Intel Corporation. | ||
5 | * | ||
6 | * Portions based on wistron_btns.c: | ||
7 | * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz> | ||
8 | * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org> | ||
9 | * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru> | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License as published by | ||
13 | * the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 | */ | ||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/init.h> | ||
29 | #include <linux/types.h> | ||
30 | #include <linux/input.h> | ||
31 | #include <linux/input/sparse-keymap.h> | ||
32 | #include <acpi/acpi_bus.h> | ||
33 | #include <acpi/acpi_drivers.h> | ||
34 | |||
35 | MODULE_AUTHOR("Yong Wang <yong.y.wang@intel.com>"); | ||
36 | MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver"); | ||
37 | MODULE_LICENSE("GPL"); | ||
38 | |||
39 | #define EEEPC_WMI_EVENT_GUID "ABBC0F72-8EA1-11D1-00A0-C90629100000" | ||
40 | |||
41 | MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID); | ||
42 | |||
43 | #define NOTIFY_BRNUP_MIN 0x11 | ||
44 | #define NOTIFY_BRNUP_MAX 0x1f | ||
45 | #define NOTIFY_BRNDOWN_MIN 0x20 | ||
46 | #define NOTIFY_BRNDOWN_MAX 0x2e | ||
47 | |||
48 | static const struct key_entry eeepc_wmi_keymap[] = { | ||
49 | /* Sleep already handled via generic ACPI code */ | ||
50 | { KE_KEY, 0x5d, { KEY_WLAN } }, | ||
51 | { KE_KEY, 0x32, { KEY_MUTE } }, | ||
52 | { KE_KEY, 0x31, { KEY_VOLUMEDOWN } }, | ||
53 | { KE_KEY, 0x30, { KEY_VOLUMEUP } }, | ||
54 | { KE_IGNORE, NOTIFY_BRNDOWN_MIN, { KEY_BRIGHTNESSDOWN } }, | ||
55 | { KE_IGNORE, NOTIFY_BRNUP_MIN, { KEY_BRIGHTNESSUP } }, | ||
56 | { KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } }, | ||
57 | { KE_END, 0}, | ||
58 | }; | ||
59 | |||
60 | static struct input_dev *eeepc_wmi_input_dev; | ||
61 | |||
62 | static void eeepc_wmi_notify(u32 value, void *context) | ||
63 | { | ||
64 | struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
65 | union acpi_object *obj; | ||
66 | acpi_status status; | ||
67 | int code; | ||
68 | |||
69 | status = wmi_get_event_data(value, &response); | ||
70 | if (status != AE_OK) { | ||
71 | pr_err("EEEPC WMI: bad event status 0x%x\n", status); | ||
72 | return; | ||
73 | } | ||
74 | |||
75 | obj = (union acpi_object *)response.pointer; | ||
76 | |||
77 | if (obj && obj->type == ACPI_TYPE_INTEGER) { | ||
78 | code = obj->integer.value; | ||
79 | |||
80 | if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX) | ||
81 | code = NOTIFY_BRNUP_MIN; | ||
82 | else if (code >= NOTIFY_BRNDOWN_MIN && code <= NOTIFY_BRNDOWN_MAX) | ||
83 | code = NOTIFY_BRNDOWN_MIN; | ||
84 | |||
85 | if (!sparse_keymap_report_event(eeepc_wmi_input_dev, | ||
86 | code, 1, true)) | ||
87 | pr_info("EEEPC WMI: Unknown key %x pressed\n", code); | ||
88 | } | ||
89 | |||
90 | kfree(obj); | ||
91 | } | ||
92 | |||
93 | static int eeepc_wmi_input_setup(void) | ||
94 | { | ||
95 | int err; | ||
96 | |||
97 | eeepc_wmi_input_dev = input_allocate_device(); | ||
98 | if (!eeepc_wmi_input_dev) | ||
99 | return -ENOMEM; | ||
100 | |||
101 | eeepc_wmi_input_dev->name = "Eee PC WMI hotkeys"; | ||
102 | eeepc_wmi_input_dev->phys = "wmi/input0"; | ||
103 | eeepc_wmi_input_dev->id.bustype = BUS_HOST; | ||
104 | |||
105 | err = sparse_keymap_setup(eeepc_wmi_input_dev, eeepc_wmi_keymap, NULL); | ||
106 | if (err) | ||
107 | goto err_free_dev; | ||
108 | |||
109 | err = input_register_device(eeepc_wmi_input_dev); | ||
110 | if (err) | ||
111 | goto err_free_keymap; | ||
112 | |||
113 | return 0; | ||
114 | |||
115 | err_free_keymap: | ||
116 | sparse_keymap_free(eeepc_wmi_input_dev); | ||
117 | err_free_dev: | ||
118 | input_free_device(eeepc_wmi_input_dev); | ||
119 | return err; | ||
120 | } | ||
121 | |||
122 | static int __init eeepc_wmi_init(void) | ||
123 | { | ||
124 | int err; | ||
125 | acpi_status status; | ||
126 | |||
127 | if (!wmi_has_guid(EEEPC_WMI_EVENT_GUID)) { | ||
128 | pr_warning("EEEPC WMI: No known WMI GUID found\n"); | ||
129 | return -ENODEV; | ||
130 | } | ||
131 | |||
132 | err = eeepc_wmi_input_setup(); | ||
133 | if (err) | ||
134 | return err; | ||
135 | |||
136 | status = wmi_install_notify_handler(EEEPC_WMI_EVENT_GUID, | ||
137 | eeepc_wmi_notify, NULL); | ||
138 | if (ACPI_FAILURE(status)) { | ||
139 | sparse_keymap_free(eeepc_wmi_input_dev); | ||
140 | input_unregister_device(eeepc_wmi_input_dev); | ||
141 | pr_err("EEEPC WMI: Unable to register notify handler - %d\n", | ||
142 | status); | ||
143 | return -ENODEV; | ||
144 | } | ||
145 | |||
146 | return 0; | ||
147 | } | ||
148 | |||
149 | static void __exit eeepc_wmi_exit(void) | ||
150 | { | ||
151 | wmi_remove_notify_handler(EEEPC_WMI_EVENT_GUID); | ||
152 | sparse_keymap_free(eeepc_wmi_input_dev); | ||
153 | input_unregister_device(eeepc_wmi_input_dev); | ||
154 | } | ||
155 | |||
156 | module_init(eeepc_wmi_init); | ||
157 | module_exit(eeepc_wmi_exit); | ||