[alsa-devel] Questions about writing a new ALSA driver for a very limitted device

Takashi Iwai tiwai at suse.de
Fri Apr 27 19:09:45 CEST 2007

At Thu, 26 Apr 2007 15:30:41 -0700 (PDT),
Tim Harvey wrote:
> Thanks to the help I've gotten on this list my alsa driver is working great.  I
> got a little hung up not realizing that the alsa core basically provides
> everything you need to implement your own circular buffer if you need to use an
> intermediate buffer.
> The only question I still have is that if alsa allocates your DMA buffer for
> you based on snd_pcm_hardware_t buffer_bytes_max what exactly does
> snd_pcm_lib_preallocate_pages_for_all allocate buffers for?  Does this allocate
> the buffers that would be passed to the copy callback?

hardware.buffer_bytes_max can be really big.  Many hardwares have no
hardware limitation, i.e. can be 4GB or more in theory.
The paramters passed to preallocator is the "reasonable" buffer sizes
for normal uses.

Without preallocator, you'll have to allocate buffer at each open.
Particularly in the case of contiguous pages, it gets always more
difficult because the whole memory area gets more fragmented.  Thus,
you'd like to preallocate the buffer and keep that area for later

Currently, there is a constraint that the max buffer size is limited
by the preallocated size (if any), so a buffer bigger than
preallocated won't work.  I don't know why this constraint exists, and
I believe it's fine to remove it.  (You can see FIXME comment there


More information about the Alsa-devel mailing list