Lines Matching refs:video
173 static int vsp1_video_verify_format(struct vsp1_video *video) in vsp1_video_verify_format() argument
179 subdev = vsp1_video_remote_subdev(&video->pad, &fmt.pad); in vsp1_video_verify_format()
188 if (video->fmtinfo->mbus != fmt.format.code || in vsp1_video_verify_format()
189 video->format.height != fmt.format.height || in vsp1_video_verify_format()
190 video->format.width != fmt.format.width) in vsp1_video_verify_format()
196 static int __vsp1_video_try_format(struct vsp1_video *video, in __vsp1_video_try_format() argument
278 vsp1_video_format_adjust(struct vsp1_video *video, in vsp1_video_format_adjust() argument
285 __vsp1_video_try_format(video, adjust, NULL); in vsp1_video_format_adjust()
408 struct vsp1_video *video) in vsp1_pipeline_validate() argument
411 struct media_entity *entity = &video->video.entity; in vsp1_pipeline_validate()
438 rwpf->video.pipe_index = pipe->num_inputs; in vsp1_pipeline_validate()
442 rwpf->video.pipe_index = 0; in vsp1_pipeline_validate()
476 struct vsp1_video *video) in vsp1_pipeline_init() argument
484 ret = vsp1_pipeline_validate(pipe, video); in vsp1_pipeline_init()
537 v4l2_subdev_call(&entity->subdev, video, s_stream, 0); in vsp1_pipeline_stop()
569 vsp1_video_complete_buffer(struct vsp1_video *video) in vsp1_video_complete_buffer() argument
571 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); in vsp1_video_complete_buffer()
577 spin_lock_irqsave(&video->irqlock, flags); in vsp1_video_complete_buffer()
579 if (list_empty(&video->irqqueue)) { in vsp1_video_complete_buffer()
580 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_complete_buffer()
584 done = list_first_entry(&video->irqqueue, in vsp1_video_complete_buffer()
588 if (pipe->lif && list_is_singular(&video->irqqueue)) { in vsp1_video_complete_buffer()
589 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_complete_buffer()
595 if (!list_empty(&video->irqqueue)) in vsp1_video_complete_buffer()
596 next = list_first_entry(&video->irqqueue, in vsp1_video_complete_buffer()
599 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_complete_buffer()
601 done->buf.v4l2_buf.sequence = video->sequence++; in vsp1_video_complete_buffer()
611 struct vsp1_video *video) in vsp1_video_frame_end() argument
616 buf = vsp1_video_complete_buffer(video); in vsp1_video_frame_end()
622 video->ops->queue(video, buf); in vsp1_video_frame_end()
623 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_frame_end()
639 vsp1_video_frame_end(pipe, &pipe->inputs[i]->video); in vsp1_pipeline_frame_end()
642 vsp1_video_frame_end(pipe, &pipe->output->video); in vsp1_pipeline_frame_end()
715 struct vsp1_video *video = vb2_get_drv_priv(vq); in vsp1_video_queue_setup() local
724 if (!vsp1_video_format_adjust(video, &fmt->fmt.pix_mp, &pix_mp)) in vsp1_video_queue_setup()
729 format = &video->format; in vsp1_video_queue_setup()
736 alloc_ctxs[i] = video->alloc_ctx; in vsp1_video_queue_setup()
744 struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue); in vsp1_video_buffer_prepare() local
746 const struct v4l2_pix_format_mplane *format = &video->format; in vsp1_video_buffer_prepare()
765 struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue); in vsp1_video_buffer_queue() local
766 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); in vsp1_video_buffer_queue()
771 spin_lock_irqsave(&video->irqlock, flags); in vsp1_video_buffer_queue()
772 empty = list_empty(&video->irqqueue); in vsp1_video_buffer_queue()
773 list_add_tail(&buf->queue, &video->irqqueue); in vsp1_video_buffer_queue()
774 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_buffer_queue()
781 video->ops->queue(video, buf); in vsp1_video_buffer_queue()
782 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_buffer_queue()
784 if (vb2_is_streaming(&video->queue) && in vsp1_video_buffer_queue()
805 struct vsp1_video *video = vb2_get_drv_priv(vq); in vsp1_video_start_streaming() local
806 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); in vsp1_video_start_streaming()
828 uds->scale_alpha = rpf->video.fmtinfo->alpha; in vsp1_video_start_streaming()
835 ret = v4l2_subdev_call(&entity->subdev, video, in vsp1_video_start_streaming()
857 struct vsp1_video *video = vb2_get_drv_priv(vq); in vsp1_video_stop_streaming() local
858 struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity); in vsp1_video_stop_streaming()
868 dev_err(video->vsp1->dev, "pipeline stop timeout\n"); in vsp1_video_stop_streaming()
873 media_entity_pipeline_stop(&video->video.entity); in vsp1_video_stop_streaming()
876 spin_lock_irqsave(&video->irqlock, flags); in vsp1_video_stop_streaming()
877 list_for_each_entry(buffer, &video->irqqueue, queue) in vsp1_video_stop_streaming()
879 INIT_LIST_HEAD(&video->irqqueue); in vsp1_video_stop_streaming()
880 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_stop_streaming()
901 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_querycap() local
907 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) in vsp1_video_querycap()
915 strlcpy(cap->card, video->video.name, sizeof(cap->card)); in vsp1_video_querycap()
917 dev_name(video->vsp1->dev)); in vsp1_video_querycap()
926 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_get_format() local
928 if (format->type != video->queue.type) in vsp1_video_get_format()
931 mutex_lock(&video->lock); in vsp1_video_get_format()
932 format->fmt.pix_mp = video->format; in vsp1_video_get_format()
933 mutex_unlock(&video->lock); in vsp1_video_get_format()
942 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_try_format() local
944 if (format->type != video->queue.type) in vsp1_video_try_format()
947 return __vsp1_video_try_format(video, &format->fmt.pix_mp, NULL); in vsp1_video_try_format()
954 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_set_format() local
958 if (format->type != video->queue.type) in vsp1_video_set_format()
961 ret = __vsp1_video_try_format(video, &format->fmt.pix_mp, &info); in vsp1_video_set_format()
965 mutex_lock(&video->lock); in vsp1_video_set_format()
967 if (vb2_is_busy(&video->queue)) { in vsp1_video_set_format()
972 video->format = format->fmt.pix_mp; in vsp1_video_set_format()
973 video->fmtinfo = info; in vsp1_video_set_format()
976 mutex_unlock(&video->lock); in vsp1_video_set_format()
984 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_streamon() local
988 if (video->queue.owner && video->queue.owner != file->private_data) in vsp1_video_streamon()
991 video->sequence = 0; in vsp1_video_streamon()
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()
1009 ret = vsp1_video_verify_format(video); in vsp1_video_streamon()
1013 ret = vsp1_pipeline_init(pipe, video); in vsp1_video_streamon()
1018 ret = vb2_streamon(&video->queue, type); in vsp1_video_streamon()
1027 media_entity_pipeline_stop(&video->video.entity); in vsp1_video_streamon()
1055 struct vsp1_video *video = video_drvdata(file); in vsp1_video_open() local
1063 v4l2_fh_init(vfh, &video->video); in vsp1_video_open()
1068 ret = vsp1_device_get(video->vsp1); in vsp1_video_open()
1079 struct vsp1_video *video = video_drvdata(file); in vsp1_video_release() local
1082 mutex_lock(&video->lock); in vsp1_video_release()
1083 if (video->queue.owner == vfh) { in vsp1_video_release()
1084 vb2_queue_release(&video->queue); in vsp1_video_release()
1085 video->queue.owner = NULL; in vsp1_video_release()
1087 mutex_unlock(&video->lock); in vsp1_video_release()
1089 vsp1_device_put(video->vsp1); in vsp1_video_release()
1111 int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf) in vsp1_video_init() argument
1116 switch (video->type) { in vsp1_video_init()
1119 video->pad.flags = MEDIA_PAD_FL_SINK; in vsp1_video_init()
1124 video->pad.flags = MEDIA_PAD_FL_SOURCE; in vsp1_video_init()
1125 video->video.vfl_dir = VFL_DIR_TX; in vsp1_video_init()
1132 video->rwpf = rwpf; in vsp1_video_init()
1134 mutex_init(&video->lock); in vsp1_video_init()
1135 spin_lock_init(&video->irqlock); in vsp1_video_init()
1136 INIT_LIST_HEAD(&video->irqqueue); in vsp1_video_init()
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()
1145 ret = media_entity_init(&video->video.entity, 1, &video->pad, 0); in vsp1_video_init()
1150 video->fmtinfo = vsp1_get_format_info(VSP1_VIDEO_DEF_FORMAT); in vsp1_video_init()
1151 video->format.pixelformat = video->fmtinfo->fourcc; in vsp1_video_init()
1152 video->format.colorspace = V4L2_COLORSPACE_SRGB; in vsp1_video_init()
1153 video->format.field = V4L2_FIELD_NONE; in vsp1_video_init()
1154 video->format.width = VSP1_VIDEO_DEF_WIDTH; in vsp1_video_init()
1155 video->format.height = VSP1_VIDEO_DEF_HEIGHT; in vsp1_video_init()
1156 video->format.num_planes = 1; in vsp1_video_init()
1157 video->format.plane_fmt[0].bytesperline = in vsp1_video_init()
1158 video->format.width * video->fmtinfo->bpp[0] / 8; in vsp1_video_init()
1159 video->format.plane_fmt[0].sizeimage = in vsp1_video_init()
1160 video->format.plane_fmt[0].bytesperline * video->format.height; in vsp1_video_init()
1163 video->video.v4l2_dev = &video->vsp1->v4l2_dev; in vsp1_video_init()
1164 video->video.fops = &vsp1_video_fops; in vsp1_video_init()
1165 snprintf(video->video.name, sizeof(video->video.name), "%s %s", in vsp1_video_init()
1167 video->video.vfl_type = VFL_TYPE_GRABBER; in vsp1_video_init()
1168 video->video.release = video_device_release_empty; in vsp1_video_init()
1169 video->video.ioctl_ops = &vsp1_video_ioctl_ops; in vsp1_video_init()
1171 video_set_drvdata(&video->video, video); in vsp1_video_init()
1174 video->alloc_ctx = vb2_dma_contig_init_ctx(video->vsp1->dev); in vsp1_video_init()
1175 if (IS_ERR(video->alloc_ctx)) { in vsp1_video_init()
1176 ret = PTR_ERR(video->alloc_ctx); in vsp1_video_init()
1180 video->queue.type = video->type; in vsp1_video_init()
1181 video->queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; in vsp1_video_init()
1182 video->queue.lock = &video->lock; in vsp1_video_init()
1183 video->queue.drv_priv = video; in vsp1_video_init()
1184 video->queue.buf_struct_size = sizeof(struct vsp1_video_buffer); in vsp1_video_init()
1185 video->queue.ops = &vsp1_video_queue_qops; in vsp1_video_init()
1186 video->queue.mem_ops = &vb2_dma_contig_memops; in vsp1_video_init()
1187 video->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; in vsp1_video_init()
1188 ret = vb2_queue_init(&video->queue); in vsp1_video_init()
1190 dev_err(video->vsp1->dev, "failed to initialize vb2 queue\n"); in vsp1_video_init()
1195 video->video.queue = &video->queue; in vsp1_video_init()
1196 ret = video_register_device(&video->video, VFL_TYPE_GRABBER, -1); in vsp1_video_init()
1198 dev_err(video->vsp1->dev, "failed to register video device\n"); in vsp1_video_init()
1205 vb2_dma_contig_cleanup_ctx(video->alloc_ctx); in vsp1_video_init()
1206 vsp1_video_cleanup(video); in vsp1_video_init()
1210 void vsp1_video_cleanup(struct vsp1_video *video) in vsp1_video_cleanup() argument
1212 if (video_is_registered(&video->video)) in vsp1_video_cleanup()
1213 video_unregister_device(&video->video); in vsp1_video_cleanup()
1215 vb2_dma_contig_cleanup_ctx(video->alloc_ctx); in vsp1_video_cleanup()
1216 media_entity_cleanup(&video->video.entity); in vsp1_video_cleanup()