Lines Matching refs:pipe
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()
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()
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()
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()
209 static int vx_get_pipe_state(struct vx_core *chip, struct vx_pipe *pipe, int *state) in vx_get_pipe_state() argument
215 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_get_pipe_state()
218 *state = (rmh.Stat[0] & (1 << pipe->number)) ? 1 : 0; in vx_get_pipe_state()
234 static int vx_query_hbuffer_size(struct vx_core *chip, struct vx_pipe *pipe) in vx_query_hbuffer_size() argument
240 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_query_hbuffer_size()
241 if (pipe->is_capture) in vx_query_hbuffer_size()
258 static int vx_pipe_can_start(struct vx_core *chip, struct vx_pipe *pipe) in vx_pipe_can_start() argument
264 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_pipe_can_start()
279 static int vx_conf_pipe(struct vx_core *chip, struct vx_pipe *pipe) in vx_conf_pipe() argument
284 if (pipe->is_capture) in vx_conf_pipe()
286 rmh.Cmd[1] = 1 << pipe->number; in vx_conf_pipe()
318 static int vx_toggle_pipe(struct vx_core *chip, struct vx_pipe *pipe, int state) in vx_toggle_pipe() argument
323 if (vx_get_pipe_state(chip, pipe, &cur_state) < 0) in vx_toggle_pipe()
334 err = vx_pipe_can_start(chip, pipe); in vx_toggle_pipe()
344 err = vx_conf_pipe(chip, pipe); in vx_toggle_pipe()
357 err = vx_get_pipe_state(chip, pipe, &cur_state); in vx_toggle_pipe()
373 static int vx_stop_pipe(struct vx_core *chip, struct vx_pipe *pipe) in vx_stop_pipe() argument
377 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_stop_pipe()
396 struct vx_pipe *pipe; in vx_alloc_pipe() local
415 pipe = kzalloc(sizeof(*pipe), GFP_KERNEL); in vx_alloc_pipe()
416 if (! pipe) { in vx_alloc_pipe()
425 pipe->number = audioid; in vx_alloc_pipe()
426 pipe->is_capture = capture; in vx_alloc_pipe()
427 pipe->channels = num_audio; in vx_alloc_pipe()
428 pipe->differed_type = 0; in vx_alloc_pipe()
429 pipe->pcx_time = 0; in vx_alloc_pipe()
430 pipe->data_mode = data_mode; in vx_alloc_pipe()
431 *pipep = pipe; in vx_alloc_pipe()
441 static int vx_free_pipe(struct vx_core *chip, struct vx_pipe *pipe) in vx_free_pipe() argument
446 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_free_pipe()
449 kfree(pipe); in vx_free_pipe()
459 static int vx_start_stream(struct vx_core *chip, struct vx_pipe *pipe) in vx_start_stream() argument
464 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number); in vx_start_stream()
465 vx_set_differed_time(chip, &rmh, pipe); in vx_start_stream()
475 static int vx_stop_stream(struct vx_core *chip, struct vx_pipe *pipe) in vx_stop_stream() argument
480 vx_set_stream_cmd_params(&rmh, pipe->is_capture, pipe->number); in vx_stop_stream()
516 struct vx_pipe *pipe = NULL; in vx_pcm_playback_open() local
528 pipe = chip->playback_pipes[audio]; in vx_pcm_playback_open()
529 if (! pipe) { in vx_pcm_playback_open()
531 err = vx_alloc_pipe(chip, 0, audio, 2, &pipe); /* stereo playback */ in vx_pcm_playback_open()
536 pipe->references++; in vx_pcm_playback_open()
538 pipe->substream = subs; in vx_pcm_playback_open()
539 chip->playback_pipes[audio] = pipe; in vx_pcm_playback_open()
543 runtime->private_data = pipe; in vx_pcm_playback_open()
558 struct vx_pipe *pipe; in vx_pcm_playback_close() local
563 pipe = subs->runtime->private_data; in vx_pcm_playback_close()
565 if (--pipe->references == 0) { in vx_pcm_playback_close()
566 chip->playback_pipes[pipe->number] = NULL; in vx_pcm_playback_close()
567 vx_free_pipe(chip, pipe); in vx_pcm_playback_close()
581 static int vx_notify_end_of_buffer(struct vx_core *chip, struct vx_pipe *pipe) in vx_notify_end_of_buffer() argument
589 vx_set_stream_cmd_params(&rmh, 0, pipe->number); in vx_notify_end_of_buffer()
611 struct vx_pipe *pipe, int size) in vx_pcm_playback_transfer_chunk() argument
615 space = vx_query_hbuffer_size(chip, pipe); in vx_pcm_playback_transfer_chunk()
632 vx_pseudo_dma_write(chip, runtime, pipe, size); in vx_pcm_playback_transfer_chunk()
633 err = vx_notify_end_of_buffer(chip, pipe); in vx_pcm_playback_transfer_chunk()
649 struct vx_pipe *pipe) in vx_update_pipe_position() argument
656 vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0); in vx_update_pipe_position()
662 update = (int)(count - pipe->cur_count); in vx_update_pipe_position()
663 pipe->cur_count = count; in vx_update_pipe_position()
664 pipe->position += update; in vx_update_pipe_position()
665 if (pipe->position >= (int)runtime->buffer_size) in vx_update_pipe_position()
666 pipe->position %= runtime->buffer_size; in vx_update_pipe_position()
667 pipe->transferred += update; in vx_update_pipe_position()
677 struct vx_pipe *pipe, int nchunks) in vx_pcm_playback_transfer() argument
682 if (! pipe->prepared || (chip->chip_status & VX_STAT_IS_STALE)) in vx_pcm_playback_transfer()
685 err = vx_pcm_playback_transfer_chunk(chip, runtime, pipe, in vx_pcm_playback_transfer()
698 struct vx_pipe *pipe) in vx_pcm_playback_update() argument
703 if (pipe->running && ! (chip->chip_status & VX_STAT_IS_STALE)) { in vx_pcm_playback_update()
704 err = vx_update_pipe_position(chip, runtime, pipe); in vx_pcm_playback_update()
707 if (pipe->transferred >= (int)runtime->period_size) { in vx_pcm_playback_update()
708 pipe->transferred %= runtime->period_size; in vx_pcm_playback_update()
720 struct vx_pipe *pipe = subs->runtime->private_data; in vx_pcm_trigger() local
729 if (! pipe->is_capture) in vx_pcm_trigger()
730 vx_pcm_playback_transfer(chip, subs, pipe, 2); in vx_pcm_trigger()
731 err = vx_start_stream(chip, pipe); in vx_pcm_trigger()
736 err = vx_toggle_pipe(chip, pipe, 1); in vx_pcm_trigger()
739 vx_stop_stream(chip, pipe); in vx_pcm_trigger()
743 pipe->running = 1; in vx_pcm_trigger()
747 vx_toggle_pipe(chip, pipe, 0); in vx_pcm_trigger()
748 vx_stop_pipe(chip, pipe); in vx_pcm_trigger()
749 vx_stop_stream(chip, pipe); in vx_pcm_trigger()
751 pipe->running = 0; in vx_pcm_trigger()
754 err = vx_toggle_pipe(chip, pipe, 0); in vx_pcm_trigger()
759 err = vx_toggle_pipe(chip, pipe, 1); in vx_pcm_trigger()
775 struct vx_pipe *pipe = runtime->private_data; in vx_pcm_playback_pointer() local
776 return pipe->position; in vx_pcm_playback_pointer()
786 struct vx_pipe *pipe = runtime->private_data; in vx_pcm_prepare() local
794 if (data_mode != pipe->data_mode && ! pipe->is_capture) { in vx_pcm_prepare()
800 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, 0); in vx_pcm_prepare()
805 vx_set_pipe_cmd_params(&rmh, 0, pipe->number, pipe->channels); in vx_pcm_prepare()
811 pipe->data_mode = data_mode; in vx_pcm_prepare()
821 err = vx_set_format(chip, pipe, runtime); in vx_pcm_prepare()
826 pipe->align = 2; /* 16bit word */ in vx_pcm_prepare()
828 pipe->align = 4; /* 32bit word */ in vx_pcm_prepare()
831 pipe->buffer_bytes = frames_to_bytes(runtime, runtime->buffer_size); in vx_pcm_prepare()
832 pipe->period_bytes = frames_to_bytes(runtime, runtime->period_size); in vx_pcm_prepare()
833 pipe->hw_ptr = 0; in vx_pcm_prepare()
836 vx_update_pipe_position(chip, runtime, pipe); in vx_pcm_prepare()
838 pipe->transferred = 0; in vx_pcm_prepare()
839 pipe->position = 0; in vx_pcm_prepare()
841 pipe->prepared = 1; in vx_pcm_prepare()
890 struct vx_pipe *pipe; in vx_pcm_capture_open() local
901 err = vx_alloc_pipe(chip, 1, audio, 2, &pipe); in vx_pcm_capture_open()
904 pipe->substream = subs; in vx_pcm_capture_open()
905 chip->capture_pipes[audio] = pipe; in vx_pcm_capture_open()
929 pipe->monitoring_pipe = pipe_out_monitoring; /* default value NULL */ in vx_pcm_capture_open()
933 runtime->private_data = pipe; in vx_pcm_capture_open()
948 struct vx_pipe *pipe; in vx_pcm_capture_close() local
953 pipe = subs->runtime->private_data; in vx_pcm_capture_close()
954 chip->capture_pipes[pipe->number] = NULL; in vx_pcm_capture_close()
956 pipe_out_monitoring = pipe->monitoring_pipe; in vx_pcm_capture_close()
965 chip->playback_pipes[pipe->number] = NULL; in vx_pcm_capture_close()
966 pipe->monitoring_pipe = NULL; in vx_pcm_capture_close()
970 vx_free_pipe(chip, pipe); in vx_pcm_capture_close()
982 struct vx_pipe *pipe) in vx_pcm_capture_update() argument
987 if (!pipe->running || (chip->chip_status & VX_STAT_IS_STALE)) in vx_pcm_capture_update()
994 space = vx_query_hbuffer_size(chip, pipe); in vx_pcm_capture_update()
1009 if ((pipe->hw_ptr % pipe->align) == 0) in vx_pcm_capture_update()
1013 vx_pcm_read_per_bytes(chip, runtime, pipe); in vx_pcm_capture_update()
1018 int align = pipe->align * 3; in vx_pcm_capture_update()
1021 vx_pseudo_dma_read(chip, runtime, pipe, space); in vx_pcm_capture_update()
1029 vx_pcm_read_per_bytes(chip, runtime, pipe); in vx_pcm_capture_update()
1037 vx_pcm_read_per_bytes(chip, runtime, pipe); in vx_pcm_capture_update()
1041 pipe->transferred += size; in vx_pcm_capture_update()
1042 if (pipe->transferred >= pipe->period_bytes) { in vx_pcm_capture_update()
1043 pipe->transferred %= pipe->period_bytes; in vx_pcm_capture_update()
1060 struct vx_pipe *pipe = runtime->private_data; in vx_pcm_capture_pointer() local
1061 return bytes_to_frames(runtime, pipe->hw_ptr); in vx_pcm_capture_pointer()
1082 struct vx_pipe *pipe; in vx_pcm_update_intr() local
1117 pipe = chip->playback_pipes[p]; in vx_pcm_update_intr()
1118 if (pipe && pipe->substream) { in vx_pcm_update_intr()
1119 vx_pcm_playback_update(chip, pipe->substream, pipe); in vx_pcm_update_intr()
1120 vx_pcm_playback_transfer(chip, pipe->substream, pipe, buf); in vx_pcm_update_intr()
1127 pipe = chip->capture_pipes[i]; in vx_pcm_update_intr()
1128 if (pipe && pipe->substream) in vx_pcm_update_intr()
1129 vx_pcm_capture_update(chip, pipe->substream, pipe); in vx_pcm_update_intr()