Skip to contentSkip to conversation

Huawei laptops

PATCH Superseded Ayman Bagabas 4 participants 10 messages Dec 3, 2018 – Dec 8, 2018 1 message not in the archive

Subsystems (2)

v9 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v9 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 v8:
* Explicitly use NULL in acpi_get_handle
* Drop __initconst from huawei_wmi_keymap

Changes from v7:
* Switch to wmi_driver
* Use devm to allocate and manage 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 | 226 ++++++++++++++++++++++++++++++
 sound/pci/hda/patch_realtek.c     |  22 +++
 4 files changed, 265 insertions(+)
 create mode 100644 drivers/platform/x86/huawei-wmi.c
Signature · 1 line
2.19.2
#1 lore raw

PATCH v9 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.2
#2 lore raw

PATCH v9 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 | 226 ++++++++++++++++++++++++++++++
 3 files changed, 243 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 +226 -0

226 lines not on this page · raw message

Signature · 1 line
2.19.2
Reviewed-by on v9 2/3
#3 lore raw

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

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

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

Quoted 10 lines
drivers/platform/x86/huawei-wmi.c new file +10 -0
+		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);

I guess you need to pass handle here? In the earlier version, you passed \\WMI0.WQ00, so it worked with NULL handle. But now it's no longer so...

Other than that, it looks OK to me.

But, you don't need to rush too much. Instead, better to test your own patches and make sure that they really work before submitting the final version.

thanks,

Takashi

#4 lore raw

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

Quoted 19 lines · Takashi Iwai
Quoted 16 lines · Ayman Bagabas
drivers/platform/x86/huawei-wmi.c new file +16 -0
+     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");
Quoted 8 lines

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

Quoted 4 lines
drivers/platform/x86/huawei-wmi.c new file +4 -0
+                     return;
+             }
+
+             status = acpi_evaluate_integer(NULL, "WQ00", &arg_list, &result);

I guess you need to pass handle here? In the earlier version, you passed \\WMI0.WQ00, so it worked with NULL handle. But now it's no longer so...

I think in this case we don't need to have a separate call to get handle and try to get integer directly. In either we will have an error case if method / namespace / etc is not found.

Quoted 6 lines

Other than that, it looks OK to me.

But, you don't need to rush too much. Instead, better to test your own patches and make sure that they really work before submitting the final version.

Yes, I will wait couple of days for v10 in hope it will be tested carefully.

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

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

Quoted 30 lines · Andy Shevchenko
Quoted 20 lines · Takashi Iwai
Quoted 18 lines · Ayman Bagabas
drivers/platform/x86/huawei-wmi.c new file +16 -0
+     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;

Quoted 8 lines
Quoted 4 lines
drivers/platform/x86/huawei-wmi.c new file +3 -0
+             }
+
+             status = acpi_evaluate_integer(NULL, "WQ00",

&arg_list, &result);

I guess you need to pass handle here? In the earlier version, you passed \\WMI0.WQ00, so it worked with NULL handle. But now it's no longer so...

Quoted 3 lines

I think in this case we don't need to have a separate call to get handle and try to get integer directly. In either we will have an error case if method / namespace / etc is not found.

Agree.

Quoted 3 lines
Quoted 3 lines

Other than that, it looks OK to me.

Thanks.

Quoted 8 lines
Quoted 5 lines

But, you don't need to rush too much. Instead, better to test your own patches and make sure that they really work before submitting the
final version.

Yes, I will wait couple of days for v10 in hope it will be tested carefully.

You're right, I will test it more and make sure everything work as expected.

Quoted 1 line

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

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

On Fri, 2018-12-07 at 00:52 -0500, [email protected] wrote:

Quoted 30 lines · Andy Shevchenko
Quoted 20 lines · Takashi Iwai
Quoted 18 lines · Ayman Bagabas
drivers/platform/x86/huawei-wmi.c new file +16 -0
+     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;

Quoted 8 lines
Quoted 4 lines
drivers/platform/x86/huawei-wmi.c new file +3 -0
+             }
+
+             status = acpi_evaluate_integer(NULL, "WQ00",

&arg_list, &result);

I guess you need to pass handle here? In the earlier version, you passed \\WMI0.WQ00, so it worked with NULL handle. But now it's no longer so...

Quoted 5 lines

I think in this case we don't need to have a separate call to get handle and try to get integer directly. In either we will have an error case if method / namespace / etc is not found.

I was digging further into the DSDT table of the laptop that has WQ00 method and it turned out that this method is a ACPI_WMI_EXPENSIVE. It has its own GUID of "39142400-C6A3-40fa-BADB-8A2652834100". I believe wmi_query_block, which is deprecated BTW, can be used to access this method instead of acpi_evaluate. However, I don't have a machine to test it on. Any ideas?

#8 lore raw

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

In reply to Ayman Bagabas
Quoted 35 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.

---
 drivers/platform/x86/Kconfig      |  16 +++
 drivers/platform/x86/Makefile     |   1 +
 drivers/platform/x86/huawei-wmi.c | 226 ++++++++++++++++++++++++++++++
 3 files changed, 243 insertions(+)
 create mode 100644 drivers/platform/x86/huawei-wmi.c
drivers/platform/x86/Kconfig +0 -0
index 87f70e8f4dd0..27db3ce7a1e1 100644

drivers/platform/x86/Kconfig config INTEL_ATOMISP2_PM · line 1300

Quoted 9 lines
drivers/platform/x86/Kconfig +6 -0
@@ -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

but LEDS_CLASS is only available if NEW_LEDS is set/enabled, so it either depends on LEDS_CLASS... or it needs to select NEW_LEDS, which is what other drivers in this Kconfig file do, even though our b.d. has said a few times that any one driver should not "select" => enable an entire subsystem, so they all should be "depends on NEW_LEDS" IMHO.

Quoted 13 lines
drivers/platform/x86/Kconfig +10 -0
+	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
Signature · 1 line
~Randy
#9 lore raw

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

Quoted 51 lines · Randy Dunlap
Quoted 50 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.

---
 drivers/platform/x86/Kconfig      |  16 +++
 drivers/platform/x86/Makefile     |   1 +
 drivers/platform/x86/huawei-wmi.c | 226
++++++++++++++++++++++++++++++
 3 files changed, 243 insertions(+)
 create mode 100644 drivers/platform/x86/huawei-wmi.c
drivers/platform/x86/Kconfig +0 -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.
 
Quoted 16 lines

drivers/platform/x86/Kconfig config INTEL_ATOMISP2_PM · line 1300

Quoted 6 lines
drivers/platform/x86/Kconfig +6 -0
+config HUAWEI_WMI
+	tristate "Huawei WMI hotkeys driver"
+	depends on ACPI_WMI
+	depends on INPUT
+	select INPUT_SPARSEKMAP
+	select LEDS_CLASS

but LEDS_CLASS is only available if NEW_LEDS is set/enabled, so it either
depends on LEDS_CLASS... or it needs to select NEW_LEDS, which is what other
drivers in this Kconfig file do, even though our b.d. has said a few times
that any one driver should not "select" => enable an entire subsystem,
so they all should be "depends on NEW_LEDS" IMHO.

Noted, I'll select NEW_LEDS just like other drivers in Kconfig.

Quoted 16 lines
Quoted 14 lines
drivers/platform/x86/Kconfig +10 -0
+	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
#10 lore raw

PATCH v9 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.2