Lines Matching refs:substream
75 static int preallocate_pcm_pages(struct snd_pcm_substream *substream, in preallocate_pcm_pages() argument
78 struct snd_dma_buffer *dmab = &substream->dma_buffer; in preallocate_pcm_pages()
79 struct snd_card *card = substream->pcm->card; in preallocate_pcm_pages()
85 substream->stream, size, dmab); in preallocate_pcm_pages()
94 substream->pcm->card->number, substream->pcm->device, in preallocate_pcm_pages()
95 substream->stream ? 'c' : 'p', substream->number, in preallocate_pcm_pages()
96 substream->pcm->name, orig_size); in preallocate_pcm_pages()
106 void snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream) in snd_pcm_lib_preallocate_free() argument
108 do_free_pages(substream->pcm->card, &substream->dma_buffer); in snd_pcm_lib_preallocate_free()
119 struct snd_pcm_substream *substream; in snd_pcm_lib_preallocate_free_for_all() local
122 for_each_pcm_substream(pcm, stream, substream) in snd_pcm_lib_preallocate_free_for_all()
123 snd_pcm_lib_preallocate_free(substream); in snd_pcm_lib_preallocate_free_for_all()
136 struct snd_pcm_substream *substream = entry->private_data; in snd_pcm_lib_preallocate_proc_read() local
137 snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_buffer.bytes / 1024); in snd_pcm_lib_preallocate_proc_read()
148 struct snd_pcm_substream *substream = entry->private_data; in snd_pcm_lib_preallocate_max_proc_read() local
149 snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_max / 1024); in snd_pcm_lib_preallocate_max_proc_read()
160 struct snd_pcm_substream *substream = entry->private_data; in snd_pcm_lib_preallocate_proc_write() local
161 struct snd_card *card = substream->pcm->card; in snd_pcm_lib_preallocate_proc_write()
166 mutex_lock(&substream->pcm->open_mutex); in snd_pcm_lib_preallocate_proc_write()
167 if (substream->runtime) { in snd_pcm_lib_preallocate_proc_write()
174 if ((size != 0 && size < 8192) || size > substream->dma_max) { in snd_pcm_lib_preallocate_proc_write()
178 if (substream->dma_buffer.bytes == size) in snd_pcm_lib_preallocate_proc_write()
181 new_dmab.dev = substream->dma_buffer.dev; in snd_pcm_lib_preallocate_proc_write()
184 substream->dma_buffer.dev.type, in snd_pcm_lib_preallocate_proc_write()
185 substream->dma_buffer.dev.dev, in snd_pcm_lib_preallocate_proc_write()
186 substream->stream, in snd_pcm_lib_preallocate_proc_write()
190 substream->pcm->card->number, substream->pcm->device, in snd_pcm_lib_preallocate_proc_write()
191 substream->stream ? 'c' : 'p', substream->number, in snd_pcm_lib_preallocate_proc_write()
192 substream->pcm->name, size); in snd_pcm_lib_preallocate_proc_write()
195 substream->buffer_bytes_max = size; in snd_pcm_lib_preallocate_proc_write()
197 substream->buffer_bytes_max = UINT_MAX; in snd_pcm_lib_preallocate_proc_write()
199 if (substream->dma_buffer.area) in snd_pcm_lib_preallocate_proc_write()
200 do_free_pages(card, &substream->dma_buffer); in snd_pcm_lib_preallocate_proc_write()
201 substream->dma_buffer = new_dmab; in snd_pcm_lib_preallocate_proc_write()
206 mutex_unlock(&substream->pcm->open_mutex); in snd_pcm_lib_preallocate_proc_write()
209 static inline void preallocate_info_init(struct snd_pcm_substream *substream) in preallocate_info_init() argument
213 entry = snd_info_create_card_entry(substream->pcm->card, "prealloc", in preallocate_info_init()
214 substream->proc_root); in preallocate_info_init()
216 snd_info_set_text_ops(entry, substream, in preallocate_info_init()
221 entry = snd_info_create_card_entry(substream->pcm->card, "prealloc_max", in preallocate_info_init()
222 substream->proc_root); in preallocate_info_init()
224 snd_info_set_text_ops(entry, substream, in preallocate_info_init()
229 static inline void preallocate_info_init(struct snd_pcm_substream *substream) in preallocate_info_init() argument
237 static int preallocate_pages(struct snd_pcm_substream *substream, in preallocate_pages() argument
243 if (snd_BUG_ON(substream->dma_buffer.dev.type)) in preallocate_pages()
246 substream->dma_buffer.dev.type = type; in preallocate_pages()
247 substream->dma_buffer.dev.dev = data; in preallocate_pages()
252 err = preallocate_pcm_pages(substream, size, true); in preallocate_pages()
256 substream->number < maximum_substreams) { in preallocate_pages()
257 err = preallocate_pcm_pages(substream, size, false); in preallocate_pages()
263 if (substream->dma_buffer.bytes > 0) in preallocate_pages()
264 substream->buffer_bytes_max = substream->dma_buffer.bytes; in preallocate_pages()
265 substream->dma_max = max; in preallocate_pages()
267 preallocate_info_init(substream); in preallocate_pages()
269 substream->managed_buffer_alloc = 1; in preallocate_pages()
277 struct snd_pcm_substream *substream; in preallocate_pages_for_all() local
280 for_each_pcm_substream(pcm, stream, substream) { in preallocate_pages_for_all()
281 err = preallocate_pages(substream, type, data, size, max, managed); in preallocate_pages_for_all()
298 void snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream, in snd_pcm_lib_preallocate_pages() argument
302 preallocate_pages(substream, type, data, size, max, false); in snd_pcm_lib_preallocate_pages()
356 int snd_pcm_set_managed_buffer(struct snd_pcm_substream *substream, int type, in snd_pcm_set_managed_buffer() argument
359 return preallocate_pages(substream, type, data, size, max, true); in snd_pcm_set_managed_buffer()
396 int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size) in snd_pcm_lib_malloc_pages() argument
402 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_lib_malloc_pages()
404 if (snd_BUG_ON(substream->dma_buffer.dev.type == in snd_pcm_lib_malloc_pages()
407 runtime = substream->runtime; in snd_pcm_lib_malloc_pages()
408 card = substream->pcm->card; in snd_pcm_lib_malloc_pages()
418 snd_pcm_lib_free_pages(substream); in snd_pcm_lib_malloc_pages()
420 if (substream->dma_buffer.area != NULL && in snd_pcm_lib_malloc_pages()
421 substream->dma_buffer.bytes >= size) { in snd_pcm_lib_malloc_pages()
422 dmab = &substream->dma_buffer; /* use the pre-allocated buffer */ in snd_pcm_lib_malloc_pages()
425 if (substream->dma_buffer.area && !substream->dma_max) in snd_pcm_lib_malloc_pages()
430 dmab->dev = substream->dma_buffer.dev; in snd_pcm_lib_malloc_pages()
432 substream->dma_buffer.dev.type, in snd_pcm_lib_malloc_pages()
433 substream->dma_buffer.dev.dev, in snd_pcm_lib_malloc_pages()
434 substream->stream, in snd_pcm_lib_malloc_pages()
438 substream->pcm->card->number, substream->pcm->device, in snd_pcm_lib_malloc_pages()
439 substream->stream ? 'c' : 'p', substream->number, in snd_pcm_lib_malloc_pages()
440 substream->pcm->name, size); in snd_pcm_lib_malloc_pages()
444 snd_pcm_set_runtime_buffer(substream, dmab); in snd_pcm_lib_malloc_pages()
458 int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) in snd_pcm_lib_free_pages() argument
462 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_lib_free_pages()
464 runtime = substream->runtime; in snd_pcm_lib_free_pages()
467 if (runtime->dma_buffer_p != &substream->dma_buffer) { in snd_pcm_lib_free_pages()
468 struct snd_card *card = substream->pcm->card; in snd_pcm_lib_free_pages()
474 snd_pcm_set_runtime_buffer(substream, NULL); in snd_pcm_lib_free_pages()
479 int _snd_pcm_lib_alloc_vmalloc_buffer(struct snd_pcm_substream *substream, in _snd_pcm_lib_alloc_vmalloc_buffer() argument
484 if (PCM_RUNTIME_CHECK(substream)) in _snd_pcm_lib_alloc_vmalloc_buffer()
486 runtime = substream->runtime; in _snd_pcm_lib_alloc_vmalloc_buffer()
507 int snd_pcm_lib_free_vmalloc_buffer(struct snd_pcm_substream *substream) in snd_pcm_lib_free_vmalloc_buffer() argument
511 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_lib_free_vmalloc_buffer()
513 runtime = substream->runtime; in snd_pcm_lib_free_vmalloc_buffer()
530 struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream, in snd_pcm_lib_get_vmalloc_page() argument
533 return vmalloc_to_page(substream->runtime->dma_area + offset); in snd_pcm_lib_get_vmalloc_page()