Skip to contentSkip to conversation

dmix and mmap

DISCUSSION Gabriel Johnson 4 participants 8 messages Apr 30, 2009 – May 6, 2009

lore
Share & tools
lore
#0 lore raw

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 SNDRV_PCM_INFO_MMAP and SNDRV_PCM_INFO_MMAP_VALID to my 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 support?

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.

Thanks,
Gabe

#1 lore raw
Quoted 1 line · Gabriel Johnson

I am using alsa-lib-1.0.11rc2.

This is a very old version of alsa-lib - I haven't looked at either of your problems but I would suggest upgrading to a current version (the release version is 1.0.19).

#2 lore raw

I updated to 1.0.19, it appears that aplay -Dplug:dmix -f cdr raw.wave is working. Now using the ioctl to get mmap address of the dma space isn't working, I get a kernel machine check error:

Playing raw data '/home/bin/stw.raw' : Signed 16 bit Big Endian, Rate 44100 Hz, Stereo

[   78.475303] Machine check in kernel mode.
[   78.479246] Caused by (from SRR1=ff37598): Unknown values in msr
[   78.527195] Machine check in kernel mode.
[   78.531121] Caused by (from SRR1=47590): Transfer error ack signal
[   78.540376] Bad page state in process 'aplay'
[   78.540388] page:c5be3f20 flags:0x00000004 mapping:00000000
mapcount:1 count:0
[   78.540400] Trying to fix it up, but a reboot is needed

Should the default mmap ioctl functions work on powerpc?

Thanks,
Gabe

Quoted 8 lines · Mark Brown
Quoted 1 line · Gabriel Johnson

I am using alsa-lib-1.0.11rc2.

This is a very old version of alsa-lib - I haven't looked at either of your problems but I would suggest upgrading to a current version (the release version is 1.0.19).

#3 lore raw
Quoted 2 lines · Gabriel Johnson

is working. Now using the ioctl to get mmap address of the dma space isn't working, I get a kernel machine check error:

...

Quoted 1 line

Should the default mmap ioctl functions work on powerpc?

I know that there were some problems with PowerPC memory access, unfortunately I don't know any specifics or if these issues are fixed in current kernels. Searching for postings by Takashi Iwai on the PowerPC kernel lists might turn something up.

#4 lore raw

At Fri, 1 May 2009 12:32:41 +0100,

Quoted 6 lines · Mark Brown
Quoted 2 lines · Gabriel Johnson

is working. Now using the ioctl to get mmap address of the dma space isn't working, I get a kernel machine check error:

Quoted 8 lines

...

Quoted 1 line

Should the default mmap ioctl functions work on powerpc?

I know that there were some problems with PowerPC memory access, unfortunately I don't know any specifics or if these issues are fixed in current kernels. Searching for postings by Takashi Iwai on the PowerPC kernel lists might turn something up.

The ALSA mmap support on non-coherent architecture is still buggy.

Some test patches are found in sound.git tree test/dma-fix branch.

    git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git

The sound-unstable tree already merges this branch. Try that tree instead.
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-unstable-2.6.git

Takashi

#5 lore raw
In reply to Mark Brown
Quoted 4 lines · Mark Brown

I know that there were some problems with PowerPC memory access, unfortunately I don't know any specifics or if these issues are fixed in current kernels.  Searching for postings by Takashi Iwai on the PowerPC kernel lists might turn something up.

The PowerPC MPC8610 drivers enable mmap support, and it seems to work, but that chip has a coherent MMU. I've never done a definitive test that it works, though. What's the easiest way to test mmap?

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#6 lore raw
Quoted 3 lines · Timur Tabi

The PowerPC MPC8610 drivers enable mmap support, and it seems to work, but that chip has a coherent MMU. I've never done a definitive test that it works, though. What's the easiest way to test mmap?

If you had issues they'd be fairly obvious in the audio stream.

#7 lore raw

Thanks for the help. I ended up using Takashi Iwai's dma_mmap_coherent patch and then added the mmap callback to my driver.
So far it seems to be working.

Quoted 8 lines · Mark Brown
Quoted 3 lines · Timur Tabi

The PowerPC MPC8610 drivers enable mmap support, and it seems to work, but that chip has a coherent MMU.  I've never done a definitive test that it works, though.  What's the easiest way to test mmap?

If you had issues they'd be fairly obvious in the audio stream.