All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liam Girdwood <lrg@slimlogic.co.uk>
To: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Cc: alsa-devel@alsa-project.org, linux-omap@vger.kernel.org,
	tony@atomide.com, broonie@opensource.wolfsonmicro.com,
	eduardo.valentin@nokia.com, ext-eero.nurkkala@nokia.com
Subject: Re: [alsa-devel] [RFC PATCH 5/5] ASoC: omap-mcbsp: Place correct constraints for streams
Date: Mon, 31 May 2010 11:00:21 +0100	[thread overview]
Message-ID: <1275300021.3174.5.camel@odin> (raw)
In-Reply-To: <1275293810-31984-6-git-send-email-peter.ujfalusi@nokia.com>

On Mon, 2010-05-31 at 11:16 +0300, Peter Ujfalusi wrote:
> OMAP McBSP FIFO is word structured:
> McBSP2 has 1024 + 256 = 1280 word long buffer,
> McBSP1,3,4,5 has 128 word long buffer
> 
> This means, that the size of the FIFO
> depends on the McBSP word size configuration.
> For example on McBSP3:
> 16bit samples: size is 128 * 2 = 256 bytes
> 32bit samples: size is 128 * 4 = 512 bytes
> It is simpler to place constraint for buffer and period based on channels.
> McBSP3 as example again (16 or 32 bit samples):
> 1 channel (mono): size is 128 frames (128 words)
> 2 channels (stereo): size is 128 / 2 = 64 frames (2 * 64 words)
> 4 channels: size is 128 / 4 = 32 frames (4 * 32 words)
> 
> Use the second method to place hw_rule on buffer size, and in threshold
> mode to period size.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
> ---
>  sound/soc/omap/omap-mcbsp.c |   98 +++++++++++++++++++++++++++++++++---------
>  1 files changed, 77 insertions(+), 21 deletions(-)
> 
> diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
> index b06d8f1..d6ed761 100644
> --- a/sound/soc/omap/omap-mcbsp.c
> +++ b/sound/soc/omap/omap-mcbsp.c
> @@ -173,6 +173,52 @@ static void omap_mcbsp_set_threshold(struct snd_pcm_substream *substream)
>  		omap_mcbsp_set_rx_threshold(mcbsp_data->bus_id, words);
>  }
>  
> +static int hw_rule_bsize_by_channels(struct snd_pcm_hw_params *params,
> +				    struct snd_pcm_hw_rule *rule)
> +{
> +	struct snd_interval *bs = hw_param_interval(params,
> +					SNDRV_PCM_HW_PARAM_BUFFER_SIZE);
> +	struct snd_interval *c = hw_param_interval(params,
> +					SNDRV_PCM_HW_PARAM_CHANNELS);

Best to make these variable names more meaningful.

> +	struct omap_mcbsp_data *mcbsp_data = rule->private;
> +	struct snd_interval frames;
> +	int size;
> +
> +	snd_interval_any(&frames);
> +	size = omap_mcbsp_get_fifo_size(mcbsp_data->bus_id);
> +
> +	frames.min = size / c->min;
> +	frames.integer = 1;
> +	return snd_interval_refine(bs, &frames);
> +
> +}
> +
> +static int hw_rule_psize_by_channels(struct snd_pcm_hw_params *params,
> +				    struct snd_pcm_hw_rule *rule)
> +{
> +	struct snd_interval *ps = hw_param_interval(params,
> +					SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
> +	struct snd_interval *c = hw_param_interval(params,
> +					SNDRV_PCM_HW_PARAM_CHANNELS);

ditto

> +	struct snd_pcm_substream *substream = rule->private;
> +	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> +	struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
> +	struct omap_mcbsp_data *mcbsp_data = to_mcbsp(cpu_dai->private_data);
> +	struct snd_interval frames;
> +	int size;
> +
> +	snd_interval_any(&frames);
> +	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
> +		size = omap_mcbsp_get_max_tx_threshold(mcbsp_data->bus_id);
> +	else
> +		size = omap_mcbsp_get_max_rx_threshold(mcbsp_data->bus_id);
> +
> +	frames.min = 8;
> +	frames.max = size / c->min;
> +	frames.integer = 1;
> +	return snd_interval_refine(ps, &frames);
> +}

Thanks

Liam
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk


  parent reply	other threads:[~2010-05-31 10:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-31  8:16 [RFC PATCH 0/5] OMAP/ASoC: McBSP: FIFO handling related fixes Peter Ujfalusi
2010-05-31  8:16 ` [RFC PATCH 1/5] OMAP: McBSP: Function to query the FIFO size Peter Ujfalusi
2010-05-31  8:16 ` [RFC PATCH 2/5] OMAP3: McBSP: Change the way how the FIFO is handled Peter Ujfalusi
2010-05-31 17:41   ` Nishanth Menon
2010-06-01  6:59     ` Peter Ujfalusi
2010-06-02  4:24       ` Nishanth Menon
2010-05-31  8:16 ` [RFC PATCH 3/5] OMAP3: McBSP: Use the port's buffer_size when calculating tx delay Peter Ujfalusi
2010-05-31  8:16 ` [RFC PATCH 4/5] ASoC: omap-mcbsp: Save, and use wlen for threshold configuration Peter Ujfalusi
2010-05-31  8:16 ` [RFC PATCH 5/5] ASoC: omap-mcbsp: Place correct constraints for streams Peter Ujfalusi
2010-05-31  8:41   ` Peter Ujfalusi
2010-05-31 10:00   ` Liam Girdwood [this message]
2010-05-31 11:57     ` Peter Ujfalusi
2010-06-01  6:38       ` Jarkko Nikula
2010-06-01  6:47         ` Peter Ujfalusi
2010-06-01  7:38           ` Jarkko Nikula
2010-06-01  8:07             ` Peter Ujfalusi
2010-06-01  8:19             ` Peter Ujfalusi
2010-06-01  9:29               ` Jarkko Nikula
2010-06-01 10:30                 ` Peter Ujfalusi
2010-06-01 11:20                   ` [alsa-devel] " Jarkko Nikula
2010-06-01 11:34                     ` Peter Ujfalusi

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=1275300021.3174.5.camel@odin \
    --to=lrg@slimlogic.co.uk \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=eduardo.valentin@nokia.com \
    --cc=ext-eero.nurkkala@nokia.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=peter.ujfalusi@nokia.com \
    --cc=tony@atomide.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.