All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.de>,
	nsekhar@ti.com, Liam Girdwood <lgirdwood@gmail.com>,
	Jyri Sarha <jsarha@ti.com>,
	zonque@gmail.com, Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH v3 1/3] ASoC: davinci-mcasp: Constraint on the period and buffer size based on FIFO usage
Date: Thu, 20 Mar 2014 15:15:03 +0100	[thread overview]
Message-ID: <532AF7E7.8060702@metafoo.de> (raw)
In-Reply-To: <532AF15A.4090506@ti.com>

On 03/20/2014 02:47 PM, Peter Ujfalusi wrote:
> Hi Mark,
>
> On 03/19/2014 03:14 PM, Mark Brown wrote:
>> On Wed, Mar 19, 2014 at 01:13:50PM +0200, Peter Ujfalusi wrote:
>>> On 03/18/2014 08:07 PM, Mark Brown wrote:
>>
>>>> OK, so is the patch an improvement or not?  If it fixes some cases it's
>>>> probably worth applying even if further fixes are still needed.
>>
>>> Some application might fail (like mplayer with 44.1KHz) with constraint on the
>>> period size only. Without the constraint we will have constant pops at every
>>> period when non aligned size has been selected - if the FIFO depth is
>>> configured to more than 1, which is not yet the case in upstream.
>>
>> OK, given that the FIFO depth change isn't yet upstream it'd be a step
>> backwards so I'll leave this for now.
>
> I have looked at the issue and I found some clues on why mplayer fails:
> it try to set the snd_pcm_hw_params_set_buffer_time_near() first followed by
> the snd_pcm_hw_params_set_periods_near(). And this fails in some cases when we
> have constraint step on the period only.
> Other applications set the period param first followed by the buffer (aplay
> and various alsa test tools as well).
> PA however have a fallback mechanism:
> 1. buffer first followed by period
> 2. period first followed by buffer
> 3. buffer only
> 4. period only
> 5. no period, no buffer params
>
> When I have step constraint on period PA fails with the first, second (because
> there's a bug in the PA code here) and third method but going to succeed with
> four.
>
> I have looked around in the kernel and other drivers do set both period and
> buffer step constraint, for example:
>
> sound/arm/pxa2xx-pcm-lib.c (_BYTES)
> sound/drivers/vx/vx_pcm.c (_BYTES)
> sound/pci/echoaudio/echoaudio.c (_SIZE)
> sound/pci/ice1712/ice1724.c (_BYTES)
> sound/pci/lola/lola_pcm.c (_SIZE)
> sound/soc/kirkwood/kirkwood-dma.c (_BYTES)
> sound/soc/s6000/s6000-pcm.c (_BYTES)
> ...
>
> I still don't know why buffer size fails (in some cases) if we only have step
> constraint on the period size, but it looks to me that others also encountered
> with similar issues and the fix they have is the same what I had in the first
> version of the patch.

That sounds like a bug in either the kernel or alsa-lib. We do have a rule 
in place that specifies that the buffer size needs to be a integer multiple 
of the period size and we have a rule in place that the period size needs to 
be a multiple of a constant C. Hence ALSA should be able to deduce that the 
buffer size needs to be at least a multiple of min_periods * C. We probably 
should fix this for good and not workaround it in individual drivers. Do you 
think you can put together a small standalone test application that shows 
the issue?

- Lars

  reply	other threads:[~2014-03-20 14:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-18 13:20 [PATCH v3 0/3] ASoC: davinci: perparation for eDMA dmaengine PCM Peter Ujfalusi
2014-03-18 13:20 ` [PATCH v3 1/3] ASoC: davinci-mcasp: Constraint on the period and buffer size based on FIFO usage Peter Ujfalusi
2014-03-18 13:23   ` Peter Ujfalusi
2014-03-18 14:28     ` Peter Ujfalusi
2014-03-18 18:07       ` Mark Brown
2014-03-19 11:13         ` Peter Ujfalusi
2014-03-19 13:14           ` Mark Brown
2014-03-20 13:47             ` Peter Ujfalusi
2014-03-20 14:15               ` Lars-Peter Clausen [this message]
2014-03-25 10:07                 ` Peter Ujfalusi
2014-03-18 13:20 ` [PATCH v3 2/3] ASoC: davinci-mcasp: Assign the dma_data earlier in dai_probe callback Peter Ujfalusi
2014-03-19 13:19   ` Mark Brown
2014-03-18 13:20 ` [PATCH v3 3/3] ASoC: davinci-pcm: Add empty functions for !CONFIG_SND_DAVINCI_SOC builds Peter Ujfalusi
2014-03-19 13:16   ` Mark Brown

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=532AF7E7.8060702@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=jsarha@ti.com \
    --cc=lgirdwood@gmail.com \
    --cc=nsekhar@ti.com \
    --cc=peter.ujfalusi@ti.com \
    --cc=tiwai@suse.de \
    --cc=zonque@gmail.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.