Skip to contentSkip to conversation

ASoC: rt712: add mute led control for specific machines

PATCH In review [email protected] 2 participants 2 messages Jul 1

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: rt712: add mute led control for specific machines

From: Shuming Fan <[email protected]>

Certain HP platforms use the RT712 GPIOs to control the microphone mute LED and mute LED. This patch registers LED class devices in the codec driver to control the GPIOs through the LED subsystem.

---
 sound/soc/codecs/rt712-sdca-sdw.h |  3 +
 sound/soc/codecs/rt712-sdca.c     | 91 +++++++++++++++++++++++++++++++
 sound/soc/codecs/rt712-sdca.h     |  3 +
 3 files changed, 97 insertions(+)
sound/soc/codecs/rt712-sdca-sdw.h +3 -0
index 99fd2d67f04d..0f54bbd64f4d 100644
@@ -45,6 +45,9 @@ static const struct reg_default rt712_sdca_mbq_defaults[] = {
 	{ 0x5b00029, 0x3fff },
 	{ 0x5b0002a, 0xf000 },
 	{ 0x6100000, 0x04e4 },
+	{ 0x6100009, 0x0000 },
+	{ 0x610000a, 0x0000 },
+	{ 0x610000b, 0x0020 },
 	{ 0x610000e, 0x0007 },
 	{ 0x6100045, 0x0860 },
 	{ 0x6100046, 0x0029 },
sound/soc/codecs/rt712-sdca.c +91 -0

115 lines not on this page · raw message

sound/soc/codecs/rt712-sdca.h +3 -0
index 7ab7d5feb50a..191225838d4f 100644
@@ -113,6 +113,9 @@ struct rt712_dmic_kctrl_priv {
 #define RT712_HDA_LEGACY_MUX_CTL0			0x00
 #define RT712_HDA_LEGACY_CONFIG_CTL0			0x06
 #define RT712_HDA_LEGACY_RESET_CTL			0x08
+#define RT712_HDA_GPIO_EN_CTL				0x09
+#define RT712_HDA_GPIO_DIRECTION_CTL			0x0a
+#define RT712_HDA_GPIO_SET_CTL				0x0b
 #define RT712_HDA_LEGACY_GPIO_WAKE_EN_CTL		0x0e
 #define RT712_DMIC_ENT_FLOAT_CTL			0x10
 #define RT712_DMIC_GAIN_ENT_FLOAT_CTL0			0x11
Signature · 1 line
2.54.0
maintainer
#1 lore raw
Quoted 6 lines · On Wed, Jul 01, 2026 at 05:05:30PM +0800, [email protected] wrote:

Certain HP platforms use the RT712 GPIOs to control the microphone mute LED and mute LED. This patch registers LED class devices in the codec driver to control the GPIOs through the LED subsystem.

sound/soc/codecs/rt712-sdca.c +1 -0
+#ifdef CONFIG_LEDS_TRIGGERS

sound/soc/codecs/rt712-sdca.c static int rt712_sdca_index_update_bits(struct rt712_sdca_priv *rt712, · line 115

Quoted 10 lines
sound/soc/codecs/rt712-sdca.c +9 -0
+static int rt712_sdca_mute_led_set(struct led_classdev *led_cdev,
+			       enum led_brightness brightness)
+{
 
+	rt712_sdca_index_update_bits(rt712, RT712_VENDOR_HDA_CTL,
+		RT712_HDA_GPIO_EN_CTL, (1 << gpio_pin), (1 << gpio_pin));
+	rt712_sdca_index_update_bits(rt712, RT712_VENDOR_HDA_CTL,
+		RT712_HDA_GPIO_DIRECTION_CTL, (1 << gpio_pin), (1 << gpio_pin));
+	rt712_sdca_index_update_bits(rt712, RT712_VENDOR_HDA_CTL,
+		RT712_HDA_GPIO_SET_CTL, (1 << gpio_pin), (value << gpio_pin));

This all looks like we should register a GPIO and let the LED subsystem GPIO support do the LED glue.

sound/soc/codecs/rt712-sdca.c static int rt712_sdca_index_update_bits(struct rt712_sdca_priv *rt712, · line 143

Quoted 3 lines
sound/soc/codecs/rt712-sdca.c +3 -0
+	for (i = 0; i < NUM_AUDIO_LEDS; i++) {
+		mute_led_cdev[i].trigger_data = (void *)rt712;
+		err = devm_led_classdev_register(rt712->component->dev, &mute_led_cdev[i]);

trigger_data looks like it's for the triggers, and the LED subsystem does overwrite it when configuring triggers.