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 /sound/core | |
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 'sound/core')
-rw-r--r-- | sound/core/pcm_memory.c | 26 | ||||
-rw-r--r-- | sound/core/sgbuf.c | 27 |
2 files changed, 27 insertions, 26 deletions
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index 957131366dd9..69e01c4fc32d 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c | |||
@@ -327,32 +327,6 @@ struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, unsigne | |||
327 | } | 327 | } |
328 | 328 | ||
329 | EXPORT_SYMBOL(snd_pcm_sgbuf_ops_page); | 329 | EXPORT_SYMBOL(snd_pcm_sgbuf_ops_page); |
330 | |||
331 | /* | ||
332 | * compute the max chunk size with continuous pages on sg-buffer | ||
333 | */ | ||
334 | unsigned int snd_pcm_sgbuf_get_chunk_size(struct snd_pcm_substream *substream, | ||
335 | unsigned int ofs, unsigned int size) | ||
336 | { | ||
337 | struct snd_sg_buf *sg = snd_pcm_substream_sgbuf(substream); | ||
338 | unsigned int start, end, pg; | ||
339 | |||
340 | start = ofs >> PAGE_SHIFT; | ||
341 | end = (ofs + size - 1) >> PAGE_SHIFT; | ||
342 | /* check page continuity */ | ||
343 | pg = sg->table[start].addr >> PAGE_SHIFT; | ||
344 | for (;;) { | ||
345 | start++; | ||
346 | if (start > end) | ||
347 | break; | ||
348 | pg++; | ||
349 | if ((sg->table[start].addr >> PAGE_SHIFT) != pg) | ||
350 | return (start << PAGE_SHIFT) - ofs; | ||
351 | } | ||
352 | /* ok, all on continuous pages */ | ||
353 | return size; | ||
354 | } | ||
355 | EXPORT_SYMBOL(snd_pcm_sgbuf_get_chunk_size); | ||
356 | #endif /* CONFIG_SND_DMA_SGBUF */ | 330 | #endif /* CONFIG_SND_DMA_SGBUF */ |
357 | 331 | ||
358 | /** | 332 | /** |
diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c index d0f00356fc11..0a418503ec41 100644 --- a/sound/core/sgbuf.c +++ b/sound/core/sgbuf.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
24 | #include <linux/vmalloc.h> | 24 | #include <linux/vmalloc.h> |
25 | #include <linux/export.h> | ||
25 | #include <sound/memalloc.h> | 26 | #include <sound/memalloc.h> |
26 | 27 | ||
27 | 28 | ||
@@ -136,3 +137,29 @@ void *snd_malloc_sgbuf_pages(struct device *device, | |||
136 | snd_free_sgbuf_pages(dmab); /* free the table */ | 137 | snd_free_sgbuf_pages(dmab); /* free the table */ |
137 | return NULL; | 138 | return NULL; |
138 | } | 139 | } |
140 | |||
141 | /* | ||
142 | * compute the max chunk size with continuous pages on sg-buffer | ||
143 | */ | ||
144 | unsigned int snd_sgbuf_get_chunk_size(struct snd_dma_buffer *dmab, | ||
145 | unsigned int ofs, unsigned int size) | ||
146 | { | ||
147 | struct snd_sg_buf *sg = dmab->private_data; | ||
148 | unsigned int start, end, pg; | ||
149 | |||
150 | start = ofs >> PAGE_SHIFT; | ||
151 | end = (ofs + size - 1) >> PAGE_SHIFT; | ||
152 | /* check page continuity */ | ||
153 | pg = sg->table[start].addr >> PAGE_SHIFT; | ||
154 | for (;;) { | ||
155 | start++; | ||
156 | if (start > end) | ||
157 | break; | ||
158 | pg++; | ||
159 | if ((sg->table[start].addr >> PAGE_SHIFT) != pg) | ||
160 | return (start << PAGE_SHIFT) - ofs; | ||
161 | } | ||
162 | /* ok, all on continuous pages */ | ||
163 | return size; | ||
164 | } | ||
165 | EXPORT_SYMBOL(snd_sgbuf_get_chunk_size); | ||