On Tue, Oct 26, 2010 at 12:54 PM, Jaroslav Kysela perex@perex.cz wrote:
On Tue, 26 Oct 2010, Manu Abraham wrote:
Hi,
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.
Use snd_pcm_lib_preallocate_pages_for_all() - type SNDRV_DMA_TYPE_DEV_SG and snd_pcm_sgbuf_* routines. Check hda_intel.c source for more details
Thanks. I did take a deeper look at it, from a few angles. However still I am not very clear on some aspects, especially due to the multiple SG buffers involved. Let me try to make it a bit more clear ..
1. I have exactly 1 stream to be handled/grabbed
2. This single stream consists of 8 SG page tables (buffers), each buffer can contain multiple frames, but initially to keep code complexity down, I will have only a single frame per buffer.
3. The Pages (PTE's) in each SG buffer are virtually contiguous, ie, say buf_pages are vmalloc'd. But one buffer is discontiguous from the other.
4. On the 1st interrupt, likely I can read from the buffer1, on the next interrupt from buffer2 and so on in a round robin fashion.
5. The SG buffers are allocated much earlier along with hardware initialization, So these SG buffers do exist, and hence cannot be allocated again.
In such a circumstance, I wonder how I can populate runtime->dma_area. Initially I thought that I would simply map the dmabuffer as it is, but since they are 8 in number and discontiguous between the buffers, just mapping the buffers alone wouldn't help. After a bit of thoughts, I came up with a following thought.
A virtual map is created with 8 of these buffers and the base address of this map is provided to runtime->dma_area
I wonder, whether such a concept will work ?
Best Regards, Manu