linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: wm8960: Fix clock configuration on slave mode
@ 2021-09-07  9:11 Shengjiu Wang
  2021-09-07 10:33 ` Charles Keepax
  0 siblings, 1 reply; 3+ messages in thread
From: Shengjiu Wang @ 2021-09-07  9:11 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, ckeepax, kuninori.morimoto.gx,
	patches, alsa-devel, linux-kernel

There is a noise issue for 8kHz sample rate on slave mode.
Compared with master mode, the difference is the DACDIV
setting, after correcting the DACDIV, the noise is gone.

There is no noise issue for 48kHz sample rate, because
the default value of DACDIV is correct for 48kHz.

So wm8960_configure_clocking() should be functional for
ADC and DAC function even if it is slave mode.

In order to be compatible for old use case, just add
condition for checking that sysclk is zero with
slave mode.

Fixes: 0e50b51aa22f ("ASoC: wm8960: Let wm8960 driver configure its bit clock and frame clock")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
 sound/soc/codecs/wm8960.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
index 9e621a254392..9c6af76a60fd 100644
--- a/sound/soc/codecs/wm8960.c
+++ b/sound/soc/codecs/wm8960.c
@@ -742,7 +742,7 @@ static int wm8960_configure_clocking(struct snd_soc_component *component)
 	int i, j, k;
 	int ret;
 
-	if (!(iface1 & (1<<6))) {
+	if (!(iface1 & (1 << 6)) && !wm8960->sysclk) {
 		dev_dbg(component->dev,
 			"Codec is slave mode, no need to configure clock\n");
 		return 0;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: wm8960: Fix clock configuration on slave mode
  2021-09-07  9:11 [PATCH] ASoC: wm8960: Fix clock configuration on slave mode Shengjiu Wang
@ 2021-09-07 10:33 ` Charles Keepax
  0 siblings, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2021-09-07 10:33 UTC (permalink / raw)
  To: Shengjiu Wang
  Cc: lgirdwood, broonie, perex, tiwai, kuninori.morimoto.gx, patches,
	alsa-devel, linux-kernel

On Tue, Sep 07, 2021 at 05:11:09PM +0800, Shengjiu Wang wrote:
> There is a noise issue for 8kHz sample rate on slave mode.
> Compared with master mode, the difference is the DACDIV
> setting, after correcting the DACDIV, the noise is gone.
> 
> There is no noise issue for 48kHz sample rate, because
> the default value of DACDIV is correct for 48kHz.
> 
> So wm8960_configure_clocking() should be functional for
> ADC and DAC function even if it is slave mode.
> 
> In order to be compatible for old use case, just add
> condition for checking that sysclk is zero with
> slave mode.
> 
> Fixes: 0e50b51aa22f ("ASoC: wm8960: Let wm8960 driver configure its bit clock and frame clock")
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> ---
>  sound/soc/codecs/wm8960.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
> index 9e621a254392..9c6af76a60fd 100644
> --- a/sound/soc/codecs/wm8960.c
> +++ b/sound/soc/codecs/wm8960.c
> @@ -742,7 +742,7 @@ static int wm8960_configure_clocking(struct snd_soc_component *component)
>  	int i, j, k;
>  	int ret;
>  
> -	if (!(iface1 & (1<<6))) {
> +	if (!(iface1 & (1 << 6)) && !wm8960->sysclk) {
>  		dev_dbg(component->dev,
>  			"Codec is slave mode, no need to configure clock\n");

Looking through the datasheet it just looks like this if
statement has always been non-sense, it looks pretty clear the
clocking should still be configured in slave mode (apart from
BCLKDIV which is presumably ignored in slave mode).

I would be slightly inclined to suggest it would be better
to just fixup any systems not setting sysclk for slave mode,
but I am assuming you are talking primarily about out of tree
systems. So I think we need to at least update the message here
as well, it should probably change to a warning and state that
the we are proceeding with no clock configuration, rather than
erroneously saying it doesn't need one.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: wm8960: Fix clock configuration on slave mode
@ 2021-10-13  5:24 S.j. Wang
  0 siblings, 0 replies; 3+ messages in thread
From: S.j. Wang @ 2021-10-13  5:24 UTC (permalink / raw)
  To: Charles Keepax
  Cc: lgirdwood, broonie, perex, tiwai, kuninori.morimoto.gx, patches,
	alsa-devel, linux-kernel

> On Tue, Sep 07, 2021 at 05:11:09PM +0800, Shengjiu Wang wrote:
> > There is a noise issue for 8kHz sample rate on slave mode.
> > Compared with master mode, the difference is the DACDIV setting, after
> > correcting the DACDIV, the noise is gone.
> >
> > There is no noise issue for 48kHz sample rate, because the default
> > value of DACDIV is correct for 48kHz.
> >
> > So wm8960_configure_clocking() should be functional for ADC and DAC
> > function even if it is slave mode.
> >
> > In order to be compatible for old use case, just add condition for
> > checking that sysclk is zero with slave mode.
> >
> > Fixes: 0e50b51aa22f ("ASoC: wm8960: Let wm8960 driver configure its
> > bit clock and frame clock")
> > Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> > ---
> >  sound/soc/codecs/wm8960.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
> > index 9e621a254392..9c6af76a60fd 100644
> > --- a/sound/soc/codecs/wm8960.c
> > +++ b/sound/soc/codecs/wm8960.c
> > @@ -742,7 +742,7 @@ static int wm8960_configure_clocking(struct
> snd_soc_component *component)
> >       int i, j, k;
> >       int ret;
> >
> > -     if (!(iface1 & (1<<6))) {
> > +     if (!(iface1 & (1 << 6)) && !wm8960->sysclk) {
> >               dev_dbg(component->dev,
> >                       "Codec is slave mode, no need to configure
> > clock\n");
> 
> Looking through the datasheet it just looks like this if statement has always
> been non-sense, it looks pretty clear the clocking should still be configured in
> slave mode (apart from BCLKDIV which is presumably ignored in slave mode).
> 
> I would be slightly inclined to suggest it would be better to just fixup any
> systems not setting sysclk for slave mode, but I am assuming you are talking
> primarily about out of tree systems. So I think we need to at least update the
> message here as well, it should probably change to a warning and state that
> the we are proceeding with no clock configuration, rather than erroneously
> saying it doesn't need one.
> 
> Thanks,
> Charles

Sorry for missing your email. I will update it in v2.
Thanks.

Best regards
Wang Shengjiu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-13  5:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07  9:11 [PATCH] ASoC: wm8960: Fix clock configuration on slave mode Shengjiu Wang
2021-09-07 10:33 ` Charles Keepax
2021-10-13  5:24 S.j. Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).