Lines Matching refs:pipe
186 static void vsp1_video_calculate_partition(struct vsp1_pipeline *pipe, in vsp1_video_calculate_partition() argument
199 format = vsp1_entity_get_pad_format(&pipe->output->entity, in vsp1_video_calculate_partition()
200 pipe->output->entity.config, in vsp1_video_calculate_partition()
204 if (pipe->partitions <= 1) { in vsp1_video_calculate_partition()
208 vsp1_pipeline_propagate_partition(pipe, partition, index, in vsp1_video_calculate_partition()
233 unsigned int partitions = pipe->partitions - 1; in vsp1_video_calculate_partition()
249 vsp1_pipeline_propagate_partition(pipe, partition, index, &window); in vsp1_video_calculate_partition()
252 static int vsp1_video_pipeline_setup_partitions(struct vsp1_pipeline *pipe) in vsp1_video_pipeline_setup_partitions() argument
254 struct vsp1_device *vsp1 = pipe->output->entity.vsp1; in vsp1_video_pipeline_setup_partitions()
264 format = vsp1_entity_get_pad_format(&pipe->output->entity, in vsp1_video_pipeline_setup_partitions()
265 pipe->output->entity.config, in vsp1_video_pipeline_setup_partitions()
274 list_for_each_entry(entity, &pipe->entities, list_pipe) { in vsp1_video_pipeline_setup_partitions()
280 entity_max = entity->ops->max_width(entity, pipe); in vsp1_video_pipeline_setup_partitions()
286 pipe->partitions = DIV_ROUND_UP(format->width, div_size); in vsp1_video_pipeline_setup_partitions()
287 pipe->part_table = kcalloc(pipe->partitions, sizeof(*pipe->part_table), in vsp1_video_pipeline_setup_partitions()
289 if (!pipe->part_table) in vsp1_video_pipeline_setup_partitions()
292 for (i = 0; i < pipe->partitions; ++i) in vsp1_video_pipeline_setup_partitions()
293 vsp1_video_calculate_partition(pipe, &pipe->part_table[i], in vsp1_video_pipeline_setup_partitions()
315 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_complete_buffer() local
339 done->buf.sequence = pipe->sequence; in vsp1_video_complete_buffer()
349 static void vsp1_video_frame_end(struct vsp1_pipeline *pipe, in vsp1_video_frame_end() argument
360 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_frame_end()
363 static void vsp1_video_pipeline_run_partition(struct vsp1_pipeline *pipe, in vsp1_video_pipeline_run_partition() argument
370 pipe->partition = &pipe->part_table[partition]; in vsp1_video_pipeline_run_partition()
372 list_for_each_entry(entity, &pipe->entities, list_pipe) in vsp1_video_pipeline_run_partition()
373 vsp1_entity_configure_partition(entity, pipe, dl, dlb); in vsp1_video_pipeline_run_partition()
376 static void vsp1_video_pipeline_run(struct vsp1_pipeline *pipe) in vsp1_video_pipeline_run() argument
378 struct vsp1_device *vsp1 = pipe->output->entity.vsp1; in vsp1_video_pipeline_run()
384 dl = vsp1_dl_list_get(pipe->output->dlm); in vsp1_video_pipeline_run()
392 if (!pipe->configured) in vsp1_video_pipeline_run()
393 vsp1_dl_list_add_body(dl, pipe->stream_config); in vsp1_video_pipeline_run()
397 list_for_each_entry(entity, &pipe->entities, list_pipe) in vsp1_video_pipeline_run()
398 vsp1_entity_configure_frame(entity, pipe, dl, dlb); in vsp1_video_pipeline_run()
401 vsp1_video_pipeline_run_partition(pipe, dl, 0); in vsp1_video_pipeline_run()
404 for (partition = 1; partition < pipe->partitions; ++partition) { in vsp1_video_pipeline_run()
407 dl_next = vsp1_dl_list_get(pipe->output->dlm); in vsp1_video_pipeline_run()
419 vsp1_video_pipeline_run_partition(pipe, dl_next, partition); in vsp1_video_pipeline_run()
425 pipe->configured = true; in vsp1_video_pipeline_run()
427 vsp1_pipeline_run(pipe); in vsp1_video_pipeline_run()
430 static void vsp1_video_pipeline_frame_end(struct vsp1_pipeline *pipe, in vsp1_video_pipeline_frame_end() argument
433 struct vsp1_device *vsp1 = pipe->output->entity.vsp1; in vsp1_video_pipeline_frame_end()
441 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_pipeline_frame_end()
445 if (!pipe->inputs[i]) in vsp1_video_pipeline_frame_end()
448 vsp1_video_frame_end(pipe, pipe->inputs[i]); in vsp1_video_pipeline_frame_end()
451 vsp1_video_frame_end(pipe, pipe->output); in vsp1_video_pipeline_frame_end()
453 state = pipe->state; in vsp1_video_pipeline_frame_end()
454 pipe->state = VSP1_PIPELINE_STOPPED; in vsp1_video_pipeline_frame_end()
461 wake_up(&pipe->wq); in vsp1_video_pipeline_frame_end()
462 else if (vsp1_pipeline_ready(pipe)) in vsp1_video_pipeline_frame_end()
463 vsp1_video_pipeline_run(pipe); in vsp1_video_pipeline_frame_end()
465 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_pipeline_frame_end()
468 static int vsp1_video_pipeline_build_branch(struct vsp1_pipeline *pipe, in vsp1_video_pipeline_build_branch() argument
534 if (pipe->uds) { in vsp1_video_pipeline_build_branch()
539 pipe->uds = entity; in vsp1_video_pipeline_build_branch()
540 pipe->uds_input = brx ? &brx->entity : &input->entity; in vsp1_video_pipeline_build_branch()
558 static int vsp1_video_pipeline_build(struct vsp1_pipeline *pipe, in vsp1_video_pipeline_build() argument
584 list_add_tail(&e->list_pipe, &pipe->entities); in vsp1_video_pipeline_build()
585 e->pipe = pipe; in vsp1_video_pipeline_build()
590 pipe->inputs[rwpf->entity.index] = rwpf; in vsp1_video_pipeline_build()
591 rwpf->video->pipe_index = ++pipe->num_inputs; in vsp1_video_pipeline_build()
596 pipe->output = rwpf; in vsp1_video_pipeline_build()
601 pipe->lif = e; in vsp1_video_pipeline_build()
606 pipe->brx = e; in vsp1_video_pipeline_build()
610 pipe->hgo = e; in vsp1_video_pipeline_build()
614 pipe->hgt = e; in vsp1_video_pipeline_build()
625 if (pipe->num_inputs == 0 || !pipe->output) in vsp1_video_pipeline_build()
633 if (!pipe->inputs[i]) in vsp1_video_pipeline_build()
636 ret = vsp1_video_pipeline_build_branch(pipe, pipe->inputs[i], in vsp1_video_pipeline_build()
637 pipe->output); in vsp1_video_pipeline_build()
645 static int vsp1_video_pipeline_init(struct vsp1_pipeline *pipe, in vsp1_video_pipeline_init() argument
648 vsp1_pipeline_init(pipe); in vsp1_video_pipeline_init()
650 pipe->frame_end = vsp1_video_pipeline_frame_end; in vsp1_video_pipeline_init()
652 return vsp1_video_pipeline_build(pipe, video); in vsp1_video_pipeline_init()
657 struct vsp1_pipeline *pipe; in vsp1_video_pipeline_get() local
666 if (!video->rwpf->entity.pipe) { in vsp1_video_pipeline_get()
667 pipe = kzalloc(sizeof(*pipe), GFP_KERNEL); in vsp1_video_pipeline_get()
668 if (!pipe) in vsp1_video_pipeline_get()
671 ret = vsp1_video_pipeline_init(pipe, video); in vsp1_video_pipeline_get()
673 vsp1_pipeline_reset(pipe); in vsp1_video_pipeline_get()
674 kfree(pipe); in vsp1_video_pipeline_get()
678 pipe = video->rwpf->entity.pipe; in vsp1_video_pipeline_get()
679 kref_get(&pipe->kref); in vsp1_video_pipeline_get()
682 return pipe; in vsp1_video_pipeline_get()
687 struct vsp1_pipeline *pipe = container_of(kref, typeof(*pipe), kref); in vsp1_video_pipeline_release() local
689 vsp1_pipeline_reset(pipe); in vsp1_video_pipeline_release()
690 kfree(pipe); in vsp1_video_pipeline_release()
693 static void vsp1_video_pipeline_put(struct vsp1_pipeline *pipe) in vsp1_video_pipeline_put() argument
695 struct media_device *mdev = &pipe->output->entity.vsp1->media_dev; in vsp1_video_pipeline_put()
698 kref_put(&pipe->kref, vsp1_video_pipeline_release); in vsp1_video_pipeline_put()
761 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_buffer_queue() local
774 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_buffer_queue()
777 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_buffer_queue()
780 vsp1_pipeline_ready(pipe)) in vsp1_video_buffer_queue()
781 vsp1_video_pipeline_run(pipe); in vsp1_video_buffer_queue()
783 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_buffer_queue()
786 static int vsp1_video_setup_pipeline(struct vsp1_pipeline *pipe) in vsp1_video_setup_pipeline() argument
792 ret = vsp1_video_pipeline_setup_partitions(pipe); in vsp1_video_setup_pipeline()
796 if (pipe->uds) { in vsp1_video_setup_pipeline()
797 struct vsp1_uds *uds = to_uds(&pipe->uds->subdev); in vsp1_video_setup_pipeline()
806 if (pipe->uds_input->type == VSP1_ENTITY_BRU || in vsp1_video_setup_pipeline()
807 pipe->uds_input->type == VSP1_ENTITY_BRS) { in vsp1_video_setup_pipeline()
811 to_rwpf(&pipe->uds_input->subdev); in vsp1_video_setup_pipeline()
822 pipe->stream_config = vsp1_dlm_dl_body_get(pipe->output->dlm); in vsp1_video_setup_pipeline()
823 if (!pipe->stream_config) in vsp1_video_setup_pipeline()
826 list_for_each_entry(entity, &pipe->entities, list_pipe) { in vsp1_video_setup_pipeline()
827 vsp1_entity_route_setup(entity, pipe, pipe->stream_config); in vsp1_video_setup_pipeline()
828 vsp1_entity_configure_stream(entity, pipe, NULL, in vsp1_video_setup_pipeline()
829 pipe->stream_config); in vsp1_video_setup_pipeline()
848 static void vsp1_video_cleanup_pipeline(struct vsp1_pipeline *pipe) in vsp1_video_cleanup_pipeline() argument
850 lockdep_assert_held(&pipe->lock); in vsp1_video_cleanup_pipeline()
853 vsp1_dl_body_put(pipe->stream_config); in vsp1_video_cleanup_pipeline()
854 pipe->stream_config = NULL; in vsp1_video_cleanup_pipeline()
855 pipe->configured = false; in vsp1_video_cleanup_pipeline()
858 kfree(pipe->part_table); in vsp1_video_cleanup_pipeline()
859 pipe->part_table = NULL; in vsp1_video_cleanup_pipeline()
865 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_start_streaming() local
870 mutex_lock(&pipe->lock); in vsp1_video_start_streaming()
871 if (pipe->stream_count == pipe->num_inputs) { in vsp1_video_start_streaming()
872 ret = vsp1_video_setup_pipeline(pipe); in vsp1_video_start_streaming()
875 vsp1_video_cleanup_pipeline(pipe); in vsp1_video_start_streaming()
876 mutex_unlock(&pipe->lock); in vsp1_video_start_streaming()
883 pipe->stream_count++; in vsp1_video_start_streaming()
884 mutex_unlock(&pipe->lock); in vsp1_video_start_streaming()
896 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_start_streaming()
897 if (vsp1_pipeline_ready(pipe)) in vsp1_video_start_streaming()
898 vsp1_video_pipeline_run(pipe); in vsp1_video_start_streaming()
899 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_start_streaming()
907 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_stop_streaming() local
916 pipe->buffers_ready &= ~(1 << video->pipe_index); in vsp1_video_stop_streaming()
919 mutex_lock(&pipe->lock); in vsp1_video_stop_streaming()
920 if (--pipe->stream_count == pipe->num_inputs) { in vsp1_video_stop_streaming()
922 ret = vsp1_pipeline_stop(pipe); in vsp1_video_stop_streaming()
926 vsp1_video_cleanup_pipeline(pipe); in vsp1_video_stop_streaming()
928 mutex_unlock(&pipe->lock); in vsp1_video_stop_streaming()
932 vsp1_video_pipeline_put(pipe); in vsp1_video_stop_streaming()
1032 struct vsp1_pipeline *pipe; in vsp1_video_streamon() local
1045 pipe = vsp1_video_pipeline_get(video); in vsp1_video_streamon()
1046 if (IS_ERR(pipe)) { in vsp1_video_streamon()
1048 return PTR_ERR(pipe); in vsp1_video_streamon()
1051 ret = __media_pipeline_start(&video->video.entity, &pipe->pipe); in vsp1_video_streamon()
1077 vsp1_video_pipeline_put(pipe); in vsp1_video_streamon()
1176 struct vsp1_pipeline *pipe; in vsp1_video_suspend() local
1181 pipe = wpf->entity.pipe; in vsp1_video_suspend()
1182 if (pipe == NULL) in vsp1_video_suspend()
1185 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_suspend()
1186 if (pipe->state == VSP1_PIPELINE_RUNNING) in vsp1_video_suspend()
1187 pipe->state = VSP1_PIPELINE_STOPPING; in vsp1_video_suspend()
1188 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_suspend()
1193 struct vsp1_pipeline *pipe; in vsp1_video_suspend() local
1198 pipe = wpf->entity.pipe; in vsp1_video_suspend()
1199 if (pipe == NULL) in vsp1_video_suspend()
1202 ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe), in vsp1_video_suspend()
1218 struct vsp1_pipeline *pipe; in vsp1_video_resume() local
1223 pipe = wpf->entity.pipe; in vsp1_video_resume()
1224 if (pipe == NULL) in vsp1_video_resume()
1231 pipe->configured = false; in vsp1_video_resume()
1233 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_resume()
1234 if (vsp1_pipeline_ready(pipe)) in vsp1_video_resume()
1235 vsp1_video_pipeline_run(pipe); in vsp1_video_resume()
1236 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_resume()