platform/x86: asus-wmi: add speaker mute LED
PATCH 1/1 platform/x86: asus-wmi: add speaker mute LED
Some ASUS laptops (e.g. the ExpertBook B3405CCA) have a mute LED on the F1 key next to the mic mute LED on F4. The mic mute LED is already driven through WMI device 0x00040017, but the speaker mute LED is not known to the driver, so it never lights up under Linux while the firmware does light it under Windows.
The DSDT of the B3405CCA exposes device 0x0004001C in the same LED group with the presence bit set, and calling DEVS(0x0004001C, 1/0) turns the F1 key LED on and off.
Register it as "platform::mute" with the "audio-mute" default trigger, mirroring the existing mic mute LED, so that the snd-ctl-led speaker mode drives it automatically. Only registered when the firmware reports the device as present, so nothing changes on other models.
Tested on an ASUS ExpertBook B3405CCA (BIOS 307): DSTS reports the device present and DEVS 1/0 toggles the LED.
--- drivers/platform/x86/asus-wmi.c | 24 ++++++++++++++++++++++ include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 25 insertions(+)
drivers/platform/x86/asus-wmi.c +24 -0
@@ -262,6 +262,7 @@ struct asus_wmi {struct led_classdev lightbar_led;int lightbar_led_wk;struct led_classdev micmute_led; +struct led_classdev mute_led;struct led_classdev camera_led;struct workqueue_struct *led_workqueue;struct work_struct tpd_led_work;
@@ -2054,6 +2055,16 @@ static int micmute_led_set(struct led_classdev *led_cdev,return err <0 ? err :0 ; } +static int mute_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_MUTE_LED , state,NULL ); +return err <0 ? err :0 ; +} +static enum led_brightness camera_led_get (struct led_classdev *led_cdev) {struct asus_wmi *asus;
@@ -2084,6 +2095,7 @@ static void asus_wmi_led_exit(struct asus_wmi *asus)led_classdev_unregister (&asus->wlan_led);led_classdev_unregister (&asus->lightbar_led);led_classdev_unregister (&asus->micmute_led); +led_classdev_unregister (&asus->mute_led);led_classdev_unregister (&asus->camera_led);if (asus->led_workqueue)
@@ -2181,6 +2193,18 @@ static int asus_wmi_led_init(struct asus_wmi *asus) goto error; } +if (asus_wmi_dev_is_present (asus,ASUS_WMI_DEVID_MUTE_LED )) { + asus->mute_led.name ="platform::mute" ; + asus->mute_led.max_brightness =1 ; + asus->mute_led.brightness_set_blocking = mute_led_set; + asus->mute_led.default_trigger ="audio-mute" ; + + rv =led_classdev_register (&asus->platform_device->dev, + &asus->mute_led); +if (rv) + goto error; + } +if (asus_wmi_dev_is_present (asus,ASUS_WMI_DEVID_CAMERA_LED )) { asus->camera_led.name ="asus::camera" ; asus->camera_led.max_brightness =1 ;
include/linux/platform_data/x86/asus-wmi.h +1 -0
@@ -54,6 +54,7 @@#define ASUS_WMI_DEVID_LED5 0x00020015#define ASUS_WMI_DEVID_LED6 0x00020016#define ASUS_WMI_DEVID_MICMUTE_LED 0x00040017 +#define ASUS_WMI_DEVID_MUTE_LED 0x0004001C/* Disable Camera LED */ #define ASUS_WMI_DEVID_CAMERA_LED_NEG 0x00060078/* 0 = on (unused) */
Signature · 1 line
2.55.0
Ilpo Järvinen
maintainerQuoted 15 lines · Jorge Núñez Granero
Some ASUS laptops (e.g. the ExpertBook B3405CCA) have a mute LED on the F1 key next to the mic mute LED on F4. The mic mute LED is already driven through WMI device
0x00040017, but the speaker mute LED is not known to the driver, so it never lights up under Linux while the firmware does light it under Windows.The DSDT of the B3405CCA exposes device
0x0004001Cin the same LED group with the presence bit set, and callingDEVS(0x0004001C, 1/0)turns the F1 key LED on and off.Register it as "
platform::mute" with the "audio-mute" default trigger, mirroring the existing mic mute LED, so that the snd-ctl-led speaker mode drives it automatically. Only registered when the firmware reports the device as present, so nothing changes on other models.
Quoted 4 lines
Tested on an ASUS ExpertBook B3405CCA (BIOS 307): DSTS reports the device present and DEVS 1/0 toggles the LED.
Signed-off-by Jorge Núñez Granero <[email protected]>
Thanks for the patch, but I've already queued another patch to this effect into the review-ilpo-next branch (from where it will eventually propagate to the for-next branch).
--
i.
Quoted 74 lines
--- drivers/platform/x86/asus-wmi.c | 24 ++++++++++++++++++++++ include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 25 insertions(+)drivers/platform/x86/asus-wmi.c +24
-0@@ -262,6 +262,7 @@ struct asus_wmi {struct led_classdev lightbar_led;int lightbar_led_wk;struct led_classdev micmute_led; +struct led_classdev mute_led;struct led_classdev camera_led;struct workqueue_struct *led_workqueue;struct work_struct tpd_led_work;@@ -2054,6 +2055,16 @@ static int micmute_led_set(struct led_classdev *led_cdev,return err <0 ? err :0 ; } +static int mute_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_MUTE_LED , state,NULL ); +return err <0 ? err :0 ; +} +static enum led_brightness camera_led_get (struct led_classdev *led_cdev) {struct asus_wmi *asus;@@ -2084,6 +2095,7 @@ static void asus_wmi_led_exit(struct asus_wmi *asus)led_classdev_unregister (&asus->wlan_led);led_classdev_unregister (&asus->lightbar_led);led_classdev_unregister (&asus->micmute_led); +led_classdev_unregister (&asus->mute_led);led_classdev_unregister (&asus->camera_led);if (asus->led_workqueue)@@ -2181,6 +2193,18 @@ static int asus_wmi_led_init(struct asus_wmi *asus) goto error; } +if (asus_wmi_dev_is_present (asus,ASUS_WMI_DEVID_MUTE_LED )) { + asus->mute_led.name ="platform::mute" ; + asus->mute_led.max_brightness =1 ; + asus->mute_led.brightness_set_blocking = mute_led_set; + asus->mute_led.default_trigger ="audio-mute" ; + + rv =led_classdev_register (&asus->platform_device->dev, + &asus->mute_led); +if (rv) + goto error; + } +if (asus_wmi_dev_is_present (asus,ASUS_WMI_DEVID_CAMERA_LED )) { asus->camera_led.name ="asus::camera" ; asus->camera_led.max_brightness =1 ;include/linux/platform_data/x86/asus-wmi.h +1
-0@@ -54,6 +54,7 @@#define ASUS_WMI_DEVID_LED5 0x00020015#define ASUS_WMI_DEVID_LED6 0x00020016#define ASUS_WMI_DEVID_MICMUTE_LED 0x00040017 +#define ASUS_WMI_DEVID_MUTE_LED 0x0004001C/* Disable Camera LED */ #define ASUS_WMI_DEVID_CAMERA_LED_NEG 0x00060078/* 0 = on (unused) */