lkml.org 
[lkml]   [2012]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/3] ALSA: pcm: add apis for writecombine dma buffer allocation
Date
Add APIs for allocation/deallocation of writecombine dma buffer
for pcm substreams.
The write combine dma buffer is not supported on few
architecture like ARM and restricting these APIs support
for ARM specific.

This can be make available to other architecture if they
start supporting this.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
include/sound/pcm.h | 17 +++++++++++++++
sound/core/pcm_native.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index e7afcc9..e1c8ac4 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -1054,6 +1054,23 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, struct vm_area_s
#define snd_pcm_lib_mmap_iomem NULL
#endif

+/**
+ * Allocate the write combine DMA buffer for the PCM streams.
+ * Not all architecture support the writecombine dma allocation and
+ * hence restricting this to ARM specific. Once all architecture
+ * support the writecombine dma buffer then these APIs will be available
+ * for all architecture.
+ */
+#ifdef CONFIG_ARM
+int snd_pcm_lib_alloc_writecombine_dma_buffer(struct snd_pcm *pcm,
+ size_t size, int stream);
+void snd_pcm_lib_dealloc_writecombine_dma_buffer(struct snd_pcm *pcm,
+ int stream);
+int snd_pcm_lib_mmap_writecombine_dma_buffer(
+ struct snd_pcm_substream *substream,
+ struct vm_area_struct *vma);
+#endif
+
#define snd_pcm_lib_mmap_vmalloc NULL

static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max)
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 53b5ada..fa56ad9 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3213,6 +3213,59 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream,
EXPORT_SYMBOL(snd_pcm_lib_mmap_iomem);
#endif /* SNDRV_PCM_INFO_MMAP */

+#ifdef CONFIG_ARM
+int snd_pcm_lib_alloc_writecombine_dma_buffer(struct snd_pcm *pcm,
+ size_t size, int stream)
+{
+ struct snd_pcm_substream *substream = pcm->streams[stream].substream;
+ struct snd_dma_buffer *buf = &substream->dma_buffer;
+
+ buf->area = dma_alloc_writecombine(pcm->card->dev, size,
+ &buf->addr, GFP_KERNEL);
+ if (!buf->area)
+ return -ENOMEM;
+
+ buf->dev.type = SNDRV_DMA_TYPE_DEV;
+ buf->dev.dev = pcm->card->dev;
+ buf->private_data = NULL;
+ buf->bytes = size;
+
+ return 0;
+}
+EXPORT_SYMBOL(snd_pcm_lib_alloc_writecombine_dma_buffer);
+
+void snd_pcm_lib_dealloc_writecombine_dma_buffer(struct snd_pcm *pcm,
+ int stream)
+{
+ struct snd_pcm_substream *substream = pcm->streams[stream].substream;
+ struct snd_dma_buffer *buf;
+
+ if (!substream)
+ return;
+
+ buf = &substream->dma_buffer;
+ if (!buf->area)
+ return;
+
+ dma_free_writecombine(pcm->card->dev, buf->bytes,
+ buf->area, buf->addr);
+ buf->area = NULL;
+}
+EXPORT_SYMBOL(snd_pcm_lib_dealloc_writecombine_dma_buffer);
+
+int snd_pcm_lib_mmap_writecombine_dma_buffer(
+ struct snd_pcm_substream *substream,
+ struct vm_area_struct *vma)
+{
+ struct snd_pcm_runtime *runtime = substream->runtime;
+
+ return dma_mmap_writecombine(substream->pcm->card->dev, vma,
+ runtime->dma_area, runtime->dma_addr,
+ runtime->dma_bytes);
+}
+EXPORT_SYMBOL(snd_pcm_lib_mmap_writecombine_dma_buffer);
+#endif
+
/*
* mmap DMA buffer
*/
--
1.7.1.1


\
 
 \ /
  Last update: 2012-06-29 13:21    [W:0.076 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site