From: pascal.huerst@gmail.com
To: lars@metafoo.de
Cc: alsa-devel@alsa-project.org, broonie@kernel.org,
Pascal Huerst <pascal.huerst@gmail.com>,
lgirdwood@gmail.com
Subject: [PATCH] ASoC: adau1701: Reset codec based on sample rate changes
Date: Wed, 23 Mar 2016 12:58:23 +0100 [thread overview]
Message-ID: <1458734303-16307-1-git-send-email-pascal.huerst@gmail.com> (raw)
From: Pascal Huerst <pascal.huerst@gmail.com>
Instead of checking if mclk/lrclk ratio has changed, check if
sample rate has changed. In certain cases, the mclk might be
changed in the machine driver, which can lead to the same
mclk/lrclk ration, eventhow the sample rate has changed.
Since the codec has to be programmed differently for every
sample rate, its better to check for samplerate changes instead
of mclk/lrclk ration changes.
Signed-off-by: Pascal Huerst <pascal.huerst@gmail.com>
---
sound/soc/codecs/adau1701.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
index 202dea1..1dbbcda 100644
--- a/sound/soc/codecs/adau1701.c
+++ b/sound/soc/codecs/adau1701.c
@@ -111,6 +111,7 @@ struct adau1701 {
unsigned int dai_fmt;
unsigned int pll_clkdiv;
unsigned int sysclk;
+ unsigned int current_rate;
struct regmap *regmap;
struct i2c_client *client;
u8 pin_config[12];
@@ -436,22 +437,24 @@ static int adau1701_hw_params(struct snd_pcm_substream *substream,
{
struct snd_soc_codec *codec = dai->codec;
struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec);
- unsigned int clkdiv = adau1701->sysclk / params_rate(params);
+ unsigned int rate = params_rate(params);
+ unsigned int clkdiv = adau1701->sysclk / rate;
unsigned int val;
int ret;
/*
- * If the mclk/lrclk ratio changes, the chip needs updated PLL
+ * If the sample rate changes, the chip needs updated PLL
* mode GPIO settings, and a full reset cycle, including a new
* firmware upload.
*/
- if (clkdiv != adau1701->pll_clkdiv) {
- ret = adau1701_reset(codec, clkdiv, params_rate(params));
+ if (adau1701->current_rate != rate) {
+ adau1701->current_rate = rate;
+ ret = adau1701_reset(codec, clkdiv, rate);
if (ret < 0)
return ret;
}
- switch (params_rate(params)) {
+ switch (rate) {
case 192000:
val = ADAU1701_DSPCTRL_SR_192;
break;
--
2.5.0
next reply other threads:[~2016-03-23 11:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-23 11:58 pascal.huerst [this message]
2016-03-23 12:48 ` [PATCH] ASoC: adau1701: Reset codec based on sample rate changes Mark Brown
2016-03-23 13:37 ` Lars-Peter Clausen
2016-03-23 13:42 ` Mark Brown
2016-03-23 13:44 ` Lars-Peter Clausen
2016-03-24 16:48 ` Pascal Huerst
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=1458734303-16307-1-git-send-email-pascal.huerst@gmail.com \
--to=pascal.huerst@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.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 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).