Re: [PATCH v10 2/3] x86: add support for Huawei WMI hotkeys.

2018-12-12 Thread Andy Shevchenko
On Wed, Dec 12, 2018 at 3:48 PM Andy Shevchenko
 wrote:
>
> On Wed, Dec 12, 2018 at 8:56 AM Takashi Iwai  wrote:
> >
> > On Tue, 11 Dec 2018 21:10:07 +0100,
> >  wrote:
> > >
> > >
> > > Do I need to resubmit?
> >
> > Yes, please.
> >
> > Andy, I think it's better to merge the series through my tree, as it
> > uses the new leds audio trigger stuff.
> >
> > Could you give ACK if the revised one is OK?
>
> For addressed comments
> Acked-by: Andy Shevchenko 

And for the entire series

Reviewed-by: Andy Shevchenko 

>
> >
> > Then I'll merge them to the immutable branch topic/leds-trigger, so
> > that you can merge to your tree cleanly, too.
> >
> >
> > thanks,
> >
> > Takashi
>
>
>
> --
> With Best Regards,
> Andy Shevchenko



-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v10 2/3] x86: add support for Huawei WMI hotkeys.

2018-12-12 Thread Andy Shevchenko
On Wed, Dec 12, 2018 at 8:56 AM Takashi Iwai  wrote:
>
> On Tue, 11 Dec 2018 21:10:07 +0100,
>  wrote:
> >
> >
> > Do I need to resubmit?
>
> Yes, please.
>
> Andy, I think it's better to merge the series through my tree, as it
> uses the new leds audio trigger stuff.
>
> Could you give ACK if the revised one is OK?

For addressed comments
Acked-by: Andy Shevchenko 

>
> Then I'll merge them to the immutable branch topic/leds-trigger, so
> that you can merge to your tree cleanly, too.
>
>
> thanks,
>
> Takashi



-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH v10 2/3] x86: add support for Huawei WMI hotkeys.

2018-12-11 Thread Takashi Iwai
On Tue, 11 Dec 2018 21:10:07 +0100,
 wrote:
> 
> 
> Do I need to resubmit?

Yes, please.

Andy, I think it's better to merge the series through my tree, as it
uses the new leds audio trigger stuff.

Could you give ACK if the revised one is OK?

Then I'll merge them to the immutable branch topic/leds-trigger, so
that you can merge to your tree cleanly, too.


thanks,

Takashi


Re: [PATCH v10 2/3] x86: add support for Huawei WMI hotkeys.

2018-12-11 Thread ayman . bagabas
On Tue, 2018-12-11 at 12:14 +0200, Andy Shevchenko wrote:
> On Tue, Dec 11, 2018 at 8:02 AM Ayman Bagabas <
> ayman.baga...@gmail.com> wrote:
> > This driver adds support for missing hotkeys on some Huawei
> > laptops.
> > Laptops such as the Matebook X have non functioning hotkeys.
> > Whereas
> > newer laptops such as the Matebook X Pro come with working hotkeys
> > out
> > of the box.
> > 
> > Old laptops, such as the Matebook X, report hotkey events through
> > ACPI
> > device "\WMI0". However, new laptops, such as the Matebook X Pro,
> > does not have this WMI device.
> > 
> > All the hotkeys on the Matebook X Pro work fine
> > without this patch except (micmute, wlan, and huawei key). These
> > keys
> > and the brightness keys report events to "\AMW0" ACPI device. One
> > problem is that brightness keys on the Matebook X Pro work without
> > this
> > patch. This results in reporting two brightness key press
> > events one is captured by ACPI and another by this driver.
> > 
> > A solution would be to check if such event came from the "\AMW0"
> > WMI driver
> > then skip reporting event. Another solution would be to leave this
> > to
> > user-space to handle. Which can be achieved by using "hwdb" tables
> > and
> > remap those keys to "unknown". This solution seems more natural to
> > me
> > because it leaves the decision to user-space.
> > 
> > Reviewed-by: Takashi Iwai 
> > Signed-off-by: Ayman Bagabas 
> > ---
> >  drivers/platform/x86/Kconfig  |  17 +++
> >  drivers/platform/x86/Makefile |   1 +
> >  drivers/platform/x86/huawei-wmi.c | 220
> > ++
> >  3 files changed, 238 insertions(+)
> >  create mode 100644 drivers/platform/x86/huawei-wmi.c
> > 
> > diff --git a/drivers/platform/x86/Kconfig
> > b/drivers/platform/x86/Kconfig
> > index 87f70e8f4dd0..45ef4d22f14c 100644
> > --- a/drivers/platform/x86/Kconfig
> > +++ b/drivers/platform/x86/Kconfig
> > @@ -1292,6 +1292,23 @@ config INTEL_ATOMISP2_PM
> >   To compile this driver as a module, choose M here: the
> > module
> >   will be called intel_atomisp2_pm.
> > 
> > +config HUAWEI_WMI
> > +   tristate "Huawei WMI hotkeys driver"
> > +   depends on ACPI_WMI
> > +   depends on INPUT
> > +   select INPUT_SPARSEKMAP
> > +   select LEDS_CLASS
> > +   select LEDS_TRIGGERS
> > +   select LEDS_TRIGGER_AUDIO
> > +   select NEW_LEDS
> > +   help
> > + This driver provides support for Huawei WMI hotkeys.
> > + It enables the missing keys and adds support to the
> > micmute
> > + LED found on some of these laptops.
> > +
> > + To compile this driver as a module, choose M here: the
> > module
> > + will be called huawei-wmi.
> > +
> >  endif # X86_PLATFORM_DEVICES
> > 
> >  config PMC_ATOM
> > diff --git a/drivers/platform/x86/Makefile
> > b/drivers/platform/x86/Makefile
> > index 39ae94135406..d841c550e3cc 100644
> > --- a/drivers/platform/x86/Makefile
> > +++ b/drivers/platform/x86/Makefile
> > @@ -32,6 +32,7 @@ obj-$(CONFIG_ACERHDF) += acerhdf.o
> >  obj-$(CONFIG_HP_ACCEL) += hp_accel.o
> >  obj-$(CONFIG_HP_WIRELESS)  += hp-wireless.o
> >  obj-$(CONFIG_HP_WMI)   += hp-wmi.o
> > +obj-$(CONFIG_HUAWEI_WMI)   += huawei-wmi.o
> >  obj-$(CONFIG_AMILO_RFKILL) += amilo-rfkill.o
> >  obj-$(CONFIG_GPD_POCKET_FAN)   += gpd-pocket-fan.o
> >  obj-$(CONFIG_TC1100_WMI)   += tc1100-wmi.o
> > diff --git a/drivers/platform/x86/huawei-wmi.c
> > b/drivers/platform/x86/huawei-wmi.c
> > new file mode 100644
> > index ..89ba7ea33499
> > --- /dev/null
> > +++ b/drivers/platform/x86/huawei-wmi.c
> > @@ -0,0 +1,220 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + *  Huawei WMI hotkeys
> > + *
> > + *  Copyright (C) 2018   Ayman Bagabas <
> > ayman.baga...@gmail.com>
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +/*
> > + * Huawei WMI GUIDs
> > + */
> > +#define WMI0_EVENT_GUID "59142400-C6A3-40fa-BADB-8A2652834100"
> > +#define AMW0_EVENT_GUID "ABBC0F5C-8EA1-11D1-A000-C9062910"
> > +
> > +#define WMI0_EXPENSIVE_GUID "39142400-C6A3-40fa-BADB-8A2652834100"
> > +
> > +struct huawei_wmi_priv {
> > +   struct input_dev *idev;
> > +   struct led_classdev cdev;
> > +   acpi_handle handle;
> > +   char *acpi_method;
> > +};
> > +
> > +static const struct key_entry huawei_wmi_keymap[] = {
> > +   { KE_KEY,0x281, { KEY_BRIGHTNESSDOWN } },
> > +   { KE_KEY,0x282, { KEY_BRIGHTNESSUP } },
> > +   { KE_KEY,0x284, { KEY_MUTE } },
> > +   { KE_KEY,0x285, { KEY_VOLUMEDOWN } },
> > +   { KE_KEY,0x286, { KEY_VOLUMEUP } },
> > +   { KE_KEY,0x287, { KEY_MICMUTE } },
> > +   { KE_KEY,0x289, { KEY_WLAN } },
> > +   // Huawei |M| key
> > +   { KE_KEY,0x28a, { KEY_CONFIG } },
> > +   // Keyboard backlight
> > +   { KE_IGNORE, 0x293, { 

Re: [PATCH v10 2/3] x86: add support for Huawei WMI hotkeys.

2018-12-11 Thread Andy Shevchenko
On Tue, Dec 11, 2018 at 8:02 AM Ayman Bagabas  wrote:
>
> This driver adds support for missing hotkeys on some Huawei laptops.
> Laptops such as the Matebook X have non functioning hotkeys. Whereas
> newer laptops such as the Matebook X Pro come with working hotkeys out
> of the box.
>
> Old laptops, such as the Matebook X, report hotkey events through ACPI
> device "\WMI0". However, new laptops, such as the Matebook X Pro,
> does not have this WMI device.
>
> All the hotkeys on the Matebook X Pro work fine
> without this patch except (micmute, wlan, and huawei key). These keys
> and the brightness keys report events to "\AMW0" ACPI device. One
> problem is that brightness keys on the Matebook X Pro work without this
> patch. This results in reporting two brightness key press
> events one is captured by ACPI and another by this driver.
>
> A solution would be to check if such event came from the "\AMW0" WMI driver
> then skip reporting event. Another solution would be to leave this to
> user-space to handle. Which can be achieved by using "hwdb" tables and
> remap those keys to "unknown". This solution seems more natural to me
> because it leaves the decision to user-space.
>
> Reviewed-by: Takashi Iwai 
> Signed-off-by: Ayman Bagabas 
> ---
>  drivers/platform/x86/Kconfig  |  17 +++
>  drivers/platform/x86/Makefile |   1 +
>  drivers/platform/x86/huawei-wmi.c | 220 ++
>  3 files changed, 238 insertions(+)
>  create mode 100644 drivers/platform/x86/huawei-wmi.c
>
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index 87f70e8f4dd0..45ef4d22f14c 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -1292,6 +1292,23 @@ config INTEL_ATOMISP2_PM
>   To compile this driver as a module, choose M here: the module
>   will be called intel_atomisp2_pm.
>
> +config HUAWEI_WMI
> +   tristate "Huawei WMI hotkeys driver"
> +   depends on ACPI_WMI
> +   depends on INPUT
> +   select INPUT_SPARSEKMAP
> +   select LEDS_CLASS
> +   select LEDS_TRIGGERS
> +   select LEDS_TRIGGER_AUDIO
> +   select NEW_LEDS
> +   help
> + This driver provides support for Huawei WMI hotkeys.
> + It enables the missing keys and adds support to the micmute
> + LED found on some of these laptops.
> +
> + To compile this driver as a module, choose M here: the module
> + will be called huawei-wmi.
> +
>  endif # X86_PLATFORM_DEVICES
>
>  config PMC_ATOM
> diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
> index 39ae94135406..d841c550e3cc 100644
> --- a/drivers/platform/x86/Makefile
> +++ b/drivers/platform/x86/Makefile
> @@ -32,6 +32,7 @@ obj-$(CONFIG_ACERHDF) += acerhdf.o
>  obj-$(CONFIG_HP_ACCEL) += hp_accel.o
>  obj-$(CONFIG_HP_WIRELESS)  += hp-wireless.o
>  obj-$(CONFIG_HP_WMI)   += hp-wmi.o
> +obj-$(CONFIG_HUAWEI_WMI)   += huawei-wmi.o
>  obj-$(CONFIG_AMILO_RFKILL) += amilo-rfkill.o
>  obj-$(CONFIG_GPD_POCKET_FAN)   += gpd-pocket-fan.o
>  obj-$(CONFIG_TC1100_WMI)   += tc1100-wmi.o
> diff --git a/drivers/platform/x86/huawei-wmi.c 
> b/drivers/platform/x86/huawei-wmi.c
> new file mode 100644
> index ..89ba7ea33499
> --- /dev/null
> +++ b/drivers/platform/x86/huawei-wmi.c
> @@ -0,0 +1,220 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + *  Huawei WMI hotkeys
> + *
> + *  Copyright (C) 2018   Ayman Bagabas 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/*
> + * Huawei WMI GUIDs
> + */
> +#define WMI0_EVENT_GUID "59142400-C6A3-40fa-BADB-8A2652834100"
> +#define AMW0_EVENT_GUID "ABBC0F5C-8EA1-11D1-A000-C9062910"
> +
> +#define WMI0_EXPENSIVE_GUID "39142400-C6A3-40fa-BADB-8A2652834100"
> +
> +struct huawei_wmi_priv {
> +   struct input_dev *idev;
> +   struct led_classdev cdev;
> +   acpi_handle handle;
> +   char *acpi_method;
> +};
> +
> +static const struct key_entry huawei_wmi_keymap[] = {
> +   { KE_KEY,0x281, { KEY_BRIGHTNESSDOWN } },
> +   { KE_KEY,0x282, { KEY_BRIGHTNESSUP } },
> +   { KE_KEY,0x284, { KEY_MUTE } },
> +   { KE_KEY,0x285, { KEY_VOLUMEDOWN } },
> +   { KE_KEY,0x286, { KEY_VOLUMEUP } },
> +   { KE_KEY,0x287, { KEY_MICMUTE } },
> +   { KE_KEY,0x289, { KEY_WLAN } },
> +   // Huawei |M| key
> +   { KE_KEY,0x28a, { KEY_CONFIG } },
> +   // Keyboard backlight
> +   { KE_IGNORE, 0x293, { KEY_KBDILLUMTOGGLE } },
> +   { KE_IGNORE, 0x294, { KEY_KBDILLUMUP } },
> +   { KE_IGNORE, 0x295, { KEY_KBDILLUMUP } },
> +   { KE_END,0 }
> +};
> +
> +static int huawei_wmi_micmute_led_set(struct led_classdev *led_cdev,
> +   enum led_brightness brightness)
> +{
> +   struct huawei_wmi_priv *priv = dev_get_drvdata(led_cdev->dev->parent);
> +   acpi_status status;
> +   union acpi_object 

[PATCH v10 2/3] x86: add support for Huawei WMI hotkeys.

2018-12-10 Thread Ayman Bagabas
This driver adds support for missing hotkeys on some Huawei laptops.
Laptops such as the Matebook X have non functioning hotkeys. Whereas
newer laptops such as the Matebook X Pro come with working hotkeys out
of the box.

Old laptops, such as the Matebook X, report hotkey events through ACPI
device "\WMI0". However, new laptops, such as the Matebook X Pro,
does not have this WMI device.

All the hotkeys on the Matebook X Pro work fine
without this patch except (micmute, wlan, and huawei key). These keys
and the brightness keys report events to "\AMW0" ACPI device. One
problem is that brightness keys on the Matebook X Pro work without this
patch. This results in reporting two brightness key press
events one is captured by ACPI and another by this driver.

A solution would be to check if such event came from the "\AMW0" WMI driver
then skip reporting event. Another solution would be to leave this to
user-space to handle. Which can be achieved by using "hwdb" tables and
remap those keys to "unknown". This solution seems more natural to me
because it leaves the decision to user-space.

Reviewed-by: Takashi Iwai 
Signed-off-by: Ayman Bagabas 
---
 drivers/platform/x86/Kconfig  |  17 +++
 drivers/platform/x86/Makefile |   1 +
 drivers/platform/x86/huawei-wmi.c | 220 ++
 3 files changed, 238 insertions(+)
 create mode 100644 drivers/platform/x86/huawei-wmi.c

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 87f70e8f4dd0..45ef4d22f14c 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -1292,6 +1292,23 @@ config INTEL_ATOMISP2_PM
  To compile this driver as a module, choose M here: the module
  will be called intel_atomisp2_pm.
 
+config HUAWEI_WMI
+   tristate "Huawei WMI hotkeys driver"
+   depends on ACPI_WMI
+   depends on INPUT
+   select INPUT_SPARSEKMAP
+   select LEDS_CLASS
+   select LEDS_TRIGGERS
+   select LEDS_TRIGGER_AUDIO
+   select NEW_LEDS
+   help
+ This driver provides support for Huawei WMI hotkeys.
+ It enables the missing keys and adds support to the micmute
+ LED found on some of these laptops.
+
+ To compile this driver as a module, choose M here: the module
+ will be called huawei-wmi.
+
 endif # X86_PLATFORM_DEVICES
 
 config PMC_ATOM
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 39ae94135406..d841c550e3cc 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_ACERHDF) += acerhdf.o
 obj-$(CONFIG_HP_ACCEL) += hp_accel.o
 obj-$(CONFIG_HP_WIRELESS)  += hp-wireless.o
 obj-$(CONFIG_HP_WMI)   += hp-wmi.o
+obj-$(CONFIG_HUAWEI_WMI)   += huawei-wmi.o
 obj-$(CONFIG_AMILO_RFKILL) += amilo-rfkill.o
 obj-$(CONFIG_GPD_POCKET_FAN)   += gpd-pocket-fan.o
 obj-$(CONFIG_TC1100_WMI)   += tc1100-wmi.o
diff --git a/drivers/platform/x86/huawei-wmi.c 
b/drivers/platform/x86/huawei-wmi.c
new file mode 100644
index ..89ba7ea33499
--- /dev/null
+++ b/drivers/platform/x86/huawei-wmi.c
@@ -0,0 +1,220 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ *  Huawei WMI hotkeys
+ *
+ *  Copyright (C) 2018   Ayman Bagabas 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * Huawei WMI GUIDs
+ */
+#define WMI0_EVENT_GUID "59142400-C6A3-40fa-BADB-8A2652834100"
+#define AMW0_EVENT_GUID "ABBC0F5C-8EA1-11D1-A000-C9062910"
+
+#define WMI0_EXPENSIVE_GUID "39142400-C6A3-40fa-BADB-8A2652834100"
+
+struct huawei_wmi_priv {
+   struct input_dev *idev;
+   struct led_classdev cdev;
+   acpi_handle handle;
+   char *acpi_method;
+};
+
+static const struct key_entry huawei_wmi_keymap[] = {
+   { KE_KEY,0x281, { KEY_BRIGHTNESSDOWN } },
+   { KE_KEY,0x282, { KEY_BRIGHTNESSUP } },
+   { KE_KEY,0x284, { KEY_MUTE } },
+   { KE_KEY,0x285, { KEY_VOLUMEDOWN } },
+   { KE_KEY,0x286, { KEY_VOLUMEUP } },
+   { KE_KEY,0x287, { KEY_MICMUTE } },
+   { KE_KEY,0x289, { KEY_WLAN } },
+   // Huawei |M| key
+   { KE_KEY,0x28a, { KEY_CONFIG } },
+   // Keyboard backlight
+   { KE_IGNORE, 0x293, { KEY_KBDILLUMTOGGLE } },
+   { KE_IGNORE, 0x294, { KEY_KBDILLUMUP } },
+   { KE_IGNORE, 0x295, { KEY_KBDILLUMUP } },
+   { KE_END,0 }
+};
+
+static int huawei_wmi_micmute_led_set(struct led_classdev *led_cdev,
+   enum led_brightness brightness)
+{
+   struct huawei_wmi_priv *priv = dev_get_drvdata(led_cdev->dev->parent);
+   acpi_status status;
+   union acpi_object args[3];
+   struct acpi_object_list arg_list = {
+   .pointer = args,
+   .count = ARRAY_SIZE(args),
+   };
+
+   args[0].type = args[1].type = args[2].type = ACPI_TYPE_INTEGER;
+   args[1].integer.value = 0x04;
+
+   if (strcmp(priv->acpi_method, "SPIN") == 0) {