From: PaddyKP_Yao <ispaddy@gmail.com>
To: andy.shevchenko@gmail.com, hdegoede@redhat.com
Cc: paddykp_yao@asus.com, acpi4asus-user@lists.sourceforge.net,
corentin.chary@gmail.com, ispaddy@gmail.com,
linux-kernel@vger.kernel.org, luke@ljones.dev,
mgross@linux.intel.com, platform-driver-x86@vger.kernel.org,
PaddyKP_Yao <PaddyKP_Yao@asus.com>
Subject: [PATCH v2 1/1] platform/x86: asus-wmi: Add mic-mute LED classdev support
Date: Mon, 11 Jul 2022 10:40:30 +0800 [thread overview]
Message-ID: <20220711024030.1694502-1-PaddyKP_Yao@asus.com> (raw)
In-Reply-To: <HK0PR04MB33636680A6DC47211560BB43FA879@HK0PR04MB3363.apcprd04.prod.outlook.com>
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 <PaddyKP_Yao@asus.com>
---
V1 -> V2: fix typo for 'present' and remove unnecessary pr_info() log
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
next prev parent reply other threads:[~2022-07-11 2:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-08 8:48 [PATCH 1/1] platform/x86: asus-wmi: Add mic-mute LED classdev support PaddyKP_Yao
2022-07-08 9:07 ` PaddyKP_Yao
2022-07-09 11:44 ` Andy Shevchenko
2022-07-09 14:48 ` Hans de Goede
2022-07-09 14:49 ` Hans de Goede
2022-07-11 2:12 ` PaddyKP Yao(姚國鵬)
2022-07-11 2:40 ` PaddyKP_Yao [this message]
2022-07-11 2:47 ` [PATCH v2 " PaddyKP_Yao
2022-07-11 8:50 ` Andy Shevchenko
2022-07-11 11:41 ` PaddyKP Yao
2022-07-11 11:47 ` Hans de Goede
2022-07-11 11:51 ` [PATCH v3 " PaddyKP_Yao
2022-07-14 20:04 ` Hans de Goede
2022-08-24 10:06 ` Pavel Machek
2022-08-24 10:59 ` PaddyKP Yao
2022-08-25 7:55 ` Pavel Machek
2022-08-25 8:05 ` PaddyKP Yao
2022-08-24 10:06 ` [PATCH v2 " Pavel Machek
2022-08-24 11:09 ` PaddyKP Yao
2022-08-24 11:11 ` Hans de Goede
2022-08-24 11:17 ` PaddyKP Yao
2022-08-25 1:29 ` PaddyKP Yao
2022-08-25 8:13 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220711024030.1694502-1-PaddyKP_Yao@asus.com \
--to=ispaddy@gmail.com \
--cc=acpi4asus-user@lists.sourceforge.net \
--cc=andy.shevchenko@gmail.com \
--cc=corentin.chary@gmail.com \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luke@ljones.dev \
--cc=mgross@linux.intel.com \
--cc=paddykp_yao@asus.com \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.