forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
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,13 @@
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
+
270262 /* Mic mute */
271263 { KE_KEY, 0x150, { KEY_MICMUTE } },
272264
....@@ -322,12 +314,33 @@
322314 /* Battery inserted */
323315 { KE_IGNORE, 0xfff1, { KEY_RESERVED } },
324316
317
+ /*
318
+ * Detachable keyboard detached / undocked
319
+ * Note SW_TABLET_MODE is already reported through the intel_vbtn
320
+ * driver for this, so we ignore it.
321
+ */
322
+ { KE_IGNORE, 0xfff2, { KEY_RESERVED } },
323
+
324
+ /* Detachable keyboard attached / docked */
325
+ { KE_IGNORE, 0xfff3, { KEY_RESERVED } },
326
+
325327 /* 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 } },
328
+ { KE_IGNORE, KBD_LED_OFF_TOKEN, { KEY_RESERVED } },
329
+ { KE_IGNORE, KBD_LED_ON_TOKEN, { KEY_RESERVED } },
330
+ { KE_IGNORE, KBD_LED_AUTO_TOKEN, { KEY_RESERVED } },
331
+ { KE_IGNORE, KBD_LED_AUTO_25_TOKEN, { KEY_RESERVED } },
332
+ { KE_IGNORE, KBD_LED_AUTO_50_TOKEN, { KEY_RESERVED } },
333
+ { KE_IGNORE, KBD_LED_AUTO_75_TOKEN, { KEY_RESERVED } },
334
+ { KE_IGNORE, KBD_LED_AUTO_100_TOKEN, { KEY_RESERVED } },
335
+};
336
+
337
+/*
338
+ * Keymap for WMI events of type 0x0012
339
+ * They are events with extended data
340
+ */
341
+static const struct key_entry dell_wmi_keymap_type_0012[] = {
342
+ /* Fn-lock button pressed */
343
+ { KE_IGNORE, 0xe035, { KEY_RESERVED } },
331344 };
332345
333346 static void dell_wmi_process_key(struct wmi_device *wdev, int type, int code)
....@@ -414,10 +427,11 @@
414427
415428 switch (buffer_entry[1]) {
416429 case 0x0000: /* One key pressed or event occurred */
430
+ case 0x0012: /* Event with extended data occurred */
417431 if (len > 2)
418
- dell_wmi_process_key(wdev, 0x0000,
432
+ dell_wmi_process_key(wdev, buffer_entry[1],
419433 buffer_entry[2]);
420
- /* Other entries could contain additional information */
434
+ /* Extended data is currently ignored */
421435 break;
422436 case 0x0010: /* Sequence of keys pressed */
423437 case 0x0011: /* Sequence of events occurred */
....@@ -492,7 +506,7 @@
492506 u16 keycode = (bios_entry->keycode <
493507 ARRAY_SIZE(bios_to_linux_keycode)) ?
494508 bios_to_linux_keycode[bios_entry->keycode] :
495
- KEY_RESERVED;
509
+ (bios_entry->keycode == 0xffff ? KEY_UNKNOWN : KEY_RESERVED);
496510
497511 /*
498512 * Log if we find an entry in the DMI table that we don't
....@@ -552,6 +566,7 @@
552566 ARRAY_SIZE(dell_wmi_keymap_type_0000) +
553567 ARRAY_SIZE(dell_wmi_keymap_type_0010) +
554568 ARRAY_SIZE(dell_wmi_keymap_type_0011) +
569
+ ARRAY_SIZE(dell_wmi_keymap_type_0012) +
555570 1,
556571 sizeof(struct key_entry), GFP_KERNEL);
557572 if (!keymap) {
....@@ -593,6 +608,13 @@
593608 for (i = 0; i < ARRAY_SIZE(dell_wmi_keymap_type_0011); i++) {
594609 keymap[pos] = dell_wmi_keymap_type_0011[i];
595610 keymap[pos].code |= (0x0011 << 16);
611
+ pos++;
612
+ }
613
+
614
+ /* Append table with events of type 0x0012 */
615
+ for (i = 0; i < ARRAY_SIZE(dell_wmi_keymap_type_0012); i++) {
616
+ keymap[pos] = dell_wmi_keymap_type_0012[i];
617
+ keymap[pos].code |= (0x0012 << 16);
596618 pos++;
597619 }
598620
....@@ -671,7 +693,7 @@
671693 return dell_smbios_error(ret);
672694 }
673695
674
-static int dell_wmi_probe(struct wmi_device *wdev)
696
+static int dell_wmi_probe(struct wmi_device *wdev, const void *context)
675697 {
676698 struct dell_wmi_priv *priv;
677699 int ret;
....@@ -738,3 +760,5 @@
738760 wmi_driver_unregister(&dell_wmi_driver);
739761 }
740762 module_exit(dell_wmi_exit);
763
+
764
+MODULE_DEVICE_TABLE(wmi, dell_wmi_id_table);