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

Manu Abraham abraham.manu at gmail.com
Wed Nov 10 17:26:40 CET 2010


On Wed, Nov 10, 2010 at 8:35 PM, Jaroslav Kysela <perex at perex.cz> wrote:
> On Wed, 10 Nov 2010, Manu Abraham wrote:
>>        /* enable stream */
>>        /* initializing 8 buffer with "pages" pages each .. */
>>        stream = saa7231_stream_init(saa7231, AUDIO_CAPTURE, ADAPTER_INT,
>> 0, pages);
>>        if (!stream) {
>>                dprintk(SAA7231_ERROR, 1, "ERROR: Registering stream");
>>                return -ENOMEM;
>>        }
>>        audio->stream = stream;
>>        buffer = stream->dmabuf;
>>        saa7231_add_irqevent(saa7231, 43, SAA7231_EDGE_RISING,
>> saa7231_audio_evhandler, "AS2D_AVIS");
>>        dprintk(SAA7231_DEBUG, 1, "Mapping %d buffers with %d pages each",
>> XS2D_BUFFERS, pages);
>
> Unfortunately, I don't understand the role of XS2D_BUFFERS. The ALSA bufsize
> is the whole DMA area (you should use params_buffer_bytes() to get this
> value instead of calculating this using periods * period_size).
>
> It means: Just allocate number of pages required for buffer_bytes. Don't
> play with periods (except the interrupts).


There are 8 SG buffers for the hardware; the maximum size of each
buffer can be 512 pages,
the minimum can be a single page.

Since each of the 8 buffers, the minimum buffer size of each buffer is
4096 bytes, the total
minimum ALSA buffer size would be 8 * 4096 bytes = 32768 bytes,
and a maximum of 8 * 512 * 4096 = 16777216 bytes

So, I should calculate the periods and period bytes based on the
buffer size involved ?
ie: it could turn out to be hard to get exact values for each of the
sampling rates involved ?

Regards,
Manu


More information about the Alsa-devel mailing list