On Wed, 10 Nov 2010, Manu Abraham wrote:
On Wed, Nov 10, 2010 at 8:35 PM, Jaroslav Kysela perex@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.
Could you describe more the whole DMA layout, including IRQ acks?
It seems to me:
SG PAGE 1 points to 1 - 512 data pages (4096 bytes long) SG PAGE 2 ..... .... SG PAGE 8 .....
How you can program interrupts? Only when the whole page is finished or the interrupt does not depend on the DMA buffer position, but a hw clock timer?
Could you limit how much data (samples) are fetched from the one data page or the hw operates with whole pages only?
Note that the stream processing rate is usually independent from the DMA layout in most hw.
Jaroslav
----- Jaroslav Kysela perex@perex.cz Linux Kernel Sound Maintainer ALSA Project, Red Hat, Inc.