diff mbox series

[8/8] ASoC: sun50i-codec-analog: Enable DAPM for earpiece switch

Message ID 20200217021813.53266-9-samuel@sholland.org (mailing list archive)
State New, archived
Headers show
Series ASoC: sun50i-codec-analog: Cleanup and power management | expand

Commit Message

Samuel Holland Feb. 17, 2020, 2:18 a.m. UTC
By including the earpiece mute switch in the DAPM graph, both the
earpiece amplifier and the Mixer/DAC inputs can be powered off when
the earpiece is muted.

The mute switch is between the source selection and the amplifier,
as per the diagram in the SoC manual.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---
 sound/soc/sunxi/sun50i-codec-analog.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Comments

Chen-Yu Tsai Feb. 17, 2020, 7:33 a.m. UTC | #1
Hi,

On Mon, Feb 17, 2020 at 10:18 AM Samuel Holland <samuel@sholland.org> wrote:
>
> By including the earpiece mute switch in the DAPM graph, both the
> earpiece amplifier and the Mixer/DAC inputs can be powered off when
> the earpiece is muted.
>
> The mute switch is between the source selection and the amplifier,
> as per the diagram in the SoC manual.
>
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
>  sound/soc/sunxi/sun50i-codec-analog.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/sound/soc/sunxi/sun50i-codec-analog.c b/sound/soc/sunxi/sun50i-codec-analog.c
> index 84bb76cad74f..6c89b0716bbd 100644
> --- a/sound/soc/sunxi/sun50i-codec-analog.c
> +++ b/sound/soc/sunxi/sun50i-codec-analog.c
> @@ -232,11 +232,6 @@ static const struct snd_kcontrol_new sun50i_a64_codec_controls[] = {
>                        SUN50I_ADDA_EARPIECE_CTRL1,
>                        SUN50I_ADDA_EARPIECE_CTRL1_ESP_VOL, 0x1f, 0,
>                        sun50i_codec_earpiece_vol_scale),
> -
> -       SOC_SINGLE("Earpiece Playback Switch",
> -                  SUN50I_ADDA_EARPIECE_CTRL1,
> -                  SUN50I_ADDA_EARPIECE_CTRL1_ESPPA_MUTE, 1, 0),
> -
>  };
>
>  static const char * const sun50i_codec_hp_src_enum_text[] = {
> @@ -295,6 +290,11 @@ static const struct snd_kcontrol_new sun50i_codec_earpiece_src[] = {
>                       sun50i_codec_earpiece_src_enum),
>  };
>
> +static const struct snd_kcontrol_new sun50i_codec_earpiece_switch =
> +       SOC_DAPM_SINGLE("Playback Switch",
> +                       SUN50I_ADDA_EARPIECE_CTRL1,
> +                       SUN50I_ADDA_EARPIECE_CTRL1_ESPPA_MUTE, 1, 0);
> +
>  static const struct snd_soc_dapm_widget sun50i_a64_codec_widgets[] = {
>         /* DAC */
>         SND_SOC_DAPM_DAC("Left DAC", NULL, SUN50I_ADDA_MIX_DAC_CTRL,
> @@ -341,6 +341,8 @@ static const struct snd_soc_dapm_widget sun50i_a64_codec_widgets[] = {
>
>         SND_SOC_DAPM_MUX("Earpiece Source Playback Route",
>                          SND_SOC_NOPM, 0, 0, sun50i_codec_earpiece_src),
> +       SND_SOC_DAPM_SWITCH("Earpiece",
> +                           SND_SOC_NOPM, 0, 0, &sun50i_codec_earpiece_switch),

I would suggest naming this something a bit more specific, in case someone
uses "Earpiece" as a widget name at the board level. Also, having the
"Earpiece" come before the "Earpiece Amp" in the route doesn't make much
sense. However, this creates an issue with the name of the created kcontrol...
Any other ideas?

ChenYu


>         SND_SOC_DAPM_OUT_DRV("Earpiece Amp", SUN50I_ADDA_EARPIECE_CTRL1,
>                              SUN50I_ADDA_EARPIECE_CTRL1_ESPPA_EN, 0, NULL, 0),
>         SND_SOC_DAPM_OUTPUT("EARPIECE"),
> @@ -462,7 +464,8 @@ static const struct snd_soc_dapm_route sun50i_a64_codec_routes[] = {
>         { "Earpiece Source Playback Route", "DACR", "Right DAC" },
>         { "Earpiece Source Playback Route", "Left Mixer", "Left Mixer" },
>         { "Earpiece Source Playback Route", "Right Mixer", "Right Mixer" },
> -       { "Earpiece Amp", NULL, "Earpiece Source Playback Route" },
> +       { "Earpiece", "Playback Switch", "Earpiece Source Playback Route" },
> +       { "Earpiece Amp", NULL, "Earpiece" },
>         { "EARPIECE", NULL, "Earpiece Amp" },
>  };
>
> --
> 2.24.1
>
diff mbox series

Patch

diff --git a/sound/soc/sunxi/sun50i-codec-analog.c b/sound/soc/sunxi/sun50i-codec-analog.c
index 84bb76cad74f..6c89b0716bbd 100644
--- a/sound/soc/sunxi/sun50i-codec-analog.c
+++ b/sound/soc/sunxi/sun50i-codec-analog.c
@@ -232,11 +232,6 @@  static const struct snd_kcontrol_new sun50i_a64_codec_controls[] = {
 		       SUN50I_ADDA_EARPIECE_CTRL1,
 		       SUN50I_ADDA_EARPIECE_CTRL1_ESP_VOL, 0x1f, 0,
 		       sun50i_codec_earpiece_vol_scale),
-
-	SOC_SINGLE("Earpiece Playback Switch",
-		   SUN50I_ADDA_EARPIECE_CTRL1,
-		   SUN50I_ADDA_EARPIECE_CTRL1_ESPPA_MUTE, 1, 0),
-
 };
 
 static const char * const sun50i_codec_hp_src_enum_text[] = {
@@ -295,6 +290,11 @@  static const struct snd_kcontrol_new sun50i_codec_earpiece_src[] = {
 		      sun50i_codec_earpiece_src_enum),
 };
 
+static const struct snd_kcontrol_new sun50i_codec_earpiece_switch =
+	SOC_DAPM_SINGLE("Playback Switch",
+			SUN50I_ADDA_EARPIECE_CTRL1,
+			SUN50I_ADDA_EARPIECE_CTRL1_ESPPA_MUTE, 1, 0);
+
 static const struct snd_soc_dapm_widget sun50i_a64_codec_widgets[] = {
 	/* DAC */
 	SND_SOC_DAPM_DAC("Left DAC", NULL, SUN50I_ADDA_MIX_DAC_CTRL,
@@ -341,6 +341,8 @@  static const struct snd_soc_dapm_widget sun50i_a64_codec_widgets[] = {
 
 	SND_SOC_DAPM_MUX("Earpiece Source Playback Route",
 			 SND_SOC_NOPM, 0, 0, sun50i_codec_earpiece_src),
+	SND_SOC_DAPM_SWITCH("Earpiece",
+			    SND_SOC_NOPM, 0, 0, &sun50i_codec_earpiece_switch),
 	SND_SOC_DAPM_OUT_DRV("Earpiece Amp", SUN50I_ADDA_EARPIECE_CTRL1,
 			     SUN50I_ADDA_EARPIECE_CTRL1_ESPPA_EN, 0, NULL, 0),
 	SND_SOC_DAPM_OUTPUT("EARPIECE"),
@@ -462,7 +464,8 @@  static const struct snd_soc_dapm_route sun50i_a64_codec_routes[] = {
 	{ "Earpiece Source Playback Route", "DACR", "Right DAC" },
 	{ "Earpiece Source Playback Route", "Left Mixer", "Left Mixer" },
 	{ "Earpiece Source Playback Route", "Right Mixer", "Right Mixer" },
-	{ "Earpiece Amp", NULL, "Earpiece Source Playback Route" },
+	{ "Earpiece", "Playback Switch", "Earpiece Source Playback Route" },
+	{ "Earpiece Amp", NULL, "Earpiece" },
 	{ "EARPIECE", NULL, "Earpiece Amp" },
 };