From patchwork Fri Nov 2 04:11:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayman Bagabas X-Patchwork-Id: 10664909 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6669113BF for ; Fri, 2 Nov 2018 04:11:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5514F2BE47 for ; Fri, 2 Nov 2018 04:11:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 444882BE86; Fri, 2 Nov 2018 04:11:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C2BE2BE47 for ; Fri, 2 Nov 2018 04:11:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727551AbeKBNRW (ORCPT ); Fri, 2 Nov 2018 09:17:22 -0400 Received: from mail-ua1-f66.google.com ([209.85.222.66]:44962 "EHLO mail-ua1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbeKBNRV (ORCPT ); Fri, 2 Nov 2018 09:17:21 -0400 Received: by mail-ua1-f66.google.com with SMTP id i30so219044uae.11; Thu, 01 Nov 2018 21:11:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=ju0EHp5DDPgeJtHoBeb9/yartdMBJ2pVo/Kmy944BHw=; b=ooIIyKOMXg34Y5Ah3HEl12ONi8uajDozeuNm6KwTM3c+3FoD3KwUQVQzgwf/lopTUY DJN0PxaShbH/RX718+GHA0c2lKfZg3w+Qe4u5m9j7VgYEQa8iG5bvL2lkrMMFpNORmiL 9b++z4McfbaDfmuyHAg3NftvSWrO/GCPJ1DPzjyTJtJhvQz9y7gEqLjBd/DsQ2ZC3XFD pRu55q1BjXy+JyoulysV2es/FYvqmZ12eh8NMxvPLk/bYxYYEPauvSvNjAS9z54oqJC4 cBK1mf3EUyEFB0wTIlO2fiSIwVrZvX+HNfd0IhUWWLKC2gZ+J31uITsTmF/3xu0ZheSk 4QJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=ju0EHp5DDPgeJtHoBeb9/yartdMBJ2pVo/Kmy944BHw=; b=ORvZuYkAjvoOpdtJeULR3H2A8ezHVsuzLs2W2DHds5rYuRCzo6WZ4GtrtPcd8ul/D1 yo2URljQW2dP/MfiqDg98UuAt2ezpcuea0rWJPOsMJ4okCJ0MklxhN5+89KUiewtExCE D6kXjD7CPeBN6v5HYGsvwrI7V5dOtRIM0ejIlUCBgmIyOjCADZp2g/Gk6/6LwnODGAi/ A+qyUMDobyquLS/hIpNzaUM+Cf/8KQAgQ4XeUHDAynD+yujeBMq2LTjYKpJFfpEtUpKP 7v4wEjFVtzk4FCWcZHcCv8W7Y4vS+YP0QTkzXvd/4aBN787sGn4m3ZOe7NAfGOiD+GtM ogVA== X-Gm-Message-State: AGRZ1gILmVw1k266lFA0V3lLERHP3Dvj3OCbJEzTi7OWw4liS9zkpv/s 2C/e/byyc7cX/+d8gUsJWg== X-Google-Smtp-Source: AJdET5fsYFD+TqMxgwwhRd5y5imILJdBXqFXoymXBhcCukhJZRw0Tp75b3HCHkGAc4DlSLq+gUwo+w== X-Received: by 2002:ab0:a8c:: with SMTP id d12mr4677880uak.67.1541131898607; Thu, 01 Nov 2018 21:11:38 -0700 (PDT) Received: from localhost.localdomain ([2601:902:c200:6512:a50b:fc5d:3604:d966]) by smtp.gmail.com with ESMTPSA id a2sm1661150uaa.15.2018.11.01.21.11.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Nov 2018 21:11:38 -0700 (PDT) From: Ayman Bagabas To: Darren Hart , Andy Shevchenko , Jaroslav Kysela , Takashi Iwai , Ayman Bagabas , Kailang Yang , Hui Wang , linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH v2 1/3] x86: add support for Huawei WMI hotkeys. Date: Fri, 2 Nov 2018 00:11:13 -0400 Message-Id: <20181102041120.7603-2-ayman.bagabas@gmail.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181102041120.7603-1-ayman.bagabas@gmail.com> References: <20181102041120.7603-1-ayman.bagabas@gmail.com> Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Ayman Bagabas --- 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 diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 0c1aa6c314f5..c6813981e45c 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -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 diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index e6d1becf81ce..5984354e18ff 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -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 diff --git a/drivers/platform/x86/huawei_wmi.c b/drivers/platform/x86/huawei_wmi.c new file mode 100644 index 000000000000..83545217ac19 --- /dev/null +++ b/drivers/platform/x86/huawei_wmi.c @@ -0,0 +1,223 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Huawei WMI Hotkeys Driver + * + * Copyright (C) 2018 Ayman Bagabas + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include +#include +#include +#include +#include +#include +#include + +MODULE_AUTHOR("Ayman Bagabas "); +MODULE_DESCRIPTION("Huawei WMI hotkeys"); +MODULE_LICENSE("GPL"); + +#define DEVICE_NAME "huawei" +#define MODULE_NAME DEVICE_NAME"_wmi" + +/* + * Huawei WMI Devices GUIDs + */ +#define AMW0_GUID "ABBC0F5B-8EA1-11D1-A000-C90629100000" // \_SB.AMW0 + +/* + * Huawei WMI Events GUIDs + */ +#define EVENT_GUID "ABBC0F5C-8EA1-11D1-A000-C90629100000" + +MODULE_ALIAS("wmi:"AMW0_GUID); +MODULE_ALIAS("wmi:"EVENT_GUID); + +enum { + MICMUTE_LED_ON = 0x00010B04, + MICMUTE_LED_OFF = 0x00000B04, +}; + +static const struct key_entry huawei_wmi_keymap[] __initconst = { + { KE_IGNORE, 0x281, { KEY_BRIGHTNESSDOWN } }, + { KE_IGNORE, 0x282, { KEY_BRIGHTNESSUP } }, + { 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; +}; +static struct huawei_wmi_device *wmi_device; + +int huawei_wmi_micmute_led_set(bool on) +{ + u32 args = (on) ? MICMUTE_LED_ON : MICMUTE_LED_OFF; + 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; + + return 0; +} +EXPORT_SYMBOL_GPL(huawei_wmi_micmute_led_set); + +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); + + if (!key) { + pr_info("%s: Unknown key pressed, code: 0x%04x\n", + MODULE_NAME, code); + 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 }; + 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); + return; + } + + obj = (union acpi_object *)response.pointer; + + 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); + + kfree(response.pointer); +} + +static int huawei_input_init(void) +{ + acpi_status status; + int err; + + wmi_device->inputdev = input_allocate_device(); + if (!wmi_device->inputdev) + return -ENOMEM; + + wmi_device->inputdev->name = "Huawei WMI hotkeys"; + wmi_device->inputdev->phys = "wmi/input0"; + wmi_device->inputdev->id.bustype = BUS_HOST; + + err = sparse_keymap_setup(wmi_device->inputdev, + huawei_wmi_keymap, NULL); + if (err) + goto err_free_dev; + + status = wmi_install_notify_handler(EVENT_GUID, + huawei_wmi_notify, + NULL); + + if (ACPI_FAILURE(status)) { + err = -EIO; + goto err_free_dev; + } + + err = input_register_device(wmi_device->inputdev); + if (err) + goto err_remove_notifier; + + return 0; + + +err_remove_notifier: + wmi_remove_notify_handler(EVENT_GUID); +err_free_dev: + input_free_device(wmi_device->inputdev); + return err; +} + +static void huawei_input_exit(void) +{ + wmi_remove_notify_handler(EVENT_GUID); + input_unregister_device(wmi_device->inputdev); +} + +static int __init huawei_wmi_setup(void) +{ + int err; + + wmi_device = kmalloc(sizeof(struct huawei_wmi_device), GFP_KERNEL); + if (!wmi_device) + return -ENOMEM; + + err = huawei_input_init(); + if (err) + goto err_input; + + return 0; + +err_input: + return err; +} + +static void huawei_wmi_destroy(void) +{ + huawei_input_exit(); + kfree(wmi_device); +} + +static int __init huawei_wmi_init(void) +{ + int err; + + if (!wmi_has_guid(EVENT_GUID)) { + pr_warn("%s: No known WMI GUID found\n", MODULE_NAME); + return -ENODEV; + } + + err = huawei_wmi_setup(); + if (err) { + pr_err("%s: Failed to setup device\n", MODULE_NAME); + return err; + } + + return 0; +} + +static void __exit huawei_wmi_exit(void) +{ + huawei_wmi_destroy(); + pr_debug("%s: Driver unloaded successfully\n", MODULE_NAME); +} + +module_init(huawei_wmi_init); +module_exit(huawei_wmi_exit); From patchwork Fri Nov 2 04:11:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayman Bagabas X-Patchwork-Id: 10664911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 21B3B13BF for ; Fri, 2 Nov 2018 04:11:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06BED2BE86 for ; Fri, 2 Nov 2018 04:11:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9B1C2BEB5; Fri, 2 Nov 2018 04:11:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7794D2BE86 for ; Fri, 2 Nov 2018 04:11:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727624AbeKBNRb (ORCPT ); Fri, 2 Nov 2018 09:17:31 -0400 Received: from mail-vk1-f194.google.com ([209.85.221.194]:34092 "EHLO mail-vk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbeKBNRa (ORCPT ); Fri, 2 Nov 2018 09:17:30 -0400 Received: by mail-vk1-f194.google.com with SMTP id y14so156400vkd.1; Thu, 01 Nov 2018 21:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=Ziut4ebdY6pgpbsJWeBt1ROGCKxjpKn2B/jm2lTBiG0=; b=YKnvLS6XLxuNYfYzJH8i/eLzkYMHyrrmrwXdGwhxi2PjZdPQjiPuZA2VsK3GHf8zq2 N8MaB4D4ImOSt6WuUejLwEIuNTsGq1tPOld8lAXYghC0Lfnz3PN6AYeFbCqMoPYq3E2X AFH4y1sGitf00LuSKc4OAwbr8+YrV8Ml9txXQTdp4MmAGGsVrDa3d2TLNixrWmmGpOB/ MuRzlzCrT8ycFuK6VBrNAX90rlrDD5Te74sWh0s0InAjHZyI5ckgFEROAPD7cqvKe/6D GwISC4N47NBqa4S1ZZn5tYRAmh8tbDhXf5OQNUbEMGqLZlzXd3EveCBUh6TY6xKpH6lQ QMaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Ziut4ebdY6pgpbsJWeBt1ROGCKxjpKn2B/jm2lTBiG0=; b=K2pz91Y57CIn/Hww80fe7u9B3UZU/WogWUadvVzo4Dt3ZNeflVrs3AGeXhjvEiT4zs TeM49OJQQb2T30i9qfnuqD3sP068JdwLDCceBi0gUKffsPrVKdJbeyv9UlMGufEDOtUe NDXelz/hHf7iodervIqgXSlWNf2y8m2+xf2z9wcxCokh1Z9rgCgHrNXSi+P1yPElBmMZ irQngJlp4GzCd/MJX6fjxyS1E94JwYibdPFJ6MTu/D+2iUgEPccXnvp1q2nTV06tZGrk HOblwRBlqA9UgyWYhixGuxclAzCfjFsc4yCItmyMPd+sibSZreAjENtJP9ZrD9Bk1G0+ tZDA== X-Gm-Message-State: AGRZ1gLAYq4xfxvdyQaUzKY5V4Z9ZdDTQJJtanHOakJ1c214WeMDpEsv xVGuwuV5Bu6hL6EeC7ZbXw== X-Google-Smtp-Source: AJdET5etaneLpnF9O4pYTO5fiKNvubzdlFvF0r71/GXEzcpvywKo0E1Vftgdjl6RwS+0llJTO1LYlw== X-Received: by 2002:a1f:ae88:: with SMTP id x130-v6mr4353901vke.91.1541131906077; Thu, 01 Nov 2018 21:11:46 -0700 (PDT) Received: from localhost.localdomain ([2601:902:c200:6512:a50b:fc5d:3604:d966]) by smtp.gmail.com with ESMTPSA id a2sm1661150uaa.15.2018.11.01.21.11.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Nov 2018 21:11:45 -0700 (PDT) From: Ayman Bagabas To: Darren Hart , Andy Shevchenko , Jaroslav Kysela , Takashi Iwai , Ayman Bagabas , Kailang Yang , Hui Wang , linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH v2 2/3] ALSA: hda: fix front speakers on Huawei MBXP. Date: Fri, 2 Nov 2018 00:11:14 -0400 Message-Id: <20181102041120.7603-3-ayman.bagabas@gmail.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181102041120.7603-1-ayman.bagabas@gmail.com> References: <20181102041120.7603-1-ayman.bagabas@gmail.com> Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Ayman Bagabas --- sound/pci/hda/patch_realtek.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 3ac7ba9b342d..4f7a39c7883c 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -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 */ From patchwork Fri Nov 2 04:11:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayman Bagabas X-Patchwork-Id: 10664913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0F6614E2 for ; Fri, 2 Nov 2018 04:11:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B13D82BE93 for ; Fri, 2 Nov 2018 04:11:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5BEB2BEBF; Fri, 2 Nov 2018 04:11:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 359BD2BE93 for ; Fri, 2 Nov 2018 04:11:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727693AbeKBNRg (ORCPT ); Fri, 2 Nov 2018 09:17:36 -0400 Received: from mail-vs1-f67.google.com ([209.85.217.67]:40133 "EHLO mail-vs1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbeKBNRg (ORCPT ); Fri, 2 Nov 2018 09:17:36 -0400 Received: by mail-vs1-f67.google.com with SMTP id s9so366401vsk.7; Thu, 01 Nov 2018 21:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=5SMTWRHblam50hFXCZFpH9+3ZtgrRgiP4fXKZNWtfJ4=; b=HPiLRerkAYVujBw+9k4TpapXG3ghOiEkffXYkePKjdYbpAkBfFyD/6cNX8UzpVktw0 p9oxG6M2dY0im+id5/rBrGjCE8N6kLD8thALVx+YgvhxPSeLLoz+9Mfs02EQza5AKm70 +Q8RF2yOIjr12rxrzUsuB8QoE4OdO3PegwbBEj73B5DjxOQW0zY5QvHt9dBIUQCt3mgN 7h46OZFt3y7NkO/P3toxSSnsjgKonCOBPlBIVLkPqzuD7liIpksV8GRyTkCD4WJ+oDrE 6HMcYuiP8pwIpudh7TrslnvexeaUiyLKht2EwJPxZbfUQZhlkYQ2KWa2it6EuA2KShiF 9WPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=5SMTWRHblam50hFXCZFpH9+3ZtgrRgiP4fXKZNWtfJ4=; b=XLTpgdf0XqQXOIBOlEtxaBkJPWsOY1H46/HszlJHq85SsNF51ZAooTSeIxcETIlQuq /B4kcEH5YNuryECgaFj2Axw/YJknJ6vrGxp3FBdUIoBDeHBXdh4lh3wsiNgw0XY3Tl8a IZaoQiaWlplAS9hh+2/uF/9DPjYpG4e5sqkITDX/y2cYedEpIhmx6oCJhLZohnU8PbuE twu3j5D38wm0jEF4KHuN5WrCjFO3CG4ta0dCVl0qgad26EjgJc1ty5txbQ/usvNP1JEe BZ7b1Amn9dqAsSi9kw/OmJPfRkY7ArGja/tdde8EK5R3zrYJNtSHym8KeuR/g6K0lWC2 F8sg== X-Gm-Message-State: AGRZ1gJeRIaqfjAaRBbX83PFiSYmNaGLKqP5+ZeWEOYWJFJ8M7U9XV1Y qV+rLheOvm3Kth0yl4GyZg== X-Google-Smtp-Source: AJdET5ddNVCQaStRGQHiZ8wrxnFW5fZf00R9K6xBoxsZk6UAppM4gkXiWQ3MNxQmd9hf55NxTF51sQ== X-Received: by 2002:a67:d81:: with SMTP id 123mr3880137vsn.211.1541131912606; Thu, 01 Nov 2018 21:11:52 -0700 (PDT) Received: from localhost.localdomain ([2601:902:c200:6512:a50b:fc5d:3604:d966]) by smtp.gmail.com with ESMTPSA id a2sm1661150uaa.15.2018.11.01.21.11.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Nov 2018 21:11:52 -0700 (PDT) From: Ayman Bagabas To: Darren Hart , Andy Shevchenko , Jaroslav Kysela , Takashi Iwai , Ayman Bagabas , Kailang Yang , Hui Wang , linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH v2 3/3] ALSA: hda: add support for Huawei WMI MicMute LED Date: Fri, 2 Nov 2018 00:11:15 -0400 Message-Id: <20181102041120.7603-4-ayman.bagabas@gmail.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181102041120.7603-1-ayman.bagabas@gmail.com> References: <20181102041120.7603-1-ayman.bagabas@gmail.com> Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some of Huawei laptops come with a LED in the mic mute key. This patch enables and disable this LED accordingly. Signed-off-by: Ayman Bagabas --- 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 diff --git a/drivers/platform/x86/huawei_wmi.c b/drivers/platform/x86/huawei_wmi.c index 83545217ac19..cc5492571727 100644 --- a/drivers/platform/x86/huawei_wmi.c +++ b/drivers/platform/x86/huawei_wmi.c @@ -26,6 +26,7 @@ #include #include #include +#include MODULE_AUTHOR("Ayman Bagabas "); MODULE_DESCRIPTION("Huawei WMI hotkeys"); diff --git a/include/linux/huawei_wmi.h b/include/linux/huawei_wmi.h new file mode 100644 index 000000000000..69b656c5029b --- /dev/null +++ b/include/linux/huawei_wmi.h @@ -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 diff --git a/sound/pci/hda/huawei_wmi_helper.c b/sound/pci/hda/huawei_wmi_helper.c new file mode 100644 index 000000000000..77edb658cbf0 --- /dev/null +++ b/sound/pci/hda/huawei_wmi_helper.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Helper functions for Huawei WMI Mic Mute LED; + * to be included from codec driver + */ + +#if IS_ENABLED(CONFIG_HUAWEI_LAPTOP) +#include + +static int (*huawei_wmi_micmute_led_set_func)(bool); + +static void update_huawei_wmi_micmute_led(struct hda_codec *codec) +{ + struct hda_gen_spec *spec = codec->spec; + + huawei_wmi_micmute_led_set_func(spec->micmute_led.led_value); +} + +static void alc_fixup_huawei_wmi(struct hda_codec *codec, + const struct hda_fixup *fix, int action) +{ + bool removefunc = false; + + 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); + + } + + 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; + } +} + +#else + +static void alc_fixup_huawei_wmi(struct hda_codec *codec, + const struct hda_fixup *fix, int action) +{ +} + +#endif diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 4f7a39c7883c..d09457d2a4f3 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -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,