[v14,3/8] ASoC: sun4i-codec: Merge sun4i_codec_left_mixer_controls and sun4i_codec_right_mixer_controls into sun4i_codec_mixer_controls
diff mbox

Message ID 20180502210800.1971-4-dannym@scratchpost.org
State New
Headers show

Commit Message

Danny Milosavljevic May 2, 2018, 9:07 p.m. UTC
Since it's now possible to have a DAPM mixer control with multiple channels,
use it to cut down the total number of controls.

Keep "Left Mixer Left DAC Playback Switch" and "Right Mixer Right DAC Playback
Switch" name & layout the same as before for compatibility.

Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
---
 sound/soc/sunxi/sun4i-codec.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

Comments

Maxime Ripard May 3, 2018, 2:46 p.m. UTC | #1
On Wed, May 02, 2018 at 11:07:55PM +0200, Danny Milosavljevic wrote:
> Since it's now possible to have a DAPM mixer control with multiple channels,
> use it to cut down the total number of controls.
> 
> Keep "Left Mixer Left DAC Playback Switch" and "Right Mixer Right DAC Playback
> Switch" name & layout the same as before for compatibility.
> 
> Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
> ---
>  sound/soc/sunxi/sun4i-codec.c | 32 ++++++++++++++++----------------
>  1 file changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
> index 4af286f44a67..b62af407967f 100644
> --- a/sound/soc/sunxi/sun4i-codec.c
> +++ b/sound/soc/sunxi/sun4i-codec.c
> @@ -715,15 +715,15 @@ static const struct snd_kcontrol_new sun7i_codec_extra_controls[] = {
>  		       sun7i_codec_micin_preamp_gain_scale),
>  };
>  
> -static const struct snd_kcontrol_new sun4i_codec_left_mixer_controls[] = {
> -	SOC_DAPM_SINGLE("Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL,
> -			SUN4I_CODEC_DAC_ACTL_LDACLMIXS, 1, 0),
> -};
> -
> -static const struct snd_kcontrol_new sun4i_codec_right_mixer_controls[] = {
> -	SOC_DAPM_SINGLE("Right DAC Playback Switch", SUN4I_CODEC_DAC_ACTL,
> -			SUN4I_CODEC_DAC_ACTL_RDACRMIXS, 1, 0),
> -	SOC_DAPM_SINGLE("Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL,
> +static const struct snd_kcontrol_new sun4i_codec_mixer_controls[] = {
> +	SOC_DAPM_SINGLE("Left Mixer Left DAC Playback Switch",
> +			SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_LDACLMIXS,
> +			1, 0),
> +	SOC_DAPM_SINGLE("Right Mixer Right DAC Playback Switch",
> +			SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_RDACRMIXS,
> +			1, 0),
> +	SOC_DAPM_SINGLE("Right Mixer Left DAC Playback Switch",
> +			SUN4I_CODEC_DAC_ACTL,
>  			SUN4I_CODEC_DAC_ACTL_LDACRMIXS, 1, 0),
>  };
>  
> @@ -759,11 +759,11 @@ static const struct snd_soc_dapm_widget sun4i_codec_codec_dapm_widgets[] = {
>  
>  	/* Mixers */
>  	SND_SOC_DAPM_MIXER("Left Mixer", SND_SOC_NOPM, 0, 0,
> -			   sun4i_codec_left_mixer_controls,
> -			   ARRAY_SIZE(sun4i_codec_left_mixer_controls)),
> +			   sun4i_codec_mixer_controls,
> +			   ARRAY_SIZE(sun4i_codec_mixer_controls)),
>  	SND_SOC_DAPM_MIXER("Right Mixer", SND_SOC_NOPM, 0, 0,
> -			   sun4i_codec_right_mixer_controls,
> -			   ARRAY_SIZE(sun4i_codec_right_mixer_controls)),
> +			   sun4i_codec_mixer_controls,
> +			   ARRAY_SIZE(sun4i_codec_mixer_controls)),

Doesn't that mean that the controls will be shared between the right
and left mixers now, which wasn't the case before? And also, wouldn't
the controls be called "Left Mixer Left Mixer Left DAC Playback
Switch" (for the first one) now?
Danny Milosavljevic May 5, 2018, 6:51 a.m. UTC | #2
Hi Maxime,

On Thu, 3 May 2018 16:46:19 +0200
Maxime Ripard <maxime.ripard@bootlin.com> wrote:

> Doesn't that mean that the controls will be shared between the right
> and left mixers now, which wasn't the case before?

Yes.  However Chen-Yu said that except for debugfs that cannot be
observed by user space anyway.

It's nice to have the NEW controls have multiple channels, which is what
this does.

>And also, wouldn't
> the controls be called "Left Mixer Left Mixer Left DAC Playback
> Switch" (for the first one) now?

No.  I checked using "amixer" - the names look fine,
"Left Mixer Left DAC Playback Switch".

With the patch series, amixer says:

numid=10,iface=MIXER,name='FM Playback Switch'
numid=6,iface=MIXER,name='FM Playback Volume'
numid=5,iface=MIXER,name='Line Boost Volume'
numid=9,iface=MIXER,name='Line Playback Switch'
numid=4,iface=MIXER,name='Line Playback Volume'
numid=1,iface=MIXER,name='Mic1 Boost Volume'
numid=11,iface=MIXER,name='Mic1 Playback Switch'
numid=2,iface=MIXER,name='Mic2 Boost Volume'
numid=12,iface=MIXER,name='Mic2 Playback Switch'
numid=7,iface=MIXER,name='Mic Playback Volume'
numid=18,iface=MIXER,name='Capture Source'
numid=19,iface=MIXER,name='Differential Line Source'
numid=8,iface=MIXER,name='Left Mixer Left DAC Playback Switch'
numid=15,iface=MIXER,name='Power Amplifier DAC Playback Switch'
numid=16,iface=MIXER,name='Power Amplifier Mixer Playback Switch'
numid=17,iface=MIXER,name='Power Amplifier Mute Switch'
numid=3,iface=MIXER,name='Power Amplifier Volume'
numid=14,iface=MIXER,name='Right Mixer Left DAC Playback Switch'
numid=13,iface=MIXER,name='Right Mixer Right DAC Playback Switch'
Maxime Ripard May 14, 2018, 2:06 p.m. UTC | #3
On Sat, May 05, 2018 at 08:51:43AM +0200, Danny Milosavljevic wrote:
> Hi Maxime,
> 
> On Thu, 3 May 2018 16:46:19 +0200
> Maxime Ripard <maxime.ripard@bootlin.com> wrote:
> 
> > Doesn't that mean that the controls will be shared between the right
> > and left mixers now, which wasn't the case before?
> 
> Yes.  However Chen-Yu said that except for debugfs that cannot be
> observed by user space anyway.
> 
> It's nice to have the NEW controls have multiple channels, which is what
> this does.
> 
> >And also, wouldn't
> > the controls be called "Left Mixer Left Mixer Left DAC Playback
> > Switch" (for the first one) now?
> 
> No.  I checked using "amixer" - the names look fine,
> "Left Mixer Left DAC Playback Switch".
> 
> With the patch series, amixer says:
> 
> numid=10,iface=MIXER,name='FM Playback Switch'
> numid=6,iface=MIXER,name='FM Playback Volume'
> numid=5,iface=MIXER,name='Line Boost Volume'
> numid=9,iface=MIXER,name='Line Playback Switch'
> numid=4,iface=MIXER,name='Line Playback Volume'
> numid=1,iface=MIXER,name='Mic1 Boost Volume'
> numid=11,iface=MIXER,name='Mic1 Playback Switch'
> numid=2,iface=MIXER,name='Mic2 Boost Volume'
> numid=12,iface=MIXER,name='Mic2 Playback Switch'
> numid=7,iface=MIXER,name='Mic Playback Volume'
> numid=18,iface=MIXER,name='Capture Source'
> numid=19,iface=MIXER,name='Differential Line Source'
> numid=8,iface=MIXER,name='Left Mixer Left DAC Playback Switch'
> numid=15,iface=MIXER,name='Power Amplifier DAC Playback Switch'
> numid=16,iface=MIXER,name='Power Amplifier Mixer Playback Switch'
> numid=17,iface=MIXER,name='Power Amplifier Mute Switch'
> numid=3,iface=MIXER,name='Power Amplifier Volume'
> numid=14,iface=MIXER,name='Right Mixer Left DAC Playback Switch'
> numid=13,iface=MIXER,name='Right Mixer Right DAC Playback Switch'

Great then :)

Maxime

Patch
diff mbox

diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index 4af286f44a67..b62af407967f 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -715,15 +715,15 @@  static const struct snd_kcontrol_new sun7i_codec_extra_controls[] = {
 		       sun7i_codec_micin_preamp_gain_scale),
 };
 
-static const struct snd_kcontrol_new sun4i_codec_left_mixer_controls[] = {
-	SOC_DAPM_SINGLE("Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL,
-			SUN4I_CODEC_DAC_ACTL_LDACLMIXS, 1, 0),
-};
-
-static const struct snd_kcontrol_new sun4i_codec_right_mixer_controls[] = {
-	SOC_DAPM_SINGLE("Right DAC Playback Switch", SUN4I_CODEC_DAC_ACTL,
-			SUN4I_CODEC_DAC_ACTL_RDACRMIXS, 1, 0),
-	SOC_DAPM_SINGLE("Left DAC Playback Switch", SUN4I_CODEC_DAC_ACTL,
+static const struct snd_kcontrol_new sun4i_codec_mixer_controls[] = {
+	SOC_DAPM_SINGLE("Left Mixer Left DAC Playback Switch",
+			SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_LDACLMIXS,
+			1, 0),
+	SOC_DAPM_SINGLE("Right Mixer Right DAC Playback Switch",
+			SUN4I_CODEC_DAC_ACTL, SUN4I_CODEC_DAC_ACTL_RDACRMIXS,
+			1, 0),
+	SOC_DAPM_SINGLE("Right Mixer Left DAC Playback Switch",
+			SUN4I_CODEC_DAC_ACTL,
 			SUN4I_CODEC_DAC_ACTL_LDACRMIXS, 1, 0),
 };
 
@@ -759,11 +759,11 @@  static const struct snd_soc_dapm_widget sun4i_codec_codec_dapm_widgets[] = {
 
 	/* Mixers */
 	SND_SOC_DAPM_MIXER("Left Mixer", SND_SOC_NOPM, 0, 0,
-			   sun4i_codec_left_mixer_controls,
-			   ARRAY_SIZE(sun4i_codec_left_mixer_controls)),
+			   sun4i_codec_mixer_controls,
+			   ARRAY_SIZE(sun4i_codec_mixer_controls)),
 	SND_SOC_DAPM_MIXER("Right Mixer", SND_SOC_NOPM, 0, 0,
-			   sun4i_codec_right_mixer_controls,
-			   ARRAY_SIZE(sun4i_codec_right_mixer_controls)),
+			   sun4i_codec_mixer_controls,
+			   ARRAY_SIZE(sun4i_codec_mixer_controls)),
 
 	/* Global Mixer Enable */
 	SND_SOC_DAPM_SUPPLY("Mixer Enable", SUN4I_CODEC_DAC_ACTL,
@@ -805,12 +805,12 @@  static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = {
 
 	/* Right Mixer Routes */
 	{ "Right Mixer", NULL, "Mixer Enable" },
-	{ "Right Mixer", "Left DAC Playback Switch", "Left DAC" },
-	{ "Right Mixer", "Right DAC Playback Switch", "Right DAC" },
+	{ "Right Mixer", "Right Mixer Left DAC Playback Switch", "Left DAC" },
+	{ "Right Mixer", "Right Mixer Right DAC Playback Switch", "Right DAC" },
 
 	/* Left Mixer Routes */
 	{ "Left Mixer", NULL, "Mixer Enable" },
-	{ "Left Mixer", "Left DAC Playback Switch", "Left DAC" },
+	{ "Left Mixer", "Left Mixer Left DAC Playback Switch", "Left DAC" },
 
 	/* Power Amplifier Routes */
 	{ "Power Amplifier", "Mixer Playback Switch", "Left Mixer" },