Lines Matching full:video

3  * vsp1_video.c  --  R-Car VSP1 Video Node
63 static int vsp1_video_verify_format(struct vsp1_video *video) in vsp1_video_verify_format() argument
69 subdev = vsp1_video_remote_subdev(&video->pad, &fmt.pad); in vsp1_video_verify_format()
78 if (video->rwpf->fmtinfo->mbus != fmt.format.code || in vsp1_video_verify_format()
79 video->rwpf->format.height != fmt.format.height || in vsp1_video_verify_format()
80 video->rwpf->format.width != fmt.format.width) in vsp1_video_verify_format()
86 static int __vsp1_video_try_format(struct vsp1_video *video, in __vsp1_video_try_format() argument
118 info = vsp1_get_format_info(video->vsp1, pix->pixelformat); in __vsp1_video_try_format()
120 info = vsp1_get_format_info(video->vsp1, VSP1_VIDEO_DEF_FORMAT); in __vsp1_video_try_format()
305 * @video: the video node
313 vsp1_video_complete_buffer(struct vsp1_video *video) in vsp1_video_complete_buffer() argument
315 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_complete_buffer()
321 spin_lock_irqsave(&video->irqlock, flags); in vsp1_video_complete_buffer()
323 if (list_empty(&video->irqqueue)) { in vsp1_video_complete_buffer()
324 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_complete_buffer()
328 done = list_first_entry(&video->irqqueue, in vsp1_video_complete_buffer()
333 if (!list_empty(&video->irqqueue)) in vsp1_video_complete_buffer()
334 next = list_first_entry(&video->irqqueue, in vsp1_video_complete_buffer()
337 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_complete_buffer()
352 struct vsp1_video *video = rwpf->video; in vsp1_video_frame_end() local
355 buf = vsp1_video_complete_buffer(video); in vsp1_video_frame_end()
359 video->rwpf->mem = buf->mem; in vsp1_video_frame_end()
360 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_frame_end()
443 /* Complete buffers on all video nodes. */ in vsp1_video_pipeline_frame_end()
495 /* We've reached a video node, that shouldn't have happened. */ in vsp1_video_pipeline_build_branch()
559 struct vsp1_video *video) in vsp1_video_pipeline_build() argument
562 struct media_entity *entity = &video->video.entity; in vsp1_video_pipeline_build()
567 /* Walk the graph to locate the entities and video nodes. */ in vsp1_video_pipeline_build()
591 rwpf->video->pipe_index = ++pipe->num_inputs; in vsp1_video_pipeline_build()
597 rwpf->video->pipe_index = 0; in vsp1_video_pipeline_build()
632 for (i = 0; i < video->vsp1->info->rpf_count; ++i) { in vsp1_video_pipeline_build()
646 struct vsp1_video *video) in vsp1_video_pipeline_init() argument
652 return vsp1_video_pipeline_build(pipe, video); in vsp1_video_pipeline_init()
655 static struct vsp1_pipeline *vsp1_video_pipeline_get(struct vsp1_video *video) in vsp1_video_pipeline_get() argument
661 * Get a pipeline object for the video node. If a pipeline has already in vsp1_video_pipeline_get()
666 if (!video->rwpf->entity.pipe) { in vsp1_video_pipeline_get()
671 ret = vsp1_video_pipeline_init(pipe, video); in vsp1_video_pipeline_get()
678 pipe = video->rwpf->entity.pipe; in vsp1_video_pipeline_get()
711 struct vsp1_video *video = vb2_get_drv_priv(vq); in vsp1_video_queue_setup() local
712 const struct v4l2_pix_format_mplane *format = &video->rwpf->format; in vsp1_video_queue_setup()
736 struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue); in vsp1_video_buffer_prepare() local
738 const struct v4l2_pix_format_mplane *format = &video->rwpf->format; in vsp1_video_buffer_prepare()
760 struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue); in vsp1_video_buffer_queue() local
761 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_buffer_queue()
766 spin_lock_irqsave(&video->irqlock, flags); in vsp1_video_buffer_queue()
767 empty = list_empty(&video->irqqueue); in vsp1_video_buffer_queue()
768 list_add_tail(&buf->queue, &video->irqqueue); in vsp1_video_buffer_queue()
769 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_buffer_queue()
776 video->rwpf->mem = buf->mem; in vsp1_video_buffer_queue()
777 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_buffer_queue()
779 if (vb2_is_streaming(&video->queue) && in vsp1_video_buffer_queue()
835 static void vsp1_video_release_buffers(struct vsp1_video *video) in vsp1_video_release_buffers() argument
841 spin_lock_irqsave(&video->irqlock, flags); in vsp1_video_release_buffers()
842 list_for_each_entry(buffer, &video->irqqueue, queue) in vsp1_video_release_buffers()
844 INIT_LIST_HEAD(&video->irqqueue); in vsp1_video_release_buffers()
845 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_release_buffers()
852 /* Release any cached configuration from our output video. */ in vsp1_video_cleanup_pipeline()
864 struct vsp1_video *video = vb2_get_drv_priv(vq); in vsp1_video_start_streaming() local
865 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_start_streaming()
874 vsp1_video_release_buffers(video); in vsp1_video_start_streaming()
906 struct vsp1_video *video = vb2_get_drv_priv(vq); in vsp1_video_stop_streaming() local
907 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_stop_streaming()
913 * by a QBUF on the video node on the other side of the pipeline. in vsp1_video_stop_streaming()
915 spin_lock_irqsave(&video->irqlock, flags); in vsp1_video_stop_streaming()
916 pipe->buffers_ready &= ~(1 << video->pipe_index); in vsp1_video_stop_streaming()
917 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_stop_streaming()
924 dev_err(video->vsp1->dev, "pipeline stop timeout\n"); in vsp1_video_stop_streaming()
930 video_device_pipeline_stop(&video->video); in vsp1_video_stop_streaming()
931 vsp1_video_release_buffers(video); in vsp1_video_stop_streaming()
953 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_querycap() local
961 strscpy(cap->card, video->video.name, sizeof(cap->card)); in vsp1_video_querycap()
970 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_get_format() local
972 if (format->type != video->queue.type) in vsp1_video_get_format()
975 mutex_lock(&video->lock); in vsp1_video_get_format()
976 format->fmt.pix_mp = video->rwpf->format; in vsp1_video_get_format()
977 mutex_unlock(&video->lock); in vsp1_video_get_format()
986 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_try_format() local
988 if (format->type != video->queue.type) in vsp1_video_try_format()
991 return __vsp1_video_try_format(video, &format->fmt.pix_mp, NULL); in vsp1_video_try_format()
998 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_set_format() local
1002 if (format->type != video->queue.type) in vsp1_video_set_format()
1005 ret = __vsp1_video_try_format(video, &format->fmt.pix_mp, &info); in vsp1_video_set_format()
1009 mutex_lock(&video->lock); in vsp1_video_set_format()
1011 if (vb2_is_busy(&video->queue)) { in vsp1_video_set_format()
1016 video->rwpf->format = format->fmt.pix_mp; in vsp1_video_set_format()
1017 video->rwpf->fmtinfo = info; in vsp1_video_set_format()
1020 mutex_unlock(&video->lock); in vsp1_video_set_format()
1028 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_streamon() local
1029 struct media_device *mdev = &video->vsp1->media_dev; in vsp1_video_streamon()
1033 if (vb2_queue_is_busy(&video->queue, file)) in vsp1_video_streamon()
1037 * Get a pipeline for the video node and start streaming on it. No link in vsp1_video_streamon()
1043 pipe = vsp1_video_pipeline_get(video); in vsp1_video_streamon()
1049 ret = __video_device_pipeline_start(&video->video, &pipe->pipe); in vsp1_video_streamon()
1061 ret = vsp1_video_verify_format(video); in vsp1_video_streamon()
1066 ret = vb2_streamon(&video->queue, type); in vsp1_video_streamon()
1073 video_device_pipeline_stop(&video->video); in vsp1_video_streamon()
1104 struct vsp1_video *video = video_drvdata(file); in vsp1_video_open() local
1112 v4l2_fh_init(vfh, &video->video); in vsp1_video_open()
1117 ret = vsp1_device_get(video->vsp1); in vsp1_video_open()
1129 struct vsp1_video *video = video_drvdata(file); in vsp1_video_release() local
1133 vsp1_device_put(video->vsp1); in vsp1_video_release()
1235 struct vsp1_video *video; in vsp1_video_create() local
1239 video = devm_kzalloc(vsp1->dev, sizeof(*video), GFP_KERNEL); in vsp1_video_create()
1240 if (!video) in vsp1_video_create()
1243 rwpf->video = video; in vsp1_video_create()
1245 video->vsp1 = vsp1; in vsp1_video_create()
1246 video->rwpf = rwpf; in vsp1_video_create()
1250 video->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; in vsp1_video_create()
1251 video->pad.flags = MEDIA_PAD_FL_SOURCE; in vsp1_video_create()
1252 video->video.vfl_dir = VFL_DIR_TX; in vsp1_video_create()
1253 video->video.device_caps = V4L2_CAP_VIDEO_OUTPUT_MPLANE | in vsp1_video_create()
1257 video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; in vsp1_video_create()
1258 video->pad.flags = MEDIA_PAD_FL_SINK; in vsp1_video_create()
1259 video->video.vfl_dir = VFL_DIR_RX; in vsp1_video_create()
1260 video->video.device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE | in vsp1_video_create()
1264 mutex_init(&video->lock); in vsp1_video_create()
1265 spin_lock_init(&video->irqlock); in vsp1_video_create()
1266 INIT_LIST_HEAD(&video->irqqueue); in vsp1_video_create()
1269 ret = media_entity_pads_init(&video->video.entity, 1, &video->pad); in vsp1_video_create()
1277 __vsp1_video_try_format(video, &rwpf->format, &rwpf->fmtinfo); in vsp1_video_create()
1279 /* ... and the video node... */ in vsp1_video_create()
1280 video->video.v4l2_dev = &video->vsp1->v4l2_dev; in vsp1_video_create()
1281 video->video.fops = &vsp1_video_fops; in vsp1_video_create()
1282 snprintf(video->video.name, sizeof(video->video.name), "%s %s", in vsp1_video_create()
1284 video->video.vfl_type = VFL_TYPE_VIDEO; in vsp1_video_create()
1285 video->video.release = video_device_release_empty; in vsp1_video_create()
1286 video->video.ioctl_ops = &vsp1_video_ioctl_ops; in vsp1_video_create()
1288 video_set_drvdata(&video->video, video); in vsp1_video_create()
1290 video->queue.type = video->type; in vsp1_video_create()
1291 video->queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; in vsp1_video_create()
1292 video->queue.lock = &video->lock; in vsp1_video_create()
1293 video->queue.drv_priv = video; in vsp1_video_create()
1294 video->queue.buf_struct_size = sizeof(struct vsp1_vb2_buffer); in vsp1_video_create()
1295 video->queue.ops = &vsp1_video_queue_qops; in vsp1_video_create()
1296 video->queue.mem_ops = &vb2_dma_contig_memops; in vsp1_video_create()
1297 video->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; in vsp1_video_create()
1298 video->queue.dev = video->vsp1->bus_master; in vsp1_video_create()
1299 ret = vb2_queue_init(&video->queue); in vsp1_video_create()
1301 dev_err(video->vsp1->dev, "failed to initialize vb2 queue\n"); in vsp1_video_create()
1305 /* ... and register the video device. */ in vsp1_video_create()
1306 video->video.queue = &video->queue; in vsp1_video_create()
1307 ret = video_register_device(&video->video, VFL_TYPE_VIDEO, -1); in vsp1_video_create()
1309 dev_err(video->vsp1->dev, "failed to register video device\n"); in vsp1_video_create()
1313 return video; in vsp1_video_create()
1316 vsp1_video_cleanup(video); in vsp1_video_create()
1320 void vsp1_video_cleanup(struct vsp1_video *video) in vsp1_video_cleanup() argument
1322 if (video_is_registered(&video->video)) in vsp1_video_cleanup()
1323 video_unregister_device(&video->video); in vsp1_video_cleanup()
1325 media_entity_cleanup(&video->video.entity); in vsp1_video_cleanup()