Lines Matching full:pipe
182 * @pipe: the pipeline
187 static void vsp1_video_calculate_partition(struct vsp1_pipeline *pipe, in vsp1_video_calculate_partition() argument
200 format = vsp1_entity_get_pad_format(&pipe->output->entity, in vsp1_video_calculate_partition()
201 pipe->output->entity.state, in vsp1_video_calculate_partition()
205 if (pipe->partitions <= 1) { in vsp1_video_calculate_partition()
209 vsp1_pipeline_propagate_partition(pipe, partition, index, in vsp1_video_calculate_partition()
231 * pipe->partitions is 1 based, whilst index is a 0 based index. in vsp1_video_calculate_partition()
234 unsigned int partitions = pipe->partitions - 1; in vsp1_video_calculate_partition()
250 vsp1_pipeline_propagate_partition(pipe, partition, index, &window); in vsp1_video_calculate_partition()
253 static int vsp1_video_pipeline_setup_partitions(struct vsp1_pipeline *pipe) in vsp1_video_pipeline_setup_partitions() argument
255 struct vsp1_device *vsp1 = pipe->output->entity.vsp1; in vsp1_video_pipeline_setup_partitions()
265 format = vsp1_entity_get_pad_format(&pipe->output->entity, in vsp1_video_pipeline_setup_partitions()
266 pipe->output->entity.state, in vsp1_video_pipeline_setup_partitions()
275 list_for_each_entry(entity, &pipe->entities, list_pipe) { in vsp1_video_pipeline_setup_partitions()
281 entity_max = entity->ops->max_width(entity, pipe); in vsp1_video_pipeline_setup_partitions()
287 pipe->partitions = DIV_ROUND_UP(format->width, div_size); in vsp1_video_pipeline_setup_partitions()
288 pipe->part_table = kcalloc(pipe->partitions, sizeof(*pipe->part_table), in vsp1_video_pipeline_setup_partitions()
290 if (!pipe->part_table) in vsp1_video_pipeline_setup_partitions()
293 for (i = 0; i < pipe->partitions; ++i) in vsp1_video_pipeline_setup_partitions()
294 vsp1_video_calculate_partition(pipe, &pipe->part_table[i], in vsp1_video_pipeline_setup_partitions()
316 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_complete_buffer() local
340 done->buf.sequence = pipe->sequence; in vsp1_video_complete_buffer()
350 static void vsp1_video_frame_end(struct vsp1_pipeline *pipe, in vsp1_video_frame_end() argument
361 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_frame_end()
364 static void vsp1_video_pipeline_run_partition(struct vsp1_pipeline *pipe, in vsp1_video_pipeline_run_partition() argument
371 pipe->partition = &pipe->part_table[partition]; in vsp1_video_pipeline_run_partition()
373 list_for_each_entry(entity, &pipe->entities, list_pipe) in vsp1_video_pipeline_run_partition()
374 vsp1_entity_configure_partition(entity, pipe, dl, dlb); in vsp1_video_pipeline_run_partition()
377 static void vsp1_video_pipeline_run(struct vsp1_pipeline *pipe) in vsp1_video_pipeline_run() argument
379 struct vsp1_device *vsp1 = pipe->output->entity.vsp1; in vsp1_video_pipeline_run()
385 dl = vsp1_dl_list_get(pipe->output->dlm); in vsp1_video_pipeline_run()
393 if (!pipe->configured) in vsp1_video_pipeline_run()
394 vsp1_dl_list_add_body(dl, pipe->stream_config); in vsp1_video_pipeline_run()
398 list_for_each_entry(entity, &pipe->entities, list_pipe) in vsp1_video_pipeline_run()
399 vsp1_entity_configure_frame(entity, pipe, dl, dlb); in vsp1_video_pipeline_run()
402 vsp1_video_pipeline_run_partition(pipe, dl, 0); in vsp1_video_pipeline_run()
405 for (partition = 1; partition < pipe->partitions; ++partition) { in vsp1_video_pipeline_run()
408 dl_next = vsp1_dl_list_get(pipe->output->dlm); in vsp1_video_pipeline_run()
420 vsp1_video_pipeline_run_partition(pipe, dl_next, partition); in vsp1_video_pipeline_run()
426 pipe->configured = true; in vsp1_video_pipeline_run()
428 vsp1_pipeline_run(pipe); in vsp1_video_pipeline_run()
431 static void vsp1_video_pipeline_frame_end(struct vsp1_pipeline *pipe, in vsp1_video_pipeline_frame_end() argument
434 struct vsp1_device *vsp1 = pipe->output->entity.vsp1; in vsp1_video_pipeline_frame_end()
442 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_pipeline_frame_end()
446 if (!pipe->inputs[i]) in vsp1_video_pipeline_frame_end()
449 vsp1_video_frame_end(pipe, pipe->inputs[i]); in vsp1_video_pipeline_frame_end()
452 vsp1_video_frame_end(pipe, pipe->output); in vsp1_video_pipeline_frame_end()
454 state = pipe->state; in vsp1_video_pipeline_frame_end()
455 pipe->state = VSP1_PIPELINE_STOPPED; in vsp1_video_pipeline_frame_end()
462 wake_up(&pipe->wq); in vsp1_video_pipeline_frame_end()
463 else if (vsp1_pipeline_ready(pipe)) in vsp1_video_pipeline_frame_end()
464 vsp1_video_pipeline_run(pipe); in vsp1_video_pipeline_frame_end()
466 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_pipeline_frame_end()
469 static int vsp1_video_pipeline_build_branch(struct vsp1_pipeline *pipe, in vsp1_video_pipeline_build_branch() argument
535 if (pipe->uds) { in vsp1_video_pipeline_build_branch()
540 pipe->uds = entity; in vsp1_video_pipeline_build_branch()
541 pipe->uds_input = brx ? &brx->entity : &input->entity; in vsp1_video_pipeline_build_branch()
559 static int vsp1_video_pipeline_build(struct vsp1_pipeline *pipe, in vsp1_video_pipeline_build() argument
585 list_add_tail(&e->list_pipe, &pipe->entities); in vsp1_video_pipeline_build()
586 e->pipe = pipe; in vsp1_video_pipeline_build()
591 pipe->inputs[rwpf->entity.index] = rwpf; in vsp1_video_pipeline_build()
592 rwpf->video->pipe_index = ++pipe->num_inputs; in vsp1_video_pipeline_build()
597 pipe->output = rwpf; in vsp1_video_pipeline_build()
602 pipe->lif = e; in vsp1_video_pipeline_build()
607 pipe->brx = e; in vsp1_video_pipeline_build()
611 pipe->hgo = e; in vsp1_video_pipeline_build()
615 pipe->hgt = e; in vsp1_video_pipeline_build()
626 if (pipe->num_inputs == 0 || !pipe->output) in vsp1_video_pipeline_build()
634 if (!pipe->inputs[i]) in vsp1_video_pipeline_build()
637 ret = vsp1_video_pipeline_build_branch(pipe, pipe->inputs[i], in vsp1_video_pipeline_build()
638 pipe->output); in vsp1_video_pipeline_build()
646 static int vsp1_video_pipeline_init(struct vsp1_pipeline *pipe, in vsp1_video_pipeline_init() argument
649 vsp1_pipeline_init(pipe); in vsp1_video_pipeline_init()
651 pipe->frame_end = vsp1_video_pipeline_frame_end; in vsp1_video_pipeline_init()
653 return vsp1_video_pipeline_build(pipe, video); in vsp1_video_pipeline_init()
658 struct vsp1_pipeline *pipe; in vsp1_video_pipeline_get() local
667 if (!video->rwpf->entity.pipe) { in vsp1_video_pipeline_get()
668 pipe = kzalloc(sizeof(*pipe), GFP_KERNEL); in vsp1_video_pipeline_get()
669 if (!pipe) in vsp1_video_pipeline_get()
672 ret = vsp1_video_pipeline_init(pipe, video); in vsp1_video_pipeline_get()
674 vsp1_pipeline_reset(pipe); in vsp1_video_pipeline_get()
675 kfree(pipe); in vsp1_video_pipeline_get()
679 pipe = video->rwpf->entity.pipe; in vsp1_video_pipeline_get()
680 kref_get(&pipe->kref); in vsp1_video_pipeline_get()
683 return pipe; in vsp1_video_pipeline_get()
688 struct vsp1_pipeline *pipe = container_of(kref, typeof(*pipe), kref); in vsp1_video_pipeline_release() local
690 vsp1_pipeline_reset(pipe); in vsp1_video_pipeline_release()
691 kfree(pipe); in vsp1_video_pipeline_release()
694 static void vsp1_video_pipeline_put(struct vsp1_pipeline *pipe) in vsp1_video_pipeline_put() argument
696 struct media_device *mdev = &pipe->output->entity.vsp1->media_dev; in vsp1_video_pipeline_put()
699 kref_put(&pipe->kref, vsp1_video_pipeline_release); in vsp1_video_pipeline_put()
762 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_buffer_queue() local
775 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_buffer_queue()
778 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_buffer_queue()
781 vsp1_pipeline_ready(pipe)) in vsp1_video_buffer_queue()
782 vsp1_video_pipeline_run(pipe); in vsp1_video_buffer_queue()
784 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_buffer_queue()
787 static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe) in vsp1_video_setup_pipeline() argument
793 ret = vsp1_video_pipeline_setup_partitions(pipe); in vsp1_video_setup_pipeline()
797 if (pipe->uds) { in vsp1_video_setup_pipeline()
798 struct vsp1_uds *uds = to_uds(&pipe->uds->subdev); in vsp1_video_setup_pipeline()
807 if (pipe->uds_input->type == VSP1_ENTITY_BRU || in vsp1_video_setup_pipeline()
808 pipe->uds_input->type == VSP1_ENTITY_BRS) { in vsp1_video_setup_pipeline()
812 to_rwpf(&pipe->uds_input->subdev); in vsp1_video_setup_pipeline()
823 pipe->stream_config = vsp1_dlm_dl_body_get(pipe->output->dlm); in vsp1_video_setup_pipeline()
824 if (!pipe->stream_config) in vsp1_video_setup_pipeline()
827 list_for_each_entry(entity, &pipe->entities, list_pipe) { in vsp1_video_setup_pipeline()
828 vsp1_entity_route_setup(entity, pipe, pipe->stream_config); in vsp1_video_setup_pipeline()
829 vsp1_entity_configure_stream(entity, pipe, NULL, in vsp1_video_setup_pipeline()
830 pipe->stream_config); in vsp1_video_setup_pipeline()
849 static void vsp1_video_cleanup_pipeline(struct vsp1_pipeline *pipe) in vsp1_video_cleanup_pipeline() argument
851 lockdep_assert_held(&pipe->lock); in vsp1_video_cleanup_pipeline()
854 vsp1_dl_body_put(pipe->stream_config); in vsp1_video_cleanup_pipeline()
855 pipe->stream_config = NULL; in vsp1_video_cleanup_pipeline()
856 pipe->configured = false; in vsp1_video_cleanup_pipeline()
859 kfree(pipe->part_table); in vsp1_video_cleanup_pipeline()
860 pipe->part_table = NULL; in vsp1_video_cleanup_pipeline()
866 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_start_streaming() local
871 mutex_lock(&pipe->lock); in vsp1_video_start_streaming()
872 if (pipe->stream_count == pipe->num_inputs) { in vsp1_video_start_streaming()
873 ret = vsp1_video_setup_pipeline(pipe); in vsp1_video_start_streaming()
876 vsp1_video_cleanup_pipeline(pipe); in vsp1_video_start_streaming()
877 mutex_unlock(&pipe->lock); in vsp1_video_start_streaming()
884 pipe->stream_count++; in vsp1_video_start_streaming()
885 mutex_unlock(&pipe->lock); in vsp1_video_start_streaming()
897 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_start_streaming()
898 if (vsp1_pipeline_ready(pipe)) in vsp1_video_start_streaming()
899 vsp1_video_pipeline_run(pipe); in vsp1_video_start_streaming()
900 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_start_streaming()
908 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_stop_streaming() local
917 pipe->buffers_ready &= ~(1 << video->pipe_index); in vsp1_video_stop_streaming()
920 mutex_lock(&pipe->lock); in vsp1_video_stop_streaming()
921 if (--pipe->stream_count == pipe->num_inputs) { in vsp1_video_stop_streaming()
923 ret = vsp1_pipeline_stop(pipe); in vsp1_video_stop_streaming()
927 vsp1_video_cleanup_pipeline(pipe); in vsp1_video_stop_streaming()
929 mutex_unlock(&pipe->lock); in vsp1_video_stop_streaming()
933 vsp1_video_pipeline_put(pipe); in vsp1_video_stop_streaming()
1031 struct vsp1_pipeline *pipe; in vsp1_video_streamon() local
1044 pipe = vsp1_video_pipeline_get(video); in vsp1_video_streamon()
1045 if (IS_ERR(pipe)) { in vsp1_video_streamon()
1047 return PTR_ERR(pipe); in vsp1_video_streamon()
1050 ret = __video_device_pipeline_start(&video->video, &pipe->pipe); in vsp1_video_streamon()
1076 vsp1_video_pipeline_put(pipe); in vsp1_video_streamon()
1165 struct vsp1_pipeline *pipe; in vsp1_video_suspend() local
1170 pipe = wpf->entity.pipe; in vsp1_video_suspend()
1171 if (pipe == NULL) in vsp1_video_suspend()
1174 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_suspend()
1175 if (pipe->state == VSP1_PIPELINE_RUNNING) in vsp1_video_suspend()
1176 pipe->state = VSP1_PIPELINE_STOPPING; in vsp1_video_suspend()
1177 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_suspend()
1182 struct vsp1_pipeline *pipe; in vsp1_video_suspend() local
1187 pipe = wpf->entity.pipe; in vsp1_video_suspend()
1188 if (pipe == NULL) in vsp1_video_suspend()
1191 ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe), in vsp1_video_suspend()
1207 struct vsp1_pipeline *pipe; in vsp1_video_resume() local
1212 pipe = wpf->entity.pipe; in vsp1_video_resume()
1213 if (pipe == NULL) in vsp1_video_resume()
1220 pipe->configured = false; in vsp1_video_resume()
1222 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_resume()
1223 if (vsp1_pipeline_ready(pipe)) in vsp1_video_resume()
1224 vsp1_video_pipeline_run(pipe); in vsp1_video_resume()
1225 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_resume()