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()
202 * vx_get_pipe_state - get the state of a pipe
203 * @pipe: the pipe to be checked
206 * checks the state of a given pipe, and stores the state (1 = running,
211 static int vx_get_pipe_state(struct vx_core *chip, struct vx_pipe *pipe, int *state) in vx_get_pipe_state() argument
217 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_get_pipe_state()
220 *state = (rmh.Stat[0] & (1 << pipe->number)) ? 1 : 0; in vx_get_pipe_state()
227 * @pipe: the pipe to be checked
236 static int vx_query_hbuffer_size(struct vx_core *chip, struct vx_pipe *pipe) in vx_query_hbuffer_size() argument
242 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_query_hbuffer_size()
243 if (pipe->is_capture) in vx_query_hbuffer_size()
253 * vx_pipe_can_start - query whether a pipe is ready for start
254 * @pipe: the pipe to be checked
260 static int vx_pipe_can_start(struct vx_core *chip, struct vx_pipe *pipe) in vx_pipe_can_start() argument
266 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_pipe_can_start()
278 * vx_conf_pipe - tell the pipe to stand by and wait for IRQA.
279 * @pipe: the pipe to be configured
281 static int vx_conf_pipe(struct vx_core *chip, struct vx_pipe *pipe) in vx_conf_pipe() argument
286 if (pipe->is_capture) in vx_conf_pipe()
288 rmh.Cmd[1] = 1 << pipe->number; in vx_conf_pipe()
307 * only 126 samples require to be prepared before a pipe can start
309 #define CAN_START_DELAY 2 /* wait 2ms only before asking if the pipe is ready*/
310 #define WAIT_STATE_DELAY 2 /* wait 2ms after irqA was requested and check if the pipe state …
313 * vx_toggle_pipe - start / pause a pipe
314 * @pipe: the pipe to be triggered
320 static int vx_toggle_pipe(struct vx_core *chip, struct vx_pipe *pipe, int state) in vx_toggle_pipe() argument
324 /* Check the pipe is not already in the requested state */ in vx_toggle_pipe()
325 if (vx_get_pipe_state(chip, pipe, &cur_state) < 0) in vx_toggle_pipe()
332 * enough sound buffer for this pipe) in vx_toggle_pipe()
336 err = vx_pipe_can_start(chip, pipe); in vx_toggle_pipe()
346 err = vx_conf_pipe(chip, pipe); in vx_toggle_pipe()
356 * Check one pipe only (since they are synchronous) in vx_toggle_pipe()
359 err = vx_get_pipe_state(chip, pipe, &cur_state); in vx_toggle_pipe()
370 * vx_stop_pipe - stop a pipe
371 * @pipe: the pipe to be stopped
375 static int vx_stop_pipe(struct vx_core *chip, struct vx_pipe *pipe) in vx_stop_pipe() argument
379 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_stop_pipe()
385 * vx_alloc_pipe - allocate a pipe and initialize the pipe instance
389 * @pipep: the returned pipe instance
398 struct vx_pipe *pipe; in vx_alloc_pipe() local
416 /* initialize the pipe record */ in vx_alloc_pipe()
417 pipe = kzalloc(sizeof(*pipe), GFP_KERNEL); in vx_alloc_pipe()
418 if (! pipe) { in vx_alloc_pipe()
419 /* release the pipe */ in vx_alloc_pipe()
426 /* the pipe index should be identical with the audio index */ in vx_alloc_pipe()
427 pipe->number = audioid; in vx_alloc_pipe()
428 pipe->is_capture = capture; in vx_alloc_pipe()
429 pipe->channels = num_audio; in vx_alloc_pipe()
430 pipe->differed_type = 0; in vx_alloc_pipe()
431 pipe->pcx_time = 0; in vx_alloc_pipe()
432 pipe->data_mode = data_mode; in vx_alloc_pipe()
433 *pipep = pipe; in vx_alloc_pipe()
440 * vx_free_pipe - release a pipe
441 * @pipe: pipe to be released
443 static int vx_free_pipe(struct vx_core *chip, struct vx_pipe *pipe) in vx_free_pipe() argument
448 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_free_pipe()
451 kfree(pipe); in vx_free_pipe()
461 static int vx_start_stream(struct vx_core *chip, struct vx_pipe *pipe) in vx_start_stream() argument
466 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number); in vx_start_stream()
467 vx_set_differed_time(chip, &rmh, pipe); in vx_start_stream()
477 static int vx_stop_stream(struct vx_core *chip, struct vx_pipe *pipe) in vx_stop_stream() argument
482 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number); in vx_stop_stream()
518 struct vx_pipe *pipe = NULL; in vx_pcm_playback_open() local
529 /* playback pipe may have been already allocated for monitoring */ in vx_pcm_playback_open()
530 pipe = chip->playback_pipes[audio]; in vx_pcm_playback_open()
531 if (! pipe) { in vx_pcm_playback_open()
533 err = vx_alloc_pipe(chip, 0, audio, 2, &pipe); /* stereo playback */ in vx_pcm_playback_open()
538 pipe->references++; in vx_pcm_playback_open()
540 pipe->substream = subs; in vx_pcm_playback_open()
541 chip->playback_pipes[audio] = pipe; in vx_pcm_playback_open()
545 runtime->private_data = pipe; in vx_pcm_playback_open()
560 struct vx_pipe *pipe; in vx_pcm_playback_close() local
565 pipe = subs->runtime->private_data; in vx_pcm_playback_close()
567 if (--pipe->references == 0) { in vx_pcm_playback_close()
568 chip->playback_pipes[pipe->number] = NULL; in vx_pcm_playback_close()
569 vx_free_pipe(chip, pipe); in vx_pcm_playback_close()
578 * vx_notify_end_of_buffer - send "end-of-buffer" notifier at the given pipe
579 * @pipe: the pipe to notify
583 static int vx_notify_end_of_buffer(struct vx_core *chip, struct vx_pipe *pipe) in vx_notify_end_of_buffer() argument
591 vx_set_stream_cmd_params(&rmh, 0, pipe->number); in vx_notify_end_of_buffer()
603 * @pipe: the pipe to transfer
613 struct vx_pipe *pipe, int size) in vx_pcm_playback_transfer_chunk() argument
617 space = vx_query_hbuffer_size(chip, pipe); in vx_pcm_playback_transfer_chunk()
634 vx_pseudo_dma_write(chip, runtime, pipe, size); in vx_pcm_playback_transfer_chunk()
635 err = vx_notify_end_of_buffer(chip, pipe); in vx_pcm_playback_transfer_chunk()
643 * update the position of the given pipe.
644 * pipe->position is updated and wrapped within the buffer size.
645 * pipe->transferred is updated, too, but the size is not wrapped,
651 struct vx_pipe *pipe) in vx_update_pipe_position() argument
658 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_update_pipe_position()
664 update = (int)(count - pipe->cur_count); in vx_update_pipe_position()
665 pipe->cur_count = count; in vx_update_pipe_position()
666 pipe->position += update; in vx_update_pipe_position()
667 if (pipe->position >= (int)runtime->buffer_size) in vx_update_pipe_position()
668 pipe->position %= runtime->buffer_size; in vx_update_pipe_position()
669 pipe->transferred += update; in vx_update_pipe_position()
679 struct vx_pipe *pipe, int nchunks) in vx_pcm_playback_transfer() argument
684 if (! pipe->prepared || (chip->chip_status & VX_STAT_IS_STALE)) in vx_pcm_playback_transfer()
687 err = vx_pcm_playback_transfer_chunk(chip, runtime, pipe, in vx_pcm_playback_transfer()
700 struct vx_pipe *pipe) in vx_pcm_playback_update() argument
705 if (pipe->running && ! (chip->chip_status & VX_STAT_IS_STALE)) { in vx_pcm_playback_update()
706 err = vx_update_pipe_position(chip, runtime, pipe); in vx_pcm_playback_update()
709 if (pipe->transferred >= (int)runtime->period_size) { in vx_pcm_playback_update()
710 pipe->transferred %= runtime->period_size; in vx_pcm_playback_update()
722 struct vx_pipe *pipe = subs->runtime->private_data; in vx_pcm_trigger() local
731 if (! pipe->is_capture) in vx_pcm_trigger()
732 vx_pcm_playback_transfer(chip, subs, pipe, 2); in vx_pcm_trigger()
733 err = vx_start_stream(chip, pipe); in vx_pcm_trigger()
738 err = vx_toggle_pipe(chip, pipe, 1); in vx_pcm_trigger()
740 pr_debug("vx: cannot start pipe\n"); in vx_pcm_trigger()
741 vx_stop_stream(chip, pipe); in vx_pcm_trigger()
745 pipe->running = 1; in vx_pcm_trigger()
749 vx_toggle_pipe(chip, pipe, 0); in vx_pcm_trigger()
750 vx_stop_pipe(chip, pipe); in vx_pcm_trigger()
751 vx_stop_stream(chip, pipe); in vx_pcm_trigger()
753 pipe->running = 0; in vx_pcm_trigger()
756 err = vx_toggle_pipe(chip, pipe, 0); in vx_pcm_trigger()
761 err = vx_toggle_pipe(chip, pipe, 1); in vx_pcm_trigger()
777 struct vx_pipe *pipe = runtime->private_data; in vx_pcm_playback_pointer() local
778 return pipe->position; in vx_pcm_playback_pointer()
788 struct vx_pipe *pipe = runtime->private_data; in vx_pcm_prepare() local
796 if (data_mode != pipe->data_mode && ! pipe->is_capture) { in vx_pcm_prepare()
798 /* we reopen the pipe */ in vx_pcm_prepare()
801 "reopen the pipe with data_mode = %d\n", data_mode); in vx_pcm_prepare()
803 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, 0); in vx_pcm_prepare()
808 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, pipe->channels); in vx_pcm_prepare()
814 pipe->data_mode = data_mode; in vx_pcm_prepare()
825 err = vx_set_format(chip, pipe, runtime); in vx_pcm_prepare()
830 pipe->align = 2; /* 16bit word */ in vx_pcm_prepare()
832 pipe->align = 4; /* 32bit word */ in vx_pcm_prepare()
835 pipe->buffer_bytes = frames_to_bytes(runtime, runtime->buffer_size); in vx_pcm_prepare()
836 pipe->period_bytes = frames_to_bytes(runtime, runtime->period_size); in vx_pcm_prepare()
837 pipe->hw_ptr = 0; in vx_pcm_prepare()
840 vx_update_pipe_position(chip, runtime, pipe); in vx_pcm_prepare()
842 pipe->transferred = 0; in vx_pcm_prepare()
843 pipe->position = 0; in vx_pcm_prepare()
845 pipe->prepared = 1; in vx_pcm_prepare()
894 struct vx_pipe *pipe; in vx_pcm_capture_open() local
905 err = vx_alloc_pipe(chip, 1, audio, 2, &pipe); in vx_pcm_capture_open()
908 pipe->substream = subs; in vx_pcm_capture_open()
909 chip->capture_pipes[audio] = pipe; in vx_pcm_capture_open()
915 /* allocate a pipe */ in vx_pcm_capture_open()
923 if an output pipe is available, it's audios still may need to be in vx_pcm_capture_open()
933 pipe->monitoring_pipe = pipe_out_monitoring; /* default value NULL */ in vx_pcm_capture_open()
937 runtime->private_data = pipe; in vx_pcm_capture_open()
952 struct vx_pipe *pipe; in vx_pcm_capture_close() local
957 pipe = subs->runtime->private_data; in vx_pcm_capture_close()
958 chip->capture_pipes[pipe->number] = NULL; in vx_pcm_capture_close()
960 pipe_out_monitoring = pipe->monitoring_pipe; in vx_pcm_capture_close()
963 if an output pipe is attached to this input, in vx_pcm_capture_close()
969 chip->playback_pipes[pipe->number] = NULL; in vx_pcm_capture_close()
970 pipe->monitoring_pipe = NULL; in vx_pcm_capture_close()
974 vx_free_pipe(chip, pipe); in vx_pcm_capture_close()
986 struct vx_pipe *pipe) in vx_pcm_capture_update() argument
991 if (!pipe->running || (chip->chip_status & VX_STAT_IS_STALE)) in vx_pcm_capture_update()
998 space = vx_query_hbuffer_size(chip, pipe); in vx_pcm_capture_update()
1013 if ((pipe->hw_ptr % pipe->align) == 0) in vx_pcm_capture_update()
1017 vx_pcm_read_per_bytes(chip, runtime, pipe); in vx_pcm_capture_update()
1022 int align = pipe->align * 3; in vx_pcm_capture_update()
1025 vx_pseudo_dma_read(chip, runtime, pipe, space); in vx_pcm_capture_update()
1033 vx_pcm_read_per_bytes(chip, runtime, pipe); in vx_pcm_capture_update()
1041 vx_pcm_read_per_bytes(chip, runtime, pipe); in vx_pcm_capture_update()
1045 pipe->transferred += size; in vx_pcm_capture_update()
1046 if (pipe->transferred >= pipe->period_bytes) { in vx_pcm_capture_update()
1047 pipe->transferred %= pipe->period_bytes; in vx_pcm_capture_update()
1064 struct vx_pipe *pipe = runtime->private_data; in vx_pcm_capture_pointer() local
1065 return bytes_to_frames(runtime, pipe->hw_ptr); in vx_pcm_capture_pointer()
1086 struct vx_pipe *pipe; in vx_pcm_update_intr() local
1121 pipe = chip->playback_pipes[p]; in vx_pcm_update_intr()
1122 if (pipe && pipe->substream) { in vx_pcm_update_intr()
1123 vx_pcm_playback_update(chip, pipe->substream, pipe); in vx_pcm_update_intr()
1124 vx_pcm_playback_transfer(chip, pipe->substream, pipe, buf); in vx_pcm_update_intr()
1131 pipe = chip->capture_pipes[i]; in vx_pcm_update_intr()
1132 if (pipe && pipe->substream) in vx_pcm_update_intr()
1133 vx_pcm_capture_update(chip, pipe->substream, pipe); in vx_pcm_update_intr()
1139 * vx_init_audio_io - check the available audio i/o and allocate pipe arrays