From: Matt Flax <flatmax@flatmax.org>
To: broonie@kernel.org, alsa-devel@alsa-project.org,
patches@opensource.wolfsonmicro.com,
ckeepax@opensource.wolfsonmicro.com
Subject: Re: [PATCH 2/2] ASoc: wm8731: add normal mode with 12MHz XTAL
Date: Sun, 12 Jun 2016 13:22:26 +1000 [thread overview]
Message-ID: <575CD572.2040700@flatmax.org> (raw)
In-Reply-To: <575BD6F2.70600@flatmax.org>
It appears that my logic here is flawed.
From what I can tell, it isn't possible to get a suitable bit clock out
of the codec when using a 12 MHz crystal. For that reason, in my
hardware I will change crystals from 12 MHz.
I just want to check ... are there any versions of this codec which
output the bit clock when in USB mode on the BCLK pin ?
thanks
Matt
On 11/06/16 19:16, Matt Flax wrote:
> I have realised that this second patch may not be necessary. It is
> also likely that it will skew the actual sample rate.
>
> Charles, can you please advise me on the following...
>
> I notice that I can probably get the correct sample rates by spoofing
> the crystal frequencies in my machine driver. For example ...
> The ratio between the USB and Normal mode fs multipliers with BOSR=0 is :
> 250/256 = 0.97656
> Similarly, I can match this with the following crystal frequency ratio
> (crystal f in MHz) :
> 12/12.288 = 0.97656
> By induction, I assume that I can spoof a 12.288 clock with BOSR=0 for
> sample rate = 48kHz, 96 kHz when using a 12 MHz crystal.
>
> Again, I can match ratios between the following crystal frequecies (in
> MHz) :
> 12/16.9344 = 0.70862
> With BOSR = 1, I assume that can get 44.1 kHz and 88.2 kHz because the
> fs ratio between normal and usb mode is :
> 272/384 = 0.70833
>
> Now these two ratios are skew by 0.41% which is equvalent to the skew
> in 12 MHz USB mode clocks of 44.1kHz to 44.118kHz as reported in the
> wm8731 datasheet.
>
> Can you advise me whether my idea of spoofing clocks in the machine
> driver is perhaps a better way of acquiring the correct sample rates,
> rather then this patch ?
>
> thanks
> Matt
>
> On 10/06/16 10:11, Matt Flax wrote:
>> This patch allows a machine to set normal mode when using a
>> 12 MHz crystal. In USB_MODE the 12 MHz crystal signal is output on
>> the BCLK pin. In NORMAL_MODE the bit clock is output on the BCLK pin.
>> The previously ignored direction variable input to the
>> wm8731_set_dai_sysclk function is used to indicate whether crystal
>> or bit clock is output on the BCLK codec pin.
>> I have ensured that this does not effect the db1200.c machine driver
>> (the only other driver to use a 12 MHz crystal in USB_MODE). It also
>> does not effect the other machine drivers which use the wm8731 codec
>> as they don't use USB_MODE nor 12 MHz crystals.
>>
>> When driving the wm8731 in normal mode with a 12 MHz crystal, the
>> DSP filters are expected to be effected. If the filters are activated
>> then it is expected that the filter cut offs are shifted by 2.3% at
>> 250 fs and 29.1% at 272 fs. The assumption is that the filters are
>> linear, which implies a linear shift in rate scaling effects the
>> filter cut off frequencies linearly. If the filters are not active,
>> there will be no effects.
>>
>> Signed-off-by: Matt Flax <flatmax@flatmax.org>
>> ---
>> sound/soc/codecs/wm8731.c | 14 ++++++++++++--
>> 1 file changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
>> index d18261a..ec98d5a 100644
>> --- a/sound/soc/codecs/wm8731.c
>> +++ b/sound/soc/codecs/wm8731.c
>> @@ -5,6 +5,7 @@
>> * Copyright 2006-12 Wolfson Microelectronics, plc
>> *
>> * Author: Richard Purdie <richard@openedhand.com>
>> + * Author: Matt Flax <flatmax@flatmax.com> 12Mhz XTAL normal mode
>> and 32bit mode.
>> *
>> * Based on wm8753.c by Liam Girdwood
>> *
>> @@ -53,6 +54,7 @@ struct wm8731_priv {
>> int sysclk_type;
>> int playback_fs;
>> bool deemph;
>> + bool bclk_12_mhz;
>> struct mutex lock;
>> };
>> @@ -341,8 +343,11 @@ static int wm8731_hw_params(struct
>> snd_pcm_substream *substream,
>> struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec);
>> u16 iface = snd_soc_read(codec, WM8731_IFACE) & 0xfff3;
>> int i = get_coeff(wm8731->sysclk, params_rate(params));
>> - u16 srate = (coeff_div[i].sr << 2) |
>> - (coeff_div[i].bosr << 1) | coeff_div[i].usb;
>> + u16 srate = (coeff_div[i].sr << 2) | (coeff_div[i].bosr << 1);
>> +
>> + /* this determines whether to output bit or crystal clk */
>> + if (wm8731->bclk_12_mhz)
>> + srate |= coeff_div[i].usb;
>> wm8731->playback_fs = params_rate(params);
>> @@ -420,6 +425,11 @@ static int wm8731_set_dai_sysclk(struct
>> snd_soc_dai *codec_dai,
>> wm8731->sysclk = freq;
>> + if (dir == SND_SOC_CLOCK_IN) /* output the 12 MHz clock */
>> + wm8731->bclk_12_mhz = 1;
>> + else /* SND_SOC_CLOCK_OUT, output the bit clock */
>> + wm8731->bclk_12_mhz = 0;
>> +
>> snd_soc_dapm_sync(dapm);
>> return 0;
>
next prev parent reply other threads:[~2016-06-12 3:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1465517516-1917-1-git-send-email-flatmax@flatmax.org>
[not found] ` <1465517516-1917-2-git-send-email-flatmax@flatmax.org>
2016-06-11 9:16 ` [PATCH 2/2] ASoc: wm8731: add normal mode with 12MHz XTAL Matt Flax
2016-06-12 3:22 ` Matt Flax [this message]
2016-06-13 8:37 ` Charles Keepax
2016-06-13 9:45 ` Matt Flax
2016-06-13 11:59 ` Charles Keepax
2016-06-13 12:39 ` Matt Flax
2016-06-15 16:56 ` Charles Keepax
2016-06-19 21:46 ` Rob Calhoun
2016-06-19 22:23 ` Matt Flax
2016-06-20 10:55 ` Charles Keepax
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=575CD572.2040700@flatmax.org \
--to=flatmax@flatmax.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.wolfsonmicro.com \
--cc=patches@opensource.wolfsonmicro.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.