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 if ((err = vx_conf_pipe(chip, pipe)) < 0)
352 * Check one pipe only (since they are synchronous)
355 err = vx_get_pipe_state(chip, pipe, &cur_state);
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)
375 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
381 * vx_alloc_pipe - allocate a pipe and initialize the pipe instance
385 * @pipep: the returned pipe instance
394 struct vx_pipe *pipe;
412 /* initialize the pipe record */
413 pipe = kzalloc(sizeof(*pipe), GFP_KERNEL);
414 if (! pipe) {
415 /* release the pipe */
422 /* the pipe index should be identical with the audio index */
423 pipe->number = audioid;
424 pipe->is_capture = capture;
425 pipe->channels = num_audio;
426 pipe->differed_type = 0;
427 pipe->pcx_time = 0;
428 pipe->data_mode = data_mode;
429 *pipep = 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)
444 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
447 kfree(pipe);
457 static int vx_start_stream(struct vx_core *chip, struct vx_pipe *pipe)
462 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number);
463 vx_set_differed_time(chip, &rmh, pipe);
473 static int vx_stop_stream(struct vx_core *chip, struct vx_pipe *pipe)
478 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number);
514 struct vx_pipe *pipe = NULL;
525 /* playback pipe may have been already allocated for monitoring */
526 pipe = chip->playback_pipes[audio];
527 if (! pipe) {
529 err = vx_alloc_pipe(chip, 0, audio, 2, &pipe); /* stereo playback */
534 pipe->references++;
536 pipe->substream = subs;
537 chip->playback_pipes[audio] = pipe;
541 runtime->private_data = pipe;
556 struct vx_pipe *pipe;
561 pipe = subs->runtime->private_data;
563 if (--pipe->references == 0) {
564 chip->playback_pipes[pipe->number] = NULL;
565 vx_free_pipe(chip, pipe);
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)
587 vx_set_stream_cmd_params(&rmh, 0, pipe->number);
599 * @pipe: the pipe to transfer
609 struct vx_pipe *pipe, int size)
613 space = vx_query_hbuffer_size(chip, pipe);
630 vx_pseudo_dma_write(chip, runtime, pipe, size);
631 err = vx_notify_end_of_buffer(chip, pipe);
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)
654 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
660 update = (int)(count - pipe->cur_count);
661 pipe->cur_count = count;
662 pipe->position += update;
663 if (pipe->position >= (int)runtime->buffer_size)
664 pipe->position %= runtime->buffer_size;
665 pipe->transferred += update;
675 struct vx_pipe *pipe, int nchunks)
680 if (! pipe->prepared || (chip->chip_status & VX_STAT_IS_STALE))
683 if ((err = vx_pcm_playback_transfer_chunk(chip, runtime, pipe,
695 struct vx_pipe *pipe)
700 if (pipe->running && ! (chip->chip_status & VX_STAT_IS_STALE)) {
701 if ((err = vx_update_pipe_position(chip, runtime, pipe)) < 0)
703 if (pipe->transferred >= (int)runtime->period_size) {
704 pipe->transferred %= runtime->period_size;
716 struct vx_pipe *pipe = subs->runtime->private_data;
725 if (! pipe->is_capture)
726 vx_pcm_playback_transfer(chip, subs, pipe, 2);
727 err = vx_start_stream(chip, pipe);
732 err = vx_toggle_pipe(chip, pipe, 1);
734 pr_debug("vx: cannot start pipe\n");
735 vx_stop_stream(chip, pipe);
739 pipe->running = 1;
743 vx_toggle_pipe(chip, pipe, 0);
744 vx_stop_pipe(chip, pipe);
745 vx_stop_stream(chip, pipe);
747 pipe->running = 0;
750 if ((err = vx_toggle_pipe(chip, pipe, 0)) < 0)
754 if ((err = vx_toggle_pipe(chip, pipe, 1)) < 0)
769 struct vx_pipe *pipe = runtime->private_data;
770 return pipe->position;
780 struct vx_pipe *pipe = runtime->private_data;
788 if (data_mode != pipe->data_mode && ! pipe->is_capture) {
790 /* we reopen the pipe */
792 snd_printdd(KERN_DEBUG "reopen the pipe with data_mode = %d\n", data_mode);
794 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, 0);
798 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, pipe->channels);
803 pipe->data_mode = data_mode;
813 if ((err = vx_set_format(chip, pipe, runtime)) < 0)
817 pipe->align = 2; /* 16bit word */
819 pipe->align = 4; /* 32bit word */
822 pipe->buffer_bytes = frames_to_bytes(runtime, runtime->buffer_size);
823 pipe->period_bytes = frames_to_bytes(runtime, runtime->period_size);
824 pipe->hw_ptr = 0;
827 vx_update_pipe_position(chip, runtime, pipe);
829 pipe->transferred = 0;
830 pipe->position = 0;
832 pipe->prepared = 1;
881 struct vx_pipe *pipe;
892 err = vx_alloc_pipe(chip, 1, audio, 2, &pipe);
895 pipe->substream = subs;
896 chip->capture_pipes[audio] = pipe;
902 /* allocate a pipe */
910 if an output pipe is available, it's audios still may need to be
920 pipe->monitoring_pipe = pipe_out_monitoring; /* default value NULL */
924 runtime->private_data = pipe;
939 struct vx_pipe *pipe;
944 pipe = subs->runtime->private_data;
945 chip->capture_pipes[pipe->number] = NULL;
947 pipe_out_monitoring = pipe->monitoring_pipe;
950 if an output pipe is attached to this input,
956 chip->playback_pipes[pipe->number] = NULL;
957 pipe->monitoring_pipe = NULL;
961 vx_free_pipe(chip, pipe);
973 struct vx_pipe *pipe)
978 if (!pipe->running || (chip->chip_status & VX_STAT_IS_STALE))
985 space = vx_query_hbuffer_size(chip, pipe);
1000 if ((pipe->hw_ptr % pipe->align) == 0)
1004 vx_pcm_read_per_bytes(chip, runtime, pipe);
1009 int align = pipe->align * 3;
1012 vx_pseudo_dma_read(chip, runtime, pipe, space);
1020 vx_pcm_read_per_bytes(chip, runtime, pipe);
1028 vx_pcm_read_per_bytes(chip, runtime, pipe);
1032 pipe->transferred += size;
1033 if (pipe->transferred >= pipe->period_bytes) {
1034 pipe->transferred %= pipe->period_bytes;
1051 struct vx_pipe *pipe = runtime->private_data;
1052 return bytes_to_frames(runtime, pipe->hw_ptr);
1073 struct vx_pipe *pipe;
1108 pipe = chip->playback_pipes[p];
1109 if (pipe && pipe->substream) {
1110 vx_pcm_playback_update(chip, pipe->substream, pipe);
1111 vx_pcm_playback_transfer(chip, pipe->substream, pipe, buf);
1118 pipe = chip->capture_pipes[i];
1119 if (pipe && pipe->substream)
1120 vx_pcm_capture_update(chip, pipe->substream, pipe);
1126 * vx_init_audio_io - check the available audio i/o and allocate pipe arrays