diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/sound/memalloc.h | 27 | ||||
| -rw-r--r-- | include/sound/pcm.h | 39 |
2 files changed, 39 insertions, 27 deletions
diff --git a/include/sound/memalloc.h b/include/sound/memalloc.h index c42506212649..844af65af626 100644 --- a/include/sound/memalloc.h +++ b/include/sound/memalloc.h | |||
| @@ -98,8 +98,10 @@ static inline unsigned int snd_sgbuf_aligned_pages(size_t size) | |||
| 98 | /* | 98 | /* |
| 99 | * return the physical address at the corresponding offset | 99 | * return the physical address at the corresponding offset |
| 100 | */ | 100 | */ |
| 101 | static inline dma_addr_t snd_sgbuf_get_addr(struct snd_sg_buf *sgbuf, size_t offset) | 101 | static inline dma_addr_t snd_sgbuf_get_addr(struct snd_dma_buffer *dmab, |
| 102 | size_t offset) | ||
| 102 | { | 103 | { |
| 104 | struct snd_sg_buf *sgbuf = dmab->private_data; | ||
| 103 | dma_addr_t addr = sgbuf->table[offset >> PAGE_SHIFT].addr; | 105 | dma_addr_t addr = sgbuf->table[offset >> PAGE_SHIFT].addr; |
| 104 | addr &= PAGE_MASK; | 106 | addr &= PAGE_MASK; |
| 105 | return addr + offset % PAGE_SIZE; | 107 | return addr + offset % PAGE_SIZE; |
| @@ -108,10 +110,31 @@ static inline dma_addr_t snd_sgbuf_get_addr(struct snd_sg_buf *sgbuf, size_t off | |||
| 108 | /* | 110 | /* |
| 109 | * return the virtual address at the corresponding offset | 111 | * return the virtual address at the corresponding offset |
| 110 | */ | 112 | */ |
| 111 | static inline void *snd_sgbuf_get_ptr(struct snd_sg_buf *sgbuf, size_t offset) | 113 | static inline void *snd_sgbuf_get_ptr(struct snd_dma_buffer *dmab, |
| 114 | size_t offset) | ||
| 112 | { | 115 | { |
| 116 | struct snd_sg_buf *sgbuf = dmab->private_data; | ||
| 113 | return sgbuf->table[offset >> PAGE_SHIFT].buf + offset % PAGE_SIZE; | 117 | return sgbuf->table[offset >> PAGE_SHIFT].buf + offset % PAGE_SIZE; |
| 114 | } | 118 | } |
| 119 | |||
| 120 | unsigned int snd_sgbuf_get_chunk_size(struct snd_dma_buffer *dmab, | ||
| 121 | unsigned int ofs, unsigned int size); | ||
| 122 | #else | ||
| 123 | /* non-SG versions */ | ||
| 124 | static inline dma_addr_t snd_sgbuf_get_addr(struct snd_dma_buffer *dmab, | ||
| 125 | size_t offset) | ||
| 126 | { | ||
| 127 | return dmab->addr + offset; | ||
| 128 | } | ||
| 129 | |||
| 130 | static inline void *snd_sgbuf_get_ptr(struct snd_dma_buffer *dmab, | ||
| 131 | size_t offset) | ||
| 132 | { | ||
| 133 | return dmab->area + offset; | ||
| 134 | } | ||
| 135 | |||
| 136 | #define snd_sgbuf_get_chunk_size(dmab, ofs, size) (size) | ||
| 137 | |||
| 115 | #endif /* CONFIG_SND_DMA_SGBUF */ | 138 | #endif /* CONFIG_SND_DMA_SGBUF */ |
| 116 | 139 | ||
| 117 | /* allocate/release a buffer */ | 140 | /* allocate/release a buffer */ |
diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 669c85a7fb03..7e4e4e380106 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h | |||
| @@ -983,53 +983,42 @@ static int snd_pcm_lib_alloc_vmalloc_32_buffer | |||
| 983 | _snd_pcm_lib_alloc_vmalloc_buffer \ | 983 | _snd_pcm_lib_alloc_vmalloc_buffer \ |
| 984 | (subs, size, GFP_KERNEL | GFP_DMA32 | __GFP_ZERO) | 984 | (subs, size, GFP_KERNEL | GFP_DMA32 | __GFP_ZERO) |
| 985 | 985 | ||
| 986 | #define snd_pcm_get_dma_buf(substream) ((substream)->runtime->dma_buffer_p) | ||
| 987 | |||
| 986 | #ifdef CONFIG_SND_DMA_SGBUF | 988 | #ifdef CONFIG_SND_DMA_SGBUF |
| 987 | /* | 989 | /* |
| 988 | * SG-buffer handling | 990 | * SG-buffer handling |
| 989 | */ | 991 | */ |
| 990 | #define snd_pcm_substream_sgbuf(substream) \ | 992 | #define snd_pcm_substream_sgbuf(substream) \ |
| 991 | ((substream)->runtime->dma_buffer_p->private_data) | 993 | snd_pcm_get_dma_buf(substream)->private_data |
| 992 | |||
| 993 | static inline dma_addr_t | ||
| 994 | snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs) | ||
| 995 | { | ||
| 996 | struct snd_sg_buf *sg = snd_pcm_substream_sgbuf(substream); | ||
| 997 | return snd_sgbuf_get_addr(sg, ofs); | ||
| 998 | } | ||
| 999 | |||
| 1000 | static inline void * | ||
| 1001 | snd_pcm_sgbuf_get_ptr(struct snd_pcm_substream *substream, unsigned int ofs) | ||
| 1002 | { | ||
| 1003 | struct snd_sg_buf *sg = snd_pcm_substream_sgbuf(substream); | ||
| 1004 | return snd_sgbuf_get_ptr(sg, ofs); | ||
| 1005 | } | ||
| 1006 | 994 | ||
| 1007 | struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, | 995 | struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, |
| 1008 | unsigned long offset); | 996 | unsigned long offset); |
| 1009 | unsigned int snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream, | ||
| 1010 | unsigned int ofs, unsigned int size); | ||
| 1011 | |||
| 1012 | #else /* !SND_DMA_SGBUF */ | 997 | #else /* !SND_DMA_SGBUF */ |
| 1013 | /* | 998 | /* |
| 1014 | * fake using a continuous buffer | 999 | * fake using a continuous buffer |
| 1015 | */ | 1000 | */ |
| 1001 | #define snd_pcm_sgbuf_ops_page NULL | ||
| 1002 | #endif /* SND_DMA_SGBUF */ | ||
| 1003 | |||
| 1016 | static inline dma_addr_t | 1004 | static inline dma_addr_t |
| 1017 | snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs) | 1005 | snd_pcm_sgbuf_get_addr(struct snd_pcm_substream *substream, unsigned int ofs) |
| 1018 | { | 1006 | { |
| 1019 | return substream->runtime->dma_addr + ofs; | 1007 | return snd_sgbuf_get_addr(snd_pcm_get_dma_buf(substream), ofs); |
| 1020 | } | 1008 | } |
| 1021 | 1009 | ||
| 1022 | static inline void * | 1010 | static inline void * |
| 1023 | snd_pcm_sgbuf_get_ptr(struct snd_pcm_substream *substream, unsigned int ofs) | 1011 | snd_pcm_sgbuf_get_ptr(struct snd_pcm_substream *substream, unsigned int ofs) |
| 1024 | { | 1012 | { |
| 1025 | return substream->runtime->dma_area + ofs; | 1013 | return snd_sgbuf_get_ptr(snd_pcm_get_dma_buf(substream), ofs); |
| 1026 | } | 1014 | } |
| 1027 | 1015 | ||
| 1028 | #define snd_pcm_sgbuf_ops_page NULL | 1016 | static inline unsigned int |
| 1029 | 1017 | snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream, | |
| 1030 | #define snd_pcm_sgbuf_get_chunk_size(subs, ofs, size) (size) | 1018 | unsigned int ofs, unsigned int size) |
| 1031 | 1019 | { | |
| 1032 | #endif /* SND_DMA_SGBUF */ | 1020 | return snd_sgbuf_get_chunk_size(snd_pcm_get_dma_buf(substream), ofs, size); |
| 1021 | } | ||
| 1033 | 1022 | ||
| 1034 | /* handle mmap counter - PCM mmap callback should handle this counter properly */ | 1023 | /* handle mmap counter - PCM mmap callback should handle this counter properly */ |
| 1035 | static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area) | 1024 | static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area) |
