]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/platform/x86/asus-nb-wmi.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[karo-tx-linux.git] / drivers / platform / x86 / asus-nb-wmi.c
1 /*
2  * Asus Notebooks WMI hotkey driver
3  *
4  * Copyright(C) 2010 Corentin Chary <corentin.chary@gmail.com>
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22
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>
28 #include <linux/fb.h>
29 #include <linux/dmi.h>
30
31 #include "asus-wmi.h"
32
33 #define ASUS_NB_WMI_FILE        "asus-nb-wmi"
34
35 MODULE_AUTHOR("Corentin Chary <corentin.chary@gmail.com>");
36 MODULE_DESCRIPTION("Asus Notebooks WMI Hotkey Driver");
37 MODULE_LICENSE("GPL");
38
39 #define ASUS_NB_WMI_EVENT_GUID  "0B3CBB35-E3C2-45ED-91C2-4C5A6D195D1C"
40
41 MODULE_ALIAS("wmi:"ASUS_NB_WMI_EVENT_GUID);
42
43 /*
44  * WAPF defines the behavior of the Fn+Fx wlan key
45  * The significance of values is yet to be found, but
46  * most of the time:
47  * Bit | Bluetooth | WLAN
48  *  0  | Hardware  | Hardware
49  *  1  | Hardware  | Software
50  *  4  | Software  | Software
51  */
52 static int wapf = -1;
53 module_param(wapf, uint, 0444);
54 MODULE_PARM_DESC(wapf, "WAPF value");
55
56 static struct quirk_entry *quirks;
57
58 static struct quirk_entry quirk_asus_unknown = {
59         .wapf = 0,
60 };
61
62 /*
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
66  */
67 static struct quirk_entry quirk_asus_x55u = {
68         .wapf = 4,
69         .wmi_backlight_power = true,
70         .no_display_toggle = true,
71 };
72
73 static struct quirk_entry quirk_asus_x401u = {
74         .wapf = 4,
75 };
76
77 static int dmi_matched(const struct dmi_system_id *dmi)
78 {
79         quirks = dmi->driver_data;
80         return 1;
81 }
82
83 static struct dmi_system_id asus_quirks[] = {
84         {
85                 .callback = dmi_matched,
86                 .ident = "ASUSTeK COMPUTER INC. X401U",
87                 .matches = {
88                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
89                         DMI_MATCH(DMI_PRODUCT_NAME, "X401U"),
90                 },
91                 .driver_data = &quirk_asus_x55u,
92         },
93         {
94                 .callback = dmi_matched,
95                 .ident = "ASUSTeK COMPUTER INC. X401A",
96                 .matches = {
97                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
98                         DMI_MATCH(DMI_PRODUCT_NAME, "X401A"),
99                 },
100                 .driver_data = &quirk_asus_x401u,
101         },
102         {
103                 .callback = dmi_matched,
104                 .ident = "ASUSTeK COMPUTER INC. X401A1",
105                 .matches = {
106                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
107                         DMI_MATCH(DMI_PRODUCT_NAME, "X401A1"),
108                 },
109                 .driver_data = &quirk_asus_x401u,
110         },
111         {
112                 .callback = dmi_matched,
113                 .ident = "ASUSTeK COMPUTER INC. X501U",
114                 .matches = {
115                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
116                         DMI_MATCH(DMI_PRODUCT_NAME, "X501U"),
117                 },
118                 .driver_data = &quirk_asus_x55u,
119         },
120         {
121                 .callback = dmi_matched,
122                 .ident = "ASUSTeK COMPUTER INC. X501A",
123                 .matches = {
124                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
125                         DMI_MATCH(DMI_PRODUCT_NAME, "X501A"),
126                 },
127                 .driver_data = &quirk_asus_x401u,
128         },
129         {
130                 .callback = dmi_matched,
131                 .ident = "ASUSTeK COMPUTER INC. X501A1",
132                 .matches = {
133                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
134                         DMI_MATCH(DMI_PRODUCT_NAME, "X501A1"),
135                 },
136                 .driver_data = &quirk_asus_x401u,
137         },
138         {
139                 .callback = dmi_matched,
140                 .ident = "ASUSTeK COMPUTER INC. X55A",
141                 .matches = {
142                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
143                         DMI_MATCH(DMI_PRODUCT_NAME, "X55A"),
144                 },
145                 .driver_data = &quirk_asus_x401u,
146         },
147         {
148                 .callback = dmi_matched,
149                 .ident = "ASUSTeK COMPUTER INC. X55C",
150                 .matches = {
151                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
152                         DMI_MATCH(DMI_PRODUCT_NAME, "X55C"),
153                 },
154                 .driver_data = &quirk_asus_x401u,
155         },
156         {
157                 .callback = dmi_matched,
158                 .ident = "ASUSTeK COMPUTER INC. X55U",
159                 .matches = {
160                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
161                         DMI_MATCH(DMI_PRODUCT_NAME, "X55U"),
162                 },
163                 .driver_data = &quirk_asus_x55u,
164         },
165         {
166                 .callback = dmi_matched,
167                 .ident = "ASUSTeK COMPUTER INC. X55VD",
168                 .matches = {
169                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
170                         DMI_MATCH(DMI_PRODUCT_NAME, "X55VD"),
171                 },
172                 .driver_data = &quirk_asus_x401u,
173         },
174         {
175                 .callback = dmi_matched,
176                 .ident = "ASUSTeK COMPUTER INC. X75A",
177                 .matches = {
178                         DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
179                         DMI_MATCH(DMI_PRODUCT_NAME, "X75A"),
180                 },
181                 .driver_data = &quirk_asus_x401u,
182         },
183         {},
184 };
185
186 static void asus_nb_wmi_quirks(struct asus_wmi_driver *driver)
187 {
188         quirks = &quirk_asus_unknown;
189         dmi_check_system(asus_quirks);
190
191         driver->quirks = quirks;
192         driver->panel_power = FB_BLANK_UNBLANK;
193
194         /* overwrite the wapf setting if the wapf paramater is specified */
195         if (wapf != -1)
196                 quirks->wapf = wapf;
197         else
198                 wapf = quirks->wapf;
199 }
200
201 static const struct key_entry asus_nb_wmi_keymap[] = {
202         { KE_KEY, ASUS_WMI_BRN_DOWN, { KEY_BRIGHTNESSDOWN } },
203         { KE_KEY, ASUS_WMI_BRN_UP, { KEY_BRIGHTNESSUP } },
204         { KE_KEY, 0x30, { KEY_VOLUMEUP } },
205         { KE_KEY, 0x31, { KEY_VOLUMEDOWN } },
206         { KE_KEY, 0x32, { KEY_MUTE } },
207         { KE_KEY, 0x33, { KEY_DISPLAYTOGGLE } }, /* LCD on */
208         { KE_KEY, 0x34, { KEY_DISPLAY_OFF } }, /* LCD off */
209         { KE_KEY, 0x40, { KEY_PREVIOUSSONG } },
210         { KE_KEY, 0x41, { KEY_NEXTSONG } },
211         { KE_KEY, 0x43, { KEY_STOPCD } }, /* Stop/Eject */
212         { KE_KEY, 0x45, { KEY_PLAYPAUSE } },
213         { KE_KEY, 0x4c, { KEY_MEDIA } }, /* WMP Key */
214         { KE_KEY, 0x50, { KEY_EMAIL } },
215         { KE_KEY, 0x51, { KEY_WWW } },
216         { KE_KEY, 0x55, { KEY_CALC } },
217         { KE_IGNORE, 0x57, },  /* Battery mode */
218         { KE_IGNORE, 0x58, },  /* AC mode */
219         { KE_KEY, 0x5C, { KEY_F15 } },  /* Power Gear key */
220         { KE_KEY, 0x5D, { KEY_WLAN } }, /* Wireless console Toggle */
221         { KE_KEY, 0x5E, { KEY_WLAN } }, /* Wireless console Enable */
222         { KE_KEY, 0x5F, { KEY_WLAN } }, /* Wireless console Disable */
223         { KE_KEY, 0x60, { KEY_TOUCHPAD_ON } },
224         { KE_KEY, 0x61, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD only */
225         { KE_KEY, 0x62, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT only */
226         { KE_KEY, 0x63, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + CRT */
227         { KE_KEY, 0x64, { KEY_SWITCHVIDEOMODE } }, /* SDSP TV */
228         { KE_KEY, 0x65, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + TV */
229         { KE_KEY, 0x66, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT + TV */
230         { KE_KEY, 0x67, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + CRT + TV */
231         { KE_KEY, 0x6B, { KEY_TOUCHPAD_TOGGLE } },
232         { KE_IGNORE, 0x6E, },  /* Low Battery notification */
233         { KE_KEY, 0x7D, { KEY_BLUETOOTH } }, /* Bluetooth Enable */
234         { KE_KEY, 0x7E, { KEY_BLUETOOTH } }, /* Bluetooth Disable */
235         { KE_KEY, 0x82, { KEY_CAMERA } },
236         { KE_KEY, 0x88, { KEY_RFKILL  } }, /* Radio Toggle Key */
237         { KE_KEY, 0x8A, { KEY_PROG1 } }, /* Color enhancement mode */
238         { KE_KEY, 0x8C, { KEY_SWITCHVIDEOMODE } }, /* SDSP DVI only */
239         { KE_KEY, 0x8D, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + DVI */
240         { KE_KEY, 0x8E, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT + DVI */
241         { KE_KEY, 0x8F, { KEY_SWITCHVIDEOMODE } }, /* SDSP TV + DVI */
242         { KE_KEY, 0x90, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + CRT + DVI */
243         { KE_KEY, 0x91, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + TV + DVI */
244         { KE_KEY, 0x92, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT + TV + DVI */
245         { KE_KEY, 0x93, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + CRT + TV + DVI */
246         { KE_KEY, 0x95, { KEY_MEDIA } },
247         { KE_KEY, 0x99, { KEY_PHONE } },
248         { KE_KEY, 0xA0, { KEY_SWITCHVIDEOMODE } }, /* SDSP HDMI only */
249         { KE_KEY, 0xA1, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + HDMI */
250         { KE_KEY, 0xA2, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT + HDMI */
251         { KE_KEY, 0xA3, { KEY_SWITCHVIDEOMODE } }, /* SDSP TV + HDMI */
252         { KE_KEY, 0xA4, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + CRT + HDMI */
253         { KE_KEY, 0xA5, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + TV + HDMI */
254         { KE_KEY, 0xA6, { KEY_SWITCHVIDEOMODE } }, /* SDSP CRT + TV + HDMI */
255         { KE_KEY, 0xA7, { KEY_SWITCHVIDEOMODE } }, /* SDSP LCD + CRT + TV + HDMI */
256         { KE_KEY, 0xB5, { KEY_CALC } },
257         { KE_KEY, 0xC4, { KEY_KBDILLUMUP } },
258         { KE_KEY, 0xC5, { KEY_KBDILLUMDOWN } },
259         { KE_END, 0},
260 };
261
262 static struct asus_wmi_driver asus_nb_wmi_driver = {
263         .name = ASUS_NB_WMI_FILE,
264         .owner = THIS_MODULE,
265         .event_guid = ASUS_NB_WMI_EVENT_GUID,
266         .keymap = asus_nb_wmi_keymap,
267         .input_name = "Asus WMI hotkeys",
268         .input_phys = ASUS_NB_WMI_FILE "/input0",
269         .detect_quirks = asus_nb_wmi_quirks,
270 };
271
272
273 static int __init asus_nb_wmi_init(void)
274 {
275         return asus_wmi_register_driver(&asus_nb_wmi_driver);
276 }
277
278 static void __exit asus_nb_wmi_exit(void)
279 {
280         asus_wmi_unregister_driver(&asus_nb_wmi_driver);
281 }
282
283 module_init(asus_nb_wmi_init);
284 module_exit(asus_nb_wmi_exit);