Lines Matching +full:line +full:- +full:orders

1 // SPDX-License-Identifier: GPL-2.0-only
5 * TI OMAP3 ISP - Generic video node
7 * Copyright (C) 2009-2010 Nokia Corporation
22 #include <media/v4l2-dev.h>
23 #include <media/v4l2-ioctl.h>
24 #include <media/v4l2-mc.h>
25 #include <media/videobuf2-dma-contig.h>
31 /* -----------------------------------------------------------------------------
37 * corresponding in-memory formats to the table below!!!
128 * isp_video_mbus_to_pix - Convert v4l2_mbus_framefmt to v4l2_pix_format
135 * per line value in the pix format and information from the video instance.
137 * Return the number of padding bytes at end of line.
143 unsigned int bpl = pix->bytesperline; in isp_video_mbus_to_pix()
148 pix->width = mbus->width; in isp_video_mbus_to_pix()
149 pix->height = mbus->height; in isp_video_mbus_to_pix()
152 if (formats[i].code == mbus->code) in isp_video_mbus_to_pix()
159 min_bpl = pix->width * formats[i].bpp; in isp_video_mbus_to_pix()
161 /* Clamp the requested bytes per line value. If the maximum bytes per in isp_video_mbus_to_pix()
162 * line value is zero, the module doesn't support user configurable line in isp_video_mbus_to_pix()
165 if (video->bpl_max) in isp_video_mbus_to_pix()
166 bpl = clamp(bpl, min_bpl, video->bpl_max); in isp_video_mbus_to_pix()
170 if (!video->bpl_zero_padding || bpl != min_bpl) in isp_video_mbus_to_pix()
171 bpl = ALIGN(bpl, video->bpl_alignment); in isp_video_mbus_to_pix()
173 pix->pixelformat = formats[i].pixelformat; in isp_video_mbus_to_pix()
174 pix->bytesperline = bpl; in isp_video_mbus_to_pix()
175 pix->sizeimage = pix->bytesperline * pix->height; in isp_video_mbus_to_pix()
176 pix->colorspace = mbus->colorspace; in isp_video_mbus_to_pix()
177 pix->field = mbus->field; in isp_video_mbus_to_pix()
179 return bpl - min_bpl; in isp_video_mbus_to_pix()
188 mbus->width = pix->width; in isp_video_pix_to_mbus()
189 mbus->height = pix->height; in isp_video_pix_to_mbus()
194 for (i = 0; i < ARRAY_SIZE(formats) - 1; ++i) { in isp_video_pix_to_mbus()
195 if (formats[i].pixelformat == pix->pixelformat) in isp_video_pix_to_mbus()
199 mbus->code = formats[i].code; in isp_video_pix_to_mbus()
200 mbus->colorspace = pix->colorspace; in isp_video_pix_to_mbus()
201 mbus->field = pix->field; in isp_video_pix_to_mbus()
209 remote = media_pad_remote_pad_first(&video->pad); in isp_video_remote_subdev()
211 if (!remote || !is_media_entity_v4l2_subdev(remote->entity)) in isp_video_remote_subdev()
215 *pad = remote->index; in isp_video_remote_subdev()
217 return media_entity_to_v4l2_subdev(remote->entity); in isp_video_remote_subdev()
229 ret = media_pipeline_entity_iter_init(&pipe->pipe, &iter); in isp_video_get_graph_data()
233 media_pipeline_for_each_entity(&pipe->pipe, &iter, entity) { in isp_video_get_graph_data()
236 media_entity_enum_set(&pipe->ent_enum, entity); in isp_video_get_graph_data()
241 if (entity == &video->video.entity) in isp_video_get_graph_data()
248 if (__video->type != video->type) in isp_video_get_graph_data()
254 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { in isp_video_get_graph_data()
255 pipe->input = far_end; in isp_video_get_graph_data()
256 pipe->output = video; in isp_video_get_graph_data()
259 return -EPIPE; in isp_video_get_graph_data()
261 pipe->input = video; in isp_video_get_graph_data()
262 pipe->output = far_end; in isp_video_get_graph_data()
280 return -EINVAL; in __isp_video_get_format()
284 mutex_lock(&video->mutex); in __isp_video_get_format()
286 mutex_unlock(&video->mutex); in __isp_video_get_format()
291 format->type = video->type; in __isp_video_get_format()
292 return isp_video_mbus_to_pix(video, &fmt.format, &format->fmt.pix); in __isp_video_get_format()
301 memcpy(&format, &vfh->format, sizeof(format)); in isp_video_check_format()
306 if (vfh->format.fmt.pix.pixelformat != format.fmt.pix.pixelformat || in isp_video_check_format()
307 vfh->format.fmt.pix.height != format.fmt.pix.height || in isp_video_check_format()
308 vfh->format.fmt.pix.width != format.fmt.pix.width || in isp_video_check_format()
309 vfh->format.fmt.pix.bytesperline != format.fmt.pix.bytesperline || in isp_video_check_format()
310 vfh->format.fmt.pix.sizeimage != format.fmt.pix.sizeimage || in isp_video_check_format()
311 vfh->format.fmt.pix.field != format.fmt.pix.field) in isp_video_check_format()
312 return -EINVAL; in isp_video_check_format()
317 /* -----------------------------------------------------------------------------
326 struct isp_video *video = vfh->video; in isp_video_queue_setup()
330 sizes[0] = vfh->format.fmt.pix.sizeimage; in isp_video_queue_setup()
332 return -EINVAL; in isp_video_queue_setup()
334 *count = min(*count, video->capture_mem / PAGE_ALIGN(sizes[0])); in isp_video_queue_setup()
342 struct isp_video_fh *vfh = vb2_get_drv_priv(buf->vb2_queue); in isp_video_buffer_prepare()
344 struct isp_video *video = vfh->video; in isp_video_buffer_prepare()
353 if (unlikely(video->error)) in isp_video_buffer_prepare()
354 return -EIO; in isp_video_buffer_prepare()
358 dev_dbg(video->isp->dev, in isp_video_buffer_prepare()
360 return -EINVAL; in isp_video_buffer_prepare()
363 vb2_set_plane_payload(&buffer->vb.vb2_buf, 0, in isp_video_buffer_prepare()
364 vfh->format.fmt.pix.sizeimage); in isp_video_buffer_prepare()
365 buffer->dma = addr; in isp_video_buffer_prepare()
371 * isp_video_buffer_queue - Add buffer to streaming queue
374 * In memory-to-memory mode, start streaming on the pipeline if buffers are
382 struct isp_video_fh *vfh = vb2_get_drv_priv(buf->vb2_queue); in isp_video_buffer_queue()
384 struct isp_video *video = vfh->video; in isp_video_buffer_queue()
385 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity); in isp_video_buffer_queue()
391 spin_lock_irqsave(&video->irqlock, flags); in isp_video_buffer_queue()
393 if (unlikely(video->error)) { in isp_video_buffer_queue()
394 vb2_buffer_done(&buffer->vb.vb2_buf, VB2_BUF_STATE_ERROR); in isp_video_buffer_queue()
395 spin_unlock_irqrestore(&video->irqlock, flags); in isp_video_buffer_queue()
399 empty = list_empty(&video->dmaqueue); in isp_video_buffer_queue()
400 list_add_tail(&buffer->irqlist, &video->dmaqueue); in isp_video_buffer_queue()
402 spin_unlock_irqrestore(&video->irqlock, flags); in isp_video_buffer_queue()
405 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) in isp_video_buffer_queue()
410 spin_lock_irqsave(&pipe->lock, flags); in isp_video_buffer_queue()
411 pipe->state |= state; in isp_video_buffer_queue()
412 video->ops->queue(video, buffer); in isp_video_buffer_queue()
413 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_QUEUED; in isp_video_buffer_queue()
417 pipe->state |= ISP_PIPELINE_STREAM; in isp_video_buffer_queue()
418 spin_unlock_irqrestore(&pipe->lock, flags); in isp_video_buffer_queue()
427 * omap3isp_video_return_buffers - Return all queued buffers to videobuf2
440 while (!list_empty(&video->dmaqueue)) { in omap3isp_video_return_buffers()
443 buf = list_first_entry(&video->dmaqueue, in omap3isp_video_return_buffers()
445 list_del(&buf->irqlist); in omap3isp_video_return_buffers()
446 vb2_buffer_done(&buf->vb.vb2_buf, state); in omap3isp_video_return_buffers()
454 struct isp_video *video = vfh->video; in isp_video_start_streaming()
455 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity); in isp_video_start_streaming()
459 /* In sensor-to-memory mode, the stream can be started synchronously in isp_video_start_streaming()
460 * to the stream on command. In memory-to-memory mode, it will be in isp_video_start_streaming()
463 if (pipe->input) in isp_video_start_streaming()
469 spin_lock_irqsave(&video->irqlock, flags); in isp_video_start_streaming()
471 spin_unlock_irqrestore(&video->irqlock, flags); in isp_video_start_streaming()
475 spin_lock_irqsave(&video->irqlock, flags); in isp_video_start_streaming()
476 if (list_empty(&video->dmaqueue)) in isp_video_start_streaming()
477 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN; in isp_video_start_streaming()
478 spin_unlock_irqrestore(&video->irqlock, flags); in isp_video_start_streaming()
486 struct isp_video *video = vfh->video; in omap3isp_wait_prepare()
488 mutex_unlock(&video->queue_lock); in omap3isp_wait_prepare()
494 struct isp_video *video = vfh->video; in omap3isp_wait_finish()
496 mutex_lock(&video->queue_lock); in omap3isp_wait_finish()
509 * omap3isp_video_buffer_next - Complete the current buffer and return the next
526 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity); in omap3isp_video_buffer_next()
531 spin_lock_irqsave(&video->irqlock, flags); in omap3isp_video_buffer_next()
532 if (WARN_ON(list_empty(&video->dmaqueue))) { in omap3isp_video_buffer_next()
533 spin_unlock_irqrestore(&video->irqlock, flags); in omap3isp_video_buffer_next()
537 buf = list_first_entry(&video->dmaqueue, struct isp_buffer, in omap3isp_video_buffer_next()
539 list_del(&buf->irqlist); in omap3isp_video_buffer_next()
540 spin_unlock_irqrestore(&video->irqlock, flags); in omap3isp_video_buffer_next()
542 buf->vb.vb2_buf.timestamp = ktime_get_ns(); in omap3isp_video_buffer_next()
550 if (video == pipe->output && !pipe->do_propagation) in omap3isp_video_buffer_next()
551 buf->vb.sequence = in omap3isp_video_buffer_next()
552 atomic_inc_return(&pipe->frame_number); in omap3isp_video_buffer_next()
554 buf->vb.sequence = atomic_read(&pipe->frame_number); in omap3isp_video_buffer_next()
556 if (pipe->field != V4L2_FIELD_NONE) in omap3isp_video_buffer_next()
557 buf->vb.sequence /= 2; in omap3isp_video_buffer_next()
559 buf->vb.field = pipe->field; in omap3isp_video_buffer_next()
562 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->error) { in omap3isp_video_buffer_next()
564 pipe->error = false; in omap3isp_video_buffer_next()
569 vb2_buffer_done(&buf->vb.vb2_buf, vb_state); in omap3isp_video_buffer_next()
571 spin_lock_irqsave(&video->irqlock, flags); in omap3isp_video_buffer_next()
573 if (list_empty(&video->dmaqueue)) { in omap3isp_video_buffer_next()
576 spin_unlock_irqrestore(&video->irqlock, flags); in omap3isp_video_buffer_next()
578 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) in omap3isp_video_buffer_next()
585 spin_lock_irqsave(&pipe->lock, flags); in omap3isp_video_buffer_next()
586 pipe->state &= ~state; in omap3isp_video_buffer_next()
587 if (video->pipe.stream_state == ISP_PIPELINE_STREAM_CONTINUOUS) in omap3isp_video_buffer_next()
588 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN; in omap3isp_video_buffer_next()
589 spin_unlock_irqrestore(&pipe->lock, flags); in omap3isp_video_buffer_next()
593 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->input != NULL) { in omap3isp_video_buffer_next()
594 spin_lock(&pipe->lock); in omap3isp_video_buffer_next()
595 pipe->state &= ~ISP_PIPELINE_STREAM; in omap3isp_video_buffer_next()
596 spin_unlock(&pipe->lock); in omap3isp_video_buffer_next()
599 buf = list_first_entry(&video->dmaqueue, struct isp_buffer, in omap3isp_video_buffer_next()
602 spin_unlock_irqrestore(&video->irqlock, flags); in omap3isp_video_buffer_next()
608 * omap3isp_video_cancel_stream - Cancel stream on a video node
618 spin_lock_irqsave(&video->irqlock, flags); in omap3isp_video_cancel_stream()
620 video->error = true; in omap3isp_video_cancel_stream()
621 spin_unlock_irqrestore(&video->irqlock, flags); in omap3isp_video_cancel_stream()
625 * omap3isp_video_resume - Perform resume operation on the buffers
638 if (continuous && video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { in omap3isp_video_resume()
639 mutex_lock(&video->queue_lock); in omap3isp_video_resume()
640 vb2_discard_done(video->queue); in omap3isp_video_resume()
641 mutex_unlock(&video->queue_lock); in omap3isp_video_resume()
644 if (!list_empty(&video->dmaqueue)) { in omap3isp_video_resume()
645 buf = list_first_entry(&video->dmaqueue, in omap3isp_video_resume()
647 video->ops->queue(video, buf); in omap3isp_video_resume()
648 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_QUEUED; in omap3isp_video_resume()
651 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN; in omap3isp_video_resume()
655 /* -----------------------------------------------------------------------------
664 strscpy(cap->driver, ISP_VIDEO_DRIVER_NAME, sizeof(cap->driver)); in isp_video_querycap()
665 strscpy(cap->card, video->video.name, sizeof(cap->card)); in isp_video_querycap()
666 strscpy(cap->bus_info, "media", sizeof(cap->bus_info)); in isp_video_querycap()
668 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT in isp_video_querycap()
681 if (format->type != video->type) in isp_video_get_format()
682 return -EINVAL; in isp_video_get_format()
684 mutex_lock(&video->mutex); in isp_video_get_format()
685 *format = vfh->format; in isp_video_get_format()
686 mutex_unlock(&video->mutex); in isp_video_get_format()
698 if (format->type != video->type) in isp_video_set_format()
699 return -EINVAL; in isp_video_set_format()
701 /* Replace unsupported field orders with sane defaults. */ in isp_video_set_format()
702 switch (format->fmt.pix.field) { in isp_video_set_format()
708 if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) in isp_video_set_format()
709 format->fmt.pix.field = V4L2_FIELD_NONE; in isp_video_set_format()
713 * top-bottom order when the unqualified interlaced order is in isp_video_set_format()
716 format->fmt.pix.field = V4L2_FIELD_INTERLACED_TB; in isp_video_set_format()
720 /* Interlaced orders are only supported at the CCDC output. */ in isp_video_set_format()
721 if (video != &video->isp->isp_ccdc.video_out) in isp_video_set_format()
722 format->fmt.pix.field = V4L2_FIELD_NONE; in isp_video_set_format()
729 /* All other field orders are currently unsupported, default to in isp_video_set_format()
732 format->fmt.pix.field = V4L2_FIELD_NONE; in isp_video_set_format()
739 isp_video_pix_to_mbus(&format->fmt.pix, &fmt); in isp_video_set_format()
740 isp_video_mbus_to_pix(video, &fmt, &format->fmt.pix); in isp_video_set_format()
742 mutex_lock(&video->mutex); in isp_video_set_format()
743 vfh->format = *format; in isp_video_set_format()
744 mutex_unlock(&video->mutex); in isp_video_set_format()
760 if (format->type != video->type) in isp_video_try_format()
761 return -EINVAL; in isp_video_try_format()
765 return -EINVAL; in isp_video_try_format()
767 isp_video_pix_to_mbus(&format->fmt.pix, &fmt.format); in isp_video_try_format()
772 return ret == -ENOIOCTLCMD ? -ENOTTY : ret; in isp_video_try_format()
774 isp_video_mbus_to_pix(video, &fmt.format, &format->fmt.pix); in isp_video_try_format()
788 .target = sel->target, in isp_video_get_selection()
793 switch (sel->target) { in isp_video_get_selection()
797 if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) in isp_video_get_selection()
798 return -EINVAL; in isp_video_get_selection()
803 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) in isp_video_get_selection()
804 return -EINVAL; in isp_video_get_selection()
807 return -EINVAL; in isp_video_get_selection()
811 return -EINVAL; in isp_video_get_selection()
819 sel->r = sdsel.r; in isp_video_get_selection()
820 if (ret != -ENOIOCTLCMD) in isp_video_get_selection()
826 return ret == -ENOIOCTLCMD ? -ENOTTY : ret; in isp_video_get_selection()
828 sel->r.left = 0; in isp_video_get_selection()
829 sel->r.top = 0; in isp_video_get_selection()
830 sel->r.width = format.format.width; in isp_video_get_selection()
831 sel->r.height = format.format.height; in isp_video_get_selection()
843 .target = sel->target, in isp_video_set_selection()
844 .flags = sel->flags, in isp_video_set_selection()
845 .r = sel->r, in isp_video_set_selection()
850 switch (sel->target) { in isp_video_set_selection()
852 if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) in isp_video_set_selection()
853 return -EINVAL; in isp_video_set_selection()
856 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) in isp_video_set_selection()
857 return -EINVAL; in isp_video_set_selection()
860 return -EINVAL; in isp_video_set_selection()
864 return -EINVAL; in isp_video_set_selection()
867 mutex_lock(&video->mutex); in isp_video_set_selection()
869 mutex_unlock(&video->mutex); in isp_video_set_selection()
871 sel->r = sdsel.r; in isp_video_set_selection()
873 return ret == -ENOIOCTLCMD ? -ENOTTY : ret; in isp_video_set_selection()
882 if (video->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || in isp_video_get_param()
883 video->type != a->type) in isp_video_get_param()
884 return -EINVAL; in isp_video_get_param()
887 a->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; in isp_video_get_param()
888 a->parm.output.capability = V4L2_CAP_TIMEPERFRAME; in isp_video_get_param()
889 a->parm.output.timeperframe = vfh->timeperframe; in isp_video_get_param()
900 if (video->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || in isp_video_set_param()
901 video->type != a->type) in isp_video_set_param()
902 return -EINVAL; in isp_video_set_param()
904 if (a->parm.output.timeperframe.denominator == 0) in isp_video_set_param()
905 a->parm.output.timeperframe.denominator = 1; in isp_video_set_param()
907 vfh->timeperframe = a->parm.output.timeperframe; in isp_video_set_param()
919 mutex_lock(&video->queue_lock); in isp_video_reqbufs()
920 ret = vb2_reqbufs(&vfh->queue, rb); in isp_video_reqbufs()
921 mutex_unlock(&video->queue_lock); in isp_video_reqbufs()
933 mutex_lock(&video->queue_lock); in isp_video_querybuf()
934 ret = vb2_querybuf(&vfh->queue, b); in isp_video_querybuf()
935 mutex_unlock(&video->queue_lock); in isp_video_querybuf()
947 mutex_lock(&video->queue_lock); in isp_video_qbuf()
948 ret = vb2_qbuf(&vfh->queue, video->video.v4l2_dev->mdev, b); in isp_video_qbuf()
949 mutex_unlock(&video->queue_lock); in isp_video_qbuf()
961 mutex_lock(&video->queue_lock); in isp_video_dqbuf()
962 ret = vb2_dqbuf(&vfh->queue, b, file->f_flags & O_NONBLOCK); in isp_video_dqbuf()
963 mutex_unlock(&video->queue_lock); in isp_video_dqbuf()
971 struct isp_device *isp = video->isp; in isp_video_check_external_subdevs()
973 &isp->isp_csi2a.subdev.entity, in isp_video_check_external_subdevs()
974 &isp->isp_csi2c.subdev.entity, in isp_video_check_external_subdevs()
975 &isp->isp_ccp2.subdev.entity, in isp_video_check_external_subdevs()
976 &isp->isp_ccdc.subdev.entity in isp_video_check_external_subdevs()
989 /* Memory-to-memory pipelines have no external subdev. */ in isp_video_check_external_subdevs()
990 if (pipe->input != NULL) in isp_video_check_external_subdevs()
995 if (!media_entity_enum_test(&pipe->ent_enum, ents[i])) in isp_video_check_external_subdevs()
999 source_pad = media_pad_remote_pad_first(&ents[i]->pads[0]); in isp_video_check_external_subdevs()
1003 source = source_pad->entity; in isp_video_check_external_subdevs()
1009 dev_warn(isp->dev, "can't find source, failing now\n"); in isp_video_check_external_subdevs()
1010 return -EINVAL; in isp_video_check_external_subdevs()
1016 pipe->external = media_entity_to_v4l2_subdev(source); in isp_video_check_external_subdevs()
1018 fmt.pad = source_pad->index; in isp_video_check_external_subdevs()
1022 dev_warn(isp->dev, "get_fmt returned null!\n"); in isp_video_check_external_subdevs()
1026 pipe->external_width = in isp_video_check_external_subdevs()
1027 omap3isp_video_format_info(fmt.format.code)->width; in isp_video_check_external_subdevs()
1036 ret = v4l2_g_ext_ctrls(pipe->external->ctrl_handler, &video->video, in isp_video_check_external_subdevs()
1039 dev_warn(isp->dev, "no pixel rate control in subdev %s\n", in isp_video_check_external_subdevs()
1040 pipe->external->name); in isp_video_check_external_subdevs()
1044 pipe->external_rate = ctrl.value64; in isp_video_check_external_subdevs()
1046 if (media_entity_enum_test(&pipe->ent_enum, in isp_video_check_external_subdevs()
1047 &isp->isp_ccdc.subdev.entity)) { in isp_video_check_external_subdevs()
1053 omap3isp_ccdc_max_rate(&isp->isp_ccdc, &rate); in isp_video_check_external_subdevs()
1054 if (pipe->external_rate > rate) in isp_video_check_external_subdevs()
1055 return -ENOSPC; in isp_video_check_external_subdevs()
1071 * In sensor-to-memory mode, frames are always available at the pipeline input.
1078 * In memory-to-memory mode, starting/stopping the stream requires
1082 * event. For that reason frames need to be processed in single-shot mode. The
1102 if (type != video->type) in isp_video_streamon()
1103 return -EINVAL; in isp_video_streamon()
1105 mutex_lock(&video->stream_lock); in isp_video_streamon()
1110 pipe = to_isp_pipeline(&video->video.entity) ? : &video->pipe; in isp_video_streamon()
1112 ret = media_entity_enum_init(&pipe->ent_enum, &video->isp->media_dev); in isp_video_streamon()
1117 pipe->l3_ick = clk_get_rate(video->isp->clock[ISP_CLK_L3_ICK]); in isp_video_streamon()
1118 pipe->max_rate = pipe->l3_ick; in isp_video_streamon()
1120 ret = video_device_pipeline_start(&video->video, &pipe->pipe); in isp_video_streamon()
1131 video->bpl_padding = ret; in isp_video_streamon()
1132 video->bpl_value = vfh->format.fmt.pix.bytesperline; in isp_video_streamon()
1138 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) in isp_video_streamon()
1147 pipe->error = false; in isp_video_streamon()
1149 spin_lock_irqsave(&pipe->lock, flags); in isp_video_streamon()
1150 pipe->state &= ~ISP_PIPELINE_STREAM; in isp_video_streamon()
1151 pipe->state |= state; in isp_video_streamon()
1152 spin_unlock_irqrestore(&pipe->lock, flags); in isp_video_streamon()
1158 if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) in isp_video_streamon()
1159 pipe->max_timeperframe = vfh->timeperframe; in isp_video_streamon()
1161 video->queue = &vfh->queue; in isp_video_streamon()
1162 INIT_LIST_HEAD(&video->dmaqueue); in isp_video_streamon()
1163 atomic_set(&pipe->frame_number, -1); in isp_video_streamon()
1164 pipe->field = vfh->format.fmt.pix.field; in isp_video_streamon()
1166 mutex_lock(&video->queue_lock); in isp_video_streamon()
1167 ret = vb2_streamon(&vfh->queue, type); in isp_video_streamon()
1168 mutex_unlock(&video->queue_lock); in isp_video_streamon()
1172 mutex_unlock(&video->stream_lock); in isp_video_streamon()
1177 video_device_pipeline_stop(&video->video); in isp_video_streamon()
1185 * free-running sensor. in isp_video_streamon()
1187 INIT_LIST_HEAD(&video->dmaqueue); in isp_video_streamon()
1188 video->queue = NULL; in isp_video_streamon()
1190 media_entity_enum_cleanup(&pipe->ent_enum); in isp_video_streamon()
1193 mutex_unlock(&video->stream_lock); in isp_video_streamon()
1203 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity); in isp_video_streamoff()
1208 if (type != video->type) in isp_video_streamoff()
1209 return -EINVAL; in isp_video_streamoff()
1211 mutex_lock(&video->stream_lock); in isp_video_streamoff()
1214 mutex_lock(&video->queue_lock); in isp_video_streamoff()
1215 streaming = vb2_is_streaming(&vfh->queue); in isp_video_streamoff()
1216 mutex_unlock(&video->queue_lock); in isp_video_streamoff()
1222 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) in isp_video_streamoff()
1229 spin_lock_irqsave(&pipe->lock, flags); in isp_video_streamoff()
1230 pipe->state &= ~state; in isp_video_streamoff()
1231 spin_unlock_irqrestore(&pipe->lock, flags); in isp_video_streamoff()
1237 mutex_lock(&video->queue_lock); in isp_video_streamoff()
1238 vb2_streamoff(&vfh->queue, type); in isp_video_streamoff()
1239 mutex_unlock(&video->queue_lock); in isp_video_streamoff()
1240 video->queue = NULL; in isp_video_streamoff()
1241 video->error = false; in isp_video_streamoff()
1244 video_device_pipeline_stop(&video->video); in isp_video_streamoff()
1246 media_entity_enum_cleanup(&pipe->ent_enum); in isp_video_streamoff()
1249 mutex_unlock(&video->stream_lock); in isp_video_streamoff()
1256 if (input->index > 0) in isp_video_enum_input()
1257 return -EINVAL; in isp_video_enum_input()
1259 strscpy(input->name, "camera", sizeof(input->name)); in isp_video_enum_input()
1260 input->type = V4L2_INPUT_TYPE_CAMERA; in isp_video_enum_input()
1276 return input == 0 ? 0 : -EINVAL; in isp_video_s_input()
1302 /* -----------------------------------------------------------------------------
1315 return -ENOMEM; in isp_video_open()
1317 v4l2_fh_init(&handle->vfh, &video->video); in isp_video_open()
1318 v4l2_fh_add(&handle->vfh); in isp_video_open()
1321 if (omap3isp_get(video->isp) == NULL) { in isp_video_open()
1322 ret = -EBUSY; in isp_video_open()
1326 ret = v4l2_pipeline_pm_get(&video->video.entity); in isp_video_open()
1328 omap3isp_put(video->isp); in isp_video_open()
1332 queue = &handle->queue; in isp_video_open()
1333 queue->type = video->type; in isp_video_open()
1334 queue->io_modes = VB2_MMAP | VB2_USERPTR; in isp_video_open()
1335 queue->drv_priv = handle; in isp_video_open()
1336 queue->ops = &isp_video_queue_ops; in isp_video_open()
1337 queue->mem_ops = &vb2_dma_contig_memops; in isp_video_open()
1338 queue->buf_struct_size = sizeof(struct isp_buffer); in isp_video_open()
1339 queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in isp_video_open()
1340 queue->dev = video->isp->dev; in isp_video_open()
1342 ret = vb2_queue_init(&handle->queue); in isp_video_open()
1344 omap3isp_put(video->isp); in isp_video_open()
1348 memset(&handle->format, 0, sizeof(handle->format)); in isp_video_open()
1349 handle->format.type = video->type; in isp_video_open()
1350 handle->timeperframe.denominator = 1; in isp_video_open()
1352 handle->video = video; in isp_video_open()
1353 file->private_data = &handle->vfh; in isp_video_open()
1357 v4l2_fh_del(&handle->vfh); in isp_video_open()
1358 v4l2_fh_exit(&handle->vfh); in isp_video_open()
1368 struct v4l2_fh *vfh = file->private_data; in isp_video_release()
1372 isp_video_streamoff(file, vfh, video->type); in isp_video_release()
1374 mutex_lock(&video->queue_lock); in isp_video_release()
1375 vb2_queue_release(&handle->queue); in isp_video_release()
1376 mutex_unlock(&video->queue_lock); in isp_video_release()
1378 v4l2_pipeline_pm_put(&video->video.entity); in isp_video_release()
1384 file->private_data = NULL; in isp_video_release()
1386 omap3isp_put(video->isp); in isp_video_release()
1393 struct isp_video_fh *vfh = to_isp_video_fh(file->private_data); in isp_video_poll()
1397 mutex_lock(&video->queue_lock); in isp_video_poll()
1398 ret = vb2_poll(&vfh->queue, file, wait); in isp_video_poll()
1399 mutex_unlock(&video->queue_lock); in isp_video_poll()
1406 struct isp_video_fh *vfh = to_isp_video_fh(file->private_data); in isp_video_mmap()
1408 return vb2_mmap(&vfh->queue, vma); in isp_video_mmap()
1420 /* -----------------------------------------------------------------------------
1432 switch (video->type) { in omap3isp_video_init()
1435 video->pad.flags = MEDIA_PAD_FL_SINK in omap3isp_video_init()
1440 video->pad.flags = MEDIA_PAD_FL_SOURCE in omap3isp_video_init()
1442 video->video.vfl_dir = VFL_DIR_TX; in omap3isp_video_init()
1446 return -EINVAL; in omap3isp_video_init()
1449 ret = media_entity_pads_init(&video->video.entity, 1, &video->pad); in omap3isp_video_init()
1453 mutex_init(&video->mutex); in omap3isp_video_init()
1454 atomic_set(&video->active, 0); in omap3isp_video_init()
1456 spin_lock_init(&video->pipe.lock); in omap3isp_video_init()
1457 mutex_init(&video->stream_lock); in omap3isp_video_init()
1458 mutex_init(&video->queue_lock); in omap3isp_video_init()
1459 spin_lock_init(&video->irqlock); in omap3isp_video_init()
1462 if (video->ops == NULL) in omap3isp_video_init()
1463 video->ops = &isp_video_dummy_ops; in omap3isp_video_init()
1465 video->video.fops = &isp_video_fops; in omap3isp_video_init()
1466 snprintf(video->video.name, sizeof(video->video.name), in omap3isp_video_init()
1468 video->video.vfl_type = VFL_TYPE_VIDEO; in omap3isp_video_init()
1469 video->video.release = video_device_release_empty; in omap3isp_video_init()
1470 video->video.ioctl_ops = &isp_video_ioctl_ops; in omap3isp_video_init()
1471 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) in omap3isp_video_init()
1472 video->video.device_caps = V4L2_CAP_VIDEO_CAPTURE in omap3isp_video_init()
1475 video->video.device_caps = V4L2_CAP_VIDEO_OUTPUT in omap3isp_video_init()
1478 video->pipe.stream_state = ISP_PIPELINE_STREAM_STOPPED; in omap3isp_video_init()
1480 video_set_drvdata(&video->video, video); in omap3isp_video_init()
1487 media_entity_cleanup(&video->video.entity); in omap3isp_video_cleanup()
1488 mutex_destroy(&video->queue_lock); in omap3isp_video_cleanup()
1489 mutex_destroy(&video->stream_lock); in omap3isp_video_cleanup()
1490 mutex_destroy(&video->mutex); in omap3isp_video_cleanup()
1497 video->video.v4l2_dev = vdev; in omap3isp_video_register()
1499 ret = video_register_device(&video->video, VFL_TYPE_VIDEO, -1); in omap3isp_video_register()
1501 dev_err(video->isp->dev, in omap3isp_video_register()
1510 video_unregister_device(&video->video); in omap3isp_video_unregister()