[alsa-devel] hw_params function and OSS emulation

Takashi Iwai tiwai at suse.de
Thu Aug 23 21:35:13 CEST 2007

At Thu, 23 Aug 2007 14:13:08 -0500,
Timur Tabi wrote:
> Takashi Iwai wrote:
> > At Thu, 23 Aug 2007 13:43:40 -0500,
> > Timur Tabi wrote:
> >> Takashi Iwai wrote:
> >>
> >>> Err, usually, application = user-space application.  Do you mean
> >>> really this?
> >> Yes.  The application allocates a buffer, locks it down, and passes it to the 
> >> kernel.  Since the buffer was allocated in user space, it is virtual 
> >> contiguous but not physically contiguous, hence the need for a list of 
> >> physical addresses.  To the hardware, the buffer appears as a collection of 
> >> scattered buffers.  Hence, scatter/gather.
> > 
> > Hm, then it must be a really special application.  I've never seen
> > linux audio apps doing such things...
> That could be.  I'm using a generic definition of S/G.  Perhaps I should read 
> the ALSA API before posting further. :-)

Well, a generic definition of SG in the "kernel" driver area is what
the kernel does, not what user-space does :)

> > The problem in your scenario is that the buffers allocated from
> > user-space are not always DMA-able for devices, thus not always usable
> > for the hardware.
> It's possible for an application to allocate DMA-able memory.  I think you 
> need to allocate it normally than use mlock() on it, but it's been a while so 
> I'm not sure.

The DMA-able area is sometimes limited (especally with old hardwares).
For example, ISA requires the memory below 16MB where are not usable
via normal syscalls from the user-space.

> > The ALSA SG-buffer helper is simply to allocate individual pages and
> > gather as a virtually linear buffer.  From the user-space, it's
> > nothing but a normal linear buffer.
> So what is the value of having the driver allocate a physically discontiguous 
> buffer when it can easily allocate a contiguous one?  Are there systems where 
> allocating a 32KB physically-contiguous buffer is too hard?

Sometimes even 32kB allocation fails when the whole memory is

And, as you noticed, apps sometimes want really large area like over
MB.  Contiguous pages in such a size are hard to allocate in the later


More information about the Alsa-devel mailing list