Lines Matching refs:video

141 static unsigned int isp_video_mbus_to_pix(const struct isp_video *video,  in isp_video_mbus_to_pix()  argument
167 if (video->bpl_max) in isp_video_mbus_to_pix()
168 bpl = clamp(bpl, min_bpl, video->bpl_max); in isp_video_mbus_to_pix()
172 if (!video->bpl_zero_padding || bpl != min_bpl) in isp_video_mbus_to_pix()
173 bpl = ALIGN(bpl, video->bpl_alignment); in isp_video_mbus_to_pix()
207 isp_video_remote_subdev(struct isp_video *video, u32 *pad) in isp_video_remote_subdev() argument
211 remote = media_entity_remote_pad(&video->pad); in isp_video_remote_subdev()
224 static int isp_video_get_graph_data(struct isp_video *video, in isp_video_get_graph_data() argument
228 struct media_entity *entity = &video->video.entity; in isp_video_get_graph_data()
243 if (entity == &video->video.entity) in isp_video_get_graph_data()
250 if (__video->type != video->type) in isp_video_get_graph_data()
256 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { in isp_video_get_graph_data()
258 pipe->output = video; in isp_video_get_graph_data()
263 pipe->input = video; in isp_video_get_graph_data()
271 __isp_video_get_format(struct isp_video *video, struct v4l2_format *format) in __isp_video_get_format() argument
278 subdev = isp_video_remote_subdev(video, &pad); in __isp_video_get_format()
285 mutex_lock(&video->mutex); in __isp_video_get_format()
287 mutex_unlock(&video->mutex); in __isp_video_get_format()
292 format->type = video->type; in __isp_video_get_format()
293 return isp_video_mbus_to_pix(video, &fmt.format, &format->fmt.pix); in __isp_video_get_format()
297 isp_video_check_format(struct isp_video *video, struct isp_video_fh *vfh) in isp_video_check_format() argument
303 ret = __isp_video_get_format(video, &format); in isp_video_check_format()
328 struct isp_video *video = vfh->video; in isp_video_queue_setup() local
336 alloc_ctxs[0] = video->alloc_ctx; in isp_video_queue_setup()
338 *count = min(*count, video->capture_mem / PAGE_ALIGN(sizes[0])); in isp_video_queue_setup()
348 struct isp_video *video = vfh->video; in isp_video_buffer_prepare() local
357 if (unlikely(video->error)) in isp_video_buffer_prepare()
362 dev_dbg(video->isp->dev, in isp_video_buffer_prepare()
388 struct isp_video *video = vfh->video; in isp_video_buffer_queue() local
389 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity); in isp_video_buffer_queue()
395 spin_lock_irqsave(&video->irqlock, flags); in isp_video_buffer_queue()
397 if (unlikely(video->error)) { in isp_video_buffer_queue()
399 spin_unlock_irqrestore(&video->irqlock, flags); in isp_video_buffer_queue()
403 empty = list_empty(&video->dmaqueue); in isp_video_buffer_queue()
404 list_add_tail(&buffer->irqlist, &video->dmaqueue); in isp_video_buffer_queue()
406 spin_unlock_irqrestore(&video->irqlock, flags); in isp_video_buffer_queue()
409 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) in isp_video_buffer_queue()
416 video->ops->queue(video, buffer); in isp_video_buffer_queue()
417 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_QUEUED; in isp_video_buffer_queue()
452 struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video) in omap3isp_video_buffer_next() argument
454 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity); in omap3isp_video_buffer_next()
459 spin_lock_irqsave(&video->irqlock, flags); in omap3isp_video_buffer_next()
460 if (WARN_ON(list_empty(&video->dmaqueue))) { in omap3isp_video_buffer_next()
461 spin_unlock_irqrestore(&video->irqlock, flags); in omap3isp_video_buffer_next()
465 buf = list_first_entry(&video->dmaqueue, struct isp_buffer, in omap3isp_video_buffer_next()
468 spin_unlock_irqrestore(&video->irqlock, flags); in omap3isp_video_buffer_next()
478 if (video == pipe->output && !pipe->do_propagation) in omap3isp_video_buffer_next()
490 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->error) { in omap3isp_video_buffer_next()
499 spin_lock_irqsave(&video->irqlock, flags); in omap3isp_video_buffer_next()
501 if (list_empty(&video->dmaqueue)) { in omap3isp_video_buffer_next()
502 spin_unlock_irqrestore(&video->irqlock, flags); in omap3isp_video_buffer_next()
504 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) in omap3isp_video_buffer_next()
513 if (video->pipe.stream_state == ISP_PIPELINE_STREAM_CONTINUOUS) in omap3isp_video_buffer_next()
514 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN; in omap3isp_video_buffer_next()
519 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->input != NULL) { in omap3isp_video_buffer_next()
525 buf = list_first_entry(&video->dmaqueue, struct isp_buffer, in omap3isp_video_buffer_next()
528 spin_unlock_irqrestore(&video->irqlock, flags); in omap3isp_video_buffer_next()
540 void omap3isp_video_cancel_stream(struct isp_video *video) in omap3isp_video_cancel_stream() argument
544 spin_lock_irqsave(&video->irqlock, flags); in omap3isp_video_cancel_stream()
546 while (!list_empty(&video->dmaqueue)) { in omap3isp_video_cancel_stream()
549 buf = list_first_entry(&video->dmaqueue, in omap3isp_video_cancel_stream()
555 video->error = true; in omap3isp_video_cancel_stream()
557 spin_unlock_irqrestore(&video->irqlock, flags); in omap3isp_video_cancel_stream()
570 void omap3isp_video_resume(struct isp_video *video, int continuous) in omap3isp_video_resume() argument
574 if (continuous && video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { in omap3isp_video_resume()
575 mutex_lock(&video->queue_lock); in omap3isp_video_resume()
576 vb2_discard_done(video->queue); in omap3isp_video_resume()
577 mutex_unlock(&video->queue_lock); in omap3isp_video_resume()
580 if (!list_empty(&video->dmaqueue)) { in omap3isp_video_resume()
581 buf = list_first_entry(&video->dmaqueue, in omap3isp_video_resume()
583 video->ops->queue(video, buf); in omap3isp_video_resume()
584 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_QUEUED; in omap3isp_video_resume()
587 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN; in omap3isp_video_resume()
598 struct isp_video *video = video_drvdata(file); in isp_video_querycap() local
601 strlcpy(cap->card, video->video.name, sizeof(cap->card)); in isp_video_querycap()
607 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) in isp_video_querycap()
619 struct isp_video *video = video_drvdata(file); in isp_video_get_format() local
621 if (format->type != video->type) in isp_video_get_format()
624 mutex_lock(&video->mutex); in isp_video_get_format()
626 mutex_unlock(&video->mutex); in isp_video_get_format()
635 struct isp_video *video = video_drvdata(file); in isp_video_set_format() local
638 if (format->type != video->type) in isp_video_set_format()
648 if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) in isp_video_set_format()
661 if (video != &video->isp->isp_ccdc.video_out) in isp_video_set_format()
680 isp_video_mbus_to_pix(video, &fmt, &format->fmt.pix); in isp_video_set_format()
682 mutex_lock(&video->mutex); in isp_video_set_format()
684 mutex_unlock(&video->mutex); in isp_video_set_format()
692 struct isp_video *video = video_drvdata(file); in isp_video_try_format() local
698 if (format->type != video->type) in isp_video_try_format()
701 subdev = isp_video_remote_subdev(video, &pad); in isp_video_try_format()
713 isp_video_mbus_to_pix(video, &fmt.format, &format->fmt.pix); in isp_video_try_format()
720 struct isp_video *video = video_drvdata(file); in isp_video_cropcap() local
724 subdev = isp_video_remote_subdev(video, NULL); in isp_video_cropcap()
728 mutex_lock(&video->mutex); in isp_video_cropcap()
729 ret = v4l2_subdev_call(subdev, video, cropcap, cropcap); in isp_video_cropcap()
730 mutex_unlock(&video->mutex); in isp_video_cropcap()
738 struct isp_video *video = video_drvdata(file); in isp_video_get_crop() local
744 subdev = isp_video_remote_subdev(video, &pad); in isp_video_get_crop()
751 ret = v4l2_subdev_call(subdev, video, g_crop, crop); in isp_video_get_crop()
772 struct isp_video *video = video_drvdata(file); in isp_video_set_crop() local
776 subdev = isp_video_remote_subdev(video, NULL); in isp_video_set_crop()
780 mutex_lock(&video->mutex); in isp_video_set_crop()
781 ret = v4l2_subdev_call(subdev, video, s_crop, crop); in isp_video_set_crop()
782 mutex_unlock(&video->mutex); in isp_video_set_crop()
791 struct isp_video *video = video_drvdata(file); in isp_video_get_param() local
793 if (video->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || in isp_video_get_param()
794 video->type != a->type) in isp_video_get_param()
809 struct isp_video *video = video_drvdata(file); in isp_video_set_param() local
811 if (video->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || in isp_video_set_param()
812 video->type != a->type) in isp_video_set_param()
827 struct isp_video *video = video_drvdata(file); in isp_video_reqbufs() local
830 mutex_lock(&video->queue_lock); in isp_video_reqbufs()
832 mutex_unlock(&video->queue_lock); in isp_video_reqbufs()
841 struct isp_video *video = video_drvdata(file); in isp_video_querybuf() local
844 mutex_lock(&video->queue_lock); in isp_video_querybuf()
846 mutex_unlock(&video->queue_lock); in isp_video_querybuf()
855 struct isp_video *video = video_drvdata(file); in isp_video_qbuf() local
858 mutex_lock(&video->queue_lock); in isp_video_qbuf()
860 mutex_unlock(&video->queue_lock); in isp_video_qbuf()
869 struct isp_video *video = video_drvdata(file); in isp_video_dqbuf() local
872 mutex_lock(&video->queue_lock); in isp_video_dqbuf()
874 mutex_unlock(&video->queue_lock); in isp_video_dqbuf()
879 static int isp_video_check_external_subdevs(struct isp_video *video, in isp_video_check_external_subdevs() argument
882 struct isp_device *isp = video->isp; in isp_video_check_external_subdevs()
1005 struct isp_video *video = video_drvdata(file); in isp_video_streamon() local
1011 if (type != video->type) in isp_video_streamon()
1014 mutex_lock(&video->stream_lock); in isp_video_streamon()
1019 pipe = video->video.entity.pipe in isp_video_streamon()
1020 ? to_isp_pipeline(&video->video.entity) : &video->pipe; in isp_video_streamon()
1025 pipe->l3_ick = clk_get_rate(video->isp->clock[ISP_CLK_L3_ICK]); in isp_video_streamon()
1028 ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe); in isp_video_streamon()
1035 ret = isp_video_check_format(video, vfh); in isp_video_streamon()
1039 video->bpl_padding = ret; in isp_video_streamon()
1040 video->bpl_value = vfh->format.fmt.pix.bytesperline; in isp_video_streamon()
1042 ret = isp_video_get_graph_data(video, pipe); in isp_video_streamon()
1046 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) in isp_video_streamon()
1051 ret = isp_video_check_external_subdevs(video, pipe); in isp_video_streamon()
1066 if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) in isp_video_streamon()
1069 video->queue = &vfh->queue; in isp_video_streamon()
1070 INIT_LIST_HEAD(&video->dmaqueue); in isp_video_streamon()
1074 mutex_lock(&video->queue_lock); in isp_video_streamon()
1076 mutex_unlock(&video->queue_lock); in isp_video_streamon()
1089 spin_lock_irqsave(&video->irqlock, flags); in isp_video_streamon()
1090 if (list_empty(&video->dmaqueue)) in isp_video_streamon()
1091 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN; in isp_video_streamon()
1092 spin_unlock_irqrestore(&video->irqlock, flags); in isp_video_streamon()
1095 mutex_unlock(&video->stream_lock); in isp_video_streamon()
1099 mutex_lock(&video->queue_lock); in isp_video_streamon()
1101 mutex_unlock(&video->queue_lock); in isp_video_streamon()
1103 media_entity_pipeline_stop(&video->video.entity); in isp_video_streamon()
1113 INIT_LIST_HEAD(&video->dmaqueue); in isp_video_streamon()
1114 video->queue = NULL; in isp_video_streamon()
1116 mutex_unlock(&video->stream_lock); in isp_video_streamon()
1124 struct isp_video *video = video_drvdata(file); in isp_video_streamoff() local
1125 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity); in isp_video_streamoff()
1130 if (type != video->type) in isp_video_streamoff()
1133 mutex_lock(&video->stream_lock); in isp_video_streamoff()
1136 mutex_lock(&video->queue_lock); in isp_video_streamoff()
1138 mutex_unlock(&video->queue_lock); in isp_video_streamoff()
1144 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) in isp_video_streamoff()
1157 omap3isp_video_cancel_stream(video); in isp_video_streamoff()
1159 mutex_lock(&video->queue_lock); in isp_video_streamoff()
1161 mutex_unlock(&video->queue_lock); in isp_video_streamoff()
1162 video->queue = NULL; in isp_video_streamoff()
1163 video->error = false; in isp_video_streamoff()
1166 media_entity_pipeline_stop(&video->video.entity); in isp_video_streamoff()
1169 mutex_unlock(&video->stream_lock); in isp_video_streamoff()
1229 struct isp_video *video = video_drvdata(file); in isp_video_open() local
1238 v4l2_fh_init(&handle->vfh, &video->video); in isp_video_open()
1242 if (omap3isp_get(video->isp) == NULL) { in isp_video_open()
1247 ret = omap3isp_pipeline_pm_use(&video->video.entity, 1); in isp_video_open()
1249 omap3isp_put(video->isp); in isp_video_open()
1254 queue->type = video->type; in isp_video_open()
1264 omap3isp_put(video->isp); in isp_video_open()
1269 handle->format.type = video->type; in isp_video_open()
1272 handle->video = video; in isp_video_open()
1286 struct isp_video *video = video_drvdata(file); in isp_video_release() local
1291 isp_video_streamoff(file, vfh, video->type); in isp_video_release()
1293 mutex_lock(&video->queue_lock); in isp_video_release()
1295 mutex_unlock(&video->queue_lock); in isp_video_release()
1297 omap3isp_pipeline_pm_use(&video->video.entity, 0); in isp_video_release()
1304 omap3isp_put(video->isp); in isp_video_release()
1312 struct isp_video *video = video_drvdata(file); in isp_video_poll() local
1315 mutex_lock(&video->queue_lock); in isp_video_poll()
1317 mutex_unlock(&video->queue_lock); in isp_video_poll()
1345 int omap3isp_video_init(struct isp_video *video, const char *name) in omap3isp_video_init() argument
1350 switch (video->type) { in omap3isp_video_init()
1353 video->pad.flags = MEDIA_PAD_FL_SINK in omap3isp_video_init()
1358 video->pad.flags = MEDIA_PAD_FL_SOURCE in omap3isp_video_init()
1360 video->video.vfl_dir = VFL_DIR_TX; in omap3isp_video_init()
1367 video->alloc_ctx = vb2_dma_contig_init_ctx(video->isp->dev); in omap3isp_video_init()
1368 if (IS_ERR(video->alloc_ctx)) in omap3isp_video_init()
1369 return PTR_ERR(video->alloc_ctx); in omap3isp_video_init()
1371 ret = media_entity_init(&video->video.entity, 1, &video->pad, 0); in omap3isp_video_init()
1373 vb2_dma_contig_cleanup_ctx(video->alloc_ctx); in omap3isp_video_init()
1377 mutex_init(&video->mutex); in omap3isp_video_init()
1378 atomic_set(&video->active, 0); in omap3isp_video_init()
1380 spin_lock_init(&video->pipe.lock); in omap3isp_video_init()
1381 mutex_init(&video->stream_lock); in omap3isp_video_init()
1382 mutex_init(&video->queue_lock); in omap3isp_video_init()
1383 spin_lock_init(&video->irqlock); in omap3isp_video_init()
1386 if (video->ops == NULL) in omap3isp_video_init()
1387 video->ops = &isp_video_dummy_ops; in omap3isp_video_init()
1389 video->video.fops = &isp_video_fops; in omap3isp_video_init()
1390 snprintf(video->video.name, sizeof(video->video.name), in omap3isp_video_init()
1392 video->video.vfl_type = VFL_TYPE_GRABBER; in omap3isp_video_init()
1393 video->video.release = video_device_release_empty; in omap3isp_video_init()
1394 video->video.ioctl_ops = &isp_video_ioctl_ops; in omap3isp_video_init()
1395 video->pipe.stream_state = ISP_PIPELINE_STREAM_STOPPED; in omap3isp_video_init()
1397 video_set_drvdata(&video->video, video); in omap3isp_video_init()
1402 void omap3isp_video_cleanup(struct isp_video *video) in omap3isp_video_cleanup() argument
1404 vb2_dma_contig_cleanup_ctx(video->alloc_ctx); in omap3isp_video_cleanup()
1405 media_entity_cleanup(&video->video.entity); in omap3isp_video_cleanup()
1406 mutex_destroy(&video->queue_lock); in omap3isp_video_cleanup()
1407 mutex_destroy(&video->stream_lock); in omap3isp_video_cleanup()
1408 mutex_destroy(&video->mutex); in omap3isp_video_cleanup()
1411 int omap3isp_video_register(struct isp_video *video, struct v4l2_device *vdev) in omap3isp_video_register() argument
1415 video->video.v4l2_dev = vdev; in omap3isp_video_register()
1417 ret = video_register_device(&video->video, VFL_TYPE_GRABBER, -1); in omap3isp_video_register()
1419 dev_err(video->isp->dev, in omap3isp_video_register()
1426 void omap3isp_video_unregister(struct isp_video *video) in omap3isp_video_unregister() argument
1428 if (video_is_registered(&video->video)) in omap3isp_video_unregister()
1429 video_unregister_device(&video->video); in omap3isp_video_unregister()