Lines Matching refs:substream
103 static int preallocate_pcm_pages(struct snd_pcm_substream *substream, in preallocate_pcm_pages() argument
106 struct snd_dma_buffer *dmab = &substream->dma_buffer; in preallocate_pcm_pages()
107 struct snd_card *card = substream->pcm->card; in preallocate_pcm_pages()
113 substream->stream, size, dmab); in preallocate_pcm_pages()
122 substream->pcm->card->number, substream->pcm->device, in preallocate_pcm_pages()
123 substream->stream ? 'c' : 'p', substream->number, in preallocate_pcm_pages()
124 substream->pcm->name, orig_size); in preallocate_pcm_pages()
134 void snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream) in snd_pcm_lib_preallocate_free() argument
136 do_free_pages(substream->pcm->card, &substream->dma_buffer); in snd_pcm_lib_preallocate_free()
147 struct snd_pcm_substream *substream; in snd_pcm_lib_preallocate_free_for_all() local
150 for_each_pcm_substream(pcm, stream, substream) in snd_pcm_lib_preallocate_free_for_all()
151 snd_pcm_lib_preallocate_free(substream); in snd_pcm_lib_preallocate_free_for_all()
164 struct snd_pcm_substream *substream = entry->private_data; in snd_pcm_lib_preallocate_proc_read() local
165 snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_buffer.bytes / 1024); in snd_pcm_lib_preallocate_proc_read()
176 struct snd_pcm_substream *substream = entry->private_data; in snd_pcm_lib_preallocate_max_proc_read() local
177 snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_max / 1024); in snd_pcm_lib_preallocate_max_proc_read()
188 struct snd_pcm_substream *substream = entry->private_data; in snd_pcm_lib_preallocate_proc_write() local
189 struct snd_card *card = substream->pcm->card; in snd_pcm_lib_preallocate_proc_write()
194 mutex_lock(&substream->pcm->open_mutex); in snd_pcm_lib_preallocate_proc_write()
195 if (substream->runtime) { in snd_pcm_lib_preallocate_proc_write()
202 if ((size != 0 && size < 8192) || size > substream->dma_max) { in snd_pcm_lib_preallocate_proc_write()
206 if (substream->dma_buffer.bytes == size) in snd_pcm_lib_preallocate_proc_write()
209 new_dmab.dev = substream->dma_buffer.dev; in snd_pcm_lib_preallocate_proc_write()
212 substream->dma_buffer.dev.type, in snd_pcm_lib_preallocate_proc_write()
213 substream->dma_buffer.dev.dev, in snd_pcm_lib_preallocate_proc_write()
214 substream->stream, in snd_pcm_lib_preallocate_proc_write()
218 substream->pcm->card->number, substream->pcm->device, in snd_pcm_lib_preallocate_proc_write()
219 substream->stream ? 'c' : 'p', substream->number, in snd_pcm_lib_preallocate_proc_write()
220 substream->pcm->name, size); in snd_pcm_lib_preallocate_proc_write()
223 substream->buffer_bytes_max = size; in snd_pcm_lib_preallocate_proc_write()
225 substream->buffer_bytes_max = UINT_MAX; in snd_pcm_lib_preallocate_proc_write()
227 if (substream->dma_buffer.area) in snd_pcm_lib_preallocate_proc_write()
228 do_free_pages(card, &substream->dma_buffer); in snd_pcm_lib_preallocate_proc_write()
229 substream->dma_buffer = new_dmab; in snd_pcm_lib_preallocate_proc_write()
234 mutex_unlock(&substream->pcm->open_mutex); in snd_pcm_lib_preallocate_proc_write()
237 static inline void preallocate_info_init(struct snd_pcm_substream *substream) in preallocate_info_init() argument
241 entry = snd_info_create_card_entry(substream->pcm->card, "prealloc", in preallocate_info_init()
242 substream->proc_root); in preallocate_info_init()
244 snd_info_set_text_ops(entry, substream, in preallocate_info_init()
249 entry = snd_info_create_card_entry(substream->pcm->card, "prealloc_max", in preallocate_info_init()
250 substream->proc_root); in preallocate_info_init()
252 snd_info_set_text_ops(entry, substream, in preallocate_info_init()
257 static inline void preallocate_info_init(struct snd_pcm_substream *substream) in preallocate_info_init() argument
265 static int preallocate_pages(struct snd_pcm_substream *substream, in preallocate_pages() argument
271 if (snd_BUG_ON(substream->dma_buffer.dev.type)) in preallocate_pages()
274 substream->dma_buffer.dev.type = type; in preallocate_pages()
275 substream->dma_buffer.dev.dev = data; in preallocate_pages()
280 err = preallocate_pcm_pages(substream, size, true); in preallocate_pages()
284 substream->number < maximum_substreams) { in preallocate_pages()
285 err = preallocate_pcm_pages(substream, size, false); in preallocate_pages()
291 if (substream->dma_buffer.bytes > 0) in preallocate_pages()
292 substream->buffer_bytes_max = substream->dma_buffer.bytes; in preallocate_pages()
293 substream->dma_max = max; in preallocate_pages()
295 preallocate_info_init(substream); in preallocate_pages()
297 substream->managed_buffer_alloc = 1; in preallocate_pages()
305 struct snd_pcm_substream *substream; in preallocate_pages_for_all() local
308 for_each_pcm_substream(pcm, stream, substream) { in preallocate_pages_for_all()
309 err = preallocate_pages(substream, type, data, size, max, managed); in preallocate_pages_for_all()
326 void snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream, in snd_pcm_lib_preallocate_pages() argument
330 preallocate_pages(substream, type, data, size, max, false); in snd_pcm_lib_preallocate_pages()
384 int snd_pcm_set_managed_buffer(struct snd_pcm_substream *substream, int type, in snd_pcm_set_managed_buffer() argument
387 return preallocate_pages(substream, type, data, size, max, true); in snd_pcm_set_managed_buffer()
424 int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size) in snd_pcm_lib_malloc_pages() argument
430 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_lib_malloc_pages()
432 if (snd_BUG_ON(substream->dma_buffer.dev.type == in snd_pcm_lib_malloc_pages()
435 runtime = substream->runtime; in snd_pcm_lib_malloc_pages()
436 card = substream->pcm->card; in snd_pcm_lib_malloc_pages()
446 snd_pcm_lib_free_pages(substream); in snd_pcm_lib_malloc_pages()
448 if (substream->dma_buffer.area != NULL && in snd_pcm_lib_malloc_pages()
449 substream->dma_buffer.bytes >= size) { in snd_pcm_lib_malloc_pages()
450 dmab = &substream->dma_buffer; /* use the pre-allocated buffer */ in snd_pcm_lib_malloc_pages()
453 if (substream->dma_buffer.area && !substream->dma_max) in snd_pcm_lib_malloc_pages()
458 dmab->dev = substream->dma_buffer.dev; in snd_pcm_lib_malloc_pages()
460 substream->dma_buffer.dev.type, in snd_pcm_lib_malloc_pages()
461 substream->dma_buffer.dev.dev, in snd_pcm_lib_malloc_pages()
462 substream->stream, in snd_pcm_lib_malloc_pages()
466 substream->pcm->card->number, substream->pcm->device, in snd_pcm_lib_malloc_pages()
467 substream->stream ? 'c' : 'p', substream->number, in snd_pcm_lib_malloc_pages()
468 substream->pcm->name, size); in snd_pcm_lib_malloc_pages()
472 snd_pcm_set_runtime_buffer(substream, dmab); in snd_pcm_lib_malloc_pages()
486 int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) in snd_pcm_lib_free_pages() argument
490 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_lib_free_pages()
492 runtime = substream->runtime; in snd_pcm_lib_free_pages()
495 if (runtime->dma_buffer_p != &substream->dma_buffer) { in snd_pcm_lib_free_pages()
496 struct snd_card *card = substream->pcm->card; in snd_pcm_lib_free_pages()
502 snd_pcm_set_runtime_buffer(substream, NULL); in snd_pcm_lib_free_pages()
507 int _snd_pcm_lib_alloc_vmalloc_buffer(struct snd_pcm_substream *substream, in _snd_pcm_lib_alloc_vmalloc_buffer() argument
512 if (PCM_RUNTIME_CHECK(substream)) in _snd_pcm_lib_alloc_vmalloc_buffer()
514 runtime = substream->runtime; in _snd_pcm_lib_alloc_vmalloc_buffer()
535 int snd_pcm_lib_free_vmalloc_buffer(struct snd_pcm_substream *substream) in snd_pcm_lib_free_vmalloc_buffer() argument
539 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_lib_free_vmalloc_buffer()
541 runtime = substream->runtime; in snd_pcm_lib_free_vmalloc_buffer()
558 struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream, in snd_pcm_lib_get_vmalloc_page() argument
561 return vmalloc_to_page(substream->runtime->dma_area + offset); in snd_pcm_lib_get_vmalloc_page()