From: Perry Yuan <Perry.Yuan@dell.com>
To: oder_chiou@realtek.com, lgirdwood@gmail.com, broonie@kernel.org,
perex@perex.cz, tiwai@suse.com
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
perry_yuan <Perry.Yuan@dell.com>,
Limonciello Mario <Mario.Limonciello@dell.com>
Subject: [PATCH] ASoC: rt715:add Mic Mute LED control support
Date: Tue, 3 Nov 2020 04:58:59 -0800 [thread overview]
Message-ID: <20201103125859.8759-1-Perry_Yuan@Dell.com> (raw)
From: perry_yuan <perry_yuan@dell.com>
Some new Dell system is going to support audio internal micphone
privacy setting from hardware level with micmute led state changing
This patch allow to change micmute led state through this micphone
led control interface like hda_generic provided.
Signed-off-by: Perry Yuan <perry_yuan@dell.com>
Signed-off-by: Limonciello Mario <mario_limonciello@dell.com>
---
sound/soc/codecs/rt715.c | 43 ++++++++++++++++++++++++++++++++++++++++
sound/soc/codecs/rt715.h | 1 +
2 files changed, 44 insertions(+)
diff --git a/sound/soc/codecs/rt715.c b/sound/soc/codecs/rt715.c
index 099c8bd20006..2df2895d0092 100644
--- a/sound/soc/codecs/rt715.c
+++ b/sound/soc/codecs/rt715.c
@@ -26,6 +26,7 @@
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_device.h>
+#include <linux/leds.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@@ -213,6 +214,45 @@ static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, 0, 1000, 0);
.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
xmax, xinvert) }
+static const char *rt715_micmute_led_mode[] = {
+ "Off", "On"
+};
+
+static const struct soc_enum rt715_micmute_led_mode_enum =
+ SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rt715_micmute_led_mode),
+ rt715_micmute_led_mode);
+
+static int rt715_mic_mute_led_mode_get(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
+ struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component);
+ int led_mode = rt715->micmute_led;
+
+ ucontrol->value.integer.value[0] = led_mode;
+#if IS_ENABLED(CONFIG_LEDS_TRIGGER_AUDIO)
+ ledtrig_audio_set(LED_AUDIO_MICMUTE,
+ rt715->micmute_led ? LED_ON : LED_OFF);
+#endif
+ return 0;
+}
+
+static int rt715_micmute_led_mode_put(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
+ struct rt715_priv *rt715 = snd_soc_component_get_drvdata(component);
+ int led_mode = ucontrol->value.integer.value[0];
+
+ rt715->micmute_led = led_mode;
+#if IS_ENABLED(CONFIG_LEDS_TRIGGER_AUDIO)
+ ledtrig_audio_set(LED_AUDIO_MICMUTE,
+ rt715->micmute_led ? LED_ON : LED_OFF);
+#endif
+ return 0;
+}
+
+
static const struct snd_kcontrol_new rt715_snd_controls[] = {
/* Capture switch */
SOC_DOUBLE_R_EXT("ADC 07 Capture Switch", RT715_SET_GAIN_MIC_ADC_H,
@@ -277,6 +317,9 @@ static const struct snd_kcontrol_new rt715_snd_controls[] = {
RT715_SET_GAIN_LINE2_L, RT715_DIR_IN_SFT, 3, 0,
rt715_set_amp_gain_get, rt715_set_amp_gain_put,
mic_vol_tlv),
+ /*Micmute Led Control*/
+ SOC_ENUM_EXT("Micmute Led Mode", rt715_micmute_led_mode_enum,
+ rt715_mic_mute_led_mode_get, rt715_micmute_led_mode_put),
};
static int rt715_mux_get(struct snd_kcontrol *kcontrol,
diff --git a/sound/soc/codecs/rt715.h b/sound/soc/codecs/rt715.h
index df0f24f9bc0c..32917b7846b4 100644
--- a/sound/soc/codecs/rt715.h
+++ b/sound/soc/codecs/rt715.h
@@ -22,6 +22,7 @@ struct rt715_priv {
struct sdw_bus_params params;
bool hw_init;
bool first_hw_init;
+ int micmute_led;
};
struct sdw_stream_data {
--
2.25.1
next reply other threads:[~2020-11-03 12:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 12:58 Perry Yuan [this message]
2020-11-03 13:12 ` Mark Brown
2020-11-03 16:13 ` Pierre-Louis Bossart
2020-11-03 17:51 ` Limonciello, Mario
2020-11-03 17:59 ` Mark Brown
2020-11-03 18:04 ` Limonciello, Mario
2020-11-03 18:31 ` Mark Brown
2020-11-03 19:01 ` Limonciello, Mario
2020-11-03 18:35 ` Pierre-Louis Bossart
2020-11-03 19:03 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201103125859.8759-1-Perry_Yuan@Dell.com \
--to=perry.yuan@dell.com \
--cc=Mario.Limonciello@dell.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oder_chiou@realtek.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®