[alsa-devel] Audio DMA buffer layout and setup

Markus Korber korbse at gmx.at
Wed May 2 10:54:01 CEST 2007


Hi,

I'm working with a custom sound chip with its own DMA hardware.  The
figure shows how the I2S DMA expects data to be prepared:

     IRQ1 +----------------+
          | page_3 (right) |\
          +----------------+ > double buffer 1
          | page_2 (left)  |/
     IRQ0 +----------------+
          | page_1 (right) |\
          +----------------+ > double buffer 0
          | page_0 (left)  |/
          +----------------+

The hardware has 2 double buffers, each containing left and right sample
regions, i.e. it alternately transmits samples from page_0 and page_1,
i.e. double buffer 0, then generates an interrupt and starts
transmitting page_2 and page_3.  After that another interrupt is
generated and the process begins again with double buffer 0.

So my question is, how to tell ALSA about this memory layout?  Is it
possible to operate in MMAP mode with SNDRV_PCM_INFO_NONINTERLEAVED?
But then, how to tell the application that it should either fill double
buffer 0 or 1?  Or should I use RW mode?  Or something else?

Furthermore, since the hardware doesn't provide a 'current' DMA pointer
containing the DMA address being transmitted at the moment (I only have
interrupts generated after each double buffer has been transmitted),
what should the pcm_pointer() callback return?  

(I guess it should return 0 when called before IRQ0 and sizeof(double
 buffer 0) between IRQ0 and IRQ1?)

Best regards,
Markus Korber


More information about the Alsa-devel mailing list