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
71 subdev = vsp1_video_remote_subdev(&video->pad, &fmt.pad); in vsp1_video_verify_format()
79 if (video->rwpf->fmtinfo->mbus != fmt.format.code || in vsp1_video_verify_format()
80 video->rwpf->format.height != fmt.format.height || in vsp1_video_verify_format()
81 video->rwpf->format.width != fmt.format.width) { in vsp1_video_verify_format()
82 dev_dbg(video->vsp1->dev, in vsp1_video_verify_format()
84 video->rwpf->fmtinfo->mbus, video->rwpf->format.width, in vsp1_video_verify_format()
85 video->rwpf->format.height, fmt.format.code, in vsp1_video_verify_format()
93 static int __vsp1_video_try_format(struct vsp1_video *video, in __vsp1_video_try_format() argument
125 info = vsp1_get_format_info(video->vsp1, pix->pixelformat); in __vsp1_video_try_format()
127 info = vsp1_get_format_info(video->vsp1, VSP1_VIDEO_DEF_FORMAT); in __vsp1_video_try_format()
187 * @video: the video node
195 vsp1_video_complete_buffer(struct vsp1_video *video) in vsp1_video_complete_buffer() argument
197 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_complete_buffer()
203 spin_lock_irqsave(&video->irqlock, flags); in vsp1_video_complete_buffer()
205 if (list_empty(&video->irqqueue)) { in vsp1_video_complete_buffer()
206 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_complete_buffer()
210 done = list_first_entry(&video->irqqueue, in vsp1_video_complete_buffer()
215 if (!list_empty(&video->irqqueue)) in vsp1_video_complete_buffer()
216 next = list_first_entry(&video->irqqueue, in vsp1_video_complete_buffer()
219 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_complete_buffer()
234 struct vsp1_video *video = rwpf->video; in vsp1_video_frame_end() local
237 buf = vsp1_video_complete_buffer(video); in vsp1_video_frame_end()
241 video->rwpf->mem = buf->mem; in vsp1_video_frame_end()
242 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_frame_end()
324 /* Complete buffers on all video nodes. */ in vsp1_video_pipeline_frame_end()
376 /* We've reached a video node, that shouldn't have happened. */ in vsp1_video_pipeline_build_branch()
440 struct vsp1_video *video) in vsp1_video_pipeline_build() argument
443 struct media_entity *entity = &video->video.entity; in vsp1_video_pipeline_build()
448 /* Walk the graph to locate the entities and video nodes. */ in vsp1_video_pipeline_build()
472 rwpf->video->pipe_index = ++pipe->num_inputs; in vsp1_video_pipeline_build()
478 rwpf->video->pipe_index = 0; in vsp1_video_pipeline_build()
513 for (i = 0; i < video->vsp1->info->rpf_count; ++i) { in vsp1_video_pipeline_build()
527 struct vsp1_video *video) in vsp1_video_pipeline_init() argument
535 ret = vsp1_video_pipeline_build(pipe, video); in vsp1_video_pipeline_init()
539 vsp1_pipeline_dump(pipe, "video"); in vsp1_video_pipeline_init()
544 static struct vsp1_pipeline *vsp1_video_pipeline_get(struct vsp1_video *video) in vsp1_video_pipeline_get() argument
550 * Get a pipeline object for the video node. If a pipeline has already in vsp1_video_pipeline_get()
555 if (!video->rwpf->entity.pipe) { in vsp1_video_pipeline_get()
560 ret = vsp1_video_pipeline_init(pipe, video); in vsp1_video_pipeline_get()
567 pipe = video->rwpf->entity.pipe; in vsp1_video_pipeline_get()
600 struct vsp1_video *video = vb2_get_drv_priv(vq); in vsp1_video_queue_setup() local
601 const struct v4l2_pix_format_mplane *format = &video->rwpf->format; in vsp1_video_queue_setup()
625 struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue); in vsp1_video_buffer_prepare() local
627 const struct v4l2_pix_format_mplane *format = &video->rwpf->format; in vsp1_video_buffer_prepare()
649 struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue); in vsp1_video_buffer_queue() local
650 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_buffer_queue()
655 spin_lock_irqsave(&video->irqlock, flags); in vsp1_video_buffer_queue()
656 empty = list_empty(&video->irqqueue); in vsp1_video_buffer_queue()
657 list_add_tail(&buf->queue, &video->irqqueue); in vsp1_video_buffer_queue()
658 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_buffer_queue()
665 video->rwpf->mem = buf->mem; in vsp1_video_buffer_queue()
666 pipe->buffers_ready |= 1 << video->pipe_index; in vsp1_video_buffer_queue()
668 if (vb2_start_streaming_called(&video->queue) && in vsp1_video_buffer_queue()
772 static void vsp1_video_release_buffers(struct vsp1_video *video) in vsp1_video_release_buffers() argument
778 spin_lock_irqsave(&video->irqlock, flags); in vsp1_video_release_buffers()
779 list_for_each_entry(buffer, &video->irqqueue, queue) in vsp1_video_release_buffers()
781 INIT_LIST_HEAD(&video->irqqueue); in vsp1_video_release_buffers()
782 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_release_buffers()
789 /* Release any cached configuration from our output video. */ in vsp1_video_cleanup_pipeline()
801 struct vsp1_video *video = vb2_get_drv_priv(vq); in vsp1_video_start_streaming() local
802 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_start_streaming()
811 vsp1_video_release_buffers(video); in vsp1_video_start_streaming()
843 struct vsp1_video *video = vb2_get_drv_priv(vq); in vsp1_video_stop_streaming() local
844 struct vsp1_pipeline *pipe = video->rwpf->entity.pipe; in vsp1_video_stop_streaming()
850 * by a QBUF on the video node on the other side of the pipeline. in vsp1_video_stop_streaming()
852 spin_lock_irqsave(&video->irqlock, flags); in vsp1_video_stop_streaming()
853 pipe->buffers_ready &= ~(1 << video->pipe_index); in vsp1_video_stop_streaming()
854 spin_unlock_irqrestore(&video->irqlock, flags); in vsp1_video_stop_streaming()
861 dev_err(video->vsp1->dev, "pipeline stop timeout\n"); in vsp1_video_stop_streaming()
867 video_device_pipeline_stop(&video->video); in vsp1_video_stop_streaming()
868 vsp1_video_release_buffers(video); in vsp1_video_stop_streaming()
888 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_querycap() local
896 strscpy(cap->card, video->video.name, sizeof(cap->card)); in vsp1_video_querycap()
905 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_get_format() local
907 if (format->type != video->queue.type) in vsp1_video_get_format()
910 mutex_lock(&video->lock); in vsp1_video_get_format()
911 format->fmt.pix_mp = video->rwpf->format; in vsp1_video_get_format()
912 mutex_unlock(&video->lock); in vsp1_video_get_format()
921 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_try_format() local
923 if (format->type != video->queue.type) in vsp1_video_try_format()
926 return __vsp1_video_try_format(video, &format->fmt.pix_mp, NULL); in vsp1_video_try_format()
933 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_set_format() local
937 if (format->type != video->queue.type) in vsp1_video_set_format()
940 ret = __vsp1_video_try_format(video, &format->fmt.pix_mp, &info); in vsp1_video_set_format()
944 mutex_lock(&video->lock); in vsp1_video_set_format()
946 if (vb2_is_busy(&video->queue)) { in vsp1_video_set_format()
951 video->rwpf->format = format->fmt.pix_mp; in vsp1_video_set_format()
952 video->rwpf->fmtinfo = info; in vsp1_video_set_format()
955 mutex_unlock(&video->lock); in vsp1_video_set_format()
963 struct vsp1_video *video = to_vsp1_video(vfh->vdev); in vsp1_video_streamon() local
964 struct media_device *mdev = &video->vsp1->media_dev; in vsp1_video_streamon()
968 if (vb2_queue_is_busy(&video->queue, file)) in vsp1_video_streamon()
972 * Get a pipeline for the video node and start streaming on it. No link in vsp1_video_streamon()
978 pipe = vsp1_video_pipeline_get(video); in vsp1_video_streamon()
984 ret = __video_device_pipeline_start(&video->video, &pipe->pipe); in vsp1_video_streamon()
996 ret = vsp1_video_verify_format(video); in vsp1_video_streamon()
1001 ret = vb2_streamon(&video->queue, type); in vsp1_video_streamon()
1008 video_device_pipeline_stop(&video->video); in vsp1_video_streamon()
1039 struct vsp1_video *video = video_drvdata(file); in vsp1_video_open() local
1047 v4l2_fh_init(vfh, &video->video); in vsp1_video_open()
1052 ret = vsp1_device_get(video->vsp1); in vsp1_video_open()
1064 struct vsp1_video *video = video_drvdata(file); in vsp1_video_release() local
1068 vsp1_device_put(video->vsp1); in vsp1_video_release()
1091 * manually. That would however break userspace that start one video in vsp1_video_link_validate()
1092 * device before configures formats on other video devices in the in vsp1_video_link_validate()
1191 struct vsp1_video *video; in vsp1_video_create() local
1195 video = devm_kzalloc(vsp1->dev, sizeof(*video), GFP_KERNEL); in vsp1_video_create()
1196 if (!video) in vsp1_video_create()
1199 rwpf->video = video; in vsp1_video_create()
1201 video->vsp1 = vsp1; in vsp1_video_create()
1202 video->rwpf = rwpf; in vsp1_video_create()
1206 video->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; in vsp1_video_create()
1207 video->pad.flags = MEDIA_PAD_FL_SOURCE; in vsp1_video_create()
1208 video->video.vfl_dir = VFL_DIR_TX; in vsp1_video_create()
1209 video->video.device_caps = V4L2_CAP_VIDEO_OUTPUT_MPLANE | in vsp1_video_create()
1213 video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; in vsp1_video_create()
1214 video->pad.flags = MEDIA_PAD_FL_SINK; in vsp1_video_create()
1215 video->video.vfl_dir = VFL_DIR_RX; in vsp1_video_create()
1216 video->video.device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE | in vsp1_video_create()
1220 mutex_init(&video->lock); in vsp1_video_create()
1221 spin_lock_init(&video->irqlock); in vsp1_video_create()
1222 INIT_LIST_HEAD(&video->irqqueue); in vsp1_video_create()
1225 ret = media_entity_pads_init(&video->video.entity, 1, &video->pad); in vsp1_video_create()
1233 __vsp1_video_try_format(video, &rwpf->format, &rwpf->fmtinfo); in vsp1_video_create()
1235 /* ... and the video node... */ in vsp1_video_create()
1236 video->video.v4l2_dev = &video->vsp1->v4l2_dev; in vsp1_video_create()
1237 video->video.entity.ops = &vsp1_video_media_ops; in vsp1_video_create()
1238 video->video.fops = &vsp1_video_fops; in vsp1_video_create()
1239 snprintf(video->video.name, sizeof(video->video.name), "%s %s", in vsp1_video_create()
1241 video->video.vfl_type = VFL_TYPE_VIDEO; in vsp1_video_create()
1242 video->video.release = video_device_release_empty; in vsp1_video_create()
1243 video->video.ioctl_ops = &vsp1_video_ioctl_ops; in vsp1_video_create()
1245 video_set_drvdata(&video->video, video); in vsp1_video_create()
1247 video->queue.type = video->type; in vsp1_video_create()
1248 video->queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; in vsp1_video_create()
1249 video->queue.lock = &video->lock; in vsp1_video_create()
1250 video->queue.drv_priv = video; in vsp1_video_create()
1251 video->queue.buf_struct_size = sizeof(struct vsp1_vb2_buffer); in vsp1_video_create()
1252 video->queue.ops = &vsp1_video_queue_qops; in vsp1_video_create()
1253 video->queue.mem_ops = &vb2_dma_contig_memops; in vsp1_video_create()
1254 video->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; in vsp1_video_create()
1255 video->queue.dev = video->vsp1->bus_master; in vsp1_video_create()
1256 ret = vb2_queue_init(&video->queue); in vsp1_video_create()
1258 dev_err(video->vsp1->dev, "failed to initialize vb2 queue\n"); in vsp1_video_create()
1262 /* ... and register the video device. */ in vsp1_video_create()
1263 video->video.queue = &video->queue; in vsp1_video_create()
1264 ret = video_register_device(&video->video, VFL_TYPE_VIDEO, -1); in vsp1_video_create()
1266 dev_err(video->vsp1->dev, "failed to register video device\n"); in vsp1_video_create()
1270 return video; in vsp1_video_create()
1273 vsp1_video_cleanup(video); in vsp1_video_create()
1277 void vsp1_video_cleanup(struct vsp1_video *video) in vsp1_video_cleanup() argument
1279 if (video_is_registered(&video->video)) in vsp1_video_cleanup()
1280 video_unregister_device(&video->video); in vsp1_video_cleanup()
1282 media_entity_cleanup(&video->video.entity); in vsp1_video_cleanup()