1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Eee PC WMI hotkey driver
5 * Copyright(C) 2010 Intel Corporation.
6 * Copyright(C) 2010-2011 Corentin Chary <corentin.chary@gmail.com>
8 * Portions based on wistron_btns.c:
9 * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
10 * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
11 * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
14 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/init.h>
19 #include <linux/input.h>
20 #include <linux/input/sparse-keymap.h>
21 #include <linux/dmi.h>
23 #include <linux/acpi.h>
27 #define EEEPC_WMI_FILE "eeepc-wmi"
29 MODULE_AUTHOR("Corentin Chary <corentin.chary@gmail.com>");
30 MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver");
31 MODULE_LICENSE("GPL");
33 #define EEEPC_ACPI_HID "ASUS010" /* old _HID used in eeepc-laptop */
35 #define EEEPC_WMI_EVENT_GUID "ABBC0F72-8EA1-11D1-00A0-C90629100000"
37 MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID
);
39 static bool hotplug_wireless
;
41 module_param(hotplug_wireless
, bool, 0444);
42 MODULE_PARM_DESC(hotplug_wireless
,
43 "Enable hotplug for wireless device. "
44 "If your laptop needs that, please report to "
45 "acpi4asus-user@lists.sourceforge.net.");
47 /* Values for T101MT "Home" key */
48 #define HOME_PRESS 0xe4
49 #define HOME_HOLD 0xea
50 #define HOME_RELEASE 0xe5
52 static const struct key_entry eeepc_wmi_keymap
[] = {
53 { KE_KEY
, ASUS_WMI_BRN_DOWN
, { KEY_BRIGHTNESSDOWN
} },
54 { KE_KEY
, ASUS_WMI_BRN_UP
, { KEY_BRIGHTNESSUP
} },
55 /* Sleep already handled via generic ACPI code */
56 { KE_KEY
, 0x30, { KEY_VOLUMEUP
} },
57 { KE_KEY
, 0x31, { KEY_VOLUMEDOWN
} },
58 { KE_KEY
, 0x32, { KEY_MUTE
} },
59 { KE_KEY
, 0x5c, { KEY_F15
} }, /* Power Gear key */
60 { KE_KEY
, 0x5d, { KEY_WLAN
} },
61 { KE_KEY
, 0x6b, { KEY_TOUCHPAD_TOGGLE
} }, /* Toggle Touchpad */
62 { KE_KEY
, 0x82, { KEY_CAMERA
} },
63 { KE_KEY
, 0x83, { KEY_CAMERA_ZOOMIN
} },
64 { KE_KEY
, 0x88, { KEY_WLAN
} },
65 { KE_KEY
, 0xbd, { KEY_CAMERA
} },
66 { KE_KEY
, 0xcc, { KEY_SWITCHVIDEOMODE
} },
67 { KE_KEY
, 0xe0, { KEY_PROG1
} }, /* Task Manager */
68 { KE_KEY
, 0xe1, { KEY_F14
} }, /* Change Resolution */
69 { KE_KEY
, HOME_PRESS
, { KEY_CONFIG
} }, /* Home/Express gate key */
70 { KE_KEY
, 0xe8, { KEY_SCREENLOCK
} },
71 { KE_KEY
, 0xe9, { KEY_DISPLAYTOGGLE
} },
72 { KE_KEY
, 0xeb, { KEY_CAMERA_ZOOMOUT
} },
73 { KE_KEY
, 0xec, { KEY_CAMERA_UP
} },
74 { KE_KEY
, 0xed, { KEY_CAMERA_DOWN
} },
75 { KE_KEY
, 0xee, { KEY_CAMERA_LEFT
} },
76 { KE_KEY
, 0xef, { KEY_CAMERA_RIGHT
} },
77 { KE_KEY
, 0xf3, { KEY_MENU
} },
78 { KE_KEY
, 0xf5, { KEY_HOMEPAGE
} },
79 { KE_KEY
, 0xf6, { KEY_ESC
} },
83 static struct quirk_entry quirk_asus_unknown
= {
86 static struct quirk_entry quirk_asus_1000h
= {
87 .hotplug_wireless
= true,
90 static struct quirk_entry quirk_asus_et2012_type1
= {
91 .store_backlight_power
= true,
94 static struct quirk_entry quirk_asus_et2012_type3
= {
95 .scalar_panel_brightness
= true,
96 .store_backlight_power
= true,
99 static struct quirk_entry quirk_asus_x101ch
= {
100 /* We need this when ACPI function doesn't do this well */
101 .wmi_backlight_power
= true,
104 static struct quirk_entry
*quirks
;
106 static void et2012_quirks(void)
108 const struct dmi_device
*dev
= NULL
;
111 while ((dev
= dmi_find_device(DMI_DEV_TYPE_OEM_STRING
, NULL
, dev
))) {
112 if (sscanf(dev
->name
, "AEMS%24c", oemstring
) == 1) {
113 if (oemstring
[18] == '1')
114 quirks
= &quirk_asus_et2012_type1
;
115 else if (oemstring
[18] == '3')
116 quirks
= &quirk_asus_et2012_type3
;
122 static int dmi_matched(const struct dmi_system_id
*dmi
)
126 quirks
= dmi
->driver_data
;
128 model
= (char *)dmi
->matches
[1].substr
;
129 if (unlikely(strncmp(model
, "ET2012", 6) == 0))
135 static const struct dmi_system_id asus_quirks
[] = {
137 .callback
= dmi_matched
,
138 .ident
= "ASUSTeK Computer INC. 1000H",
140 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK Computer INC."),
141 DMI_MATCH(DMI_PRODUCT_NAME
, "1000H"),
143 .driver_data
= &quirk_asus_1000h
,
146 .callback
= dmi_matched
,
147 .ident
= "ASUSTeK Computer INC. ET2012E/I",
149 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK Computer INC."),
150 DMI_MATCH(DMI_PRODUCT_NAME
, "ET2012"),
152 .driver_data
= &quirk_asus_unknown
,
155 .callback
= dmi_matched
,
156 .ident
= "ASUSTeK Computer INC. X101CH",
158 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
159 DMI_MATCH(DMI_PRODUCT_NAME
, "X101CH"),
161 .driver_data
= &quirk_asus_x101ch
,
164 .callback
= dmi_matched
,
165 .ident
= "ASUSTeK Computer INC. 1015CX",
167 DMI_MATCH(DMI_SYS_VENDOR
, "ASUSTeK COMPUTER INC."),
168 DMI_MATCH(DMI_PRODUCT_NAME
, "1015CX"),
170 .driver_data
= &quirk_asus_x101ch
,
175 static void eeepc_wmi_key_filter(struct asus_wmi_driver
*asus_wmi
, int *code
,
176 unsigned int *value
, bool *autorelease
)
184 *code
= ASUS_WMI_KEY_IGNORE
;
194 static int eeepc_wmi_probe(struct platform_device
*pdev
)
196 if (acpi_dev_found(EEEPC_ACPI_HID
)) {
197 pr_warn("Found legacy ATKD device (%s)\n", EEEPC_ACPI_HID
);
198 pr_warn("WMI device present, but legacy ATKD device is also "
199 "present and enabled\n");
200 pr_warn("You probably booted with acpi_osi=\"Linux\" or "
201 "acpi_osi=\"!Windows 2009\"\n");
202 pr_warn("Can't load eeepc-wmi, use default acpi_osi "
203 "(preferred) or eeepc-laptop\n");
209 static void eeepc_wmi_quirks(struct asus_wmi_driver
*driver
)
211 quirks
= &quirk_asus_unknown
;
212 quirks
->hotplug_wireless
= hotplug_wireless
;
214 dmi_check_system(asus_quirks
);
216 driver
->quirks
= quirks
;
217 driver
->quirks
->wapf
= -1;
218 driver
->panel_power
= FB_BLANK_UNBLANK
;
221 static struct asus_wmi_driver asus_wmi_driver
= {
222 .name
= EEEPC_WMI_FILE
,
223 .owner
= THIS_MODULE
,
224 .event_guid
= EEEPC_WMI_EVENT_GUID
,
225 .keymap
= eeepc_wmi_keymap
,
226 .input_name
= "Eee PC WMI hotkeys",
227 .input_phys
= EEEPC_WMI_FILE
"/input0",
228 .key_filter
= eeepc_wmi_key_filter
,
229 .probe
= eeepc_wmi_probe
,
230 .detect_quirks
= eeepc_wmi_quirks
,
234 static int __init
eeepc_wmi_init(void)
236 return asus_wmi_register_driver(&asus_wmi_driver
);
239 static void __exit
eeepc_wmi_exit(void)
241 asus_wmi_unregister_driver(&asus_wmi_driver
);
244 module_init(eeepc_wmi_init
);
245 module_exit(eeepc_wmi_exit
);