aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAzael Avalos <coproscefalo@gmail.com>2015-09-28 22:32:28 -0400
committerDarren Hart <dvhart@linux.intel.com>2015-10-03 13:07:08 -0400
commit14991fc7dfc6cd18b0d79ebc8f39b1350cb34fc9 (patch)
treeedb11fc2b720b83fcf686ce40289eb5d7183b945
parent963406ffa6e77ae85b400a9bc8b747813c4497cf (diff)
platform/x86: Toshiba WMI Hotkey Driver
Toshiba laptops that feature WMI events for hotkeys were left unsupported by the toshiba_acpi driver, however, commit a88bc06e5aec ("toshiba_acpi: Avoid registering input device on WMI event laptops") added hardware support for such laptops, but the hotkeys are not handled there. This driver adds support for hotkey monitoring on certain Toshiba laptops that manage the hotkeys via WMI events instead of the Toshiba Configuration Interface (TCI). The toshiba_acpi driver and this one can co-exist, as this only takes care of hotkeys, while the proper takes care of hardware related stuff. Currently the driver is under the EXPERIMENTAL flag, as the keymap and the notify function are incomplete (due to lack of hardware to test). Signed-off-by: Azael Avalos <coproscefalo@gmail.com> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
-rw-r--r--MAINTAINERS6
-rw-r--r--drivers/platform/x86/Kconfig18
-rw-r--r--drivers/platform/x86/Makefile1
-rw-r--r--drivers/platform/x86/toshiba-wmi.c138
4 files changed, 163 insertions, 0 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 9f6685f6c5a9..adb8e5820506 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10529,6 +10529,12 @@ L: platform-driver-x86@vger.kernel.org
10529S: Maintained 10529S: Maintained
10530F: drivers/platform/x86/toshiba_haps.c 10530F: drivers/platform/x86/toshiba_haps.c
10531 10531
10532TOSHIBA WMI HOTKEYS DRIVER
10533M: Azael Avalos <coproscefalo@gmail.com>
10534L: platform-driver-x86@vger.kernel.org
10535S: Maintained
10536F: drivers/platform/x86/toshiba-wmi.c
10537
10532TOSHIBA SMM DRIVER 10538TOSHIBA SMM DRIVER
10533M: Jonathan Buzzard <jonathan@buzzard.org.uk> 10539M: Jonathan Buzzard <jonathan@buzzard.org.uk>
10534W: http://www.buzzard.org.uk/toshiba/ 10540W: http://www.buzzard.org.uk/toshiba/
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 2f9026d31444..7b492d9b3ec4 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -700,6 +700,24 @@ config TOSHIBA_HAPS
700 If you have a recent Toshiba laptop with a built-in accelerometer 700 If you have a recent Toshiba laptop with a built-in accelerometer
701 device, say Y. 701 device, say Y.
702 702
703config TOSHIBA_WMI
704 tristate "Toshiba WMI Hotkeys Driver (EXPERIMENTAL)"
705 default n
706 depends on ACPI_WMI
707 depends on INPUT
708 select INPUT_SPARSEKMAP
709 ---help---
710 This driver adds hotkey monitoring support to some Toshiba models
711 that manage the hotkeys via WMI events.
712
713 WARNING: This driver is incomplete as it lacks a proper keymap and the
714 *notify function only prints the ACPI event type value. Be warned that
715 you will need to provide some information if you have a Toshiba model
716 with WMI event hotkeys and want to help with the develpment of this
717 driver.
718
719 If you have a WMI-based hotkeys Toshiba laptop, say Y or M here.
720
703config ACPI_CMPC 721config ACPI_CMPC
704 tristate "CMPC Laptop Extras" 722 tristate "CMPC Laptop Extras"
705 depends on X86 && ACPI 723 depends on X86 && ACPI
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index ada512819028..3ca78a3eb6f8 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -40,6 +40,7 @@ obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o
40 40
41obj-$(CONFIG_TOSHIBA_BT_RFKILL) += toshiba_bluetooth.o 41obj-$(CONFIG_TOSHIBA_BT_RFKILL) += toshiba_bluetooth.o
42obj-$(CONFIG_TOSHIBA_HAPS) += toshiba_haps.o 42obj-$(CONFIG_TOSHIBA_HAPS) += toshiba_haps.o
43obj-$(CONFIG_TOSHIBA_WMI) += toshiba-wmi.o
43obj-$(CONFIG_INTEL_SCU_IPC) += intel_scu_ipc.o 44obj-$(CONFIG_INTEL_SCU_IPC) += intel_scu_ipc.o
44obj-$(CONFIG_INTEL_SCU_IPC_UTIL) += intel_scu_ipcutil.o 45obj-$(CONFIG_INTEL_SCU_IPC_UTIL) += intel_scu_ipcutil.o
45obj-$(CONFIG_INTEL_MFLD_THERMAL) += intel_mid_thermal.o 46obj-$(CONFIG_INTEL_MFLD_THERMAL) += intel_mid_thermal.o
diff --git a/drivers/platform/x86/toshiba-wmi.c b/drivers/platform/x86/toshiba-wmi.c
new file mode 100644
index 000000000000..feac4576b837
--- /dev/null
+++ b/drivers/platform/x86/toshiba-wmi.c
@@ -0,0 +1,138 @@
1/*
2 * toshiba_wmi.c - Toshiba WMI Hotkey Driver
3 *
4 * Copyright (C) 2015 Azael Avalos <coproscefalo@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 */
17
18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19
20#include <linux/kernel.h>
21#include <linux/module.h>
22#include <linux/init.h>
23#include <linux/types.h>
24#include <linux/acpi.h>
25#include <linux/input.h>
26#include <linux/input/sparse-keymap.h>
27
28MODULE_AUTHOR("Azael Avalos");
29MODULE_DESCRIPTION("Toshiba WMI Hotkey Driver");
30MODULE_LICENSE("GPL");
31
32#define TOSHIBA_WMI_EVENT_GUID "59142400-C6A3-40FA-BADB-8A2652834100"
33
34MODULE_ALIAS("wmi:"TOSHIBA_WMI_EVENT_GUID);
35
36static struct input_dev *toshiba_wmi_input_dev;
37
38static const struct key_entry toshiba_wmi_keymap[] __initconst = {
39 /* TODO: Add keymap values once found... */
40 /*{ KE_KEY, 0x00, { KEY_ } },*/
41 { KE_END, 0 }
42};
43
44static void toshiba_wmi_notify(u32 value, void *context)
45{
46 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
47 union acpi_object *obj;
48 acpi_status status;
49
50 status = wmi_get_event_data(value, &response);
51 if (ACPI_FAILURE(status)) {
52 pr_err("Bad event status 0x%x\n", status);
53 return;
54 }
55
56 obj = (union acpi_object *)response.pointer;
57 if (!obj)
58 return;
59
60 /* TODO: Add proper checks once we have data */
61 pr_debug("Unknown event received, obj type %x\n", obj->type);
62
63 kfree(response.pointer);
64}
65
66static int __init toshiba_wmi_input_setup(void)
67{
68 acpi_status status;
69 int err;
70
71 toshiba_wmi_input_dev = input_allocate_device();
72 if (!toshiba_wmi_input_dev)
73 return -ENOMEM;
74
75 toshiba_wmi_input_dev->name = "Toshiba WMI hotkeys";
76 toshiba_wmi_input_dev->phys = "wmi/input0";
77 toshiba_wmi_input_dev->id.bustype = BUS_HOST;
78
79 err = sparse_keymap_setup(toshiba_wmi_input_dev,
80 toshiba_wmi_keymap, NULL);
81 if (err)
82 goto err_free_dev;
83
84 status = wmi_install_notify_handler(TOSHIBA_WMI_EVENT_GUID,
85 toshiba_wmi_notify, NULL);
86 if (ACPI_FAILURE(status)) {
87 err = -EIO;
88 goto err_free_keymap;
89 }
90
91 err = input_register_device(toshiba_wmi_input_dev);
92 if (err)
93 goto err_remove_notifier;
94
95 return 0;
96
97 err_remove_notifier:
98 wmi_remove_notify_handler(TOSHIBA_WMI_EVENT_GUID);
99 err_free_keymap:
100 sparse_keymap_free(toshiba_wmi_input_dev);
101 err_free_dev:
102 input_free_device(toshiba_wmi_input_dev);
103 return err;
104}
105
106static void toshiba_wmi_input_destroy(void)
107{
108 wmi_remove_notify_handler(TOSHIBA_WMI_EVENT_GUID);
109 sparse_keymap_free(toshiba_wmi_input_dev);
110 input_unregister_device(toshiba_wmi_input_dev);
111}
112
113static int __init toshiba_wmi_init(void)
114{
115 int ret;
116
117 if (!wmi_has_guid(TOSHIBA_WMI_EVENT_GUID))
118 return -ENODEV;
119
120 ret = toshiba_wmi_input_setup();
121 if (ret) {
122 pr_err("Failed to setup input device\n");
123 return ret;
124 }
125
126 pr_info("Toshiba WMI Hotkey Driver\n");
127
128 return 0;
129}
130
131static void __exit toshiba_wmi_exit(void)
132{
133 if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID))
134 toshiba_wmi_input_destroy();
135}
136
137module_init(toshiba_wmi_init);
138module_exit(toshiba_wmi_exit);