#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/dma-mapping.h>
#include <linux/dma-map-ops.h>
#include <linux/genalloc.h>
#include <linux/highmem.h>
#include <linux/vmalloc.h>
#ifdef CONFIG_X86
#include <asm/set_memory.h>
#endif
#include <sound/memalloc.h>
struct snd_malloc_ops { … };
#define DEFAULT_GFP …
static const struct snd_malloc_ops *snd_dma_get_ops(struct snd_dma_buffer *dmab);
static void *__snd_dma_alloc_pages(struct snd_dma_buffer *dmab, size_t size)
{ … }
int snd_dma_alloc_dir_pages(int type, struct device *device,
enum dma_data_direction dir, size_t size,
struct snd_dma_buffer *dmab)
{ … }
EXPORT_SYMBOL(…);
int snd_dma_alloc_pages_fallback(int type, struct device *device, size_t size,
struct snd_dma_buffer *dmab)
{ … }
EXPORT_SYMBOL(…);
void snd_dma_free_pages(struct snd_dma_buffer *dmab)
{ … }
EXPORT_SYMBOL(…);
static void __snd_release_pages(struct device *dev, void *res)
{ … }
struct snd_dma_buffer *
snd_devm_alloc_dir_pages(struct device *dev, int type,
enum dma_data_direction dir, size_t size)
{ … }
EXPORT_SYMBOL_GPL(…);
int snd_dma_buffer_mmap(struct snd_dma_buffer *dmab,
struct vm_area_struct *area)
{ … }
EXPORT_SYMBOL(…);
#ifdef CONFIG_HAS_DMA
void snd_dma_buffer_sync(struct snd_dma_buffer *dmab,
enum snd_dma_sync_mode mode)
{ … }
EXPORT_SYMBOL_GPL(…);
#endif
dma_addr_t snd_sgbuf_get_addr(struct snd_dma_buffer *dmab, size_t offset)
{ … }
EXPORT_SYMBOL(…);
struct page *snd_sgbuf_get_page(struct snd_dma_buffer *dmab, size_t offset)
{ … }
EXPORT_SYMBOL(…);
unsigned int snd_sgbuf_get_chunk_size(struct snd_dma_buffer *dmab,
unsigned int ofs, unsigned int size)
{ … }
EXPORT_SYMBOL(…);
static void *do_alloc_pages(struct device *dev, size_t size, dma_addr_t *addr,
bool wc)
{ … }
static void do_free_pages(void *p, size_t size, bool wc)
{ … }
static void *snd_dma_continuous_alloc(struct snd_dma_buffer *dmab, size_t size)
{ … }
static void snd_dma_continuous_free(struct snd_dma_buffer *dmab)
{ … }
static int snd_dma_continuous_mmap(struct snd_dma_buffer *dmab,
struct vm_area_struct *area)
{ … }
static const struct snd_malloc_ops snd_dma_continuous_ops = …;
static void *snd_dma_vmalloc_alloc(struct snd_dma_buffer *dmab, size_t size)
{ … }
static void snd_dma_vmalloc_free(struct snd_dma_buffer *dmab)
{ … }
static int snd_dma_vmalloc_mmap(struct snd_dma_buffer *dmab,
struct vm_area_struct *area)
{ … }
#define get_vmalloc_page_addr(dmab, offset) …
static dma_addr_t snd_dma_vmalloc_get_addr(struct snd_dma_buffer *dmab,
size_t offset)
{ … }
static struct page *snd_dma_vmalloc_get_page(struct snd_dma_buffer *dmab,
size_t offset)
{ … }
static unsigned int
snd_dma_vmalloc_get_chunk_size(struct snd_dma_buffer *dmab,
unsigned int ofs, unsigned int size)
{ … }
static const struct snd_malloc_ops snd_dma_vmalloc_ops = …;
#ifdef CONFIG_HAS_DMA
#ifdef CONFIG_GENERIC_ALLOCATOR
static void *snd_dma_iram_alloc(struct snd_dma_buffer *dmab, size_t size)
{ … }
static void snd_dma_iram_free(struct snd_dma_buffer *dmab)
{ … }
static int snd_dma_iram_mmap(struct snd_dma_buffer *dmab,
struct vm_area_struct *area)
{ … }
static const struct snd_malloc_ops snd_dma_iram_ops = …;
#endif
static void *snd_dma_dev_alloc(struct snd_dma_buffer *dmab, size_t size)
{ … }
static void snd_dma_dev_free(struct snd_dma_buffer *dmab)
{ … }
static int snd_dma_dev_mmap(struct snd_dma_buffer *dmab,
struct vm_area_struct *area)
{ … }
static const struct snd_malloc_ops snd_dma_dev_ops = …;
#ifdef CONFIG_SND_DMA_SGBUF
static void *snd_dma_wc_alloc(struct snd_dma_buffer *dmab, size_t size)
{ … }
static void snd_dma_wc_free(struct snd_dma_buffer *dmab)
{ … }
static int snd_dma_wc_mmap(struct snd_dma_buffer *dmab,
struct vm_area_struct *area)
{ … }
#else
static void *snd_dma_wc_alloc(struct snd_dma_buffer *dmab, size_t size)
{
return dma_alloc_wc(dmab->dev.dev, size, &dmab->addr, DEFAULT_GFP);
}
static void snd_dma_wc_free(struct snd_dma_buffer *dmab)
{
dma_free_wc(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr);
}
static int snd_dma_wc_mmap(struct snd_dma_buffer *dmab,
struct vm_area_struct *area)
{
return dma_mmap_wc(dmab->dev.dev, area,
dmab->area, dmab->addr, dmab->bytes);
}
#endif
static const struct snd_malloc_ops snd_dma_wc_ops = …;
static void *snd_dma_noncontig_alloc(struct snd_dma_buffer *dmab, size_t size)
{ … }
static void snd_dma_noncontig_free(struct snd_dma_buffer *dmab)
{ … }
static int snd_dma_noncontig_mmap(struct snd_dma_buffer *dmab,
struct vm_area_struct *area)
{ … }
static void snd_dma_noncontig_sync(struct snd_dma_buffer *dmab,
enum snd_dma_sync_mode mode)
{ … }
static inline void snd_dma_noncontig_iter_set(struct snd_dma_buffer *dmab,
struct sg_page_iter *piter,
size_t offset)
{ … }
static dma_addr_t snd_dma_noncontig_get_addr(struct snd_dma_buffer *dmab,
size_t offset)
{ … }
static struct page *snd_dma_noncontig_get_page(struct snd_dma_buffer *dmab,
size_t offset)
{ … }
static unsigned int
snd_dma_noncontig_get_chunk_size(struct snd_dma_buffer *dmab,
unsigned int ofs, unsigned int size)
{ … }
static const struct snd_malloc_ops snd_dma_noncontig_ops = …;
#ifdef CONFIG_SND_DMA_SGBUF
struct snd_dma_sg_fallback { … };
static void __snd_dma_sg_fallback_free(struct snd_dma_buffer *dmab,
struct snd_dma_sg_fallback *sgbuf)
{ … }
static void *snd_dma_sg_fallback_alloc(struct snd_dma_buffer *dmab, size_t size)
{ … }
static void snd_dma_sg_fallback_free(struct snd_dma_buffer *dmab)
{ … }
static int snd_dma_sg_fallback_mmap(struct snd_dma_buffer *dmab,
struct vm_area_struct *area)
{ … }
static void *snd_dma_sg_alloc(struct snd_dma_buffer *dmab, size_t size)
{ … }
static const struct snd_malloc_ops snd_dma_sg_ops = …;
#endif
static void *snd_dma_noncoherent_alloc(struct snd_dma_buffer *dmab, size_t size)
{ … }
static void snd_dma_noncoherent_free(struct snd_dma_buffer *dmab)
{ … }
static int snd_dma_noncoherent_mmap(struct snd_dma_buffer *dmab,
struct vm_area_struct *area)
{ … }
static void snd_dma_noncoherent_sync(struct snd_dma_buffer *dmab,
enum snd_dma_sync_mode mode)
{ … }
static const struct snd_malloc_ops snd_dma_noncoherent_ops = …;
#endif
static const struct snd_malloc_ops *snd_dma_ops[] = …;
static const struct snd_malloc_ops *snd_dma_get_ops(struct snd_dma_buffer *dmab)
{ … }