Lines Matching refs:substream
70 static int preallocate_pcm_pages(struct snd_pcm_substream *substream, in preallocate_pcm_pages() argument
73 struct snd_dma_buffer *dmab = &substream->dma_buffer; in preallocate_pcm_pages()
74 struct snd_card *card = substream->pcm->card; in preallocate_pcm_pages()
89 substream->pcm->card->number, substream->pcm->device, in preallocate_pcm_pages()
90 substream->stream ? 'c' : 'p', substream->number, in preallocate_pcm_pages()
91 substream->pcm->name, orig_size); in preallocate_pcm_pages()
101 void snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream) in snd_pcm_lib_preallocate_free() argument
103 do_free_pages(substream->pcm->card, &substream->dma_buffer); in snd_pcm_lib_preallocate_free()
114 struct snd_pcm_substream *substream; in snd_pcm_lib_preallocate_free_for_all() local
117 for_each_pcm_substream(pcm, stream, substream) in snd_pcm_lib_preallocate_free_for_all()
118 snd_pcm_lib_preallocate_free(substream); in snd_pcm_lib_preallocate_free_for_all()
131 struct snd_pcm_substream *substream = entry->private_data; in snd_pcm_lib_preallocate_proc_read() local
132 snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_buffer.bytes / 1024); in snd_pcm_lib_preallocate_proc_read()
143 struct snd_pcm_substream *substream = entry->private_data; in snd_pcm_lib_preallocate_max_proc_read() local
144 snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_max / 1024); in snd_pcm_lib_preallocate_max_proc_read()
155 struct snd_pcm_substream *substream = entry->private_data; in snd_pcm_lib_preallocate_proc_write() local
156 struct snd_card *card = substream->pcm->card; in snd_pcm_lib_preallocate_proc_write()
161 if (substream->runtime) { in snd_pcm_lib_preallocate_proc_write()
168 if ((size != 0 && size < 8192) || size > substream->dma_max) { in snd_pcm_lib_preallocate_proc_write()
172 if (substream->dma_buffer.bytes == size) in snd_pcm_lib_preallocate_proc_write()
175 new_dmab.dev = substream->dma_buffer.dev; in snd_pcm_lib_preallocate_proc_write()
178 substream->dma_buffer.dev.type, in snd_pcm_lib_preallocate_proc_write()
179 substream->dma_buffer.dev.dev, in snd_pcm_lib_preallocate_proc_write()
183 substream->pcm->card->number, substream->pcm->device, in snd_pcm_lib_preallocate_proc_write()
184 substream->stream ? 'c' : 'p', substream->number, in snd_pcm_lib_preallocate_proc_write()
185 substream->pcm->name, size); in snd_pcm_lib_preallocate_proc_write()
188 substream->buffer_bytes_max = size; in snd_pcm_lib_preallocate_proc_write()
190 substream->buffer_bytes_max = UINT_MAX; in snd_pcm_lib_preallocate_proc_write()
192 if (substream->dma_buffer.area) in snd_pcm_lib_preallocate_proc_write()
193 do_free_pages(card, &substream->dma_buffer); in snd_pcm_lib_preallocate_proc_write()
194 substream->dma_buffer = new_dmab; in snd_pcm_lib_preallocate_proc_write()
200 static inline void preallocate_info_init(struct snd_pcm_substream *substream) in preallocate_info_init() argument
204 entry = snd_info_create_card_entry(substream->pcm->card, "prealloc", in preallocate_info_init()
205 substream->proc_root); in preallocate_info_init()
207 snd_info_set_text_ops(entry, substream, in preallocate_info_init()
212 entry = snd_info_create_card_entry(substream->pcm->card, "prealloc_max", in preallocate_info_init()
213 substream->proc_root); in preallocate_info_init()
215 snd_info_set_text_ops(entry, substream, in preallocate_info_init()
220 static inline void preallocate_info_init(struct snd_pcm_substream *substream) in preallocate_info_init() argument
228 static int preallocate_pages(struct snd_pcm_substream *substream, in preallocate_pages() argument
234 if (snd_BUG_ON(substream->dma_buffer.dev.type)) in preallocate_pages()
237 substream->dma_buffer.dev.type = type; in preallocate_pages()
238 substream->dma_buffer.dev.dev = data; in preallocate_pages()
243 err = preallocate_pcm_pages(substream, size, true); in preallocate_pages()
247 substream->number < maximum_substreams) { in preallocate_pages()
248 err = preallocate_pcm_pages(substream, size, false); in preallocate_pages()
254 if (substream->dma_buffer.bytes > 0) in preallocate_pages()
255 substream->buffer_bytes_max = substream->dma_buffer.bytes; in preallocate_pages()
256 substream->dma_max = max; in preallocate_pages()
258 preallocate_info_init(substream); in preallocate_pages()
260 substream->managed_buffer_alloc = 1; in preallocate_pages()
268 struct snd_pcm_substream *substream; in preallocate_pages_for_all() local
271 for_each_pcm_substream(pcm, stream, substream) { in preallocate_pages_for_all()
272 err = preallocate_pages(substream, type, data, size, max, managed); in preallocate_pages_for_all()
289 void snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream, in snd_pcm_lib_preallocate_pages() argument
293 preallocate_pages(substream, type, data, size, max, false); in snd_pcm_lib_preallocate_pages()
345 int snd_pcm_set_managed_buffer(struct snd_pcm_substream *substream, int type, in snd_pcm_set_managed_buffer() argument
348 return preallocate_pages(substream, type, data, size, max, true); in snd_pcm_set_managed_buffer()
383 int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size) in snd_pcm_lib_malloc_pages() argument
389 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_lib_malloc_pages()
391 if (snd_BUG_ON(substream->dma_buffer.dev.type == in snd_pcm_lib_malloc_pages()
394 runtime = substream->runtime; in snd_pcm_lib_malloc_pages()
395 card = substream->pcm->card; in snd_pcm_lib_malloc_pages()
405 snd_pcm_lib_free_pages(substream); in snd_pcm_lib_malloc_pages()
407 if (substream->dma_buffer.area != NULL && in snd_pcm_lib_malloc_pages()
408 substream->dma_buffer.bytes >= size) { in snd_pcm_lib_malloc_pages()
409 dmab = &substream->dma_buffer; /* use the pre-allocated buffer */ in snd_pcm_lib_malloc_pages()
412 if (substream->dma_buffer.area && !substream->dma_max) in snd_pcm_lib_malloc_pages()
417 dmab->dev = substream->dma_buffer.dev; in snd_pcm_lib_malloc_pages()
419 substream->dma_buffer.dev.type, in snd_pcm_lib_malloc_pages()
420 substream->dma_buffer.dev.dev, in snd_pcm_lib_malloc_pages()
424 substream->pcm->card->number, substream->pcm->device, in snd_pcm_lib_malloc_pages()
425 substream->stream ? 'c' : 'p', substream->number, in snd_pcm_lib_malloc_pages()
426 substream->pcm->name, size); in snd_pcm_lib_malloc_pages()
430 snd_pcm_set_runtime_buffer(substream, dmab); in snd_pcm_lib_malloc_pages()
444 int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) in snd_pcm_lib_free_pages() argument
446 struct snd_card *card = substream->pcm->card; in snd_pcm_lib_free_pages()
449 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_lib_free_pages()
451 runtime = substream->runtime; in snd_pcm_lib_free_pages()
454 if (runtime->dma_buffer_p != &substream->dma_buffer) { in snd_pcm_lib_free_pages()
459 snd_pcm_set_runtime_buffer(substream, NULL); in snd_pcm_lib_free_pages()
464 int _snd_pcm_lib_alloc_vmalloc_buffer(struct snd_pcm_substream *substream, in _snd_pcm_lib_alloc_vmalloc_buffer() argument
469 if (PCM_RUNTIME_CHECK(substream)) in _snd_pcm_lib_alloc_vmalloc_buffer()
471 runtime = substream->runtime; in _snd_pcm_lib_alloc_vmalloc_buffer()
492 int snd_pcm_lib_free_vmalloc_buffer(struct snd_pcm_substream *substream) in snd_pcm_lib_free_vmalloc_buffer() argument
496 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_lib_free_vmalloc_buffer()
498 runtime = substream->runtime; in snd_pcm_lib_free_vmalloc_buffer()
515 struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream, in snd_pcm_lib_get_vmalloc_page() argument
518 return vmalloc_to_page(substream->runtime->dma_area + offset); in snd_pcm_lib_get_vmalloc_page()