Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp258864imw; Fri, 8 Jul 2022 02:24:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uq/1jaqNUBz8B8PgBJSPKPzqfk3RyAtGQLo/Vq41glVeXSTzwC8OOk2oowGtGhRqnZiWe1 X-Received: by 2002:a50:fe98:0:b0:435:a8b:c4c3 with SMTP id d24-20020a50fe98000000b004350a8bc4c3mr3340797edt.78.1657272249658; Fri, 08 Jul 2022 02:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657272249; cv=none; d=google.com; s=arc-20160816; b=WYWI0pkVML185kUhUoKP8lE8t+I3ZYiniaYfq/36hUwnWw+4sQ+qQ+ZSJhMy6N00au wT7Z44mK5rRGP15Oj+9qgs2G/ZtriYNiKa1K6nUtOwcD6OzBPc3nLh5SpwqAhPMlJwp9 XhjVn7vSMh3lcLPsTPOxnPT61CZ4DOFpPtx4kjkYH4zZMvU0Iqg0S+9X4YzkBHKo5rPv i9QVH2dOFicHiq7IAOqxOQkhIFQSHcPL5lhFqjxOFSpOwB3lDh/u6d0orFRMuWAolE1L wdRVkggKDa77Br6wlGqjUPv/MbW6Ip2z+1u6QF62UQpLoeuqcKSwBJaeMhlIUkAqoTu5 6k7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=C33xyLawJhRLBaWCMnBU/MS45wpGFkBXlQelADzR1CM=; b=DTvjDnMu8tgexJFU2eM65iuw0kEBJQnkkwlvHQzSvooo1joaW/rrZlLs1wofSFEKzH 9RSzva1mR5ddeWyGX9SckUzyu5hULQgQaU2yh68ujdv1X5a9yXAPEMvStRtGWqMQbFNI s3vuL9ro0KNKv5kFz/BHOzlT2GP/ZhEcufpStdIBEFgGrlG2keti4UOLhZcfHG7LP4Ji rgyX6hU/Eou/GGt4pPJEHDydRWaH3Dpo8Tyrxp3TNFivG7AdIFdF85l475hGR1VLe67j mgZftXLNKe0E6TeY0VX0rMFHCIkGD4LfgPFQZv6k8qHGfatqPLETgm7vuNGRIRYvdnjm hnFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VE2aEf6w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n4-20020a05640206c400b0043a93d806ccsi5966911edy.449.2022.07.08.02.23.43; Fri, 08 Jul 2022 02:24:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VE2aEf6w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237797AbiGHJHp (ORCPT + 99 others); Fri, 8 Jul 2022 05:07:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbiGHJHo (ORCPT ); Fri, 8 Jul 2022 05:07:44 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B4031FCE4; Fri, 8 Jul 2022 02:07:43 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id r1so15836245plo.10; Fri, 08 Jul 2022 02:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C33xyLawJhRLBaWCMnBU/MS45wpGFkBXlQelADzR1CM=; b=VE2aEf6wO3TdSh1eQqY/sbtphYbuNh22y9pfryfy9Rh8iNoi68OEb6m4WoG9zRjPoO I+S2Pkyuyp1s4sKTKbnaUfcqLt3FjJLJ4j9w82Nt/TwQDAubSnyqcX2BvG5iYeq32+Xf HYI2wU11GO9nmMdzecfprIM3mu5OqULJDBznBbj58l0e8hznp8IptyPeMkjiwhZbwVyl elZHVNROTFKrRI523VVdi+xUBEYoMAB2Do7mnHNhbpraMgOk+63Jgj2L/Y2BK6ew/HV/ Q9CXAgcE5KLYmQEFUEC3fzMrMLNOz5GXxKPisqZoKcGYt1MOqjOhZyCYrm2b06vsMKui xjuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C33xyLawJhRLBaWCMnBU/MS45wpGFkBXlQelADzR1CM=; b=7MInlN1p7WuWiM8f2QZsX3Hb064wqDz0Yb6wFSZtyGGGBQcNUkxOB0fXpRBL0pFUd3 yWUP8cqfwyvdd8iAwQbfiZLbMBlaJ3nfcJ3ObdE56FDgp0GBHRY3PVygQUGBh8UxGcEj iZfw7Q8mgO7A46oEP7mEU93eWOf7AZPT8To3DN88C8PJDr5/rZ1rfstawq5med5HRyrT AtY330lqAP/NwyHyBEr4XW5iyTV7hHMubJS2AePZqNBcADQscMAeTyyZW0hMcQoHBltS O5M3fZnHNNGxAIkNN9DnDBYkQ6vNSp5wzeNsn3E+3B99vXK+jHLiife2/unkgKOBTrti C+Pg== X-Gm-Message-State: AJIora/SqD0mf4xOSCY90oKFDSdc3yK8QOucy1GVsSg6AXafTKtpMaz3 K1fdZULIq5jRakQ+eWHcpFg= X-Received: by 2002:a17:902:e9d3:b0:16b:fe8c:e89b with SMTP id 19-20020a170902e9d300b0016bfe8ce89bmr2829189plk.81.1657271262811; Fri, 08 Jul 2022 02:07:42 -0700 (PDT) Received: from localhost.localdomain (61-216-65-192.hinet-ip.hinet.net. [61.216.65.192]) by smtp.gmail.com with ESMTPSA id l17-20020a170903245100b0016c06a10861sm4563666pls.74.2022.07.08.02.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 02:07:42 -0700 (PDT) From: PaddyKP_Yao X-Google-Original-From: PaddyKP_Yao To: hdegoede@redhat.com, mgross@linux.intel.com, corentin.chary@gmail.com Cc: luke@ljones.dev, PaddyKP_Yao@asus.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, acpi4asus-user@lists.sourceforge.net Subject: [PATCH 1/1] platform/x86: asus-wmi: Add mic-mute LED classdev support Date: Fri, 8 Jul 2022 17:07:31 +0800 Message-Id: <20220708090731.1237488-1-PaddyKP_Yao@asus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708084816.1140540-1-PaddyKP_Yao@asus.com> References: <20220708084816.1140540-1-PaddyKP_Yao@asus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In some new ASUS devices, hotkey Fn+F13 is used for mic mute. If mic-mute LED is present by checking WMI ASUS_WMI_DEVID_MICMUTE_LED, we will add a mic-mute LED classdev, asus::micmute, in the asus-wmi driver to control it. The binding of mic-mute LED controls will be swithched with LED trigger. Signed-off-by: PaddyKP_Yao --- drivers/platform/x86/Kconfig | 2 ++ drivers/platform/x86/asus-wmi.c | 25 ++++++++++++++++++++++ include/linux/platform_data/x86/asus-wmi.h | 1 + 3 files changed, 28 insertions(+) diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index f915cf67aa26..74769050b770 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -274,6 +274,8 @@ config ASUS_WMI select INPUT_SPARSEKMAP select LEDS_CLASS select NEW_LEDS + select LEDS_TRIGGERS + select LEDS_TRIGGER_AUDIO select ACPI_PLATFORM_PROFILE help Say Y here if you have a WMI aware Asus laptop (like Eee PCs or new diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index e14fb5fa7324..40c0e00a4b71 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -191,6 +191,7 @@ struct asus_wmi { int kbd_led_wk; struct led_classdev lightbar_led; int lightbar_led_wk; + struct led_classdev micmute_led; struct workqueue_struct *led_workqueue; struct work_struct tpd_led_work; struct work_struct wlan_led_work; @@ -906,12 +907,23 @@ static enum led_brightness lightbar_led_get(struct led_classdev *led_cdev) return result & ASUS_WMI_DSTS_LIGHTBAR_MASK; } +static int micmute_led_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + int state = brightness != LED_OFF; + int err; + + err = asus_wmi_set_devstate(ASUS_WMI_DEVID_MICMUTE_LED, state, NULL); + return err < 0 ? err : 0; +} + static void asus_wmi_led_exit(struct asus_wmi *asus) { led_classdev_unregister(&asus->kbd_led); led_classdev_unregister(&asus->tpd_led); led_classdev_unregister(&asus->wlan_led); led_classdev_unregister(&asus->lightbar_led); + led_classdev_unregister(&asus->micmute_led); if (asus->led_workqueue) destroy_workqueue(asus->led_workqueue); @@ -983,6 +995,19 @@ static int asus_wmi_led_init(struct asus_wmi *asus) &asus->lightbar_led); } + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MICMUTE_LED)) { + asus->micmute_led.name = "asus::micmute"; + asus->micmute_led.max_brightness = 1; + asus->micmute_led.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE); + asus->micmute_led.brightness_set_blocking = micmute_led_set; + asus->micmute_led.default_trigger = "audio-micmute"; + + rv = led_classdev_register(&asus->platform_device->dev, + &asus->micmute_led); + if (rv) + goto error; + } + error: if (rv) asus_wmi_led_exit(asus); diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h index 17dc5cb6f3f2..38ee75874d11 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -49,6 +49,7 @@ #define ASUS_WMI_DEVID_LED4 0x00020014 #define ASUS_WMI_DEVID_LED5 0x00020015 #define ASUS_WMI_DEVID_LED6 0x00020016 +#define ASUS_WMI_DEVID_MICMUTE_LED 0x00040017 /* Backlight and Brightness */ #define ASUS_WMI_DEVID_ALS_ENABLE 0x00050001 /* Ambient Light Sensor */ -- 2.34.1