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>
33 #define ASUS_NB_WMI_FILE "asus-nb-wmi"
35 MODULE_AUTHOR("Corentin Chary <corentin.chary@gmail.com>");
36 MODULE_DESCRIPTION("Asus Notebooks WMI Hotkey Driver");
37 MODULE_LICENSE("GPL");
39 #define ASUS_NB_WMI_EVENT_GUID "0B3CBB35-E3C2-45ED-91C2-4C5A6D195D1C"
41 MODULE_ALIAS("wmi:"ASUS_NB_WMI_EVENT_GUID
);
44 * WAPF defines the behavior of the Fn+Fx wlan key
45 * The significance of values is yet to be found, but
47 * Bit | Bluetooth | WLAN
48 * 0 | Hardware | Hardware
49 * 1 | Hardware | Software
50 * 4 | Software | Software
53 module_param(wapf
, uint
, 0444);
54 MODULE_PARM_DESC(wapf
, "WAPF value");
56 static struct quirk_entry
*quirks
;
58 static struct quirk_entry quirk_asus_unknown
= {
63 * For those machines that need software to control bt/wifi status
64 * and can't adjust brightness through ACPI interface
65 * and have duplicate events(ACPI and WMI) for display toggle
67 static struct quirk_entry quirk_asus_x55u
= {
69 .wmi_backlight_power
= true,
70 .no_display_toggle
= true,
73 static struct quirk_entry quirk_asus_wapf4
= {
77 static struct quirk_entry quirk_asus_x200ca
= {
81 static int dmi_matched(const struct dmi_system_id
*dmi
)
83 quirks
= dmi
->driver_data
;
87 static const struct dmi_system_id asus_quirks
[] = {
89 .callback
= dmi_matched
,
90 .ident
= "ASUSTeK COMPUTER INC. U32U",
92 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK Computer Inc."),
93 DMI_MATCH(DMI_PRODUCT_NAME
, "U32U"),
96 * Note this machine has a Brazos APU, and most Brazos Asus
97 * machines need quirk_asus_x55u / wmi_backlight_power but
98 * here acpi-video seems to work fine for backlight control.
100 .driver_data
= &quirk_asus_wapf4
,
103 .callback
= dmi_matched
,
104 .ident
= "ASUSTeK COMPUTER INC. X302UA",
106 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
107 DMI_MATCH(DMI_PRODUCT_NAME
, "X302UA"),
109 .driver_data
= &quirk_asus_wapf4
,
112 .callback
= dmi_matched
,
113 .ident
= "ASUSTeK COMPUTER INC. X401U",
115 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
116 DMI_MATCH(DMI_PRODUCT_NAME
, "X401U"),
118 .driver_data
= &quirk_asus_x55u
,
121 .callback
= dmi_matched
,
122 .ident
= "ASUSTeK COMPUTER INC. X401A",
124 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
125 DMI_MATCH(DMI_PRODUCT_NAME
, "X401A"),
127 .driver_data
= &quirk_asus_wapf4
,
130 .callback
= dmi_matched
,
131 .ident
= "ASUSTeK COMPUTER INC. X401A1",
133 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
134 DMI_MATCH(DMI_PRODUCT_NAME
, "X401A1"),
136 .driver_data
= &quirk_asus_wapf4
,
139 .callback
= dmi_matched
,
140 .ident
= "ASUSTeK COMPUTER INC. X45U",
142 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
143 DMI_MATCH(DMI_PRODUCT_NAME
, "X45U"),
145 .driver_data
= &quirk_asus_wapf4
,
148 .callback
= dmi_matched
,
149 .ident
= "ASUSTeK COMPUTER INC. X456UA",
151 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
152 DMI_MATCH(DMI_PRODUCT_NAME
, "X456UA"),
154 .driver_data
= &quirk_asus_wapf4
,
157 .callback
= dmi_matched
,
158 .ident
= "ASUSTeK COMPUTER INC. X456UF",
160 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
161 DMI_MATCH(DMI_PRODUCT_NAME
, "X456UF"),
163 .driver_data
= &quirk_asus_wapf4
,
166 .callback
= dmi_matched
,
167 .ident
= "ASUSTeK COMPUTER INC. X501U",
169 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
170 DMI_MATCH(DMI_PRODUCT_NAME
, "X501U"),
172 .driver_data
= &quirk_asus_x55u
,
175 .callback
= dmi_matched
,
176 .ident
= "ASUSTeK COMPUTER INC. X501A",
178 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
179 DMI_MATCH(DMI_PRODUCT_NAME
, "X501A"),
181 .driver_data
= &quirk_asus_wapf4
,
184 .callback
= dmi_matched
,
185 .ident
= "ASUSTeK COMPUTER INC. X501A1",
187 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
188 DMI_MATCH(DMI_PRODUCT_NAME
, "X501A1"),
190 .driver_data
= &quirk_asus_wapf4
,
193 .callback
= dmi_matched
,
194 .ident
= "ASUSTeK COMPUTER INC. X550CA",
196 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
197 DMI_MATCH(DMI_PRODUCT_NAME
, "X550CA"),
199 .driver_data
= &quirk_asus_wapf4
,
202 .callback
= dmi_matched
,
203 .ident
= "ASUSTeK COMPUTER INC. X550CC",
205 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
206 DMI_MATCH(DMI_PRODUCT_NAME
, "X550CC"),
208 .driver_data
= &quirk_asus_wapf4
,
211 .callback
= dmi_matched
,
212 .ident
= "ASUSTeK COMPUTER INC. X550CL",
214 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
215 DMI_MATCH(DMI_PRODUCT_NAME
, "X550CL"),
217 .driver_data
= &quirk_asus_wapf4
,
220 .callback
= dmi_matched
,
221 .ident
= "ASUSTeK COMPUTER INC. X550VB",
223 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
224 DMI_MATCH(DMI_PRODUCT_NAME
, "X550VB"),
226 .driver_data
= &quirk_asus_wapf4
,
229 .callback
= dmi_matched
,
230 .ident
= "ASUSTeK COMPUTER INC. X551CA",
232 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
233 DMI_MATCH(DMI_PRODUCT_NAME
, "X551CA"),
235 .driver_data
= &quirk_asus_wapf4
,
238 .callback
= dmi_matched
,
239 .ident
= "ASUSTeK COMPUTER INC. X55A",
241 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
242 DMI_MATCH(DMI_PRODUCT_NAME
, "X55A"),
244 .driver_data
= &quirk_asus_wapf4
,
247 .callback
= dmi_matched
,
248 .ident
= "ASUSTeK COMPUTER INC. X55C",
250 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
251 DMI_MATCH(DMI_PRODUCT_NAME
, "X55C"),
253 .driver_data
= &quirk_asus_wapf4
,
256 .callback
= dmi_matched
,
257 .ident
= "ASUSTeK COMPUTER INC. X55U",
259 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
260 DMI_MATCH(DMI_PRODUCT_NAME
, "X55U"),
262 .driver_data
= &quirk_asus_x55u
,
265 .callback
= dmi_matched
,
266 .ident
= "ASUSTeK COMPUTER INC. X55VD",
268 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
269 DMI_MATCH(DMI_PRODUCT_NAME
, "X55VD"),
271 .driver_data
= &quirk_asus_wapf4
,
274 .callback
= dmi_matched
,
275 .ident
= "ASUSTeK COMPUTER INC. X75A",
277 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
278 DMI_MATCH(DMI_PRODUCT_NAME
, "X75A"),
280 .driver_data
= &quirk_asus_wapf4
,
283 .callback
= dmi_matched
,
284 .ident
= "ASUSTeK COMPUTER INC. X75VBP",
286 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
287 DMI_MATCH(DMI_PRODUCT_NAME
, "X75VBP"),
289 .driver_data
= &quirk_asus_wapf4
,
292 .callback
= dmi_matched
,
293 .ident
= "ASUSTeK COMPUTER INC. 1015E",
295 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
296 DMI_MATCH(DMI_PRODUCT_NAME
, "1015E"),
298 .driver_data
= &quirk_asus_wapf4
,
301 .callback
= dmi_matched
,
302 .ident
= "ASUSTeK COMPUTER INC. 1015U",
304 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
305 DMI_MATCH(DMI_PRODUCT_NAME
, "1015U"),
307 .driver_data
= &quirk_asus_wapf4
,
310 .callback
= dmi_matched
,
311 .ident
= "ASUSTeK COMPUTER INC. X200CA",
313 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
314 DMI_MATCH(DMI_PRODUCT_NAME
, "X200CA"),
316 .driver_data
= &quirk_asus_x200ca
,
321 static void asus_nb_wmi_quirks(struct asus_wmi_driver
*driver
)
323 quirks
= &quirk_asus_unknown
;
324 dmi_check_system(asus_quirks
);
326 driver
->quirks
= quirks
;
327 driver
->panel_power
= FB_BLANK_UNBLANK
;
329 /* overwrite the wapf setting if the wapf paramater is specified */
336 static const struct key_entry asus_nb_wmi_keymap
[] = {
337 { KE_KEY
, ASUS_WMI_BRN_DOWN
, { KEY_BRIGHTNESSDOWN
} },
338 { KE_KEY
, ASUS_WMI_BRN_UP
, { KEY_BRIGHTNESSUP
} },
339 { KE_KEY
, 0x30, { KEY_VOLUMEUP
} },
340 { KE_KEY
, 0x31, { KEY_VOLUMEDOWN
} },
341 { KE_KEY
, 0x32, { KEY_MUTE
} },
342 { KE_KEY
, 0x33, { KEY_DISPLAYTOGGLE
} }, /* LCD on */
343 { KE_KEY
, 0x34, { KEY_DISPLAY_OFF
} }, /* LCD off */
344 { KE_KEY
, 0x40, { KEY_PREVIOUSSONG
} },
345 { KE_KEY
, 0x41, { KEY_NEXTSONG
} },
346 { KE_KEY
, 0x43, { KEY_STOPCD
} }, /* Stop/Eject */
347 { KE_KEY
, 0x45, { KEY_PLAYPAUSE
} },
348 { KE_KEY
, 0x4c, { KEY_MEDIA
} }, /* WMP Key */
349 { KE_KEY
, 0x50, { KEY_EMAIL
} },
350 { KE_KEY
, 0x51, { KEY_WWW
} },
351 { KE_KEY
, 0x55, { KEY_CALC
} },
352 { KE_IGNORE
, 0x57, }, /* Battery mode */
353 { KE_IGNORE
, 0x58, }, /* AC mode */
354 { KE_KEY
, 0x5C, { KEY_F15
} }, /* Power Gear key */
355 { KE_KEY
, 0x5D, { KEY_WLAN
} }, /* Wireless console Toggle */
356 { KE_KEY
, 0x5E, { KEY_WLAN
} }, /* Wireless console Enable */
357 { KE_KEY
, 0x5F, { KEY_WLAN
} }, /* Wireless console Disable */
358 { KE_KEY
, 0x60, { KEY_TOUCHPAD_ON
} },
359 { KE_KEY
, 0x61, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD only */
360 { KE_KEY
, 0x62, { KEY_SWITCHVIDEOMODE
} }, /* SDSP CRT only */
361 { KE_KEY
, 0x63, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + CRT */
362 { KE_KEY
, 0x64, { KEY_SWITCHVIDEOMODE
} }, /* SDSP TV */
363 { KE_KEY
, 0x65, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + TV */
364 { KE_KEY
, 0x66, { KEY_SWITCHVIDEOMODE
} }, /* SDSP CRT + TV */
365 { KE_KEY
, 0x67, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + CRT + TV */
366 { KE_KEY
, 0x6B, { KEY_TOUCHPAD_TOGGLE
} },
367 { KE_IGNORE
, 0x6E, }, /* Low Battery notification */
368 { KE_KEY
, 0x7D, { KEY_BLUETOOTH
} }, /* Bluetooth Enable */
369 { KE_KEY
, 0x7E, { KEY_BLUETOOTH
} }, /* Bluetooth Disable */
370 { KE_KEY
, 0x82, { KEY_CAMERA
} },
371 { KE_KEY
, 0x88, { KEY_RFKILL
} }, /* Radio Toggle Key */
372 { KE_KEY
, 0x8A, { KEY_PROG1
} }, /* Color enhancement mode */
373 { KE_KEY
, 0x8C, { KEY_SWITCHVIDEOMODE
} }, /* SDSP DVI only */
374 { KE_KEY
, 0x8D, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + DVI */
375 { KE_KEY
, 0x8E, { KEY_SWITCHVIDEOMODE
} }, /* SDSP CRT + DVI */
376 { KE_KEY
, 0x8F, { KEY_SWITCHVIDEOMODE
} }, /* SDSP TV + DVI */
377 { KE_KEY
, 0x90, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + CRT + DVI */
378 { KE_KEY
, 0x91, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + TV + DVI */
379 { KE_KEY
, 0x92, { KEY_SWITCHVIDEOMODE
} }, /* SDSP CRT + TV + DVI */
380 { KE_KEY
, 0x93, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + CRT + TV + DVI */
381 { KE_KEY
, 0x95, { KEY_MEDIA
} },
382 { KE_KEY
, 0x99, { KEY_PHONE
} },
383 { KE_KEY
, 0xA0, { KEY_SWITCHVIDEOMODE
} }, /* SDSP HDMI only */
384 { KE_KEY
, 0xA1, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + HDMI */
385 { KE_KEY
, 0xA2, { KEY_SWITCHVIDEOMODE
} }, /* SDSP CRT + HDMI */
386 { KE_KEY
, 0xA3, { KEY_SWITCHVIDEOMODE
} }, /* SDSP TV + HDMI */
387 { KE_KEY
, 0xA4, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + CRT + HDMI */
388 { KE_KEY
, 0xA5, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + TV + HDMI */
389 { KE_KEY
, 0xA6, { KEY_SWITCHVIDEOMODE
} }, /* SDSP CRT + TV + HDMI */
390 { KE_KEY
, 0xA7, { KEY_SWITCHVIDEOMODE
} }, /* SDSP LCD + CRT + TV + HDMI */
391 { KE_KEY
, 0xB5, { KEY_CALC
} },
392 { KE_KEY
, 0xC4, { KEY_KBDILLUMUP
} },
393 { KE_KEY
, 0xC5, { KEY_KBDILLUMDOWN
} },
394 { KE_IGNORE
, 0xC6, }, /* Ambient Light Sensor notification */
395 { KE_KEY
, 0xFA, { KEY_PROG2
} }, /* Lid flip action */
399 static struct asus_wmi_driver asus_nb_wmi_driver
= {
400 .name
= ASUS_NB_WMI_FILE
,
401 .owner
= THIS_MODULE
,
402 .event_guid
= ASUS_NB_WMI_EVENT_GUID
,
403 .keymap
= asus_nb_wmi_keymap
,
404 .input_name
= "Asus WMI hotkeys",
405 .input_phys
= ASUS_NB_WMI_FILE
"/input0",
406 .detect_quirks
= asus_nb_wmi_quirks
,
410 static int __init
asus_nb_wmi_init(void)
412 return asus_wmi_register_driver(&asus_nb_wmi_driver
);
415 static void __exit
asus_nb_wmi_exit(void)
417 asus_wmi_unregister_driver(&asus_nb_wmi_driver
);
420 module_init(asus_nb_wmi_init
);
421 module_exit(asus_nb_wmi_exit
);