Skip to contentSkip to conversation

V4L2: OMAP: VOUT: Extend V4L2 support for OMAP4

PATCH Superseded Amber Jain 2 participants 15 messages Jun 7, 2011 – Jul 6, 2011 Media (V4L/DVB)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Amber Jain

author
#0 lore raw

cover V4L2: OMAP: VOUT: Extend V4L2 support for OMAP4

This patch set addresses following:
- Extend omap vout isr for secondary LCD over DPI panel.
- Extend omap vout isr for HDMI interface.
- DMA map and unmap the V4L2 buffers in qbuf and dqbuf so that they are properly flushed into memory before DMA starts. If this not done we were seeing artifacts on OMAP4.
- Adapt to V4L2 multiplanar API's.
- Add support for NV12 format to omap vout on OMAP4.
- Minor cleanup to remove unnecessary code.

Can be tested using v4l2 streaming over:
https://gitorious.org/~amber/linux-omap-dss2/amber-omap-dss2/commits/v4l2-multi-planar

Amber Jain (6):
V4L2: OMAP: VOUT: isr handling extended for DPI and HDMI interface
V4L2: OMAP: VOUT: dma map and unmap v4l2 buffers in qbuf and dqbuf
V4L2: OMAP: VOUT: Adapt to Multiplanar APIs
V4L2: OMAP: VOUT: Modifications to support 1-plane Multiplanar for
RGB/YUYV formats
V4L2: OMAP: VOUT: Changes for NV12 format support for OMAP4
V4l2: OMAP: VOUT: Minor Cleanup, removing the unnecessary code.

 drivers/media/video/omap/omap_vout.c    |  305 +++++++++++++++++++++----------
 drivers/media/video/omap/omap_voutdef.h |    4 +
 drivers/media/video/omap/omap_voutlib.c |   36 ++--
 drivers/media/video/omap/omap_voutlib.h |    6 +-
 4 files changed, 236 insertions(+), 115 deletions(-)
author
#1 lore raw

PATCH 1/6 V4L2: OMAP: VOUT: isr handling extended for DPI and HDMI interface

Extending the omap vout isr handling for:
- secondary lcd over DPI interface,
- HDMI interface.

---
 drivers/media/video/omap/omap_vout.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)
drivers/media/video/omap/omap_vout.c +19 -7
index a831241..6fe7efa 100644
@@ -544,10 +544,20 @@ void omap_vout_isr(void *arg, unsigned int irqstatus)
 
 	spin_lock(&vout->vbq_lock);
 	do_gettimeofday(&timevalue);
-	if (cur_display->type == OMAP_DISPLAY_TYPE_DPI) {
-		if (!(irqstatus & DISPC_IRQ_VSYNC))
-			goto vout_isr_err;
 
+	if (cur_display->type != OMAP_DISPLAY_TYPE_VENC) {
+		switch (cur_display->type) {
+		case OMAP_DISPLAY_TYPE_DPI:
+			if (!(irqstatus & (DISPC_IRQ_VSYNC | DISPC_IRQ_VSYNC2)))
+				goto vout_isr_err;
+			break;
+		case OMAP_DISPLAY_TYPE_HDMI:
+			if (!(irqstatus & DISPC_IRQ_EVSYNC_EVEN))
+				goto vout_isr_err;
+			break;
+		default:
+			goto vout_isr_err;
+		}
 		if (!vout->first_int && (vout->cur_frm != vout->next_frm)) {
 			vout->cur_frm->ts = timevalue;
 			vout->cur_frm->state = VIDEOBUF_DONE;
@@ -571,7 +581,7 @@ void omap_vout_isr(void *arg, unsigned int irqstatus)
 		ret = omapvid_init(vout, addr);
 		if (ret)
 			printk(KERN_ERR VOUT_NAME
-					"failed to set overlay info\n");
+				"failed to set overlay info\n");
 		/* Enable the pipeline and set the Go bit */
 		ret = omapvid_apply_changes(vout);
 		if (ret)
@@ -925,7 +935,7 @@ static int omap_vout_release(struct file *file)
 		u32 mask = 0;
 
 		mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN |
-			DISPC_IRQ_EVSYNC_ODD;
+			DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_VSYNC2;
 		omap_dispc_unregister_isr(omap_vout_isr, vout, mask);
 		vout->streaming = 0;
 
@@ -1596,7 +1606,8 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
 	addr = (unsigned long) vout->queued_buf_addr[vout->cur_frm->i]
 		+ vout->cropped_offset;
 
-	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN | DISPC_IRQ_EVSYNC_ODD;
+	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN | DISPC_IRQ_EVSYNC_ODD
+		| DISPC_IRQ_VSYNC2;
 
 	omap_dispc_register_isr(omap_vout_isr, vout, mask);
 
@@ -1646,7 +1657,8 @@ static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
 		return -EINVAL;
 
 	vout->streaming = 0;
-	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN | DISPC_IRQ_EVSYNC_ODD;
+	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN | DISPC_IRQ_EVSYNC_ODD
+		| DISPC_IRQ_VSYNC2;
 
 	omap_dispc_unregister_isr(omap_vout_isr, vout, mask);
 
Signature · 1 line
1.7.1
author
#4 lore raw

PATCH 2/6 V4L2: OMAP: VOUT: dma map and unmap v4l2 buffers in qbuf and dqbuf

In reply to Amber Jain

Add support to map the buffer using dma_map_single during qbuf which inturn calls cache flush and unmap the same during dqbuf. This is done to prevent the artifacts seen because of cache-coherency issues on OMAP4

---
 drivers/media/video/omap/omap_vout.c |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)
drivers/media/video/omap/omap_vout.c +27 -2
index 6fe7efa..435fe65 100644
@@ -37,6 +37,7 @@
 #include <linux/platform_device.h>
 #include <linux/irq.h>
 #include <linux/videodev2.h>
+#include <linux/dma-mapping.h>
 
 #include <media/videobuf-dma-contig.h>
 #include <media/v4l2-device.h>
@@ -768,6 +769,17 @@ static int omap_vout_buffer_prepare(struct videobuf_queue *q,
 		vout->queued_buf_addr[vb->i] = (u8 *)
 			omap_vout_uservirt_to_phys(vb->baddr);
 	} else {
+		int addr, dma_addr;
+		unsigned long size;
+
+		addr = (unsigned long) vout->buf_virt_addr[vb->i];
+		size = (unsigned long) vb->size;
+
+		dma_addr = dma_map_single(vout->vid_dev->v4l2_dev.dev, (void *) addr,
+				(unsigned) size, DMA_TO_DEVICE);
+		if (dma_mapping_error(vout->vid_dev->v4l2_dev.dev, dma_addr))
+			printk(KERN_ERR "dma_map_single failed\n");
+
 		vout->queued_buf_addr[vb->i] = (u8 *)vout->buf_phy_addr[vb->i];
 	}
 
@@ -1549,15 +1561,28 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b)
 	struct omap_vout_device *vout = fh;
 	struct videobuf_queue *q = &vout->vbq;
 
+	unsigned long size;
+	u32 addr;
+	struct videobuf_buffer *vb;
+	int ret;
+
+	vb = q->bufs[b->index];
+
 	if (!vout->streaming)
 		return -EINVAL;
 
 	if (file->f_flags & O_NONBLOCK)
 		/* Call videobuf_dqbuf for non blocking mode */
-		return videobuf_dqbuf(q, (struct v4l2_buffer *)b, 1);
+		ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 1);
 	else
 		/* Call videobuf_dqbuf for  blocking mode */
-		return videobuf_dqbuf(q, (struct v4l2_buffer *)b, 0);
+		ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 0);
+
+	addr = (unsigned long) vout->buf_phy_addr[vb->i];
+	size = (unsigned long) vb->size;
+	dma_unmap_single(vout->vid_dev->v4l2_dev.dev,  addr,
+				(unsigned) size, DMA_TO_DEVICE);
+	return ret;
 }
 
 static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
Signature · 1 line
1.7.1
author
#7 lore raw

PATCH 3/6 V4L2: OMAP: VOUT: Adapt to Multiplanar APIs

In reply to Amber Jain

Adapting the omap_vout driver for multiplanar API support.

---
 drivers/media/video/omap/omap_vout.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
drivers/media/video/omap/omap_vout.c +10 -9
index 435fe65..70fb45e 100644
@@ -1014,12 +1014,13 @@ static int vidioc_querycap(struct file *file, void *fh,
 	strlcpy(cap->driver, VOUT_NAME, sizeof(cap->driver));
 	strlcpy(cap->card, vout->vfd->name, sizeof(cap->card));
 	cap->bus_info[0] = '\0';
-	cap->capabilities = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_OUTPUT;
+	cap->capabilities = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_OUTPUT |
+				V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
 
 	return 0;
 }
 
-static int vidioc_enum_fmt_vid_out(struct file *file, void *fh,
+static int vidioc_enum_fmt_vid_out_mplane(struct file *file, void *fh,
 			struct v4l2_fmtdesc *fmt)
 {
 	int index = fmt->index;
@@ -1038,7 +1039,7 @@ static int vidioc_enum_fmt_vid_out(struct file *file, void *fh,
 	return 0;
 }
 
-static int vidioc_g_fmt_vid_out(struct file *file, void *fh,
+static int vidioc_g_fmt_vid_out_mplane(struct file *file, void *fh,
 			struct v4l2_format *f)
 {
 	struct omap_vout_device *vout = fh;
@@ -1048,7 +1049,7 @@ static int vidioc_g_fmt_vid_out(struct file *file, void *fh,
 
 }
 
-static int vidioc_try_fmt_vid_out(struct file *file, void *fh,
+static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *fh,
 			struct v4l2_format *f)
 {
 	struct omap_overlay *ovl;
@@ -1071,7 +1072,7 @@ static int vidioc_try_fmt_vid_out(struct file *file, void *fh,
 	return 0;
 }
 
-static int vidioc_s_fmt_vid_out(struct file *file, void *fh,
+static int vidioc_s_fmt_vid_out_mplane(struct file *file, void *fh,
 			struct v4l2_format *f)
 {
 	int ret, bpp;
@@ -1817,10 +1818,10 @@ static int vidioc_g_fbuf(struct file *file, void *fh,
 
 static const struct v4l2_ioctl_ops vout_ioctl_ops = {
 	.vidioc_querycap      			= vidioc_querycap,
-	.vidioc_enum_fmt_vid_out 		= vidioc_enum_fmt_vid_out,
-	.vidioc_g_fmt_vid_out			= vidioc_g_fmt_vid_out,
-	.vidioc_try_fmt_vid_out			= vidioc_try_fmt_vid_out,
-	.vidioc_s_fmt_vid_out			= vidioc_s_fmt_vid_out,
+	.vidioc_enum_fmt_vid_out_mplane		= vidioc_enum_fmt_vid_out_mplane,
+	.vidioc_g_fmt_vid_out_mplane		= vidioc_g_fmt_vid_out_mplane,
+	.vidioc_try_fmt_vid_out_mplane		= vidioc_try_fmt_vid_out_mplane,
+	.vidioc_s_fmt_vid_out_mplane		= vidioc_s_fmt_vid_out_mplane,
 	.vidioc_queryctrl    			= vidioc_queryctrl,
 	.vidioc_g_ctrl       			= vidioc_g_ctrl,
 	.vidioc_s_fbuf				= vidioc_s_fbuf,
Signature · 1 line
1.7.1
author
#9 lore raw

PATCH 4/6 V4L2: OMAP: VOUT: Modifications to support 1-plane Multiplanar for RGB/YUYV formats

In reply to Amber Jain

The changes involved are to utilise the various structures of Multiplanar framework.

---
 drivers/media/video/omap/omap_vout.c    |  126 ++++++++++++++++---------------
 drivers/media/video/omap/omap_voutdef.h |    1 +
 drivers/media/video/omap/omap_voutlib.c |   36 +++++-----
 drivers/media/video/omap/omap_voutlib.h |    6 +-
 4 files changed, 88 insertions(+), 81 deletions(-)
drivers/media/video/omap/omap_vout.c +66 -60
index 70fb45e..f0946ea 100644
@@ -145,50 +145,53 @@ const static struct v4l2_fmtdesc omap_formats[] = {
 /*
  * Try format
  */
-static int omap_vout_try_format(struct v4l2_pix_format *pix)
+static int omap_vout_try_format(struct v4l2_pix_format_mplane *pix_mp)
 {
-	int ifmt, bpp = 0;
+	int ifmt, bpp = 0, i = 0;
 
-	pix->height = clamp(pix->height, (u32)VID_MIN_HEIGHT,
+	pix_mp->height = clamp(pix_mp->height, (u32)VID_MIN_HEIGHT,
 						(u32)VID_MAX_HEIGHT);
-	pix->width = clamp(pix->width, (u32)VID_MIN_WIDTH, (u32)VID_MAX_WIDTH);
+	pix_mp->width = clamp(pix_mp->width, (u32)VID_MIN_WIDTH, (u32)VID_MAX_WIDTH);
 
 	for (ifmt = 0; ifmt < NUM_OUTPUT_FORMATS; ifmt++) {
-		if (pix->pixelformat == omap_formats[ifmt].pixelformat)
+		if (pix_mp->pixelformat == omap_formats[ifmt].pixelformat)
 			break;
 	}
 
 	if (ifmt == NUM_OUTPUT_FORMATS)
 		ifmt = 0;
 
-	pix->pixelformat = omap_formats[ifmt].pixelformat;
-	pix->field = V4L2_FIELD_ANY;
-	pix->priv = 0;
+	pix_mp->pixelformat = omap_formats[ifmt].pixelformat;
+	pix_mp->field = V4L2_FIELD_ANY;
 
-	switch (pix->pixelformat) {
+	switch (pix_mp->pixelformat) {
 	case V4L2_PIX_FMT_YUYV:
 	case V4L2_PIX_FMT_UYVY:
 	default:
-		pix->colorspace = V4L2_COLORSPACE_JPEG;
+		pix_mp->colorspace = V4L2_COLORSPACE_JPEG;
 		bpp = YUYV_BPP;
 		break;
 	case V4L2_PIX_FMT_RGB565:
 	case V4L2_PIX_FMT_RGB565X:
-		pix->colorspace = V4L2_COLORSPACE_SRGB;
+		pix_mp->colorspace = V4L2_COLORSPACE_SRGB;
 		bpp = RGB565_BPP;
 		break;
 	case V4L2_PIX_FMT_RGB24:
-		pix->colorspace = V4L2_COLORSPACE_SRGB;
+		pix_mp->colorspace = V4L2_COLORSPACE_SRGB;
 		bpp = RGB24_BPP;
 		break;
 	case V4L2_PIX_FMT_RGB32:
 	case V4L2_PIX_FMT_BGR32:
-		pix->colorspace = V4L2_COLORSPACE_SRGB;
+		pix_mp->colorspace = V4L2_COLORSPACE_SRGB;
 		bpp = RGB32_BPP;
 		break;
 	}
-	pix->bytesperline = pix->width * bpp;
-	pix->sizeimage = pix->bytesperline * pix->height;
+
+	for (i = 0; i < pix_mp->num_planes; ++i) {
+		int bpl = pix_mp->width * bpp;
+		pix_mp->plane_fmt[i].bytesperline = bpl;
+		pix_mp->plane_fmt[i].sizeimage = bpl * pix_mp->height;
+	}
 
 	return bpp;
 }
@@ -286,7 +289,7 @@ static int omap_vout_calculate_offset(struct omap_vout_device *vout)
 {
 	struct omapvideo_info *ovid;
 	struct v4l2_rect *crop = &vout->crop;
-	struct v4l2_pix_format *pix = &vout->pix;
+	struct v4l2_pix_format_mplane *pix_mp = &vout->pix_mp;
 	int *cropped_offset = &vout->cropped_offset;
 	int ps = 2, line_length = 0;
 
@@ -295,14 +298,14 @@ static int omap_vout_calculate_offset(struct omap_vout_device *vout)
 	if (ovid->rotation_type == VOUT_ROT_VRFB) {
 		omap_vout_calculate_vrfb_offset(vout);
 	} else {
-		vout->line_length = line_length = pix->width;
+		vout->line_length = line_length = pix_mp->width;
 
-		if (V4L2_PIX_FMT_YUYV == pix->pixelformat ||
-			V4L2_PIX_FMT_UYVY == pix->pixelformat)
+		if (V4L2_PIX_FMT_YUYV == pix_mp->pixelformat ||
+			V4L2_PIX_FMT_UYVY == pix_mp->pixelformat)
 			ps = 2;
-		else if (V4L2_PIX_FMT_RGB32 == pix->pixelformat)
+		else if (V4L2_PIX_FMT_RGB32 == pix_mp->pixelformat)
 			ps = 4;
-		else if (V4L2_PIX_FMT_RGB24 == pix->pixelformat)
+		else if (V4L2_PIX_FMT_RGB24 == pix_mp->pixelformat)
 			ps = 3;
 
 		vout->ps = ps;
@@ -324,13 +327,13 @@ static int video_mode_to_dss_mode(struct omap_vout_device *vout)
 {
 	struct omap_overlay *ovl;
 	struct omapvideo_info *ovid;
-	struct v4l2_pix_format *pix = &vout->pix;
+	struct v4l2_pix_format_mplane *pix_mp = &vout->pix_mp;
 	enum omap_color_mode mode;
 
 	ovid = &vout->vid_info;
 	ovl = ovid->overlays[0];
 
-	switch (pix->pixelformat) {
+	switch (pix_mp->pixelformat) {
 	case 0:
 		break;
 	case V4L2_PIX_FMT_YUYV:
@@ -370,7 +373,7 @@ int omapvid_setup_overlay(struct omap_vout_device *vout,
 	int cropheight, cropwidth, pixheight, pixwidth;
 
 	if ((ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0 &&
-			(outw != vout->pix.width || outh != vout->pix.height)) {
+			(outw != vout->pix_mp.width || outh != vout->pix_mp.height)) {
 		ret = -EINVAL;
 		goto setup_ovl_err;
 	}
@@ -387,13 +390,13 @@ int omapvid_setup_overlay(struct omap_vout_device *vout,
 	if (rotate_90_or_270(vout)) {
 		cropheight = vout->crop.width;
 		cropwidth = vout->crop.height;
-		pixheight = vout->pix.width;
-		pixwidth = vout->pix.height;
+		pixheight = vout->pix_mp.width;
+		pixwidth = vout->pix_mp.height;
 	} else {
 		cropheight = vout->crop.height;
 		cropwidth = vout->crop.width;
-		pixheight = vout->pix.height;
-		pixwidth = vout->pix.width;
+		pixheight = vout->pix_mp.height;
+		pixwidth = vout->pix_mp.width;
 	}
 
 	ovl->get_overlay_info(ovl, &info);
@@ -683,7 +686,7 @@ static int omap_vout_buffer_setup(struct videobuf_queue *q, unsigned int *count,
 		return 0;
 
 	/* Now allocated the V4L2 buffers */
-	*size = PAGE_ALIGN(vout->pix.width * vout->pix.height * vout->bpp);
+	*size = PAGE_ALIGN(vout->pix_mp.width * vout->pix_mp.height * vout->bpp);
 	startindex = (vout->vid == OMAP_VIDEO1) ?
 		video1_numbuffers : video2_numbuffers;
 
@@ -753,8 +756,8 @@ static int omap_vout_buffer_prepare(struct videobuf_queue *q,
 	struct omapvideo_info *ovid = &vout->vid_info;
 
 	if (VIDEOBUF_NEEDS_INIT == vb->state) {
-		vb->width = vout->pix.width;
-		vb->height = vout->pix.height;
+		vb->width = vout->pix_mp.width;
+		vb->height = vout->pix_mp.height;
 		vb->size = vb->width * vb->height * vout->bpp;
 		vb->field = field;
 	}
@@ -1044,7 +1047,7 @@ static int vidioc_g_fmt_vid_out_mplane(struct file *file, void *fh,
 {
 	struct omap_vout_device *vout = fh;
 
-	f->fmt.pix = vout->pix;
+	f->fmt.pix_mp = vout->pix_mp;
 	return 0;
 
 }
@@ -1068,14 +1071,14 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *fh,
 	vout->fbuf.fmt.height = timing->y_res;
 	vout->fbuf.fmt.width = timing->x_res;
 
-	omap_vout_try_format(&f->fmt.pix);
+	omap_vout_try_format(&f->fmt.pix_mp);
 	return 0;
 }
 
 static int vidioc_s_fmt_vid_out_mplane(struct file *file, void *fh,
 			struct v4l2_format *f)
 {
-	int ret, bpp;
+	int ret, bpp, i;
 	struct omap_overlay *ovl;
 	struct omapvideo_info *ovid;
 	struct omap_video_timings *timing;
@@ -1099,7 +1102,7 @@ static int vidioc_s_fmt_vid_out_mplane(struct file *file, void *fh,
 	/* We dont support RGB24-packed mode if vrfb rotation
 	 * is enabled*/
 	if ((rotation_enabled(vout)) &&
-			f->fmt.pix.pixelformat == V4L2_PIX_FMT_RGB24) {
+			f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_RGB24) {
 		ret = -EINVAL;
 		goto s_fmt_vid_out_exit;
 	}
@@ -1116,21 +1119,23 @@ static int vidioc_s_fmt_vid_out_mplane(struct file *file, void *fh,
 
 	/* change to samller size is OK */
 
-	bpp = omap_vout_try_format(&f->fmt.pix);
-	f->fmt.pix.sizeimage = f->fmt.pix.width * f->fmt.pix.height * bpp;
+	bpp = omap_vout_try_format(&f->fmt.pix_mp);
 
+	for (i = 0; i < f->fmt.pix_mp.num_planes; ++i)
+		f->fmt.pix_mp.plane_fmt[i].sizeimage = f->fmt.pix_mp.width *
+						f->fmt.pix_mp.height * bpp;
 	/* try & set the new output format */
 	vout->bpp = bpp;
-	vout->pix = f->fmt.pix;
+	vout->pix_mp = f->fmt.pix_mp;
 	vout->vrfb_bpp = 1;
 
 	/* If YUYV then vrfb bpp is 2, for  others its 1 */
-	if (V4L2_PIX_FMT_YUYV == vout->pix.pixelformat ||
-			V4L2_PIX_FMT_UYVY == vout->pix.pixelformat)
+	if (V4L2_PIX_FMT_YUYV == vout->pix_mp.pixelformat ||
+			V4L2_PIX_FMT_UYVY == vout->pix_mp.pixelformat)
 		vout->vrfb_bpp = 2;
 
 	/* set default crop and win */
-	omap_vout_new_format(&vout->pix, &vout->fbuf, &vout->crop, &vout->win);
+	omap_vout_new_format(&vout->pix_mp, &vout->fbuf, &vout->crop, &vout->win);
 
 	/* Save the changes in the overlay strcuture */
 	ret = omapvid_init(vout, 0);
@@ -1239,16 +1244,16 @@ static int vidioc_cropcap(struct file *file, void *fh,
 		struct v4l2_cropcap *cropcap)
 {
 	struct omap_vout_device *vout = fh;
-	struct v4l2_pix_format *pix = &vout->pix;
+	struct v4l2_pix_format_mplane *pix_mp = &vout->pix_mp;
 
 	if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
 		return -EINVAL;
 
 	/* Width and height are always even */
-	cropcap->bounds.width = pix->width & ~1;
-	cropcap->bounds.height = pix->height & ~1;
+	cropcap->bounds.width = pix_mp->width & ~1;
+	cropcap->bounds.height = pix_mp->height & ~1;
 
-	omap_vout_default_crop(&vout->pix, &vout->fbuf, &cropcap->defrect);
+	omap_vout_default_crop(&vout->pix_mp, &vout->fbuf, &cropcap->defrect);
 	cropcap->pixelaspect.numerator = 1;
 	cropcap->pixelaspect.denominator = 1;
 	return 0;
@@ -1295,7 +1300,7 @@ static int vidioc_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
 	}
 
 	if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
-		ret = omap_vout_new_crop(&vout->pix, &vout->crop, &vout->win,
+		ret = omap_vout_new_crop(&vout->pix_mp, &vout->crop, &vout->win,
 				&vout->fbuf, &crop->c);
 
 s_crop_err:
@@ -1378,7 +1383,7 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *a)
 			break;
 		}
 
-		if (rotation && vout->pix.pixelformat == V4L2_PIX_FMT_RGB24) {
+		if (rotation && vout->pix_mp.pixelformat == V4L2_PIX_FMT_RGB24) {
 			mutex_unlock(&vout->lock);
 			ret = -EINVAL;
 			break;
@@ -1438,7 +1443,7 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *a)
 			break;
 		}
 
-		if (mirror  && vout->pix.pixelformat == V4L2_PIX_FMT_RGB24) {
+		if (mirror  && vout->pix_mp.pixelformat == V4L2_PIX_FMT_RGB24) {
 			mutex_unlock(&vout->lock);
 			ret = -EINVAL;
 			break;
@@ -1541,7 +1546,7 @@ static int vidioc_qbuf(struct file *file, void *fh,
 		return -EINVAL;
 	}
 	if (V4L2_MEMORY_USERPTR == buffer->memory) {
-		if ((buffer->length < vout->pix.sizeimage) ||
+		if ((buffer->length < vout->pix_mp.plane_fmt[0].sizeimage) ||
 				(0 == buffer->m.userptr)) {
 			return -EINVAL;
 		}
@@ -1855,25 +1860,26 @@ static const struct v4l2_file_operations omap_vout_fops = {
 static int __init omap_vout_setup_video_data(struct omap_vout_device *vout)
 {
 	struct video_device *vfd;
-	struct v4l2_pix_format *pix;
+	struct v4l2_pix_format_mplane *pix_mp;
 	struct v4l2_control *control;
 	struct omap_dss_device *display =
 		vout->vid_info.overlays[0]->manager->device;
 
 	/* set the default pix */
-	pix = &vout->pix;
+	pix_mp = &vout->pix_mp;
 
 	/* Set the default picture of QVGA  */
-	pix->width = QQVGA_WIDTH;
-	pix->height = QQVGA_HEIGHT;
+	pix_mp->width = QQVGA_WIDTH;
+	pix_mp->height = QQVGA_HEIGHT;
 
 	/* Default pixel format is RGB 5-6-5 */
-	pix->pixelformat = V4L2_PIX_FMT_RGB565;
-	pix->field = V4L2_FIELD_ANY;
-	pix->bytesperline = pix->width * 2;
-	pix->sizeimage = pix->bytesperline * pix->height;
-	pix->priv = 0;
-	pix->colorspace = V4L2_COLORSPACE_JPEG;
+	pix_mp->pixelformat = V4L2_PIX_FMT_RGB565;
+	pix_mp->field = V4L2_FIELD_ANY;
+	/* Single plane as RGB is defualt */
+	pix_mp->plane_fmt[0].bytesperline = pix_mp->width * 2;
+	pix_mp->plane_fmt[0].sizeimage = pix_mp->plane_fmt[0].bytesperline
+					* pix_mp->height;
+	pix_mp->colorspace = V4L2_COLORSPACE_JPEG;
 
 	vout->bpp = RGB565_BPP;
 	vout->fbuf.fmt.width  =  display->panel.timings.x_res;
@@ -1886,7 +1892,7 @@ static int __init omap_vout_setup_video_data(struct omap_vout_device *vout)
 		V4L2_FBUF_CAP_SRC_CHROMAKEY | V4L2_FBUF_CAP_CHROMAKEY;
 	vout->win.chromakey = 0;
 
-	omap_vout_new_format(pix, &vout->fbuf, &vout->crop, &vout->win);
+	omap_vout_new_format(pix_mp, &vout->fbuf, &vout->crop, &vout->win);
 
 	/*Initialize the control variables for
 	  rotation, flipping and background color. */
drivers/media/video/omap/omap_voutdef.h +1 -0
index 26e2b63..6f94ea1 100644
@@ -142,6 +142,7 @@ struct omap_vout_device {
 	bool streaming;
 
 	struct v4l2_pix_format pix;
+	struct v4l2_pix_format_mplane pix_mp;
 	struct v4l2_rect crop;
 	struct v4l2_window win;
 	struct v4l2_framebuffer fbuf;
drivers/media/video/omap/omap_voutlib.c +18 -18
index c28ef05..e3a712e 100644
@@ -38,17 +38,17 @@ MODULE_LICENSE("GPL");
  * that will fit on the display.  The default cropping rectangle is centered in
  * the image.  All dimensions and offsets are rounded down to even numbers.
  */
-void omap_vout_default_crop(struct v4l2_pix_format *pix,
+void omap_vout_default_crop(struct v4l2_pix_format_mplane *pix_mp,
 		  struct v4l2_framebuffer *fbuf, struct v4l2_rect *crop)
 {
-	crop->width = (pix->width < fbuf->fmt.width) ?
-		pix->width : fbuf->fmt.width;
-	crop->height = (pix->height < fbuf->fmt.height) ?
-		pix->height : fbuf->fmt.height;
+	crop->width = (pix_mp->width < fbuf->fmt.width) ?
+		pix_mp->width : fbuf->fmt.width;
+	crop->height = (pix_mp->height < fbuf->fmt.height) ?
+		pix_mp->height : fbuf->fmt.height;
 	crop->width &= ~1;
 	crop->height &= ~1;
-	crop->left = ((pix->width - crop->width) >> 1) & ~1;
-	crop->top = ((pix->height - crop->height) >> 1) & ~1;
+	crop->left = ((pix_mp->width - crop->width) >> 1) & ~1;
+	crop->top = ((pix_mp->height - crop->height) >> 1) & ~1;
 }
 EXPORT_SYMBOL_GPL(omap_vout_default_crop);
 
@@ -160,7 +160,7 @@ EXPORT_SYMBOL_GPL(omap_vout_new_window);
  * Returns zero if successful, or -EINVAL if the requested cropping rectangle is
  * impossible and cannot reasonably be adjusted.
  */
-int omap_vout_new_crop(struct v4l2_pix_format *pix,
+int omap_vout_new_crop(struct v4l2_pix_format_mplane *pix_mp,
 	      struct v4l2_rect *crop, struct v4l2_window *win,
 	      struct v4l2_framebuffer *fbuf, const struct v4l2_rect *new_crop)
 {
@@ -179,14 +179,14 @@ int omap_vout_new_crop(struct v4l2_pix_format *pix,
 		try_crop.height += try_crop.top;
 		try_crop.top = 0;
 	}
-	try_crop.width = (try_crop.width < pix->width) ?
-		try_crop.width : pix->width;
-	try_crop.height = (try_crop.height < pix->height) ?
-		try_crop.height : pix->height;
-	if (try_crop.left + try_crop.width > pix->width)
-		try_crop.width = pix->width - try_crop.left;
-	if (try_crop.top + try_crop.height > pix->height)
-		try_crop.height = pix->height - try_crop.top;
+	try_crop.width = (try_crop.width < pix_mp->width) ?
+		try_crop.width : pix_mp->width;
+	try_crop.height = (try_crop.height < pix_mp->height) ?
+		try_crop.height : pix_mp->height;
+	if (try_crop.left + try_crop.width > pix_mp->width)
+		try_crop.width = pix_mp->width - try_crop.left;
+	if (try_crop.top + try_crop.height > pix_mp->height)
+		try_crop.height = pix_mp->height - try_crop.top;
 
 	try_crop.width &= ~1;
 	try_crop.height &= ~1;
@@ -276,14 +276,14 @@ EXPORT_SYMBOL_GPL(omap_vout_new_crop);
  * the same size as crop and is centered on the display.
  * All sizes and offsets are constrained to be even numbers.
  */
-void omap_vout_new_format(struct v4l2_pix_format *pix,
+void omap_vout_new_format(struct v4l2_pix_format_mplane *pix_mp,
 		struct v4l2_framebuffer *fbuf, struct v4l2_rect *crop,
 		struct v4l2_window *win)
 {
 	/* crop defines the preview source window in the image capture
 	 * buffer
 	 */
-	omap_vout_default_crop(pix, fbuf, crop);
+	omap_vout_default_crop(pix_mp, fbuf, crop);
 
 	/* win defines the preview target window on the display */
 	win->w.width = crop->width;
drivers/media/video/omap/omap_voutlib.h +3 -3
index 1d722be..2a6d501 100644
@@ -12,10 +12,10 @@
 #ifndef OMAP_VOUTLIB_H
 #define OMAP_VOUTLIB_H
 
-extern void omap_vout_default_crop(struct v4l2_pix_format *pix,
+extern void omap_vout_default_crop(struct v4l2_pix_format_mplane *pix_mp,
 		struct v4l2_framebuffer *fbuf, struct v4l2_rect *crop);
 
-extern int omap_vout_new_crop(struct v4l2_pix_format *pix,
+extern int omap_vout_new_crop(struct v4l2_pix_format_mplane *pix_mp,
 		struct v4l2_rect *crop, struct v4l2_window *win,
 		struct v4l2_framebuffer *fbuf,
 		const struct v4l2_rect *new_crop);
@@ -27,7 +27,7 @@ extern int omap_vout_new_window(struct v4l2_rect *crop,
 		struct v4l2_window *win, struct v4l2_framebuffer *fbuf,
 		struct v4l2_window *new_win);
 
-extern void omap_vout_new_format(struct v4l2_pix_format *pix,
+extern void omap_vout_new_format(struct v4l2_pix_format_mplane *pix_mp,
 		struct v4l2_framebuffer *fbuf, struct v4l2_rect *crop,
 		struct v4l2_window *win);
 extern unsigned long omap_vout_alloc_buffer(u32 buf_size, u32 *phys_addr);
Signature · 1 line
1.7.1
author
#10 lore raw

PATCH 5/6 V4L2: OMAP: VOUT: Changes for NV12 format support for OMAP4

In reply to Amber Jain

V4l2 side changes to add NV12 format supportted by OMAP4.

---
 drivers/media/video/omap/omap_vout.c    |  113 ++++++++++++++++++++++++++-----
 drivers/media/video/omap/omap_voutdef.h |    3 +
 2 files changed, 99 insertions(+), 17 deletions(-)
drivers/media/video/omap/omap_vout.c +96 -17
index f0946ea..25025a1 100644
@@ -138,6 +138,10 @@ const static struct v4l2_fmtdesc omap_formats[] = {
 		.description = "UYVY, packed",
 		.pixelformat = V4L2_PIX_FMT_UYVY,
 	},
+	{
+		.description = "NV12 - YUV420 format",
+		.pixelformat = V4L2_PIX_FMT_NV12,
+	},
 };
 
 #define NUM_OUTPUT_FORMATS (ARRAY_SIZE(omap_formats))
@@ -185,12 +189,23 @@ static int omap_vout_try_format(struct v4l2_pix_format_mplane *pix_mp)
 		pix_mp->colorspace = V4L2_COLORSPACE_SRGB;
 		bpp = RGB32_BPP;
 		break;
+	case V4L2_PIX_FMT_NV12:
+		pix_mp->colorspace = V4L2_COLORSPACE_JPEG;
+		bpp = 1;
+		break;
 	}
 
 	for (i = 0; i < pix_mp->num_planes; ++i) {
 		int bpl = pix_mp->width * bpp;
-		pix_mp->plane_fmt[i].bytesperline = bpl;
+		pix_mp->plane_fmt[i].bytesperline = (bpl + PAGE_SIZE - 1) &
+					~(PAGE_SIZE - 1);
+		bpl = pix_mp->plane_fmt[i].bytesperline;
+
 		pix_mp->plane_fmt[i].sizeimage = bpl * pix_mp->height;
+
+		/* :NOTE: NV12 has width bytes per line in both Y and UV sections */
+		if (V4L2_PIX_FMT_NV12 == pix_mp->pixelformat)
+			pix_mp->plane_fmt[i].sizeimage += pix_mp->plane_fmt[i].sizeimage >> 1;
 	}
 
 	return bpp;
@@ -292,6 +307,7 @@ static int omap_vout_calculate_offset(struct omap_vout_device *vout)
 	struct v4l2_pix_format_mplane *pix_mp = &vout->pix_mp;
 	int *cropped_offset = &vout->cropped_offset;
 	int ps = 2, line_length = 0;
+	u32 *cropped_uv_offset = &vout->cropped_uv_offset;
 
 	ovid = &vout->vid_info;
 
@@ -307,11 +323,17 @@ static int omap_vout_calculate_offset(struct omap_vout_device *vout)
 			ps = 4;
 		else if (V4L2_PIX_FMT_RGB24 == pix_mp->pixelformat)
 			ps = 3;
+		else if (V4L2_PIX_FMT_NV12 == pix_mp->pixelformat)
+			ps = 1;
 
 		vout->ps = ps;
 
 		*cropped_offset = (line_length * ps) *
 			crop->top + crop->left * ps;
+
+		if (V4L2_PIX_FMT_NV12 == pix_mp->pixelformat)
+			*cropped_uv_offset = (line_length * ps) *
+				(crop->top >> 1) + (crop->left & ~1) * ps;
 	}
 
 	v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "%s Offset:%x\n",
@@ -355,6 +377,9 @@ static int video_mode_to_dss_mode(struct omap_vout_device *vout)
 	case V4L2_PIX_FMT_BGR32:
 		mode = OMAP_DSS_COLOR_RGBX32;
 		break;
+	case V4L2_PIX_FMT_NV12:
+		mode = OMAP_DSS_COLOR_NV12;
+		break;
 	default:
 		mode = -EINVAL;
 	}
@@ -366,7 +391,7 @@ static int video_mode_to_dss_mode(struct omap_vout_device *vout)
  */
 int omapvid_setup_overlay(struct omap_vout_device *vout,
 		struct omap_overlay *ovl, int posx, int posy, int outw,
-		int outh, u32 addr)
+		int outh, u32 addr, u32 uv_addr)
 {
 	int ret = 0;
 	struct omap_overlay_info info;
@@ -400,7 +425,15 @@ int omapvid_setup_overlay(struct omap_vout_device *vout,
 	}
 
 	ovl->get_overlay_info(ovl, &info);
-	info.paddr = addr;
+
+	if (addr)
+		info.paddr = addr;
+
+	if (OMAP_DSS_COLOR_NV12 == vout->dss_mode)
+		info.p_uv_addr = uv_addr;
+	else
+		info.p_uv_addr = (u32) NULL;
+
 	info.vaddr = NULL;
 	info.width = cropwidth;
 	info.height = cropheight;
@@ -430,6 +463,9 @@ int omapvid_setup_overlay(struct omap_vout_device *vout,
 		info.pos_y, info.out_width, info.out_height, info.rotation_type,
 		info.screen_width);
 
+	v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "info.puvaddr=%x\n",
+		info.p_uv_addr);
+
 	ret = ovl->set_overlay_info(ovl, &info);
 	if (ret)
 		goto setup_ovl_err;
@@ -444,7 +480,7 @@ setup_ovl_err:
 /*
  * Initialize the overlay structure
  */
-int omapvid_init(struct omap_vout_device *vout, u32 addr)
+int omapvid_init(struct omap_vout_device *vout, u32 addr, u32 uv_addr)
 {
 	int ret = 0, i;
 	struct v4l2_window *win;
@@ -495,7 +531,7 @@ int omapvid_init(struct omap_vout_device *vout, u32 addr)
 		}
 
 		ret = omapvid_setup_overlay(vout, ovl, posx, posy,
-				outw, outh, addr);
+				outw, outh, addr, uv_addr);
 		if (ret)
 			goto omapvid_init_err;
 	}
@@ -529,6 +565,7 @@ void omap_vout_isr(void *arg, unsigned int irqstatus)
 {
 	int ret;
 	u32 addr, fid;
+	u32 uv_addr;
 	struct omap_overlay *ovl;
 	struct timeval timevalue;
 	struct omapvideo_info *ovid;
@@ -581,8 +618,11 @@ void omap_vout_isr(void *arg, unsigned int irqstatus)
 		addr = (unsigned long) vout->queued_buf_addr[vout->next_frm->i]
 			+ vout->cropped_offset;
 
+		uv_addr = (unsigned long)vout->queued_buf_uv_addr[vout->next_frm->i]
+			+ vout->cropped_uv_offset;
+
 		/* First save the configuration in ovelray structure */
-		ret = omapvid_init(vout, addr);
+		ret = omapvid_init(vout, addr, uv_addr);
 		if (ret)
 			printk(KERN_ERR VOUT_NAME
 				"failed to set overlay info\n");
@@ -631,8 +671,12 @@ void omap_vout_isr(void *arg, unsigned int irqstatus)
 			addr = (unsigned long)
 				vout->queued_buf_addr[vout->next_frm->i] +
 				vout->cropped_offset;
+
+			uv_addr = (unsigned long)vout->queued_buf_uv_addr[vout->next_frm->i]
+				+ vout->cropped_uv_offset;
+
 			/* First save the configuration in ovelray structure */
-			ret = omapvid_init(vout, addr);
+			ret = omapvid_init(vout, addr, uv_addr);
 			if (ret)
 				printk(KERN_ERR VOUT_NAME
 						"failed to set overlay info\n");
@@ -686,7 +730,11 @@ static int omap_vout_buffer_setup(struct videobuf_queue *q, unsigned int *count,
 		return 0;
 
 	/* Now allocated the V4L2 buffers */
-	*size = PAGE_ALIGN(vout->pix_mp.width * vout->pix_mp.height * vout->bpp);
+	if (V4L2_PIX_FMT_NV12 == vout->pix_mp.pixelformat)
+		*size = PAGE_ALIGN(vout->pix_mp.width * vout->pix_mp.height * vout->bpp * 3/2);
+	else
+		*size = PAGE_ALIGN(vout->pix_mp.width * vout->pix_mp.height * vout->bpp);
+
 	startindex = (vout->vid == OMAP_VIDEO1) ?
 		video1_numbuffers : video2_numbuffers;
 
@@ -771,19 +819,34 @@ static int omap_vout_buffer_prepare(struct videobuf_queue *q,
 		/* Physical address */
 		vout->queued_buf_addr[vb->i] = (u8 *)
 			omap_vout_uservirt_to_phys(vb->baddr);
+		vout->queued_buf_uv_addr[vb->i] = (u8 *)
+			omap_vout_uservirt_to_phys(vb->baddr + vb->size);
 	} else {
-		int addr, dma_addr;
-		unsigned long size;
+		int addr, uv_addr, dma_addr, dma_uv_addr;
+		unsigned long size, size_uv;
 
 		addr = (unsigned long) vout->buf_virt_addr[vb->i];
 		size = (unsigned long) vb->size;
 
+		uv_addr = (unsigned long) (vout->buf_virt_addr[vb->i]
+			+ vb->size);
+
 		dma_addr = dma_map_single(vout->vid_dev->v4l2_dev.dev, (void *) addr,
 				(unsigned) size, DMA_TO_DEVICE);
 		if (dma_mapping_error(vout->vid_dev->v4l2_dev.dev, dma_addr))
 			printk(KERN_ERR "dma_map_single failed\n");
 
-		vout->queued_buf_addr[vb->i] = (u8 *)vout->buf_phy_addr[vb->i];
+		if (vout->dss_mode == OMAP_DSS_COLOR_NV12) {
+			size_uv = (unsigned long) (vb->size)/2;
+			dma_uv_addr = dma_map_single(vout->vid_dev->v4l2_dev.dev, (void *) uv_addr,
+							(unsigned) size_uv, DMA_TO_DEVICE);
+			if (dma_mapping_error(vout->vid_dev->v4l2_dev.dev, dma_uv_addr))
+				printk(KERN_ERR "dma_map_single failed\n");
+		}
+
+		vout->queued_buf_addr[vb->i] = (u8 *) vout->buf_phy_addr[vb->i];
+		vout->queued_buf_uv_addr[vb->i] = (u8 *) (vout->buf_phy_addr[vb->i]
+						+ vb->size);
 	}
 
 	if (ovid->rotation_type == VOUT_ROT_VRFB)
@@ -1121,9 +1184,13 @@ static int vidioc_s_fmt_vid_out_mplane(struct file *file, void *fh,
 
 	bpp = omap_vout_try_format(&f->fmt.pix_mp);
 
-	for (i = 0; i < f->fmt.pix_mp.num_planes; ++i)
+	for (i = 0; i < f->fmt.pix_mp.num_planes; ++i) {
 		f->fmt.pix_mp.plane_fmt[i].sizeimage = f->fmt.pix_mp.width *
 						f->fmt.pix_mp.height * bpp;
+		if (V4L2_PIX_FMT_NV12 == f->fmt.pix_mp.pixelformat)
+			f->fmt.pix_mp.plane_fmt[i].sizeimage +=
+				f->fmt.pix_mp.plane_fmt[i].sizeimage >> 1;
+	}
 	/* try & set the new output format */
 	vout->bpp = bpp;
 	vout->pix_mp = f->fmt.pix_mp;
@@ -1138,7 +1205,7 @@ static int vidioc_s_fmt_vid_out_mplane(struct file *file, void *fh,
 	omap_vout_new_format(&vout->pix_mp, &vout->fbuf, &vout->crop, &vout->win);
 
 	/* Save the changes in the overlay strcuture */
-	ret = omapvid_init(vout, 0);
+	ret = omapvid_init(vout, 0, 0);
 	if (ret) {
 		v4l2_err(&vout->vid_dev->v4l2_dev, "failed to change mode\n");
 		goto s_fmt_vid_out_exit;
@@ -1567,8 +1634,8 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b)
 	struct omap_vout_device *vout = fh;
 	struct videobuf_queue *q = &vout->vbq;
 
-	unsigned long size;
-	u32 addr;
+	unsigned long size, size_uv;
+	u32 addr, uv_addr;
 	struct videobuf_buffer *vb;
 	int ret;
 
@@ -1588,6 +1655,13 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b)
 	size = (unsigned long) vb->size;
 	dma_unmap_single(vout->vid_dev->v4l2_dev.dev,  addr,
 				(unsigned) size, DMA_TO_DEVICE);
+	if (vout->dss_mode == OMAP_DSS_COLOR_NV12) {
+		uv_addr = (unsigned long) (vout->buf_phy_addr[vb->i]
+			+ vb->size);
+		size_uv = (unsigned long) (vb->size)/2;
+		dma_unmap_single(vout->vid_dev->v4l2_dev.dev, uv_addr,
+					(unsigned) size_uv, DMA_TO_DEVICE);
+	}
 	return ret;
 }
 
@@ -1595,6 +1669,7 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
 {
 	int ret = 0, j;
 	u32 addr = 0, mask = 0;
+	u32 uv_addr = 0;
 	struct omap_vout_device *vout = fh;
 	struct videobuf_queue *q = &vout->vbq;
 	struct omapvideo_info *ovid = &vout->vid_info;
@@ -1637,6 +1712,9 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
 	addr = (unsigned long) vout->queued_buf_addr[vout->cur_frm->i]
 		+ vout->cropped_offset;
 
+	uv_addr = (unsigned long) vout->queued_buf_uv_addr[vout->cur_frm->i]
+		+ vout->cropped_uv_offset;
+
 	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN | DISPC_IRQ_EVSYNC_ODD
 		| DISPC_IRQ_VSYNC2;
 
@@ -1650,6 +1728,7 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
 			ovl->get_overlay_info(ovl, &info);
 			info.enabled = 1;
 			info.paddr = addr;
+			info.p_uv_addr = uv_addr;
 			if (ovl->set_overlay_info(ovl, &info)) {
 				ret = -EINVAL;
 				goto streamon_err1;
@@ -1658,7 +1737,7 @@ static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
 	}
 
 	/* First save the configuration in ovelray structure */
-	ret = omapvid_init(vout, addr);
+	ret = omapvid_init(vout, addr, uv_addr);
 	if (ret)
 		v4l2_err(&vout->vid_dev->v4l2_dev,
 				"failed to set overlay info\n");
@@ -2045,7 +2124,7 @@ static int __init omap_vout_create_video_devices(struct platform_device *pdev)
 		video_set_drvdata(vfd, vout);
 
 		/* Configure the overlay structure */
-		ret = omapvid_init(vid_dev->vouts[k], 0);
+		ret = omapvid_init(vid_dev->vouts[k], 0, 0);
 		if (!ret)
 			goto success;
 
drivers/media/video/omap/omap_voutdef.h +3 -0
index 6f94ea1..a2ae56a 100644
@@ -128,6 +128,8 @@ struct omap_vout_device {
 	/* keep buffer info across opens */
 	unsigned long buf_virt_addr[VIDEO_MAX_FRAME];
 	unsigned long buf_phy_addr[VIDEO_MAX_FRAME];
+	u8 *queued_buf_uv_addr[VIDEO_MAX_FRAME];
+
 	enum omap_color_mode dss_mode;
 
 	/* we don't allow to request new buffer when old buffers are
@@ -174,6 +176,7 @@ struct omap_vout_device {
 	struct list_head dma_queue;
 	u8 *queued_buf_addr[VIDEO_MAX_FRAME];
 	u32 cropped_offset;
+	u32 cropped_uv_offset;
 	s32 tv_field1_offset;
 	void *isr_handle;
 
Signature · 1 line
1.7.1
author
#11 lore raw

PATCH 6/6 V4l2: OMAP: VOUT: Minor Cleanup, removing the unnecessary code.

In reply to Amber Jain

Minor changes to remove the unused code from omap_vout driver.

---
 drivers/media/video/omap/omap_vout.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
drivers/media/video/omap/omap_vout.c +0 -6
index 25025a1..4aeea06 100644
@@ -1090,10 +1090,7 @@ static int vidioc_enum_fmt_vid_out_mplane(struct file *file, void *fh,
 			struct v4l2_fmtdesc *fmt)
 {
 	int index = fmt->index;
-	enum v4l2_buf_type type = fmt->type;
 
-	fmt->index = index;
-	fmt->type = type;
 	if (index >= NUM_OUTPUT_FORMATS)
 		return -EINVAL;
 
@@ -1268,10 +1265,7 @@ static int vidioc_enum_fmt_vid_overlay(struct file *file, void *fh,
 			struct v4l2_fmtdesc *fmt)
 {
 	int index = fmt->index;
-	enum v4l2_buf_type type = fmt->type;
 
-	fmt->index = index;
-	fmt->type = type;
 	if (index >= NUM_OUTPUT_FORMATS)
 		return -EINVAL;
 
Signature · 1 line
1.7.1
#2 lore raw

RE: [PATCH 1/6] V4L2: OMAP: VOUT: isr handling extended for DPI and HDMI interface

In reply to Amber Jain
Quoted 8 lines

-----Original Message-----
From: JAIN, AMBER
Sent: Tuesday, June 07, 2011 8:18 PM
To: [email protected]
Cc: Hiremath, Vaibhav; Semwal, Sumit; JAIN, AMBER
Subject: [PATCH 1/6] V4L2: OMAP: VOUT: isr handling extended for DPI and HDMI interface

[Hiremath, Vaibhav] Few minor comments below -

Quoted 5 lines

Extending the omap vout isr handling for:
- secondary lcd over DPI interface,
- HDMI interface.

[Hiremath, Vaibhav] It would be useful to mention about OMAP4 DSS block (these are new additions compared to OAMP3), that's where both the interfaces are getting used, right?

Quoted 22 lines
---
 drivers/media/video/omap/omap_vout.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)
drivers/media/video/omap/omap_vout.c +3 -3
index a831241..6fe7efa 100644
@@ -544,10 +544,20 @@ void omap_vout_isr(void *arg, unsigned int
 irqstatus)
 
 	spin_lock(&vout->vbq_lock);
 	do_gettimeofday(&timevalue);
-	if (cur_display->type == OMAP_DISPLAY_TYPE_DPI) {
-		if (!(irqstatus & DISPC_IRQ_VSYNC))
-			goto vout_isr_err;
 
+	if (cur_display->type != OMAP_DISPLAY_TYPE_VENC) {
+		switch (cur_display->type) {
+		case OMAP_DISPLAY_TYPE_DPI:

drivers/media/video/omap/omap_vout.c void omap_vout_isr(void *arg, unsigned int · line 561

Quoted 10 lines
drivers/media/video/omap/omap_vout.c +10 -0
+			if (!(irqstatus & (DISPC_IRQ_VSYNC | DISPC_IRQ_VSYNC2)))
+				goto vout_isr_err;
+			break;
+		case OMAP_DISPLAY_TYPE_HDMI:
+			if (!(irqstatus & DISPC_IRQ_EVSYNC_EVEN))
+				goto vout_isr_err;
+			break;
+		default:
+			goto vout_isr_err;
+		}

[Hiremath, Vaibhav] how about implementing this like,

if (cur_display->type != OMAP_DISPLAY_TYPE_VENC) {
	unsigned int status;

	switch (cur_display->type) {
	case OMAP_DISPLAY_TYPE_DPI:
		status = DISPC_IRQ_VSYNC | DISPC_IRQ_VSYNC2;
		break;
	case OMAP_DISPLAY_TYPE_HDMI:
		status = DISPC_IRQ_EVSYNC_EVEN;
		break;
	default:
		goto vout_isr_err;
	}
	If (!(irqstatus & status))
		goto vout_isr_err;

Thanks,
Vaibhav

Quoted 49 lines
drivers/media/video/omap/omap_vout.c +0 -0
 		if (!vout->first_int && (vout->cur_frm != vout->next_frm)) {
 			vout->cur_frm->ts = timevalue;
drivers/media/video/omap/omap_vout.c +3 -3
 			vout->cur_frm->state = VIDEOBUF_DONE;
@@ -571,7 +581,7 @@ void omap_vout_isr(void *arg, unsigned int irqstatus)
 		ret = omapvid_init(vout, addr);
 		if (ret)
 			printk(KERN_ERR VOUT_NAME
-					"failed to set overlay info\n");
+		[Hiremath, Vaibhav] 			"failed to set overlay info\n");
 		/* Enable the pipeline and set the Go bit */
 		ret = omapvid_apply_changes(vout);
 		if (ret)
@@ -925,7 +935,7 @@ static int omap_vout_release(struct file *file)
 		u32 mask = 0;
 
 		mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN |
-			DISPC_IRQ_EVSYNC_ODD;
+			DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_VSYNC2;
 		omap_dispc_unregister_isr(omap_vout_isr, vout, mask);
 		vout->streaming = 0;
 
@@ -1596,7 +1606,8 @@ static int vidioc_streamon(struct file *file, void
 *fh, enum v4l2_buf_type i)
 	addr = (unsigned long) vout->queued_buf_addr[vout->cur_frm->i]
 		+ vout->cropped_offset;
 
-	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN |
 DISPC_IRQ_EVSYNC_ODD;
+	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN |

DISPC_IRQ_EVSYNC_ODD

drivers/media/video/omap/omap_vout.c +2 -1
+		| DISPC_IRQ_VSYNC2;
 
 	omap_dispc_register_isr(omap_vout_isr, vout, mask);
@@ -1646,7 +1657,8 @@ static int vidioc_streamoff(struct file *file, void
 *fh, enum v4l2_buf_type i)
 		return -EINVAL;
 
 	vout->streaming = 0;
-	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN |
 DISPC_IRQ_EVSYNC_ODD;
+	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN |

DISPC_IRQ_EVSYNC_ODD

drivers/media/video/omap/omap_vout.c +1 -1
+		| DISPC_IRQ_VSYNC2;
 
 	omap_dispc_unregister_isr(omap_vout_isr, vout, mask);
 
--

1.7.1

#5 lore raw

RE: [PATCH 2/6] V4L2: OMAP: VOUT: dma map and unmap v4l2 buffers in qbuf and dqbuf

In reply to Amber Jain
Quoted 9 lines

-----Original Message-----
From: JAIN, AMBER
Sent: Tuesday, June 07, 2011 8:18 PM
To: [email protected]
Cc: Hiremath, Vaibhav; Semwal, Sumit; JAIN, AMBER
Subject: [PATCH 2/6] V4L2: OMAP: VOUT: dma map and unmap v4l2 buffers in qbuf and dqbuf

[Hiremath, Vaibhav] few minor comments below -

Quoted 24 lines

Add support to map the buffer using dma_map_single during qbuf which inturn
calls cache flush and unmap the same during dqbuf. This is done to prevent the artifacts seen because of cache-coherency issues on OMAP4

---
 drivers/media/video/omap/omap_vout.c |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)
drivers/media/video/omap/omap_vout.c +1 -0
index 6fe7efa..435fe65 100644
@@ -37,6 +37,7 @@
 #include <linux/platform_device.h>
 #include <linux/irq.h>
 #include <linux/videodev2.h>
+#include <linux/dma-mapping.h>
 
 #include <media/videobuf-dma-contig.h>
 #include <media/v4l2-device.h>

drivers/media/video/omap/omap_vout.c static int omap_vout_buffer_prepare(struct · line 773

Quoted 5 lines
drivers/media/video/omap/omap_vout.c +1 -0
@@ -768,6 +769,17 @@ static int omap_vout_buffer_prepare(struct
 videobuf_queue *q,
 		vout->queued_buf_addr[vb->i] = (u8 *)
 			omap_vout_uservirt_to_phys(vb->baddr);
 	} else {
+		int addr, dma_addr;

[Hiremath, Vaibhav] Why is it "int"? It should be either u32 or unsigned long or dma_addr_t. Also you don't need type casting everywhere with this.

drivers/media/video/omap/omap_vout.c static int omap_vout_buffer_prepare(struct videobuf_queue *q, · line 779

Quoted 8 lines
drivers/media/video/omap/omap_vout.c +7 -0
+		unsigned long size;
+
+		addr = (unsigned long) vout->buf_virt_addr[vb->i];
+		size = (unsigned long) vb->size;
+
+		dma_addr = dma_map_single(vout->vid_dev->v4l2_dev.dev, (void
 *) addr,
+				(unsigned) size, DMA_TO_DEVICE);

[Hiremath, Vaibhav] Why type casting required here?

drivers/media/video/omap/omap_vout.c static int omap_vout_buffer_prepare(struct videobuf_queue *q, · line 781

Quoted 2 lines
drivers/media/video/omap/omap_vout.c +2 -0
+		if (dma_mapping_error(vout->vid_dev->v4l2_dev.dev, dma_addr))
+			printk(KERN_ERR "dma_map_single failed\n");

[Hiremath, Vaibhav] Can this be changed to v4l2_err?

Quoted 6 lines
drivers/media/video/omap/omap_vout.c +1 -0
+
 		vout->queued_buf_addr[vb->i] = (u8 *)vout->buf_phy_addr[vb-
Quoted 1 line

i];

drivers/media/video/omap/omap_vout.c +0 -0
 	}

drivers/media/video/omap/omap_vout.c static int vidioc_dqbuf(struct file *file, void · line 1569

Quoted 9 lines
drivers/media/video/omap/omap_vout.c +5 -0
@@ -1549,15 +1561,28 @@ static int vidioc_dqbuf(struct file *file, void
 *fh, struct v4l2_buffer *b)
 	struct omap_vout_device *vout = fh;
 	struct videobuf_queue *q = &vout->vbq;
 
+	unsigned long size;
+	u32 addr;
+	struct videobuf_buffer *vb;
+	int ret;
+

[Hiremath, Vaibhav] Just for readability can you put them in order (lengthwise)?

Quoted 8 lines
drivers/media/video/omap/omap_vout.c +2 -1
+	vb = q->bufs[b->index];
+
 	if (!vout->streaming)
 		return -EINVAL;
 
 	if (file->f_flags & O_NONBLOCK)
 		/* Call videobuf_dqbuf for non blocking mode */
-		return videobuf_dqbuf(q, (struct v4l2_buffer *)b, 1);

drivers/media/video/omap/omap_vout.c static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b) · line 1584

Quoted 10 lines
drivers/media/video/omap/omap_vout.c +7 -1
+		ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 1);
 	else
 		/* Call videobuf_dqbuf for  blocking mode */
-		return videobuf_dqbuf(q, (struct v4l2_buffer *)b, 0);
+		ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 0);
+
+	addr = (unsigned long) vout->buf_phy_addr[vb->i];
+	size = (unsigned long) vb->size;
+	dma_unmap_single(vout->vid_dev->v4l2_dev.dev,  addr,
+				(unsigned) size, DMA_TO_DEVICE);

[Hiremath, Vaibhav] Type cast???

Thanks,
Vaibhav

Quoted 7 lines
drivers/media/video/omap/omap_vout.c +1 -0
+	return ret;
 }
 

static int vidioc_streamon(struct file *file, void *fh, enum
v4l2_buf_type i)
--
1.7.1

#12 lore raw

RE: [PATCH 6/6] V4l2: OMAP: VOUT: Minor Cleanup, removing the unnecessary code.

In reply to Amber Jain
Quoted 23 lines

-----Original Message-----
From: JAIN, AMBER
Sent: Tuesday, June 07, 2011 8:18 PM
To: [email protected]
Cc: Hiremath, Vaibhav; Semwal, Sumit; JAIN, AMBER; Nilofer, Samreen
Subject: [PATCH 6/6] V4l2: OMAP: VOUT: Minor Cleanup, removing the unnecessary code.

Minor changes to remove the unused code from omap_vout driver.

---
 drivers/media/video/omap/omap_vout.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
drivers/media/video/omap/omap_vout.c +0 -0
index 25025a1..4aeea06 100644

drivers/media/video/omap/omap_vout.c static int vidioc_enum_fmt_vid_out_mplane(struct · line 1097

Quoted 8 lines
drivers/media/video/omap/omap_vout.c +0 -3
@@ -1090,10 +1090,7 @@ static int vidioc_enum_fmt_vid_out_mplane(struct
 file *file, void *fh,
 			struct v4l2_fmtdesc *fmt)
 {
 	int index = fmt->index;
-	enum v4l2_buf_type type = fmt->type;
 
-	fmt->index = index;
-	fmt->type = type;

[Hiremath, Vaibhav] These lines are not present in main-line driver? Which baseline have you used for this patch?

Thanks,
Vaibhav

Quoted 17 lines
drivers/media/video/omap/omap_vout.c +0 -4
 	if (index >= NUM_OUTPUT_FORMATS)
 		return -EINVAL;
@@ -1268,10 +1265,7 @@ static int vidioc_enum_fmt_vid_overlay(struct file
 *file, void *fh,
 			struct v4l2_fmtdesc *fmt)
 {
 	int index = fmt->index;
-	enum v4l2_buf_type type = fmt->type;
 
-	fmt->index = index;
-	fmt->type = type;
 	if (index >= NUM_OUTPUT_FORMATS)
 		return -EINVAL;
 
--

1.7.1

Acked-by on v1 6/6
#14 lore raw

RE: [PATCH 6/6] V4l2: OMAP: VOUT: Minor Cleanup, removing the unnecessary code.

In reply to Amber Jain
Quoted 38 lines

-----Original Message-----
From: Hiremath, Vaibhav
Sent: Wednesday, July 06, 2011 12:38 AM
To: JAIN, AMBER; [email protected]
Cc: Semwal, Sumit; Nilofer, Samreen
Subject: RE: [PATCH 6/6] V4l2: OMAP: VOUT: Minor Cleanup, removing the unnecessary code.

Quoted 28 lines

-----Original Message-----
From: JAIN, AMBER
Sent: Tuesday, June 07, 2011 8:18 PM
To: [email protected]
Cc: Hiremath, Vaibhav; Semwal, Sumit; JAIN, AMBER; Nilofer, Samreen
Subject: [PATCH 6/6] V4l2: OMAP: VOUT: Minor Cleanup, removing the unnecessary code.

Minor changes to remove the unused code from omap_vout driver.

---
 drivers/media/video/omap/omap_vout.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
drivers/media/video/omap/omap_vout.c +0 -1
index 25025a1..4aeea06 100644
@@ -1090,10 +1090,7 @@ static int vidioc_enum_fmt_vid_out_mplane(struct
 file *file, void *fh,
 			struct v4l2_fmtdesc *fmt)
 {
 	int index = fmt->index;
-	enum v4l2_buf_type type = fmt->type;
 
Quoted 4 lines

drivers/media/video/omap/omap_vout.c static int vidioc_enum_fmt_vid_out_mplane(struct · line 1097

Quoted 2 lines
drivers/media/video/omap/omap_vout.c +0 -2
-	fmt->index = index;
-	fmt->type = type;

[Hiremath, Vaibhav] These lines are not present in main-line driver? Which baseline have you used for this patch?

[Hiremath, Vaibhav] My bad, I hit send button quite early. I will queue this up for 3.1.

Thanks,
Vaibhav

Quoted 22 lines

Thanks,
Vaibhav

drivers/media/video/omap/omap_vout.c static int vidioc_enum_fmt_vid_overlay(struct

Quoted 4 lines
drivers/media/video/omap/omap_vout.c +0 -0
 	if (index >= NUM_OUTPUT_FORMATS)
 		return -EINVAL;
@@ -1268,10 +1265,7 @@ static int vidioc_enum_fmt_vid_overlay(struct

file

Quoted 13 lines
drivers/media/video/omap/omap_vout.c +0 -4
 *file, void *fh,
 			struct v4l2_fmtdesc *fmt)
 {
 	int index = fmt->index;
-	enum v4l2_buf_type type = fmt->type;
 
-	fmt->index = index;
-	fmt->type = type;
 	if (index >= NUM_OUTPUT_FORMATS)
 		return -EINVAL;
 
--

1.7.1

#8 lore raw

RE: [PATCH 3/6] V4L2: OMAP: VOUT: Adapt to Multiplanar APIs

In reply to Amber Jain
Quoted 10 lines

-----Original Message-----
From: JAIN, AMBER
Sent: Tuesday, June 07, 2011 8:18 PM
To: [email protected]
Cc: Hiremath, Vaibhav; Semwal, Sumit; JAIN, AMBER; Nilofer, Samreen
Subject: [PATCH 3/6] V4L2: OMAP: VOUT: Adapt to Multiplanar APIs

Adapting the omap_vout driver for multiplanar API support.

[Hiremath, Vaibhav] Personally I think it doesn't make sense to change function names only without adding functionality.

So I would suggest merging this patch with the actual multi-planar format support patch, which I believe is not part of this series.

Irrespective of this, can you create separate patch series for,

V4L2: OMAP: VOUT: isr handling extended for DPI and HDMI interface
V4L2: OMAP: VOUT: dma map and unmap v4l2 buffers in qbuf and dqbuf
V4l2: OMAP: VOUT: Minor Cleanup, removing the unnecessary code.

Thanks,
Vaibhav

Quoted 78 lines
---
 drivers/media/video/omap/omap_vout.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
drivers/media/video/omap/omap_vout.c +3 -2
index 435fe65..70fb45e 100644
@@ -1014,12 +1014,13 @@ static int vidioc_querycap(struct file *file, void
 *fh,
 	strlcpy(cap->driver, VOUT_NAME, sizeof(cap->driver));
 	strlcpy(cap->card, vout->vfd->name, sizeof(cap->card));
 	cap->bus_info[0] = '\0';
-	cap->capabilities = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_OUTPUT;
+	cap->capabilities = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_OUTPUT |
+				V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
 
 	return 0;
 }
 
-static int vidioc_enum_fmt_vid_out(struct file *file, void *fh,
+static int vidioc_enum_fmt_vid_out_mplane(struct file *file, void *fh,
 			struct v4l2_fmtdesc *fmt)
 {
drivers/media/video/omap/omap_vout.c +1 -1
 	int index = fmt->index;
@@ -1038,7 +1039,7 @@ static int vidioc_enum_fmt_vid_out(struct file *file,
 void *fh,
 	return 0;
 }
 
-static int vidioc_g_fmt_vid_out(struct file *file, void *fh,
+static int vidioc_g_fmt_vid_out_mplane(struct file *file, void *fh,
 			struct v4l2_format *f)
 {
drivers/media/video/omap/omap_vout.c +1 -1
 	struct omap_vout_device *vout = fh;
@@ -1048,7 +1049,7 @@ static int vidioc_g_fmt_vid_out(struct file *file,
 void *fh,
 
 }
 
-static int vidioc_try_fmt_vid_out(struct file *file, void *fh,
+static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *fh,
 			struct v4l2_format *f)
 {
drivers/media/video/omap/omap_vout.c +1 -1
 	struct omap_overlay *ovl;
@@ -1071,7 +1072,7 @@ static int vidioc_try_fmt_vid_out(struct file *file,
 void *fh,
 	return 0;
 }
 
-static int vidioc_s_fmt_vid_out(struct file *file, void *fh,
+static int vidioc_s_fmt_vid_out_mplane(struct file *file, void *fh,
 			struct v4l2_format *f)
 {
drivers/media/video/omap/omap_vout.c +4 -4
 	int ret, bpp;
@@ -1817,10 +1818,10 @@ static int vidioc_g_fbuf(struct file *file, void
 *fh,
 
 static const struct v4l2_ioctl_ops vout_ioctl_ops = {
 	.vidioc_querycap      			= vidioc_querycap,
-	.vidioc_enum_fmt_vid_out 		= vidioc_enum_fmt_vid_out,
-	.vidioc_g_fmt_vid_out			= vidioc_g_fmt_vid_out,
-	.vidioc_try_fmt_vid_out			= vidioc_try_fmt_vid_out,
-	.vidioc_s_fmt_vid_out			= vidioc_s_fmt_vid_out,
+	.vidioc_enum_fmt_vid_out_mplane		=
 vidioc_enum_fmt_vid_out_mplane,
+	.vidioc_g_fmt_vid_out_mplane		= vidioc_g_fmt_vid_out_mplane,
+	.vidioc_try_fmt_vid_out_mplane		=
 vidioc_try_fmt_vid_out_mplane,
+	.vidioc_s_fmt_vid_out_mplane		= vidioc_s_fmt_vid_out_mplane,
drivers/media/video/omap/omap_vout.c +0 -1
 	.vidioc_queryctrl    			= vidioc_queryctrl,
 	.vidioc_g_ctrl       			= vidioc_g_ctrl,
 	.vidioc_s_fbuf				= vidioc_s_fbuf,
--

1.7.1

#3 lore raw

RE: [PATCH 1/6] V4L2: OMAP: VOUT: isr handling extended for DPI and HDMI interface

In reply to Hiremath, Vaibhav
Quoted 21 lines

-----Original Message-----
From: Hiremath, Vaibhav
Sent: Wednesday, July 06, 2011 12:17 AM
To: JAIN, AMBER; [email protected]
Cc: Semwal, Sumit
Subject: RE: [PATCH 1/6] V4L2: OMAP: VOUT: isr handling extended for DPI and HDMI interface

Quoted 7 lines

-----Original Message-----
From: JAIN, AMBER
Sent: Tuesday, June 07, 2011 8:18 PM
To: [email protected]
Cc: Hiremath, Vaibhav; Semwal, Sumit; JAIN, AMBER
Subject: [PATCH 1/6] V4L2: OMAP: VOUT: isr handling extended for DPI and HDMI interface

[Hiremath, Vaibhav] Few minor comments below -

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

Extending the omap vout isr handling for:
- secondary lcd over DPI interface,
- HDMI interface.

[Hiremath, Vaibhav] It would be useful to mention about OMAP4 DSS block (these are new additions compared to OAMP3), that's where both the interfaces are getting used, right?

Ok, will add that.

Quoted 53 lines
Quoted 23 lines
---
 drivers/media/video/omap/omap_vout.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)
drivers/media/video/omap/omap_vout.c +3 -3
index a831241..6fe7efa 100644
@@ -544,10 +544,20 @@ void omap_vout_isr(void *arg, unsigned int
 irqstatus)
 
 	spin_lock(&vout->vbq_lock);
 	do_gettimeofday(&timevalue);
-	if (cur_display->type == OMAP_DISPLAY_TYPE_DPI) {
-		if (!(irqstatus & DISPC_IRQ_VSYNC))
-			goto vout_isr_err;
 
+	if (cur_display->type != OMAP_DISPLAY_TYPE_VENC) {
+		switch (cur_display->type) {
+		case OMAP_DISPLAY_TYPE_DPI:

drivers/media/video/omap/omap_vout.c void omap_vout_isr(void *arg, unsigned int · line 561

Quoted 10 lines
drivers/media/video/omap/omap_vout.c +10 -0
+			if (!(irqstatus & (DISPC_IRQ_VSYNC | DISPC_IRQ_VSYNC2)))
+				goto vout_isr_err;
+			break;
+		case OMAP_DISPLAY_TYPE_HDMI:
+			if (!(irqstatus & DISPC_IRQ_EVSYNC_EVEN))
+				goto vout_isr_err;
+			break;
+		default:
+			goto vout_isr_err;
+		}

[Hiremath, Vaibhav] how about implementing this like,

if (cur_display->type != OMAP_DISPLAY_TYPE_VENC) {
	unsigned int status;

	switch (cur_display->type) {
	case OMAP_DISPLAY_TYPE_DPI:
		status = DISPC_IRQ_VSYNC | DISPC_IRQ_VSYNC2;
		break;
	case OMAP_DISPLAY_TYPE_HDMI:
		status = DISPC_IRQ_EVSYNC_EVEN;
		break;
	default:
		goto vout_isr_err;
	}
	If (!(irqstatus & status))
		goto vout_isr_err;
Quoted 2 lines

Thanks,
Vaibhav

It can be done, but I don't really see a benefit of using a new variable for it as it is used just once for check.

Quoted 53 lines

drivers/media/video/omap/omap_vout.c void omap_vout_isr(void *arg, unsigned int

Quoted 5 lines
drivers/media/video/omap/omap_vout.c +0 -0
 		if (!vout->first_int && (vout->cur_frm != vout->next_frm)) {
 			vout->cur_frm->ts = timevalue;
drivers/media/video/omap/omap_vout.c +0 -0
 			vout->cur_frm->state = VIDEOBUF_DONE;
@@ -571,7 +581,7 @@ void omap_vout_isr(void *arg, unsigned int

irqstatus)

drivers/media/video/omap/omap_vout.c void omap_vout_isr(void *arg, unsigned int irqstatus)

Quoted 5 lines
drivers/media/video/omap/omap_vout.c +1 -1
 		ret = omapvid_init(vout, addr);
 		if (ret)
 			printk(KERN_ERR VOUT_NAME
-					"failed to set overlay info\n");
+		[Hiremath, Vaibhav] 			"failed to set overlay

info\n");

drivers/media/video/omap/omap_vout.c static int vidioc_streamoff(struct file *file,

Quoted 26 lines
drivers/media/video/omap/omap_vout.c +2 -2
 		/* Enable the pipeline and set the Go bit */
 		ret = omapvid_apply_changes(vout);
 		if (ret)
@@ -925,7 +935,7 @@ static int omap_vout_release(struct file *file)
 		u32 mask = 0;
 
 		mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN |
-			DISPC_IRQ_EVSYNC_ODD;
+			DISPC_IRQ_EVSYNC_ODD | DISPC_IRQ_VSYNC2;
 		omap_dispc_unregister_isr(omap_vout_isr, vout, mask);
 		vout->streaming = 0;
 
@@ -1596,7 +1606,8 @@ static int vidioc_streamon(struct file *file, void
 *fh, enum v4l2_buf_type i)
 	addr = (unsigned long) vout->queued_buf_addr[vout->cur_frm->i]
 		+ vout->cropped_offset;
 
-	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN |
 DISPC_IRQ_EVSYNC_ODD;
+	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN |

DISPC_IRQ_EVSYNC_ODD

drivers/media/video/omap/omap_vout.c +1 -0
+		| DISPC_IRQ_VSYNC2;
 
 	omap_dispc_register_isr(omap_vout_isr, vout, mask);
@@ -1646,7 +1657,8 @@ static int vidioc_streamoff(struct file *file,

void

Quoted 14 lines
drivers/media/video/omap/omap_vout.c +1 -1
 *fh, enum v4l2_buf_type i)
 		return -EINVAL;
 
 	vout->streaming = 0;
-	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN |
 DISPC_IRQ_EVSYNC_ODD;
+	mask = DISPC_IRQ_VSYNC | DISPC_IRQ_EVSYNC_EVEN |

DISPC_IRQ_EVSYNC_ODD

drivers/media/video/omap/omap_vout.c +1 -1
+		| DISPC_IRQ_VSYNC2;
 
 	omap_dispc_unregister_isr(omap_vout_isr, vout, mask);
 
--

1.7.1

#6 lore raw

RE: [PATCH 2/6] V4L2: OMAP: VOUT: dma map and unmap v4l2 buffers in qbuf and dqbuf

In reply to Hiremath, Vaibhav
Quoted 44 lines

-----Original Message-----
From: Hiremath, Vaibhav
Sent: Wednesday, July 06, 2011 12:34 AM
To: JAIN, AMBER; [email protected]
Cc: Semwal, Sumit
Subject: RE: [PATCH 2/6] V4L2: OMAP: VOUT: dma map and unmap v4l2 buffers in qbuf and dqbuf

Quoted 8 lines

-----Original Message-----
From: JAIN, AMBER
Sent: Tuesday, June 07, 2011 8:18 PM
To: [email protected]
Cc: Hiremath, Vaibhav; Semwal, Sumit; JAIN, AMBER
Subject: [PATCH 2/6] V4L2: OMAP: VOUT: dma map and unmap v4l2 buffers in qbuf and dqbuf

[Hiremath, Vaibhav] few minor comments below -

Quoted 3 lines

Add support to map the buffer using dma_map_single during qbuf which inturn
calls cache flush and unmap the same during dqbuf. This is done to

prevent

Quoted 5 lines

the artifacts seen because of cache-coherency issues on OMAP4

---
 drivers/media/video/omap/omap_vout.c |   29

+++++++++++++++++++++++++++--

Quoted 13 lines
 1 files changed, 27 insertions(+), 2 deletions(-)
drivers/media/video/omap/omap_vout.c +1 -0
index 6fe7efa..435fe65 100644
@@ -37,6 +37,7 @@
 #include <linux/platform_device.h>
 #include <linux/irq.h>
 #include <linux/videodev2.h>
+#include <linux/dma-mapping.h>
 
Quoted 10 lines

drivers/media/video/omap/omap_vout.c static int omap_vout_buffer_prepare(struct · line 773

Quoted 8 lines
drivers/media/video/omap/omap_vout.c +1 -0
 #include <media/videobuf-dma-contig.h>
 #include <media/v4l2-device.h>
@@ -768,6 +769,17 @@ static int omap_vout_buffer_prepare(struct
 videobuf_queue *q,
 		vout->queued_buf_addr[vb->i] = (u8 *)
 			omap_vout_uservirt_to_phys(vb->baddr);
 	} else {
+		int addr, dma_addr;

[Hiremath, Vaibhav] Why is it "int"? It should be either u32 or unsigned long or dma_addr_t. Also you don't need type casting everywhere with this.

Ok, I will change it.

Quoted 11 lines

drivers/media/video/omap/omap_vout.c static int omap_vout_buffer_prepare(struct videobuf_queue *q, · line 779

Quoted 9 lines
drivers/media/video/omap/omap_vout.c +7 -0
+		unsigned long size;
+
+		addr = (unsigned long) vout->buf_virt_addr[vb->i];
+		size = (unsigned long) vb->size;
+
+		dma_addr = dma_map_single(vout->vid_dev->v4l2_dev.dev, (void
 *) addr,
+				(unsigned) size, DMA_TO_DEVICE);

[Hiremath, Vaibhav] Why type casting required here?

Quoted 3 lines

drivers/media/video/omap/omap_vout.c static int omap_vout_buffer_prepare(struct videobuf_queue *q, · line 781

Quoted 2 lines
drivers/media/video/omap/omap_vout.c +2 -0
+		if (dma_mapping_error(vout->vid_dev->v4l2_dev.dev, dma_addr))
+			printk(KERN_ERR "dma_map_single failed\n");

[Hiremath, Vaibhav] Can this be changed to v4l2_err?

Ok, I will change it.

Quoted 49 lines
Quoted 7 lines
drivers/media/video/omap/omap_vout.c +1 -0
+
 		vout->queued_buf_addr[vb->i] = (u8 *)vout->buf_phy_addr[vb-
Quoted 1 line

i];

drivers/media/video/omap/omap_vout.c +0 -0
 	}

drivers/media/video/omap/omap_vout.c static int vidioc_dqbuf(struct file *file, void · line 1569

Quoted 9 lines
drivers/media/video/omap/omap_vout.c +5 -0
@@ -1549,15 +1561,28 @@ static int vidioc_dqbuf(struct file *file, void
 *fh, struct v4l2_buffer *b)
 	struct omap_vout_device *vout = fh;
 	struct videobuf_queue *q = &vout->vbq;
 
+	unsigned long size;
+	u32 addr;
+	struct videobuf_buffer *vb;
+	int ret;
+

[Hiremath, Vaibhav] Just for readability can you put them in order (lengthwise)?

Quoted 8 lines
drivers/media/video/omap/omap_vout.c +2 -1
+	vb = q->bufs[b->index];
+
 	if (!vout->streaming)
 		return -EINVAL;
 
 	if (file->f_flags & O_NONBLOCK)
 		/* Call videobuf_dqbuf for non blocking mode */
-		return videobuf_dqbuf(q, (struct v4l2_buffer *)b, 1);

drivers/media/video/omap/omap_vout.c static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b) · line 1584

Quoted 10 lines
drivers/media/video/omap/omap_vout.c +7 -1
+		ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 1);
 	else
 		/* Call videobuf_dqbuf for  blocking mode */
-		return videobuf_dqbuf(q, (struct v4l2_buffer *)b, 0);
+		ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 0);
+
+	addr = (unsigned long) vout->buf_phy_addr[vb->i];
+	size = (unsigned long) vb->size;
+	dma_unmap_single(vout->vid_dev->v4l2_dev.dev,  addr,
+				(unsigned) size, DMA_TO_DEVICE);

[Hiremath, Vaibhav] Type cast???

Thanks,
Vaibhav

Quoted 7 lines
drivers/media/video/omap/omap_vout.c +1 -0
+	return ret;
 }
 

static int vidioc_streamon(struct file *file, void *fh, enum
v4l2_buf_type i)
--
1.7.1

#13 lore raw

RE: [PATCH 6/6] V4l2: OMAP: VOUT: Minor Cleanup, removing the unnecessary code.

In reply to Hiremath, Vaibhav
Quoted 39 lines

-----Original Message-----
From: Hiremath, Vaibhav
Sent: Wednesday, July 06, 2011 12:38 AM
To: JAIN, AMBER; [email protected]
Cc: Semwal, Sumit; Nilofer, Samreen
Subject: RE: [PATCH 6/6] V4l2: OMAP: VOUT: Minor Cleanup, removing the unnecessary code.

Quoted 28 lines

-----Original Message-----
From: JAIN, AMBER
Sent: Tuesday, June 07, 2011 8:18 PM
To: [email protected]
Cc: Hiremath, Vaibhav; Semwal, Sumit; JAIN, AMBER; Nilofer, Samreen
Subject: [PATCH 6/6] V4l2: OMAP: VOUT: Minor Cleanup, removing the unnecessary code.

Minor changes to remove the unused code from omap_vout driver.

---
 drivers/media/video/omap/omap_vout.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
drivers/media/video/omap/omap_vout.c +0 -1
index 25025a1..4aeea06 100644
@@ -1090,10 +1090,7 @@ static int vidioc_enum_fmt_vid_out_mplane(struct
 file *file, void *fh,
 			struct v4l2_fmtdesc *fmt)
 {
 	int index = fmt->index;
-	enum v4l2_buf_type type = fmt->type;
 
Quoted 4 lines

drivers/media/video/omap/omap_vout.c static int vidioc_enum_fmt_vid_out_mplane(struct · line 1097

Quoted 2 lines
drivers/media/video/omap/omap_vout.c +0 -2
-	fmt->index = index;
-	fmt->type = type;

[Hiremath, Vaibhav] These lines are not present in main-line driver? Which baseline have you used for this patch?

I checked it again, it is present in mainline. Can you please check 3.0-rc6 branch.

Thanks,
Amber

Quoted 22 lines

Thanks,
Vaibhav

drivers/media/video/omap/omap_vout.c static int vidioc_enum_fmt_vid_overlay(struct

Quoted 4 lines
drivers/media/video/omap/omap_vout.c +0 -0
 	if (index >= NUM_OUTPUT_FORMATS)
 		return -EINVAL;
@@ -1268,10 +1265,7 @@ static int vidioc_enum_fmt_vid_overlay(struct

file

Quoted 13 lines
drivers/media/video/omap/omap_vout.c +0 -4
 *file, void *fh,
 			struct v4l2_fmtdesc *fmt)
 {
 	int index = fmt->index;
-	enum v4l2_buf_type type = fmt->type;
 
-	fmt->index = index;
-	fmt->type = type;
 	if (index >= NUM_OUTPUT_FORMATS)
 		return -EINVAL;
 
--

1.7.1