From: Liam Girdwood <lrg@slimlogic.co.uk>
To: Jarkko Nikula <jhnikula@gmail.com>
Cc: alsa-devel <alsa-devel@alsa-project.org>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Peter Ujfalusi <peter.ujfalusi@nokia.com>,
Graeme Gregory <gg@slimlogic.co.uk>
Subject: Re: [PATCH] ASoC - Add support for upto 16 channels on OMAP MCBSP
Date: Thu, 05 Nov 2009 14:55:30 +0000 [thread overview]
Message-ID: <1257432930.3603.902.camel@odin> (raw)
In-Reply-To: <20091105095143.995beeea.jhnikula@gmail.com>
On Thu, 2009-11-05 at 09:51 +0200, Jarkko Nikula wrote:
> On Wed, 04 Nov 2009 19:46:49 +0000
> Liam Girdwood <lrg@slimlogic.co.uk> wrote:
>
> > > > + /* calc best frame size for rate and clock divider */
> > > > + do {
> > > > + frame_size = (mcbsp_data->in_freq / div) / params_rate(params);
> > > > + pr_debug("freq %d, rate %d, frame size %d, div %d\n",
> > > > + mcbsp_data->in_freq, params_rate(params), frame_size, div);
> > > > +
> > > > + if (frame_size > 256)
> > > > + div++;
> > > > + } while (frame_size > 256);
> > > > +
>
> This would be better if it tries to calculate minimum frame size. Now
> the algorithm stops when the frame_size is 256 and leads to higher
> bit clock.
>
> E.g. 4 * 16bits * 48 kHz and using 96 MHz internal clock:
>
> Algorithm: div = 8, frame_size = 250 and bit clock = 12 MHz.
>
> Possible dividers and frame_sizes:
>
> 25*80 (-> best, bit clock = 3.840 MHz)
> 20*100
> 16*125
> 10*200
> 8*250
>
I've reworked this myself now. It does appear that the current FPER
calculations assume BCLK scales with rate
i.e. BCLK = rate * channels * word len
This is fine for when McBSP is FRM/BCLK slave (all users except pandora)
as FPER should be ignored internally.
However, when BCLK is constant (e.g. McBSP BCLK derived from constant
source) and we run McBSP as FRM/BCLK master we currently break our
sample rate generation.
Imho, it's better to generate FPER based upon BCLK and rate. e.g. we
calculate the frame size required for the given BCLK and rate.
/* In McBSP master modes, FRAME (i.e. sample rate) is generated
* by _counting_ BCLKs. Calculate frame size in BCLKs */
div = mcbsp_data->clk_div ? mcbsp_data->clk_div : 1;
framesize = (mcbsp_data->in_freq / div) / params_rate(params);
if (framesize < wlen * channels) {
printk(KERN_ERR "%s: not enough bandwidth for desired rate and channels\n",
__func__);
return -EINVAL;
}
/* Set FS period and length in terms of bit clock periods */
switch (format) {
case SND_SOC_DAIFMT_I2S:
regs->srgr2 |= FPER(framesize - 1);
regs->srgr1 |= FWID((framesize >> 1) - 1);
break;
case SND_SOC_DAIFMT_DSP_A:
case SND_SOC_DAIFMT_DSP_B:
regs->srgr2 |= FPER(framesize - 1);
regs->srgr1 |= FWID(0);
break;
}
I'm now slightly curious about how pandora handles different rates since
it uses the McBSP in master mode too. I guess they can only handle a
single sample rate ?
Liam
next prev parent reply other threads:[~2009-11-05 14:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-04 17:53 [PATCH] ASoC - Add support for upto 16 channels on OMAP MCBSP Liam Girdwood
2009-11-04 18:28 ` Mark Brown
2009-11-04 18:55 ` Graeme Gregory
2009-11-04 19:46 ` Liam Girdwood
2009-11-05 7:51 ` Jarkko Nikula
2009-11-05 14:55 ` Liam Girdwood [this message]
2009-11-05 19:28 ` Jarkko Nikula
2009-11-05 20:08 ` Liam Girdwood
2009-11-06 13:20 ` Mark Brown
2009-11-06 14:25 ` Liam Girdwood
2009-11-06 15:00 ` Mark Brown
2009-11-05 8:14 ` Peter Ujfalusi
2009-11-05 8:26 ` Peter Ujfalusi
2009-11-05 10:05 ` Liam Girdwood
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=1257432930.3603.902.camel@odin \
--to=lrg@slimlogic.co.uk \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=gg@slimlogic.co.uk \
--cc=jhnikula@gmail.com \
--cc=peter.ujfalusi@nokia.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.