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,