[alsa-devel] mapping externally allocated Scatter Gather DMA buffers

Jaroslav Kysela perex at perex.cz
Tue Nov 9 15:34:36 CET 2010


On Tue, 9 Nov 2010, Manu Abraham wrote:

> On Tue, Nov 9, 2010 at 6:21 PM, Jaroslav Kysela <perex at perex.cz> wrote:
>> On Tue, 9 Nov 2010, Manu Abraham wrote:
>>
>>> On Tue, Nov 9, 2010 at 5:31 PM, Jaroslav Kysela <perex at perex.cz> wrote:
>>>>
>>>> On Tue, 9 Nov 2010, Manu Abraham wrote:
>>>>
>>>>> testbox ~ # arecord -Dhw:2,0
>>>>> Recording WAVE 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono
>>>>
>>>>> Any idea, why saa7231_hw_params is not getting invoked ?
>>>>
>>>> Your hw probably does not support directly 8-bit sample at 8000Hz, one
>>>> channel. Use 'plughw:2,0' device instead 'hw:2,0' to let alsa-lib do all
>>>> stream format conversions.
>>>
>>> That didn't make any difference at all.
>>
>> Check your code. You probably created wrong hw_ops, looking to your code:
>>
>>        .buffer_bytes_max       = 512 * 4096,
>>        .period_bytes_min       = 8192,
>>        .period_bytes_max       = 8192,
>>        .periods_min            = 8192,
>>        .periods_max            = 8192,
>>
>> It's definitely an empty configuration space.
>>
>> You have buffer_bytes_max 2097152, but restricted number of periods to 8192
>> and period_bytes to 8192.
>>
>> 8192 * 8192 = 67108864 which is not less than 2097152 (and I'm not counting
>> the bytes for channels and formats). Bingo, the ALSA PCM code does not know
>> what to configure.
>>
>> Decrease periods_min and probably also periods_max.
>>
>
> oh ! The error message was really a weird one. I can say that the
> hardware can do 192 audio frames in an interrupt, whatever the frame
> size is. So, what periods and period_bytes should I describe in the
> configuration ?

You cannot describe this using hw_ops. Leave period bytes in good range 
(192 - 1536?), periods (2-1024?) and add something like this to the open 
callback:

        err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
                                           192, 192);

Note the difference between SNDRV_PCM_HW_PARAM_PERIOD_SIZE and 
SNDRV_PCM_HW_PARAM_PERIOD_BYTES.

 						Jaroslav

-----
Jaroslav Kysela <perex at perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.


More information about the Alsa-devel mailing list