Thread (4 messages) flat view 4 messages, 2 authors, 2006-06-14

Re: [Alsa-devel] RFC: dma_mmap_coherent() for powerpc/ppc architecture and ALSA?

From: Takashi Iwai <hidden>
Date: 2006-06-14 14:42:59
Also in: alsa-devel, lkml

At Mon, 12 Jun 2006 16:42:54 +0200,
Gerhard Pircher wrote:
quoted
quoted
But as far as I understand this would require a rewrite of all the
ALSA drivers (or at least a rewrite of the ALSA's DMA helper
functions).
Yes.  The change of ALSA side has been also on my tree.  But it was
still pending since I'm not satisfied with the design yet.
If you're interested in it, let me know.  I'll post the patch.
Yes, please! Then I can test, if the dma_mmap_coherent() patch works on
my non cache coherent powerpc machine.
For using dma_mmap_coherent(), the patch below should suffice.
(Also you need to enable HAVE_DMA_MMAP_COHERENT there not only for
 ARM.)
Do you think the DMA Layer/ALSA patches will go upstream in one of
the next ALSA/Linux kernel versions? 
Definitely no 2.6.18 material yet.


Takashi


diff -r 08577d0b45ef sound/core/pcm_native.c
--- a/sound/core/pcm_native.c	Tue Jun 13 12:01:14 2006 +0200
+++ b/sound/core/pcm_native.c	Wed Jun 14 16:40:32 2006 +0200
@@ -3123,6 +3123,10 @@ static int snd_pcm_mmap_control(struct s
 }
 #endif /* coherent mmap */
 
+#if defined(CONFIG_ARM)
+#define HAVE_DMA_MMAP_COHERENT
+#endif
+
 /*
  * nopage callback for mmapping a RAM page
  */
@@ -3166,6 +3170,14 @@ static struct vm_operations_struct snd_p
 	.nopage =	snd_pcm_mmap_data_nopage,
 };
 
+#ifdef HAVE_DMA_MMAP_COHERENT
+static struct vm_operations_struct snd_pcm_vm_ops_data_one_map =
+{
+	.open =		snd_pcm_mmap_data_open,
+	.close =	snd_pcm_mmap_data_close,
+};
+#endif
+
 /*
  * mmap the DMA buffer on RAM
  */
@@ -3175,6 +3187,16 @@ static int snd_pcm_default_mmap(struct s
 	area->vm_ops = &snd_pcm_vm_ops_data;
 	area->vm_private_data = substream;
 	area->vm_flags |= VM_RESERVED;
+#ifdef HAVE_DMA_MMAP_COHERENT
+	if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) {
+		area->vm_ops = &snd_pcm_vm_ops_data_one_map;
+		if (dma_mmap_coherent(substream->dma_buffer.dev.dev, area,
+				      substream->runtime->dma_area,
+				      substream->runtime->dma_addr,
+				      area->vm_end - area->vm_start))
+			return -EAGAIN;
+	}
+#endif
 	atomic_inc(&substream->mmap_count);
 	return 0;
 }
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help