Lines Matching full:pipe
15 * pipe->transferred is the counter of data which has been already transferred.
25 * the current point of read buffer is kept in pipe->hw_ptr. note that
46 struct vx_pipe *pipe) in vx_pcm_read_per_bytes() argument
48 int offset = pipe->hw_ptr; in vx_pcm_read_per_bytes()
51 if (++offset >= pipe->buffer_bytes) { in vx_pcm_read_per_bytes()
56 if (++offset >= pipe->buffer_bytes) { in vx_pcm_read_per_bytes()
61 if (++offset >= pipe->buffer_bytes) { in vx_pcm_read_per_bytes()
64 pipe->hw_ptr = offset; in vx_pcm_read_per_bytes()
82 * @pipe: the pipe to be checked
84 * if the pipe is programmed with the differed time, set the DSP time
90 struct vx_pipe *pipe) in vx_set_differed_time() argument
93 if (! (pipe->differed_type & DC_DIFFERED_DELAY)) in vx_set_differed_time()
100 vx_set_pcx_time(chip, &pipe->pcx_time, &rmh->Cmd[1]); in vx_set_differed_time()
103 if (pipe->differed_type & DC_NOTIFY_DELAY) in vx_set_differed_time()
107 if (pipe->differed_type & DC_MULTIPLE_DELAY) in vx_set_differed_time()
111 if (pipe->differed_type & DC_STREAM_TIME_DELAY) in vx_set_differed_time()
120 * @pipe: the affected pipe
123 static int vx_set_stream_format(struct vx_core *chip, struct vx_pipe *pipe, in vx_set_stream_format() argument
128 vx_init_rmh(&rmh, pipe->is_capture ? in vx_set_stream_format()
130 rmh.Cmd[0] |= pipe->number << FIELD_SIZE; in vx_set_stream_format()
133 vx_set_differed_time(chip, &rmh, pipe); in vx_set_stream_format()
144 * vx_set_format - set the format of a pipe
145 * @pipe: the affected pipe
150 static int vx_set_format(struct vx_core *chip, struct vx_pipe *pipe, in vx_set_format() argument
173 return vx_set_stream_format(chip, pipe, header); in vx_set_format()
200 * vx_get_pipe_state - get the state of a pipe
201 * @pipe: the pipe to be checked
204 * checks the state of a given pipe, and stores the state (1 = running,
209 static int vx_get_pipe_state(struct vx_core *chip, struct vx_pipe *pipe, int *state) in vx_get_pipe_state() argument
215 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_get_pipe_state()
218 *state = (rmh.Stat[0] & (1 << pipe->number)) ? 1 : 0; in vx_get_pipe_state()
225 * @pipe: the pipe to be checked
234 static int vx_query_hbuffer_size(struct vx_core *chip, struct vx_pipe *pipe) in vx_query_hbuffer_size() argument
240 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_query_hbuffer_size()
241 if (pipe->is_capture) in vx_query_hbuffer_size()
251 * vx_pipe_can_start - query whether a pipe is ready for start
252 * @pipe: the pipe to be checked
258 static int vx_pipe_can_start(struct vx_core *chip, struct vx_pipe *pipe) in vx_pipe_can_start() argument
264 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_pipe_can_start()
276 * vx_conf_pipe - tell the pipe to stand by and wait for IRQA.
277 * @pipe: the pipe to be configured
279 static int vx_conf_pipe(struct vx_core *chip, struct vx_pipe *pipe) in vx_conf_pipe() argument
284 if (pipe->is_capture) in vx_conf_pipe()
286 rmh.Cmd[1] = 1 << pipe->number; in vx_conf_pipe()
305 * only 126 samples require to be prepared before a pipe can start
307 #define CAN_START_DELAY 2 /* wait 2ms only before asking if the pipe is ready*/
308 #define WAIT_STATE_DELAY 2 /* wait 2ms after irqA was requested and check if the pipe state …
311 * vx_toggle_pipe - start / pause a pipe
312 * @pipe: the pipe to be triggered
318 static int vx_toggle_pipe(struct vx_core *chip, struct vx_pipe *pipe, int state) in vx_toggle_pipe() argument
322 /* Check the pipe is not already in the requested state */ in vx_toggle_pipe()
323 if (vx_get_pipe_state(chip, pipe, &cur_state) < 0) in vx_toggle_pipe()
330 * enough sound buffer for this pipe) in vx_toggle_pipe()
334 err = vx_pipe_can_start(chip, pipe); in vx_toggle_pipe()
344 if ((err = vx_conf_pipe(chip, pipe)) < 0) in vx_toggle_pipe()
352 * Check one pipe only (since they are synchronous) in vx_toggle_pipe()
355 err = vx_get_pipe_state(chip, pipe, &cur_state); in vx_toggle_pipe()
366 * vx_stop_pipe - stop a pipe
367 * @pipe: the pipe to be stopped
371 static int vx_stop_pipe(struct vx_core *chip, struct vx_pipe *pipe) in vx_stop_pipe() argument
375 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_stop_pipe()
381 * vx_alloc_pipe - allocate a pipe and initialize the pipe instance
385 * @pipep: the returned pipe instance
394 struct vx_pipe *pipe; in vx_alloc_pipe() local
412 /* initialize the pipe record */ in vx_alloc_pipe()
413 pipe = kzalloc(sizeof(*pipe), GFP_KERNEL); in vx_alloc_pipe()
414 if (! pipe) { in vx_alloc_pipe()
415 /* release the pipe */ in vx_alloc_pipe()
422 /* the pipe index should be identical with the audio index */ in vx_alloc_pipe()
423 pipe->number = audioid; in vx_alloc_pipe()
424 pipe->is_capture = capture; in vx_alloc_pipe()
425 pipe->channels = num_audio; in vx_alloc_pipe()
426 pipe->differed_type = 0; in vx_alloc_pipe()
427 pipe->pcx_time = 0; in vx_alloc_pipe()
428 pipe->data_mode = data_mode; in vx_alloc_pipe()
429 *pipep = pipe; in vx_alloc_pipe()
436 * vx_free_pipe - release a pipe
437 * @pipe: pipe to be released
439 static int vx_free_pipe(struct vx_core *chip, struct vx_pipe *pipe) in vx_free_pipe() argument
444 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_free_pipe()
447 kfree(pipe); in vx_free_pipe()
457 static int vx_start_stream(struct vx_core *chip, struct vx_pipe *pipe) in vx_start_stream() argument
462 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number); in vx_start_stream()
463 vx_set_differed_time(chip, &rmh, pipe); in vx_start_stream()
473 static int vx_stop_stream(struct vx_core *chip, struct vx_pipe *pipe) in vx_stop_stream() argument
478 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number); in vx_stop_stream()
514 struct vx_pipe *pipe = NULL; in vx_pcm_playback_open() local
525 /* playback pipe may have been already allocated for monitoring */ in vx_pcm_playback_open()
526 pipe = chip->playback_pipes[audio]; in vx_pcm_playback_open()
527 if (! pipe) { in vx_pcm_playback_open()
529 err = vx_alloc_pipe(chip, 0, audio, 2, &pipe); /* stereo playback */ in vx_pcm_playback_open()
534 pipe->references++; in vx_pcm_playback_open()
536 pipe->substream = subs; in vx_pcm_playback_open()
537 chip->playback_pipes[audio] = pipe; in vx_pcm_playback_open()
541 runtime->private_data = pipe; in vx_pcm_playback_open()
556 struct vx_pipe *pipe; in vx_pcm_playback_close() local
561 pipe = subs->runtime->private_data; in vx_pcm_playback_close()
563 if (--pipe->references == 0) { in vx_pcm_playback_close()
564 chip->playback_pipes[pipe->number] = NULL; in vx_pcm_playback_close()
565 vx_free_pipe(chip, pipe); in vx_pcm_playback_close()
574 * vx_notify_end_of_buffer - send "end-of-buffer" notifier at the given pipe
575 * @pipe: the pipe to notify
579 static int vx_notify_end_of_buffer(struct vx_core *chip, struct vx_pipe *pipe) in vx_notify_end_of_buffer() argument
587 vx_set_stream_cmd_params(&rmh, 0, pipe->number); in vx_notify_end_of_buffer()
599 * @pipe: the pipe to transfer
609 struct vx_pipe *pipe, int size) in vx_pcm_playback_transfer_chunk() argument
613 space = vx_query_hbuffer_size(chip, pipe); in vx_pcm_playback_transfer_chunk()
630 vx_pseudo_dma_write(chip, runtime, pipe, size); in vx_pcm_playback_transfer_chunk()
631 err = vx_notify_end_of_buffer(chip, pipe); in vx_pcm_playback_transfer_chunk()
639 * update the position of the given pipe.
640 * pipe->position is updated and wrapped within the buffer size.
641 * pipe->transferred is updated, too, but the size is not wrapped,
647 struct vx_pipe *pipe) in vx_update_pipe_position() argument
654 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_update_pipe_position()
660 update = (int)(count - pipe->cur_count); in vx_update_pipe_position()
661 pipe->cur_count = count; in vx_update_pipe_position()
662 pipe->position += update; in vx_update_pipe_position()
663 if (pipe->position >= (int)runtime->buffer_size) in vx_update_pipe_position()
664 pipe->position %= runtime->buffer_size; in vx_update_pipe_position()
665 pipe->transferred += update; in vx_update_pipe_position()
675 struct vx_pipe *pipe, int nchunks) in vx_pcm_playback_transfer() argument
680 if (! pipe->prepared || (chip->chip_status & VX_STAT_IS_STALE)) in vx_pcm_playback_transfer()
683 if ((err = vx_pcm_playback_transfer_chunk(chip, runtime, pipe, in vx_pcm_playback_transfer()
695 struct vx_pipe *pipe) in vx_pcm_playback_update() argument
700 if (pipe->running && ! (chip->chip_status & VX_STAT_IS_STALE)) { in vx_pcm_playback_update()
701 if ((err = vx_update_pipe_position(chip, runtime, pipe)) < 0) in vx_pcm_playback_update()
703 if (pipe->transferred >= (int)runtime->period_size) { in vx_pcm_playback_update()
704 pipe->transferred %= runtime->period_size; in vx_pcm_playback_update()
716 struct vx_pipe *pipe = subs->runtime->private_data; in vx_pcm_trigger() local
725 if (! pipe->is_capture) in vx_pcm_trigger()
726 vx_pcm_playback_transfer(chip, subs, pipe, 2); in vx_pcm_trigger()
727 err = vx_start_stream(chip, pipe); in vx_pcm_trigger()
732 err = vx_toggle_pipe(chip, pipe, 1); in vx_pcm_trigger()
734 pr_debug("vx: cannot start pipe\n"); in vx_pcm_trigger()
735 vx_stop_stream(chip, pipe); in vx_pcm_trigger()
739 pipe->running = 1; in vx_pcm_trigger()
743 vx_toggle_pipe(chip, pipe, 0); in vx_pcm_trigger()
744 vx_stop_pipe(chip, pipe); in vx_pcm_trigger()
745 vx_stop_stream(chip, pipe); in vx_pcm_trigger()
747 pipe->running = 0; in vx_pcm_trigger()
750 if ((err = vx_toggle_pipe(chip, pipe, 0)) < 0) in vx_pcm_trigger()
754 if ((err = vx_toggle_pipe(chip, pipe, 1)) < 0) in vx_pcm_trigger()
769 struct vx_pipe *pipe = runtime->private_data; in vx_pcm_playback_pointer() local
770 return pipe->position; in vx_pcm_playback_pointer()
780 struct vx_pipe *pipe = runtime->private_data; in vx_pcm_prepare() local
788 if (data_mode != pipe->data_mode && ! pipe->is_capture) { in vx_pcm_prepare()
790 /* we reopen the pipe */ in vx_pcm_prepare()
792 snd_printdd(KERN_DEBUG "reopen the pipe with data_mode = %d\n", data_mode); in vx_pcm_prepare()
794 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, 0); in vx_pcm_prepare()
798 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, pipe->channels); in vx_pcm_prepare()
803 pipe->data_mode = data_mode; in vx_pcm_prepare()
813 if ((err = vx_set_format(chip, pipe, runtime)) < 0) in vx_pcm_prepare()
817 pipe->align = 2; /* 16bit word */ in vx_pcm_prepare()
819 pipe->align = 4; /* 32bit word */ in vx_pcm_prepare()
822 pipe->buffer_bytes = frames_to_bytes(runtime, runtime->buffer_size); in vx_pcm_prepare()
823 pipe->period_bytes = frames_to_bytes(runtime, runtime->period_size); in vx_pcm_prepare()
824 pipe->hw_ptr = 0; in vx_pcm_prepare()
827 vx_update_pipe_position(chip, runtime, pipe); in vx_pcm_prepare()
829 pipe->transferred = 0; in vx_pcm_prepare()
830 pipe->position = 0; in vx_pcm_prepare()
832 pipe->prepared = 1; in vx_pcm_prepare()
881 struct vx_pipe *pipe; in vx_pcm_capture_open() local
892 err = vx_alloc_pipe(chip, 1, audio, 2, &pipe); in vx_pcm_capture_open()
895 pipe->substream = subs; in vx_pcm_capture_open()
896 chip->capture_pipes[audio] = pipe; in vx_pcm_capture_open()
902 /* allocate a pipe */ in vx_pcm_capture_open()
910 if an output pipe is available, it's audios still may need to be in vx_pcm_capture_open()
920 pipe->monitoring_pipe = pipe_out_monitoring; /* default value NULL */ in vx_pcm_capture_open()
924 runtime->private_data = pipe; in vx_pcm_capture_open()
939 struct vx_pipe *pipe; in vx_pcm_capture_close() local
944 pipe = subs->runtime->private_data; in vx_pcm_capture_close()
945 chip->capture_pipes[pipe->number] = NULL; in vx_pcm_capture_close()
947 pipe_out_monitoring = pipe->monitoring_pipe; in vx_pcm_capture_close()
950 if an output pipe is attached to this input, in vx_pcm_capture_close()
956 chip->playback_pipes[pipe->number] = NULL; in vx_pcm_capture_close()
957 pipe->monitoring_pipe = NULL; in vx_pcm_capture_close()
961 vx_free_pipe(chip, pipe); in vx_pcm_capture_close()
973 struct vx_pipe *pipe) in vx_pcm_capture_update() argument
978 if (!pipe->running || (chip->chip_status & VX_STAT_IS_STALE)) in vx_pcm_capture_update()
985 space = vx_query_hbuffer_size(chip, pipe); in vx_pcm_capture_update()
1000 if ((pipe->hw_ptr % pipe->align) == 0) in vx_pcm_capture_update()
1004 vx_pcm_read_per_bytes(chip, runtime, pipe); in vx_pcm_capture_update()
1009 int align = pipe->align * 3; in vx_pcm_capture_update()
1012 vx_pseudo_dma_read(chip, runtime, pipe, space); in vx_pcm_capture_update()
1020 vx_pcm_read_per_bytes(chip, runtime, pipe); in vx_pcm_capture_update()
1028 vx_pcm_read_per_bytes(chip, runtime, pipe); in vx_pcm_capture_update()
1032 pipe->transferred += size; in vx_pcm_capture_update()
1033 if (pipe->transferred >= pipe->period_bytes) { in vx_pcm_capture_update()
1034 pipe->transferred %= pipe->period_bytes; in vx_pcm_capture_update()
1051 struct vx_pipe *pipe = runtime->private_data; in vx_pcm_capture_pointer() local
1052 return bytes_to_frames(runtime, pipe->hw_ptr); in vx_pcm_capture_pointer()
1073 struct vx_pipe *pipe; in vx_pcm_update_intr() local
1108 pipe = chip->playback_pipes[p]; in vx_pcm_update_intr()
1109 if (pipe && pipe->substream) { in vx_pcm_update_intr()
1110 vx_pcm_playback_update(chip, pipe->substream, pipe); in vx_pcm_update_intr()
1111 vx_pcm_playback_transfer(chip, pipe->substream, pipe, buf); in vx_pcm_update_intr()
1118 pipe = chip->capture_pipes[i]; in vx_pcm_update_intr()
1119 if (pipe && pipe->substream) in vx_pcm_update_intr()
1120 vx_pcm_capture_update(chip, pipe->substream, pipe); in vx_pcm_update_intr()
1126 * vx_init_audio_io - check the available audio i/o and allocate pipe arrays