Lines Matching refs:substream

99 static int preallocate_pcm_pages(struct snd_pcm_substream *substream,
102 struct snd_dma_buffer *dmab = &substream->dma_buffer;
103 struct snd_card *card = substream->pcm->card;
109 substream->stream, size, dmab);
118 substream->pcm->card->number, substream->pcm->device,
119 substream->stream ? 'c' : 'p', substream->number,
120 substream->pcm->name, orig_size);
125 * snd_pcm_lib_preallocate_free - release the preallocated buffer of the specified substream.
126 * @substream: the pcm substream instance
128 * Releases the pre-allocated buffer of the given substream.
130 void snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream)
132 do_free_pages(substream->pcm->card, &substream->dma_buffer);
143 struct snd_pcm_substream *substream;
146 for_each_pcm_substream(pcm, stream, substream)
147 snd_pcm_lib_preallocate_free(substream);
160 struct snd_pcm_substream *substream = entry->private_data;
161 snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_buffer.bytes / 1024);
172 struct snd_pcm_substream *substream = entry->private_data;
173 snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_max / 1024);
184 struct snd_pcm_substream *substream = entry->private_data;
185 struct snd_card *card = substream->pcm->card;
190 guard(mutex)(&substream->pcm->open_mutex);
191 if (substream->runtime) {
198 if ((size != 0 && size < 8192) || size > substream->dma_max) {
202 if (substream->dma_buffer.bytes == size)
205 new_dmab.dev = substream->dma_buffer.dev;
208 substream->dma_buffer.dev.type,
209 substream->dma_buffer.dev.dev,
210 substream->stream,
214 substream->pcm->card->number, substream->pcm->device,
215 substream->stream ? 'c' : 'p', substream->number,
216 substream->pcm->name, size);
219 substream->buffer_bytes_max = size;
221 substream->buffer_bytes_max = UINT_MAX;
223 if (substream->dma_buffer.area)
224 do_free_pages(card, &substream->dma_buffer);
225 substream->dma_buffer = new_dmab;
231 static inline void preallocate_info_init(struct snd_pcm_substream *substream)
235 entry = snd_info_create_card_entry(substream->pcm->card, "prealloc",
236 substream->proc_root);
238 snd_info_set_text_ops(entry, substream,
243 entry = snd_info_create_card_entry(substream->pcm->card, "prealloc_max",
244 substream->proc_root);
246 snd_info_set_text_ops(entry, substream,
251 static inline void preallocate_info_init(struct snd_pcm_substream *substream)
257 * pre-allocate the buffer and create a proc file for the substream
259 static int preallocate_pages(struct snd_pcm_substream *substream,
265 if (snd_BUG_ON(substream->dma_buffer.dev.type))
268 substream->dma_buffer.dev.type = type;
269 substream->dma_buffer.dev.dev = data;
274 err = preallocate_pcm_pages(substream, size, true);
278 substream->number < maximum_substreams) {
279 err = preallocate_pcm_pages(substream, size, false);
285 if (substream->dma_buffer.bytes > 0)
286 substream->buffer_bytes_max = substream->dma_buffer.bytes;
287 substream->dma_max = max;
289 preallocate_info_init(substream);
291 substream->managed_buffer_alloc = 1;
299 struct snd_pcm_substream *substream;
302 for_each_pcm_substream(pcm, stream, substream) {
303 err = preallocate_pages(substream, type, data, size, max, managed);
312 * @substream: the pcm substream instance
320 void snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream,
324 preallocate_pages(substream, type, data, size, max, false);
348 * snd_pcm_set_managed_buffer - set up buffer management for a substream
349 * @substream: the pcm substream instance
356 * buffer allocation mode to the given substream.
378 int snd_pcm_set_managed_buffer(struct snd_pcm_substream *substream, int type,
381 return preallocate_pages(substream, type, data, size, max, true);
395 * type and size, and set the managed_buffer_alloc flag to each substream.
409 * @substream: the substream to allocate the DMA buffer to
418 int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size)
424 if (PCM_RUNTIME_CHECK(substream))
426 if (snd_BUG_ON(substream->dma_buffer.dev.type ==
429 runtime = substream->runtime;
430 card = substream->pcm->card;
440 snd_pcm_lib_free_pages(substream);
442 if (substream->dma_buffer.area != NULL &&
443 substream->dma_buffer.bytes >= size) {
444 dmab = &substream->dma_buffer; /* use the pre-allocated buffer */
447 if (substream->dma_buffer.area && !substream->dma_max)
452 dmab->dev = substream->dma_buffer.dev;
454 substream->dma_buffer.dev.type,
455 substream->dma_buffer.dev.dev,
456 substream->stream,
460 substream->pcm->card->number, substream->pcm->device,
461 substream->stream ? 'c' : 'p', substream->number,
462 substream->pcm->name, size);
466 snd_pcm_set_runtime_buffer(substream, dmab);
474 * @substream: the substream to release the DMA buffer
480 int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream)
484 if (PCM_RUNTIME_CHECK(substream))
486 runtime = substream->runtime;
489 if (runtime->dma_buffer_p != &substream->dma_buffer) {
490 struct snd_card *card = substream->pcm->card;
496 snd_pcm_set_runtime_buffer(substream, NULL);
501 int _snd_pcm_lib_alloc_vmalloc_buffer(struct snd_pcm_substream *substream,
506 if (PCM_RUNTIME_CHECK(substream))
508 runtime = substream->runtime;
524 * @substream: the substream with a buffer allocated by
529 int snd_pcm_lib_free_vmalloc_buffer(struct snd_pcm_substream *substream)
533 if (PCM_RUNTIME_CHECK(substream))
535 runtime = substream->runtime;
544 * @substream: the substream with a buffer allocated by
552 struct page *snd_pcm_lib_get_vmalloc_page(struct snd_pcm_substream *substream,
555 return vmalloc_to_page(substream->runtime->dma_area + offset);