blob: 3a060aefc5f3a74916189a295cd34c9b2905e9af [file] [log] [blame]
Corentin Charye12e6d92011-02-26 10:20:31 +01001/*
2 * Eee PC WMI hotkey driver
3 *
4 * Copyright(C) 2010 Intel Corporation.
5 * Copyright(C) 2010 Corentin Chary <corentin.chary@gmail.com>
6 *
7 * Portions based on wistron_btns.c:
8 * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
9 * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
10 * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 <acpi/acpi_bus.h>
36
37#include "asus-wmi.h"
38
39#define EEEPC_WMI_FILE "eeepc-wmi"
40
41MODULE_AUTHOR("Corentin Chary <corentincj@iksaif.net>");
42MODULE_DESCRIPTION("Eee PC WMI Hotkey Driver");
43MODULE_LICENSE("GPL");
44
45#define EEEPC_ACPI_HID "ASUS010" /* old _HID used in eeepc-laptop */
46
47#define EEEPC_WMI_EVENT_GUID "ABBC0F72-8EA1-11D1-00A0-C90629100000"
48
49MODULE_ALIAS("wmi:"EEEPC_WMI_EVENT_GUID);
50
51static bool hotplug_wireless;
52
53module_param(hotplug_wireless, bool, 0444);
54MODULE_PARM_DESC(hotplug_wireless,
55 "Enable hotplug for wireless device. "
56 "If your laptop needs that, please report to "
57 "acpi4asus-user@lists.sourceforge.net.");
58
59static const struct key_entry eeepc_wmi_keymap[] = {
60 /* Sleep already handled via generic ACPI code */
61 { KE_KEY, 0x30, { KEY_VOLUMEUP } },
62 { KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
63 { KE_KEY, 0x32, { KEY_MUTE } },
64 { KE_KEY, 0x5c, { KEY_F15 } }, /* Power Gear key */
65 { KE_KEY, 0x5d, { KEY_WLAN } },
66 { KE_KEY, 0x6b, { KEY_F13 } }, /* Disable Touchpad */
67 { KE_KEY, 0x82, { KEY_CAMERA } },
68 { KE_KEY, 0x88, { KEY_WLAN } },
69 { KE_KEY, 0xcc, { KEY_SWITCHVIDEOMODE } },
70 { KE_KEY, 0xe0, { KEY_PROG1 } }, /* Task Manager */
71 { KE_KEY, 0xe1, { KEY_F14 } }, /* Change Resolution */
72 { KE_KEY, 0xe9, { KEY_BRIGHTNESS_ZERO } },
73 { KE_END, 0},
74};
75
76static acpi_status eeepc_wmi_parse_device(acpi_handle handle, u32 level,
77 void *context, void **retval)
78{
79 pr_warning("Found legacy ATKD device (%s)", EEEPC_ACPI_HID);
80 *(bool *)context = true;
81 return AE_CTRL_TERMINATE;
82}
83
84static int eeepc_wmi_check_atkd(void)
85{
86 acpi_status status;
87 bool found = false;
88
89 status = acpi_get_devices(EEEPC_ACPI_HID, eeepc_wmi_parse_device,
90 &found, NULL);
91
92 if (ACPI_FAILURE(status) || !found)
93 return 0;
94 return -1;
95}
96
97static int eeepc_wmi_probe(struct platform_device *pdev)
98{
99 if (eeepc_wmi_check_atkd()) {
100 pr_warning("WMI device present, but legacy ATKD device is also "
101 "present and enabled.");
102 pr_warning("You probably booted with acpi_osi=\"Linux\" or "
103 "acpi_osi=\"!Windows 2009\"");
104 pr_warning("Can't load eeepc-wmi, use default acpi_osi "
105 "(preferred) or eeepc-laptop");
106 return -EBUSY;
107 }
108 return 0;
109}
110
111static void eeepc_dmi_check(struct asus_wmi_driver *driver)
112{
113 const char *model;
114
115 model = dmi_get_system_info(DMI_PRODUCT_NAME);
116 if (!model)
117 return;
118
119 /*
120 * Whitelist for wlan hotplug
121 *
122 * Asus 1000H needs the current hotplug code to handle
123 * Fn+F2 correctly. We may add other Asus here later, but
124 * it seems that most of the laptops supported by asus-wmi
125 * don't need to be on this list
126 */
127 if (strcmp(model, "1000H") == 0) {
128 driver->hotplug_wireless = true;
129 pr_info("wlan hotplug enabled\n");
130 }
131}
132
133static void eeepc_wmi_quirks(struct asus_wmi_driver *driver)
134{
135 driver->hotplug_wireless = hotplug_wireless;
136 eeepc_dmi_check(driver);
137}
138
139static struct asus_wmi_driver asus_wmi_driver = {
140 .name = EEEPC_WMI_FILE,
141 .owner = THIS_MODULE,
142 .event_guid = EEEPC_WMI_EVENT_GUID,
143 .keymap = eeepc_wmi_keymap,
144 .input_name = "Eee PC WMI hotkeys",
145 .input_phys = EEEPC_WMI_FILE "/input0",
146 .probe = eeepc_wmi_probe,
147 .quirks = eeepc_wmi_quirks,
148};
149
150
151static int __init eeepc_wmi_init(void)
152{
153 return asus_wmi_register_driver(&asus_wmi_driver);
154}
155
156static void __exit eeepc_wmi_exit(void)
157{
158 asus_wmi_unregister_driver(&asus_wmi_driver);
159}
160
161module_init(eeepc_wmi_init);
162module_exit(eeepc_wmi_exit);