Lines Matching refs: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);
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)
215 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
218 *state = (rmh.Stat[0] & (1 << pipe->number)) ? 1 : 0;
225 * @pipe: the pipe to be checked
234 static int vx_query_hbuffer_size(struct vx_core *chip, struct vx_pipe *pipe)
240 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
241 if (pipe->is_capture)
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)
264 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
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)
284 if (pipe->is_capture)
286 rmh.Cmd[1] = 1 << pipe->number;
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 toggled*/
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)
322 /* Check the pipe is not already in the requested state */
323 if (vx_get_pipe_state(chip, pipe, &cur_state) < 0)
330 * enough sound buffer for this pipe)
334 err = vx_pipe_can_start(chip, pipe);
344 err = vx_conf_pipe(chip, pipe);
354 * Check one pipe only (since they are synchronous)
357 err = vx_get_pipe_state(chip, pipe, &cur_state);
368 * vx_stop_pipe - stop a pipe
369 * @pipe: the pipe to be stopped
373 static int vx_stop_pipe(struct vx_core *chip, struct vx_pipe *pipe)
377 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
383 * vx_alloc_pipe - allocate a pipe and initialize the pipe instance
387 * @pipep: the returned pipe instance
396 struct vx_pipe *pipe;
414 /* initialize the pipe record */
415 pipe = kzalloc(sizeof(*pipe), GFP_KERNEL);
416 if (! pipe) {
417 /* release the pipe */
424 /* the pipe index should be identical with the audio index */
425 pipe->number = audioid;
426 pipe->is_capture = capture;
427 pipe->channels = num_audio;
428 pipe->differed_type = 0;
429 pipe->pcx_time = 0;
430 pipe->data_mode = data_mode;
431 *pipep = pipe;
438 * vx_free_pipe - release a pipe
439 * @pipe: pipe to be released
441 static int vx_free_pipe(struct vx_core *chip, struct vx_pipe *pipe)
446 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
449 kfree(pipe);
459 static int vx_start_stream(struct vx_core *chip, struct vx_pipe *pipe)
464 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number);
465 vx_set_differed_time(chip, &rmh, pipe);
475 static int vx_stop_stream(struct vx_core *chip, struct vx_pipe *pipe)
480 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number);
516 struct vx_pipe *pipe = NULL;
527 /* playback pipe may have been already allocated for monitoring */
528 pipe = chip->playback_pipes[audio];
529 if (! pipe) {
531 err = vx_alloc_pipe(chip, 0, audio, 2, &pipe); /* stereo playback */
536 pipe->references++;
538 pipe->substream = subs;
539 chip->playback_pipes[audio] = pipe;
543 runtime->private_data = pipe;
558 struct vx_pipe *pipe;
563 pipe = subs->runtime->private_data;
565 if (--pipe->references == 0) {
566 chip->playback_pipes[pipe->number] = NULL;
567 vx_free_pipe(chip, pipe);
576 * vx_notify_end_of_buffer - send "end-of-buffer" notifier at the given pipe
577 * @pipe: the pipe to notify
581 static int vx_notify_end_of_buffer(struct vx_core *chip, struct vx_pipe *pipe)
589 vx_set_stream_cmd_params(&rmh, 0, pipe->number);
601 * @pipe: the pipe to transfer
611 struct vx_pipe *pipe, int size)
615 space = vx_query_hbuffer_size(chip, pipe);
632 vx_pseudo_dma_write(chip, runtime, pipe, size);
633 err = vx_notify_end_of_buffer(chip, pipe);
641 * update the position of the given pipe.
642 * pipe->position is updated and wrapped within the buffer size.
643 * pipe->transferred is updated, too, but the size is not wrapped,
649 struct vx_pipe *pipe)
656 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
662 update = (int)(count - pipe->cur_count);
663 pipe->cur_count = count;
664 pipe->position += update;
665 if (pipe->position >= (int)runtime->buffer_size)
666 pipe->position %= runtime->buffer_size;
667 pipe->transferred += update;
677 struct vx_pipe *pipe, int nchunks)
682 if (! pipe->prepared || (chip->chip_status & VX_STAT_IS_STALE))
685 err = vx_pcm_playback_transfer_chunk(chip, runtime, pipe,
698 struct vx_pipe *pipe)
703 if (pipe->running && ! (chip->chip_status & VX_STAT_IS_STALE)) {
704 err = vx_update_pipe_position(chip, runtime, pipe);
707 if (pipe->transferred >= (int)runtime->period_size) {
708 pipe->transferred %= runtime->period_size;
720 struct vx_pipe *pipe = subs->runtime->private_data;
729 if (! pipe->is_capture)
730 vx_pcm_playback_transfer(chip, subs, pipe, 2);
731 err = vx_start_stream(chip, pipe);
736 err = vx_toggle_pipe(chip, pipe, 1);
738 pr_debug("vx: cannot start pipe\n");
739 vx_stop_stream(chip, pipe);
743 pipe->running = 1;
747 vx_toggle_pipe(chip, pipe, 0);
748 vx_stop_pipe(chip, pipe);
749 vx_stop_stream(chip, pipe);
751 pipe->running = 0;
754 err = vx_toggle_pipe(chip, pipe, 0);
759 err = vx_toggle_pipe(chip, pipe, 1);
775 struct vx_pipe *pipe = runtime->private_data;
776 return pipe->position;
786 struct vx_pipe *pipe = runtime->private_data;
794 if (data_mode != pipe->data_mode && ! pipe->is_capture) {
796 /* we reopen the pipe */
798 snd_printdd(KERN_DEBUG "reopen the pipe with data_mode = %d\n", data_mode);
800 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, 0);
805 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, pipe->channels);
811 pipe->data_mode = data_mode;
821 err = vx_set_format(chip, pipe, runtime);
826 pipe->align = 2; /* 16bit word */
828 pipe->align = 4; /* 32bit word */
831 pipe->buffer_bytes = frames_to_bytes(runtime, runtime->buffer_size);
832 pipe->period_bytes = frames_to_bytes(runtime, runtime->period_size);
833 pipe->hw_ptr = 0;
836 vx_update_pipe_position(chip, runtime, pipe);
838 pipe->transferred = 0;
839 pipe->position = 0;
841 pipe->prepared = 1;
890 struct vx_pipe *pipe;
901 err = vx_alloc_pipe(chip, 1, audio, 2, &pipe);
904 pipe->substream = subs;
905 chip->capture_pipes[audio] = pipe;
911 /* allocate a pipe */
919 if an output pipe is available, it's audios still may need to be
929 pipe->monitoring_pipe = pipe_out_monitoring; /* default value NULL */
933 runtime->private_data = pipe;
948 struct vx_pipe *pipe;
953 pipe = subs->runtime->private_data;
954 chip->capture_pipes[pipe->number] = NULL;
956 pipe_out_monitoring = pipe->monitoring_pipe;
959 if an output pipe is attached to this input,
965 chip->playback_pipes[pipe->number] = NULL;
966 pipe->monitoring_pipe = NULL;
970 vx_free_pipe(chip, pipe);
982 struct vx_pipe *pipe)
987 if (!pipe->running || (chip->chip_status & VX_STAT_IS_STALE))
994 space = vx_query_hbuffer_size(chip, pipe);
1009 if ((pipe->hw_ptr % pipe->align) == 0)
1013 vx_pcm_read_per_bytes(chip, runtime, pipe);
1018 int align = pipe->align * 3;
1021 vx_pseudo_dma_read(chip, runtime, pipe, space);
1029 vx_pcm_read_per_bytes(chip, runtime, pipe);
1037 vx_pcm_read_per_bytes(chip, runtime, pipe);
1041 pipe->transferred += size;
1042 if (pipe->transferred >= pipe->period_bytes) {
1043 pipe->transferred %= pipe->period_bytes;
1060 struct vx_pipe *pipe = runtime->private_data;
1061 return bytes_to_frames(runtime, pipe->hw_ptr);
1082 struct vx_pipe *pipe;
1117 pipe = chip->playback_pipes[p];
1118 if (pipe && pipe->substream) {
1119 vx_pcm_playback_update(chip, pipe->substream, pipe);
1120 vx_pcm_playback_transfer(chip, pipe->substream, pipe, buf);
1127 pipe = chip->capture_pipes[i];
1128 if (pipe && pipe->substream)
1129 vx_pcm_capture_update(chip, pipe->substream, pipe);
1135 * vx_init_audio_io - check the available audio i/o and allocate pipe arrays