diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-09-20 23:29:12 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-09-23 05:24:42 -0400 |
commit | 9d069dc00b02b886abe3cab5e369140f7cd78965 (patch) | |
tree | d2f29878332a7c36a6c30128b67b2780c4a44f41 /include/sound/pcm.h | |
parent | 3d98c21d064bfbb8c6fddc659471acb4950320fa (diff) |
ALSA: Make snd_sgbuf_get_{ptr|addr}() available for non-SG cases
Passing struct snd_dma_buffer pointer instead, so that they work no
matter whether real SG buffer is used or not.
This is a preliminary work for the HD-audio DSP loader code.
Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include/sound/pcm.h')
-rw-r--r-- | include/sound/pcm.h | 39 |
1 files changed, 14 insertions, 25 deletions
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) |