Lines Matching refs:pipe
310 static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe, in vsp1_pipeline_validate_branch() argument
362 if (pipe->uds) in vsp1_pipeline_validate_branch()
365 pipe->uds = entity; in vsp1_pipeline_validate_branch()
366 pipe->uds_input = bru_found ? pipe->bru in vsp1_pipeline_validate_branch()
386 static void __vsp1_pipeline_cleanup(struct vsp1_pipeline *pipe) in __vsp1_pipeline_cleanup() argument
388 if (pipe->bru) { in __vsp1_pipeline_cleanup()
389 struct vsp1_bru *bru = to_bru(&pipe->bru->subdev); in __vsp1_pipeline_cleanup()
396 INIT_LIST_HEAD(&pipe->entities); in __vsp1_pipeline_cleanup()
397 pipe->state = VSP1_PIPELINE_STOPPED; in __vsp1_pipeline_cleanup()
398 pipe->buffers_ready = 0; in __vsp1_pipeline_cleanup()
399 pipe->num_video = 0; in __vsp1_pipeline_cleanup()
400 pipe->num_inputs = 0; in __vsp1_pipeline_cleanup()
401 pipe->output = NULL; in __vsp1_pipeline_cleanup()
402 pipe->bru = NULL; in __vsp1_pipeline_cleanup()
403 pipe->lif = NULL; in __vsp1_pipeline_cleanup()
404 pipe->uds = NULL; in __vsp1_pipeline_cleanup()
407 static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe, in vsp1_pipeline_validate() argument
427 pipe->num_video++; in vsp1_pipeline_validate()
433 list_add_tail(&e->list_pipe, &pipe->entities); in vsp1_pipeline_validate()
437 pipe->inputs[pipe->num_inputs++] = rwpf; in vsp1_pipeline_validate()
438 rwpf->video.pipe_index = pipe->num_inputs; in vsp1_pipeline_validate()
441 pipe->output = to_rwpf(subdev); in vsp1_pipeline_validate()
444 pipe->lif = e; in vsp1_pipeline_validate()
446 pipe->bru = e; in vsp1_pipeline_validate()
453 if (pipe->num_inputs == 0 || !pipe->output) { in vsp1_pipeline_validate()
461 for (i = 0; i < pipe->num_inputs; ++i) { in vsp1_pipeline_validate()
462 ret = vsp1_pipeline_validate_branch(pipe, pipe->inputs[i], in vsp1_pipeline_validate()
463 pipe->output); in vsp1_pipeline_validate()
471 __vsp1_pipeline_cleanup(pipe); in vsp1_pipeline_validate()
475 static int vsp1_pipeline_init(struct vsp1_pipeline *pipe, in vsp1_pipeline_init() argument
480 mutex_lock(&pipe->lock); in vsp1_pipeline_init()
483 if (pipe->use_count == 0) { in vsp1_pipeline_init()
484 ret = vsp1_pipeline_validate(pipe, video); in vsp1_pipeline_init()
489 pipe->use_count++; in vsp1_pipeline_init()
493 mutex_unlock(&pipe->lock); in vsp1_pipeline_init()
497 static void vsp1_pipeline_cleanup(struct vsp1_pipeline *pipe) in vsp1_pipeline_cleanup() argument
499 mutex_lock(&pipe->lock); in vsp1_pipeline_cleanup()
502 if (--pipe->use_count == 0) in vsp1_pipeline_cleanup()
503 __vsp1_pipeline_cleanup(pipe); in vsp1_pipeline_cleanup()
505 mutex_unlock(&pipe->lock); in vsp1_pipeline_cleanup()
508 static void vsp1_pipeline_run(struct vsp1_pipeline *pipe) in vsp1_pipeline_run() argument
510 struct vsp1_device *vsp1 = pipe->output->entity.vsp1; in vsp1_pipeline_run()
512 vsp1_write(vsp1, VI6_CMD(pipe->output->entity.index), VI6_CMD_STRCMD); in vsp1_pipeline_run()
513 pipe->state = VSP1_PIPELINE_RUNNING; in vsp1_pipeline_run()
514 pipe->buffers_ready = 0; in vsp1_pipeline_run()
517 static bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe) in vsp1_pipeline_stopped() argument
522 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_pipeline_stopped()
523 stopped = pipe->state == VSP1_PIPELINE_STOPPED, in vsp1_pipeline_stopped()
524 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_pipeline_stopped()
529 static int vsp1_pipeline_stop(struct vsp1_pipeline *pipe) in vsp1_pipeline_stop() argument
535 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_pipeline_stop()
536 if (pipe->state == VSP1_PIPELINE_RUNNING) in vsp1_pipeline_stop()
537 pipe->state = VSP1_PIPELINE_STOPPING; in vsp1_pipeline_stop()
538 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_pipeline_stop()
540 ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe), in vsp1_pipeline_stop()
544 list_for_each_entry(entity, &pipe->entities, list_pipe) { in vsp1_pipeline_stop()
555 static bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe) in vsp1_pipeline_ready() argument
559 mask = ((1 << pipe->num_inputs) - 1) << 1; in vsp1_pipeline_ready()
560 if (!pipe->lif) in vsp1_pipeline_ready()
563 return pipe->buffers_ready == mask; in vsp1_pipeline_ready()
583 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); in vsp1_video_complete_buffer() local
600 if (pipe->lif && list_is_singular(&video->irqqueue)) { in vsp1_video_complete_buffer()
622 static void vsp1_video_frame_end(struct vsp1_pipeline *pipe, in vsp1_video_frame_end() argument
632 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_frame_end()
635 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_frame_end()
637 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_frame_end()
640 void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe) in vsp1_pipeline_frame_end() argument
646 if (pipe == NULL) in vsp1_pipeline_frame_end()
650 for (i = 0; i < pipe->num_inputs; ++i) in vsp1_pipeline_frame_end()
651 vsp1_video_frame_end(pipe, &pipe->inputs[i]->video); in vsp1_pipeline_frame_end()
653 if (!pipe->lif) in vsp1_pipeline_frame_end()
654 vsp1_video_frame_end(pipe, &pipe->output->video); in vsp1_pipeline_frame_end()
656 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_pipeline_frame_end()
658 state = pipe->state; in vsp1_pipeline_frame_end()
659 pipe->state = VSP1_PIPELINE_STOPPED; in vsp1_pipeline_frame_end()
665 wake_up(&pipe->wq); in vsp1_pipeline_frame_end()
670 if (vsp1_pipeline_ready(pipe)) in vsp1_pipeline_frame_end()
671 vsp1_pipeline_run(pipe); in vsp1_pipeline_frame_end()
674 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_pipeline_frame_end()
685 void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe, in vsp1_pipeline_propagate_alpha() argument
730 struct vsp1_pipeline *pipe; in vsp1_pipelines_suspend() local
735 pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity); in vsp1_pipelines_suspend()
736 if (pipe == NULL) in vsp1_pipelines_suspend()
739 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_pipelines_suspend()
740 if (pipe->state == VSP1_PIPELINE_RUNNING) in vsp1_pipelines_suspend()
741 pipe->state = VSP1_PIPELINE_STOPPING; in vsp1_pipelines_suspend()
742 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_pipelines_suspend()
747 struct vsp1_pipeline *pipe; in vsp1_pipelines_suspend() local
752 pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity); in vsp1_pipelines_suspend()
753 if (pipe == NULL) in vsp1_pipelines_suspend()
756 ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe), in vsp1_pipelines_suspend()
771 struct vsp1_pipeline *pipe; in vsp1_pipelines_resume() local
776 pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity); in vsp1_pipelines_resume()
777 if (pipe == NULL) in vsp1_pipelines_resume()
780 if (vsp1_pipeline_ready(pipe)) in vsp1_pipelines_resume()
781 vsp1_pipeline_run(pipe); in vsp1_pipelines_resume()
848 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); in vsp1_video_buffer_queue() local
861 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_buffer_queue()
864 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_buffer_queue()
867 vsp1_pipeline_ready(pipe)) in vsp1_video_buffer_queue()
868 vsp1_pipeline_run(pipe); in vsp1_video_buffer_queue()
870 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_buffer_queue()
888 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); in vsp1_video_start_streaming() local
893 mutex_lock(&pipe->lock); in vsp1_video_start_streaming()
894 if (pipe->stream_count == pipe->num_video - 1) { in vsp1_video_start_streaming()
895 if (pipe->uds) { in vsp1_video_start_streaming()
896 struct vsp1_uds *uds = to_uds(&pipe->uds->subdev); in vsp1_video_start_streaming()
904 if (pipe->uds_input->type == VSP1_ENTITY_BRU) { in vsp1_video_start_streaming()
908 to_rwpf(&pipe->uds_input->subdev); in vsp1_video_start_streaming()
914 list_for_each_entry(entity, &pipe->entities, list_pipe) { in vsp1_video_start_streaming()
920 mutex_unlock(&pipe->lock); in vsp1_video_start_streaming()
926 pipe->stream_count++; in vsp1_video_start_streaming()
927 mutex_unlock(&pipe->lock); in vsp1_video_start_streaming()
929 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_start_streaming()
930 if (vsp1_pipeline_ready(pipe)) in vsp1_video_start_streaming()
931 vsp1_pipeline_run(pipe); in vsp1_video_start_streaming()
932 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_start_streaming()
940 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); in vsp1_video_stop_streaming() local
945 mutex_lock(&pipe->lock); in vsp1_video_stop_streaming()
946 if (--pipe->stream_count == 0) { in vsp1_video_stop_streaming()
948 ret = vsp1_pipeline_stop(pipe); in vsp1_video_stop_streaming()
952 mutex_unlock(&pipe->lock); in vsp1_video_stop_streaming()
954 vsp1_pipeline_cleanup(pipe); in vsp1_video_stop_streaming()
1067 struct vsp1_pipeline *pipe; in vsp1_video_streamon() local
1081 pipe = video->video.entity.pipe in vsp1_video_streamon()
1082 ? to_vsp1_pipeline(&video->video.entity) : &video->pipe; in vsp1_video_streamon()
1084 ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe); in vsp1_video_streamon()
1095 ret = vsp1_pipeline_init(pipe, video); in vsp1_video_streamon()
1107 vsp1_pipeline_cleanup(pipe); in vsp1_video_streamon()
1220 mutex_init(&video->pipe.lock); in vsp1_video_init()
1221 spin_lock_init(&video->pipe.irqlock); in vsp1_video_init()
1222 INIT_LIST_HEAD(&video->pipe.entities); in vsp1_video_init()
1223 init_waitqueue_head(&video->pipe.wq); in vsp1_video_init()
1224 video->pipe.state = VSP1_PIPELINE_STOPPED; in vsp1_video_init()