hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/platform/x86/dell-wmi.c
....@@ -1,27 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Dell WMI hotkeys
34 *
45 * Copyright (C) 2008 Red Hat <mjg@redhat.com>
5
- * Copyright (C) 2014-2015 Pali Rohár <pali.rohar@gmail.com>
6
+ * Copyright (C) 2014-2015 Pali Rohár <pali@kernel.org>
67 *
78 * Portions based on wistron_btns.c:
89 * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
910 * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
1011 * 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
2512 */
2613
2714 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -42,15 +29,13 @@
4229 #include "dell-wmi-descriptor.h"
4330
4431 MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
45
-MODULE_AUTHOR("Pali Rohár <pali.rohar@gmail.com>");
32
+MODULE_AUTHOR("Pali Rohár <pali@kernel.org>");
4633 MODULE_DESCRIPTION("Dell laptop WMI hotkeys driver");
4734 MODULE_LICENSE("GPL");
4835
4936 #define DELL_EVENT_GUID "9DBB5994-A997-11DA-B012-B622A1EF5492"
5037
5138 static bool wmi_requires_smbios_request;
52
-
53
-MODULE_ALIAS("wmi:"DELL_EVENT_GUID);
5439
5540 struct dell_wmi_priv {
5641 struct input_dev *input_dev;
....@@ -267,6 +252,16 @@
267252 /* Fn-lock switched to multimedia keys */
268253 { KE_IGNORE, 0x1, { KEY_RESERVED } },
269254
255
+ /* Keyboard backlight change notification */
256
+ { KE_IGNORE, 0x3f, { KEY_RESERVED } },
257
+
258
+ /* Backlight brightness level */
259
+ { KE_KEY, 0x57, { KEY_BRIGHTNESSDOWN } },
260
+ { KE_KEY, 0x58, { KEY_BRIGHTNESSUP } },
261
+
262
+ /*Speaker Mute*/
263
+ { KE_KEY, 0x109, { KEY_MUTE} },
264
+
270265 /* Mic mute */
271266 { KE_KEY, 0x150, { KEY_MICMUTE } },
272267
....@@ -322,12 +317,33 @@
322317 /* Battery inserted */
323318 { KE_IGNORE, 0xfff1, { KEY_RESERVED } },
324319
320
+ /*
321
+ * Detachable keyboard detached / undocked
322
+ * Note SW_TABLET_MODE is already reported through the intel_vbtn
323
+ * driver for this, so we ignore it.
324
+ */
325
+ { KE_IGNORE, 0xfff2, { KEY_RESERVED } },
326
+
327
+ /* Detachable keyboard attached / docked */
328
+ { KE_IGNORE, 0xfff3, { KEY_RESERVED } },
329
+
325330 /* Keyboard backlight level changed */
326
- { KE_IGNORE, 0x01e1, { KEY_RESERVED } },
327
- { KE_IGNORE, 0x02ea, { KEY_RESERVED } },
328
- { KE_IGNORE, 0x02eb, { KEY_RESERVED } },
329
- { KE_IGNORE, 0x02ec, { KEY_RESERVED } },
330
- { KE_IGNORE, 0x02f6, { KEY_RESERVED } },
331
+ { KE_IGNORE, KBD_LED_OFF_TOKEN, { KEY_RESERVED } },
332
+ { KE_IGNORE, KBD_LED_ON_TOKEN, { KEY_RESERVED } },
333
+ { KE_IGNORE, KBD_LED_AUTO_TOKEN, { KEY_RESERVED } },
334
+ { KE_IGNORE, KBD_LED_AUTO_25_TOKEN, { KEY_RESERVED } },
335
+ { KE_IGNORE, KBD_LED_AUTO_50_TOKEN, { KEY_RESERVED } },
336
+ { KE_IGNORE, KBD_LED_AUTO_75_TOKEN, { KEY_RESERVED } },
337
+ { KE_IGNORE, KBD_LED_AUTO_100_TOKEN, { KEY_RESERVED } },
338
+};
339
+
340
+/*
341
+ * Keymap for WMI events of type 0x0012
342
+ * They are events with extended data
343
+ */
344
+static const struct key_entry dell_wmi_keymap_type_0012[] = {
345
+ /* Fn-lock button pressed */
346
+ { KE_IGNORE, 0xe035, { KEY_RESERVED } },
331347 };
332348
333349 static void dell_wmi_process_key(struct wmi_device *wdev, int type, int code)
....@@ -414,10 +430,11 @@
414430
415431 switch (buffer_entry[1]) {
416432 case 0x0000: /* One key pressed or event occurred */
433
+ case 0x0012: /* Event with extended data occurred */
417434 if (len > 2)
418
- dell_wmi_process_key(wdev, 0x0000,
435
+ dell_wmi_process_key(wdev, buffer_entry[1],
419436 buffer_entry[2]);
420
- /* Other entries could contain additional information */
437
+ /* Extended data is currently ignored */
421438 break;
422439 case 0x0010: /* Sequence of keys pressed */
423440 case 0x0011: /* Sequence of events occurred */
....@@ -492,7 +509,7 @@
492509 u16 keycode = (bios_entry->keycode <
493510 ARRAY_SIZE(bios_to_linux_keycode)) ?
494511 bios_to_linux_keycode[bios_entry->keycode] :
495
- KEY_RESERVED;
512
+ (bios_entry->keycode == 0xffff ? KEY_UNKNOWN : KEY_RESERVED);
496513
497514 /*
498515 * Log if we find an entry in the DMI table that we don't
....@@ -552,6 +569,7 @@
552569 ARRAY_SIZE(dell_wmi_keymap_type_0000) +
553570 ARRAY_SIZE(dell_wmi_keymap_type_0010) +
554571 ARRAY_SIZE(dell_wmi_keymap_type_0011) +
572
+ ARRAY_SIZE(dell_wmi_keymap_type_0012) +
555573 1,
556574 sizeof(struct key_entry), GFP_KERNEL);
557575 if (!keymap) {
....@@ -593,6 +611,13 @@
593611 for (i = 0; i < ARRAY_SIZE(dell_wmi_keymap_type_0011); i++) {
594612 keymap[pos] = dell_wmi_keymap_type_0011[i];
595613 keymap[pos].code |= (0x0011 << 16);
614
+ pos++;
615
+ }
616
+
617
+ /* Append table with events of type 0x0012 */
618
+ for (i = 0; i < ARRAY_SIZE(dell_wmi_keymap_type_0012); i++) {
619
+ keymap[pos] = dell_wmi_keymap_type_0012[i];
620
+ keymap[pos].code |= (0x0012 << 16);
596621 pos++;
597622 }
598623
....@@ -671,7 +696,7 @@
671696 return dell_smbios_error(ret);
672697 }
673698
674
-static int dell_wmi_probe(struct wmi_device *wdev)
699
+static int dell_wmi_probe(struct wmi_device *wdev, const void *context)
675700 {
676701 struct dell_wmi_priv *priv;
677702 int ret;
....@@ -738,3 +763,5 @@
738763 wmi_driver_unregister(&dell_wmi_driver);
739764 }
740765 module_exit(dell_wmi_exit);
766
+
767
+MODULE_DEVICE_TABLE(wmi, dell_wmi_id_table);