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)
48 int offset = pipe->hw_ptr;
51 if (++offset >= pipe->buffer_bytes) {
56 if (++offset >= pipe->buffer_bytes) {
61 if (++offset >= pipe->buffer_bytes) {
64 pipe->hw_ptr = offset;
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)
93 if (! (pipe->differed_type & DC_DIFFERED_DELAY))
100 vx_set_pcx_time(chip, &pipe->pcx_time, &rmh->Cmd[1]);
103 if (pipe->differed_type & DC_NOTIFY_DELAY)
107 if (pipe->differed_type & DC_MULTIPLE_DELAY)
111 if (pipe->differed_type & DC_STREAM_TIME_DELAY)
120 * @pipe: the affected pipe
123 static int vx_set_stream_format(struct vx_core *chip, struct vx_pipe *pipe,
128 vx_init_rmh(&rmh, pipe->is_capture ?
130 rmh.Cmd[0] |= pipe->number << FIELD_SIZE;
133 vx_set_differed_time(chip, &rmh, pipe);
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,
173 return vx_set_stream_format(chip, pipe, header);
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)
217 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
220 *state = (rmh.Stat[0] & (1 << pipe->number)) ? 1 : 0;
227 * @pipe: the pipe to be checked
236 static int vx_query_hbuffer_size(struct vx_core *chip, struct vx_pipe *pipe)
242 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
243 if (pipe->is_capture)
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)
266 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
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)
286 if (pipe->is_capture)
288 rmh.Cmd[1] = 1 << pipe->number;
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 toggled*/
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)
324 /* Check the pipe is not already in the requested state */
325 if (vx_get_pipe_state(chip, pipe, &cur_state) < 0)
332 * enough sound buffer for this pipe)
336 err = vx_pipe_can_start(chip, pipe);
346 err = vx_conf_pipe(chip, pipe);
356 * Check one pipe only (since they are synchronous)
359 err = vx_get_pipe_state(chip, pipe, &cur_state);
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)
379 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
385 * vx_alloc_pipe - allocate a pipe and initialize the pipe instance
389 * @pipep: the returned pipe instance
398 struct vx_pipe *pipe;
416 /* initialize the pipe record */
417 pipe = kzalloc(sizeof(*pipe), GFP_KERNEL);
418 if (! pipe) {
419 /* release the pipe */
426 /* the pipe index should be identical with the audio index */
427 pipe->number = audioid;
428 pipe->is_capture = capture;
429 pipe->channels = num_audio;
430 pipe->differed_type = 0;
431 pipe->pcx_time = 0;
432 pipe->data_mode = data_mode;
433 *pipep = 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)
448 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
451 kfree(pipe);
461 static int vx_start_stream(struct vx_core *chip, struct vx_pipe *pipe)
466 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number);
467 vx_set_differed_time(chip, &rmh, pipe);
477 static int vx_stop_stream(struct vx_core *chip, struct vx_pipe *pipe)
482 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number);
518 struct vx_pipe *pipe = NULL;
529 /* playback pipe may have been already allocated for monitoring */
530 pipe = chip->playback_pipes[audio];
531 if (! pipe) {
533 err = vx_alloc_pipe(chip, 0, audio, 2, &pipe); /* stereo playback */
538 pipe->references++;
540 pipe->substream = subs;
541 chip->playback_pipes[audio] = pipe;
545 runtime->private_data = pipe;
560 struct vx_pipe *pipe;
565 pipe = subs->runtime->private_data;
567 if (--pipe->references == 0) {
568 chip->playback_pipes[pipe->number] = NULL;
569 vx_free_pipe(chip, pipe);
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)
591 vx_set_stream_cmd_params(&rmh, 0, pipe->number);
603 * @pipe: the pipe to transfer
613 struct vx_pipe *pipe, int size)
617 space = vx_query_hbuffer_size(chip, pipe);
634 vx_pseudo_dma_write(chip, runtime, pipe, size);
635 err = vx_notify_end_of_buffer(chip, pipe);
642 * update the position of the given pipe.
643 * pipe->position is updated and wrapped within the buffer size.
644 * pipe->transferred is updated, too, but the size is not wrapped,
650 struct vx_pipe *pipe)
657 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
663 update = (int)(count - pipe->cur_count);
664 pipe->cur_count = count;
665 pipe->position += update;
666 if (pipe->position >= (int)runtime->buffer_size)
667 pipe->position %= runtime->buffer_size;
668 pipe->transferred += update;
678 struct vx_pipe *pipe, int nchunks)
683 if (! pipe->prepared || (chip->chip_status & VX_STAT_IS_STALE))
686 err = vx_pcm_playback_transfer_chunk(chip, runtime, pipe,
699 struct vx_pipe *pipe)
704 if (pipe->running && ! (chip->chip_status & VX_STAT_IS_STALE)) {
705 err = vx_update_pipe_position(chip, runtime, pipe);
708 if (pipe->transferred >= (int)runtime->period_size) {
709 pipe->transferred %= runtime->period_size;
721 struct vx_pipe *pipe = subs->runtime->private_data;
730 if (! pipe->is_capture)
731 vx_pcm_playback_transfer(chip, subs, pipe, 2);
732 err = vx_start_stream(chip, pipe);
737 err = vx_toggle_pipe(chip, pipe, 1);
739 pr_debug("vx: cannot start pipe\n");
740 vx_stop_stream(chip, pipe);
744 pipe->running = 1;
748 vx_toggle_pipe(chip, pipe, 0);
749 vx_stop_pipe(chip, pipe);
750 vx_stop_stream(chip, pipe);
752 pipe->running = 0;
755 err = vx_toggle_pipe(chip, pipe, 0);
760 err = vx_toggle_pipe(chip, pipe, 1);
776 struct vx_pipe *pipe = runtime->private_data;
777 return pipe->position;
787 struct vx_pipe *pipe = runtime->private_data;
795 if (data_mode != pipe->data_mode && ! pipe->is_capture) {
797 /* we reopen the pipe */
800 "reopen the pipe with data_mode = %d\n", data_mode);
802 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, 0);
807 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, pipe->channels);
813 pipe->data_mode = data_mode;
824 err = vx_set_format(chip, pipe, runtime);
829 pipe->align = 2; /* 16bit word */
831 pipe->align = 4; /* 32bit word */
834 pipe->buffer_bytes = frames_to_bytes(runtime, runtime->buffer_size);
835 pipe->period_bytes = frames_to_bytes(runtime, runtime->period_size);
836 pipe->hw_ptr = 0;
839 vx_update_pipe_position(chip, runtime, pipe);
841 pipe->transferred = 0;
842 pipe->position = 0;
844 pipe->prepared = 1;
893 struct vx_pipe *pipe;
904 err = vx_alloc_pipe(chip, 1, audio, 2, &pipe);
907 pipe->substream = subs;
908 chip->capture_pipes[audio] = pipe;
914 /* allocate a pipe */
922 if an output pipe is available, it's audios still may need to be
932 pipe->monitoring_pipe = pipe_out_monitoring; /* default value NULL */
936 runtime->private_data = pipe;
951 struct vx_pipe *pipe;
956 pipe = subs->runtime->private_data;
957 chip->capture_pipes[pipe->number] = NULL;
959 pipe_out_monitoring = pipe->monitoring_pipe;
962 if an output pipe is attached to this input,
968 chip->playback_pipes[pipe->number] = NULL;
969 pipe->monitoring_pipe = NULL;
973 vx_free_pipe(chip, pipe);
985 struct vx_pipe *pipe)
990 if (!pipe->running || (chip->chip_status & VX_STAT_IS_STALE))
997 space = vx_query_hbuffer_size(chip, pipe);
1012 if ((pipe->hw_ptr % pipe->align) == 0)
1016 vx_pcm_read_per_bytes(chip, runtime, pipe);
1021 int align = pipe->align * 3;
1024 vx_pseudo_dma_read(chip, runtime, pipe, space);
1032 vx_pcm_read_per_bytes(chip, runtime, pipe);
1040 vx_pcm_read_per_bytes(chip, runtime, pipe);
1044 pipe->transferred += size;
1045 if (pipe->transferred >= pipe->period_bytes) {
1046 pipe->transferred %= pipe->period_bytes;
1063 struct vx_pipe *pipe = runtime->private_data;
1064 return bytes_to_frames(runtime, pipe->hw_ptr);
1085 struct vx_pipe *pipe;
1120 pipe = chip->playback_pipes[p];
1121 if (pipe && pipe->substream) {
1122 vx_pcm_playback_update(chip, pipe->substream, pipe);
1123 vx_pcm_playback_transfer(chip, pipe->substream, pipe, buf);
1130 pipe = chip->capture_pipes[i];
1131 if (pipe && pipe->substream)
1132 vx_pcm_capture_update(chip, pipe->substream, pipe);
1138 * vx_init_audio_io - check the available audio i/o and allocate pipe arrays