[alsa-devel] dmix and mmap

Gabriel Johnson johnsoga at gmail.com
Thu Apr 30 17:10:23 CEST 2009

I am currently working on two issues.

First, I am trying to add mmaping support to the pcm driver I am using
so that I can use the dmix plugin.  My driver is a soc driver for the
powerpc mpc5121.  The pcm_new function preallocates the dma buffers
with the following code:

static int mpc512x_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
	struct snd_pcm_substream *substream = pcm->streams[stream].substream;
	struct snd_dma_buffer *buf = &substream->dma_buffer;
	size_t size = mpc512x_pcm_hardware.buffer_bytes_max;

	buf->dev.type = SNDRV_DMA_TYPE_DEV;
	buf->dev.dev = pcm->card->dev;
	buf->private_data = NULL;
	buf->area = dma_alloc_coherent(pcm->card->dev, size,
				       &buf->addr, GFP_KERNEL);
	if (!buf->area)
		return -ENOMEM;
	buf->bytes = size;
	return 0;

Given the way the dma buffers are allocated if I just add
snd_pcm_hardware struct with the alsa framework use a generic mmap
function or do I still need to implement one?  If I need to implement
a mmap callback what is the fastest and most simple way to add that

Second, I need to test dmix with my driver.  My codec only supports
S16_BE.  When I try to use `aplay -Dplug:dmix -f SE16_BE mywave.raw` I
get the error `requested or auto-format is not available`.  After
looking in pcm_direct.c it appears that when I use -Dplug:dmx it
ignores -f S16_BE and is defaulting to some format that my codec
doesn't support.  I don't have a /etc/alsa.conf or ~/.asoundrc file
and /proc/asound/modules doesn't exists.  Where is aplay getting the
default setting for plug:dmix?  How can I override those defaults?

I am using alsa-lib-1.0.11rc2.


More information about the Alsa-devel mailing list