aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/pcm_memory.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c
index caa7796bc2f..d9727c74b2e 100644
--- a/sound/core/pcm_memory.c
+++ b/sound/core/pcm_memory.c
@@ -434,3 +434,57 @@ int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream)
434} 434}
435 435
436EXPORT_SYMBOL(snd_pcm_lib_free_pages); 436EXPORT_SYMBOL(snd_pcm_lib_free_pages);
437
438int _snd_pcm_lib_alloc_vmalloc_buffer(struct snd_pcm_substream *substream,
439 size_t size, gfp_t gfp_flags)
440{
441 struct snd_pcm_runtime *runtime;
442
443 if (PCM_RUNTIME_CHECK(substream))
444 return -EINVAL;
445 runtime = substream->runtime;
446 if (runtime->dma_area) {
447 if (runtime->dma_bytes >= size)
448 return 0; /* already large enough */
449 vfree(runtime->dma_area);
450 }
451 runtime->dma_area = __vmalloc(size, gfp_flags, PAGE_KERNEL);
452 if (!runtime->dma_area)
453 return -ENOMEM;
454 runtime->dma_bytes = size;
455 return 1;
456}
457EXPORT_SYMBOL(_snd_pcm_lib_alloc_vmalloc_buffer);
458
459/**
460 * snd_pcm_lib_free_vmalloc_buffer - free vmalloc buffer
461 * @substream: the substream with a buffer allocated by
462 * snd_pcm_lib_alloc_vmalloc_buffer()
463 */
464int snd_pcm_lib_free_vmalloc_buffer(struct snd_pcm_substream *substream)
465{
466 struct snd_pcm_runtime *runtime;
467
468 if (PCM_RUNTIME_CHECK(substream))
469 return -EINVAL;
470 runtime = substream->runtime;
471 vfree(runtime->dma_area);
472 runtime->dma_area = NULL;
473 return 0;
474}
475EXPORT_SYMBOL(snd_pcm_lib_free_vmalloc_buffer);
476
477/**
478 * snd_pcm_lib_get_vmalloc_page - map vmalloc buffer offset to page struct
479 * @substream: the substream with a buffer allocated by
480 * snd_pcm_lib_alloc_vmalloc_buffer()
481 * @offset: offset in the buffer
482 *
483 * This function is to be used as the page callback in the PCM ops.
484 */
485struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream,
486 unsigned long offset)
487{
488 return vmalloc_to_page(substream->runtime->dma_area + offset);
489}
490EXPORT_SYMBOL(snd_pcm_lib_get_vmalloc_page);