1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
28
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/init.h>
32#include <linux/input.h>
33#include <linux/input/sparse-keymap.h>
34#include <linux/dmi.h>
35#include <linux/fb.h>
36#include <linux/acpi.h>
37
38#include "asus-wmi.h"
39
40#define EEEPC_WMI_FILE "eeepc-wmi"
41
42MODULE_AUTHOR("Corentin Chary <corentin.chary@gmail.com>");
43MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver");
44MODULE_LICENSE("GPL");
45
46#define EEEPC_ACPI_HID "ASUS010"
47
48#define EEEPC_WMI_EVENT_GUID "ABBC0F72-8EA1-11D1-00A0-C90629100000"
49
50MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID);
51
52static bool hotplug_wireless;
53
54module_param(hotplug_wireless, bool, 0444);
55MODULE_PARM_DESC(hotplug_wireless,
56 "Enable hotplug for wireless device. "
57 "If your laptop needs that, please report to "
58 "acpi4asus-user@lists.sourceforge.net.");
59
60
61#define HOME_PRESS 0xe4
62#define HOME_HOLD 0xea
63#define HOME_RELEASE 0xe5
64
65static const struct key_entry eeepc_wmi_keymap[] = {
66 { KE_KEY, ASUS_WMI_BRN_DOWN, { KEY_BRIGHTNESSDOWN } },
67 { KE_KEY, ASUS_WMI_BRN_UP, { KEY_BRIGHTNESSUP } },
68
69 { KE_KEY, 0x30, { KEY_VOLUMEUP } },
70 { KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
71 { KE_KEY, 0x32, { KEY_MUTE } },
72 { KE_KEY, 0x5c, { KEY_F15 } },
73 { KE_KEY, 0x5d, { KEY_WLAN } },
74 { KE_KEY, 0x6b, { KEY_TOUCHPAD_TOGGLE } },
75 { KE_KEY, 0x82, { KEY_CAMERA } },
76 { KE_KEY, 0x83, { KEY_CAMERA_ZOOMIN } },
77 { KE_KEY, 0x88, { KEY_WLAN } },
78 { KE_KEY, 0xbd, { KEY_CAMERA } },
79 { KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } },
80 { KE_KEY, 0xe0, { KEY_PROG1 } },
81 { KE_KEY, 0xe1, { KEY_F14 } },
82 { KE_KEY, HOME_PRESS, { KEY_CONFIG } },
83 { KE_KEY, 0xe8, { KEY_SCREENLOCK } },
84 { KE_KEY, 0xe9, { KEY_DISPLAYTOGGLE } },
85 { KE_KEY, 0xeb, { KEY_CAMERA_ZOOMOUT } },
86 { KE_KEY, 0xec, { KEY_CAMERA_UP } },
87 { KE_KEY, 0xed, { KEY_CAMERA_DOWN } },
88 { KE_KEY, 0xee, { KEY_CAMERA_LEFT } },
89 { KE_KEY, 0xef, { KEY_CAMERA_RIGHT } },
90 { KE_KEY, 0xf3, { KEY_MENU } },
91 { KE_KEY, 0xf5, { KEY_HOMEPAGE } },
92 { KE_KEY, 0xf6, { KEY_ESC } },
93 { KE_END, 0},
94};
95
96static struct quirk_entry quirk_asus_unknown = {
97};
98
99static struct quirk_entry quirk_asus_1000h = {
100 .hotplug_wireless = true,
101};
102
103static struct quirk_entry quirk_asus_et2012_type1 = {
104 .store_backlight_power = true,
105};
106
107static struct quirk_entry quirk_asus_et2012_type3 = {
108 .scalar_panel_brightness = true,
109 .store_backlight_power = true,
110};
111
112static struct quirk_entry quirk_asus_x101ch = {
113
114 .wmi_backlight_power = true,
115};
116
117static struct quirk_entry *quirks;
118
119static void et2012_quirks(void)
120{
121 const struct dmi_device *dev = NULL;
122 char oemstring[30];
123
124 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
125 if (sscanf(dev->name, "AEMS%24c", oemstring) == 1) {
126 if (oemstring[18] == '1')
127 quirks = &quirk_asus_et2012_type1;
128 else if (oemstring[18] == '3')
129 quirks = &quirk_asus_et2012_type3;
130 break;
131 }
132 }
133}
134
135static int dmi_matched(const struct dmi_system_id *dmi)
136{
137 char *model;
138
139 quirks = dmi->driver_data;
140
141 model = (char *)dmi->matches[1].substr;
142 if (unlikely(strncmp(model, "ET2012", 6) == 0))
143 et2012_quirks();
144
145 return 1;
146}
147
148static const struct dmi_system_id asus_quirks[] = {
149 {
150 .callback = dmi_matched,
151 .ident = "ASUSTeK Computer INC. 1000H",
152 .matches = {
153 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
154 DMI_MATCH(DMI_PRODUCT_NAME, "1000H"),
155 },
156 .driver_data = &quirk_asus_1000h,
157 },
158 {
159 .callback = dmi_matched,
160 .ident = "ASUSTeK Computer INC. ET2012E/I",
161 .matches = {
162 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer INC."),
163 DMI_MATCH(DMI_PRODUCT_NAME, "ET2012"),
164 },
165 .driver_data = &quirk_asus_unknown,
166 },
167 {
168 .callback = dmi_matched,
169 .ident = "ASUSTeK Computer INC. X101CH",
170 .matches = {
171 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
172 DMI_MATCH(DMI_PRODUCT_NAME, "X101CH"),
173 },
174 .driver_data = &quirk_asus_x101ch,
175 },
176 {
177 .callback = dmi_matched,
178 .ident = "ASUSTeK Computer INC. 1015CX",
179 .matches = {
180 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
181 DMI_MATCH(DMI_PRODUCT_NAME, "1015CX"),
182 },
183 .driver_data = &quirk_asus_x101ch,
184 },
185 {},
186};
187
188static void eeepc_wmi_key_filter(struct asus_wmi_driver *asus_wmi, int *code,
189 unsigned int *value, bool *autorelease)
190{
191 switch (*code) {
192 case HOME_PRESS:
193 *value = 1;
194 *autorelease = 0;
195 break;
196 case HOME_HOLD:
197 *code = ASUS_WMI_KEY_IGNORE;
198 break;
199 case HOME_RELEASE:
200 *code = HOME_PRESS;
201 *value = 0;
202 *autorelease = 0;
203 break;
204 }
205}
206
207static int eeepc_wmi_probe(struct platform_device *pdev)
208{
209 if (acpi_dev_found(EEEPC_ACPI_HID)) {
210 pr_warn("Found legacy ATKD device (%s)\n", EEEPC_ACPI_HID);
211 pr_warn("WMI device present, but legacy ATKD device is also "
212 "present and enabled\n");
213 pr_warn("You probably booted with acpi_osi=\"Linux\" or "
214 "acpi_osi=\"!Windows 2009\"\n");
215 pr_warn("Can't load eeepc-wmi, use default acpi_osi "
216 "(preferred) or eeepc-laptop\n");
217 return -EBUSY;
218 }
219 return 0;
220}
221
222static void eeepc_wmi_quirks(struct asus_wmi_driver *driver)
223{
224 quirks = &quirk_asus_unknown;
225 quirks->hotplug_wireless = hotplug_wireless;
226
227 dmi_check_system(asus_quirks);
228
229 driver->quirks = quirks;
230 driver->quirks->wapf = -1;
231 driver->panel_power = FB_BLANK_UNBLANK;
232}
233
234static struct asus_wmi_driver asus_wmi_driver = {
235 .name = EEEPC_WMI_FILE,
236 .owner = THIS_MODULE,
237 .event_guid = EEEPC_WMI_EVENT_GUID,
238 .keymap = eeepc_wmi_keymap,
239 .input_name = "Eee PC WMI hotkeys",
240 .input_phys = EEEPC_WMI_FILE "/input0",
241 .key_filter = eeepc_wmi_key_filter,
242 .probe = eeepc_wmi_probe,
243 .detect_quirks = eeepc_wmi_quirks,
244};
245
246
247static int __init eeepc_wmi_init(void)
248{
249 return asus_wmi_register_driver(&asus_wmi_driver);
250}
251
252static void __exit eeepc_wmi_exit(void)
253{
254 asus_wmi_unregister_driver(&asus_wmi_driver);
255}
256
257module_init(eeepc_wmi_init);
258module_exit(eeepc_wmi_exit);
259