Skip to contentSkip to conversation

ASoC: rt5682s: Add dapm switch to mute/unmute HP playback output

PATCH In review Ajit Kumar Pandey 4 participants 6 messages Dec 8, 2021 – Dec 17, 2021

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

v2 cover ASoC: rt5682s: Add dapm switch to mute/unmute HP playback output

changes since v1:
- Fix typo in commit description

Ajit Kumar Pandey (1):
ASoC: rt5682s: Add dapm switch to mute/unmute HP playback output

 sound/soc/codecs/rt5682s.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/1 ASoC: rt5682s: Add dapm switch to mute/unmute HP playback output

Add dapm switch in playback path to mute or unmute HP output data. We will set and reset MUTE_SFT bit in RT5682S_HP_CTRL_1 register based on switch value to mute or unmute respective channel.

---
 sound/soc/codecs/rt5682s.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
sound/soc/codecs/rt5682s.c +17 -2
index d49a4f68566d..21ab5f7df422 100644
@@ -1573,6 +1573,14 @@ static const char * const rt5682s_adcdat_pin_select[] = {
 	"ADCDAT1", "ADCDAT2",
 };
 
+/* Out Switch */
+static const struct snd_kcontrol_new hpol_switch =
+	SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5682S_HP_CTRL_1,
+		RT5682S_L_MUTE_SFT, 1, 1);
+static const struct snd_kcontrol_new hpor_switch =
+	SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5682S_HP_CTRL_1,
+		RT5682S_R_MUTE_SFT, 1, 1);
+
 static SOC_VALUE_ENUM_SINGLE_DECL(rt5682s_adcdat_pin_enum,
 	RT5682S_GPIO_CTRL_1, RT5682S_GP4_PIN_SFT, RT5682S_GP4_PIN_MASK,
 	rt5682s_adcdat_pin_select, rt5682s_adcdat_pin_values);
@@ -1746,6 +1754,11 @@ static const struct snd_soc_dapm_widget rt5682s_dapm_widgets[] = {
 	SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0, rt5682s_hp_amp_event,
 		SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU),
 
+	SND_SOC_DAPM_SWITCH("HPOL Playback", SND_SOC_NOPM, 0, 0,
+		&hpol_switch),
+	SND_SOC_DAPM_SWITCH("HPOR Playback", SND_SOC_NOPM, 0, 0,
+		&hpor_switch),
+
 	/* CLK DET */
 	SND_SOC_DAPM_SUPPLY("CLKDET SYS", RT5682S_CLK_DET,
 		RT5682S_SYS_CLK_DET_SFT, 0, NULL, 0),
@@ -1895,8 +1908,10 @@ static const struct snd_soc_dapm_route rt5682s_dapm_routes[] = {
 	{"HP Amp", NULL, "CLKDET SYS"},
 	{"HP Amp", NULL, "SAR"},
 
-	{"HPOL", NULL, "HP Amp"},
-	{"HPOR", NULL, "HP Amp"},
+	{"HPOL Playback", "Switch", "HP Amp"},
+	{"HPOR Playback", "Switch", "HP Amp"},
+	{"HPOL", NULL, "HPOL Playback"},
+	{"HPOR", NULL, "HPOR Playback"},
 };
 
 static int rt5682s_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
Signature · 1 line
2.25.1
#2 lore raw
Quoted 48 lines

Subject: [PATCH v2 1/1] ASoC: rt5682s: Add dapm switch to mute/unmute HP playback output

Add dapm switch in playback path to mute or unmute HP output data. We will set and reset MUTE_SFT bit in RT5682S_HP_CTRL_1 register based on switch value to mute or unmute respective channel.

---
 sound/soc/codecs/rt5682s.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
sound/soc/codecs/rt5682s.c index renamed from sound/soc/codecs/rt5682s.c +0 -0

d49a4f68566d..21ab5f7df422 100644

sound/soc/codecs/rt5682s.c +8 -0
@@ -1573,6 +1573,14 @@ static const char * const
 rt5682s_adcdat_pin_select[] = {
 	"ADCDAT1", "ADCDAT2",
 };
 
+/* Out Switch */
+static const struct snd_kcontrol_new hpol_switch =
+	SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5682S_HP_CTRL_1,
+		RT5682S_L_MUTE_SFT, 1, 1);
+static const struct snd_kcontrol_new hpor_switch =
+	SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5682S_HP_CTRL_1,
+		RT5682S_R_MUTE_SFT, 1, 1);
+
 static SOC_VALUE_ENUM_SINGLE_DECL(rt5682s_adcdat_pin_enum,
 	RT5682S_GPIO_CTRL_1, RT5682S_GP4_PIN_SFT,

RT5682S_GP4_PIN_MASK,
rt5682s_adcdat_pin_select, rt5682s_adcdat_pin_values); @@ -1746,6
+1754,11 @@ static const struct snd_soc_dapm_widget rt5682s_dapm_widgets[] = {
SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0,
rt5682s_hp_amp_event,

sound/soc/codecs/rt5682s.c +5 -0
 		SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU),
 
+	SND_SOC_DAPM_SWITCH("HPOL Playback", SND_SOC_NOPM, 0, 0,
+		&hpol_switch),
+	SND_SOC_DAPM_SWITCH("HPOR Playback", SND_SOC_NOPM, 0, 0,
+		&hpor_switch),
+
 	/* CLK DET */
 	SND_SOC_DAPM_SUPPLY("CLKDET SYS", RT5682S_CLK_DET,
 		RT5682S_SYS_CLK_DET_SFT, 0, NULL, 0), @@ -1895,8 +1908,10 @@

static const struct snd_soc_dapm_route rt5682s_dapm_routes[] = {

sound/soc/codecs/rt5682s.c static const struct snd_soc_dapm_route rt5682s_dapm_routes[] = { · line 1915

Quoted 10 lines
sound/soc/codecs/rt5682s.c +4 -2
 	{"HP Amp", NULL, "CLKDET SYS"},
 	{"HP Amp", NULL, "SAR"},
 
-	{"HPOL", NULL, "HP Amp"},
-	{"HPOR", NULL, "HP Amp"},
+	{"HPOL Playback", "Switch", "HP Amp"},
+	{"HPOR Playback", "Switch", "HP Amp"},
+	{"HPOL", NULL, "HPOL Playback"},
+	{"HPOR", NULL, "HPOR Playback"},
 };

RT5682S enables the 1 bit control for HP output.
Therefore, the setting of RT5682S_HP_CTRL_1[15][7] will be not effective.

#3 lore raw
Quoted 53 lines · Shuming [范書銘]

[CAUTION: External Email]

Quoted 51 lines

Subject: [PATCH v2 1/1] ASoC: rt5682s: Add dapm switch to mute/unmute HP playback output

Add dapm switch in playback path to mute or unmute HP output data. We will set and reset MUTE_SFT bit in RT5682S_HP_CTRL_1 register based on switch value to mute or unmute respective channel.

---
  sound/soc/codecs/rt5682s.c | 19 +++++++++++++++++--
  1 file changed, 17 insertions(+), 2 deletions(-)
sound/soc/codecs/rt5682s.c index renamed from sound/soc/codecs/rt5682s.c +0 -0

d49a4f68566d..21ab5f7df422 100644

sound/soc/codecs/rt5682s.c +8 -0
@@ -1573,6 +1573,14 @@ static const char * const
 rt5682s_adcdat_pin_select[] = {
       "ADCDAT1", "ADCDAT2",
  };
 
+/* Out Switch */
+static const struct snd_kcontrol_new hpol_switch =
+     SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5682S_HP_CTRL_1,
+             RT5682S_L_MUTE_SFT, 1, 1);
+static const struct snd_kcontrol_new hpor_switch =
+     SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5682S_HP_CTRL_1,
+             RT5682S_R_MUTE_SFT, 1, 1);
+
  static SOC_VALUE_ENUM_SINGLE_DECL(rt5682s_adcdat_pin_enum,
       RT5682S_GPIO_CTRL_1, RT5682S_GP4_PIN_SFT,

RT5682S_GP4_PIN_MASK,

       rt5682s_adcdat_pin_select, rt5682s_adcdat_pin_values); @@ -1746,6
+1754,11 @@ static const struct snd_soc_dapm_widget
rt5682s_dapm_widgets[] = {
       SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0,

rt5682s_hp_amp_event,
SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU),

sound/soc/codecs/rt5682s.c +5 -0
+     SND_SOC_DAPM_SWITCH("HPOL Playback", SND_SOC_NOPM, 0, 0,
+             &hpol_switch),
+     SND_SOC_DAPM_SWITCH("HPOR Playback", SND_SOC_NOPM, 0, 0,
+             &hpor_switch),
+
       /* CLK DET */
       SND_SOC_DAPM_SUPPLY("CLKDET SYS", RT5682S_CLK_DET,
               RT5682S_SYS_CLK_DET_SFT, 0, NULL, 0), @@ -1895,8 +1908,10 @@
static const struct snd_soc_dapm_route rt5682s_dapm_routes[] = {
       {"HP Amp", NULL, "CLKDET SYS"},
       {"HP Amp", NULL, "SAR"},
Quoted 12 lines

sound/soc/codecs/rt5682s.c static const struct snd_soc_dapm_route rt5682s_dapm_routes[] = { · line 1915

Quoted 7 lines
sound/soc/codecs/rt5682s.c +4 -2
-     {"HPOL", NULL, "HP Amp"},
-     {"HPOR", NULL, "HP Amp"},
+     {"HPOL Playback", "Switch", "HP Amp"},
+     {"HPOR Playback", "Switch", "HP Amp"},
+     {"HPOL", NULL, "HPOL Playback"},
+     {"HPOR", NULL, "HPOR Playback"},
  };

RT5682S enables the 1 bit control for HP output.
Therefore, the setting of RT5682S_HP_CTRL_1[15][7] will be not effective.

Ok, it was actually effective and muted audio when we test in our platform, possible because i'm tearing down dapm path based on switch value. If we don't have register bits available to mute i'll resubmit the change with virtual switch widget to disable DAPM and stop audio.

#4 lore raw
Quoted 68 lines

Subject: Re: [PATCH v2 1/1] ASoC: rt5682s: Add dapm switch to mute/unmute HP playback output

Quoted 23 lines · Shuming [范書銘]

[CAUTION: External Email]

Quoted 21 lines

Subject: [PATCH v2 1/1] ASoC: rt5682s: Add dapm switch to mute/unmute HP playback output

Add dapm switch in playback path to mute or unmute HP output data. We will set and reset MUTE_SFT bit in RT5682S_HP_CTRL_1 register based on switch value to mute or unmute respective channel.

---
  sound/soc/codecs/rt5682s.c | 19 +++++++++++++++++--
  1 file changed, 17 insertions(+), 2 deletions(-)
sound/soc/codecs/rt5682s.c index renamed from sound/soc/codecs/rt5682s.c +0 -0

d49a4f68566d..21ab5f7df422 100644

sound/soc/codecs/rt5682s.c +0 -0
@@ -1573,6 +1573,14 @@ static const char * const
 rt5682s_adcdat_pin_select[] = {
       "ADCDAT1", "ADCDAT2",
  };
 
Quoted 12 lines
Quoted 11 lines
sound/soc/codecs/rt5682s.c +8 -0
+/* Out Switch */
+static const struct snd_kcontrol_new hpol_switch =
+     SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5682S_HP_CTRL_1,
+             RT5682S_L_MUTE_SFT, 1, 1);
+static const struct snd_kcontrol_new hpor_switch =
+     SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5682S_HP_CTRL_1,
+             RT5682S_R_MUTE_SFT, 1, 1);
+
  static SOC_VALUE_ENUM_SINGLE_DECL(rt5682s_adcdat_pin_enum,
       RT5682S_GPIO_CTRL_1, RT5682S_GP4_PIN_SFT,

RT5682S_GP4_PIN_MASK,

Quoted 1 line
       rt5682s_adcdat_pin_select, rt5682s_adcdat_pin_values); @@

-1746,6

Quoted 5 lines
Quoted 5 lines

+1754,11 @@ static const struct snd_soc_dapm_widget

rt5682s_dapm_widgets[] = {
       SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0,

rt5682s_hp_amp_event,
SND_SOC_DAPM_POST_PMD |

SND_SOC_DAPM_POST_PMU),

Quoted 9 lines

sound/soc/codecs/rt5682s.c static const struct snd_soc_dapm_widget rt5682s_dapm_widgets[] = {

Quoted 9 lines
sound/soc/codecs/rt5682s.c +5 -0
+     SND_SOC_DAPM_SWITCH("HPOL Playback", SND_SOC_NOPM, 0, 0,
+             &hpol_switch),
+     SND_SOC_DAPM_SWITCH("HPOR Playback", SND_SOC_NOPM, 0, 0,
+             &hpor_switch),
+
       /* CLK DET */
       SND_SOC_DAPM_SUPPLY("CLKDET SYS", RT5682S_CLK_DET,
               RT5682S_SYS_CLK_DET_SFT, 0, NULL, 0), @@ -1895,8

+1908,10 @@

Quoted 12 lines
Quoted 11 lines
static const struct snd_soc_dapm_route rt5682s_dapm_routes[] = {
       {"HP Amp", NULL, "CLKDET SYS"},
       {"HP Amp", NULL, "SAR"},
sound/soc/codecs/rt5682s.c +4 -2
-     {"HPOL", NULL, "HP Amp"},
-     {"HPOR", NULL, "HP Amp"},
+     {"HPOL Playback", "Switch", "HP Amp"},
+     {"HPOR Playback", "Switch", "HP Amp"},
+     {"HPOL", NULL, "HPOL Playback"},
+     {"HPOR", NULL, "HPOR Playback"},
  };
Quoted 9 lines
Quoted 4 lines

RT5682S enables the 1 bit control for HP output.
Therefore, the setting of RT5682S_HP_CTRL_1[15][7] will be not effective.

Ok, it was actually effective and muted audio when we test in our platform, possible because i'm tearing down dapm path based on switch value. If we don't have register bits available to mute i'll resubmit the change with virtual switch widget to disable DAPM and stop audio.

What purpose do you want to add an additional switch to power up/down the dapm in the codec driver instead of using existing controls? And we thought the virtual switch you talked about could be implemented in the machine driver.

maintainer
#5 lore raw
In reply to Ajit Kumar Pandey
Quoted 2 lines · Ajit Kumar Pandey

changes since v1:
- Fix typo in commit description

Please don't send cover letters for single patches, if there is anything that needs saying put it in the changelog of the patch or after the --- if it's administrative stuff. This reduces mail volume and ensures that any important information is recorded in the changelog rather than being lost.