Skip to contentSkip to conversation

toshiba_acpi: Remove unneeded u32 variables from *setup_keyboard

PATCH Superseded Azael Avalos 3 participants 9 messages Sep 9, 2015 – Sep 22, 2015

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Azael Avalos

author maintainer
#0 lore raw

PATCH 1/1 toshiba_acpi: Remove unneeded u32 variables from *setup_keyboard

The function toshiba_acpi_setup_keyboard currently has two u32 variables used to store the Hotkey Event Type and the result of the HCI_SYSTEM_EVENT query.

This patch removes those two variables, as we already have a global variable named "hotkey_event_type" and the result of the HCI_SYSTEM_EVENT query can be checked directly from the function.

---
 drivers/platform/x86/toshiba_acpi.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/platform/x86/toshiba_acpi.c +8 -13
index 803e967..9f7ced1 100644
@@ -2381,8 +2381,6 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
 {
 	const struct key_entry *keymap = toshiba_acpi_keymap;
 	acpi_handle ec_handle;
-	u32 events_type;
-	u32 hci_result;
 	int error;
 
 	if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID)) {
@@ -2394,11 +2392,9 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
 	if (error)
 		return error;
 
-	if (toshiba_hotkey_event_type_get(dev, &events_type))
+	if (toshiba_hotkey_event_type_get(dev, &dev->hotkey_event_type))
 		pr_notice("Unable to query Hotkey Event Type\n");
 
-	dev->hotkey_event_type = events_type;
-
 	dev->hotkey_dev = input_allocate_device();
 	if (!dev->hotkey_dev)
 		return -ENOMEM;
@@ -2407,14 +2403,15 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
 	dev->hotkey_dev->phys = "toshiba_acpi/input0";
 	dev->hotkey_dev->id.bustype = BUS_HOST;
 
-	if (events_type == HCI_SYSTEM_TYPE1 ||
+	if (dev->hotkey_event_type == HCI_SYSTEM_TYPE1 ||
 	    !dev->kbd_function_keys_supported)
 		keymap = toshiba_acpi_keymap;
-	else if (events_type == HCI_SYSTEM_TYPE2 ||
+	else if (dev->hotkey_event_type == HCI_SYSTEM_TYPE2 ||
 		 dev->kbd_function_keys_supported)
 		keymap = toshiba_acpi_alt_keymap;
 	else
-		pr_info("Unknown event type received %x\n", events_type);
+		pr_info("Unknown event type received %x\n",
+			dev->hotkey_event_type);
 	error = sparse_keymap_setup(dev->hotkey_dev, keymap, NULL);
 	if (error)
 		goto err_free_dev;
@@ -2443,12 +2440,10 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
 	 * Determine hotkey query interface. Prefer using the INFO
 	 * method when it is available.
 	 */
-	if (acpi_has_method(dev->acpi_dev->handle, "INFO"))
+	if (acpi_has_method(dev->acpi_dev->handle, "INFO")) {
 		dev->info_supported = 1;
-	else {
-		hci_result = hci_write(dev, HCI_SYSTEM_EVENT, 1);
-		if (hci_result == TOS_SUCCESS)
-			dev->system_event_supported = 1;
+	} else if (hci_write(dev, HCI_SYSTEM_EVENT, 1) == TOS_SUCCESS)
+		dev->system_event_supported = 1;
 	}
 
 	if (!dev->info_supported && !dev->system_event_supported) {
Signature · 1 line
2.5.1
author maintainer
#1 lore raw

PATCH 1/1 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 propper 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).

---
 MAINTAINERS                        |   6 ++
 drivers/platform/x86/Kconfig       |  18 +++++
 drivers/platform/x86/Makefile      |   1 +
 drivers/platform/x86/toshiba-wmi.c | 138 +++++++++++++++++++++++++++++++++++++
 4 files changed, 163 insertions(+)
 create mode 100644 drivers/platform/x86/toshiba-wmi.c
MAINTAINERS +6 -0
index 884d398..07f4446 100644
@@ -10318,6 +10318,12 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/platform/x86/toshiba_haps.c
 
+TOSHIBA WMI HOTKEYS DRIVER
+M:	Azael Avalos <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/platform/x86/toshiba-wmi.c
+
 TOSHIBA SMM DRIVER
 M:	Jonathan Buzzard <[email protected]>
 W:	http://www.buzzard.org.uk/toshiba/
drivers/platform/x86/Kconfig +18 -0
index c69bb70..9ae1e89 100644
@@ -700,6 +700,24 @@ config TOSHIBA_HAPS
 	  If you have a recent Toshiba laptop with a built-in accelerometer
 	  device, say Y.
 
+config TOSHIBA_WMI
+	tristate "Toshiba WMI Hotkeys Driver (EXPERIMENTAL)"
+	default n
+	depends on ACPI_WMI
+	depends on INPUT
+	select INPUT_SPARSEKMAP
+	---help---
+	  This driver adds hotkey monitoring support to some Toshiba models
+	  that manage the hotkeys via WMI events.
+
+	  WARNING: This driver is incomplete as it lacks a propper keymap and the
+	  *notify function only prints the ACPI event type value. Be warned that
+	  you will need to provide some information if you have a Toshiba model
+	  with WMI event hotkeys and want to help with the develpment of this
+	  driver.
+
+	  If you have a WMI-based hotkeys Toshiba laptop, say Y or M here.
+
 config ACPI_CMPC
 	tristate "CMPC Laptop Extras"
 	depends on X86 && ACPI
drivers/platform/x86/Makefile +1 -0
index ada5128..8f077cb 100644
@@ -40,6 +40,7 @@ obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
 
 obj-$(CONFIG_TOSHIBA_BT_RFKILL)	+= toshiba_bluetooth.o
 obj-$(CONFIG_TOSHIBA_HAPS)	+= toshiba_haps.o
+obj-$(CONFIG_TOSHIBA_HAPS)	+= toshiba-wmi.o
 obj-$(CONFIG_INTEL_SCU_IPC)	+= intel_scu_ipc.o
 obj-$(CONFIG_INTEL_SCU_IPC_UTIL) += intel_scu_ipcutil.o
 obj-$(CONFIG_INTEL_MFLD_THERMAL) += intel_mid_thermal.o
drivers/platform/x86/toshiba-wmi.c new file +138 -0

138 lines not on this page · raw message

Signature · 1 line
2.5.1
#2 lore raw

Re: [PATCH] platform/x86: Toshiba WMI Hotkey Driver

Quoted 9 lines · Azael Avalos

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).

Quoted 7 lines

The toshiba_acpi driver and this one can co-exist, as this only takes care of hotkeys, while the propper 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).

+Dmitry - Are you interested in being Cc'd on new users of input outside drivers/input ?

Quoted 123 lines
---
 MAINTAINERS                        |   6 ++
 drivers/platform/x86/Kconfig       |  18 +++++
 drivers/platform/x86/Makefile      |   1 +
 drivers/platform/x86/toshiba-wmi.c | 138 +++++++++++++++++++++++++++++++++++++
 4 files changed, 163 insertions(+)
 create mode 100644 drivers/platform/x86/toshiba-wmi.c
MAINTAINERS +6 -0
index 884d398..07f4446 100644
@@ -10318,6 +10318,12 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/platform/x86/toshiba_haps.c
 
+TOSHIBA WMI HOTKEYS DRIVER
+M:	Azael Avalos <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/platform/x86/toshiba-wmi.c
+
 TOSHIBA SMM DRIVER
 M:	Jonathan Buzzard <[email protected]>
 W:	http://www.buzzard.org.uk/toshiba/
drivers/platform/x86/Kconfig +18 -0
index c69bb70..9ae1e89 100644
@@ -700,6 +700,24 @@ config TOSHIBA_HAPS
 	  If you have a recent Toshiba laptop with a built-in accelerometer
 	  device, say Y.
 
+config TOSHIBA_WMI
+	tristate "Toshiba WMI Hotkeys Driver (EXPERIMENTAL)"
+	default n
+	depends on ACPI_WMI
+	depends on INPUT
+	select INPUT_SPARSEKMAP
+	---help---
+	  This driver adds hotkey monitoring support to some Toshiba models
+	  that manage the hotkeys via WMI events.
+
+	  WARNING: This driver is incomplete as it lacks a propper keymap and the
+	  *notify function only prints the ACPI event type value. Be warned that
+	  you will need to provide some information if you have a Toshiba model
+	  with WMI event hotkeys and want to help with the develpment of this
+	  driver.
+
+	  If you have a WMI-based hotkeys Toshiba laptop, say Y or M here.
+
 config ACPI_CMPC
 	tristate "CMPC Laptop Extras"
 	depends on X86 && ACPI
drivers/platform/x86/Makefile +1 -0
index ada5128..8f077cb 100644
@@ -40,6 +40,7 @@ obj-$(CONFIG_ACPI_TOSHIBA)	+= toshiba_acpi.o
 
 obj-$(CONFIG_TOSHIBA_BT_RFKILL)	+= toshiba_bluetooth.o
 obj-$(CONFIG_TOSHIBA_HAPS)	+= toshiba_haps.o
+obj-$(CONFIG_TOSHIBA_HAPS)	+= toshiba-wmi.o
 obj-$(CONFIG_INTEL_SCU_IPC)	+= intel_scu_ipc.o
 obj-$(CONFIG_INTEL_SCU_IPC_UTIL) += intel_scu_ipcutil.o
 obj-$(CONFIG_INTEL_MFLD_THERMAL) += intel_mid_thermal.o
drivers/platform/x86/toshiba-wmi.c new file +51 -0
new file mode 100644
index 0000000..8cf62a1
@@ -0,0 +1,138 @@
+/*
+ * toshiba_wmi.c - Toshiba WMI Hotkey Driver
+ *
+ * Copyright (C) 2015 Azael Avalos <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/acpi.h>
+#include <linux/input.h>
+#include <linux/input/sparse-keymap.h>
+
+MODULE_AUTHOR("Azael Avalos");
+MODULE_DESCRIPTION("Toshiba WMI Hotkey Driver");
+MODULE_LICENSE("GPL");
+
+#define TOSHIBA_WMI_EVENT_GUID	"59142400-C6A3-40FA-BADB-8A2652834100"
+
+MODULE_ALIAS("wmi:"TOSHIBA_WMI_EVENT_GUID);
+
+struct input_dev *toshiba_wmi_input_dev;
+
+static const struct key_entry toshiba_wmi_keymap[] __initconst = {
+	/* TODO: Add keymap values once found... */
+	/*{ KE_KEY, 0x00, { KEY_ } },*/
+	{ KE_END, 0 }
+};
+
+static void toshiba_wmi_notify(u32 value, void *context)
+{
+	struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
+	union acpi_object *obj;
+	acpi_status status;
+
+	status = wmi_get_event_data(value, &response);
+	if (ACPI_FAILURE(status)) {

drivers/platform/x86/toshiba-wmi.c line 61

Quoted 10 lines
drivers/platform/x86/toshiba-wmi.c new file +10 -0
+		pr_err("Bad event status 0x%x\n", status);
+		return;
+	}
+
+	obj = (union acpi_object *)response.pointer;
+	if (!obj)
+		return;
+
+	/* TODO: Add propper checks once we have data */
+	pr_info("Unknown event received, obj type %x\n", obj->type);

Since this will print all the time, perhaps a pr_dbg is more appropraite here...

Quoted 81 lines
drivers/platform/x86/toshiba-wmi.c new file +77 -0
+
+	kfree(response.pointer);
+}
+
+static int __init toshiba_wmi_input_setup(void)
+{
+	acpi_status status;
+	int err;
+
+	toshiba_wmi_input_dev = input_allocate_device();
+	if (!toshiba_wmi_input_dev)
+		return -ENOMEM;
+
+	toshiba_wmi_input_dev->name = "Toshiba WMI hotkeys";
+	toshiba_wmi_input_dev->phys = "wmi/input0";
+	toshiba_wmi_input_dev->id.bustype = BUS_HOST;
+
+	err = sparse_keymap_setup(toshiba_wmi_input_dev,
+				  toshiba_wmi_keymap, NULL);
+	if (err)
+		goto err_free_dev;
+
+	status = wmi_install_notify_handler(TOSHIBA_WMI_EVENT_GUID,
+					    toshiba_wmi_notify, NULL);
+	if (ACPI_FAILURE(status)) {
+		err = -EIO;
+		goto err_free_keymap;
+	}
+
+	err = input_register_device(toshiba_wmi_input_dev);
+	if (err)
+		goto err_remove_notifier;
+
+	return 0;
+
+ err_remove_notifier:
+	wmi_remove_notify_handler(TOSHIBA_WMI_EVENT_GUID);
+ err_free_keymap:
+	sparse_keymap_free(toshiba_wmi_input_dev);
+ err_free_dev:
+	input_free_device(toshiba_wmi_input_dev);
+	return err;
+}
+
+static void toshiba_wmi_input_destroy(void)
+{
+	wmi_remove_notify_handler(TOSHIBA_WMI_EVENT_GUID);
+	sparse_keymap_free(toshiba_wmi_input_dev);
+	input_unregister_device(toshiba_wmi_input_dev);
+}
+
+static int __init toshiba_wmi_init(void)
+{
+	int ret;
+
+	if (!wmi_has_guid(TOSHIBA_WMI_EVENT_GUID))
+		return -ENODEV;
+
+	ret = toshiba_wmi_input_setup();
+	if (ret) {
+		pr_err("Failed to setup input device\n");
+		return ret;
+	}
+
+	pr_info("Toshiba WMI Hotkey Driver\n");
+
+	return 0;
+}
+
+static void __exit toshiba_wmi_exit(void)
+{
+	if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID))
+		toshiba_wmi_input_destroy();
+}
+
+module_init(toshiba_wmi_init);
+module_exit(toshiba_wmi_exit);
Signature · 1 line
2.5.1
Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
author maintainer
#3 lore raw

Re: [PATCH] platform/x86: Toshiba WMI Hotkey Driver

Hi Darren,

2015-09-18 15:59 GMT-06:00 Darren Hart <[email protected]>:

Quoted 148 lines · Azael Avalos
Quoted 9 lines

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).

Quoted 7 lines

The toshiba_acpi driver and this one can co-exist, as this only takes care of hotkeys, while the propper 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).

+Dmitry - Are you interested in being Cc'd on new users of input outside drivers/input ?

Quoted 127 lines
---
 MAINTAINERS                        |   6 ++
 drivers/platform/x86/Kconfig       |  18 +++++
 drivers/platform/x86/Makefile      |   1 +
 drivers/platform/x86/toshiba-wmi.c | 138 +++++++++++++++++++++++++++++++++++++
 4 files changed, 163 insertions(+)
 create mode 100644 drivers/platform/x86/toshiba-wmi.c
MAINTAINERS +6 -0
index 884d398..07f4446 100644
@@ -10318,6 +10318,12 @@ L:   [email protected]
 S:   Maintained
 F:   drivers/platform/x86/toshiba_haps.c
 
+TOSHIBA WMI HOTKEYS DRIVER
+M:   Azael Avalos <[email protected]>
+L:   [email protected]
+S:   Maintained
+F:   drivers/platform/x86/toshiba-wmi.c
+
 TOSHIBA SMM DRIVER
 M:   Jonathan Buzzard <[email protected]>
 W:   http://www.buzzard.org.uk/toshiba/
drivers/platform/x86/Kconfig +18 -0
index c69bb70..9ae1e89 100644
@@ -700,6 +700,24 @@ config TOSHIBA_HAPS
        If you have a recent Toshiba laptop with a built-in accelerometer
        device, say Y.
 
+config TOSHIBA_WMI
+     tristate "Toshiba WMI Hotkeys Driver (EXPERIMENTAL)"
+     default n
+     depends on ACPI_WMI
+     depends on INPUT
+     select INPUT_SPARSEKMAP
+     ---help---
+       This driver adds hotkey monitoring support to some Toshiba models
+       that manage the hotkeys via WMI events.
+
+       WARNING: This driver is incomplete as it lacks a propper keymap and the
+       *notify function only prints the ACPI event type value. Be warned that
+       you will need to provide some information if you have a Toshiba model
+       with WMI event hotkeys and want to help with the develpment of this
+       driver.
+
+       If you have a WMI-based hotkeys Toshiba laptop, say Y or M here.
+
 config ACPI_CMPC
      tristate "CMPC Laptop Extras"
      depends on X86 && ACPI
drivers/platform/x86/Makefile +1 -0
index ada5128..8f077cb 100644
@@ -40,6 +40,7 @@ obj-$(CONFIG_ACPI_TOSHIBA)  += toshiba_acpi.o
 
 obj-$(CONFIG_TOSHIBA_BT_RFKILL)      += toshiba_bluetooth.o
 obj-$(CONFIG_TOSHIBA_HAPS)   += toshiba_haps.o
+obj-$(CONFIG_TOSHIBA_HAPS)   += toshiba-wmi.o
 obj-$(CONFIG_INTEL_SCU_IPC)  += intel_scu_ipc.o
 obj-$(CONFIG_INTEL_SCU_IPC_UTIL) += intel_scu_ipcutil.o
 obj-$(CONFIG_INTEL_MFLD_THERMAL) += intel_mid_thermal.o
drivers/platform/x86/toshiba-wmi.c new file +55 -0
new file mode 100644
index 0000000..8cf62a1
@@ -0,0 +1,138 @@
+/*
+ * toshiba_wmi.c - Toshiba WMI Hotkey Driver
+ *
+ * Copyright (C) 2015 Azael Avalos <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/acpi.h>
+#include <linux/input.h>
+#include <linux/input/sparse-keymap.h>
+
+MODULE_AUTHOR("Azael Avalos");
+MODULE_DESCRIPTION("Toshiba WMI Hotkey Driver");
+MODULE_LICENSE("GPL");
+
+#define TOSHIBA_WMI_EVENT_GUID       "59142400-C6A3-40FA-BADB-8A2652834100"
+
+MODULE_ALIAS("wmi:"TOSHIBA_WMI_EVENT_GUID);
+
+struct input_dev *toshiba_wmi_input_dev;
+
+static const struct key_entry toshiba_wmi_keymap[] __initconst = {
+     /* TODO: Add keymap values once found... */
+     /*{ KE_KEY, 0x00, { KEY_ } },*/
+     { KE_END, 0 }
+};
+
+static void toshiba_wmi_notify(u32 value, void *context)
+{
+     struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
+     union acpi_object *obj;
+     acpi_status status;
+
+     status = wmi_get_event_data(value, &response);
+     if (ACPI_FAILURE(status)) {
+             pr_err("Bad event status 0x%x\n", status);
+             return;
+     }
+
Quoted 8 lines

drivers/platform/x86/toshiba-wmi.c line 61

Quoted 6 lines
drivers/platform/x86/toshiba-wmi.c new file +6 -0
+     obj = (union acpi_object *)response.pointer;
+     if (!obj)
+             return;
+
+     /* TODO: Add propper checks once we have data */
+     pr_info("Unknown event received, obj type %x\n", obj->type);

Since this will print all the time, perhaps a pr_dbg is more appropraite here...

OK, will change in v2, along with a static warning caught by the build test.

Quoted 79 lines
Quoted 79 lines
drivers/platform/x86/toshiba-wmi.c new file +77 -0
+
+     kfree(response.pointer);
+}
+
+static int __init toshiba_wmi_input_setup(void)
+{
+     acpi_status status;
+     int err;
+
+     toshiba_wmi_input_dev = input_allocate_device();
+     if (!toshiba_wmi_input_dev)
+             return -ENOMEM;
+
+     toshiba_wmi_input_dev->name = "Toshiba WMI hotkeys";
+     toshiba_wmi_input_dev->phys = "wmi/input0";
+     toshiba_wmi_input_dev->id.bustype = BUS_HOST;
+
+     err = sparse_keymap_setup(toshiba_wmi_input_dev,
+                               toshiba_wmi_keymap, NULL);
+     if (err)
+             goto err_free_dev;
+
+     status = wmi_install_notify_handler(TOSHIBA_WMI_EVENT_GUID,
+                                         toshiba_wmi_notify, NULL);
+     if (ACPI_FAILURE(status)) {
+             err = -EIO;
+             goto err_free_keymap;
+     }
+
+     err = input_register_device(toshiba_wmi_input_dev);
+     if (err)
+             goto err_remove_notifier;
+
+     return 0;
+
+ err_remove_notifier:
+     wmi_remove_notify_handler(TOSHIBA_WMI_EVENT_GUID);
+ err_free_keymap:
+     sparse_keymap_free(toshiba_wmi_input_dev);
+ err_free_dev:
+     input_free_device(toshiba_wmi_input_dev);
+     return err;
+}
+
+static void toshiba_wmi_input_destroy(void)
+{
+     wmi_remove_notify_handler(TOSHIBA_WMI_EVENT_GUID);
+     sparse_keymap_free(toshiba_wmi_input_dev);
+     input_unregister_device(toshiba_wmi_input_dev);
+}
+
+static int __init toshiba_wmi_init(void)
+{
+     int ret;
+
+     if (!wmi_has_guid(TOSHIBA_WMI_EVENT_GUID))
+             return -ENODEV;
+
+     ret = toshiba_wmi_input_setup();
+     if (ret) {
+             pr_err("Failed to setup input device\n");
+             return ret;
+     }
+
+     pr_info("Toshiba WMI Hotkey Driver\n");
+
+     return 0;
+}
+
+static void __exit toshiba_wmi_exit(void)
+{
+     if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID))
+             toshiba_wmi_input_destroy();
+}
+
+module_init(toshiba_wmi_init);
+module_exit(toshiba_wmi_exit);
Quoted 8 lines
Quoted 4 lines

--
2.5.1

--
Darren Hart
Intel Open Source Technology Center

Cheers
Azael

Signature · 1 line
-- El mundo apesta y vosotros apestais tambien --
#4 lore raw

Re: [PATCH] platform/x86: Toshiba WMI Hotkey Driver

In reply to Darren Hart
Quoted 13 lines · Darren Hart
Quoted 12 lines · Azael Avalos

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 propper takes care of hardware related stuff.

Quoted 7 lines
Quoted 4 lines

Currently the driver is under the EXPERIMENTAL flag, as the keymap and the notify function are incomplete (due to lack of hardware to test).

+Dmitry - Are you interested in being Cc'd on new users of input outside drivers/input ?

Yes, please.

Quoted 34 lines
Quoted 34 lines
---
 MAINTAINERS                        |   6 ++
 drivers/platform/x86/Kconfig       |  18 +++++
 drivers/platform/x86/Makefile      |   1 +
 drivers/platform/x86/toshiba-wmi.c | 138 +++++++++++++++++++++++++++++++++++++
 4 files changed, 163 insertions(+)
 create mode 100644 drivers/platform/x86/toshiba-wmi.c
MAINTAINERS +6 -0
index 884d398..07f4446 100644
@@ -10318,6 +10318,12 @@ L:   [email protected]
 S:   Maintained
 F:   drivers/platform/x86/toshiba_haps.c
 
+TOSHIBA WMI HOTKEYS DRIVER
+M:   Azael Avalos <[email protected]>
+L:   [email protected]
+S:   Maintained
+F:   drivers/platform/x86/toshiba-wmi.c
+
 TOSHIBA SMM DRIVER
 M:   Jonathan Buzzard <[email protected]>
 W:   http://www.buzzard.org.uk/toshiba/
drivers/platform/x86/Kconfig +0 -0
index c69bb70..9ae1e89 100644
@@ -700,6 +700,24 @@ config TOSHIBA_HAPS
        If you have a recent Toshiba laptop with a built-in accelerometer
        device, say Y.
 
Quoted 11 lines

drivers/platform/x86/Kconfig config TOSHIBA_HAPS · line 713

Quoted 11 lines
drivers/platform/x86/Kconfig +11 -0
+config TOSHIBA_WMI
+     tristate "Toshiba WMI Hotkeys Driver (EXPERIMENTAL)"
+     default n
+     depends on ACPI_WMI
+     depends on INPUT
+     select INPUT_SPARSEKMAP
+     ---help---
+       This driver adds hotkey monitoring support to some Toshiba models
+       that manage the hotkeys via WMI events.
+
+       WARNING: This driver is incomplete as it lacks a propper keymap and the

s/propper/proper/

Quoted 56 lines
Quoted 56 lines
drivers/platform/x86/Kconfig +7 -0
+       *notify function only prints the ACPI event type value. Be warned that
+       you will need to provide some information if you have a Toshiba model
+       with WMI event hotkeys and want to help with the develpment of this
+       driver.
+
+       If you have a WMI-based hotkeys Toshiba laptop, say Y or M here.
+
 config ACPI_CMPC
      tristate "CMPC Laptop Extras"
      depends on X86 && ACPI
drivers/platform/x86/Makefile +1 -0
index ada5128..8f077cb 100644
@@ -40,6 +40,7 @@ obj-$(CONFIG_ACPI_TOSHIBA)  += toshiba_acpi.o
 
 obj-$(CONFIG_TOSHIBA_BT_RFKILL)      += toshiba_bluetooth.o
 obj-$(CONFIG_TOSHIBA_HAPS)   += toshiba_haps.o
+obj-$(CONFIG_TOSHIBA_HAPS)   += toshiba-wmi.o
 obj-$(CONFIG_INTEL_SCU_IPC)  += intel_scu_ipc.o
 obj-$(CONFIG_INTEL_SCU_IPC_UTIL) += intel_scu_ipcutil.o
 obj-$(CONFIG_INTEL_MFLD_THERMAL) += intel_mid_thermal.o
drivers/platform/x86/toshiba-wmi.c new file +28 -0
new file mode 100644
index 0000000..8cf62a1
@@ -0,0 +1,138 @@
+/*
+ * toshiba_wmi.c - Toshiba WMI Hotkey Driver
+ *
+ * Copyright (C) 2015 Azael Avalos <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/acpi.h>
+#include <linux/input.h>
+#include <linux/input/sparse-keymap.h>
+
+MODULE_AUTHOR("Azael Avalos");
Quoted 8 lines

drivers/platform/x86/toshiba-wmi.c line 36

Quoted 8 lines
drivers/platform/x86/toshiba-wmi.c new file +8 -0
+MODULE_DESCRIPTION("Toshiba WMI Hotkey Driver");
+MODULE_LICENSE("GPL");
+
+#define TOSHIBA_WMI_EVENT_GUID       "59142400-C6A3-40FA-BADB-8A2652834100"
+
+MODULE_ALIAS("wmi:"TOSHIBA_WMI_EVENT_GUID);
+
+struct input_dev *toshiba_wmi_input_dev;

static?

Thanks.

Signature · 1 line
Dmitry
author maintainer
#5 lore raw

Re: [PATCH] platform/x86: Toshiba WMI Hotkey Driver

Hi there

2015-09-19 10:48 GMT-06:00 Dmitry Torokhov <[email protected]>:

Quoted 130 lines · Darren Hart
Quoted 13 lines · Azael Avalos
Quoted 12 lines

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 propper takes care of hardware related stuff.

Quoted 7 lines
Quoted 4 lines

Currently the driver is under the EXPERIMENTAL flag, as the keymap and the notify function are incomplete (due to lack of hardware to test).

+Dmitry - Are you interested in being Cc'd on new users of input outside drivers/input ?

Yes, please.

Quoted 34 lines
Quoted 34 lines
---
 MAINTAINERS                        |   6 ++
 drivers/platform/x86/Kconfig       |  18 +++++
 drivers/platform/x86/Makefile      |   1 +
 drivers/platform/x86/toshiba-wmi.c | 138 +++++++++++++++++++++++++++++++++++++
 4 files changed, 163 insertions(+)
 create mode 100644 drivers/platform/x86/toshiba-wmi.c
MAINTAINERS +6 -0
index 884d398..07f4446 100644
@@ -10318,6 +10318,12 @@ L:   [email protected]
 S:   Maintained
 F:   drivers/platform/x86/toshiba_haps.c
 
+TOSHIBA WMI HOTKEYS DRIVER
+M:   Azael Avalos <[email protected]>
+L:   [email protected]
+S:   Maintained
+F:   drivers/platform/x86/toshiba-wmi.c
+
 TOSHIBA SMM DRIVER
 M:   Jonathan Buzzard <[email protected]>
 W:   http://www.buzzard.org.uk/toshiba/
drivers/platform/x86/Kconfig +0 -0
index c69bb70..9ae1e89 100644
@@ -700,6 +700,24 @@ config TOSHIBA_HAPS
        If you have a recent Toshiba laptop with a built-in accelerometer
        device, say Y.
 
Quoted 11 lines

drivers/platform/x86/Kconfig config TOSHIBA_HAPS · line 713

Quoted 11 lines
drivers/platform/x86/Kconfig +11 -0
+config TOSHIBA_WMI
+     tristate "Toshiba WMI Hotkeys Driver (EXPERIMENTAL)"
+     default n
+     depends on ACPI_WMI
+     depends on INPUT
+     select INPUT_SPARSEKMAP
+     ---help---
+       This driver adds hotkey monitoring support to some Toshiba models
+       that manage the hotkeys via WMI events.
+
+       WARNING: This driver is incomplete as it lacks a propper keymap and the

s/propper/proper/

Quoted 58 lines
Quoted 58 lines
drivers/platform/x86/Kconfig +7 -0
+       *notify function only prints the ACPI event type value. Be warned that
+       you will need to provide some information if you have a Toshiba model
+       with WMI event hotkeys and want to help with the develpment of this
+       driver.
+
+       If you have a WMI-based hotkeys Toshiba laptop, say Y or M here.
+
 config ACPI_CMPC
      tristate "CMPC Laptop Extras"
      depends on X86 && ACPI
drivers/platform/x86/Makefile +1 -0
index ada5128..8f077cb 100644
@@ -40,6 +40,7 @@ obj-$(CONFIG_ACPI_TOSHIBA)  += toshiba_acpi.o
 
 obj-$(CONFIG_TOSHIBA_BT_RFKILL)      += toshiba_bluetooth.o
 obj-$(CONFIG_TOSHIBA_HAPS)   += toshiba_haps.o
+obj-$(CONFIG_TOSHIBA_HAPS)   += toshiba-wmi.o
 obj-$(CONFIG_INTEL_SCU_IPC)  += intel_scu_ipc.o
 obj-$(CONFIG_INTEL_SCU_IPC_UTIL) += intel_scu_ipcutil.o
 obj-$(CONFIG_INTEL_MFLD_THERMAL) += intel_mid_thermal.o
drivers/platform/x86/toshiba-wmi.c new file +30 -0
new file mode 100644
index 0000000..8cf62a1
@@ -0,0 +1,138 @@
+/*
+ * toshiba_wmi.c - Toshiba WMI Hotkey Driver
+ *
+ * Copyright (C) 2015 Azael Avalos <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/acpi.h>
+#include <linux/input.h>
+#include <linux/input/sparse-keymap.h>
+
+MODULE_AUTHOR("Azael Avalos");
+MODULE_DESCRIPTION("Toshiba WMI Hotkey Driver");
+MODULE_LICENSE("GPL");
Quoted 8 lines
Quoted 6 lines

drivers/platform/x86/toshiba-wmi.c line 36

Quoted 6 lines
drivers/platform/x86/toshiba-wmi.c new file +6 -0
+
+#define TOSHIBA_WMI_EVENT_GUID       "59142400-C6A3-40FA-BADB-8A2652834100"
+
+MODULE_ALIAS("wmi:"TOSHIBA_WMI_EVENT_GUID);
+
+struct input_dev *toshiba_wmi_input_dev;

static?

Already done in v2 :-)

I'll wait for more comments on this and send a v3 correcting the typo and whatever comes up.

Quoted 5 lines

Thanks.

--
Dmitry

Cheers
Azael

Signature · 1 line
-- El mundo apesta y vosotros apestais tambien --
author maintainer
#6 lore raw

PATCH 1/1 toshiba_acpi: Add 0x prefix to available_kbd_modes_show funtion

In reply to Azael Avalos

This patch adds the 0x prefix to the values printed by such function, the values are already being printed in hex, but without the prefix, causing confussion, even though the file under Documentation/ABI clearly states that hey are hex values.

Simply add the 0x prefix to avoid such confussion.

---
 drivers/platform/x86/toshiba_acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/toshiba_acpi.c +2 -2
index 9f7ced1..50a2116 100644
@@ -1669,10 +1669,10 @@ static ssize_t available_kbd_modes_show(struct device *dev,
 	struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
 
 	if (toshiba->kbd_type == 1)
-		return sprintf(buf, "%x %x\n",
+		return sprintf(buf, "0x%x 0x%x\n",
 			       SCI_KBD_MODE_FNZ, SCI_KBD_MODE_AUTO);
 
-	return sprintf(buf, "%x %x %x\n",
+	return sprintf(buf, "0x%x 0x%x 0x%x\n",
 		       SCI_KBD_MODE_AUTO, SCI_KBD_MODE_ON, SCI_KBD_MODE_OFF);
 }
 static DEVICE_ATTR_RO(available_kbd_modes);
Signature · 1 line
2.5.1
#7 lore raw

Re: [PATCH 1/1] toshiba_acpi: Add 0x prefix to available_kbd_modes_show funtion

Quoted 8 lines · Azael Avalos

This patch adds the 0x prefix to the values printed by such function, the values are already being printed in hex, but without the prefix, causing confussion, even though the file under Documentation/ABI clearly states that hey are hex values.

Simply add the 0x prefix to avoid such confussion.

Queued to testing for 4.4.

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#8 lore raw
In reply to Azael Avalos
Quoted 9 lines · Azael Avalos

The function toshiba_acpi_setup_keyboard currently has two u32 variables used to store the Hotkey Event Type and the result of the HCI_SYSTEM_EVENT query.

This patch removes those two variables, as we already have a global variable named "hotkey_event_type" and the result of the HCI_SYSTEM_EVENT query can be checked directly from the function.

...

drivers/platform/x86/toshiba_acpi.c static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev) · line 2445

Quoted 13 lines
drivers/platform/x86/toshiba_acpi.c +2 -5
 		goto err_free_dev;
@@ -2443,12 +2440,10 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
 	 * Determine hotkey query interface. Prefer using the INFO
 	 * method when it is available.
 	 */
-	if (acpi_has_method(dev->acpi_dev->handle, "INFO"))
+	if (acpi_has_method(dev->acpi_dev->handle, "INFO")) {
 		dev->info_supported = 1;
-	else {
-		hci_result = hci_write(dev, HCI_SYSTEM_EVENT, 1);
-		if (hci_result == TOS_SUCCESS)
-			dev->system_event_supported = 1;
+	} else if (hci_write(dev, HCI_SYSTEM_EVENT, 1) == TOS_SUCCESS)

Ahem.

Missing the brace at the end and wreaking havoc on the poor compiler!

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center