Lines Matching full:stream

212 static void stream_clear(struct xen_snd_front_pcm_stream_info *stream)  in stream_clear()  argument
214 stream->is_open = false; in stream_clear()
215 stream->be_cur_frame = 0; in stream_clear()
216 stream->out_frames = 0; in stream_clear()
217 atomic_set(&stream->hw_ptr, 0); in stream_clear()
218 xen_snd_front_evtchnl_pair_clear(stream->evt_pair); in stream_clear()
219 memset(&stream->shbuf, 0, sizeof(stream->shbuf)); in stream_clear()
220 stream->buffer = NULL; in stream_clear()
221 stream->buffer_sz = 0; in stream_clear()
222 stream->pages = NULL; in stream_clear()
223 stream->num_pages = 0; in stream_clear()
226 static void stream_free(struct xen_snd_front_pcm_stream_info *stream) in stream_free() argument
228 xen_front_pgdir_shbuf_unmap(&stream->shbuf); in stream_free()
229 xen_front_pgdir_shbuf_free(&stream->shbuf); in stream_free()
230 if (stream->buffer) in stream_free()
231 free_pages_exact(stream->buffer, stream->buffer_sz); in stream_free()
232 kfree(stream->pages); in stream_free()
233 stream_clear(stream); in stream_free()
241 struct xen_snd_front_pcm_stream_info *stream; in stream_get() local
243 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in stream_get()
244 stream = &pcm_instance->streams_pb[substream->number]; in stream_get()
246 stream = &pcm_instance->streams_cap[substream->number]; in stream_get()
248 return stream; in stream_get()
254 struct xen_snd_front_pcm_stream_info *stream = rule->private; in alsa_hw_rule() local
255 struct device *dev = &stream->front_info->xb_dev->dev; in alsa_hw_rule()
292 ret = xen_snd_front_stream_query_hw_param(&stream->evt_pair->req, in alsa_hw_rule()
352 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_open() local
363 runtime->hw = stream->pcm_hw; in alsa_open()
373 stream->evt_pair = &front_info->evt_pairs[stream->index]; in alsa_open()
375 stream->front_info = front_info; in alsa_open()
377 stream->evt_pair->evt.u.evt.substream = substream; in alsa_open()
379 stream_clear(stream); in alsa_open()
381 xen_snd_front_evtchnl_pair_set_connected(stream->evt_pair, true); in alsa_open()
384 alsa_hw_rule, stream, in alsa_open()
392 alsa_hw_rule, stream, in alsa_open()
400 alsa_hw_rule, stream, in alsa_open()
408 alsa_hw_rule, stream, in alsa_open()
416 alsa_hw_rule, stream, in alsa_open()
428 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_close() local
430 xen_snd_front_evtchnl_pair_set_connected(stream->evt_pair, false); in alsa_close()
434 static int shbuf_setup_backstore(struct xen_snd_front_pcm_stream_info *stream, in shbuf_setup_backstore() argument
439 stream->buffer = alloc_pages_exact(buffer_sz, GFP_KERNEL); in shbuf_setup_backstore()
440 if (!stream->buffer) in shbuf_setup_backstore()
443 stream->buffer_sz = buffer_sz; in shbuf_setup_backstore()
444 stream->num_pages = DIV_ROUND_UP(stream->buffer_sz, PAGE_SIZE); in shbuf_setup_backstore()
445 stream->pages = kcalloc(stream->num_pages, sizeof(struct page *), in shbuf_setup_backstore()
447 if (!stream->pages) in shbuf_setup_backstore()
450 for (i = 0; i < stream->num_pages; i++) in shbuf_setup_backstore()
451 stream->pages[i] = virt_to_page(stream->buffer + i * PAGE_SIZE); in shbuf_setup_backstore()
459 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_hw_params() local
460 struct xen_snd_front_info *front_info = stream->front_info; in alsa_hw_params()
468 stream_free(stream); in alsa_hw_params()
469 ret = shbuf_setup_backstore(stream, params_buffer_bytes(params)); in alsa_hw_params()
475 buf_cfg.pgdir = &stream->shbuf; in alsa_hw_params()
476 buf_cfg.num_pages = stream->num_pages; in alsa_hw_params()
477 buf_cfg.pages = stream->pages; in alsa_hw_params()
483 ret = xen_front_pgdir_shbuf_map(&stream->shbuf); in alsa_hw_params()
490 stream_free(stream); in alsa_hw_params()
492 "Failed to allocate buffers for stream with index %d\n", in alsa_hw_params()
493 stream->index); in alsa_hw_params()
499 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_hw_free() local
502 ret = xen_snd_front_stream_close(&stream->evt_pair->req); in alsa_hw_free()
503 stream_free(stream); in alsa_hw_free()
509 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_prepare() local
511 if (!stream->is_open) { in alsa_prepare()
518 dev_err(&stream->front_info->xb_dev->dev, in alsa_prepare()
525 ret = xen_snd_front_stream_prepare(&stream->evt_pair->req, in alsa_prepare()
526 &stream->shbuf, in alsa_prepare()
535 stream->is_open = true; in alsa_prepare()
543 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_trigger() local
567 return xen_snd_front_stream_trigger(&stream->evt_pair->req, type); in alsa_trigger()
574 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in xen_snd_front_alsa_handle_cur_pos() local
579 delta = cur_frame - stream->be_cur_frame; in xen_snd_front_alsa_handle_cur_pos()
580 stream->be_cur_frame = cur_frame; in xen_snd_front_alsa_handle_cur_pos()
582 new_hw_ptr = (snd_pcm_uframes_t)atomic_read(&stream->hw_ptr); in xen_snd_front_alsa_handle_cur_pos()
584 atomic_set(&stream->hw_ptr, (int)new_hw_ptr); in xen_snd_front_alsa_handle_cur_pos()
586 stream->out_frames += delta; in xen_snd_front_alsa_handle_cur_pos()
587 if (stream->out_frames > substream->runtime->period_size) { in xen_snd_front_alsa_handle_cur_pos()
588 stream->out_frames %= substream->runtime->period_size; in xen_snd_front_alsa_handle_cur_pos()
595 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_pointer() local
597 return (snd_pcm_uframes_t)atomic_read(&stream->hw_ptr); in alsa_pointer()
604 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_pb_copy() local
606 if (unlikely(pos + count > stream->buffer_sz)) in alsa_pb_copy()
609 if (copy_from_iter(stream->buffer + pos, count, src) != count) in alsa_pb_copy()
612 return xen_snd_front_stream_write(&stream->evt_pair->req, pos, count); in alsa_pb_copy()
619 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_cap_copy() local
622 if (unlikely(pos + count > stream->buffer_sz)) in alsa_cap_copy()
625 ret = xen_snd_front_stream_read(&stream->evt_pair->req, pos, count); in alsa_cap_copy()
629 if (copy_to_iter(stream->buffer + pos, count, dst) != count) in alsa_cap_copy()
638 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_pb_fill_silence() local
640 if (unlikely(pos + count > stream->buffer_sz)) in alsa_pb_fill_silence()
643 memset(stream->buffer + pos, 0, count); in alsa_pb_fill_silence()
645 return xen_snd_front_stream_write(&stream->evt_pair->req, pos, count); in alsa_pb_fill_silence()