aboutsummaryrefslogtreecommitdiffstats
path: root/sound/drivers/vx/vx_pcm.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2009-12-18 03:30:55 -0500
committerTakashi Iwai <tiwai@suse.de>2009-12-18 06:57:21 -0500
commit149feef54bf543448dd4ec5820ef8ae178021c3a (patch)
tree1924aae62f8e99120bb3c2c614846891370e893e /sound/drivers/vx/vx_pcm.c
parent6cedf8696d6a01bba391bdae06231243cfe2f48a (diff)
sound: vx: use vmalloc buffer helper functions
Remove this duplicate of snd_pcm_alloc_vmalloc_buffer and use the equivalent core functions instead. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/drivers/vx/vx_pcm.c')
-rw-r--r--sound/drivers/vx/vx_pcm.c59
1 files changed, 5 insertions, 54 deletions
diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c
index 6644d0034fb..c8385d26a16 100644
--- a/sound/drivers/vx/vx_pcm.c
+++ b/sound/drivers/vx/vx_pcm.c
@@ -46,7 +46,6 @@
46 */ 46 */
47 47
48#include <linux/slab.h> 48#include <linux/slab.h>
49#include <linux/vmalloc.h>
50#include <linux/delay.h> 49#include <linux/delay.h>
51#include <sound/core.h> 50#include <sound/core.h>
52#include <sound/asoundef.h> 51#include <sound/asoundef.h>
@@ -56,55 +55,6 @@
56 55
57 56
58/* 57/*
59 * we use a vmalloc'ed (sg-)buffer
60 */
61
62/* get the physical page pointer on the given offset */
63static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs,
64 unsigned long offset)
65{
66 void *pageptr = subs->runtime->dma_area + offset;
67 return vmalloc_to_page(pageptr);
68}
69
70/*
71 * allocate a buffer via vmalloc_32().
72 * called from hw_params
73 * NOTE: this may be called not only once per pcm open!
74 */
75static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size)
76{
77 struct snd_pcm_runtime *runtime = subs->runtime;
78 if (runtime->dma_area) {
79 /* already allocated */
80 if (runtime->dma_bytes >= size)
81 return 0; /* already enough large */
82 vfree(runtime->dma_area);
83 }
84 runtime->dma_area = vmalloc_32(size);
85 if (! runtime->dma_area)
86 return -ENOMEM;
87 memset(runtime->dma_area, 0, size);
88 runtime->dma_bytes = size;
89 return 1; /* changed */
90}
91
92/*
93 * free the buffer.
94 * called from hw_free callback
95 * NOTE: this may be called not only once per pcm open!
96 */
97static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs)
98{
99 struct snd_pcm_runtime *runtime = subs->runtime;
100
101 vfree(runtime->dma_area);
102 runtime->dma_area = NULL;
103 return 0;
104}
105
106
107/*
108 * read three pending pcm bytes via inb() 58 * read three pending pcm bytes via inb()
109 */ 59 */
110static void vx_pcm_read_per_bytes(struct vx_core *chip, struct snd_pcm_runtime *runtime, 60static void vx_pcm_read_per_bytes(struct vx_core *chip, struct snd_pcm_runtime *runtime,
@@ -865,7 +815,8 @@ static snd_pcm_uframes_t vx_pcm_playback_pointer(struct snd_pcm_substream *subs)
865static int vx_pcm_hw_params(struct snd_pcm_substream *subs, 815static int vx_pcm_hw_params(struct snd_pcm_substream *subs,
866 struct snd_pcm_hw_params *hw_params) 816 struct snd_pcm_hw_params *hw_params)
867{ 817{
868 return snd_pcm_alloc_vmalloc_buffer(subs, params_buffer_bytes(hw_params)); 818 return snd_pcm_lib_alloc_vmalloc_32_buffer
819 (subs, params_buffer_bytes(hw_params));
869} 820}
870 821
871/* 822/*
@@ -873,7 +824,7 @@ static int vx_pcm_hw_params(struct snd_pcm_substream *subs,
873 */ 824 */
874static int vx_pcm_hw_free(struct snd_pcm_substream *subs) 825static int vx_pcm_hw_free(struct snd_pcm_substream *subs)
875{ 826{
876 return snd_pcm_free_vmalloc_buffer(subs); 827 return snd_pcm_lib_free_vmalloc_buffer(subs);
877} 828}
878 829
879/* 830/*
@@ -953,7 +904,7 @@ static struct snd_pcm_ops vx_pcm_playback_ops = {
953 .prepare = vx_pcm_prepare, 904 .prepare = vx_pcm_prepare,
954 .trigger = vx_pcm_trigger, 905 .trigger = vx_pcm_trigger,
955 .pointer = vx_pcm_playback_pointer, 906 .pointer = vx_pcm_playback_pointer,
956 .page = snd_pcm_get_vmalloc_page, 907 .page = snd_pcm_lib_get_vmalloc_page,
957}; 908};
958 909
959 910
@@ -1173,7 +1124,7 @@ static struct snd_pcm_ops vx_pcm_capture_ops = {
1173 .prepare = vx_pcm_prepare, 1124 .prepare = vx_pcm_prepare,
1174 .trigger = vx_pcm_trigger, 1125 .trigger = vx_pcm_trigger,
1175 .pointer = vx_pcm_capture_pointer, 1126 .pointer = vx_pcm_capture_pointer,
1176 .page = snd_pcm_get_vmalloc_page, 1127 .page = snd_pcm_lib_get_vmalloc_page,
1177}; 1128};
1178 1129
1179 1130