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 <sugar.zhang@rock-chips.com>
This commit is contained in:
Sugar Zhang
2018-05-04 11:19:39 +08:00
committed by Tao Huang
parent 8ed5fc3749
commit 57fae85633
2 changed files with 26 additions and 2 deletions

View File

@@ -25,6 +25,7 @@
#include <linux/mm.h>
#include <linux/dma-mapping.h>
#include <linux/genalloc.h>
#include <linux/of.h>
#include <sound/memalloc.h>
/*
@@ -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.

View File

@@ -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++) {