Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH] platform/arm64: lenovo-yoga-slim7x-gen11-ec: add the mic mute LED
@ 2026-11-30 13:33 Oleg Keri
  2026-11-30 13:43 ` Konrad Dybcio
  2026-11-30 13:47 ` Hans de Goede
  0 siblings, 2 replies; 3+ messages in thread
From: Oleg Keri @ 2026-11-30 13:33 UTC (permalink / raw)
  To: hansg, ilpo.jarvinen
  Cc: bryan.odonoghue, platform-driver-x86, linux-arm-msm, Oleg Keri

The mic mute key of the Yoga Slim 7x Gen 11 has an indicator LED which
the EC does not drive on its own. The key press is only reported as an
event and the LED stays dark.

The vendor ACPI tables implement the SetFeature method of the Lenovo
hotkey utility WMI interface (CE6C0974-0407-4F50-88BA-4FC3B6559AD8) for
this LED by setting or clearing bit 6 of the KBLT byte in the EC RAM,
the same byte that holds the keyboard backlight level in bits 1:0.

Expose that bit as the platform::micmute LED with the audio-micmute
default trigger, and select SND_CTL_LED so that the trigger is available,
as the ThinkPad T14s EC driver does. The LED is turned off across system
suspend by the LED core and restored on resume.

Signed-off-by: Oleg Keri <okerixx@gmail.com>
---
 drivers/platform/arm64/Kconfig                |  5 +-
 .../arm64/lenovo-yoga-slim7x-gen11-ec.c       | 46 +++++++++++++++++++
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/arm64/Kconfig b/drivers/platform/arm64/Kconfig
index 3f879410b311..0a7054c66705 100644
--- a/drivers/platform/arm64/Kconfig
+++ b/drivers/platform/arm64/Kconfig
@@ -113,12 +113,13 @@ config EC_LENOVO_YOGA_SLIM7X_GEN11
 	depends on HWMON
 	select NEW_LEDS
 	select LEDS_CLASS
+	select SND_CTL_LED if SND
 	help
 	  Say Y here to enable the EC driver for the (Snapdragon X2 Elite,
 	  glymur-based) Lenovo Yoga Slim 7x Gen 11 laptop. The EC provides
 	  thermistors and CPU fan speed as hwmon channels, the keyboard
-	  backlight as an LED, Fn-lock as a sysfs attribute, and the mic-mute
-	  and airplane-mode keys.
+	  backlight and the mic-mute indicator as LEDs, Fn-lock as a sysfs
+	  attribute, and the mic-mute and airplane-mode keys.
 
 	  This is the Gen 11 (glymur) machine specifically. Its EC is a Compal
 	  design at i2c address 0x70 and speaks a different protocol from the
diff --git a/drivers/platform/arm64/lenovo-yoga-slim7x-gen11-ec.c b/drivers/platform/arm64/lenovo-yoga-slim7x-gen11-ec.c
index 36dcbff58755..2db46fbf1f75 100644
--- a/drivers/platform/arm64/lenovo-yoga-slim7x-gen11-ec.c
+++ b/drivers/platform/arm64/lenovo-yoga-slim7x-gen11-ec.c
@@ -49,6 +49,7 @@
 #define SLIM7X11_EC_KBLT_LEVEL	GENMASK(1, 0)
 #define SLIM7X11_EC_KBLT_AUTO	3
 #define SLIM7X11_EC_KBLT_MAX	2
+#define SLIM7X11_EC_KBLT_MIC_MUTE	BIT(6)
 
 #define SLIM7X11_EC_TEMP_FIRST	0x12
 #define SLIM7X11_EC_NUM_TEMP	6
@@ -60,6 +61,7 @@ struct slim7x11_ec {
 	struct mutex lock;
 	unsigned long temp_present;
 	struct led_classdev kbd_led;
+	struct led_classdev mic_led;
 	u8 kblt_level;
 	bool kblt_restore;
 	struct input_dev *keys;
@@ -234,6 +236,39 @@ static int slim7x11_ec_kbd_led_set(struct led_classdev *led, enum led_brightness
 	return slim7x11_ec_kbd_led_level(ec, brightness, NULL);
 }
 
+static enum led_brightness slim7x11_ec_mic_led_get(struct led_classdev *led)
+{
+	struct slim7x11_ec *ec = container_of(led, struct slim7x11_ec, mic_led);
+	u8 raw;
+
+	guard(mutex)(&ec->lock);
+
+	if (slim7x11_ec_ram_read(ec, SLIM7X11_EC_KBLT, &raw))
+		return 0;
+
+	return !!(raw & SLIM7X11_EC_KBLT_MIC_MUTE);
+}
+
+static int slim7x11_ec_mic_led_set(struct led_classdev *led, enum led_brightness brightness)
+{
+	struct slim7x11_ec *ec = container_of(led, struct slim7x11_ec, mic_led);
+	u8 raw;
+	int ret;
+
+	guard(mutex)(&ec->lock);
+
+	ret = slim7x11_ec_ram_read(ec, SLIM7X11_EC_KBLT, &raw);
+	if (ret)
+		return ret;
+
+	if (brightness)
+		raw |= SLIM7X11_EC_KBLT_MIC_MUTE;
+	else
+		raw &= ~SLIM7X11_EC_KBLT_MIC_MUTE;
+
+	return slim7x11_ec_ram_write(ec, SLIM7X11_EC_KBLT, raw);
+}
+
 static const struct hwmon_ops slim7x11_ec_hwmon_ops = {
 	.is_visible = slim7x11_ec_is_visible,
 	.read = slim7x11_ec_read,
@@ -453,6 +488,17 @@ static int slim7x11_ec_probe(struct i2c_client *client)
 	if (ret)
 		return dev_err_probe(dev, ret, "failed to register keyboard backlight\n");
 
+	ec->mic_led.name = "platform::micmute";
+	ec->mic_led.max_brightness = 1;
+	ec->mic_led.default_trigger = "audio-micmute";
+	ec->mic_led.flags = LED_CORE_SUSPENDRESUME;
+	ec->mic_led.brightness_get = slim7x11_ec_mic_led_get;
+	ec->mic_led.brightness_set_blocking = slim7x11_ec_mic_led_set;
+
+	ret = devm_led_classdev_register(dev, &ec->mic_led);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to register the mic mute LED\n");
+
 	if (client->irq) {
 		slim7x11_ec_register_keys(ec);
 
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] platform/arm64: lenovo-yoga-slim7x-gen11-ec: add the mic mute LED
  2026-11-30 13:33 [PATCH] platform/arm64: lenovo-yoga-slim7x-gen11-ec: add the mic mute LED Oleg Keri
@ 2026-11-30 13:43 ` Konrad Dybcio
  2026-11-30 13:47 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Konrad Dybcio @ 2026-11-30 13:43 UTC (permalink / raw)
  To: Oleg Keri, hansg, ilpo.jarvinen
  Cc: bryan.odonoghue, platform-driver-x86, linux-arm-msm

On 11/30/26 2:33 PM, Oleg Keri wrote:
> The mic mute key of the Yoga Slim 7x Gen 11 has an indicator LED which
> the EC does not drive on its own. The key press is only reported as an
> event and the LED stays dark.
> 
> The vendor ACPI tables implement the SetFeature method of the Lenovo
> hotkey utility WMI interface (CE6C0974-0407-4F50-88BA-4FC3B6559AD8) for
> this LED by setting or clearing bit 6 of the KBLT byte in the EC RAM,
> the same byte that holds the keyboard backlight level in bits 1:0.
> 
> Expose that bit as the platform::micmute LED with the audio-micmute
> default trigger, and select SND_CTL_LED so that the trigger is available,
> as the ThinkPad T14s EC driver does. The LED is turned off across system
> suspend by the LED core and restored on resume.
> 
> Signed-off-by: Oleg Keri <okerixx@gmail.com>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] platform/arm64: lenovo-yoga-slim7x-gen11-ec: add the mic mute LED
  2026-11-30 13:33 [PATCH] platform/arm64: lenovo-yoga-slim7x-gen11-ec: add the mic mute LED Oleg Keri
  2026-11-30 13:43 ` Konrad Dybcio
@ 2026-11-30 13:47 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2026-11-30 13:47 UTC (permalink / raw)
  To: Oleg Keri, ilpo.jarvinen
  Cc: bryan.odonoghue, platform-driver-x86, linux-arm-msm

Hi,

On 30-Nov-26 14:33, Oleg Keri wrote:
> The mic mute key of the Yoga Slim 7x Gen 11 has an indicator LED which
> the EC does not drive on its own. The key press is only reported as an
> event and the LED stays dark.
> 
> The vendor ACPI tables implement the SetFeature method of the Lenovo
> hotkey utility WMI interface (CE6C0974-0407-4F50-88BA-4FC3B6559AD8) for
> this LED by setting or clearing bit 6 of the KBLT byte in the EC RAM,
> the same byte that holds the keyboard backlight level in bits 1:0.
> 
> Expose that bit as the platform::micmute LED with the audio-micmute
> default trigger, and select SND_CTL_LED so that the trigger is available,
> as the ThinkPad T14s EC driver does. The LED is turned off across system
> suspend by the LED core and restored on resume.
> 
> Signed-off-by: Oleg Keri <okerixx@gmail.com>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>

Regards,

Hans


> ---
>  drivers/platform/arm64/Kconfig                |  5 +-
>  .../arm64/lenovo-yoga-slim7x-gen11-ec.c       | 46 +++++++++++++++++++
>  2 files changed, 49 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/arm64/Kconfig b/drivers/platform/arm64/Kconfig
> index 3f879410b311..0a7054c66705 100644
> --- a/drivers/platform/arm64/Kconfig
> +++ b/drivers/platform/arm64/Kconfig
> @@ -113,12 +113,13 @@ config EC_LENOVO_YOGA_SLIM7X_GEN11
>  	depends on HWMON
>  	select NEW_LEDS
>  	select LEDS_CLASS
> +	select SND_CTL_LED if SND
>  	help
>  	  Say Y here to enable the EC driver for the (Snapdragon X2 Elite,
>  	  glymur-based) Lenovo Yoga Slim 7x Gen 11 laptop. The EC provides
>  	  thermistors and CPU fan speed as hwmon channels, the keyboard
> -	  backlight as an LED, Fn-lock as a sysfs attribute, and the mic-mute
> -	  and airplane-mode keys.
> +	  backlight and the mic-mute indicator as LEDs, Fn-lock as a sysfs
> +	  attribute, and the mic-mute and airplane-mode keys.
>  
>  	  This is the Gen 11 (glymur) machine specifically. Its EC is a Compal
>  	  design at i2c address 0x70 and speaks a different protocol from the
> diff --git a/drivers/platform/arm64/lenovo-yoga-slim7x-gen11-ec.c b/drivers/platform/arm64/lenovo-yoga-slim7x-gen11-ec.c
> index 36dcbff58755..2db46fbf1f75 100644
> --- a/drivers/platform/arm64/lenovo-yoga-slim7x-gen11-ec.c
> +++ b/drivers/platform/arm64/lenovo-yoga-slim7x-gen11-ec.c
> @@ -49,6 +49,7 @@
>  #define SLIM7X11_EC_KBLT_LEVEL	GENMASK(1, 0)
>  #define SLIM7X11_EC_KBLT_AUTO	3
>  #define SLIM7X11_EC_KBLT_MAX	2
> +#define SLIM7X11_EC_KBLT_MIC_MUTE	BIT(6)
>  
>  #define SLIM7X11_EC_TEMP_FIRST	0x12
>  #define SLIM7X11_EC_NUM_TEMP	6
> @@ -60,6 +61,7 @@ struct slim7x11_ec {
>  	struct mutex lock;
>  	unsigned long temp_present;
>  	struct led_classdev kbd_led;
> +	struct led_classdev mic_led;
>  	u8 kblt_level;
>  	bool kblt_restore;
>  	struct input_dev *keys;
> @@ -234,6 +236,39 @@ static int slim7x11_ec_kbd_led_set(struct led_classdev *led, enum led_brightness
>  	return slim7x11_ec_kbd_led_level(ec, brightness, NULL);
>  }
>  
> +static enum led_brightness slim7x11_ec_mic_led_get(struct led_classdev *led)
> +{
> +	struct slim7x11_ec *ec = container_of(led, struct slim7x11_ec, mic_led);
> +	u8 raw;
> +
> +	guard(mutex)(&ec->lock);
> +
> +	if (slim7x11_ec_ram_read(ec, SLIM7X11_EC_KBLT, &raw))
> +		return 0;
> +
> +	return !!(raw & SLIM7X11_EC_KBLT_MIC_MUTE);
> +}
> +
> +static int slim7x11_ec_mic_led_set(struct led_classdev *led, enum led_brightness brightness)
> +{
> +	struct slim7x11_ec *ec = container_of(led, struct slim7x11_ec, mic_led);
> +	u8 raw;
> +	int ret;
> +
> +	guard(mutex)(&ec->lock);
> +
> +	ret = slim7x11_ec_ram_read(ec, SLIM7X11_EC_KBLT, &raw);
> +	if (ret)
> +		return ret;
> +
> +	if (brightness)
> +		raw |= SLIM7X11_EC_KBLT_MIC_MUTE;
> +	else
> +		raw &= ~SLIM7X11_EC_KBLT_MIC_MUTE;
> +
> +	return slim7x11_ec_ram_write(ec, SLIM7X11_EC_KBLT, raw);
> +}
> +
>  static const struct hwmon_ops slim7x11_ec_hwmon_ops = {
>  	.is_visible = slim7x11_ec_is_visible,
>  	.read = slim7x11_ec_read,
> @@ -453,6 +488,17 @@ static int slim7x11_ec_probe(struct i2c_client *client)
>  	if (ret)
>  		return dev_err_probe(dev, ret, "failed to register keyboard backlight\n");
>  
> +	ec->mic_led.name = "platform::micmute";
> +	ec->mic_led.max_brightness = 1;
> +	ec->mic_led.default_trigger = "audio-micmute";
> +	ec->mic_led.flags = LED_CORE_SUSPENDRESUME;
> +	ec->mic_led.brightness_get = slim7x11_ec_mic_led_get;
> +	ec->mic_led.brightness_set_blocking = slim7x11_ec_mic_led_set;
> +
> +	ret = devm_led_classdev_register(dev, &ec->mic_led);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to register the mic mute LED\n");
> +
>  	if (client->irq) {
>  		slim7x11_ec_register_keys(ec);
>  


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-30 13:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 13:33 [PATCH] platform/arm64: lenovo-yoga-slim7x-gen11-ec: add the mic mute LED Oleg Keri
2026-11-30 13:43 ` Konrad Dybcio
2026-11-30 13:47 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox