Skip to contentSkip to conversation

platform/x86: peaq-wmi: Add new peaq-wmi driver

PATCH Superseded Hans de Goede 3 participants 5 messages May 8, 2017 – May 9, 2017 x86 platform drivers

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: peaq-wmi: Add new peaq-wmi driver

PEAQ is a new European OEM, I've bought one of their 2-in-1 x86 devices, which is actually quite a nice device. Under Windows it has Dolby software for "better" sound and you can select different equalizer presets using a special button.

This WMI interface for this button is not really nice, as it does not do notifies (it really does not I tripple checked), but since I had already figured out the entire WMI interface for this I decided to go the full mile anyways and also implent a WMI based input driver for this using input_polldev since, well, we need to poll.

This commit adds support for this button making it report KEY_SOUND input events. KEY_SOUND is already used in various places to switch sound into theatre mode and things like that so it seems appropriate here.

---
 drivers/platform/x86/Kconfig    |  7 +++
 drivers/platform/x86/Makefile   |  1 +
 drivers/platform/x86/peaq-wmi.c | 94 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 102 insertions(+)
 create mode 100644 drivers/platform/x86/peaq-wmi.c
drivers/platform/x86/Kconfig +7 -0
index be2ffbd6eb6c..2bac2b2644f9 100644
@@ -660,6 +660,13 @@ config MSI_WMI
 	 To compile this driver as a module, choose M here: the module will
 	 be called msi-wmi.
 
+config PEAQ_WMI
+	tristate "PEAQ 2-in-1 WMI hotkey driver"
+	depends on ACPI_WMI
+	depends on INPUT
+	help
+	 Say Y here if you want to support WMI-based hotkeys on PEAQ 2-in-1s.
+
 config TOPSTAR_LAPTOP
 	tristate "Topstar Laptop Extras"
 	depends on ACPI
drivers/platform/x86/Makefile +1 -0
index de4ffb594ba5..02487f95dd27 100644
@@ -34,6 +34,7 @@ obj-$(CONFIG_PANASONIC_LAPTOP)	+= panasonic-laptop.o
 obj-$(CONFIG_INTEL_MENLOW)	+= intel_menlow.o
 obj-$(CONFIG_ACPI_WMI)		+= wmi.o
 obj-$(CONFIG_MSI_WMI)		+= msi-wmi.o
+obj-$(CONFIG_PEAQ_WMI)		+= peaq-wmi.o
 obj-$(CONFIG_SURFACE3_WMI)	+= surface3-wmi.o
 obj-$(CONFIG_TOPSTAR_LAPTOP)	+= topstar-laptop.o
 
drivers/platform/x86/peaq-wmi.c new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
2.12.2
#1 lore raw
Quoted 11 lines · Hans de Goede

PEAQ is a new European OEM, I've bought one of their 2-in-1 x86 devices, which is actually quite a nice device. Under Windows it has Dolby software for "better" sound and you can select different equalizer presets using a special button.

This WMI interface for this button is not really nice, as it does not do notifies (it really does not I tripple checked), but since I had already figured out the entire WMI interface for this I decided to go the full mile anyways and also implent a WMI based input driver for this using input_polldev since, well, we need to poll.

Quoted 5 lines

This commit adds support for this button making it report KEY_SOUND input events. KEY_SOUND is already used in various places to switch sound into theatre mode and things like that so it seems appropriate here.

Thanks Hans,

A couple nits below, otherwise, looks good to me.

+Dmitry in case he cares to weigh in on input/input-polldev usage

Quoted 44 lines
---
 drivers/platform/x86/Kconfig    |  7 +++
 drivers/platform/x86/Makefile   |  1 +
 drivers/platform/x86/peaq-wmi.c | 94 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 102 insertions(+)
 create mode 100644 drivers/platform/x86/peaq-wmi.c
drivers/platform/x86/Kconfig +7 -0
index be2ffbd6eb6c..2bac2b2644f9 100644
@@ -660,6 +660,13 @@ config MSI_WMI
 	 To compile this driver as a module, choose M here: the module will
 	 be called msi-wmi.
 
+config PEAQ_WMI
+	tristate "PEAQ 2-in-1 WMI hotkey driver"
+	depends on ACPI_WMI
+	depends on INPUT
+	help
+	 Say Y here if you want to support WMI-based hotkeys on PEAQ 2-in-1s.
+
 config TOPSTAR_LAPTOP
 	tristate "Topstar Laptop Extras"
 	depends on ACPI
drivers/platform/x86/Makefile +1 -0
index de4ffb594ba5..02487f95dd27 100644
@@ -34,6 +34,7 @@ obj-$(CONFIG_PANASONIC_LAPTOP)	+= panasonic-laptop.o
 obj-$(CONFIG_INTEL_MENLOW)	+= intel_menlow.o
 obj-$(CONFIG_ACPI_WMI)		+= wmi.o
 obj-$(CONFIG_MSI_WMI)		+= msi-wmi.o
+obj-$(CONFIG_PEAQ_WMI)		+= peaq-wmi.o
 obj-$(CONFIG_SURFACE3_WMI)	+= surface3-wmi.o
 obj-$(CONFIG_TOPSTAR_LAPTOP)	+= topstar-laptop.o
 
drivers/platform/x86/peaq-wmi.c new file +1 -0
new file mode 100644
index 000000000000..8cd6b962ce5e
@@ -0,0 +1,94 @@
+/*

drivers/platform/x86/peaq-wmi.c line 11

Quoted 10 lines
drivers/platform/x86/peaq-wmi.c new file +10 -0
+ * PEAQ 2-in-1 WMI hotkey driver
+ * Copyright (C) 2017 Hans de Goede <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/acpi.h>
+#include <linux/input.h>

input-polldev includes input, no need for both.

drivers/platform/x86/peaq-wmi.c line 23

Quoted 12 lines
drivers/platform/x86/peaq-wmi.c new file +12 -0
+#include <linux/input-polldev.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#define PEAQ_DOLBY_BUTTON_GUID		"ABBC0F6F-8EA1-11D1-00A0-C90629100000"
+#define PEAQ_DOLBY_BUTTON_METHOD_ID	5
+#define PEAQ_POLL_INTERVAL_MS		250
+
+MODULE_ALIAS("wmi:"PEAQ_DOLBY_BUTTON_GUID);
+
+struct input_polled_dev *peaq_poll_dev;
+int peaq_ignore_events_counter;

Please make local globals static if they are needed.

Once we make WMI a bus with devices, we should be able to clean this up with devm.

Quoted 24 lines
drivers/platform/x86/peaq-wmi.c new file +24 -0
+
+/*
+ * The Dolby button (yes really a Dolby button) causes an ACPI variable to get
+ * set on both press and release. The WMI method checks and clears that flag.
+ * So for a press + release we will get back One from the WMI method either once
+ * (if polling after the release) or twice (polling between press and release).
+ * We ignore events for 0.5s after the first event to avoid reporting 2 presses.
+ */
+static void peaq_wmi_poll(struct input_polled_dev *dev)
+{
+	union acpi_object obj;
+	struct acpi_buffer buffer = { sizeof(obj), &obj };
+	acpi_status status;
+
+	status = wmi_evaluate_method(PEAQ_DOLBY_BUTTON_GUID, 1,
+				     PEAQ_DOLBY_BUTTON_METHOD_ID,
+				     NULL, &buffer);
+	if (ACPI_FAILURE(status))
+		return;
+
+	if (obj.type != ACPI_TYPE_INTEGER) {
+		dev_err(&peaq_poll_dev->input->dev,
+			"Error WMBC did not return an integer\n");
+		return;

drivers/platform/x86/peaq-wmi.c line 57

Quoted 10 lines
drivers/platform/x86/peaq-wmi.c new file +10 -0
+	}
+
+	if (peaq_ignore_events_counter && --peaq_ignore_events_counter > 0)
+		return;
+
+	if (obj.integer.value) {
+		input_event(peaq_poll_dev->input, EV_KEY, KEY_SOUND, 1);
+		input_event(peaq_poll_dev->input, EV_KEY, KEY_SOUND, 0);
+		input_sync(peaq_poll_dev->input);
+		peaq_ignore_events_counter = 500 / peaq_poll_dev->poll_interval;

Might as well define 500 above with the interval and keep these parameters together, keep the units obvious, etc. e.g.

#define PEAQ_POLL_IGNORE_MS 500

Or similar

Quoted 6 lines
drivers/platform/x86/peaq-wmi.c new file +6 -0
+	}
+}
+
+static int __init peaq_wmi_init(void)
+{
+	if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))

drivers/platform/x86/peaq-wmi.c line 73

Quoted 10 lines
drivers/platform/x86/peaq-wmi.c new file +10 -0
+		return -ENODEV;
+
+	peaq_poll_dev = input_allocate_polled_device();
+	if (!peaq_poll_dev)
+		return -ENOMEM;
+
+	peaq_poll_dev->poll = peaq_wmi_poll;
+	peaq_poll_dev->poll_interval = PEAQ_POLL_INTERVAL_MS;
+	peaq_poll_dev->poll_interval_max = 1000; /* 1 second */
+	peaq_poll_dev->input->name = "PEAQ WMI hotkeys";

Are there additional keys/buttons?

Quoted 25 lines
drivers/platform/x86/peaq-wmi.c new file +21 -0
+	peaq_poll_dev->input->phys = "wmi/input0";
+	peaq_poll_dev->input->id.bustype = BUS_HOST;
+	input_set_capability(peaq_poll_dev->input, EV_KEY, KEY_SOUND);
+
+	return input_register_polled_device(peaq_poll_dev);
+}
+
+static void __exit peaq_wmi_exit(void)
+{
+	if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))
+		return;
+
+	input_unregister_polled_device(peaq_poll_dev);
+}
+
+module_init(peaq_wmi_init);
+module_exit(peaq_wmi_exit);
+
+MODULE_DESCRIPTION("PEAQ 2-in-1 WMI hotkey driver");
+MODULE_AUTHOR("Hans de Goede <[email protected]>");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.12.2
Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
#2 lore raw
Quoted 122 lines · Darren Hart
Quoted 11 lines · Hans de Goede

PEAQ is a new European OEM, I've bought one of their 2-in-1 x86 devices, which is actually quite a nice device. Under Windows it has Dolby software for "better" sound and you can select different equalizer presets using a special button.

This WMI interface for this button is not really nice, as it does not do notifies (it really does not I tripple checked), but since I had already figured out the entire WMI interface for this I decided to go the full mile anyways and also implent a WMI based input driver for this using input_polldev since, well, we need to poll.

Quoted 5 lines

This commit adds support for this button making it report KEY_SOUND input events. KEY_SOUND is already used in various places to switch sound into theatre mode and things like that so it seems appropriate here.

Thanks Hans,

A couple nits below, otherwise, looks good to me.

+Dmitry in case he cares to weigh in on input/input-polldev usage

Quoted 44 lines
---
 drivers/platform/x86/Kconfig    |  7 +++
 drivers/platform/x86/Makefile   |  1 +
 drivers/platform/x86/peaq-wmi.c | 94 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 102 insertions(+)
 create mode 100644 drivers/platform/x86/peaq-wmi.c
drivers/platform/x86/Kconfig +7 -0
index be2ffbd6eb6c..2bac2b2644f9 100644
@@ -660,6 +660,13 @@ config MSI_WMI
 	 To compile this driver as a module, choose M here: the module will
 	 be called msi-wmi.
 
+config PEAQ_WMI
+	tristate "PEAQ 2-in-1 WMI hotkey driver"
+	depends on ACPI_WMI
+	depends on INPUT
+	help
+	 Say Y here if you want to support WMI-based hotkeys on PEAQ 2-in-1s.
+
 config TOPSTAR_LAPTOP
 	tristate "Topstar Laptop Extras"
 	depends on ACPI
drivers/platform/x86/Makefile +1 -0
index de4ffb594ba5..02487f95dd27 100644
@@ -34,6 +34,7 @@ obj-$(CONFIG_PANASONIC_LAPTOP)	+= panasonic-laptop.o
 obj-$(CONFIG_INTEL_MENLOW)	+= intel_menlow.o
 obj-$(CONFIG_ACPI_WMI)		+= wmi.o
 obj-$(CONFIG_MSI_WMI)		+= msi-wmi.o
+obj-$(CONFIG_PEAQ_WMI)		+= peaq-wmi.o
 obj-$(CONFIG_SURFACE3_WMI)	+= surface3-wmi.o
 obj-$(CONFIG_TOPSTAR_LAPTOP)	+= topstar-laptop.o
 
drivers/platform/x86/peaq-wmi.c new file +1 -0
new file mode 100644
index 000000000000..8cd6b962ce5e
@@ -0,0 +1,94 @@
+/*

drivers/platform/x86/peaq-wmi.c line 11

Quoted 10 lines
drivers/platform/x86/peaq-wmi.c new file +10 -0
+ * PEAQ 2-in-1 WMI hotkey driver
+ * Copyright (C) 2017 Hans de Goede <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/acpi.h>
+#include <linux/input.h>

input-polldev includes input, no need for both.

drivers/platform/x86/peaq-wmi.c line 23

Quoted 12 lines
drivers/platform/x86/peaq-wmi.c new file +12 -0
+#include <linux/input-polldev.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#define PEAQ_DOLBY_BUTTON_GUID		"ABBC0F6F-8EA1-11D1-00A0-C90629100000"
+#define PEAQ_DOLBY_BUTTON_METHOD_ID	5
+#define PEAQ_POLL_INTERVAL_MS		250
+
+MODULE_ALIAS("wmi:"PEAQ_DOLBY_BUTTON_GUID);
+
+struct input_polled_dev *peaq_poll_dev;
+int peaq_ignore_events_counter;

Please make local globals static if they are needed.

Once we make WMI a bus with devices, we should be able to clean this up with devm.

Quoted 23 lines
drivers/platform/x86/peaq-wmi.c new file +23 -0
+
+/*
+ * The Dolby button (yes really a Dolby button) causes an ACPI variable to get
+ * set on both press and release. The WMI method checks and clears that flag.
+ * So for a press + release we will get back One from the WMI method either once
+ * (if polling after the release) or twice (polling between press and release).
+ * We ignore events for 0.5s after the first event to avoid reporting 2 presses.
+ */
+static void peaq_wmi_poll(struct input_polled_dev *dev)
+{
+	union acpi_object obj;
+	struct acpi_buffer buffer = { sizeof(obj), &obj };
+	acpi_status status;
+
+	status = wmi_evaluate_method(PEAQ_DOLBY_BUTTON_GUID, 1,
+				     PEAQ_DOLBY_BUTTON_METHOD_ID,
+				     NULL, &buffer);
+	if (ACPI_FAILURE(status))
+		return;
+
+	if (obj.type != ACPI_TYPE_INTEGER) {
+		dev_err(&peaq_poll_dev->input->dev,
+			"Error WMBC did not return an integer\n");
Quoted 8 lines

drivers/platform/x86/peaq-wmi.c line 54

Quoted 8 lines
drivers/platform/x86/peaq-wmi.c new file +8 -0
+		return;
+	}
+
+	if (peaq_ignore_events_counter && --peaq_ignore_events_counter > 0)
+		return;
+
+	if (obj.integer.value) {
+		input_event(peaq_poll_dev->input, EV_KEY, KEY_SOUND, 1);

input_sync() here as well please.

Quoted 59 lines

drivers/platform/x86/peaq-wmi.c line 57

Quoted 3 lines
drivers/platform/x86/peaq-wmi.c new file +3 -0
+		input_event(peaq_poll_dev->input, EV_KEY, KEY_SOUND, 0);
+		input_sync(peaq_poll_dev->input);
+		peaq_ignore_events_counter = 500 / peaq_poll_dev->poll_interval;

Might as well define 500 above with the interval and keep these parameters together, keep the units obvious, etc. e.g.

#define PEAQ_POLL_IGNORE_MS 500

Or similar

Quoted 6 lines
drivers/platform/x86/peaq-wmi.c new file +6 -0
+	}
+}
+
+static int __init peaq_wmi_init(void)
+{
+	if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))

drivers/platform/x86/peaq-wmi.c line 73

Quoted 10 lines
drivers/platform/x86/peaq-wmi.c new file +10 -0
+		return -ENODEV;
+
+	peaq_poll_dev = input_allocate_polled_device();
+	if (!peaq_poll_dev)
+		return -ENOMEM;
+
+	peaq_poll_dev->poll = peaq_wmi_poll;
+	peaq_poll_dev->poll_interval = PEAQ_POLL_INTERVAL_MS;
+	peaq_poll_dev->poll_interval_max = 1000; /* 1 second */
+	peaq_poll_dev->input->name = "PEAQ WMI hotkeys";

Are there additional keys/buttons?

Quoted 25 lines
drivers/platform/x86/peaq-wmi.c new file +21 -0
+	peaq_poll_dev->input->phys = "wmi/input0";
+	peaq_poll_dev->input->id.bustype = BUS_HOST;
+	input_set_capability(peaq_poll_dev->input, EV_KEY, KEY_SOUND);
+
+	return input_register_polled_device(peaq_poll_dev);
+}
+
+static void __exit peaq_wmi_exit(void)
+{
+	if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))
+		return;
+
+	input_unregister_polled_device(peaq_poll_dev);
+}
+
+module_init(peaq_wmi_init);
+module_exit(peaq_wmi_exit);
+
+MODULE_DESCRIPTION("PEAQ 2-in-1 WMI hotkey driver");
+MODULE_AUTHOR("Hans de Goede <[email protected]>");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.12.2
Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
Signature · 1 line
Dmitry
#3 lore raw
In reply to Darren Hart

Hi,

Darren, Dmitry, thank you for the review.

Quoted 151 lines · Darren Hart
Quoted 11 lines · Hans de Goede

PEAQ is a new European OEM, I've bought one of their 2-in-1 x86 devices, which is actually quite a nice device. Under Windows it has Dolby software for "better" sound and you can select different equalizer presets using a special button.

This WMI interface for this button is not really nice, as it does not do notifies (it really does not I tripple checked), but since I had already figured out the entire WMI interface for this I decided to go the full mile anyways and also implent a WMI based input driver for this using input_polldev since, well, we need to poll.

Quoted 5 lines

This commit adds support for this button making it report KEY_SOUND input events. KEY_SOUND is already used in various places to switch sound into theatre mode and things like that so it seems appropriate here.

Thanks Hans,

A couple nits below, otherwise, looks good to me.

+Dmitry in case he cares to weigh in on input/input-polldev usage

Quoted 44 lines
---
  drivers/platform/x86/Kconfig    |  7 +++
  drivers/platform/x86/Makefile   |  1 +
  drivers/platform/x86/peaq-wmi.c | 94 +++++++++++++++++++++++++++++++++++++++++
  3 files changed, 102 insertions(+)

create mode 100644 drivers/platform/x86/peaq-wmi.c

drivers/platform/x86/Kconfig +7 -0
index be2ffbd6eb6c..2bac2b2644f9 100644
@@ -660,6 +660,13 @@ config MSI_WMI
  	 To compile this driver as a module, choose M here: the module will
  	 be called msi-wmi.
 
+config PEAQ_WMI
+	tristate "PEAQ 2-in-1 WMI hotkey driver"
+	depends on ACPI_WMI
+	depends on INPUT
+	help
+	 Say Y here if you want to support WMI-based hotkeys on PEAQ 2-in-1s.
+
  config TOPSTAR_LAPTOP
  	tristate "Topstar Laptop Extras"
  	depends on ACPI
drivers/platform/x86/Makefile +1 -0
index de4ffb594ba5..02487f95dd27 100644
@@ -34,6 +34,7 @@ obj-$(CONFIG_PANASONIC_LAPTOP)	+= panasonic-laptop.o
  obj-$(CONFIG_INTEL_MENLOW)	+= intel_menlow.o
  obj-$(CONFIG_ACPI_WMI)		+= wmi.o
  obj-$(CONFIG_MSI_WMI)		+= msi-wmi.o
+obj-$(CONFIG_PEAQ_WMI)		+= peaq-wmi.o
  obj-$(CONFIG_SURFACE3_WMI)	+= surface3-wmi.o
  obj-$(CONFIG_TOPSTAR_LAPTOP)	+= topstar-laptop.o
 
drivers/platform/x86/peaq-wmi.c new file +1 -0
new file mode 100644
index 000000000000..8cd6b962ce5e
@@ -0,0 +1,94 @@
+/*

drivers/platform/x86/peaq-wmi.c line 11

Quoted 10 lines
drivers/platform/x86/peaq-wmi.c new file +10 -0
+ * PEAQ 2-in-1 WMI hotkey driver
+ * Copyright (C) 2017 Hans de Goede <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/acpi.h>
+#include <linux/input.h>

input-polldev includes input, no need for both.

drivers/platform/x86/peaq-wmi.c line 23

Quoted 12 lines
drivers/platform/x86/peaq-wmi.c new file +12 -0
+#include <linux/input-polldev.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#define PEAQ_DOLBY_BUTTON_GUID		"ABBC0F6F-8EA1-11D1-00A0-C90629100000"
+#define PEAQ_DOLBY_BUTTON_METHOD_ID	5
+#define PEAQ_POLL_INTERVAL_MS		250
+
+MODULE_ALIAS("wmi:"PEAQ_DOLBY_BUTTON_GUID);
+
+struct input_polled_dev *peaq_poll_dev;
+int peaq_ignore_events_counter;

Please make local globals static if they are needed.

Once we make WMI a bus with devices, we should be able to clean this up with devm.

Quoted 24 lines
drivers/platform/x86/peaq-wmi.c new file +24 -0
+
+/*
+ * The Dolby button (yes really a Dolby button) causes an ACPI variable to get
+ * set on both press and release. The WMI method checks and clears that flag.
+ * So for a press + release we will get back One from the WMI method either once
+ * (if polling after the release) or twice (polling between press and release).
+ * We ignore events for 0.5s after the first event to avoid reporting 2 presses.
+ */
+static void peaq_wmi_poll(struct input_polled_dev *dev)
+{
+	union acpi_object obj;
+	struct acpi_buffer buffer = { sizeof(obj), &obj };
+	acpi_status status;
+
+	status = wmi_evaluate_method(PEAQ_DOLBY_BUTTON_GUID, 1,
+				     PEAQ_DOLBY_BUTTON_METHOD_ID,
+				     NULL, &buffer);
+	if (ACPI_FAILURE(status))
+		return;
+
+	if (obj.type != ACPI_TYPE_INTEGER) {
+		dev_err(&peaq_poll_dev->input->dev,
+			"Error WMBC did not return an integer\n");
+		return;

drivers/platform/x86/peaq-wmi.c line 57

Quoted 10 lines
drivers/platform/x86/peaq-wmi.c new file +10 -0
+	}
+
+	if (peaq_ignore_events_counter && --peaq_ignore_events_counter > 0)
+		return;
+
+	if (obj.integer.value) {
+		input_event(peaq_poll_dev->input, EV_KEY, KEY_SOUND, 1);
+		input_event(peaq_poll_dev->input, EV_KEY, KEY_SOUND, 0);
+		input_sync(peaq_poll_dev->input);
+		peaq_ignore_events_counter = 500 / peaq_poll_dev->poll_interval;

Might as well define 500 above with the interval and keep these parameters together, keep the units obvious, etc. e.g.

#define PEAQ_POLL_IGNORE_MS 500

Or similar

Quoted 10 lines
drivers/platform/x86/peaq-wmi.c new file +10 -0
+	}
+}
+
+static int __init peaq_wmi_init(void)
+{
+	if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))
+		return -ENODEV;
+
+	peaq_poll_dev = input_allocate_polled_device();
+	if (!peaq_poll_dev)
Quoted 8 lines

drivers/platform/x86/peaq-wmi.c line 73

Quoted 6 lines
drivers/platform/x86/peaq-wmi.c new file +6 -0
+		return -ENOMEM;
+
+	peaq_poll_dev->poll = peaq_wmi_poll;
+	peaq_poll_dev->poll_interval = PEAQ_POLL_INTERVAL_MS;
+	peaq_poll_dev->poll_interval_max = 1000; /* 1 second */
+	peaq_poll_dev->input->name = "PEAQ WMI hotkeys";

Are there additional keys/buttons?

Not through the WMI interface on this model, I decided on the "PEAQ WMI hotkeys" name rather then say "PEAQ Dolby button" as future proofing (this gets exported to userspace so we should not change it in the future) in case this driver ends up delivering events for more special buttons on PEAQ devices.

As for all the other remarks from both you and Dmitry I agree with all of them and I will send a v2 addressing them all.

Regards,

Hans

Quoted 27 lines
Quoted 26 lines
drivers/platform/x86/peaq-wmi.c new file +21 -0
+	peaq_poll_dev->input->phys = "wmi/input0";
+	peaq_poll_dev->input->id.bustype = BUS_HOST;
+	input_set_capability(peaq_poll_dev->input, EV_KEY, KEY_SOUND);
+
+	return input_register_polled_device(peaq_poll_dev);
+}
+
+static void __exit peaq_wmi_exit(void)
+{
+	if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))
+		return;
+
+	input_unregister_polled_device(peaq_poll_dev);
+}
+
+module_init(peaq_wmi_init);
+module_exit(peaq_wmi_exit);
+
+MODULE_DESCRIPTION("PEAQ 2-in-1 WMI hotkey driver");
+MODULE_AUTHOR("Hans de Goede <[email protected]>");
+MODULE_LICENSE("GPL");
Signature · 1 line
2.12.2
#4 lore raw
Quoted 14 lines · Hans de Goede
Quoted 5 lines · Darren Hart

drivers/platform/x86/peaq-wmi.c line 73

Quoted 1 line · Hans de Goede
drivers/platform/x86/peaq-wmi.c new file +1 -0
+	peaq_poll_dev->input->name = "PEAQ WMI hotkeys";

Are there additional keys/buttons?

Not through the WMI interface on this model, I decided on the "PEAQ WMI hotkeys" name rather then say "PEAQ Dolby button" as future proofing (this gets exported to userspace so we should not change it in the future) in case this driver ends up delivering events for more special buttons on PEAQ devices.

Quoted 3 lines

As for all the other remarks from both you and Dmitry I agree with all of them and I will send a v2 addressing them all.

Sounds good, thanks Hans.

Signature · 2 lines
Darren Hart
VMware Open Source Technology Center