Huawei laptops WMI & sound fixes
Subsystems (2)
v2 cover Huawei laptops WMI & sound fixes
This patch set fixes some of the issues with Huawei laptops.
[PATCH v2 1/3]
The first patch adds support for missing hotkeys on some models. Some hotkeys, like brightness keys, work out of the box on these models.
[PATCH v2 2/3]
This one enables the front speakers on the Huawei Matebook X Pro (MBXP). This solves bug 200501 https://bugzilla.kernel.org/show_bug.cgi?id=200501
It simply uses the pins configurations generated by hdajackretast using the settings posted on the bug page https://imgur.com/a/N1xsCVZ
[PATCH v2 3/3]
This enables the micmute LED on Huawei laptops. It calls an WMI method, using PATCH #1, to turn the micmute LED on/off.
Ayman Bagabas (3):
x86: add support for Huawei WMI hotkeys.
ALSA: hda: fix front speakers on Huawei MBXP.
ALSA: hda: add support for Huawei WMI MicMute LED
drivers/platform/x86/Kconfig | 13 ++ drivers/platform/x86/Makefile | 1 + drivers/platform/x86/huawei_wmi.c | 224 ++++++++++++++++++++++++++++++ include/linux/huawei_wmi.h | 7 + sound/pci/hda/huawei_wmi_helper.c | 48 +++++++ sound/pci/hda/patch_realtek.c | 28 ++++ 6 files changed, 321 insertions(+) create mode 100644 drivers/platform/x86/huawei_wmi.c create mode 100644 include/linux/huawei_wmi.h create mode 100644 sound/pci/hda/huawei_wmi_helper.c
Signature · 1 line
2.17.2
PATCH v2 1/3 x86: add support for Huawei WMI hotkeys.
This driver adds support for missing hotkeys on some Huawei laptops. Currently, only Huawei Matebook X Pro is supported. The driver recognizes the following keys: brightness keys, micmute, wlan, and Huawei special key. The brightness keys are ignored since they work out of the box.
--- drivers/platform/x86/Kconfig | 13 ++ drivers/platform/x86/Makefile | 1 + drivers/platform/x86/huawei_wmi.c | 223 ++++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+) create mode 100644 drivers/platform/x86/huawei_wmi.c
drivers/platform/x86/Kconfig +13 -0
@@ -1229,6 +1229,19 @@ config I2C_MULTI_INSTANTIATE To compile this driver as a module, choose M here: the module will be called i2c-multi-instantiate. +config HUAWEI_LAPTOP + tristate "Huawei WMI hotkeys driver" + depends on ACPI + depends on ACPI_WMI + depends on INPUT + select INPUT_SPARSEKMAP + help + This driver provides support for Huawei WMI hotkeys. + It enables the missing keys and adds support to micmute + led found on these laptops.q + Supported devices are: + - Matebook X Pro + endif # X86_PLATFORM_DEVICES config PMC_ATOM
drivers/platform/x86/Makefile +1 -0
@@ -29,6 +29,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_LAPTOP) += 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 +223 -0
223 lines not on this page · raw message
Signature · 1 line
2.17.2
Re: [PATCH v2 1/3] x86: add support for Huawei WMI hotkeys.
Quoted 36 lines · Ayman Bagabas
This driver adds support for missing hotkeys on some Huawei laptops. Currently, only Huawei Matebook X Pro is supported. The driver recognizes the following keys: brightness keys, micmute, wlan, and Huawei special key. The brightness keys are ignored since they work out of the box.
(quoted diff) +24
-0+config HUAWEI_LAPTOP + tristate "Huawei WMI hotkeys driver" + depends on ACPI + depends on ACPI_WMI + depends on INPUT + select INPUT_SPARSEKMAP + help + This driver provides support for Huawei WMI hotkeys. + It enables the missing keys and adds support to micmute + led found on these laptops.q + Supported devices are: + - Matebook X Pro +// SPDX-License-Identifier: GPL-2.0 +/* + * Huawei WMI Hotkeys Driver + * + * Copyright (C) 2018 Ayman Bagabas <[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,
Review
Quoted 10 lines
(quoted diff) +9
-0+ * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ +MODULE_LICENSE("GPL");
Here you have the following issues:
- inconsistency between IDs for license (fix accordingly)
- SDPX _and_ License header (remove latter)
drivers/platform/x86/huawei_wmi.c line 24
Quoted 4 lines
drivers/platform/x86/huawei_wmi.c new file +3
-0+#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h>
Choose one of them.
drivers/platform/x86/huawei_wmi.c line 28
Quoted 4 lines
drivers/platform/x86/huawei_wmi.c new file +4
-0+#include <linux/input.h> +#include <linux/input/sparse-keymap.h> +#include <linux/acpi.h> +#include <linux/wmi.h>
Please, keep in order.
Quoted 4 lines
drivers/platform/x86/huawei_wmi.c new file +4
-0+static const struct key_entry huawei_wmi_keymap[]__initconst = { + {KE_IGNORE ,0x281 , {KEY_BRIGHTNESSDOWN } }, + {KE_IGNORE ,0x282 , {KEY_BRIGHTNESSUP } }, + {KE_KEY ,0x287 , {KEY_MICMUTE } },
drivers/platform/x86/huawei_wmi.c line 67
Quoted 10 lines
drivers/platform/x86/huawei_wmi.c new file +9
-0+ { KE_KEY, 0x289, { KEY_WLAN } }, +// Huawei |M| button + { KE_KEY, 0x28a, { KEY_PROG1 } }, + { KE_END, 0 } +}; + +struct huawei_wmi_device { +struct input_dev *inputdev; +};
Apparently no need to have this, you may use struct input_dev directly, isn't it?
Quoted 1 line
+static struct
huawei_wmi_device*wmi_device;
No global variables, please.
drivers/platform/x86/huawei_wmi.c line 72
Quoted 3 lines
drivers/platform/x86/huawei_wmi.c new file +3
-0+int huawei_wmi_micmute_led_set (bool on) +{ +u32 args = (on) ?MICMUTE_LED_ON :MICMUTE_LED_OFF ;
Redundant parens.
Quoted 7 lines
drivers/platform/x86/huawei_wmi.c new file +7
-0+struct acpi_buffer input = { (acpi_size )sizeof (args), &args }; +acpi_status status; + + status =wmi_evaluate_method (AMW0_GUID ,0 ,1 , &input,NULL ); +if (ACPI_FAILURE (status)) +return status; +
drivers/platform/x86/huawei_wmi.c line 89
Quoted 10 lines
drivers/platform/x86/huawei_wmi.c new file +8
-0+return 0 ; +} +static void huawei_wmi_process_key (struct input_dev *input_dev,int code) +{ +const struct key_entry *key; + + key =sparse_keymap_entry_from_scancode (input_dev, code); +
This blank line is redundant.
drivers/platform/x86/huawei_wmi.c line 92
Quoted 3 lines
drivers/platform/x86/huawei_wmi.c new file +3
-0+if (!key) { +pr_info ("%s: Unknown key pressed, code: 0x%04x\n" , +MODULE_NAME , code);
dev_info(); no MODULE_NAME, please.
Quoted 7 lines
drivers/platform/x86/huawei_wmi.c new file +6
-0+return ; + } + +sparse_keymap_report_entry (input_dev, key,1 , true); +} +static void huawei_wmi_notify (u32 value,void *context)
drivers/platform/x86/huawei_wmi.c line 108
Quoted 10 lines
drivers/platform/x86/huawei_wmi.c new file +9
-0+{ +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 ("%s: Bad event status 0x%x\n" , +MODULE_NAME , status);
No MODULE_NAME, please.
If needed, use pr_fmt() macro.
But I'm pretty sure you may pass pointer to input device and use dev_err().
drivers/platform/x86/huawei_wmi.c line 113
Quoted 6 lines
drivers/platform/x86/huawei_wmi.c new file +5
-0+return ; + } + + obj = (union acpi_object *)response.pointer; +
No redundant blank lines, please.
drivers/platform/x86/huawei_wmi.c line 122
Quoted 10 lines
drivers/platform/x86/huawei_wmi.c new file +9
-0+if (!obj) +return ; + +if (obj->type ==ACPI_TYPE_INTEGER ) +huawei_wmi_process_key (wmi_device->inputdev, + obj->integer.value); +else +pr_info ("%s: Unknown response received %d\n" , +MODULE_NAME , obj->type);
Ditto about module name.
drivers/platform/x86/huawei_wmi.c line 147
Quoted 13 lines
drivers/platform/x86/huawei_wmi.c new file +11
-0+ +kfree (response.pointer); +} + +static int huawei_input_init (void ) +{ +acpi_status status; +int err; + status =wmi_install_notify_handler (EVENT_GUID , + huawei_wmi_notify, +NULL );
Pointer to the input device instead of NULL.
Quoted 1 line
+
No redundant blank lines, please.
drivers/platform/x86/huawei_wmi.c line 178
Quoted 9 lines
drivers/platform/x86/huawei_wmi.c new file +6
-0+if (ACPI_FAILURE (status)) { + err = -EIO ; + goto err_free_dev; + } +} + wmi_device =kmalloc (sizeof (struct huawei_wmi_device ),GFP_KERNEL );
sizeof(*wmi_device)
drivers/platform/x86/huawei_wmi.c line 219
Quoted 7 lines
drivers/platform/x86/huawei_wmi.c new file +4
-0+if (!wmi_device) +return -ENOMEM ; +} +pr_debug ("%s: Driver unloaded successfully\n" ,MODULE_NAME );
Noise.
--
With Best Regards,
Andy Shevchenko
Re: [PATCH v2 1/3] x86: add support for Huawei WMI hotkeys.
Quoted 67 lines · Andy Shevchenko
On Fri, Nov 2, 2018 at 6:11 AM Ayman Bagabas <[email protected]
Quoted 45 lines
wrote:
This driver adds support for missing hotkeys on some Huawei laptops.
Currently, only Huawei Matebook X Pro is supported. The driver recognizes the following keys: brightness keys, micmute, wlan, and Huawei special key. The brightness keys are ignored since they work out
of the box.(quoted diff) +17
-0+config HUAWEI_LAPTOP + tristate "Huawei WMI hotkeys driver" + depends on ACPI + depends on ACPI_WMI + depends on INPUT + select INPUT_SPARSEKMAP + help + This driver provides support for Huawei WMI hotkeys. + It enables the missing keys and adds support to micmute + led found on these laptops.q + Supported devices are: + - Matebook X Pro +// SPDX-License-Identifier: GPL-2.0 +/* + * Huawei WMI Hotkeys Driver + * + * Copyright (C) 2018 Ayman Bagabas <[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.Quoted 8 lines
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <
https://www.gnu.org/licenses/>.
+ *
+ */
+MODULE_LICENSE("GPL");Here you have the following issues:
- inconsistency between IDs for license (fix accordingly)
- SDPX _and_ License header (remove latter)drivers/platform/x86/huawei_wmi.c line 24
Quoted 3 lines
drivers/platform/x86/huawei_wmi.c new file +3
-0+#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> Choose one of them.
Quoted 6 lines
drivers/platform/x86/huawei_wmi.c line 28
Quoted 4 lines
drivers/platform/x86/huawei_wmi.c new file +4
-0+#include <linux/input.h> +#include <linux/input/sparse-keymap.h> +#include <linux/acpi.h> +#include <linux/wmi.h> Please, keep in order.
What order do I have to follow? Does this look right? module.hinit.hapci.hwmi.hinput.hsparse-keymap.h
Quoted 18 lines
Quoted 4 lines
drivers/platform/x86/huawei_wmi.c new file +3
-0+static const struct key_entry huawei_wmi_keymap[]__initconst = { + {KE_IGNORE ,0x281 , {KEY_BRIGHTNESSDOWN } }, + {KE_IGNORE ,0x282 , {KEY_BRIGHTNESSUP } },drivers/platform/x86/huawei_wmi.c line 67
Quoted 10 lines
drivers/platform/x86/huawei_wmi.c new file +10
-0+ { KE_KEY, 0x287, { KEY_MICMUTE } }, + { KE_KEY, 0x289, { KEY_WLAN } }, +// Huawei |M| button + { KE_KEY, 0x28a, { KEY_PROG1 } }, + { KE_END, 0 } +}; + +struct huawei_wmi_device { +struct input_dev *inputdev; +};Apparently no need to have this, you may use struct
input_devdirectly, isn't it?
Quoted 3 lines
Quoted 1 line
+static struct
huawei_wmi_device*wmi_device;No global variables, please.
What about input_dev as a global variable? How would input_unregister_device access input_dev on exit if it wasn't global?
Quoted 121 lines
drivers/platform/x86/huawei_wmi.c line 72
Quoted 4 lines
drivers/platform/x86/huawei_wmi.c new file +3
-0+int huawei_wmi_micmute_led_set (bool on) +{ +u32 args = (on) ?MICMUTE_LED_ON :MICMUTE_LED_OFF ;Redundant parens.
Quoted 13 lines
+ struct
acpi_bufferinput = { (acpi_size)sizeof(args), &args
};drivers/platform/x86/huawei_wmi.c new file +3
-0+acpi_status status; + + status = wmi_evaluate_method(AMW0_GUID, 0, 1, &input,NULL);
drivers/platform/x86/huawei_wmi.c new file +6
-0+if (ACPI_FAILURE (status)) +return status; + +return 0 ; +} +static void huawei_wmi_process_key(struct input_dev *input_dev,int code)
drivers/platform/x86/huawei_wmi.c line 89
Quoted 5 lines
drivers/platform/x86/huawei_wmi.c new file +5
-0+{ +const struct key_entry *key; + + key =sparse_keymap_entry_from_scancode (input_dev, code); +This blank line is redundant.
drivers/platform/x86/huawei_wmi.c line 92
Quoted 3 lines
drivers/platform/x86/huawei_wmi.c new file +3
-0+if (!key) { +pr_info ("%s: Unknown key pressed, code: 0x%04x\n" , +MODULE_NAME , code);
dev_info(); noMODULE_NAME, please.Quoted 9 lines
drivers/platform/x86/huawei_wmi.c new file +8
-0+return ; + } + +sparse_keymap_report_entry (input_dev, key,1 , true); +} +static void huawei_wmi_notify (u32 value,void *context) +{ +struct acpi_buffer response = {ACPI_ALLOCATE_BUFFER ,NULL };
drivers/platform/x86/huawei_wmi.c line 108
Quoted 7 lines
drivers/platform/x86/huawei_wmi.c new file +7
-0+union acpi_object *obj; +acpi_status status; + + status =wmi_get_event_data (value, &response); +if (ACPI_FAILURE (status)) { +pr_err ("%s: Bad event status 0x%x\n" , +MODULE_NAME , status);No
MODULE_NAME, please.
If needed, usepr_fmt()macro.But I'm pretty sure you may pass pointer to input device and use
dev_err().drivers/platform/x86/huawei_wmi.c line 113
Quoted 5 lines
drivers/platform/x86/huawei_wmi.c new file +5
-0+return ; + } + + obj = (union acpi_object *)response.pointer; +No redundant blank lines, please.
drivers/platform/x86/huawei_wmi.c line 122
Quoted 10 lines
drivers/platform/x86/huawei_wmi.c new file +6
-0+if (!obj) +return ; + +if (obj->type ==ACPI_TYPE_INTEGER ) + huawei_wmi_process_key(wmi_device->inputdev, + obj-Quoted 1 line
integer.value);
drivers/platform/x86/huawei_wmi.c new file +3
-0+else +pr_info ("%s: Unknown response received %d\n" , +MODULE_NAME , obj->type);Ditto about module name.
drivers/platform/x86/huawei_wmi.c line 147
Quoted 11 lines
drivers/platform/x86/huawei_wmi.c new file +11
-0+ +kfree (response.pointer); +} + +static int huawei_input_init (void ) +{ +acpi_status status; +int err; + status =wmi_install_notify_handler (EVENT_GUID , + huawei_wmi_notify, +NULL );Pointer to the input device instead of NULL.
Quoted 1 line
+
No redundant blank lines, please.
Quoted 9 lines
drivers/platform/x86/huawei_wmi.c new file +6
-0+if (ACPI_FAILURE (status)) { + err = -EIO ; + goto err_free_dev; + } +} + wmi_device = kmalloc(sizeof(struct huawei_wmi_device),
GFP_KERNEL);
sizeof(*wmi_device)Quoted 7 lines
drivers/platform/x86/huawei_wmi.c new file +4
-0+if (!wmi_device) +return -ENOMEM ; +} + pr_debug("%s: Driver unloaded successfully\n",
MODULE_NAME);Noise.
--
With Best Regards,
Andy Shevchenko
Re: [PATCH v2 1/3] x86: add support for Huawei WMI hotkeys.
Quoted 9 lines · On Sat, 03 Nov 2018 00:10:18 +0100, <[email protected]> wrote:
Quoted 6 lines · Andy Shevchenko
drivers/platform/x86/huawei_wmi.c line 28
Quoted 4 lines
drivers/platform/x86/huawei_wmi.c new file +4
-0+#include <linux/input.h> +#include <linux/input/sparse-keymap.h> +#include <linux/acpi.h> +#include <linux/wmi.h> Please, keep in order.
Quoted 7 lines
What order do I have to follow? Does this look right?
module.hinit.hapci.hwmi.hinput.hsparse-keymap.h
A most common pattern is the alphabetical order.
thanks,
Takashi
PATCH v2 2/3 ALSA: hda: fix front speakers on Huawei MBXP.
In reply to Ayman BagabasThis 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
@@ -5493,6 +5493,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, };
@@ -6347,6 +6348,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 }, + { }, + }, + }, [ALC295_FIXUP_HP_X360] = { .type = HDA_FIXUP_FUNC, .v.func = alc295_fixup_hp_top_speakers,
@@ -6592,6 +6609,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x5109 ,"Thinkpad" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x17aa ,0x511e ,"Thinkpad" ,ALC298_FIXUP_TPT470_DOCK ),SND_PCI_QUIRK (0x17aa ,0x511f ,"Thinkpad" ,ALC298_FIXUP_TPT470_DOCK ), +SND_PCI_QUIRK (0x19e5 ,0x3204 ,"Huawei MBXP" ,ALC256_FIXUP_HUAWEI_MBXP_PINS ),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(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
Signature · 1 line
2.17.2
Re: [PATCH v2 2/3] ALSA: hda: fix front speakers on Huawei MBXP.
Quoted 13 lines · Ayman Bagabas
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 +6
-0+ [ALC256_FIXUP_HUAWEI_MBXP_PINS] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl[]) { + {0x12, 0x90a60130}, + {0x13, 0x40000000}, + {0x14, 0x90170110},
sound/pci/hda/patch_realtek.c static const struct hda_fixup alc269_fixups[] = { · line 6364
Quoted 10 lines
sound/pci/hda/patch_realtek.c +8
-0+ {0x18, 0x411111f0}, + {0x19, 0x04a11040}, + {0x1a, 0x411111f0}, + {0x1b, 0x90170112}, + {0x1d, 0x40759a05}, + {0x1e, 0x411111f0}, + {0x21, 0x04211020}, + { },
Terminators better w/o comma.
Quoted 2 lines
sound/pci/hda/patch_realtek.c +2
-0+ }, + },
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 3/3 ALSA: hda: add support for Huawei WMI MicMute LED
In reply to Ayman BagabasSome of Huawei laptops come with a LED in the mic mute key. This patch enables and disable this LED accordingly.
--- drivers/platform/x86/huawei_wmi.c | 1 + include/linux/huawei_wmi.h | 7 +++++ sound/pci/hda/huawei_wmi_helper.c | 48 +++++++++++++++++++++++++++++++ sound/pci/hda/patch_realtek.c | 10 +++++++ 4 files changed, 66 insertions(+) create mode 100644 include/linux/huawei_wmi.h create mode 100644 sound/pci/hda/huawei_wmi_helper.c
drivers/platform/x86/huawei_wmi.c +1 -0
@@ -26,6 +26,7 @@#include <linux/input/sparse-keymap.h> #include <linux/acpi.h> #include <linux/wmi.h> +#include <linux/huawei_wmi.h> MODULE_AUTHOR ("Ayman Bagabas <[email protected]>" );MODULE_DESCRIPTION ("Huawei WMI hotkeys" );
include/linux/huawei_wmi.h new file +7 -0
@@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __HUAWEI_WMI_H__ +#define __HUAWEI_WMI_H__ + +int huawei_wmi_micmute_led_set (bool on); + +#endif
sound/pci/hda/huawei_wmi_helper.c new file +48 -0
48 lines not on this page · raw message
sound/pci/hda/patch_realtek.c +10 -0
@@ -5374,6 +5374,9 @@ static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,/* for alc295_fixup_hp_top_speakers */ #include "hp_x360_helper.c" +/* for alc_fixup_huawei_micmute_led */ +#include "huawei_wmi_helper.c" +enum {ALC269_FIXUP_SONY_VAIO ,ALC275_FIXUP_SONY_VAIO_GPIO2 ,
@@ -5494,6 +5497,7 @@ enum {ALC255_FIXUP_DUMMY_LINEOUT_VERB ,ALC255_FIXUP_DELL_HEADSET_MIC ,ALC256_FIXUP_HUAWEI_MBXP_PINS , +ALC256_FIXUP_HUAWEI_WMI_MICMUTE_LED ,ALC295_FIXUP_HP_X360 , ALC221_FIXUP_HP_HEADSET_MIC, };
@@ -6348,6 +6352,10 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id =ALC269_FIXUP_HEADSET_MIC }, + [ALC256_FIXUP_HUAWEI_WMI_MICMUTE_LED] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc_fixup_huawei_wmi + }, [ALC256_FIXUP_HUAWEI_MBXP_PINS] = { .type = HDA_FIXUP_PINS, .v.pins = (const struct hda_pintbl []) {
@@ -6363,6 +6371,8 @@ static const struct hda_fixup alc269_fixups[] = { {0x21, 0x04211020}, { }, }, + .chained = true, + .chain_id = ALC256_FIXUP_HUAWEI_WMI_MICMUTE_LED }, [ALC295_FIXUP_HP_X360] = { .type = HDA_FIXUP_FUNC,
Signature · 1 line
2.17.2
Re: [PATCH v2 3/3] ALSA: hda: add support for Huawei WMI MicMute LED
drivers/platform/x86/huawei_wmi.c line 29
Quoted 11 lines · Ayman Bagabas
Some of Huawei laptops come with a LED in the mic mute key. This patch enables and disable this LED accordingly.
drivers/platform/x86/huawei_wmi.c +1
-0@@ -26,6 +26,7 @@#include <linux/input/sparse-keymap.h> #include <linux/acpi.h> #include <linux/wmi.h> +#include <linux/huawei_wmi.h>
Keep it in order and put underinclude/linux/platform_data/x86/
folder.
drivers/platform/x86/huawei_wmi.c
Quoted 7 lines
drivers/platform/x86/huawei_wmi.c +7
-0+/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __HUAWEI_WMI_H__ +#define __HUAWEI_WMI_H__ + +int huawei_wmi_micmute_led_set (bool on); + +#endif
This has to cover !HUAWEI_LAPTOP case.
Quoted 3 lines
+/* Helper functions for Huawei WMI Mic Mute LED;
+ * to be included from codec driver
+ */
Comment style.
Quoted 1 line
+#if
IS_ENABLED(CONFIG_HUAWEI_LAPTOP)
See above
Quoted 1 line
+static int (*huawei_wmi_micmute_led_set_func)(bool);
Why is that?
Quoted 7 lines
drivers/platform/x86/huawei_wmi.c +7
-0+if (action ==HDA_FIXUP_ACT_PROBE ) { +if (!huawei_wmi_micmute_led_set_func) + huawei_wmi_micmute_led_set_func =symbol_request (huawei_wmi_micmute_led_set); +if (!huawei_wmi_micmute_led_set_func) { +codec_warn (codec,"Failed to find huawei_wmi symbol huawei_wmi_micmute_led_set\n" ); +return ; + }
drivers/platform/x86/huawei_wmi.c
Quoted 10 lines
drivers/platform/x86/huawei_wmi.c +10
-0+ removefunc = (huawei_wmi_micmute_led_set_func (false) <0 ) + || (snd_hda_gen_add_micmute_led (codec, update_huawei_wmi_micmute_led) <0 ); + + } + +if (huawei_wmi_micmute_led_set_func && (action ==HDA_FIXUP_ACT_FREE || removefunc)) { +symbol_put (huawei_wmi_micmute_led_set); + huawei_wmi_micmute_led_set_func =NULL ; + } +}
Takashi, is it a way how the rest sound drivers are written? B/c this symbol_request(s) look to me a bit ugly.
drivers/platform/x86/huawei_wmi.c
Quoted 2 lines
drivers/platform/x86/huawei_wmi.c +2
-0+/* for alc_fixup_huawei_micmute_led */ +#include "huawei_wmi_helper.c"
Ditto.
Include *.c?! Huh?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 3/3] ALSA: hda: add support for Huawei WMI MicMute LED
Quoted 13 lines · Andy Shevchenko
Quoted 13 lines
sound/pci/hda/huawei_wmi_helper.c new file +12
-0+if (action ==HDA_FIXUP_ACT_PROBE ) { +if (!huawei_wmi_micmute_led_set_func) + huawei_wmi_micmute_led_set_func =symbol_request (huawei_wmi_micmute_led_set); +if (!huawei_wmi_micmute_led_set_func) { +codec_warn (codec,"Failed to find huawei_wmi symbol huawei_wmi_micmute_led_set\n" ); +return ; + } + removefunc = (huawei_wmi_micmute_led_set_func (false) <0 ) + || (snd_hda_gen_add_micmute_led (codec, update_huawei_wmi_micmute_led) <0 ); + + } +
Quoted 8 lines
sound/pci/hda/huawei_wmi_helper.c line 39
Quoted 5 lines
sound/pci/hda/huawei_wmi_helper.c new file +5
-0+if (huawei_wmi_micmute_led_set_func && (action ==HDA_FIXUP_ACT_FREE || removefunc)) { +symbol_put (huawei_wmi_micmute_led_set); + huawei_wmi_micmute_led_set_func =NULL ; + } +}Takashi, is it a way how the rest sound drivers are written? B/c this
symbol_request(s)look to me a bit ugly.
It's a workaround for not having a hard dependency. The HD-audio codec driver is generic, and we don't want to load the multiple WMI drivers always for using a Realtek codec.
Ugly, yes, but simple enough.
thanks,
Takashi
Re: [PATCH v2 3/3] ALSA: hda: add support for Huawei WMI MicMute LED
Quoted 24 lines · Takashi Iwai
Quoted 13 lines · Andy Shevchenko
Quoted 13 lines
sound/pci/hda/huawei_wmi_helper.c new file +12
-0+if (action ==HDA_FIXUP_ACT_PROBE ) { +if (!huawei_wmi_micmute_led_set_func) + huawei_wmi_micmute_led_set_func =symbol_request (huawei_wmi_micmute_led_set); +if (!huawei_wmi_micmute_led_set_func) { +codec_warn (codec,"Failed to find huawei_wmi symbol huawei_wmi_micmute_led_set\n" ); +return ; + } + removefunc = (huawei_wmi_micmute_led_set_func (false) <0 ) + || (snd_hda_gen_add_micmute_led (codec, update_huawei_wmi_micmute_led) <0 ); + + } +Quoted 8 lines
sound/pci/hda/huawei_wmi_helper.c line 39
Quoted 5 lines
sound/pci/hda/huawei_wmi_helper.c new file +5
-0+if (huawei_wmi_micmute_led_set_func && (action ==HDA_FIXUP_ACT_FREE || removefunc)) { +symbol_put (huawei_wmi_micmute_led_set); + huawei_wmi_micmute_led_set_func =NULL ; + } +}Takashi, is it a way how the rest sound drivers are written? B/c this
symbol_request(s)look to me a bit ugly.
Quoted 5 lines
It's a workaround for not having a hard dependency. The HD-audio codec driver is generic, and we don't want to load the multiple WMI drivers always for using a Realtek codec.
Ugly, yes, but simple enough.
Okay, thanks for elaboration.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 3/3] ALSA: hda: add support for Huawei WMI MicMute LED
In reply to Andy ShevchenkoQuoted 28 lines · Andy Shevchenko
On Fri, Nov 2, 2018 at 6:12 AM Ayman Bagabas <[email protected]
drivers/platform/x86/huawei_wmi.c line 29
Quoted 12 lines
wrote:
Some of Huawei laptops come with a LED in the mic mute key. This patch
enables and disable this LED accordingly.drivers/platform/x86/huawei_wmi.c +1
-0@@ -26,6 +26,7 @@#include <linux/input/sparse-keymap.h> #include <linux/acpi.h> #include <linux/wmi.h> +#include <linux/huawei_wmi.h> Keep it in order and put under
include/linux/platform_data/x86/
folder.drivers/platform/x86/huawei_wmi.c
Quoted 7 lines
drivers/platform/x86/huawei_wmi.c +7
-0+/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __HUAWEI_WMI_H__ +#define __HUAWEI_WMI_H__ + +int huawei_wmi_micmute_led_set (bool on); + +#endif This has to cover !HUAWEI_LAPTOP case.
Quoted 5 lines
Quoted 3 lines
+/* Helper functions for Huawei WMI Mic Mute LED;
+ * to be included from codec driver
+ */Comment style.
/* Helper functions for Huawei WMI micmute led;
* to be included from codec driver
*/
Quoted 8 lines
Quoted 2 lines
+#if
IS_ENABLED(CONFIG_HUAWEI_LAPTOP)See above
Quoted 1 line
+static int (*huawei_wmi_micmute_led_set_func)(bool);
Why is that?
This is used with symbol_request and then in the update function to locate the function from the wmi device. But I guess you are right, we could use the function defined in the header file directly.
Quoted 27 lines
Quoted 19 lines
drivers/platform/x86/huawei_wmi.c +3
-0+if (action ==HDA_FIXUP_ACT_PROBE ) { +if (!huawei_wmi_micmute_led_set_func) + huawei_wmi_micmute_led_set_func =
symbol_request(huawei_wmi_micmute_led_set);drivers/platform/x86/huawei_wmi.c +2
-0+if (!huawei_wmi_micmute_led_set_func) { + codec_warn(codec, "Failed to find
huawei_wmisymbol huawei_wmi_micmute_led_set\n");drivers/platform/x86/huawei_wmi.c +3
-0+return ; + } + removefunc =(
huawei_wmi_micmute_led_set_func(false)< 0)
+ || (snd_hda_gen_add_micmute_led(codec,update_huawei_wmi_micmute_led) < 0);drivers/platform/x86/huawei_wmi.c +4
-0+ + } + + if (huawei_wmi_micmute_led_set_func && (action ==
HDA_FIXUP_ACT_FREE|| removefunc)) {drivers/platform/x86/huawei_wmi.c
Quoted 4 lines
drivers/platform/x86/huawei_wmi.c +4
-0+symbol_put (huawei_wmi_micmute_led_set); + huawei_wmi_micmute_led_set_func =NULL ; + } +}Takashi, is it a way how the rest sound drivers are written? B/c this
symbol_request(s)look to me a bit ugly.
Quoted 6 lines
drivers/platform/x86/huawei_wmi.c
Quoted 2 lines
drivers/platform/x86/huawei_wmi.c +2
-0+/* for alc_fixup_huawei_micmute_led */ +#include "huawei_wmi_helper.c" Ditto.
Include *.c?! Huh?
Is that the wrong way? Should I define the functions directly into patch_realtek.c?
Quoted 1 line
Re: [PATCH v2 3/3] ALSA: hda: add support for Huawei WMI MicMute LED
Quoted 3 lines · On Sat, Nov 3, 2018 at 1:21 AM <[email protected]> wrote:
Quoted 2 lines · Andy Shevchenko
On Fri, Nov 2, 2018 at 6:12 AM Ayman Bagabas <[email protected]
Quoted 1 line
wrote:
Takashi explained me, that is the way sound driver are using the external symbols, so, follow his suggestion.
Quoted 20 lines
Quoted 3 lines
Quoted 1 line
+static int (*huawei_wmi_micmute_led_set_func)(bool);
Why is that?
This is used with
symbol_requestand then in the update function to locate the function from the wmi device. But I guess you are right, we could use the function defined in the header file directly.Quoted 9 lines
Takashi, is it a way how the rest sound drivers are written? B/c this
symbol_request(s)look to me a bit ugly.sound/pci/hda/patch_realtek.c static void alc_fixup_thinkpad_acpi(struct hda_codec *codec, · line 5378
Quoted 2 lines
sound/pci/hda/patch_realtek.c +2
-0+/* for alc_fixup_huawei_micmute_led */ +#include "huawei_wmi_helper.c" Ditto.
Include *.c?! Huh?
Is that the wrong way? Should I define the functions directly into
patch_realtek.c?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 3 lines · Ayman Bagabas
This patch set fixes some of the issues with Huawei laptops.
Thanks for the series, I'll review it later on.
Quoted 33 lines
[PATCH v2 1/3]
The first patch adds support for missing hotkeys on some models. Some hotkeys, like brightness keys, work out of the box on these models.[PATCH v2 2/3]
This one enables the front speakers on the Huawei Matebook X Pro (MBXP). This solves bug 200501 https://bugzilla.kernel.org/show_bug.cgi?id=200501
It simply uses the pins configurations generated by hdajackretast using the settings posted on the bug page https://imgur.com/a/N1xsCVZ[PATCH v2 3/3]
This enables the micmute LED on Huawei laptops. It calls an WMI method, using PATCH #1, to turn the micmute LED on/off.Ayman Bagabas (3):
x86: add support for Huawei WMI hotkeys.
ALSA: hda: fix front speakers on Huawei MBXP.
ALSA: hda: add support for Huawei WMI MicMute LEDdrivers/platform/x86/Kconfig | 13 ++ drivers/platform/x86/Makefile | 1 + drivers/platform/x86/huawei_wmi.c | 224 ++++++++++++++++++++++++++++++ include/linux/huawei_wmi.h | 7 + sound/pci/hda/huawei_wmi_helper.c | 48 +++++++ sound/pci/hda/patch_realtek.c | 28 ++++ 6 files changed, 321 insertions(+) create mode 100644 drivers/platform/x86/huawei_wmi.c create mode 100644 include/linux/huawei_wmi.h create mode 100644 sound/pci/hda/huawei_wmi_helper.c--
2.17.2
Signature · 2 lines
With Best Regards, Andy Shevchenko