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

Manu Abraham abraham.manu at gmail.com
Tue Oct 26 08:32:09 CEST 2010


I have been wondering how to interface a Scatter Gather region as a DMA
buffer for an Audio Grabbing device.
The device is a NOC type device, similar to a SOC, the audio grabber is a
part of it, for realizing the audio
capabilities on the device.

The hardware DMA is mostly a Scatter Gather based engine, and it can be
described thus, briefly.

struct dmabuf {
    void *vmalloc;
    dma_addr_t phys;
    void *virt;
    int pages;
    int offset;
    struct scatterlist *sg_list;
    struct list_head list;


dmabuf->virt = __get_free_page(GFP_KERNEL);
dmabuf->phys = dma_map_single(dev, PAGE_SIZE, DMA_FROM_DEVICE);
dmabuf->sg_list = kzalloc(sizeof (struct scatterlist) * pages, GFP_KERNEL);
sg_init_table(sg_list, pages);
dmabuf->vmalloc = vmalloc((pages + 1) * PAGE_SIZE);

In a loop with the pages involved, I do populate the pages into the list;

Now I have a stream engine with the hardware, where 8 such dmabufs are
allocated. On an interrupt, the device
can know from status registers, which dmabuf the device driver needs to read
the data from.

I wonder what would be the best possible way to interface the stream engine
to the Alsa DMA capture engine.
I have been eyeballing the alsa sources and whatever documents that are
available, but found very little details
on the alsa core, but nevertheless found that, it might be possible to pass
the vmalloc'd region to
substream->runtime->dma_area. I wonder whether this is possible practically
and would like to hear your
comments on it, whatever feedback, or ideas you have.

Any helpful comments appreciated very much.


More information about the Alsa-devel mailing list