alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@nokia.com>
To: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>
Cc: "tony@atomide.com" <tony@atomide.com>,
	"broonie@opensource.wolfsonmicro.com"
	<broonie@opensource.wolfsonmicro.com>,
	"Valentin Eduardo (Nokia-D/Helsinki)"
	<eduardo.valentin@nokia.com>,
	"Nurkkala Eero.An (EXT-Offcode/Oulu)"
	<ext-Eero.Nurkkala@nokia.com>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"lrg@slimlogic.co.uk" <lrg@slimlogic.co.uk>
Subject: Re: [RFC PATCH 5/5] ASoC: omap-mcbsp: Place correct constraints for streams
Date: Mon, 31 May 2010 11:41:12 +0300	[thread overview]
Message-ID: <201005311141.12947.peter.ujfalusi@nokia.com> (raw)
In-Reply-To: <1275293810-31984-6-git-send-email-peter.ujfalusi@nokia.com>

On Monday 31 May 2010 11:16:50 Ujfalusi Peter (Nokia-D/Tampere) wrote:
...

> @@ -185,33 +231,43 @@ static int omap_mcbsp_dai_startup(struct
> snd_pcm_substream *substream, if (!cpu_dai->active)
>  		err = omap_mcbsp_request(bus_id);
> 
> +	/*
> +	 * 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 sample format.
> +	 * 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)
> +	 */
> +
> +	/*
> +	 * The first rule is for the buffer size, we should not allow smaller
> +	 * buffer than the FIFO size to avoid underruns
> +	 */
> +	snd_pcm_hw_rule_add(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
> +				    hw_rule_bsize_by_channels, mcbsp_data,
> +				    SNDRV_PCM_HW_PARAM_BUFFER_SIZE, -1);
> +

Obviously this hw_rule must be moved after checking the CPU type, since it is 
only valid for OMAP3 class of devices.
I'll fix this in the v2 series.
I have been testing this on OMAP3...

>  	if (cpu_is_omap343x()) {
>  		int dma_op_mode = omap_mcbsp_get_dma_op_mode(bus_id);
> -		int max_period;
> 
>  		/*
> -		 * McBSP2 in OMAP3 has 1024 * 32-bit internal audio buffer.
> -		 * Set constraint for minimum buffer size to the same than FIFO
> -		 * size in order to avoid underruns in playback startup because
> -		 * HW is keeping the DMA request active until FIFO is filled.
> +		 * In case os threshold mode, the rule will ensure, that the
> +		 * period size is not bigger than the maximum allowed threshold
> +		 * value.
>  		 */
> -		if (bus_id == 1)
> -			snd_pcm_hw_constraint_minmax(substream->runtime,
> -					SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
> -					4096, UINT_MAX);
> -
> -		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
> -			max_period = omap_mcbsp_get_max_tx_threshold(bus_id);
> -		else
> -			max_period = omap_mcbsp_get_max_rx_threshold(bus_id);
> -
> -		max_period++;
> -		max_period <<= 1;
> -
>  		if (dma_op_mode == MCBSP_DMA_MODE_THRESHOLD)
> -			snd_pcm_hw_constraint_minmax(substream->runtime,
> -						SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
> -						32, max_period);
> +			snd_pcm_hw_rule_add(substream->runtime, 0,
> +					SNDRV_PCM_HW_PARAM_CHANNELS,
> +					hw_rule_psize_by_channels, substream,
> +					SNDRV_PCM_HW_PARAM_PERIOD_SIZE, -1);
>  	}
> 
>  	return err;

-- 
Péter

  reply	other threads:[~2010-05-31  8:41 UTC|newest]

Thread overview: 23+ 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 [this message]
2010-05-31 10:00   ` [alsa-devel] " Liam Girdwood
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
  -- strict thread matches above, loose matches on Subject: below --
2010-05-31  8:03 [RFC PATCH 0/5] OMAP/ASoC: McBSP: FIFO handling related fixes Peter Ujfalusi
2010-05-31  8:03 ` [RFC PATCH 5/5] ASoC: omap-mcbsp: Place correct constraints for streams Peter Ujfalusi
2010-05-31  8:09   ` 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=201005311141.12947.peter.ujfalusi@nokia.com \
    --to=peter.ujfalusi@nokia.com \
    --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=lrg@slimlogic.co.uk \
    --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 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).