[alsa-devel] mapping externally allocated Scatter Gather DMA buffers

Jaroslav Kysela perex at perex.cz
Wed Nov 10 08:05:00 CET 2010


On Wed, 10 Nov 2010, Manu Abraham wrote:

> testbox ~ # arecord -Dplughw:2,0
> Recording WAVE 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono
> ALSA lib pcm_mmap.c:369:(snd_pcm_mmap) mmap failed: Invalid argument
> arecord: set_params:1041: Unable to install hw params:

set_params fails, because snd_pcm_mmap (mmap() syscall) failed for your 
driver. The configuration space for hw_params is now OK.

You have to check sound/core/pcm_native.c, if snd_pcm_default_mmap() and 
snd_pcm_mmap_data() implementation matches the mmap policy for your DMA 
buffer. You may create your own mmap callback - substream->ops->mmap.

> bufsiz=31872 periods=83 bytes=384

This looks correct. Frame (in ALSA meaning) is 2 8-bit unsigned samples 
(you have forced to use 2 channels in your hw->ops). Thus 192 frames is 
384 bytes for this stream format. Perhaps, your frame is not ALSA frame.

ALSA frame: channels * sizeof(sample)

> Now, I wonder what a period really is. I guess I lack the basics here
> .. A basic explanation to the context,
> would be quite helpful.

Period is just a time after which should the driver acknowledge the 
transferred samples. Note that it's preffered to also allow large periods 
(if you can set hw to not acknowledge each DMA block transfer).

 						Jaroslav

-----
Jaroslav Kysela <perex at perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.



More information about the Alsa-devel mailing list