From 69b65400528f3c19e21fdd38b36a4a81ff7feca0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Wed, 16 May 2012 15:03:58 +0800 Subject: [PATCH] rk30: support sound playback DMA buffer in internal SRAM --- arch/arm/mach-rk30/include/mach/io.h | 1 + arch/arm/mach-rk30/io.c | 8 ++++++++ arch/arm/plat-rk/Kconfig | 4 ++++ sound/soc/rk29/rk29_pcm.c | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/arch/arm/mach-rk30/include/mach/io.h b/arch/arm/mach-rk30/include/mach/io.h index 58cfda9908c8..0e6d8652c66c 100644 --- a/arch/arm/mach-rk30/include/mach/io.h +++ b/arch/arm/mach-rk30/include/mach/io.h @@ -34,6 +34,7 @@ #define RK30_L2MEM_SIZE SZ_512K #define RK30_IMEM_PHYS 0x10080000 #define RK30_IMEM_BASE IOMEM(0xFEF00000) +#define RK30_IMEM_NONCACHED RK30_IO_TO_VIRT0(RK30_IMEM_PHYS) #define RK30_IMEM_SIZE SZ_64K #define RK30_GPU_PHYS 0x10090000 #define RK30_GPU_SIZE SZ_64K diff --git a/arch/arm/mach-rk30/io.c b/arch/arm/mach-rk30/io.c index 791267c0affe..a548607c5a50 100644 --- a/arch/arm/mach-rk30/io.c +++ b/arch/arm/mach-rk30/io.c @@ -55,6 +55,14 @@ static struct map_desc rk30_io_desc[] __initdata = { RK30_DEVICE(PWM23), RK30_DEVICE(DDR_PCTL), RK30_DEVICE(DDR_PUBL), +#ifdef CONFIG_RK_SRAM_DMA + { + .virtual = (unsigned long) RK30_IMEM_NONCACHED, + .pfn = __phys_to_pfn(RK30_IMEM_PHYS), + .length = RK30_IMEM_SIZE, + .type = MT_MEMORY_NONCACHED, + }, +#endif }; void __init rk30_map_common_io(void) diff --git a/arch/arm/plat-rk/Kconfig b/arch/arm/plat-rk/Kconfig index 9b19e420f832..c02435d6cb14 100644 --- a/arch/arm/plat-rk/Kconfig +++ b/arch/arm/plat-rk/Kconfig @@ -132,4 +132,8 @@ config RK_DEBUG_UART help Select a UART for debugging. -1 disable. +config RK_SRAM_DMA + bool "Sound playback DMA buffer in internal SRAM" + depends on ARCH_RK30 + endif diff --git a/sound/soc/rk29/rk29_pcm.c b/sound/soc/rk29/rk29_pcm.c index 6285a94f50e4..048038077c62 100755 --- a/sound/soc/rk29/rk29_pcm.c +++ b/sound/soc/rk29/rk29_pcm.c @@ -49,9 +49,17 @@ static const struct snd_pcm_hardware rockchip_pcm_hardware = { SNDRV_PCM_FMTBIT_S16_LE, .channels_min = 2, .channels_max = 8, +#ifdef CONFIG_RK_SRAM_DMA + .buffer_bytes_max = 48*1024, +#else .buffer_bytes_max = 128*1024, +#endif .period_bytes_min = 64, ///PAGE_SIZE, +#ifdef CONFIG_RK_SRAM_DMA + .period_bytes_max = 4096*4, +#else .period_bytes_max = 2048*4,///PAGE_SIZE*2, +#endif .periods_min = 3,///2, .periods_max = 128, .fifo_size = 16, @@ -492,6 +500,11 @@ static struct snd_pcm_ops rockchip_pcm_ops = { .mmap = rockchip_pcm_mmap, }; +#ifdef CONFIG_ARCH_RK30 +#define SRAM_DMA_PHYS (dma_addr_t)(RK30_IMEM_PHYS + 16*1024) +#define SRAM_DMA_START (RK30_IMEM_NONCACHED + 16*1024) +#endif + static int rockchip_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) { struct snd_pcm_substream *substream = pcm->streams[stream].substream; @@ -503,6 +516,12 @@ static int rockchip_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) buf->dev.type = SNDRV_DMA_TYPE_DEV; buf->dev.dev = pcm->card->dev; buf->private_data = NULL; +#ifdef CONFIG_RK_SRAM_DMA + if (stream == SNDRV_PCM_STREAM_PLAYBACK) { + buf->area = SRAM_DMA_START; + buf->addr = SRAM_DMA_PHYS; + } else +#endif buf->area = dma_alloc_writecombine(pcm->card->dev, size, &buf->addr, GFP_KERNEL); if (!buf->area) -- 2.34.1