ALSA: Add SoC on-chip internal memory support for DMA buffer allocation
PATCH v5 1/1 ALSA: Add SoC on-chip internal memory support for DMA buffer allocation
Now it's quite common that an SoC contains its on-chip internal memory. By using this memory space for DMA buffer during audio playback/record, we can shutdown the voltage for external memory to save power.
Thus add new DEV type with iram malloc()/free() and accordingly modify current default mmap() for the iram circumstance.
---
Changelogv4->v5:
* Minimized the OF dependency.v3->v4:
* Appropriately placed '#ifdef CONFIG_OF'
* Tested by adding '#undef CONFIG_OF' to modified files, and passed compiling.v2->v3:
* Moved iram specific mmap procedure out of ifdef ARCH_HAS_DMA_MMAP_COHERENTv1->v2:
* Added of_node check
* Dropped noops and unused physical addr in snd_free_dev_iram()
--- include/sound/memalloc.h | 1 + sound/core/memalloc.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ sound/core/pcm_native.c | 6 +++++ 3 files changed, 76 insertions(+)
include/sound/memalloc.h +1 -0
@@ -52,6 +52,7 @@ struct snd_dma_device {#else #define SNDRV_DMA_TYPE_DEV_SG SNDRV_DMA_TYPE_DEV/* no SG-buf support */ #endif +#define SNDRV_DMA_TYPE_DEV_IRAM 4/* generic device iram-buffer */ /* * info for buffer allocation
sound/core/memalloc.c +69 -0
93 lines not on this page · raw message
sound/core/pcm_native.c +6 -0
@@ -3199,6 +3199,12 @@ int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *area) { area->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; +if (substream->dma_buffer.dev.type ==SNDRV_DMA_TYPE_DEV_IRAM ) { + area->vm_page_prot =pgprot_writecombine (area->vm_page_prot); +return remap_pfn_range (area, area->vm_start, + substream->dma_buffer.addr >>PAGE_SHIFT , + area->vm_end - area->vm_start, area->vm_page_prot); + }#ifdef ARCH_HAS_DMA_MMAP_COHERENT if (!substream->ops->page && substream->dma_buffer.dev.type ==SNDRV_DMA_TYPE_DEV )
Signature · 1 line
1.8.4