diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index f05cb6a8cbe0..021dc8efee8c 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -192,6 +192,9 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size, snd_malloc_dev_iram(dmab, size); if (dmab->area) break; +#ifdef CONFIG_SND_SOC_ROCKCHIP_FORCE_SRAM + 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/rockchip/Kconfig b/sound/soc/rockchip/Kconfig index 7fc51a0a4729..bbeb8ff009b5 100644 --- a/sound/soc/rockchip/Kconfig +++ b/sound/soc/rockchip/Kconfig @@ -6,6 +6,13 @@ config SND_SOC_ROCKCHIP the Rockchip SoCs' Audio interfaces. You will also need to select the audio interfaces to support below. +config SND_SOC_ROCKCHIP_FORCE_SRAM + bool "Rockchip force using sram buffer" + def_bool n + help + Say Y if you want to force using sram buffer for pcm buffer, + but the sram size is limited. + config SND_SOC_ROCKCHIP_I2S tristate "Rockchip I2S Device Driver" depends on CLKDEV_LOOKUP && SND_SOC_ROCKCHIP diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index 6fd1906af387..275a85300a01 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -267,6 +267,9 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) max_buffer_size = SIZE_MAX; } +#ifdef CONFIG_SND_SOC_ROCKCHIP_FORCE_SRAM + prealloc_buffer_size = 32 * 1024; +#endif for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) { substream = rtd->pcm->streams[i].substream;