4 * TI OMAP3 ISP - Generic video node
6 * Copyright (C) 2009-2010 Nokia Corporation
8 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
9 * Sakari Ailus <sakari.ailus@iki.fi>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include <asm/cacheflush.h>
17 #include <linux/clk.h>
19 #include <linux/module.h>
20 #include <linux/pagemap.h>
21 #include <linux/scatterlist.h>
22 #include <linux/sched.h>
23 #include <linux/slab.h>
24 #include <linux/vmalloc.h>
25 #include <media/v4l2-dev.h>
26 #include <media/v4l2-ioctl.h>
27 #include <media/videobuf2-dma-contig.h>
33 /* -----------------------------------------------------------------------------
38 * NOTE: When adding new media bus codes, always remember to add
39 * corresponding in-memory formats to the table below!!!
41 static struct isp_format_info formats[] = {
42 { MEDIA_BUS_FMT_Y8_1X8, MEDIA_BUS_FMT_Y8_1X8,
43 MEDIA_BUS_FMT_Y8_1X8, MEDIA_BUS_FMT_Y8_1X8,
44 V4L2_PIX_FMT_GREY, 8, 1, },
45 { MEDIA_BUS_FMT_Y10_1X10, MEDIA_BUS_FMT_Y10_1X10,
46 MEDIA_BUS_FMT_Y10_1X10, MEDIA_BUS_FMT_Y8_1X8,
47 V4L2_PIX_FMT_Y10, 10, 2, },
48 { MEDIA_BUS_FMT_Y12_1X12, MEDIA_BUS_FMT_Y10_1X10,
49 MEDIA_BUS_FMT_Y12_1X12, MEDIA_BUS_FMT_Y8_1X8,
50 V4L2_PIX_FMT_Y12, 12, 2, },
51 { MEDIA_BUS_FMT_SBGGR8_1X8, MEDIA_BUS_FMT_SBGGR8_1X8,
52 MEDIA_BUS_FMT_SBGGR8_1X8, MEDIA_BUS_FMT_SBGGR8_1X8,
53 V4L2_PIX_FMT_SBGGR8, 8, 1, },
54 { MEDIA_BUS_FMT_SGBRG8_1X8, MEDIA_BUS_FMT_SGBRG8_1X8,
55 MEDIA_BUS_FMT_SGBRG8_1X8, MEDIA_BUS_FMT_SGBRG8_1X8,
56 V4L2_PIX_FMT_SGBRG8, 8, 1, },
57 { MEDIA_BUS_FMT_SGRBG8_1X8, MEDIA_BUS_FMT_SGRBG8_1X8,
58 MEDIA_BUS_FMT_SGRBG8_1X8, MEDIA_BUS_FMT_SGRBG8_1X8,
59 V4L2_PIX_FMT_SGRBG8, 8, 1, },
60 { MEDIA_BUS_FMT_SRGGB8_1X8, MEDIA_BUS_FMT_SRGGB8_1X8,
61 MEDIA_BUS_FMT_SRGGB8_1X8, MEDIA_BUS_FMT_SRGGB8_1X8,
62 V4L2_PIX_FMT_SRGGB8, 8, 1, },
63 { MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8, MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8,
64 MEDIA_BUS_FMT_SBGGR10_1X10, 0,
65 V4L2_PIX_FMT_SBGGR10DPCM8, 8, 1, },
66 { MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8, MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8,
67 MEDIA_BUS_FMT_SGBRG10_1X10, 0,
68 V4L2_PIX_FMT_SGBRG10DPCM8, 8, 1, },
69 { MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8, MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8,
70 MEDIA_BUS_FMT_SGRBG10_1X10, 0,
71 V4L2_PIX_FMT_SGRBG10DPCM8, 8, 1, },
72 { MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8, MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8,
73 MEDIA_BUS_FMT_SRGGB10_1X10, 0,
74 V4L2_PIX_FMT_SRGGB10DPCM8, 8, 1, },
75 { MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SBGGR10_1X10,
76 MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SBGGR8_1X8,
77 V4L2_PIX_FMT_SBGGR10, 10, 2, },
78 { MEDIA_BUS_FMT_SGBRG10_1X10, MEDIA_BUS_FMT_SGBRG10_1X10,
79 MEDIA_BUS_FMT_SGBRG10_1X10, MEDIA_BUS_FMT_SGBRG8_1X8,
80 V4L2_PIX_FMT_SGBRG10, 10, 2, },
81 { MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SGRBG10_1X10,
82 MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SGRBG8_1X8,
83 V4L2_PIX_FMT_SGRBG10, 10, 2, },
84 { MEDIA_BUS_FMT_SRGGB10_1X10, MEDIA_BUS_FMT_SRGGB10_1X10,
85 MEDIA_BUS_FMT_SRGGB10_1X10, MEDIA_BUS_FMT_SRGGB8_1X8,
86 V4L2_PIX_FMT_SRGGB10, 10, 2, },
87 { MEDIA_BUS_FMT_SBGGR12_1X12, MEDIA_BUS_FMT_SBGGR10_1X10,
88 MEDIA_BUS_FMT_SBGGR12_1X12, MEDIA_BUS_FMT_SBGGR8_1X8,
89 V4L2_PIX_FMT_SBGGR12, 12, 2, },
90 { MEDIA_BUS_FMT_SGBRG12_1X12, MEDIA_BUS_FMT_SGBRG10_1X10,
91 MEDIA_BUS_FMT_SGBRG12_1X12, MEDIA_BUS_FMT_SGBRG8_1X8,
92 V4L2_PIX_FMT_SGBRG12, 12, 2, },
93 { MEDIA_BUS_FMT_SGRBG12_1X12, MEDIA_BUS_FMT_SGRBG10_1X10,
94 MEDIA_BUS_FMT_SGRBG12_1X12, MEDIA_BUS_FMT_SGRBG8_1X8,
95 V4L2_PIX_FMT_SGRBG12, 12, 2, },
96 { MEDIA_BUS_FMT_SRGGB12_1X12, MEDIA_BUS_FMT_SRGGB10_1X10,
97 MEDIA_BUS_FMT_SRGGB12_1X12, MEDIA_BUS_FMT_SRGGB8_1X8,
98 V4L2_PIX_FMT_SRGGB12, 12, 2, },
99 { MEDIA_BUS_FMT_UYVY8_1X16, MEDIA_BUS_FMT_UYVY8_1X16,
100 MEDIA_BUS_FMT_UYVY8_1X16, 0,
101 V4L2_PIX_FMT_UYVY, 16, 2, },
102 { MEDIA_BUS_FMT_YUYV8_1X16, MEDIA_BUS_FMT_YUYV8_1X16,
103 MEDIA_BUS_FMT_YUYV8_1X16, 0,
104 V4L2_PIX_FMT_YUYV, 16, 2, },
105 { MEDIA_BUS_FMT_UYVY8_2X8, MEDIA_BUS_FMT_UYVY8_2X8,
106 MEDIA_BUS_FMT_UYVY8_2X8, 0,
107 V4L2_PIX_FMT_UYVY, 8, 2, },
108 { MEDIA_BUS_FMT_YUYV8_2X8, MEDIA_BUS_FMT_YUYV8_2X8,
109 MEDIA_BUS_FMT_YUYV8_2X8, 0,
110 V4L2_PIX_FMT_YUYV, 8, 2, },
111 /* Empty entry to catch the unsupported pixel code (0) used by the CCDC
112 * module and avoid NULL pointer dereferences.
117 const struct isp_format_info *omap3isp_video_format_info(u32 code)
121 for (i = 0; i < ARRAY_SIZE(formats); ++i) {
122 if (formats[i].code == code)
130 * isp_video_mbus_to_pix - Convert v4l2_mbus_framefmt to v4l2_pix_format
131 * @video: ISP video instance
132 * @mbus: v4l2_mbus_framefmt format (input)
133 * @pix: v4l2_pix_format format (output)
135 * Fill the output pix structure with information from the input mbus format.
136 * The bytesperline and sizeimage fields are computed from the requested bytes
137 * per line value in the pix format and information from the video instance.
139 * Return the number of padding bytes at end of line.
141 static unsigned int isp_video_mbus_to_pix(const struct isp_video *video,
142 const struct v4l2_mbus_framefmt *mbus,
143 struct v4l2_pix_format *pix)
145 unsigned int bpl = pix->bytesperline;
146 unsigned int min_bpl;
149 memset(pix, 0, sizeof(*pix));
150 pix->width = mbus->width;
151 pix->height = mbus->height;
153 for (i = 0; i < ARRAY_SIZE(formats); ++i) {
154 if (formats[i].code == mbus->code)
158 if (WARN_ON(i == ARRAY_SIZE(formats)))
161 min_bpl = pix->width * formats[i].bpp;
163 /* Clamp the requested bytes per line value. If the maximum bytes per
164 * line value is zero, the module doesn't support user configurable line
165 * sizes. Override the requested value with the minimum in that case.
168 bpl = clamp(bpl, min_bpl, video->bpl_max);
172 if (!video->bpl_zero_padding || bpl != min_bpl)
173 bpl = ALIGN(bpl, video->bpl_alignment);
175 pix->pixelformat = formats[i].pixelformat;
176 pix->bytesperline = bpl;
177 pix->sizeimage = pix->bytesperline * pix->height;
178 pix->colorspace = mbus->colorspace;
179 pix->field = mbus->field;
181 return bpl - min_bpl;
184 static void isp_video_pix_to_mbus(const struct v4l2_pix_format *pix,
185 struct v4l2_mbus_framefmt *mbus)
189 memset(mbus, 0, sizeof(*mbus));
190 mbus->width = pix->width;
191 mbus->height = pix->height;
193 /* Skip the last format in the loop so that it will be selected if no
196 for (i = 0; i < ARRAY_SIZE(formats) - 1; ++i) {
197 if (formats[i].pixelformat == pix->pixelformat)
201 mbus->code = formats[i].code;
202 mbus->colorspace = pix->colorspace;
203 mbus->field = pix->field;
206 static struct v4l2_subdev *
207 isp_video_remote_subdev(struct isp_video *video, u32 *pad)
209 struct media_pad *remote;
211 remote = media_entity_remote_pad(&video->pad);
213 if (!remote || !is_media_entity_v4l2_subdev(remote->entity))
217 *pad = remote->index;
219 return media_entity_to_v4l2_subdev(remote->entity);
222 /* Return a pointer to the ISP video instance at the far end of the pipeline. */
223 static int isp_video_get_graph_data(struct isp_video *video,
224 struct isp_pipeline *pipe)
226 struct media_entity_graph graph;
227 struct media_entity *entity = &video->video.entity;
228 struct media_device *mdev = entity->graph_obj.mdev;
229 struct isp_video *far_end = NULL;
232 mutex_lock(&mdev->graph_mutex);
233 ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev);
235 mutex_unlock(&mdev->graph_mutex);
239 media_entity_graph_walk_start(&graph, entity);
241 while ((entity = media_entity_graph_walk_next(&graph))) {
242 struct isp_video *__video;
244 media_entity_enum_set(&pipe->ent_enum, entity);
249 if (entity == &video->video.entity)
252 if (!is_media_entity_v4l2_io(entity))
255 __video = to_isp_video(media_entity_to_video_device(entity));
256 if (__video->type != video->type)
260 mutex_unlock(&mdev->graph_mutex);
262 media_entity_graph_walk_cleanup(&graph);
264 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
265 pipe->input = far_end;
266 pipe->output = video;
272 pipe->output = far_end;
279 __isp_video_get_format(struct isp_video *video, struct v4l2_format *format)
281 struct v4l2_subdev_format fmt;
282 struct v4l2_subdev *subdev;
286 subdev = isp_video_remote_subdev(video, &pad);
291 fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
293 mutex_lock(&video->mutex);
294 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
295 mutex_unlock(&video->mutex);
300 format->type = video->type;
301 return isp_video_mbus_to_pix(video, &fmt.format, &format->fmt.pix);
305 isp_video_check_format(struct isp_video *video, struct isp_video_fh *vfh)
307 struct v4l2_format format;
310 memcpy(&format, &vfh->format, sizeof(format));
311 ret = __isp_video_get_format(video, &format);
315 if (vfh->format.fmt.pix.pixelformat != format.fmt.pix.pixelformat ||
316 vfh->format.fmt.pix.height != format.fmt.pix.height ||
317 vfh->format.fmt.pix.width != format.fmt.pix.width ||
318 vfh->format.fmt.pix.bytesperline != format.fmt.pix.bytesperline ||
319 vfh->format.fmt.pix.sizeimage != format.fmt.pix.sizeimage ||
320 vfh->format.fmt.pix.field != format.fmt.pix.field)
326 /* -----------------------------------------------------------------------------
327 * Video queue operations
330 static int isp_video_queue_setup(struct vb2_queue *queue,
331 unsigned int *count, unsigned int *num_planes,
332 unsigned int sizes[], void *alloc_ctxs[])
334 struct isp_video_fh *vfh = vb2_get_drv_priv(queue);
335 struct isp_video *video = vfh->video;
339 sizes[0] = vfh->format.fmt.pix.sizeimage;
343 alloc_ctxs[0] = video->alloc_ctx;
345 *count = min(*count, video->capture_mem / PAGE_ALIGN(sizes[0]));
350 static int isp_video_buffer_prepare(struct vb2_buffer *buf)
352 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(buf);
353 struct isp_video_fh *vfh = vb2_get_drv_priv(buf->vb2_queue);
354 struct isp_buffer *buffer = to_isp_buffer(vbuf);
355 struct isp_video *video = vfh->video;
358 /* Refuse to prepare the buffer is the video node has registered an
359 * error. We don't need to take any lock here as the operation is
360 * inherently racy. The authoritative check will be performed in the
361 * queue handler, which can't return an error, this check is just a best
362 * effort to notify userspace as early as possible.
364 if (unlikely(video->error))
367 addr = vb2_dma_contig_plane_dma_addr(buf, 0);
368 if (!IS_ALIGNED(addr, 32)) {
369 dev_dbg(video->isp->dev,
370 "Buffer address must be aligned to 32 bytes boundary.\n");
374 vb2_set_plane_payload(&buffer->vb.vb2_buf, 0,
375 vfh->format.fmt.pix.sizeimage);
382 * isp_video_buffer_queue - Add buffer to streaming queue
385 * In memory-to-memory mode, start streaming on the pipeline if buffers are
386 * queued on both the input and the output, if the pipeline isn't already busy.
387 * If the pipeline is busy, it will be restarted in the output module interrupt
390 static void isp_video_buffer_queue(struct vb2_buffer *buf)
392 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(buf);
393 struct isp_video_fh *vfh = vb2_get_drv_priv(buf->vb2_queue);
394 struct isp_buffer *buffer = to_isp_buffer(vbuf);
395 struct isp_video *video = vfh->video;
396 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity);
397 enum isp_pipeline_state state;
402 spin_lock_irqsave(&video->irqlock, flags);
404 if (unlikely(video->error)) {
405 vb2_buffer_done(&buffer->vb.vb2_buf, VB2_BUF_STATE_ERROR);
406 spin_unlock_irqrestore(&video->irqlock, flags);
410 empty = list_empty(&video->dmaqueue);
411 list_add_tail(&buffer->irqlist, &video->dmaqueue);
413 spin_unlock_irqrestore(&video->irqlock, flags);
416 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
417 state = ISP_PIPELINE_QUEUE_OUTPUT;
419 state = ISP_PIPELINE_QUEUE_INPUT;
421 spin_lock_irqsave(&pipe->lock, flags);
422 pipe->state |= state;
423 video->ops->queue(video, buffer);
424 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_QUEUED;
426 start = isp_pipeline_ready(pipe);
428 pipe->state |= ISP_PIPELINE_STREAM;
429 spin_unlock_irqrestore(&pipe->lock, flags);
432 omap3isp_pipeline_set_stream(pipe,
433 ISP_PIPELINE_STREAM_SINGLESHOT);
437 static const struct vb2_ops isp_video_queue_ops = {
438 .queue_setup = isp_video_queue_setup,
439 .buf_prepare = isp_video_buffer_prepare,
440 .buf_queue = isp_video_buffer_queue,
444 * omap3isp_video_buffer_next - Complete the current buffer and return the next
445 * @video: ISP video object
447 * Remove the current video buffer from the DMA queue and fill its timestamp and
448 * field count before handing it back to videobuf2.
450 * For capture video nodes the buffer state is set to VB2_BUF_STATE_DONE if no
451 * error has been flagged in the pipeline, or to VB2_BUF_STATE_ERROR otherwise.
452 * For video output nodes the buffer state is always set to VB2_BUF_STATE_DONE.
454 * The DMA queue is expected to contain at least one buffer.
456 * Return a pointer to the next buffer in the DMA queue, or NULL if the queue is
459 struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
461 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity);
462 enum isp_pipeline_state state;
463 struct isp_buffer *buf;
466 spin_lock_irqsave(&video->irqlock, flags);
467 if (WARN_ON(list_empty(&video->dmaqueue))) {
468 spin_unlock_irqrestore(&video->irqlock, flags);
472 buf = list_first_entry(&video->dmaqueue, struct isp_buffer,
474 list_del(&buf->irqlist);
475 spin_unlock_irqrestore(&video->irqlock, flags);
477 buf->vb.vb2_buf.timestamp = ktime_get_ns();
479 /* Do frame number propagation only if this is the output video node.
480 * Frame number either comes from the CSI receivers or it gets
481 * incremented here if H3A is not active.
482 * Note: There is no guarantee that the output buffer will finish
483 * first, so the input number might lag behind by 1 in some cases.
485 if (video == pipe->output && !pipe->do_propagation)
487 atomic_inc_return(&pipe->frame_number);
489 buf->vb.sequence = atomic_read(&pipe->frame_number);
491 if (pipe->field != V4L2_FIELD_NONE)
492 buf->vb.sequence /= 2;
494 buf->vb.field = pipe->field;
496 /* Report pipeline errors to userspace on the capture device side. */
497 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->error) {
498 state = VB2_BUF_STATE_ERROR;
501 state = VB2_BUF_STATE_DONE;
504 vb2_buffer_done(&buf->vb.vb2_buf, state);
506 spin_lock_irqsave(&video->irqlock, flags);
508 if (list_empty(&video->dmaqueue)) {
509 spin_unlock_irqrestore(&video->irqlock, flags);
511 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
512 state = ISP_PIPELINE_QUEUE_OUTPUT
513 | ISP_PIPELINE_STREAM;
515 state = ISP_PIPELINE_QUEUE_INPUT
516 | ISP_PIPELINE_STREAM;
518 spin_lock_irqsave(&pipe->lock, flags);
519 pipe->state &= ~state;
520 if (video->pipe.stream_state == ISP_PIPELINE_STREAM_CONTINUOUS)
521 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN;
522 spin_unlock_irqrestore(&pipe->lock, flags);
526 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->input != NULL) {
527 spin_lock(&pipe->lock);
528 pipe->state &= ~ISP_PIPELINE_STREAM;
529 spin_unlock(&pipe->lock);
532 buf = list_first_entry(&video->dmaqueue, struct isp_buffer,
535 spin_unlock_irqrestore(&video->irqlock, flags);
541 * omap3isp_video_cancel_stream - Cancel stream on a video node
542 * @video: ISP video object
544 * Cancelling a stream mark all buffers on the video node as erroneous and makes
545 * sure no new buffer can be queued.
547 void omap3isp_video_cancel_stream(struct isp_video *video)
551 spin_lock_irqsave(&video->irqlock, flags);
553 while (!list_empty(&video->dmaqueue)) {
554 struct isp_buffer *buf;
556 buf = list_first_entry(&video->dmaqueue,
557 struct isp_buffer, irqlist);
558 list_del(&buf->irqlist);
559 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
564 spin_unlock_irqrestore(&video->irqlock, flags);
568 * omap3isp_video_resume - Perform resume operation on the buffers
569 * @video: ISP video object
570 * @continuous: Pipeline is in single shot mode if 0 or continuous mode otherwise
572 * This function is intended to be used on suspend/resume scenario. It
573 * requests video queue layer to discard buffers marked as DONE if it's in
574 * continuous mode and requests ISP modules to queue again the ACTIVE buffer
577 void omap3isp_video_resume(struct isp_video *video, int continuous)
579 struct isp_buffer *buf = NULL;
581 if (continuous && video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
582 mutex_lock(&video->queue_lock);
583 vb2_discard_done(video->queue);
584 mutex_unlock(&video->queue_lock);
587 if (!list_empty(&video->dmaqueue)) {
588 buf = list_first_entry(&video->dmaqueue,
589 struct isp_buffer, irqlist);
590 video->ops->queue(video, buf);
591 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_QUEUED;
594 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN;
598 /* -----------------------------------------------------------------------------
603 isp_video_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
605 struct isp_video *video = video_drvdata(file);
607 strlcpy(cap->driver, ISP_VIDEO_DRIVER_NAME, sizeof(cap->driver));
608 strlcpy(cap->card, video->video.name, sizeof(cap->card));
609 strlcpy(cap->bus_info, "media", sizeof(cap->bus_info));
611 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT
612 | V4L2_CAP_STREAMING | V4L2_CAP_DEVICE_CAPS;
614 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
615 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
617 cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
623 isp_video_get_format(struct file *file, void *fh, struct v4l2_format *format)
625 struct isp_video_fh *vfh = to_isp_video_fh(fh);
626 struct isp_video *video = video_drvdata(file);
628 if (format->type != video->type)
631 mutex_lock(&video->mutex);
632 *format = vfh->format;
633 mutex_unlock(&video->mutex);
639 isp_video_set_format(struct file *file, void *fh, struct v4l2_format *format)
641 struct isp_video_fh *vfh = to_isp_video_fh(fh);
642 struct isp_video *video = video_drvdata(file);
643 struct v4l2_mbus_framefmt fmt;
645 if (format->type != video->type)
648 /* Replace unsupported field orders with sane defaults. */
649 switch (format->fmt.pix.field) {
650 case V4L2_FIELD_NONE:
651 /* Progressive is supported everywhere. */
653 case V4L2_FIELD_ALTERNATE:
654 /* ALTERNATE is not supported on output nodes. */
655 if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
656 format->fmt.pix.field = V4L2_FIELD_NONE;
658 case V4L2_FIELD_INTERLACED:
659 /* The ISP has no concept of video standard, select the
660 * top-bottom order when the unqualified interlaced order is
663 format->fmt.pix.field = V4L2_FIELD_INTERLACED_TB;
665 case V4L2_FIELD_INTERLACED_TB:
666 case V4L2_FIELD_INTERLACED_BT:
667 /* Interlaced orders are only supported at the CCDC output. */
668 if (video != &video->isp->isp_ccdc.video_out)
669 format->fmt.pix.field = V4L2_FIELD_NONE;
672 case V4L2_FIELD_BOTTOM:
673 case V4L2_FIELD_SEQ_TB:
674 case V4L2_FIELD_SEQ_BT:
676 /* All other field orders are currently unsupported, default to
679 format->fmt.pix.field = V4L2_FIELD_NONE;
683 /* Fill the bytesperline and sizeimage fields by converting to media bus
684 * format and back to pixel format.
686 isp_video_pix_to_mbus(&format->fmt.pix, &fmt);
687 isp_video_mbus_to_pix(video, &fmt, &format->fmt.pix);
689 mutex_lock(&video->mutex);
690 vfh->format = *format;
691 mutex_unlock(&video->mutex);
697 isp_video_try_format(struct file *file, void *fh, struct v4l2_format *format)
699 struct isp_video *video = video_drvdata(file);
700 struct v4l2_subdev_format fmt;
701 struct v4l2_subdev *subdev;
705 if (format->type != video->type)
708 subdev = isp_video_remote_subdev(video, &pad);
712 isp_video_pix_to_mbus(&format->fmt.pix, &fmt.format);
715 fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
716 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
718 return ret == -ENOIOCTLCMD ? -ENOTTY : ret;
720 isp_video_mbus_to_pix(video, &fmt.format, &format->fmt.pix);
725 isp_video_cropcap(struct file *file, void *fh, struct v4l2_cropcap *cropcap)
727 struct isp_video *video = video_drvdata(file);
728 struct v4l2_subdev *subdev;
731 subdev = isp_video_remote_subdev(video, NULL);
735 mutex_lock(&video->mutex);
736 ret = v4l2_subdev_call(subdev, video, cropcap, cropcap);
737 mutex_unlock(&video->mutex);
739 return ret == -ENOIOCTLCMD ? -ENOTTY : ret;
743 isp_video_get_crop(struct file *file, void *fh, struct v4l2_crop *crop)
745 struct isp_video *video = video_drvdata(file);
746 struct v4l2_subdev_format format;
747 struct v4l2_subdev *subdev;
751 subdev = isp_video_remote_subdev(video, &pad);
755 /* Try the get crop operation first and fallback to get format if not
758 ret = v4l2_subdev_call(subdev, video, g_crop, crop);
759 if (ret != -ENOIOCTLCMD)
763 format.which = V4L2_SUBDEV_FORMAT_ACTIVE;
764 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &format);
766 return ret == -ENOIOCTLCMD ? -ENOTTY : ret;
770 crop->c.width = format.format.width;
771 crop->c.height = format.format.height;
777 isp_video_set_crop(struct file *file, void *fh, const struct v4l2_crop *crop)
779 struct isp_video *video = video_drvdata(file);
780 struct v4l2_subdev *subdev;
783 subdev = isp_video_remote_subdev(video, NULL);
787 mutex_lock(&video->mutex);
788 ret = v4l2_subdev_call(subdev, video, s_crop, crop);
789 mutex_unlock(&video->mutex);
791 return ret == -ENOIOCTLCMD ? -ENOTTY : ret;
795 isp_video_get_param(struct file *file, void *fh, struct v4l2_streamparm *a)
797 struct isp_video_fh *vfh = to_isp_video_fh(fh);
798 struct isp_video *video = video_drvdata(file);
800 if (video->type != V4L2_BUF_TYPE_VIDEO_OUTPUT ||
801 video->type != a->type)
804 memset(a, 0, sizeof(*a));
805 a->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
806 a->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
807 a->parm.output.timeperframe = vfh->timeperframe;
813 isp_video_set_param(struct file *file, void *fh, struct v4l2_streamparm *a)
815 struct isp_video_fh *vfh = to_isp_video_fh(fh);
816 struct isp_video *video = video_drvdata(file);
818 if (video->type != V4L2_BUF_TYPE_VIDEO_OUTPUT ||
819 video->type != a->type)
822 if (a->parm.output.timeperframe.denominator == 0)
823 a->parm.output.timeperframe.denominator = 1;
825 vfh->timeperframe = a->parm.output.timeperframe;
831 isp_video_reqbufs(struct file *file, void *fh, struct v4l2_requestbuffers *rb)
833 struct isp_video_fh *vfh = to_isp_video_fh(fh);
834 struct isp_video *video = video_drvdata(file);
837 mutex_lock(&video->queue_lock);
838 ret = vb2_reqbufs(&vfh->queue, rb);
839 mutex_unlock(&video->queue_lock);
845 isp_video_querybuf(struct file *file, void *fh, struct v4l2_buffer *b)
847 struct isp_video_fh *vfh = to_isp_video_fh(fh);
848 struct isp_video *video = video_drvdata(file);
851 mutex_lock(&video->queue_lock);
852 ret = vb2_querybuf(&vfh->queue, b);
853 mutex_unlock(&video->queue_lock);
859 isp_video_qbuf(struct file *file, void *fh, struct v4l2_buffer *b)
861 struct isp_video_fh *vfh = to_isp_video_fh(fh);
862 struct isp_video *video = video_drvdata(file);
865 mutex_lock(&video->queue_lock);
866 ret = vb2_qbuf(&vfh->queue, b);
867 mutex_unlock(&video->queue_lock);
873 isp_video_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b)
875 struct isp_video_fh *vfh = to_isp_video_fh(fh);
876 struct isp_video *video = video_drvdata(file);
879 mutex_lock(&video->queue_lock);
880 ret = vb2_dqbuf(&vfh->queue, b, file->f_flags & O_NONBLOCK);
881 mutex_unlock(&video->queue_lock);
886 static int isp_video_check_external_subdevs(struct isp_video *video,
887 struct isp_pipeline *pipe)
889 struct isp_device *isp = video->isp;
890 struct media_entity *ents[] = {
891 &isp->isp_csi2a.subdev.entity,
892 &isp->isp_csi2c.subdev.entity,
893 &isp->isp_ccp2.subdev.entity,
894 &isp->isp_ccdc.subdev.entity
896 struct media_pad *source_pad;
897 struct media_entity *source = NULL;
898 struct media_entity *sink;
899 struct v4l2_subdev_format fmt;
900 struct v4l2_ext_controls ctrls;
901 struct v4l2_ext_control ctrl;
905 /* Memory-to-memory pipelines have no external subdev. */
906 if (pipe->input != NULL)
909 for (i = 0; i < ARRAY_SIZE(ents); i++) {
910 /* Is the entity part of the pipeline? */
911 if (!media_entity_enum_test(&pipe->ent_enum, ents[i]))
914 /* ISP entities have always sink pad == 0. Find source. */
915 source_pad = media_entity_remote_pad(&ents[i]->pads[0]);
916 if (source_pad == NULL)
919 source = source_pad->entity;
925 dev_warn(isp->dev, "can't find source, failing now\n");
929 if (!is_media_entity_v4l2_subdev(source))
932 pipe->external = media_entity_to_v4l2_subdev(source);
934 fmt.pad = source_pad->index;
935 fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
936 ret = v4l2_subdev_call(media_entity_to_v4l2_subdev(sink),
937 pad, get_fmt, NULL, &fmt);
938 if (unlikely(ret < 0)) {
939 dev_warn(isp->dev, "get_fmt returned null!\n");
943 pipe->external_width =
944 omap3isp_video_format_info(fmt.format.code)->width;
946 memset(&ctrls, 0, sizeof(ctrls));
947 memset(&ctrl, 0, sizeof(ctrl));
949 ctrl.id = V4L2_CID_PIXEL_RATE;
952 ctrls.controls = &ctrl;
954 ret = v4l2_g_ext_ctrls(pipe->external->ctrl_handler, &ctrls);
956 dev_warn(isp->dev, "no pixel rate control in subdev %s\n",
957 pipe->external->name);
961 pipe->external_rate = ctrl.value64;
963 if (media_entity_enum_test(&pipe->ent_enum,
964 &isp->isp_ccdc.subdev.entity)) {
965 unsigned int rate = UINT_MAX;
967 * Check that maximum allowed CCDC pixel rate isn't
968 * exceeded by the pixel rate.
970 omap3isp_ccdc_max_rate(&isp->isp_ccdc, &rate);
971 if (pipe->external_rate > rate)
981 * Every ISP pipeline has a single input and a single output. The input can be
982 * either a sensor or a video node. The output is always a video node.
984 * As every pipeline has an output video node, the ISP video objects at the
985 * pipeline output stores the pipeline state. It tracks the streaming state of
986 * both the input and output, as well as the availability of buffers.
988 * In sensor-to-memory mode, frames are always available at the pipeline input.
989 * Starting the sensor usually requires I2C transfers and must be done in
990 * interruptible context. The pipeline is started and stopped synchronously
991 * to the stream on/off commands. All modules in the pipeline will get their
992 * subdev set stream handler called. The module at the end of the pipeline must
993 * delay starting the hardware until buffers are available at its output.
995 * In memory-to-memory mode, starting/stopping the stream requires
996 * synchronization between the input and output. ISP modules can't be stopped
997 * in the middle of a frame, and at least some of the modules seem to become
998 * busy as soon as they're started, even if they don't receive a frame start
999 * event. For that reason frames need to be processed in single-shot mode. The
1000 * driver needs to wait until a frame is completely processed and written to
1001 * memory before restarting the pipeline for the next frame. Pipelined
1002 * processing might be possible but requires more testing.
1004 * Stream start must be delayed until buffers are available at both the input
1005 * and output. The pipeline must be started in the videobuf queue callback with
1006 * the buffers queue spinlock held. The modules subdev set stream operation must
1010 isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
1012 struct isp_video_fh *vfh = to_isp_video_fh(fh);
1013 struct isp_video *video = video_drvdata(file);
1014 enum isp_pipeline_state state;
1015 struct isp_pipeline *pipe;
1016 unsigned long flags;
1019 if (type != video->type)
1022 mutex_lock(&video->stream_lock);
1024 /* Start streaming on the pipeline. No link touching an entity in the
1025 * pipeline can be activated or deactivated once streaming is started.
1027 pipe = video->video.entity.pipe
1028 ? to_isp_pipeline(&video->video.entity) : &video->pipe;
1030 ret = media_entity_enum_init(&pipe->ent_enum, &video->isp->media_dev);
1034 /* TODO: Implement PM QoS */
1035 pipe->l3_ick = clk_get_rate(video->isp->clock[ISP_CLK_L3_ICK]);
1036 pipe->max_rate = pipe->l3_ick;
1038 ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe);
1040 goto err_pipeline_start;
1042 /* Verify that the currently configured format matches the output of
1043 * the connected subdev.
1045 ret = isp_video_check_format(video, vfh);
1047 goto err_check_format;
1049 video->bpl_padding = ret;
1050 video->bpl_value = vfh->format.fmt.pix.bytesperline;
1052 ret = isp_video_get_graph_data(video, pipe);
1054 goto err_check_format;
1056 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
1057 state = ISP_PIPELINE_STREAM_OUTPUT | ISP_PIPELINE_IDLE_OUTPUT;
1059 state = ISP_PIPELINE_STREAM_INPUT | ISP_PIPELINE_IDLE_INPUT;
1061 ret = isp_video_check_external_subdevs(video, pipe);
1063 goto err_check_format;
1065 pipe->error = false;
1067 spin_lock_irqsave(&pipe->lock, flags);
1068 pipe->state &= ~ISP_PIPELINE_STREAM;
1069 pipe->state |= state;
1070 spin_unlock_irqrestore(&pipe->lock, flags);
1072 /* Set the maximum time per frame as the value requested by userspace.
1073 * This is a soft limit that can be overridden if the hardware doesn't
1074 * support the request limit.
1076 if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
1077 pipe->max_timeperframe = vfh->timeperframe;
1079 video->queue = &vfh->queue;
1080 INIT_LIST_HEAD(&video->dmaqueue);
1081 atomic_set(&pipe->frame_number, -1);
1082 pipe->field = vfh->format.fmt.pix.field;
1084 mutex_lock(&video->queue_lock);
1085 ret = vb2_streamon(&vfh->queue, type);
1086 mutex_unlock(&video->queue_lock);
1088 goto err_check_format;
1090 /* In sensor-to-memory mode, the stream can be started synchronously
1091 * to the stream on command. In memory-to-memory mode, it will be
1092 * started when buffers are queued on both the input and output.
1094 if (pipe->input == NULL) {
1095 ret = omap3isp_pipeline_set_stream(pipe,
1096 ISP_PIPELINE_STREAM_CONTINUOUS);
1098 goto err_set_stream;
1099 spin_lock_irqsave(&video->irqlock, flags);
1100 if (list_empty(&video->dmaqueue))
1101 video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN;
1102 spin_unlock_irqrestore(&video->irqlock, flags);
1105 mutex_unlock(&video->stream_lock);
1110 mutex_lock(&video->queue_lock);
1111 vb2_streamoff(&vfh->queue, type);
1112 mutex_unlock(&video->queue_lock);
1114 media_entity_pipeline_stop(&video->video.entity);
1116 /* TODO: Implement PM QoS */
1117 /* The DMA queue must be emptied here, otherwise CCDC interrupts that
1118 * will get triggered the next time the CCDC is powered up will try to
1119 * access buffers that might have been freed but still present in the
1120 * DMA queue. This can easily get triggered if the above
1121 * omap3isp_pipeline_set_stream() call fails on a system with a
1122 * free-running sensor.
1124 INIT_LIST_HEAD(&video->dmaqueue);
1125 video->queue = NULL;
1127 media_entity_enum_cleanup(&pipe->ent_enum);
1130 mutex_unlock(&video->stream_lock);
1136 isp_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
1138 struct isp_video_fh *vfh = to_isp_video_fh(fh);
1139 struct isp_video *video = video_drvdata(file);
1140 struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity);
1141 enum isp_pipeline_state state;
1142 unsigned int streaming;
1143 unsigned long flags;
1145 if (type != video->type)
1148 mutex_lock(&video->stream_lock);
1150 /* Make sure we're not streaming yet. */
1151 mutex_lock(&video->queue_lock);
1152 streaming = vb2_is_streaming(&vfh->queue);
1153 mutex_unlock(&video->queue_lock);
1158 /* Update the pipeline state. */
1159 if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
1160 state = ISP_PIPELINE_STREAM_OUTPUT
1161 | ISP_PIPELINE_QUEUE_OUTPUT;
1163 state = ISP_PIPELINE_STREAM_INPUT
1164 | ISP_PIPELINE_QUEUE_INPUT;
1166 spin_lock_irqsave(&pipe->lock, flags);
1167 pipe->state &= ~state;
1168 spin_unlock_irqrestore(&pipe->lock, flags);
1170 /* Stop the stream. */
1171 omap3isp_pipeline_set_stream(pipe, ISP_PIPELINE_STREAM_STOPPED);
1172 omap3isp_video_cancel_stream(video);
1174 mutex_lock(&video->queue_lock);
1175 vb2_streamoff(&vfh->queue, type);
1176 mutex_unlock(&video->queue_lock);
1177 video->queue = NULL;
1178 video->error = false;
1180 /* TODO: Implement PM QoS */
1181 media_entity_pipeline_stop(&video->video.entity);
1183 media_entity_enum_cleanup(&pipe->ent_enum);
1186 mutex_unlock(&video->stream_lock);
1191 isp_video_enum_input(struct file *file, void *fh, struct v4l2_input *input)
1193 if (input->index > 0)
1196 strlcpy(input->name, "camera", sizeof(input->name));
1197 input->type = V4L2_INPUT_TYPE_CAMERA;
1203 isp_video_g_input(struct file *file, void *fh, unsigned int *input)
1211 isp_video_s_input(struct file *file, void *fh, unsigned int input)
1213 return input == 0 ? 0 : -EINVAL;
1216 static const struct v4l2_ioctl_ops isp_video_ioctl_ops = {
1217 .vidioc_querycap = isp_video_querycap,
1218 .vidioc_g_fmt_vid_cap = isp_video_get_format,
1219 .vidioc_s_fmt_vid_cap = isp_video_set_format,
1220 .vidioc_try_fmt_vid_cap = isp_video_try_format,
1221 .vidioc_g_fmt_vid_out = isp_video_get_format,
1222 .vidioc_s_fmt_vid_out = isp_video_set_format,
1223 .vidioc_try_fmt_vid_out = isp_video_try_format,
1224 .vidioc_cropcap = isp_video_cropcap,
1225 .vidioc_g_crop = isp_video_get_crop,
1226 .vidioc_s_crop = isp_video_set_crop,
1227 .vidioc_g_parm = isp_video_get_param,
1228 .vidioc_s_parm = isp_video_set_param,
1229 .vidioc_reqbufs = isp_video_reqbufs,
1230 .vidioc_querybuf = isp_video_querybuf,
1231 .vidioc_qbuf = isp_video_qbuf,
1232 .vidioc_dqbuf = isp_video_dqbuf,
1233 .vidioc_streamon = isp_video_streamon,
1234 .vidioc_streamoff = isp_video_streamoff,
1235 .vidioc_enum_input = isp_video_enum_input,
1236 .vidioc_g_input = isp_video_g_input,
1237 .vidioc_s_input = isp_video_s_input,
1240 /* -----------------------------------------------------------------------------
1241 * V4L2 file operations
1244 static int isp_video_open(struct file *file)
1246 struct isp_video *video = video_drvdata(file);
1247 struct isp_video_fh *handle;
1248 struct vb2_queue *queue;
1251 handle = kzalloc(sizeof(*handle), GFP_KERNEL);
1255 v4l2_fh_init(&handle->vfh, &video->video);
1256 v4l2_fh_add(&handle->vfh);
1258 /* If this is the first user, initialise the pipeline. */
1259 if (omap3isp_get(video->isp) == NULL) {
1264 ret = media_entity_graph_walk_init(&handle->graph,
1265 &video->isp->media_dev);
1269 ret = omap3isp_pipeline_pm_use(&video->video.entity, 1, &handle->graph);
1271 omap3isp_put(video->isp);
1275 queue = &handle->queue;
1276 queue->type = video->type;
1277 queue->io_modes = VB2_MMAP | VB2_USERPTR;
1278 queue->drv_priv = handle;
1279 queue->ops = &isp_video_queue_ops;
1280 queue->mem_ops = &vb2_dma_contig_memops;
1281 queue->buf_struct_size = sizeof(struct isp_buffer);
1282 queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1284 ret = vb2_queue_init(&handle->queue);
1286 omap3isp_put(video->isp);
1290 memset(&handle->format, 0, sizeof(handle->format));
1291 handle->format.type = video->type;
1292 handle->timeperframe.denominator = 1;
1294 handle->video = video;
1295 file->private_data = &handle->vfh;
1299 v4l2_fh_del(&handle->vfh);
1300 media_entity_graph_walk_cleanup(&handle->graph);
1307 static int isp_video_release(struct file *file)
1309 struct isp_video *video = video_drvdata(file);
1310 struct v4l2_fh *vfh = file->private_data;
1311 struct isp_video_fh *handle = to_isp_video_fh(vfh);
1313 /* Disable streaming and free the buffers queue resources. */
1314 isp_video_streamoff(file, vfh, video->type);
1316 mutex_lock(&video->queue_lock);
1317 vb2_queue_release(&handle->queue);
1318 mutex_unlock(&video->queue_lock);
1320 omap3isp_pipeline_pm_use(&video->video.entity, 0, &handle->graph);
1321 media_entity_graph_walk_cleanup(&handle->graph);
1323 /* Release the file handle. */
1326 file->private_data = NULL;
1328 omap3isp_put(video->isp);
1333 static unsigned int isp_video_poll(struct file *file, poll_table *wait)
1335 struct isp_video_fh *vfh = to_isp_video_fh(file->private_data);
1336 struct isp_video *video = video_drvdata(file);
1339 mutex_lock(&video->queue_lock);
1340 ret = vb2_poll(&vfh->queue, file, wait);
1341 mutex_unlock(&video->queue_lock);
1346 static int isp_video_mmap(struct file *file, struct vm_area_struct *vma)
1348 struct isp_video_fh *vfh = to_isp_video_fh(file->private_data);
1350 return vb2_mmap(&vfh->queue, vma);
1353 static struct v4l2_file_operations isp_video_fops = {
1354 .owner = THIS_MODULE,
1355 .unlocked_ioctl = video_ioctl2,
1356 .open = isp_video_open,
1357 .release = isp_video_release,
1358 .poll = isp_video_poll,
1359 .mmap = isp_video_mmap,
1362 /* -----------------------------------------------------------------------------
1366 static const struct isp_video_operations isp_video_dummy_ops = {
1369 int omap3isp_video_init(struct isp_video *video, const char *name)
1371 const char *direction;
1374 switch (video->type) {
1375 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1376 direction = "output";
1377 video->pad.flags = MEDIA_PAD_FL_SINK
1378 | MEDIA_PAD_FL_MUST_CONNECT;
1380 case V4L2_BUF_TYPE_VIDEO_OUTPUT:
1381 direction = "input";
1382 video->pad.flags = MEDIA_PAD_FL_SOURCE
1383 | MEDIA_PAD_FL_MUST_CONNECT;
1384 video->video.vfl_dir = VFL_DIR_TX;
1391 video->alloc_ctx = vb2_dma_contig_init_ctx(video->isp->dev);
1392 if (IS_ERR(video->alloc_ctx))
1393 return PTR_ERR(video->alloc_ctx);
1395 ret = media_entity_pads_init(&video->video.entity, 1, &video->pad);
1397 vb2_dma_contig_cleanup_ctx(video->alloc_ctx);
1401 mutex_init(&video->mutex);
1402 atomic_set(&video->active, 0);
1404 spin_lock_init(&video->pipe.lock);
1405 mutex_init(&video->stream_lock);
1406 mutex_init(&video->queue_lock);
1407 spin_lock_init(&video->irqlock);
1409 /* Initialize the video device. */
1410 if (video->ops == NULL)
1411 video->ops = &isp_video_dummy_ops;
1413 video->video.fops = &isp_video_fops;
1414 snprintf(video->video.name, sizeof(video->video.name),
1415 "OMAP3 ISP %s %s", name, direction);
1416 video->video.vfl_type = VFL_TYPE_GRABBER;
1417 video->video.release = video_device_release_empty;
1418 video->video.ioctl_ops = &isp_video_ioctl_ops;
1419 video->pipe.stream_state = ISP_PIPELINE_STREAM_STOPPED;
1421 video_set_drvdata(&video->video, video);
1426 void omap3isp_video_cleanup(struct isp_video *video)
1428 vb2_dma_contig_cleanup_ctx(video->alloc_ctx);
1429 media_entity_cleanup(&video->video.entity);
1430 mutex_destroy(&video->queue_lock);
1431 mutex_destroy(&video->stream_lock);
1432 mutex_destroy(&video->mutex);
1435 int omap3isp_video_register(struct isp_video *video, struct v4l2_device *vdev)
1439 video->video.v4l2_dev = vdev;
1441 ret = video_register_device(&video->video, VFL_TYPE_GRABBER, -1);
1443 dev_err(video->isp->dev,
1444 "%s: could not register video device (%d)\n",
1450 void omap3isp_video_unregister(struct isp_video *video)
1452 if (video_is_registered(&video->video))
1453 video_unregister_device(&video->video);