[alsa-devel] dmix and mmap
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
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
On Thu, Apr 30, 2009 at 10:13 AM, Mark Brown broonie@sirena.org.uk wrote:
On Thu, Apr 30, 2009 at 10:10:23AM -0500, Gabriel Johnson wrote:
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).
On Thu, Apr 30, 2009 at 02:29:41PM -0500, Gabriel Johnson wrote:
is working. Now using the ioctl to get mmap address of the dma space isn't working, I get a kernel machine check error:
...
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.
At Fri, 1 May 2009 12:32:41 +0100, Mark Brown wrote:
On Thu, Apr 30, 2009 at 02:29:41PM -0500, Gabriel Johnson wrote:
is working. Now using the ioctl to get mmap address of the dma space isn't working, I get a kernel machine check error:
...
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
On Fri, May 1, 2009 at 6:32 AM, Mark Brown broonie@sirena.org.uk wrote:
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?
On Mon, May 04, 2009 at 11:57:20AM -0500, Timur Tabi wrote:
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.
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.
On Tue, May 5, 2009 at 6:32 AM, Mark Brown broonie@sirena.org.uk wrote:
On Mon, May 04, 2009 at 11:57:20AM -0500, Timur Tabi wrote:
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.
participants (4)
-
Gabriel Johnson
-
Mark Brown
-
Takashi Iwai
-
Timur Tabi