2 * Asus Notebooks WMI hotkey driver
4 * Copyright(C) 2010 Corentin Chary <corentin.chary@gmail.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/init.h>
26 #include <linux/input.h>
27 #include <linux/input/sparse-keymap.h>
29 #include <linux/dmi.h>
30 #include <linux/i8042.h>
34 #define ASUS_NB_WMI_FILE "asus-nb-wmi"
36 MODULE_AUTHOR("Corentin Chary <corentin.chary@gmail.com>");
37 MODULE_DESCRIPTION("Asus Notebooks WMI Hotkey Driver");
38 MODULE_LICENSE("GPL");
40 #define ASUS_NB_WMI_EVENT_GUID "0B3CBB35-E3C2-45ED-91C2-4C5A6D195D1C"
42 MODULE_ALIAS("wmi:"ASUS_NB_WMI_EVENT_GUID
);
45 * WAPF defines the behavior of the Fn+Fx wlan key
46 * The significance of values is yet to be found, but
48 * Bit | Bluetooth | WLAN
49 * 0 | Hardware | Hardware
50 * 1 | Hardware | Software
51 * 4 | Software | Software
54 module_param(wapf
, uint
, 0444);
55 MODULE_PARM_DESC(wapf
, "WAPF value");
57 static struct quirk_entry
*quirks
;
59 static bool asus_q500a_i8042_filter(unsigned char data
, unsigned char str
,
65 if (str
& I8042_STR_AUXDATA
)
68 if (unlikely(data
== 0xe1)) {
71 } else if (unlikely(extended
)) {
79 static struct quirk_entry quirk_asus_unknown
= {
81 .wmi_backlight_set_devstate
= true,
84 static struct quirk_entry quirk_asus_q500a
= {
85 .i8042_filter
= asus_q500a_i8042_filter
,
86 .wmi_backlight_set_devstate
= true,
90 * For those machines that need software to control bt/wifi status
91 * and can't adjust brightness through ACPI interface
92 * and have duplicate events(ACPI and WMI) for display toggle
94 static struct quirk_entry quirk_asus_x55u
= {
96 .wmi_backlight_power
= true,
97 .wmi_backlight_set_devstate
= true,
98 .no_display_toggle
= true,
101 static struct quirk_entry quirk_asus_wapf4
= {
103 .wmi_backlight_set_devstate
= true,
106 static struct quirk_entry quirk_asus_x200ca
= {
108 .wmi_backlight_set_devstate
= true,
111 static struct quirk_entry quirk_asus_ux303ub
= {
112 .wmi_backlight_native
= true,
113 .wmi_backlight_set_devstate
= true,
116 static struct quirk_entry quirk_asus_x550lb
= {
117 .wmi_backlight_set_devstate
= true,
121 static struct quirk_entry quirk_asus_forceals
= {
122 .wmi_backlight_set_devstate
= true,
123 .wmi_force_als_set
= true,
126 static int dmi_matched(const struct dmi_system_id
*dmi
)
128 pr_info("Identified laptop model '%s'\n", dmi
->ident
);
129 quirks
= dmi
->driver_data
;
133 static const struct dmi_system_id asus_quirks
[] = {
135 .callback
= dmi_matched
,
136 .ident
= "ASUSTeK COMPUTER INC. Q500A",
138 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
139 DMI_MATCH(DMI_PRODUCT_NAME
, "Q500A"),
141 .driver_data
= &quirk_asus_q500a
,
144 .callback
= dmi_matched
,
145 .ident
= "ASUSTeK COMPUTER INC. U32U",
147 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK Computer Inc."),
148 DMI_MATCH(DMI_PRODUCT_NAME
, "U32U"),
151 * Note this machine has a Brazos APU, and most Brazos Asus
152 * machines need quirk_asus_x55u / wmi_backlight_power but
153 * here acpi-video seems to work fine for backlight control.
155 .driver_data
= &quirk_asus_wapf4
,
158 .callback
= dmi_matched
,
159 .ident
= "ASUSTeK COMPUTER INC. X302UA",
161 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
162 DMI_MATCH(DMI_PRODUCT_NAME
, "X302UA"),
164 .driver_data
= &quirk_asus_wapf4
,
167 .callback
= dmi_matched
,
168 .ident
= "ASUSTeK COMPUTER INC. X401U",
170 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
171 DMI_MATCH(DMI_PRODUCT_NAME
, "X401U"),
173 .driver_data
= &quirk_asus_x55u
,
176 .callback
= dmi_matched
,
177 .ident
= "ASUSTeK COMPUTER INC. X401A",
179 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
180 DMI_MATCH(DMI_PRODUCT_NAME
, "X401A"),
182 .driver_data
= &quirk_asus_wapf4
,
185 .callback
= dmi_matched
,
186 .ident
= "ASUSTeK COMPUTER INC. X401A1",
188 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
189 DMI_MATCH(DMI_PRODUCT_NAME
, "X401A1"),
191 .driver_data
= &quirk_asus_wapf4
,
194 .callback
= dmi_matched
,
195 .ident
= "ASUSTeK COMPUTER INC. X45U",
197 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
198 DMI_MATCH(DMI_PRODUCT_NAME
, "X45U"),
200 .driver_data
= &quirk_asus_wapf4
,
203 .callback
= dmi_matched
,
204 .ident
= "ASUSTeK COMPUTER INC. X456UA",
206 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
207 DMI_MATCH(DMI_PRODUCT_NAME
, "X456UA"),
209 .driver_data
= &quirk_asus_wapf4
,
212 .callback
= dmi_matched
,
213 .ident
= "ASUSTeK COMPUTER INC. X456UF",
215 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
216 DMI_MATCH(DMI_PRODUCT_NAME
, "X456UF"),
218 .driver_data
= &quirk_asus_wapf4
,
221 .callback
= dmi_matched
,
222 .ident
= "ASUSTeK COMPUTER INC. X501U",
224 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
225 DMI_MATCH(DMI_PRODUCT_NAME
, "X501U"),
227 .driver_data
= &quirk_asus_x55u
,
230 .callback
= dmi_matched
,
231 .ident
= "ASUSTeK COMPUTER INC. X501A",
233 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
234 DMI_MATCH(DMI_PRODUCT_NAME
, "X501A"),
236 .driver_data
= &quirk_asus_wapf4
,
239 .callback
= dmi_matched
,
240 .ident
= "ASUSTeK COMPUTER INC. X501A1",
242 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
243 DMI_MATCH(DMI_PRODUCT_NAME
, "X501A1"),
245 .driver_data
= &quirk_asus_wapf4
,
248 .callback
= dmi_matched
,
249 .ident
= "ASUSTeK COMPUTER INC. X550CA",
251 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
252 DMI_MATCH(DMI_PRODUCT_NAME
, "X550CA"),
254 .driver_data
= &quirk_asus_wapf4
,
257 .callback
= dmi_matched
,
258 .ident
= "ASUSTeK COMPUTER INC. X550CC",
260 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
261 DMI_MATCH(DMI_PRODUCT_NAME
, "X550CC"),
263 .driver_data
= &quirk_asus_wapf4
,
266 .callback
= dmi_matched
,
267 .ident
= "ASUSTeK COMPUTER INC. X550CL",
269 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
270 DMI_MATCH(DMI_PRODUCT_NAME
, "X550CL"),
272 .driver_data
= &quirk_asus_wapf4
,
275 .callback
= dmi_matched
,
276 .ident
= "ASUSTeK COMPUTER INC. X550VB",
278 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
279 DMI_MATCH(DMI_PRODUCT_NAME
, "X550VB"),
281 .driver_data
= &quirk_asus_wapf4
,
284 .callback
= dmi_matched
,
285 .ident
= "ASUSTeK COMPUTER INC. X551CA",
287 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
288 DMI_MATCH(DMI_PRODUCT_NAME
, "X551CA"),
290 .driver_data
= &quirk_asus_wapf4
,
293 .callback
= dmi_matched
,
294 .ident
= "ASUSTeK COMPUTER INC. X55A",
296 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
297 DMI_MATCH(DMI_PRODUCT_NAME
, "X55A"),
299 .driver_data
= &quirk_asus_wapf4
,
302 .callback
= dmi_matched
,
303 .ident
= "ASUSTeK COMPUTER INC. X55C",
305 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
306 DMI_MATCH(DMI_PRODUCT_NAME
, "X55C"),
308 .driver_data
= &quirk_asus_wapf4
,
311 .callback
= dmi_matched
,
312 .ident
= "ASUSTeK COMPUTER INC. X55U",
314 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
315 DMI_MATCH(DMI_PRODUCT_NAME
, "X55U"),
317 .driver_data
= &quirk_asus_x55u
,
320 .callback
= dmi_matched
,
321 .ident
= "ASUSTeK COMPUTER INC. X55VD",
323 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
324 DMI_MATCH(DMI_PRODUCT_NAME
, "X55VD"),
326 .driver_data
= &quirk_asus_wapf4
,
329 .callback
= dmi_matched
,
330 .ident
= "ASUSTeK COMPUTER INC. X75A",
332 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
333 DMI_MATCH(DMI_PRODUCT_NAME
, "X75A"),
335 .driver_data
= &quirk_asus_wapf4
,
338 .callback
= dmi_matched
,
339 .ident
= "ASUSTeK COMPUTER INC. X75VBP",
341 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
342 DMI_MATCH(DMI_PRODUCT_NAME
, "X75VBP"),
344 .driver_data
= &quirk_asus_wapf4
,
347 .callback
= dmi_matched
,
348 .ident
= "ASUSTeK COMPUTER INC. X75VD",
350 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
351 DMI_MATCH(DMI_PRODUCT_NAME
, "X75VD"),
353 .driver_data
= &quirk_asus_wapf4
,
356 .callback
= dmi_matched
,
357 .ident
= "ASUSTeK COMPUTER INC. 1015E",
359 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
360 DMI_MATCH(DMI_PRODUCT_NAME
, "1015E"),
362 .driver_data
= &quirk_asus_wapf4
,
365 .callback
= dmi_matched
,
366 .ident
= "ASUSTeK COMPUTER INC. 1015U",
368 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
369 DMI_MATCH(DMI_PRODUCT_NAME
, "1015U"),
371 .driver_data
= &quirk_asus_wapf4
,
374 .callback
= dmi_matched
,
375 .ident
= "ASUSTeK COMPUTER INC. X200CA",
377 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
378 DMI_MATCH(DMI_PRODUCT_NAME
, "X200CA"),
380 .driver_data
= &quirk_asus_x200ca
,
383 .callback
= dmi_matched
,
384 .ident
= "ASUSTeK COMPUTER INC. UX303UB",
386 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
387 DMI_MATCH(DMI_PRODUCT_NAME
, "UX303UB"),
389 .driver_data
= &quirk_asus_ux303ub
,
392 .callback
= dmi_matched
,
393 .ident
= "ASUSTeK COMPUTER INC. UX330UAK",
395 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
396 DMI_MATCH(DMI_PRODUCT_NAME
, "UX330UAK"),
398 .driver_data
= &quirk_asus_forceals
,
401 .callback
= dmi_matched
,
402 .ident
= "ASUSTeK COMPUTER INC. X550LB",
404 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
405 DMI_MATCH(DMI_PRODUCT_NAME
, "X550LB"),
407 .driver_data
= &quirk_asus_x550lb
,
410 .callback
= dmi_matched
,
411 .ident
= "ASUSTeK COMPUTER INC. UX430UQ",
413 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
414 DMI_MATCH(DMI_PRODUCT_NAME
, "UX430UQ"),
416 .driver_data
= &quirk_asus_forceals
,
421 static void asus_nb_wmi_quirks(struct asus_wmi_driver
*driver
)
425 quirks
= &quirk_asus_unknown
;
426 dmi_check_system(asus_quirks
);
428 driver
->quirks
= quirks
;
429 driver
->panel_power
= FB_BLANK_UNBLANK
;
431 /* overwrite the wapf setting if the wapf paramater is specified */
437 if (quirks
->i8042_filter
) {
438 ret
= i8042_install_filter(quirks
->i8042_filter
);
440 pr_warn("Unable to install key filter\n");
443 pr_info("Using i8042 filter function for receiving events\n");
447 static const struct key_entry asus_nb_wmi_keymap
[] = {
448 { KE_KEY
, ASUS_WMI_BRN_DOWN
, { KEY_BRIGHTNESSDOWN
} },
449 { KE_KEY
, ASUS_WMI_BRN_UP
, { KEY_BRIGHTNESSUP
} },
450 { KE_KEY
, 0x30, { KEY_VOLUMEUP
} },
451 { KE_KEY
, 0x31, { KEY_VOLUMEDOWN
} },
452 { KE_KEY
, 0x32, { KEY_MUTE
} },
453 { KE_KEY
, 0x35, { KEY_SCREENLOCK
} },
454 { KE_KEY
, 0x40, { KEY_PREVIOUSSONG
} },
455 { KE_KEY
, 0x41, { KEY_NEXTSONG
} },
456 { KE_KEY
, 0x43, { KEY_STOPCD
} }, /* Stop/Eject */
457 { KE_KEY
, 0x45, { KEY_PLAYPAUSE
} },
458 { KE_KEY
, 0x4c, { KEY_MEDIA
} }, /* WMP Key */
459 { KE_KEY
, 0x50, { KEY_EMAIL
} },
460 { KE_KEY
, 0x51, { KEY_WWW
} },
461 { KE_KEY
, 0x55, { KEY_CALC
} },
462 { KE_IGNORE
, 0x57, }, /* Battery mode */
463 { KE_IGNORE
, 0x58, }, /* AC mode */
464 { KE_KEY
, 0x5C, { KEY_F15
} }, /* Power Gear key */
465 { KE_KEY
, 0x5D, { KEY_WLAN
} }, /* Wireless console Toggle */
466 { KE_KEY
, 0x5E, { KEY_WLAN
} }, /* Wireless console Enable */
467 { KE_KEY
, 0x5F, { KEY_WLAN
} }, /* Wireless console Disable */
468 { KE_KEY
, 0x60, { KEY_TOUCHPAD_ON
} },
469 { KE_KEY
, 0x61, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD only */
470 { KE_KEY
, 0x62, { KEY_SWITCHVIDEOMODE
} }, /* SDSP CRT only */
471 { KE_KEY
, 0x63, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + CRT */
472 { KE_KEY
, 0x64, { KEY_SWITCHVIDEOMODE
} }, /* SDSP TV */
473 { KE_KEY
, 0x65, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + TV */
474 { KE_KEY
, 0x66, { KEY_SWITCHVIDEOMODE
} }, /* SDSP CRT + TV */
475 { KE_KEY
, 0x67, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + CRT + TV */
476 { KE_KEY
, 0x6B, { KEY_TOUCHPAD_TOGGLE
} },
477 { KE_IGNORE
, 0x6E, }, /* Low Battery notification */
478 { KE_KEY
, 0x7a, { KEY_ALS_TOGGLE
} }, /* Ambient Light Sensor Toggle */
479 { KE_KEY
, 0x7D, { KEY_BLUETOOTH
} }, /* Bluetooth Enable */
480 { KE_KEY
, 0x7E, { KEY_BLUETOOTH
} }, /* Bluetooth Disable */
481 { KE_KEY
, 0x82, { KEY_CAMERA
} },
482 { KE_KEY
, 0x88, { KEY_RFKILL
} }, /* Radio Toggle Key */
483 { KE_KEY
, 0x8A, { KEY_PROG1
} }, /* Color enhancement mode */
484 { KE_KEY
, 0x8C, { KEY_SWITCHVIDEOMODE
} }, /* SDSP DVI only */
485 { KE_KEY
, 0x8D, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + DVI */
486 { KE_KEY
, 0x8E, { KEY_SWITCHVIDEOMODE
} }, /* SDSP CRT + DVI */
487 { KE_KEY
, 0x8F, { KEY_SWITCHVIDEOMODE
} }, /* SDSP TV + DVI */
488 { KE_KEY
, 0x90, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + CRT + DVI */
489 { KE_KEY
, 0x91, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + TV + DVI */
490 { KE_KEY
, 0x92, { KEY_SWITCHVIDEOMODE
} }, /* SDSP CRT + TV + DVI */
491 { KE_KEY
, 0x93, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + CRT + TV + DVI */
492 { KE_KEY
, 0x95, { KEY_MEDIA
} },
493 { KE_KEY
, 0x99, { KEY_PHONE
} },
494 { KE_KEY
, 0xA0, { KEY_SWITCHVIDEOMODE
} }, /* SDSP HDMI only */
495 { KE_KEY
, 0xA1, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + HDMI */
496 { KE_KEY
, 0xA2, { KEY_SWITCHVIDEOMODE
} }, /* SDSP CRT + HDMI */
497 { KE_KEY
, 0xA3, { KEY_SWITCHVIDEOMODE
} }, /* SDSP TV + HDMI */
498 { KE_KEY
, 0xA4, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + CRT + HDMI */
499 { KE_KEY
, 0xA5, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + TV + HDMI */
500 { KE_KEY
, 0xA6, { KEY_SWITCHVIDEOMODE
} }, /* SDSP CRT + TV + HDMI */
501 { KE_KEY
, 0xA7, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + CRT + TV + HDMI */
502 { KE_KEY
, 0xB5, { KEY_CALC
} },
503 { KE_KEY
, 0xC4, { KEY_KBDILLUMUP
} },
504 { KE_KEY
, 0xC5, { KEY_KBDILLUMDOWN
} },
505 { KE_IGNORE
, 0xC6, }, /* Ambient Light Sensor notification */
506 { KE_KEY
, 0xFA, { KEY_PROG2
} }, /* Lid flip action */
510 static struct asus_wmi_driver asus_nb_wmi_driver
= {
511 .name
= ASUS_NB_WMI_FILE
,
512 .owner
= THIS_MODULE
,
513 .event_guid
= ASUS_NB_WMI_EVENT_GUID
,
514 .keymap
= asus_nb_wmi_keymap
,
515 .input_name
= "Asus WMI hotkeys",
516 .input_phys
= ASUS_NB_WMI_FILE
"/input0",
517 .detect_quirks
= asus_nb_wmi_quirks
,
520 static const struct dmi_system_id asus_nb_wmi_blacklist
[] __initconst
= {
523 * asus-nb-wm adds no functionality. The T100TA has a detachable
524 * USB kbd, so no hotkeys and it has no WMI rfkill; and loading
525 * asus-nb-wm causes the camera LED to turn and _stay_ on.
528 DMI_EXACT_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
529 DMI_EXACT_MATCH(DMI_PRODUCT_NAME
, "T100TA"),
533 /* The Asus T200TA has the same issue as the T100TA */
535 DMI_EXACT_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
536 DMI_EXACT_MATCH(DMI_PRODUCT_NAME
, "T200TA"),
539 {} /* Terminating entry */
542 static int __init
asus_nb_wmi_init(void)
544 if (dmi_check_system(asus_nb_wmi_blacklist
))
547 return asus_wmi_register_driver(&asus_nb_wmi_driver
);
550 static void __exit
asus_nb_wmi_exit(void)
552 asus_wmi_unregister_driver(&asus_nb_wmi_driver
);
555 module_init(asus_nb_wmi_init
);
556 module_exit(asus_nb_wmi_exit
);