[alsa-devel] [PATCH 1/3] ASoC: omap-mcbsp: fix snd_pcm_hw_rule_add arguments
notasas at gmail.com
Fri Mar 9 11:45:24 CET 2012
On Fri, Mar 9, 2012 at 12:08 PM, Peter Ujfalusi <peter.ujfalusi at ti.com> wrote:
> On 03/09/2012 01:19 AM, Grazvydas Ignotas wrote:
>> We are setting SNDRV_PCM_HW_PARAM_BUFFER_SIZE based on
>> SNDRV_PCM_HW_PARAM_CHANNELS, not vice versa.
> The intention is to set the buffer size based on the channels here.
> This is needed because of the McBSP internal FIFO operation.
> It is word based. As example on McBSP2 has 1280 word FIFO.
> In mono stream it is 1280 sample long.
> In stereo it is 640 (stereo) sample long.
> In four channel mode it is 320 (4 channel) sample long.
That's all fine, but the argument order is wrong, take a look at
* snd_pcm_hw_rule_add - add the hw-constraint rule
* @var: the variable to evaluate
* @dep: the dependent variables
int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond,
snd_pcm_hw_rule_func_t func, void *private,
int dep, ...)
So var should be SNDRV_PCM_HW_PARAM_BUFFER_SIZE, dep
SNDRV_PCM_HW_PARAM_CHANNELS, but it is the opposite now.
>> This bug didn't
>> have much impact because the rules are evaluated multiple times
>> by the core, and intended value got set eventually.
>> Signed-off-by: Grazvydas Ignotas <notasas at gmail.com>
>> sound/soc/omap/omap-mcbsp.c | 4 ++--
>> 1 files changed, 2 insertions(+), 2 deletions(-)
>> diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
>> index 10eb645..207365c 100644
>> --- a/sound/soc/omap/omap-mcbsp.c
>> +++ b/sound/soc/omap/omap-mcbsp.c
>> @@ -142,10 +142,10 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream,
>> * smaller buffer than the FIFO size to avoid underruns
>> snd_pcm_hw_rule_add(substream->runtime, 0,
>> - SNDRV_PCM_HW_PARAM_CHANNELS,
>> + SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
>> - SNDRV_PCM_HW_PARAM_BUFFER_SIZE, -1);
>> + SNDRV_PCM_HW_PARAM_CHANNELS, -1);
>> /* Make sure, that the period size is always even */
>> snd_pcm_hw_constraint_step(substream->runtime, 0,
More information about the Alsa-devel