Skip to contentSkip to conversation

Huawei laptops

PATCH Superseded Ayman Bagabas 3 participants 13 messages Nov 29, 2018 – Dec 3, 2018

Subsystems (2)

v8 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v8 cover Huawei laptops

This patch set is based on new audio LED triggers in branch topic/leds-trigger from
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git

Changes from v7:
* Switch to wmi_driver
* Use devm to allocate and register devices
* Skip registering LED subsystem if a ACPI controller method was not found

Changes from v6:
* Use audio LED triggers patch set
* Use KEY_CONFIG (XF86Tools) instead of KEY_PROG1.
In Windows, the key is used to launch Huawei PC manager. XF86Tools is used by default on most desktop environments i.e. Gnome.

Changes from v5:
* Review tags

Changes from v4:
* Consistency in file names
* How module would be enabled (Kconfig)
* Match license in SPDX and MODULE_LICENSE

Changes from v3:
* Code formatting

Changes from v2:
* Support for Huawei MBX
* Style and formatting issues

Ayman Bagabas (3):
ALSA: hda: fix front speakers on Huawei MBXP.
x86: add support for Huawei WMI hotkeys.
ALSA: hda: add support for Huawei WMI micmute LED

 drivers/platform/x86/Kconfig      |  16 ++
 drivers/platform/x86/Makefile     |   1 +
 drivers/platform/x86/huawei-wmi.c | 238 ++++++++++++++++++++++++++++++
 sound/pci/hda/patch_realtek.c     |  22 +++
 4 files changed, 277 insertions(+)
 create mode 100644 drivers/platform/x86/huawei-wmi.c
Signature · 1 line
2.19.1
#1 lore raw

PATCH v8 1/3 ALSA: hda: fix front speakers on Huawei MBXP.

This patch solves bug 200501 'Only 2 of 4 speakers playing sound.'
https://bugzilla.kernel.org/show_bug.cgi?id=200501
It enables the front speakers on Huawei Matebook X Pro laptops. These laptops come with Dolby Atmos sound system and these pins configuration enables the front speakers.

---
 sound/pci/hda/patch_realtek.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
sound/pci/hda/patch_realtek.c +18 -0
index 993d34c141c2..1326f32f4574 100644
@@ -5490,6 +5490,7 @@ enum {
 	ALC298_FIXUP_TPT470_DOCK,
 	ALC255_FIXUP_DUMMY_LINEOUT_VERB,
 	ALC255_FIXUP_DELL_HEADSET_MIC,
+	ALC256_FIXUP_HUAWEI_MBXP_PINS,
 	ALC295_FIXUP_HP_X360,
 	ALC221_FIXUP_HP_HEADSET_MIC,
 };
@@ -5761,6 +5762,22 @@ static const struct hda_fixup alc269_fixups[] = {
 		.chained = true,
 		.chain_id = ALC269_FIXUP_HEADSET_MIC
 	},
+	[ALC256_FIXUP_HUAWEI_MBXP_PINS] = {
+		.type = HDA_FIXUP_PINS,
+		.v.pins = (const struct hda_pintbl[]) {
+			{0x12, 0x90a60130},
+			{0x13, 0x40000000},
+			{0x14, 0x90170110},
+			{0x18, 0x411111f0},
+			{0x19, 0x04a11040},
+			{0x1a, 0x411111f0},
+			{0x1b, 0x90170112},
+			{0x1d, 0x40759a05},
+			{0x1e, 0x411111f0},
+			{0x21, 0x04211020},
+			{ }
+		}
+	},
 	[ALC269_FIXUP_ASUS_X101_FUNC] = {
 		.type = HDA_FIXUP_FUNC,
 		.v.func = alc269_fixup_x101_headset_mic,
@@ -6591,6 +6608,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
 	SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
 	SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
+	SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MBXP", ALC256_FIXUP_HUAWEI_MBXP_PINS),
 	SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
 
 #if 0
Signature · 1 line
2.19.1
#2 lore raw

PATCH v8 2/3 x86: add support for Huawei WMI hotkeys.

In reply to 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.

---
 drivers/platform/x86/Kconfig      |  16 ++
 drivers/platform/x86/Makefile     |   1 +
 drivers/platform/x86/huawei-wmi.c | 238 ++++++++++++++++++++++++++++++
 3 files changed, 255 insertions(+)
 create mode 100644 drivers/platform/x86/huawei-wmi.c
drivers/platform/x86/Kconfig +16 -0
index 87f70e8f4dd0..27db3ce7a1e1 100644
@@ -1292,6 +1292,22 @@ 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
+	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
drivers/platform/x86/Makefile +1 -0
index 39ae94135406..d841c550e3cc 100644
@@ -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
drivers/platform/x86/huawei-wmi.c new file +238 -0

238 lines not on this page · raw message

Signature · 1 line
2.19.1
#3 lore raw

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

Quoted 17 lines · 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.

Quoted 7 lines

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.

The new patch looks much better than the previous one, thanks for working on it.

Just a few comments:

drivers/platform/x86/huawei-wmi.c line 24

Quoted 4 lines
drivers/platform/x86/huawei-wmi.c new file +4 -0
+struct huawei_wmi_priv {
+	struct input_dev *idev;
+	struct led_classdev cdev;
+	acpi_handle handle;

Is this handle set in anywhere? I couldn't see it in your patch. If it's supposed to be NULL, passing NULL explicitly makes your intention clearer.

Quoted 13 lines
drivers/platform/x86/huawei-wmi.c new file +13 -0
+static int huawei_wmi_leds_setup(struct wmi_device *wdev)
+{
+	struct huawei_wmi_priv *priv = dev_get_drvdata(&wdev->dev);
+	acpi_status status;
+
+	// Skip registering LED subsystem if no ACPI method was found.
+	status = acpi_get_handle(priv->handle, "\\_SB.PCI0.LPCB.EC0", &priv->handle);
+	if (ACPI_FAILURE(status))
+		return 0;
+
+	if (acpi_has_method(priv->handle, "SPIN"))
+		priv->acpi_method = "SPIN";
+	else if (acpi_has_method(priv->handle, "WPIN"))

drivers/platform/x86/huawei-wmi.c line 95

Quoted 10 lines
drivers/platform/x86/huawei-wmi.c new file +10 -0
+		priv->acpi_method = "WPIN";
+	else
+		return 0;
+
+	priv->cdev.name = "platform::micmute";
+	priv->cdev.max_brightness = 1;
+	priv->cdev.brightness_set_blocking = huawei_wmi_micmute_led_set;
+	priv->cdev.default_trigger = "audio-micmute";
+	priv->cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
+	priv->cdev.dev = &wdev->dev;

What about suspend/resume?
When the driver is bound wit HD-audio, the HD-audio will restore the state at resume, so it would work. But, by providing the LED class device, it is supposed to work even without HD-audio, so it might make sense to pass LED_CORE_SUSPENDRESUME, too.

drivers/platform/x86/huawei-wmi.c line 221

Quoted 6 lines
drivers/platform/x86/huawei-wmi.c new file +6 -0
+static int __init huawei_wmi_init(void)
+{
+	if (!(wmi_has_guid(WMI0_EVENT_GUID) || wmi_has_guid(AMW0_EVENT_GUID))) {
+		pr_debug("Compatible WMI GUID not found\n");
+		return -ENODEV;
+	}

This is superfluous when you implement with wmi_driver. In theory, the supported GUID can be added dynamically via sysfs, too.

thanks,

Takashi

#4 lore raw

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

Quoted 11 lines · Takashi Iwai

drivers/platform/x86/huawei-wmi.c line 24

Quoted 4 lines · Ayman Bagabas
drivers/platform/x86/huawei-wmi.c new file +4 -0
+struct huawei_wmi_priv {
+     struct input_dev *idev;
+     struct led_classdev cdev;
+     acpi_handle handle;

Is this handle set in anywhere? I couldn't see it in your patch. If it's supposed to be NULL, passing NULL explicitly makes your intention clearer.

Isn't below an answer?

Quoted 4 lines
Quoted 4 lines
drivers/platform/x86/huawei-wmi.c new file +4 -0
+     // Skip registering LED subsystem if no ACPI method was found.
+     status = acpi_get_handle(priv->handle, "\\_SB.PCI0.LPCB.EC0", &priv->handle);
+     if (ACPI_FAILURE(status))
+             return 0;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

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

Quoted 10 lines · Andy Shevchenko
Quoted 8 lines · Takashi Iwai
Quoted 4 lines · Ayman Bagabas
drivers/platform/x86/huawei-wmi.c new file +4 -0
+struct huawei_wmi_priv {
+     struct input_dev *idev;
+     struct led_classdev cdev;
+     acpi_handle handle;
Quoted 8 lines
Quoted 3 lines

Is this handle set in anywhere? I couldn't see it in your patch. If it's supposed to be NULL, passing NULL explicitly makes your intention clearer.

Isn't below an answer?

Quoted 2 lines
Quoted 2 lines
drivers/platform/x86/huawei-wmi.c new file +2 -0
+     // Skip registering LED subsystem if no ACPI method was found.
+     status = acpi_get_handle(priv->handle, "\\_SB.PCI0.LPCB.EC0", &priv->handle);

Oh indeed, but why it passes priv->handle at the first argument...?

thanks,

Takashi

#6 lore raw

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

Quoted 16 lines · Takashi Iwai
Quoted 14 lines · Andy Shevchenko
Quoted 11 lines · Takashi Iwai

drivers/platform/x86/huawei-wmi.c line 24

Quoted 4 lines · Ayman Bagabas
drivers/platform/x86/huawei-wmi.c new file +4 -0
+struct huawei_wmi_priv {
+     struct input_dev *idev;
+     struct led_classdev cdev;
+     acpi_handle handle;

Is this handle set in anywhere? I couldn't see it in your patch. If it's supposed to be NULL, passing NULL explicitly makes your intention clearer.

Quoted 6 lines
Quoted 4 lines

Isn't below an answer?

Quoted 2 lines
Quoted 2 lines
drivers/platform/x86/huawei-wmi.c new file +2 -0
+     // Skip registering LED subsystem if no ACPI method was found.
+     status = acpi_get_handle(priv->handle, "\\_SB.PCI0.LPCB.EC0", &priv->handle);

Oh indeed, but why it passes priv->handle at the first argument...?

Yes, since it's an absolute, I guess NULL in this case will be OK.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw

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

In reply to Takashi Iwai
Quoted 75 lines · Takashi Iwai
Quoted 32 lines · 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.

Quoted 1 line

The new patch looks much better than the previous one, thanks for working on it.

Just a few comments:

drivers/platform/x86/huawei-wmi.c line 24

Quoted 4 lines
drivers/platform/x86/huawei-wmi.c new file +4 -0
+struct huawei_wmi_priv {
+	struct input_dev *idev;
+	struct led_classdev cdev;
+	acpi_handle handle;

Is this handle set in anywhere? I couldn't see it in your patch. If it's supposed to be NULL, passing NULL explicitly makes your intention clearer.

Quoted 24 lines
drivers/platform/x86/huawei-wmi.c new file +7 -0
+static int huawei_wmi_leds_setup(struct wmi_device *wdev)
+{
+	struct huawei_wmi_priv *priv = dev_get_drvdata(&wdev->dev);
+	acpi_status status;
+
+	// Skip registering LED subsystem if no ACPI method was found.
+	status = acpi_get_handle(priv->handle, "\\_SB.PCI0.LPCB.EC0",

&priv->handle);

drivers/platform/x86/huawei-wmi.c new file +13 -0
+	if (ACPI_FAILURE(status))
+		return 0;
+
+	if (acpi_has_method(priv->handle, "SPIN"))
+		priv->acpi_method = "SPIN";
+	else if (acpi_has_method(priv->handle, "WPIN"))
+		priv->acpi_method = "WPIN";
+	else
+		return 0;
+
+	priv->cdev.name = "platform::micmute";
+	priv->cdev.max_brightness = 1;
+	priv->cdev.brightness_set_blocking =

huawei_wmi_micmute_led_set;

drivers/platform/x86/huawei-wmi.c new file +2 -0
+	priv->cdev.default_trigger = "audio-micmute";
+	priv->cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
Quoted 8 lines

drivers/platform/x86/huawei-wmi.c line 95

Quoted 1 line
drivers/platform/x86/huawei-wmi.c new file +1 -0
+	priv->cdev.dev = &wdev->dev;

What about suspend/resume?
When the driver is bound wit HD-audio, the HD-audio will restore the state at resume, so it would work. But, by providing the LED class device, it is supposed to work even without HD-audio, so it might make
sense to pass LED_CORE_SUSPENDRESUME, too.

Besides that, is there anything needed for wmi_device suspend/resume?

Quoted 14 lines

drivers/platform/x86/huawei-wmi.c line 221

Quoted 9 lines
drivers/platform/x86/huawei-wmi.c new file +3 -0
+static int __init huawei_wmi_init(void)
+{
+	if (!(wmi_has_guid(WMI0_EVENT_GUID) ||

wmi_has_guid(AMW0_EVENT_GUID))) {

drivers/platform/x86/huawei-wmi.c new file +3 -0
+		pr_debug("Compatible WMI GUID not found\n");
+		return -ENODEV;
+	}

This is superfluous when you implement with wmi_driver. In theory, the supported GUID can be added dynamically via sysfs, too.

I left it that way so it doesn't insert the module if these GUIDs were not found. Should I drop that and use module_wmi_driver instead?

Quoted 4 lines

thanks,

Takashi

#8 lore raw

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

Quoted 16 lines · On Mon, 03 Dec 2018 16:46:01 +0100, [email protected] wrote:
Quoted 15 lines

drivers/platform/x86/huawei-wmi.c line 95

Quoted 8 lines
drivers/platform/x86/huawei-wmi.c new file +3 -0
+	priv->cdev.name = "platform::micmute";
+	priv->cdev.max_brightness = 1;
+	priv->cdev.brightness_set_blocking =

huawei_wmi_micmute_led_set;

drivers/platform/x86/huawei-wmi.c new file +3 -0
+	priv->cdev.default_trigger = "audio-micmute";
+	priv->cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
+	priv->cdev.dev = &wdev->dev;

What about suspend/resume?
When the driver is bound wit HD-audio, the HD-audio will restore the state at resume, so it would work. But, by providing the LED class device, it is supposed to work even without HD-audio, so it might make
sense to pass LED_CORE_SUSPENDRESUME, too.

Quoted 1 line

Besides that, is there anything needed for wmi_device suspend/resume?

AFAIK, the wmi_driver itself doesn't need anything. The input also doesn't need, so most likely only LED.

Quoted 13 lines
Quoted 12 lines

drivers/platform/x86/huawei-wmi.c line 221

Quoted 7 lines
drivers/platform/x86/huawei-wmi.c new file +3 -0
+static int __init huawei_wmi_init(void)
+{
+	if (!(wmi_has_guid(WMI0_EVENT_GUID) ||

wmi_has_guid(AMW0_EVENT_GUID))) {

drivers/platform/x86/huawei-wmi.c new file +3 -0
+		pr_debug("Compatible WMI GUID not found\n");
+		return -ENODEV;
+	}

This is superfluous when you implement with wmi_driver. In theory, the supported GUID can be added dynamically via sysfs, too.

Quoted 2 lines

I left it that way so it doesn't insert the module if these GUIDs were not found.

But they aren't loaded on such devices unless you do explicitly. If they are done explicitly, there must be a reason to do so, hence you don't need to block it :)

Quoted 1 line

Should I drop that and use module_wmi_driver instead?

Yes, that's cleaner. Let's try to make it as simple as possible at first.

thanks,

Takashi

#9 lore raw

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

In reply to Ayman Bagabas
Quoted 11 lines · Ayman Bagabas
drivers/platform/x86/huawei-wmi.c new file +11 -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),
+       };
+

drivers/platform/x86/huawei-wmi.c line 64

Quoted 10 lines
drivers/platform/x86/huawei-wmi.c new file +9 -0
+       args[0].type = args[1].type = args[2].type = ACPI_TYPE_INTEGER;
 
+       args[0].integer.value = 0;
+       args[1].integer.value = 0x04;
+       args[2].integer.value = brightness ? 1 : 0;
+
+       if (strcmp(priv->acpi_method, "WPIN") == 0) {
+               args[0].integer.value = 1;
+               args[2].integer.value = brightness ? 0 : 1;
+       }

I would rather still see explicit settings for the other method as well. Something like:

if (strcmp(...)) {
} else if (strcmp(...)) {
} else {
return -EINVAL;
}

Quoted 177 lines
drivers/platform/x86/huawei-wmi.c new file +174 -1
+
+       status = acpi_evaluate_object(priv->handle, priv->acpi_method, &arg_list, NULL);
+       if (ACPI_FAILURE(status))
+               return -ENXIO;
+
+       return 0;
+}
+
+static int huawei_wmi_leds_setup(struct wmi_device *wdev)
+{
+       struct huawei_wmi_priv *priv = dev_get_drvdata(&wdev->dev);
+       acpi_status status;
+
+       // Skip registering LED subsystem if no ACPI method was found.
+       status = acpi_get_handle(priv->handle, "\\_SB.PCI0.LPCB.EC0", &priv->handle);
+       if (ACPI_FAILURE(status))
+               return 0;
+
+       if (acpi_has_method(priv->handle, "SPIN"))
+               priv->acpi_method = "SPIN";
+       else if (acpi_has_method(priv->handle, "WPIN"))
+               priv->acpi_method = "WPIN";
+       else
+               return 0;
+
+       priv->cdev.name = "platform::micmute";
+       priv->cdev.max_brightness = 1;
+       priv->cdev.brightness_set_blocking = huawei_wmi_micmute_led_set;
+       priv->cdev.default_trigger = "audio-micmute";
+       priv->cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
+       priv->cdev.dev = &wdev->dev;
+
+       return devm_led_classdev_register(&wdev->dev, &priv->cdev);
+}
+
+static void huawei_wmi_process_key(struct wmi_device *wdev, int code)
+{
+       struct huawei_wmi_priv *priv = dev_get_drvdata(&wdev->dev);
+       const struct key_entry *key;
+
+       /*
+        * WMI0 uses code 0x80 to indicate a hotkey event.
+        * The actual key is fetched from the method WQ00.
+        */
+       if (code == 0x80) {
+               acpi_status status;
+               acpi_handle handle;
+               unsigned long long result;
+               union acpi_object args[1];
+               struct acpi_object_list arg_list = {
+                       .pointer = args,
+                       .count = ARRAY_SIZE(args),
+               };
+
+               args[0].type = ACPI_TYPE_INTEGER;
+               args[0].integer.value = 0;
+
+               status = acpi_get_handle(NULL, "\\WMI0", &handle);
+               if (ACPI_FAILURE(status)) {
+                       dev_err(&wdev->dev, "Unable to get ACPI handle\n");
+                       return;
+               }
+
+               status = acpi_evaluate_integer(NULL, "WQ00", &arg_list, &result);
+               if (ACPI_FAILURE(status)) {
+                       dev_err(&wdev->dev, "Unable to evaluate ACPI method\n");
+                       return;
+               }
+
+               code = result;
+       }
+
+       key = sparse_keymap_entry_from_scancode(priv->idev, code);
+       if (!key) {
+               dev_info(&wdev->dev, "Unknown key pressed, code: 0x%04x\n", code);
+               return;
+       }
+
+       sparse_keymap_report_entry(priv->idev, key, 1, true);
+}
+
+static void huawei_wmi_notify(struct wmi_device *wdev,
+               union acpi_object *obj)
+{
+       if (obj->type == ACPI_TYPE_INTEGER)
+               huawei_wmi_process_key(wdev, obj->integer.value);
+       else
+               dev_info(&wdev->dev, "Bad response type %d\n", obj->type);
+}
+
+static int huawei_wmi_input_setup(struct wmi_device *wdev)
+{
+       struct huawei_wmi_priv *priv = dev_get_drvdata(&wdev->dev);
+       int err;
+
+       priv->idev = devm_input_allocate_device(&wdev->dev);
+       if (!priv->idev)
+               return -ENOMEM;
+
+       priv->idev->name = "Huawei WMI hotkeys";
+       priv->idev->phys = "wmi/input0";
+       priv->idev->id.bustype = BUS_HOST;
+       priv->idev->dev.parent = &wdev->dev;
+
+       err = sparse_keymap_setup(priv->idev, huawei_wmi_keymap, NULL);
+       if (err)
+               return err;
+
+       err = input_register_device(priv->idev);
+       if (err)
+               return err;
+
+       return 0;
+}
+
+static int huawei_wmi_probe(struct wmi_device *wdev)
+{
+       struct huawei_wmi_priv *priv;
+       int err;
+
+       priv = devm_kzalloc(&wdev->dev, sizeof(struct huawei_wmi_priv), GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+       dev_set_drvdata(&wdev->dev, priv);
+
+       err = huawei_wmi_input_setup(wdev);
+       if (err)
+               return err;
+
+       err = huawei_wmi_leds_setup(wdev);
+       if (err)
+               return err;
+
+       return 0;
+}
+
+static const struct wmi_device_id huawei_wmi_id_table[] = {
+       { .guid_string = WMI0_EVENT_GUID },
+       { .guid_string = AMW0_EVENT_GUID },
+       {  }
+};
+
+static struct wmi_driver huawei_wmi_driver = {
+       .driver = {
+               .name = "huawei-wmi",
+       },
+       .id_table = huawei_wmi_id_table,
+       .probe = huawei_wmi_probe,
+       .notify = huawei_wmi_notify,
+};
+
+static int __init huawei_wmi_init(void)
+{
+       if (!(wmi_has_guid(WMI0_EVENT_GUID) || wmi_has_guid(AMW0_EVENT_GUID))) {
+               pr_debug("Compatible WMI GUID not found\n");
+               return -ENODEV;
+       }
+
+       return wmi_driver_register(&huawei_wmi_driver);
+}
+
+static void __exit huawei_wmi_exit(void)
+{
+       wmi_driver_unregister(&huawei_wmi_driver);
+}
+
+module_init(huawei_wmi_init);
+module_exit(huawei_wmi_exit);
+
+MODULE_ALIAS("wmi:"WMI0_EVENT_GUID);
+MODULE_ALIAS("wmi:"AMW0_EVENT_GUID);
+MODULE_AUTHOR("Ayman Bagabas <[email protected]>");
+MODULE_DESCRIPTION("Huawei WMI hotkeys");
+MODULE_LICENSE("GPL v2");
--

2.19.1

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#10 lore raw

PATCH v8 3/3 ALSA: hda: add support for Huawei WMI micmute LED

In reply to Ayman Bagabas

Some of Huawei laptops come with a LED in the micmute key. This patch enables the use of micmute LED for these devices:
1. Matebook X (19e5:3200), (19e5:3201)
2. Matebook X Pro (19e5:3204)

---
 sound/pci/hda/patch_realtek.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
sound/pci/hda/patch_realtek.c +5 -1
index 1326f32f4574..9766fd249bdf 100644
@@ -5776,7 +5776,9 @@ static const struct hda_fixup alc269_fixups[] = {
 			{0x1e, 0x411111f0},
 			{0x21, 0x04211020},
 			{ }
-		}
+		},
+		.chained = true,
+		.chain_id = ALC255_FIXUP_MIC_MUTE_LED
 	},
 	[ALC269_FIXUP_ASUS_X101_FUNC] = {
 		.type = HDA_FIXUP_FUNC,
@@ -6608,6 +6610,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
 	SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
 	SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
+	SND_PCI_QUIRK(0x19e5, 0x3200, "Huawei MBX", ALC255_FIXUP_MIC_MUTE_LED),
+	SND_PCI_QUIRK(0x19e5, 0x3201, "Huawei MBX", ALC255_FIXUP_MIC_MUTE_LED),
 	SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MBXP", ALC256_FIXUP_HUAWEI_MBXP_PINS),
 	SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
 
Signature · 1 line
2.19.1
Reviewed-by on v8 3/3
#11 lore raw

Re: [PATCH v8 3/3] ALSA: hda: add support for Huawei WMI micmute LED

Quoted 7 lines · Ayman Bagabas

Some of Huawei laptops come with a LED in the micmute key. This patch enables the use of micmute LED for these devices:
1. Matebook X (19e5:3200), (19e5:3201)
2. Matebook X Pro (19e5:3204)

Feel free to take my ack

thanks,

Takashi

#12 lore raw

Re: [PATCH v8 3/3] ALSA: hda: add support for Huawei WMI micmute LED

Quoted 8 lines · Takashi Iwai
Quoted 6 lines · Ayman Bagabas

Some of Huawei laptops come with a LED in the micmute key. This patch
enables the use of micmute LED for these devices:
1. Matebook X (19e5:3200), (19e5:3201)
2. Matebook X Pro (19e5:3204)

Quoted 4 lines
Quoted 1 line

Feel free to take my ack

Thanks, i'll include that in next submission.

Quoted 5 lines

thanks,

Takashi