Lines Matching refs:stream

217 static void stream_clear(struct xen_snd_front_pcm_stream_info *stream)  in stream_clear()  argument
219 stream->is_open = false; in stream_clear()
220 stream->be_cur_frame = 0; in stream_clear()
221 stream->out_frames = 0; in stream_clear()
222 atomic_set(&stream->hw_ptr, 0); in stream_clear()
223 xen_snd_front_evtchnl_pair_clear(stream->evt_pair); in stream_clear()
224 memset(&stream->shbuf, 0, sizeof(stream->shbuf)); in stream_clear()
225 stream->buffer = NULL; in stream_clear()
226 stream->buffer_sz = 0; in stream_clear()
227 stream->pages = NULL; in stream_clear()
228 stream->num_pages = 0; in stream_clear()
231 static void stream_free(struct xen_snd_front_pcm_stream_info *stream) in stream_free() argument
233 xen_front_pgdir_shbuf_unmap(&stream->shbuf); in stream_free()
234 xen_front_pgdir_shbuf_free(&stream->shbuf); in stream_free()
235 if (stream->buffer) in stream_free()
236 free_pages_exact(stream->buffer, stream->buffer_sz); in stream_free()
237 kfree(stream->pages); in stream_free()
238 stream_clear(stream); in stream_free()
246 struct xen_snd_front_pcm_stream_info *stream; in stream_get() local
248 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in stream_get()
249 stream = &pcm_instance->streams_pb[substream->number]; in stream_get()
251 stream = &pcm_instance->streams_cap[substream->number]; in stream_get()
253 return stream; in stream_get()
259 struct xen_snd_front_pcm_stream_info *stream = rule->private; in alsa_hw_rule() local
260 struct device *dev = &stream->front_info->xb_dev->dev; in alsa_hw_rule()
297 ret = xen_snd_front_stream_query_hw_param(&stream->evt_pair->req, in alsa_hw_rule()
357 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_open() local
368 runtime->hw = stream->pcm_hw; in alsa_open()
378 stream->evt_pair = &front_info->evt_pairs[stream->index]; in alsa_open()
380 stream->front_info = front_info; in alsa_open()
382 stream->evt_pair->evt.u.evt.substream = substream; in alsa_open()
384 stream_clear(stream); in alsa_open()
386 xen_snd_front_evtchnl_pair_set_connected(stream->evt_pair, true); in alsa_open()
389 alsa_hw_rule, stream, in alsa_open()
397 alsa_hw_rule, stream, in alsa_open()
405 alsa_hw_rule, stream, in alsa_open()
413 alsa_hw_rule, stream, in alsa_open()
421 alsa_hw_rule, stream, in alsa_open()
433 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_close() local
435 xen_snd_front_evtchnl_pair_set_connected(stream->evt_pair, false); in alsa_close()
439 static int shbuf_setup_backstore(struct xen_snd_front_pcm_stream_info *stream, in shbuf_setup_backstore() argument
444 stream->buffer = alloc_pages_exact(buffer_sz, GFP_KERNEL); in shbuf_setup_backstore()
445 if (!stream->buffer) in shbuf_setup_backstore()
448 stream->buffer_sz = buffer_sz; in shbuf_setup_backstore()
449 stream->num_pages = DIV_ROUND_UP(stream->buffer_sz, PAGE_SIZE); in shbuf_setup_backstore()
450 stream->pages = kcalloc(stream->num_pages, sizeof(struct page *), in shbuf_setup_backstore()
452 if (!stream->pages) in shbuf_setup_backstore()
455 for (i = 0; i < stream->num_pages; i++) in shbuf_setup_backstore()
456 stream->pages[i] = virt_to_page(stream->buffer + i * PAGE_SIZE); in shbuf_setup_backstore()
464 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_hw_params() local
465 struct xen_snd_front_info *front_info = stream->front_info; in alsa_hw_params()
473 stream_free(stream); in alsa_hw_params()
474 ret = shbuf_setup_backstore(stream, params_buffer_bytes(params)); in alsa_hw_params()
480 buf_cfg.pgdir = &stream->shbuf; in alsa_hw_params()
481 buf_cfg.num_pages = stream->num_pages; in alsa_hw_params()
482 buf_cfg.pages = stream->pages; in alsa_hw_params()
488 ret = xen_front_pgdir_shbuf_map(&stream->shbuf); in alsa_hw_params()
495 stream_free(stream); in alsa_hw_params()
498 stream->index); in alsa_hw_params()
504 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_hw_free() local
507 ret = xen_snd_front_stream_close(&stream->evt_pair->req); in alsa_hw_free()
508 stream_free(stream); in alsa_hw_free()
514 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_prepare() local
516 if (!stream->is_open) { in alsa_prepare()
523 dev_err(&stream->front_info->xb_dev->dev, in alsa_prepare()
530 ret = xen_snd_front_stream_prepare(&stream->evt_pair->req, in alsa_prepare()
531 &stream->shbuf, in alsa_prepare()
540 stream->is_open = true; in alsa_prepare()
548 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_trigger() local
572 return xen_snd_front_stream_trigger(&stream->evt_pair->req, type); in alsa_trigger()
579 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in xen_snd_front_alsa_handle_cur_pos() local
584 delta = cur_frame - stream->be_cur_frame; in xen_snd_front_alsa_handle_cur_pos()
585 stream->be_cur_frame = cur_frame; in xen_snd_front_alsa_handle_cur_pos()
587 new_hw_ptr = (snd_pcm_uframes_t)atomic_read(&stream->hw_ptr); in xen_snd_front_alsa_handle_cur_pos()
589 atomic_set(&stream->hw_ptr, (int)new_hw_ptr); in xen_snd_front_alsa_handle_cur_pos()
591 stream->out_frames += delta; in xen_snd_front_alsa_handle_cur_pos()
592 if (stream->out_frames > substream->runtime->period_size) { in xen_snd_front_alsa_handle_cur_pos()
593 stream->out_frames %= substream->runtime->period_size; in xen_snd_front_alsa_handle_cur_pos()
600 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_pointer() local
602 return (snd_pcm_uframes_t)atomic_read(&stream->hw_ptr); in alsa_pointer()
609 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_pb_copy_user() local
611 if (unlikely(pos + count > stream->buffer_sz)) in alsa_pb_copy_user()
614 if (copy_from_user(stream->buffer + pos, src, count)) in alsa_pb_copy_user()
617 return xen_snd_front_stream_write(&stream->evt_pair->req, pos, count); in alsa_pb_copy_user()
624 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_pb_copy_kernel() local
626 if (unlikely(pos + count > stream->buffer_sz)) in alsa_pb_copy_kernel()
629 memcpy(stream->buffer + pos, src, count); in alsa_pb_copy_kernel()
631 return xen_snd_front_stream_write(&stream->evt_pair->req, pos, count); in alsa_pb_copy_kernel()
638 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_cap_copy_user() local
641 if (unlikely(pos + count > stream->buffer_sz)) in alsa_cap_copy_user()
644 ret = xen_snd_front_stream_read(&stream->evt_pair->req, pos, count); in alsa_cap_copy_user()
648 return copy_to_user(dst, stream->buffer + pos, count) ? in alsa_cap_copy_user()
656 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_cap_copy_kernel() local
659 if (unlikely(pos + count > stream->buffer_sz)) in alsa_cap_copy_kernel()
662 ret = xen_snd_front_stream_read(&stream->evt_pair->req, pos, count); in alsa_cap_copy_kernel()
666 memcpy(dst, stream->buffer + pos, count); in alsa_cap_copy_kernel()
675 struct xen_snd_front_pcm_stream_info *stream = stream_get(substream); in alsa_pb_fill_silence() local
677 if (unlikely(pos + count > stream->buffer_sz)) in alsa_pb_fill_silence()
680 memset(stream->buffer + pos, 0, count); in alsa_pb_fill_silence()
682 return xen_snd_front_stream_write(&stream->evt_pair->req, pos, count); in alsa_pb_fill_silence()