[alsa-devel] [PATCH 2/2] ASoC: generic-dmaengine-pcm: Support on-chip internal memory for DMA buffer

Nicolin Chen b42378 at freescale.com
Wed Oct 16 10:18:04 CEST 2013


Add type check when allocating memory space for DMA buffer.

Signed-off-by: Nicolin Chen <b42378 at freescale.com>
---
 include/sound/dmaengine_pcm.h         | 4 ++++
 sound/soc/soc-generic-dmaengine-pcm.c | 8 +++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h
index f11c35c..587f091 100644
--- a/include/sound/dmaengine_pcm.h
+++ b/include/sound/dmaengine_pcm.h
@@ -96,6 +96,10 @@ void snd_dmaengine_pcm_set_config_from_dai_data(
  * playback.
  */
 #define SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX BIT(3)
+/*
+ * The memory space used by DMA is allocated from SoC on-chip internal memory
+ */
+#define SND_DMAENGINE_PCM_FLAG_DMA_IRAM BIT(4)
 
 /**
  * struct snd_dmaengine_pcm_config - Configuration data for dmaengine based PCM
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
index e29ec3c..dd72964 100644
--- a/sound/soc/soc-generic-dmaengine-pcm.c
+++ b/sound/soc/soc-generic-dmaengine-pcm.c
@@ -142,7 +142,7 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
 	struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
 	const struct snd_dmaengine_pcm_config *config = pcm->config;
 	struct snd_pcm_substream *substream;
-	unsigned int i;
+	unsigned int i, type = SNDRV_DMA_TYPE_DEV;
 	int ret;
 
 	for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) {
@@ -162,8 +162,10 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
 			goto err_free;
 		}
 
-		ret = snd_pcm_lib_preallocate_pages(substream,
-				SNDRV_DMA_TYPE_DEV,
+		if (pcm->flags & SND_DMAENGINE_PCM_FLAG_DMA_IRAM)
+			type = SNDRV_DMA_TYPE_DEV_IRAM;
+
+		ret = snd_pcm_lib_preallocate_pages(substream, type,
 				dmaengine_dma_dev(pcm, substream),
 				config->prealloc_buffer_size,
 				config->pcm_hardware->buffer_bytes_max);
-- 
1.8.4




More information about the Alsa-devel mailing list