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 int vsp1_pipeline_stop(struct vsp1_pipeline *pipe) in vsp1_pipeline_stop() argument
523 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_pipeline_stop()
524 if (pipe->state == VSP1_PIPELINE_RUNNING) in vsp1_pipeline_stop()
525 pipe->state = VSP1_PIPELINE_STOPPING; in vsp1_pipeline_stop()
526 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_pipeline_stop()
528 ret = wait_event_timeout(pipe->wq, pipe->state == VSP1_PIPELINE_STOPPED, in vsp1_pipeline_stop()
532 list_for_each_entry(entity, &pipe->entities, list_pipe) { in vsp1_pipeline_stop()
543 static bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe) in vsp1_pipeline_ready() argument
547 mask = ((1 << pipe->num_inputs) - 1) << 1; in vsp1_pipeline_ready()
548 if (!pipe->lif) in vsp1_pipeline_ready()
551 return pipe->buffers_ready == mask; in vsp1_pipeline_ready()
571 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); in vsp1_video_complete_buffer() local
588 if (pipe->lif && list_is_singular(&video->irqqueue)) { in vsp1_video_complete_buffer()
610 static void vsp1_video_frame_end(struct vsp1_pipeline *pipe, in vsp1_video_frame_end() argument
620 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_frame_end()
623 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_frame_end()
625 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_frame_end()
628 void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe) in vsp1_pipeline_frame_end() argument
634 if (pipe == NULL) in vsp1_pipeline_frame_end()
638 for (i = 0; i < pipe->num_inputs; ++i) in vsp1_pipeline_frame_end()
639 vsp1_video_frame_end(pipe, &pipe->inputs[i]->video); in vsp1_pipeline_frame_end()
641 if (!pipe->lif) in vsp1_pipeline_frame_end()
642 vsp1_video_frame_end(pipe, &pipe->output->video); in vsp1_pipeline_frame_end()
644 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_pipeline_frame_end()
646 state = pipe->state; in vsp1_pipeline_frame_end()
647 pipe->state = VSP1_PIPELINE_STOPPED; in vsp1_pipeline_frame_end()
653 wake_up(&pipe->wq); in vsp1_pipeline_frame_end()
658 if (vsp1_pipeline_ready(pipe)) in vsp1_pipeline_frame_end()
659 vsp1_pipeline_run(pipe); in vsp1_pipeline_frame_end()
662 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_pipeline_frame_end()
673 void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe, in vsp1_pipeline_propagate_alpha() argument
766 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); in vsp1_video_buffer_queue() local
779 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_buffer_queue()
782 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_buffer_queue()
785 vsp1_pipeline_ready(pipe)) in vsp1_video_buffer_queue()
786 vsp1_pipeline_run(pipe); in vsp1_video_buffer_queue()
788 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_buffer_queue()
806 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); in vsp1_video_start_streaming() local
811 mutex_lock(&pipe->lock); in vsp1_video_start_streaming()
812 if (pipe->stream_count == pipe->num_video - 1) { in vsp1_video_start_streaming()
813 if (pipe->uds) { in vsp1_video_start_streaming()
814 struct vsp1_uds *uds = to_uds(&pipe->uds->subdev); in vsp1_video_start_streaming()
822 if (pipe->uds_input->type == VSP1_ENTITY_BRU) { in vsp1_video_start_streaming()
826 to_rwpf(&pipe->uds_input->subdev); in vsp1_video_start_streaming()
832 list_for_each_entry(entity, &pipe->entities, list_pipe) { in vsp1_video_start_streaming()
838 mutex_unlock(&pipe->lock); in vsp1_video_start_streaming()
844 pipe->stream_count++; in vsp1_video_start_streaming()
845 mutex_unlock(&pipe->lock); in vsp1_video_start_streaming()
847 spin_lock_irqsave(&pipe->irqlock, flags); in vsp1_video_start_streaming()
848 if (vsp1_pipeline_ready(pipe)) in vsp1_video_start_streaming()
849 vsp1_pipeline_run(pipe); in vsp1_video_start_streaming()
850 spin_unlock_irqrestore(&pipe->irqlock, flags); in vsp1_video_start_streaming()
858 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); in vsp1_video_stop_streaming() local
863 mutex_lock(&pipe->lock); in vsp1_video_stop_streaming()
864 if (--pipe->stream_count == 0) { in vsp1_video_stop_streaming()
866 ret = vsp1_pipeline_stop(pipe); in vsp1_video_stop_streaming()
870 mutex_unlock(&pipe->lock); in vsp1_video_stop_streaming()
872 vsp1_pipeline_cleanup(pipe); in vsp1_video_stop_streaming()
985 struct vsp1_pipeline *pipe; in vsp1_video_streamon() local
999 pipe = video->video.entity.pipe in vsp1_video_streamon()
1000 ? to_vsp1_pipeline(&video->video.entity) : &video->pipe; in vsp1_video_streamon()
1002 ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe); in vsp1_video_streamon()
1013 ret = vsp1_pipeline_init(pipe, video); in vsp1_video_streamon()
1025 vsp1_pipeline_cleanup(pipe); in vsp1_video_streamon()
1138 mutex_init(&video->pipe.lock); in vsp1_video_init()
1139 spin_lock_init(&video->pipe.irqlock); in vsp1_video_init()
1140 INIT_LIST_HEAD(&video->pipe.entities); in vsp1_video_init()
1141 init_waitqueue_head(&video->pipe.wq); in vsp1_video_init()
1142 video->pipe.state = VSP1_PIPELINE_STOPPED; in vsp1_video_init()