ASoC: sgtl5000: Revert "ASoC: sgtl5000: Fix of unmute outputs on probe"
diff mbox series

Message ID 20191212071847.45561-1-alison.wang@nxp.com
State New
Headers show
Series
  • ASoC: sgtl5000: Revert "ASoC: sgtl5000: Fix of unmute outputs on probe"
Related show

Commit Message

Alison Wang Dec. 12, 2019, 7:19 a.m. UTC
This reverts commit 631bc8f0134ae9620d86a96b8c5f9445d91a2dca.

In commit 631bc8f0134a, snd_soc_component_update_bits is used instead of
snd_soc_component_write. Although EN_HP_ZCD and EN_ADC_ZCD are enabled
in ANA_CTRL register, MUTE_LO, MUTE_HP and MUTE_ADC bits are remained as
the default value. It causes LO, HP and ADC are all muted after driver
probe.

The patch is to revert this commit, snd_soc_component_write is still
used and MUTE_LO, MUTE_HP and MUTE_ADC are set as zero (unmuted).

Signed-off-by: Alison Wang <alison.wang@nxp.com>
---
 sound/soc/codecs/sgtl5000.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Alison Wang Dec. 12, 2019, 9:24 a.m. UTC | #1
Hi, Oleksandr,

I think I have explained the reason in my email which sent to you yesterday. I attached it too.
According to my test on the boards, MUTE_LO, MUTE_HP and MUTE_ADC are all muted when
playing the sound.

Could you give me some ideas about this issue?


Best Regards,I 
Alison Wang


> -----Original Message-----
> From: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
> Sent: Thursday, December 12, 2019 5:11 PM
> To: Alison Wang <alison.wang@nxp.com>
> Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>; Igor Opaniuk
> <igor.opaniuk@toradex.com>; festevam@gmail.com; broonie@kernel.org;
> lgirdwood@gmail.com; Oleksandr Suvorov <oleksandr.suvorov@toradex.com>;
> alsa-devel@alsa-project.org; linux-kernel@vger.kernel.org
> Subject: [EXT] Re: [PATCH] ASoC: sgtl5000: Revert "ASoC: sgtl5000: Fix of
> unmute outputs on probe"
> 
> Caution: EXT Email
> 
> Alison, could you please explain, what reason to revert this fix? All these blocks
> have their own control and unmute on demand.
> Why do you stand on unconditional unmuting of outputs and ADC on driver
> probing?
> 
> On Thu, Dec 12, 2019 at 9:20 AM Alison Wang <alison.wang@nxp.com>
> wrote:
> >
> > This reverts commit 631bc8f0134ae9620d86a96b8c5f9445d91a2dca.
> >
> > In commit 631bc8f0134a, snd_soc_component_update_bits is used instead
> > of snd_soc_component_write. Although EN_HP_ZCD and EN_ADC_ZCD are
> > enabled in ANA_CTRL register, MUTE_LO, MUTE_HP and MUTE_ADC bits are
> > remained as the default value. It causes LO, HP and ADC are all muted
> > after driver probe.
> >
> > The patch is to revert this commit, snd_soc_component_write is still
> > used and MUTE_LO, MUTE_HP and MUTE_ADC are set as zero (unmuted).
> >
> > Signed-off-by: Alison Wang <alison.wang@nxp.com>
> > ---
> >  sound/soc/codecs/sgtl5000.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
> > index aa1f963..0b35fca 100644
> > --- a/sound/soc/codecs/sgtl5000.c
> > +++ b/sound/soc/codecs/sgtl5000.c
> > @@ -1458,7 +1458,6 @@ static int sgtl5000_probe(struct
> snd_soc_component *component)
> >         int ret;
> >         u16 reg;
> >         struct sgtl5000_priv *sgtl5000 =
> snd_soc_component_get_drvdata(component);
> > -       unsigned int zcd_mask = SGTL5000_HP_ZCD_EN |
> SGTL5000_ADC_ZCD_EN;
> >
> >         /* power up sgtl5000 */
> >         ret = sgtl5000_set_power_regs(component);
> > @@ -1486,8 +1485,9 @@ static int sgtl5000_probe(struct
> snd_soc_component *component)
> >                0x1f);
> >         snd_soc_component_write(component,
> SGTL5000_CHIP_PAD_STRENGTH,
> > reg);
> >
> > -       snd_soc_component_update_bits(component,
> SGTL5000_CHIP_ANA_CTRL,
> > -               zcd_mask, zcd_mask);
> > +       snd_soc_component_write(component,
> SGTL5000_CHIP_ANA_CTRL,
> > +                       SGTL5000_HP_ZCD_EN |
> > +                       SGTL5000_ADC_ZCD_EN);
> >
> >         snd_soc_component_update_bits(component,
> SGTL5000_CHIP_MIC_CTRL,
> >                         SGTL5000_BIAS_R_MASK,
> > --
> > 2.9.5
> >
> 
> 
> --
> Best regards
> Oleksandr Suvorov
> 
> Toradex AG
> Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500
> 4800 (main line)
Hi, Oleksandr,

I have a question about this patch. Could you give me some ideas? Thanks.

In this patch, snd_soc_component_update_bits is used instead of snd_soc_component_write. Although EN_HP_ZCD and EN_ADC_ZCD are enabled in ANA_CTRL register, MUTE_LO, MUTE_HP and MUTE_ADC bits are remained as the default value. It causes LO, HP and ADC are all muted after driver probe. BTW, in the original code, snd_soc_component_write is used and MUTE_LO, MUTE_HP and MUTE_ADC are all set as zero (unmute).

I saw the above phenomenon on the latest linux-next. For LO and HP are muted, no sound can be heard.


Best Regards,
Alison Wang

> Subject: [v6,5/6] ASoC: sgtl5000: Fix of unmute outputs on probe
> 
> To enable "zero cross detect" for ADC/HP, change HP_ZCD_EN/ADC_ZCD_EN
> bits only instead of writing the whole CHIP_ANA_CTRL register.
> 
> Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
> Reviewed-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Reviewed-by: Igor Opaniuk <igor.opaniuk@toradex.com>
> Reviewed-by: Fabio Estevam <festevam@gmail.com>
> 
> ---
> 
> Changes in v6: None
> Changes in v5: None
> Changes in v4: None
> Changes in v3: None
> Changes in v2:
> - Fix patch formatting
> 
>  sound/soc/codecs/sgtl5000.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> 
> diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index
> b65232521ea8..23f4ae2f0723 100644
> --- a/sound/soc/codecs/sgtl5000.c
> +++ b/sound/soc/codecs/sgtl5000.c
> @@ -1453,6 +1453,7 @@  static int sgtl5000_probe(struct
> snd_soc_component *component)
>  	int ret;
>  	u16 reg;
>  	struct sgtl5000_priv *sgtl5000 =
> snd_soc_component_get_drvdata(component);
> +	unsigned int zcd_mask = SGTL5000_HP_ZCD_EN |
> SGTL5000_ADC_ZCD_EN;
> 
>  	/* power up sgtl5000 */
>  	ret = sgtl5000_set_power_regs(component);
> @@ -1480,9 +1481,8 @@  static int sgtl5000_probe(struct
> snd_soc_component *component)
>  	       0x1f);
>  	snd_soc_component_write(component, SGTL5000_CHIP_PAD_STRENGTH,
> reg);
> 
> -	snd_soc_component_write(component, SGTL5000_CHIP_ANA_CTRL,
> -			SGTL5000_HP_ZCD_EN |
> -			SGTL5000_ADC_ZCD_EN);
> +	snd_soc_component_update_bits(component,
> SGTL5000_CHIP_ANA_CTRL,
> +		zcd_mask, zcd_mask);
> 
>  	snd_soc_component_update_bits(component,
> SGTL5000_CHIP_MIC_CTRL,
>  			SGTL5000_BIAS_R_MASK,
>
Alison Wang Dec. 12, 2019, 10:07 a.m. UTC | #2
Hi, Oleksandr,

In your patch, outputs and ADC are muted on driver probing. I don't know when and
where they can be unmuted in the kernel before playing in the application.

Could you please give me some ideas?


Best Regards,
Alison Wang

> -----Original Message-----
> From: Alison Wang
> Sent: Thursday, December 12, 2019 5:25 PM
> To: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
> Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>; Igor Opaniuk
> <igor.opaniuk@toradex.com>; festevam@gmail.com; broonie@kernel.org;
> lgirdwood@gmail.com; alsa-devel@alsa-project.org;
> linux-kernel@vger.kernel.org
> Subject: RE: [EXT] Re: [PATCH] ASoC: sgtl5000: Revert "ASoC: sgtl5000: Fix of
> unmute outputs on probe"
> 
> Hi, Oleksandr,
> 
> I think I have explained the reason in my email which sent to you yesterday. I
> attached it too.
> According to my test on the boards, MUTE_LO, MUTE_HP and MUTE_ADC are
> all muted when playing the sound.
> 
> Could you give me some ideas about this issue?
> 
> 
> Best Regards,I
> Alison Wang
> 
> 
> > -----Original Message-----
> > From: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
> > Sent: Thursday, December 12, 2019 5:11 PM
> > To: Alison Wang <alison.wang@nxp.com>
> > Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>; Igor Opaniuk
> > <igor.opaniuk@toradex.com>; festevam@gmail.com; broonie@kernel.org;
> > lgirdwood@gmail.com; Oleksandr Suvorov
> <oleksandr.suvorov@toradex.com>;
> > alsa-devel@alsa-project.org; linux-kernel@vger.kernel.org
> > Subject: [EXT] Re: [PATCH] ASoC: sgtl5000: Revert "ASoC: sgtl5000: Fix of
> > unmute outputs on probe"
> >
> > Caution: EXT Email
> >
> > Alison, could you please explain, what reason to revert this fix? All these
> blocks
> > have their own control and unmute on demand.
> > Why do you stand on unconditional unmuting of outputs and ADC on driver
> > probing?
> >
> > On Thu, Dec 12, 2019 at 9:20 AM Alison Wang <alison.wang@nxp.com>
> > wrote:
> > >
> > > This reverts commit 631bc8f0134ae9620d86a96b8c5f9445d91a2dca.
> > >
> > > In commit 631bc8f0134a, snd_soc_component_update_bits is used instead
> > > of snd_soc_component_write. Although EN_HP_ZCD and EN_ADC_ZCD are
> > > enabled in ANA_CTRL register, MUTE_LO, MUTE_HP and MUTE_ADC bits
> are
> > > remained as the default value. It causes LO, HP and ADC are all muted
> > > after driver probe.
> > >
> > > The patch is to revert this commit, snd_soc_component_write is still
> > > used and MUTE_LO, MUTE_HP and MUTE_ADC are set as zero (unmuted).
> > >
> > > Signed-off-by: Alison Wang <alison.wang@nxp.com>
> > > ---
> > >  sound/soc/codecs/sgtl5000.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
> > > index aa1f963..0b35fca 100644
> > > --- a/sound/soc/codecs/sgtl5000.c
> > > +++ b/sound/soc/codecs/sgtl5000.c
> > > @@ -1458,7 +1458,6 @@ static int sgtl5000_probe(struct
> > snd_soc_component *component)
> > >         int ret;
> > >         u16 reg;
> > >         struct sgtl5000_priv *sgtl5000 =
> > snd_soc_component_get_drvdata(component);
> > > -       unsigned int zcd_mask = SGTL5000_HP_ZCD_EN |
> > SGTL5000_ADC_ZCD_EN;
> > >
> > >         /* power up sgtl5000 */
> > >         ret = sgtl5000_set_power_regs(component);
> > > @@ -1486,8 +1485,9 @@ static int sgtl5000_probe(struct
> > snd_soc_component *component)
> > >                0x1f);
> > >         snd_soc_component_write(component,
> > SGTL5000_CHIP_PAD_STRENGTH,
> > > reg);
> > >
> > > -       snd_soc_component_update_bits(component,
> > SGTL5000_CHIP_ANA_CTRL,
> > > -               zcd_mask, zcd_mask);
> > > +       snd_soc_component_write(component,
> > SGTL5000_CHIP_ANA_CTRL,
> > > +                       SGTL5000_HP_ZCD_EN |
> > > +                       SGTL5000_ADC_ZCD_EN);
> > >
> > >         snd_soc_component_update_bits(component,
> > SGTL5000_CHIP_MIC_CTRL,
> > >                         SGTL5000_BIAS_R_MASK,
> > > --
> > > 2.9.5
> > >
> >
> >
> > --
> > Best regards
> > Oleksandr Suvorov
> >
> > Toradex AG
> > Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500
> > 4800 (main line)
Alison Wang Dec. 12, 2019, 10:46 a.m. UTC | #3
Hi, Oleksandr,
...
They unmute with standard sound controls:
static const struct snd_kcontrol_new sgtl5000_snd_controls[] = {
...
SOC_SINGLE("Capture Switch", SGTL5000_CHIP_ANA_CTRL, 0, 1, 1),
...
SOC_SINGLE("Headphone Playback Switch", SGTL5000_CHIP_ANA_CTRL, 4, 1, 1),
...
SOC_SINGLE("Lineout Playback Switch", SGTL5000_CHIP_ANA_CTRL, 8, 1, 1),
...

We tested this standard solution using gstreamer and standard ALSA
tools like aplay, arecord and all these tools unmute needed blocks
successfully.
[Alison Wang] I am using aplay. Do you mean I need to add some parameters for aplay or others to unmute the outputs?

Best Regards,
Alison Wang

On Thu, Dec 12, 2019 at 12:08 PM Alison Wang <alison.wang@nxp.com> wrote:
>
> Hi, Oleksandr,
>
> In your patch, outputs and ADC are muted on driver probing. I don't know when and
> where they can be unmuted in the kernel before playing in the application.
>
> Could you please give me some ideas?
>
>
> Best Regards,
> Alison Wang
>
> > -----Original Message-----
> > From: Alison Wang
> > Sent: Thursday, December 12, 2019 5:25 PM
> > To: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
> > Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>; Igor Opaniuk
> > <igor.opaniuk@toradex.com>; festevam@gmail.com; broonie@kernel.org;
> > lgirdwood@gmail.com; alsa-devel@alsa-project.org;
> > linux-kernel@vger.kernel.org
> > Subject: RE: [EXT] Re: [PATCH] ASoC: sgtl5000: Revert "ASoC: sgtl5000: Fix of
> > unmute outputs on probe"
> >
> > Hi, Oleksandr,
> >
> > I think I have explained the reason in my email which sent to you yesterday. I
> > attached it too.
> > According to my test on the boards, MUTE_LO, MUTE_HP and MUTE_ADC are
> > all muted when playing the sound.
> >
> > Could you give me some ideas about this issue?
> >
> >
> > Best Regards,I
> > Alison Wang
> >
> >
> > > -----Original Message-----
> > > From: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
> > > Sent: Thursday, December 12, 2019 5:11 PM
> > > To: Alison Wang <alison.wang@nxp.com>
> > > Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>; Igor Opaniuk
> > > <igor.opaniuk@toradex.com>; festevam@gmail.com; broonie@kernel.org;
> > > lgirdwood@gmail.com; Oleksandr Suvorov
> > <oleksandr.suvorov@toradex.com>;
> > > alsa-devel@alsa-project.org; linux-kernel@vger.kernel.org
> > > Subject: [EXT] Re: [PATCH] ASoC: sgtl5000: Revert "ASoC: sgtl5000: Fix of
> > > unmute outputs on probe"
> > >
> > > Caution: EXT Email
> > >
> > > Alison, could you please explain, what reason to revert this fix? All these
> > blocks
> > > have their own control and unmute on demand.
> > > Why do you stand on unconditional unmuting of outputs and ADC on driver
> > > probing?
> > >
> > > On Thu, Dec 12, 2019 at 9:20 AM Alison Wang <alison.wang@nxp.com>
> > > wrote:
> > > >
> > > > This reverts commit 631bc8f0134ae9620d86a96b8c5f9445d91a2dca.
> > > >
> > > > In commit 631bc8f0134a, snd_soc_component_update_bits is used instead
> > > > of snd_soc_component_write. Although EN_HP_ZCD and EN_ADC_ZCD are
> > > > enabled in ANA_CTRL register, MUTE_LO, MUTE_HP and MUTE_ADC bits
> > are
> > > > remained as the default value. It causes LO, HP and ADC are all muted
> > > > after driver probe.
> > > >
> > > > The patch is to revert this commit, snd_soc_component_write is still
> > > > used and MUTE_LO, MUTE_HP and MUTE_ADC are set as zero (unmuted).
> > > >
> > > > Signed-off-by: Alison Wang <alison.wang@nxp.com>
> > > > ---
> > > >  sound/soc/codecs/sgtl5000.c | 6 +++---
> > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
> > > > index aa1f963..0b35fca 100644
> > > > --- a/sound/soc/codecs/sgtl5000.c
> > > > +++ b/sound/soc/codecs/sgtl5000.c
> > > > @@ -1458,7 +1458,6 @@ static int sgtl5000_probe(struct
> > > snd_soc_component *component)
> > > >         int ret;
> > > >         u16 reg;
> > > >         struct sgtl5000_priv *sgtl5000 =
> > > snd_soc_component_get_drvdata(component);
> > > > -       unsigned int zcd_mask = SGTL5000_HP_ZCD_EN |
> > > SGTL5000_ADC_ZCD_EN;
> > > >
> > > >         /* power up sgtl5000 */
> > > >         ret = sgtl5000_set_power_regs(component);
> > > > @@ -1486,8 +1485,9 @@ static int sgtl5000_probe(struct
> > > snd_soc_component *component)
> > > >                0x1f);
> > > >         snd_soc_component_write(component,
> > > SGTL5000_CHIP_PAD_STRENGTH,
> > > > reg);
> > > >
> > > > -       snd_soc_component_update_bits(component,
> > > SGTL5000_CHIP_ANA_CTRL,
> > > > -               zcd_mask, zcd_mask);
> > > > +       snd_soc_component_write(component,
> > > SGTL5000_CHIP_ANA_CTRL,
> > > > +                       SGTL5000_HP_ZCD_EN |
> > > > +                       SGTL5000_ADC_ZCD_EN);
> > > >
> > > >         snd_soc_component_update_bits(component,
> > > SGTL5000_CHIP_MIC_CTRL,
> > > >                         SGTL5000_BIAS_R_MASK,
> > > > --
> > > > 2.9.5
> > > >
> > >
> > >
> > > --
> > > Best regards
> > > Oleksandr Suvorov
> > >
> > > Toradex AG
> > > Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500
> > > 4800 (main line)



--
Best regards
Oleksandr Suvorov

Toradex AG
Altsagenstrasse 5 | 6048 Horw/Luzern | Switzerland | T: +41 41 500
4800 (main line)
Alison Wang Dec. 12, 2019, 12:31 p.m. UTC | #4
On Thu, Dec 12, 2019 at 10:46:31AM +0000, Alison Wang wrote:

> We tested this standard solution using gstreamer and standard ALSA
> tools like aplay, arecord and all these tools unmute needed blocks
> successfully.

> [Alison Wang] I am using aplay. Do you mean I need to add some parameters for aplay or others to unmute the outputs?

Use amixer.
[Alison Wang] Got it. Thanks.

Best Regards,
Alison Wang
Daniel Baluta Dec. 12, 2019, 3:11 p.m. UTC | #5
On Thu, 2019-12-12 at 12:23 +0000, Mark Brown wrote:
On Thu, Dec 12, 2019 at 10:46:31AM +0000, Alison Wang wrote:

> We tested this standard solution using gstreamer and standard ALSA
> tools like aplay, arecord and all these tools unmute needed blocks
> successfully.

> [Alison Wang] I am using aplay. Do you mean I need to add some parameters for aplay or others to unmute the outputs?

Hi Alison,

You can also update your asound.state file with default state for your controls.
Alison Wang Dec. 13, 2019, 1:51 a.m. UTC | #6
Hi, Daniel,

On Thu, 2019-12-12 at 12:23 +0000, Mark Brown wrote:
On Thu, Dec 12, 2019 at 10:46:31AM +0000, Alison Wang wrote:

> We tested this standard solution using gstreamer and standard ALSA
> tools like aplay, arecord and all these tools unmute needed blocks
> successfully.

> [Alison Wang] I am using aplay. Do you mean I need to add some parameters for aplay or others to unmute the outputs?

Hi Alison,

You can also update your asound.state file with default state for your controls.
[Alison] Got it. Thanks.

Best Regards,
Alison Wang

Patch
diff mbox series

diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index aa1f963..0b35fca 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -1458,7 +1458,6 @@  static int sgtl5000_probe(struct snd_soc_component *component)
 	int ret;
 	u16 reg;
 	struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component);
-	unsigned int zcd_mask = SGTL5000_HP_ZCD_EN | SGTL5000_ADC_ZCD_EN;
 
 	/* power up sgtl5000 */
 	ret = sgtl5000_set_power_regs(component);
@@ -1486,8 +1485,9 @@  static int sgtl5000_probe(struct snd_soc_component *component)
 	       0x1f);
 	snd_soc_component_write(component, SGTL5000_CHIP_PAD_STRENGTH, reg);
 
-	snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_CTRL,
-		zcd_mask, zcd_mask);
+	snd_soc_component_write(component, SGTL5000_CHIP_ANA_CTRL,
+			SGTL5000_HP_ZCD_EN |
+			SGTL5000_ADC_ZCD_EN);
 
 	snd_soc_component_update_bits(component, SGTL5000_CHIP_MIC_CTRL,
 			SGTL5000_BIAS_R_MASK,