diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2009-12-18 03:29:00 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-12-18 06:54:01 -0500 |
commit | 681b84e17747e1c208e8e1acc54cc5e612da84d1 (patch) | |
tree | f82316d8038b17711bdfbfb4e9ea7f2d76b5a9fc /include/sound | |
parent | 14d44e2c2cb2ef3c88c5090a2d419772e15e7a16 (diff) |
sound: pcm: add vmalloc buffer helper functions
There are now five copies of the code to allocate a PCM buffer using
vmalloc(). Add a sixth in the core so that the others can be removed.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include/sound')
-rw-r--r-- | include/sound/pcm.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/sound/pcm.h b/include/sound/pcm.h index c83a4a79f16b..0ad2d28f2360 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h | |||
@@ -905,6 +905,44 @@ int snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm, | |||
905 | int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size); | 905 | int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size); |
906 | int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream); | 906 | int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream); |
907 | 907 | ||
908 | int _snd_pcm_lib_alloc_vmalloc_buffer(struct snd_pcm_substream *substream, | ||
909 | size_t size, gfp_t gfp_flags); | ||
910 | int snd_pcm_lib_free_vmalloc_buffer(struct snd_pcm_substream *substream); | ||
911 | struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream, | ||
912 | unsigned long offset); | ||
913 | #if 0 /* for kernel-doc */ | ||
914 | /** | ||
915 | * snd_pcm_lib_alloc_vmalloc_buffer - allocate virtual DMA buffer | ||
916 | * @substream: the substream to allocate the buffer to | ||
917 | * @size: the requested buffer size, in bytes | ||
918 | * | ||
919 | * Allocates the PCM substream buffer using vmalloc(), i.e., the memory is | ||
920 | * contiguous in kernel virtual space, but not in physical memory. Use this | ||
921 | * if the buffer is accessed by kernel code but not by device DMA. | ||
922 | * | ||
923 | * Returns 1 if the buffer was changed, 0 if not changed, or a negative error | ||
924 | * code. | ||
925 | */ | ||
926 | static int snd_pcm_lib_alloc_vmalloc_buffer | ||
927 | (struct snd_pcm_substream *substream, size_t size); | ||
928 | /** | ||
929 | * snd_pcm_lib_alloc_vmalloc_32_buffer - allocate 32-bit-addressable buffer | ||
930 | * @substream: the substream to allocate the buffer to | ||
931 | * @size: the requested buffer size, in bytes | ||
932 | * | ||
933 | * This function works like snd_pcm_lib_alloc_vmalloc_buffer(), but uses | ||
934 | * vmalloc_32(), i.e., the pages are allocated from 32-bit-addressable memory. | ||
935 | */ | ||
936 | static int snd_pcm_lib_alloc_vmalloc_32_buffer | ||
937 | (struct snd_pcm_substream *substream, size_t size); | ||
938 | #endif | ||
939 | #define snd_pcm_lib_alloc_vmalloc_buffer(subs, size) \ | ||
940 | _snd_pcm_lib_alloc_vmalloc_buffer \ | ||
941 | (subs, size, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO) | ||
942 | #define snd_pcm_lib_alloc_vmalloc_32_buffer(subs, size) \ | ||
943 | _snd_pcm_lib_alloc_vmalloc_buffer \ | ||
944 | (subs, size, GFP_KERNEL | GFP_DMA32 | __GFP_ZERO) | ||
945 | |||
908 | #ifdef CONFIG_SND_DMA_SGBUF | 946 | #ifdef CONFIG_SND_DMA_SGBUF |
909 | /* | 947 | /* |
910 | * SG-buffer handling | 948 | * SG-buffer handling |