From 57fae85633fe260ba1ce8ebb240b449032b09d38 Mon Sep 17 00:00:00 2001 From: Sugar Zhang Date: Fri, 4 May 2018 11:19:39 +0800 Subject: [PATCH] ASoC: rockchip: add support for "rockchip,force-iram" This patch handle the force-iram function by devicetree. Change-Id: I95fe96091c560507a37cd0833cf2507e4d2bc636 Signed-off-by: Sugar Zhang --- sound/core/memalloc.c | 9 ++++++++- sound/soc/soc-generic-dmaengine-pcm.c | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index 021dc8efee8c..46ff830b6f53 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -25,6 +25,7 @@ #include #include #include +#include #include /* @@ -193,7 +194,13 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size, if (dmab->area) break; #ifdef CONFIG_SND_SOC_ROCKCHIP_FORCE_SRAM - break; + if (device->of_node) { + if (of_property_read_bool(device->of_node, + "rockchip,force-iram")) { + dev_err(device, "iram space is not enough!\n"); + break; + } + } #endif /* Internal memory might have limited size and no enough space, * so if we fail to malloc, try to fetch memory traditionally. diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index 275a85300a01..50c5c1e9e77b 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -268,7 +268,24 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) } #ifdef CONFIG_SND_SOC_ROCKCHIP_FORCE_SRAM - prealloc_buffer_size = 32 * 1024; + for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) { + substream = rtd->pcm->streams[i].substream; + if (substream) + break; + } + + if (!substream) + return 0; + + dev = dmaengine_dma_dev(pcm, substream); + if (dev->of_node) { + ret = of_property_read_bool(dev->of_node, + "rockchip,force-iram"); + if (ret) + prealloc_buffer_size = 32 * 1024; + } + + dev = rtd->platform->dev; #endif for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) {