From: Steffen Trumtrar <s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org,
Mark Brown
<broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>,
Sascha Hauer <kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
patches-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org,
Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Rob Landley <rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org>,
spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
Steffen Trumtrar
<s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
Liam Girdwood <lrg-l0cyMroinI0@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [PATCH 3/6] ASoC: wm8974: include MCLKDIV in pll_factors
Date: Fri, 9 Nov 2012 15:00:22 +0100 [thread overview]
Message-ID: <1352469625-32024-4-git-send-email-s.trumtrar@pengutronix.de> (raw)
In-Reply-To: <1352469625-32024-1-git-send-email-s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To calculate the integer part of the frequency ratio, the whole output
path has to be considered (post and pre are optional):
Ndiv = (pre * target * 4 * post) / source
In the current implementation only the fixed- and pre-divider is
considered, but the post-divider is omitted.
To calculate Ndiv, this post divider has to be applied before any
calculation happens. Otherwise Ndiv is considered to be to low in the
later stages. This leads to a wrong value in the PLLN register, which
in turn produces a wrong playback speed of the audio signal.
This patch adds the post divider to the pll calculation.
Signed-off-by: Steffen Trumtrar <s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
sound/soc/codecs/wm8974.c | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c
index 9a39511..b012e4d 100644
--- a/sound/soc/codecs/wm8974.c
+++ b/sound/soc/codecs/wm8974.c
@@ -275,16 +275,51 @@ struct pll_ {
* to allow rounding later */
#define FIXED_PLL_SIZE ((1 << 24) * 10)
-static void pll_factors(struct pll_ *pll_div,
+static void pll_factors(struct pll_ *pll_div, struct snd_soc_codec *codec,
unsigned int target, unsigned int source)
{
unsigned long long Kpart;
unsigned int K, Ndiv, Nmod;
+ u16 reg;
/* There is a fixed divide by 4 in the output path */
+
target *= 4;
+ /* target also depends on MCLKDIV */
+ reg = (snd_soc_read(codec, WM8974_CLOCK) & 0xe0) >> 5;
+
+ switch (reg) {
+ case WM8974_MCLKDIV_1:
+ reg = 1;
+ break;
+ case WM8974_MCLKDIV_1_5:
+ case WM8974_MCLKDIV_2:
+ reg = 2;
+ break;
+ case WM8974_MCLKDIV_3:
+ reg = 3;
+ break;
+ case WM8974_MCLKDIV_4:
+ reg = 4;
+ break;
+ case WM8974_MCLKDIV_6:
+ reg = 6;
+ break;
+ case WM8974_MCLKDIV_8:
+ reg = 8;
+ break;
+ case WM8974_MCLKDIV_12:
+ reg = 12;
+ break;
+ default:
+ reg = 2;
+ }
+
+ target *= reg;
+
Ndiv = target / source;
+
if (Ndiv < 6) {
source /= 2;
pll_div->pre_div = 1;
@@ -333,7 +368,7 @@ static int wm8974_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
return 0;
}
- pll_factors(&pll_div, freq_out, freq_in);
+ pll_factors(&pll_div, codec, freq_out, freq_in);
snd_soc_write(codec, WM8974_PLLN, (pll_div.pre_div << 4) | pll_div.n);
snd_soc_write(codec, WM8974_PLLK1, pll_div.k >> 18);
--
1.7.10.4
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
next prev parent reply other threads:[~2012-11-09 14:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-09 14:00 [PATCH 0/6] of: add support for imx-wm8974 Steffen Trumtrar
[not found] ` <1352469625-32024-1-git-send-email-s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-11-09 14:00 ` [PATCH 1/6] spi: imx: specify spi base for device tree probe Steffen Trumtrar
2012-11-09 16:38 ` Mark Brown
[not found] ` <20121109163830.GP23807-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-11-09 19:00 ` Steffen Trumtrar
2012-11-09 14:00 ` [PATCH 2/6] spi/devicetree: find spi_device via device_node Steffen Trumtrar
2012-11-09 14:00 ` Steffen Trumtrar [this message]
[not found] ` <1352469625-32024-4-git-send-email-s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-11-09 14:55 ` [PATCH 3/6] ASoC: wm8974: include MCLKDIV in pll_factors Mark Brown
2012-11-09 14:00 ` [PATCH 4/6] ASoC: wm8974: add SPI as a possible bus master Steffen Trumtrar
[not found] ` <1352469625-32024-5-git-send-email-s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-11-09 14:38 ` Mark Brown
[not found] ` <20121109143841.GG23807-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-11-09 14:55 ` Steffen Trumtrar
[not found] ` <20121109145504.GC8598-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-11-09 14:59 ` Mark Brown
2012-11-09 14:00 ` [PATCH 5/6] ARM i.MX: rename ssi1 clock for imx27 Steffen Trumtrar
[not found] ` <1352469625-32024-6-git-send-email-s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-11-09 14:58 ` Mark Brown
2012-11-09 14:00 ` [PATCH 6/6] ASoC: fsl: add imx-wm8974 machine driver Steffen Trumtrar
[not found] ` <1352469625-32024-7-git-send-email-s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-11-09 15:36 ` Mark Brown
[not found] ` <20121109153629.GK23807-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-11-09 18:54 ` Steffen Trumtrar
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=1352469625-32024-4-git-send-email-s.trumtrar@pengutronix.de \
--to=s.trumtrar-bicnvbalz9megne8c9+irq@public.gmane.org \
--cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
--cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=lrg-l0cyMroinI0@public.gmane.org \
--cc=patches-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
--cc=rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org \
--cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/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).