Skip to contentSkip to conversation

platform/arm64: lenovo-yoga-slim7x-gen11-ec: add the mic mute LED

PATCH In review Oleg Keri 4 participants 4 messages Nov 30 – Dec 1

Subsystems (3)
lore
Share & tools
lore

Oleg Keri

author
#0 lore raw

PATCH 1/1 platform/arm64: lenovo-yoga-slim7x-gen11-ec: add the mic mute LED

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.

---
 drivers/platform/arm64/Kconfig                |  5 +-
 .../arm64/lenovo-yoga-slim7x-gen11-ec.c       | 46 +++++++++++++++++++
 2 files changed, 49 insertions(+), 2 deletions(-)
drivers/platform/arm64/Kconfig +3 -2
index 3f879410b311..0a7054c66705 100644
@@ -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
drivers/platform/arm64/lenovo-yoga-slim7x-gen11-ec.c +46 -0

70 lines not on this page · raw message

Signature · 1 line
2.56.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · 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.

Quoted 7 lines

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.

---

Konrad

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Oleg Keri

Hi,

Quoted 9 lines · 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.

Quoted 6 lines

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.

Thanks, patch looks good to me:

Regards,

Hans

Quoted 103 lines
---
 drivers/platform/arm64/Kconfig                |  5 +-
 .../arm64/lenovo-yoga-slim7x-gen11-ec.c       | 46 +++++++++++++++++++
 2 files changed, 49 insertions(+), 2 deletions(-)
drivers/platform/arm64/Kconfig +3 -2
index 3f879410b311..0a7054c66705 100644
@@ -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
drivers/platform/arm64/lenovo-yoga-slim7x-gen11-ec.c +46 -0
index 36dcbff58755..2db46fbf1f75 100644
@@ -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);
 
maintainer
#3 lore raw
In reply to Oleg Keri
Quoted 10 lines · 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.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.

The list of commits applied:
[1/1] platform/arm64: lenovo-yoga-slim7x-gen11-ec: add the mic mute LED

      commit: 16aec0b7322b118c0877aeb93a2c9cdaf8c66d9c

--
i.