[PATCH v4 2/2] ASoC: rt715:add micmute led state control supports
Perry Yuan
Perry.Yuan at dell.com
Mon Mar 1 10:38:34 CET 2021
From: Perry Yuan <perry_yuan at dell.com>
Some new Dell system is going to support audio internal micphone
privacy setting from hardware level with micmute led state changing
When micmute hotkey pressed by user, soft mute will need to be enabled
firstly in case of pop noise, and codec driver need to react to mic
mute event to EC(embedded controller) notifying that SW mute is completed
Then EC will do the hardware mute physically within the timeout reached
This patch allow codec rt715 and rt715 sdca driver to change the local micmute
led state. Dell privacy led trigger driver will ack EC when micmute key pressed
through this micphone led control interface like hda_generic provided
ACPI method defined in dell-privacy micmute led trigger will be called
for notifying the EC that software mute has been completed, then hardware
audio circuit solution controlled by EC will switch the audio input source off/on
Signed-off-by: Perry Yuan <perry_yuan at dell.com>
--------
v3 -> v4:
* remove unused debug log
* remove compile flag of DELL privacy
* move the micmute_led to local from rt715_priv
* when Jaroslav upstream his gerneric LED trigger driver,I will rebase
this patch,please consider merge this at first
https://lore.kernel.org/alsa-devel/20210211111400.1131020-1-perex@perex.cz/
v2 -> v3:
* simplify the patch to reuse some val value
* add more detail to the commit info
v1 -> v2:
* fix some format issue
--------
---
sound/soc/codecs/rt715-sdca.c | 12 ++++++++++++
sound/soc/codecs/rt715.c | 12 ++++++++++++
2 files changed, 24 insertions(+)
diff --git a/sound/soc/codecs/rt715-sdca.c b/sound/soc/codecs/rt715-sdca.c
index b43ac8559e45..816348ae11a1 100644
--- a/sound/soc/codecs/rt715-sdca.c
+++ b/sound/soc/codecs/rt715-sdca.c
@@ -12,6 +12,7 @@
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/init.h>
+#include <linux/leds.h>
#include <linux/pm_runtime.h>
#include <linux/pm.h>
#include <linux/soundwire/sdw.h>
@@ -269,6 +270,7 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,
unsigned int reg = mc->reg;
unsigned int max = mc->max;
int err;
+ bool micmute_led;
val = ucontrol->value.integer.value[0];
if (invert)
@@ -287,6 +289,16 @@ static int rt715_sdca_put_volsw(struct snd_kcontrol *kcontrol,
return err;
}
+ /* Micmute LED state changed by muted/unmute switch */
+ if (mc->invert) {
+ if (ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1]) {
+ micmute_led = LED_OFF;
+ } else {
+ micmute_led = LED_ON;
+ }
+ ledtrig_audio_set(LED_AUDIO_MICMUTE, micmute_led);
+ }
+
return 0;
}
diff --git a/sound/soc/codecs/rt715.c b/sound/soc/codecs/rt715.c
index cdcba70146da..db2c0d2ff9d2 100644
--- a/sound/soc/codecs/rt715.c
+++ b/sound/soc/codecs/rt715.c
@@ -13,6 +13,7 @@
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/i2c.h>
+#include <linux/leds.h>
#include <linux/pm_runtime.h>
#include <linux/pm.h>
#include <linux/soundwire/sdw.h>
@@ -88,6 +89,7 @@ static int rt715_set_amp_gain_put(struct snd_kcontrol *kcontrol,
RT715_SET_GAIN_MIX_ADC2_L};
unsigned int addr_h, addr_l, val_h, val_ll, val_lr;
unsigned int read_ll, read_rl, i, j, loop_cnt;
+ bool micmute_led;
if (strstr(ucontrol->id.name, "Main Capture Switch") ||
strstr(ucontrol->id.name, "Main Capture Volume"))
@@ -95,6 +97,16 @@ static int rt715_set_amp_gain_put(struct snd_kcontrol *kcontrol,
else
loop_cnt = 1;
+ /* Micmute LED state changed by muted/unmute switch */
+ if (mc->invert) {
+ if (ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1]) {
+ micmute_led = LED_OFF;
+ } else {
+ micmute_led = LED_ON;
+ }
+ ledtrig_audio_set(LED_AUDIO_MICMUTE, micmute_led);
+ }
+
for (j = 0; j < loop_cnt; j++) {
/* Can't use update bit function, so read the original value first */
if (loop_cnt == 1) {
--
2.25.1
More information about the Alsa-devel
mailing list