All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Prchal Jiří" <jiri.prchal@aksignal.cz>
To: "Hebbar, Gururaja" <gururaja.hebbar@ti.com>
Cc: alsa-devel@alsa-project.org, sudhakar.raj@ti.com,
	broonie@opensource.wolfsonmicro.com, nsekhar@ti.com,
	davinci-linux-open-source@linux.davincidsp.com,
	alsa-user@lists.sourceforge.net, lrg@ti.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V2] ASoC: tlv320aic3x: Fix codec pll configure bug
Date: Tue, 26 Jun 2012 11:01:42 +0200	[thread overview]
Message-ID: <4FE97A76.5070105@aksignal.cz> (raw)
In-Reply-To: <1340690623-18177-1-git-send-email-gururaja.hebbar@ti.com>

Hi Gururaja,
shouldn't be better to use:

snd_soc_update_bits(codec, AIC3X_PLL_PROGA_REG, PLLP_MASK, pll_p);

instead of "read mask write" ?
Even at this place you don't need to keep rest of register (PLL_Q and PLL_enable), so yust writing is OK.

snd_soc_write(codec, AIC3X_PLL_PROGA_REG, pll_p << PLLP_SHIFT);


Dne 26.6.2012 08:03, Hebbar, Gururaja napsal(a):
> In sound/soc/codecs/tlv320aic3x.c
>
>          data = snd_soc_read(codec, AIC3X_PLL_PROGA_REG);
>          snd_soc_write(codec, AIC3X_PLL_PROGA_REG,
>                        data | (pll_p<<  PLLP_SHIFT));
>
> In the above code, pll-p value is OR'ed with previous value without
> clearing it. Bug is not seen if pll-p value doesn't change across
> Sampling frequency.
>
> However on some platforms (like AM335x EVM-SK), pll-p may have different
> values across different sampling frequencies. In such case, above code
> configures the pll with a wrong value.
> Because of this bug, when a audio stream is played with pll value
> different from previous stream, audio is heard as differently.
>
> Signed-off-by: Hebbar, Gururaja<gururaja.hebbar@ti.com>
> ---
> chnages in V2:
> 	modify subject to indicate ASOC and codec as tlv320aic3x
>
>   sound/soc/codecs/tlv320aic3x.c |    2 +-
>   sound/soc/codecs/tlv320aic3x.h |    1 +
>   2 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
> index d0dbac1..8c1977b 100644
> --- a/sound/soc/codecs/tlv320aic3x.c
> +++ b/sound/soc/codecs/tlv320aic3x.c
> @@ -963,7 +963,7 @@ static int aic3x_hw_params(struct snd_pcm_substream *substream,
>   	}
>
>   found:
> -	data = snd_soc_read(codec, AIC3X_PLL_PROGA_REG);
> +	data = snd_soc_read(codec, AIC3X_PLL_PROGA_REG)&  ~PLLP_MASK;
>   	snd_soc_write(codec, AIC3X_PLL_PROGA_REG,
>   		      data | (pll_p<<  PLLP_SHIFT));
>   	snd_soc_write(codec, AIC3X_OVRF_STATUS_AND_PLLR_REG,
> diff --git a/sound/soc/codecs/tlv320aic3x.h b/sound/soc/codecs/tlv320aic3x.h
> index 06a1978..16d9999 100644
> --- a/sound/soc/codecs/tlv320aic3x.h
> +++ b/sound/soc/codecs/tlv320aic3x.h
> @@ -166,6 +166,7 @@
>
>   /* PLL registers bitfields */
>   #define PLLP_SHIFT		0
> +#define PLLP_MASK		7
>   #define PLLQ_SHIFT		3
>   #define PLLR_SHIFT		0
>   #define PLLJ_SHIFT		2

WARNING: multiple messages have this Message-ID (diff)
From: jiri.prchal@aksignal.cz (Prchal Jiří)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2] ASoC: tlv320aic3x: Fix codec pll configure bug
Date: Tue, 26 Jun 2012 11:01:42 +0200	[thread overview]
Message-ID: <4FE97A76.5070105@aksignal.cz> (raw)
In-Reply-To: <1340690623-18177-1-git-send-email-gururaja.hebbar@ti.com>

Hi Gururaja,
shouldn't be better to use:

snd_soc_update_bits(codec, AIC3X_PLL_PROGA_REG, PLLP_MASK, pll_p);

instead of "read mask write" ?
Even at this place you don't need to keep rest of register (PLL_Q and PLL_enable), so yust writing is OK.

snd_soc_write(codec, AIC3X_PLL_PROGA_REG, pll_p << PLLP_SHIFT);


Dne 26.6.2012 08:03, Hebbar, Gururaja napsal(a):
> In sound/soc/codecs/tlv320aic3x.c
>
>          data = snd_soc_read(codec, AIC3X_PLL_PROGA_REG);
>          snd_soc_write(codec, AIC3X_PLL_PROGA_REG,
>                        data | (pll_p<<  PLLP_SHIFT));
>
> In the above code, pll-p value is OR'ed with previous value without
> clearing it. Bug is not seen if pll-p value doesn't change across
> Sampling frequency.
>
> However on some platforms (like AM335x EVM-SK), pll-p may have different
> values across different sampling frequencies. In such case, above code
> configures the pll with a wrong value.
> Because of this bug, when a audio stream is played with pll value
> different from previous stream, audio is heard as differently.
>
> Signed-off-by: Hebbar, Gururaja<gururaja.hebbar@ti.com>
> ---
> chnages in V2:
> 	modify subject to indicate ASOC and codec as tlv320aic3x
>
>   sound/soc/codecs/tlv320aic3x.c |    2 +-
>   sound/soc/codecs/tlv320aic3x.h |    1 +
>   2 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
> index d0dbac1..8c1977b 100644
> --- a/sound/soc/codecs/tlv320aic3x.c
> +++ b/sound/soc/codecs/tlv320aic3x.c
> @@ -963,7 +963,7 @@ static int aic3x_hw_params(struct snd_pcm_substream *substream,
>   	}
>
>   found:
> -	data = snd_soc_read(codec, AIC3X_PLL_PROGA_REG);
> +	data = snd_soc_read(codec, AIC3X_PLL_PROGA_REG)&  ~PLLP_MASK;
>   	snd_soc_write(codec, AIC3X_PLL_PROGA_REG,
>   		      data | (pll_p<<  PLLP_SHIFT));
>   	snd_soc_write(codec, AIC3X_OVRF_STATUS_AND_PLLR_REG,
> diff --git a/sound/soc/codecs/tlv320aic3x.h b/sound/soc/codecs/tlv320aic3x.h
> index 06a1978..16d9999 100644
> --- a/sound/soc/codecs/tlv320aic3x.h
> +++ b/sound/soc/codecs/tlv320aic3x.h
> @@ -166,6 +166,7 @@
>
>   /* PLL registers bitfields */
>   #define PLLP_SHIFT		0
> +#define PLLP_MASK		7
>   #define PLLQ_SHIFT		3
>   #define PLLR_SHIFT		0
>   #define PLLJ_SHIFT		2

  parent reply	other threads:[~2012-06-26  9:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-26  6:03 [PATCH V2] ASoC: tlv320aic3x: Fix codec pll configure bug Hebbar, Gururaja
2012-06-26  6:03 ` Hebbar, Gururaja
2012-06-26  8:54 ` Mark Brown
2012-06-26  8:54   ` Mark Brown
2012-06-26 14:07   ` Hebbar, Gururaja
2012-06-26 14:07     ` Hebbar, Gururaja
2012-06-26  9:01 ` Prchal Jiří [this message]
2012-06-26  9:01   ` Prchal Jiří
2012-06-26 14:08   ` Hebbar, Gururaja
2012-06-26 14:08     ` Hebbar, Gururaja

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FE97A76.5070105@aksignal.cz \
    --to=jiri.prchal@aksignal.cz \
    --cc=alsa-devel@alsa-project.org \
    --cc=alsa-user@lists.sourceforge.net \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=gururaja.hebbar@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lrg@ti.com \
    --cc=nsekhar@ti.com \
    --cc=sudhakar.raj@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.