rk30: support sound playback DMA buffer in internal SRAM
author黄涛 <huangtao@rock-chips.com>
Wed, 16 May 2012 07:03:58 +0000 (15:03 +0800)
committer黄涛 <huangtao@rock-chips.com>
Wed, 16 May 2012 07:12:04 +0000 (15:12 +0800)
arch/arm/mach-rk30/include/mach/io.h
arch/arm/mach-rk30/io.c
arch/arm/plat-rk/Kconfig
sound/soc/rk29/rk29_pcm.c

index 58cfda9908c83fcda3c021a972f6b675b878bd9d..0e6d8652c66c27ea1ccf867e3913fc9b8a9a0b0c 100644 (file)
@@ -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
index 791267c0affe6941c18a1dbe2ad23744cb659edb..a548607c5a504777773bfdc3228d503800a0ae7d 100644 (file)
@@ -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)
index 9b19e420f8324d36c5c10413ab64c727fb23d91e..c02435d6cb14acb1b0409e463ad8f964f9551177 100644 (file)
@@ -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
index 6285a94f50e43ff53b028a927f7d25683de59607..048038077c6233916796015e5455c0ab967cf407 100755 (executable)
@@ -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)