Lines Matching full:pipe
29 * pipe->transferred is the counter of data which has been already transferred.
39 * the current point of read buffer is kept in pipe->hw_ptr. note that
61 struct vx_pipe *pipe) in vx_pcm_read_per_bytes() argument
63 int offset = pipe->hw_ptr; in vx_pcm_read_per_bytes()
66 if (++offset >= pipe->buffer_bytes) { in vx_pcm_read_per_bytes()
71 if (++offset >= pipe->buffer_bytes) { in vx_pcm_read_per_bytes()
76 if (++offset >= pipe->buffer_bytes) { in vx_pcm_read_per_bytes()
80 pipe->hw_ptr = offset; in vx_pcm_read_per_bytes()
98 * @pipe: the pipe to be checked
100 * if the pipe is programmed with the differed time, set the DSP time
106 struct vx_pipe *pipe) in vx_set_differed_time() argument
109 if (! (pipe->differed_type & DC_DIFFERED_DELAY)) in vx_set_differed_time()
116 vx_set_pcx_time(chip, &pipe->pcx_time, &rmh->Cmd[1]); in vx_set_differed_time()
119 if (pipe->differed_type & DC_NOTIFY_DELAY) in vx_set_differed_time()
123 if (pipe->differed_type & DC_MULTIPLE_DELAY) in vx_set_differed_time()
127 if (pipe->differed_type & DC_STREAM_TIME_DELAY) in vx_set_differed_time()
136 * @pipe: the affected pipe
139 static int vx_set_stream_format(struct vx_core *chip, struct vx_pipe *pipe, in vx_set_stream_format() argument
144 vx_init_rmh(&rmh, pipe->is_capture ? in vx_set_stream_format()
146 rmh.Cmd[0] |= pipe->number << FIELD_SIZE; in vx_set_stream_format()
149 vx_set_differed_time(chip, &rmh, pipe); in vx_set_stream_format()
160 * vx_set_format - set the format of a pipe
161 * @pipe: the affected pipe
166 static int vx_set_format(struct vx_core *chip, struct vx_pipe *pipe, in vx_set_format() argument
189 return vx_set_stream_format(chip, pipe, header); in vx_set_format()
216 * vx_get_pipe_state - get the state of a pipe
217 * @pipe: the pipe to be checked
220 * checks the state of a given pipe, and stores the state (1 = running,
225 static int vx_get_pipe_state(struct vx_core *chip, struct vx_pipe *pipe, int *state) in vx_get_pipe_state() argument
231 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_get_pipe_state()
234 *state = (rmh.Stat[0] & (1 << pipe->number)) ? 1 : 0; in vx_get_pipe_state()
241 * @pipe: the pipe to be checked
250 static int vx_query_hbuffer_size(struct vx_core *chip, struct vx_pipe *pipe) in vx_query_hbuffer_size() argument
256 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_query_hbuffer_size()
257 if (pipe->is_capture) in vx_query_hbuffer_size()
267 * vx_pipe_can_start - query whether a pipe is ready for start
268 * @pipe: the pipe to be checked
274 static int vx_pipe_can_start(struct vx_core *chip, struct vx_pipe *pipe) in vx_pipe_can_start() argument
280 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_pipe_can_start()
292 * vx_conf_pipe - tell the pipe to stand by and wait for IRQA.
293 * @pipe: the pipe to be configured
295 static int vx_conf_pipe(struct vx_core *chip, struct vx_pipe *pipe) in vx_conf_pipe() argument
300 if (pipe->is_capture) in vx_conf_pipe()
302 rmh.Cmd[1] = 1 << pipe->number; in vx_conf_pipe()
321 * only 126 samples require to be prepared before a pipe can start
323 #define CAN_START_DELAY 2 /* wait 2ms only before asking if the pipe is ready*/
324 #define WAIT_STATE_DELAY 2 /* wait 2ms after irqA was requested and check if the pipe state …
327 * vx_toggle_pipe - start / pause a pipe
328 * @pipe: the pipe to be triggered
334 static int vx_toggle_pipe(struct vx_core *chip, struct vx_pipe *pipe, int state) in vx_toggle_pipe() argument
338 /* Check the pipe is not already in the requested state */ in vx_toggle_pipe()
339 if (vx_get_pipe_state(chip, pipe, &cur_state) < 0) in vx_toggle_pipe()
346 * enough sound buffer for this pipe) in vx_toggle_pipe()
350 err = vx_pipe_can_start(chip, pipe); in vx_toggle_pipe()
360 if ((err = vx_conf_pipe(chip, pipe)) < 0) in vx_toggle_pipe()
368 * Check one pipe only (since they are synchronous) in vx_toggle_pipe()
371 err = vx_get_pipe_state(chip, pipe, &cur_state); in vx_toggle_pipe()
382 * vx_stop_pipe - stop a pipe
383 * @pipe: the pipe to be stopped
387 static int vx_stop_pipe(struct vx_core *chip, struct vx_pipe *pipe) in vx_stop_pipe() argument
391 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_stop_pipe()
397 * vx_alloc_pipe - allocate a pipe and initialize the pipe instance
401 * @pipep: the returned pipe instance
410 struct vx_pipe *pipe; in vx_alloc_pipe() local
428 /* initialize the pipe record */ in vx_alloc_pipe()
429 pipe = kzalloc(sizeof(*pipe), GFP_KERNEL); in vx_alloc_pipe()
430 if (! pipe) { in vx_alloc_pipe()
431 /* release the pipe */ in vx_alloc_pipe()
438 /* the pipe index should be identical with the audio index */ in vx_alloc_pipe()
439 pipe->number = audioid; in vx_alloc_pipe()
440 pipe->is_capture = capture; in vx_alloc_pipe()
441 pipe->channels = num_audio; in vx_alloc_pipe()
442 pipe->differed_type = 0; in vx_alloc_pipe()
443 pipe->pcx_time = 0; in vx_alloc_pipe()
444 pipe->data_mode = data_mode; in vx_alloc_pipe()
445 *pipep = pipe; in vx_alloc_pipe()
452 * vx_free_pipe - release a pipe
453 * @pipe: pipe to be released
455 static int vx_free_pipe(struct vx_core *chip, struct vx_pipe *pipe) in vx_free_pipe() argument
460 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_free_pipe()
463 kfree(pipe); in vx_free_pipe()
473 static int vx_start_stream(struct vx_core *chip, struct vx_pipe *pipe) in vx_start_stream() argument
478 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number); in vx_start_stream()
479 vx_set_differed_time(chip, &rmh, pipe); in vx_start_stream()
489 static int vx_stop_stream(struct vx_core *chip, struct vx_pipe *pipe) in vx_stop_stream() argument
494 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number); in vx_stop_stream()
530 struct vx_pipe *pipe = NULL; in vx_pcm_playback_open() local
541 /* playback pipe may have been already allocated for monitoring */ in vx_pcm_playback_open()
542 pipe = chip->playback_pipes[audio]; in vx_pcm_playback_open()
543 if (! pipe) { in vx_pcm_playback_open()
545 err = vx_alloc_pipe(chip, 0, audio, 2, &pipe); /* stereo playback */ in vx_pcm_playback_open()
548 chip->playback_pipes[audio] = pipe; in vx_pcm_playback_open()
551 pipe->references++; in vx_pcm_playback_open()
553 pipe->substream = subs; in vx_pcm_playback_open()
554 chip->playback_pipes[audio] = pipe; in vx_pcm_playback_open()
558 runtime->private_data = pipe; in vx_pcm_playback_open()
573 struct vx_pipe *pipe; in vx_pcm_playback_close() local
578 pipe = subs->runtime->private_data; in vx_pcm_playback_close()
580 if (--pipe->references == 0) { in vx_pcm_playback_close()
581 chip->playback_pipes[pipe->number] = NULL; in vx_pcm_playback_close()
582 vx_free_pipe(chip, pipe); in vx_pcm_playback_close()
591 * vx_notify_end_of_buffer - send "end-of-buffer" notifier at the given pipe
592 * @pipe: the pipe to notify
596 static int vx_notify_end_of_buffer(struct vx_core *chip, struct vx_pipe *pipe) in vx_notify_end_of_buffer() argument
604 vx_set_stream_cmd_params(&rmh, 0, pipe->number); in vx_notify_end_of_buffer()
616 * @pipe: the pipe to transfer
626 struct vx_pipe *pipe, int size) in vx_pcm_playback_transfer_chunk() argument
630 space = vx_query_hbuffer_size(chip, pipe); in vx_pcm_playback_transfer_chunk()
647 vx_pseudo_dma_write(chip, runtime, pipe, size); in vx_pcm_playback_transfer_chunk()
648 err = vx_notify_end_of_buffer(chip, pipe); in vx_pcm_playback_transfer_chunk()
656 * update the position of the given pipe.
657 * pipe->position is updated and wrapped within the buffer size.
658 * pipe->transferred is updated, too, but the size is not wrapped,
664 struct vx_pipe *pipe) in vx_update_pipe_position() argument
671 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_update_pipe_position()
677 update = (int)(count - pipe->cur_count); in vx_update_pipe_position()
678 pipe->cur_count = count; in vx_update_pipe_position()
679 pipe->position += update; in vx_update_pipe_position()
680 if (pipe->position >= (int)runtime->buffer_size) in vx_update_pipe_position()
681 pipe->position %= runtime->buffer_size; in vx_update_pipe_position()
682 pipe->transferred += update; in vx_update_pipe_position()
692 struct vx_pipe *pipe, int nchunks) in vx_pcm_playback_transfer() argument
697 if (! pipe->prepared || (chip->chip_status & VX_STAT_IS_STALE)) in vx_pcm_playback_transfer()
700 if ((err = vx_pcm_playback_transfer_chunk(chip, runtime, pipe, in vx_pcm_playback_transfer()
712 struct vx_pipe *pipe) in vx_pcm_playback_update() argument
717 if (pipe->running && ! (chip->chip_status & VX_STAT_IS_STALE)) { in vx_pcm_playback_update()
718 if ((err = vx_update_pipe_position(chip, runtime, pipe)) < 0) in vx_pcm_playback_update()
720 if (pipe->transferred >= (int)runtime->period_size) { in vx_pcm_playback_update()
721 pipe->transferred %= runtime->period_size; in vx_pcm_playback_update()
733 struct vx_pipe *pipe = subs->runtime->private_data; in vx_pcm_trigger() local
742 if (! pipe->is_capture) in vx_pcm_trigger()
743 vx_pcm_playback_transfer(chip, subs, pipe, 2); in vx_pcm_trigger()
744 err = vx_start_stream(chip, pipe); in vx_pcm_trigger()
749 err = vx_toggle_pipe(chip, pipe, 1); in vx_pcm_trigger()
751 pr_debug("vx: cannot start pipe\n"); in vx_pcm_trigger()
752 vx_stop_stream(chip, pipe); in vx_pcm_trigger()
756 pipe->running = 1; in vx_pcm_trigger()
760 vx_toggle_pipe(chip, pipe, 0); in vx_pcm_trigger()
761 vx_stop_pipe(chip, pipe); in vx_pcm_trigger()
762 vx_stop_stream(chip, pipe); in vx_pcm_trigger()
764 pipe->running = 0; in vx_pcm_trigger()
767 if ((err = vx_toggle_pipe(chip, pipe, 0)) < 0) in vx_pcm_trigger()
771 if ((err = vx_toggle_pipe(chip, pipe, 1)) < 0) in vx_pcm_trigger()
786 struct vx_pipe *pipe = runtime->private_data; in vx_pcm_playback_pointer() local
787 return pipe->position; in vx_pcm_playback_pointer()
815 struct vx_pipe *pipe = runtime->private_data; in vx_pcm_prepare() local
823 if (data_mode != pipe->data_mode && ! pipe->is_capture) { in vx_pcm_prepare()
825 /* we reopen the pipe */ in vx_pcm_prepare()
827 snd_printdd(KERN_DEBUG "reopen the pipe with data_mode = %d\n", data_mode); in vx_pcm_prepare()
829 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, 0); in vx_pcm_prepare()
833 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, pipe->channels); in vx_pcm_prepare()
838 pipe->data_mode = data_mode; in vx_pcm_prepare()
848 if ((err = vx_set_format(chip, pipe, runtime)) < 0) in vx_pcm_prepare()
852 pipe->align = 2; /* 16bit word */ in vx_pcm_prepare()
854 pipe->align = 4; /* 32bit word */ in vx_pcm_prepare()
857 pipe->buffer_bytes = frames_to_bytes(runtime, runtime->buffer_size); in vx_pcm_prepare()
858 pipe->period_bytes = frames_to_bytes(runtime, runtime->period_size); in vx_pcm_prepare()
859 pipe->hw_ptr = 0; in vx_pcm_prepare()
862 vx_update_pipe_position(chip, runtime, pipe); in vx_pcm_prepare()
864 pipe->transferred = 0; in vx_pcm_prepare()
865 pipe->position = 0; in vx_pcm_prepare()
867 pipe->prepared = 1; in vx_pcm_prepare()
920 struct vx_pipe *pipe; in vx_pcm_capture_open() local
931 err = vx_alloc_pipe(chip, 1, audio, 2, &pipe); in vx_pcm_capture_open()
934 pipe->substream = subs; in vx_pcm_capture_open()
935 chip->capture_pipes[audio] = pipe; in vx_pcm_capture_open()
941 /* allocate a pipe */ in vx_pcm_capture_open()
949 if an output pipe is available, it's audios still may need to be in vx_pcm_capture_open()
959 pipe->monitoring_pipe = pipe_out_monitoring; /* default value NULL */ in vx_pcm_capture_open()
963 runtime->private_data = pipe; in vx_pcm_capture_open()
978 struct vx_pipe *pipe; in vx_pcm_capture_close() local
983 pipe = subs->runtime->private_data; in vx_pcm_capture_close()
984 chip->capture_pipes[pipe->number] = NULL; in vx_pcm_capture_close()
986 pipe_out_monitoring = pipe->monitoring_pipe; in vx_pcm_capture_close()
989 if an output pipe is attached to this input, in vx_pcm_capture_close()
995 chip->playback_pipes[pipe->number] = NULL; in vx_pcm_capture_close()
996 pipe->monitoring_pipe = NULL; in vx_pcm_capture_close()
1000 vx_free_pipe(chip, pipe); in vx_pcm_capture_close()
1012 struct vx_pipe *pipe) in vx_pcm_capture_update() argument
1017 if (!pipe->running || (chip->chip_status & VX_STAT_IS_STALE)) in vx_pcm_capture_update()
1024 space = vx_query_hbuffer_size(chip, pipe); in vx_pcm_capture_update()
1039 if ((pipe->hw_ptr % pipe->align) == 0) in vx_pcm_capture_update()
1043 vx_pcm_read_per_bytes(chip, runtime, pipe); in vx_pcm_capture_update()
1048 int align = pipe->align * 3; in vx_pcm_capture_update()
1051 vx_pseudo_dma_read(chip, runtime, pipe, space); in vx_pcm_capture_update()
1059 vx_pcm_read_per_bytes(chip, runtime, pipe); in vx_pcm_capture_update()
1067 vx_pcm_read_per_bytes(chip, runtime, pipe); in vx_pcm_capture_update()
1071 pipe->transferred += size; in vx_pcm_capture_update()
1072 if (pipe->transferred >= pipe->period_bytes) { in vx_pcm_capture_update()
1073 pipe->transferred %= pipe->period_bytes; in vx_pcm_capture_update()
1090 struct vx_pipe *pipe = runtime->private_data; in vx_pcm_capture_pointer() local
1091 return bytes_to_frames(runtime, pipe->hw_ptr); in vx_pcm_capture_pointer()
1116 struct vx_pipe *pipe; in vx_pcm_update_intr() local
1151 pipe = chip->playback_pipes[p]; in vx_pcm_update_intr()
1152 if (pipe && pipe->substream) { in vx_pcm_update_intr()
1153 vx_pcm_playback_update(chip, pipe->substream, pipe); in vx_pcm_update_intr()
1154 vx_pcm_playback_transfer(chip, pipe->substream, pipe, buf); in vx_pcm_update_intr()
1161 pipe = chip->capture_pipes[i]; in vx_pcm_update_intr()
1162 if (pipe && pipe->substream) in vx_pcm_update_intr()
1163 vx_pcm_capture_update(chip, pipe->substream, pipe); in vx_pcm_update_intr()
1169 * vx_init_audio_io - check the available audio i/o and allocate pipe arrays