Skip to contentSkip to conversation

V4L2: OMAP: VOUT: Extend V4L2 support for OMAP4

PATCH In review Amber Jain 2 participants 7 messages Jul 7, 2011 – Jul 18, 2011 Media (V4L/DVB)

lore
Share & tools
lore

Amber Jain

author
#0 lore raw

v2 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.
- Minor cleanup to remove unnecessary code.

Changes from v1:
- Split the patch-set into two so as to separate out NV12 color-format support for OMAP4.
- Fixed review comments.

Amber Jain (3):
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.

 drivers/media/video/omap/omap_vout.c |   61 +++++++++++++++++++++++++--------
 1 files changed, 46 insertions(+), 15 deletions(-)
author
#1 lore raw

PATCH v2 1/3 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.

These are the new interfaces added to OMAP4 DSS.

---
Changes from v1:
- updated commit message to mention that these changes are specifically for OMAP4.

 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 343b50c..6cd3622 100644
@@ -546,10 +546,20 @@ static 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;
@@ -573,7 +583,7 @@ static 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)
@@ -943,7 +953,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;
 
@@ -1614,7 +1624,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);
 
@@ -1664,7 +1675,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
#2 lore raw

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

Quoted 96 lines

-----Original Message-----
From: JAIN, AMBER
Sent: Thursday, July 07, 2011 5:51 PM
To: [email protected]
Cc: Hiremath, Vaibhav; JAIN, AMBER
Subject: [PATCH v2 1/3] 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.

These are the new interfaces added to OMAP4 DSS.

---
Changes from v1:
- updated commit message to mention that these changes are specifically for OMAP4.

 drivers/media/video/omap/omap_vout.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)
drivers/media/video/omap/omap_vout.c +13 -3
index 343b50c..6cd3622 100644
@@ -546,10 +546,20 @@ static 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;
drivers/media/video/omap/omap_vout.c +1 -1
 			vout->cur_frm->state = VIDEOBUF_DONE;
@@ -573,7 +583,7 @@ static 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);
drivers/media/video/omap/omap_vout.c +2 -2
 		if (ret)
@@ -943,7 +953,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;
 
@@ -1614,7 +1624,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);
@@ -1664,7 +1675,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 static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i) · line 1681

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

[Hiremath, Vaibhav] Acked-By: Vaibhav Hiremath <[email protected]>

Thanks,
Vaibhav

Quoted 2 lines

--
1.7.1

author
#3 lore raw

PATCH v2 2/3 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

---
Changes from v1:
- Changed the definition of address variables to be u32 instead of int.
- Removed extra typedef for size variable.

 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 6cd3622..7d3410a 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>
@@ -778,6 +779,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 {
+		u32 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,
+				size, DMA_TO_DEVICE);
+		if (dma_mapping_error(vout->vid_dev->v4l2_dev.dev, dma_addr))
+			v4l2_err(&vout->vid_dev->v4l2_dev, "dma_map_single failed\n");
+
 		vout->queued_buf_addr[vb->i] = (u8 *)vout->buf_phy_addr[vb->i];
 	}
 
@@ -1567,15 +1579,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;
 
+	int ret;
+	u32 addr;
+	unsigned long size;
+	struct videobuf_buffer *vb;
+
+	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,
+				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
#4 lore raw

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

Quoted 89 lines

-----Original Message-----
From: JAIN, AMBER
Sent: Thursday, July 07, 2011 5:51 PM
To: [email protected]
Cc: Hiremath, Vaibhav; JAIN, AMBER
Subject: [PATCH v2 2/3] V4L2: OMAP: VOUT: dma map and unmap v4l2 buffers in qbuf and dqbuf

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

---
Changes from v1:
- Changed the definition of address variables to be u32 instead of int.
- Removed extra typedef for size variable.

 drivers/media/video/omap/omap_vout.c |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)
drivers/media/video/omap/omap_vout.c +12 -0
index 6cd3622..7d3410a 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>
@@ -778,6 +779,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 {
+		u32 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,
+				size, DMA_TO_DEVICE);
+		if (dma_mapping_error(vout->vid_dev->v4l2_dev.dev, dma_addr))
+			v4l2_err(&vout->vid_dev->v4l2_dev, "dma_map_single
 failed\n");
+

vout->queued_buf_addr[vb->i] = (u8 *)vout->buf_phy_addr[vb-

Quoted 1 line

i];

drivers/media/video/omap/omap_vout.c +15 -2
 	}
@@ -1567,15 +1579,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;
 
+	int ret;
+	u32 addr;
+	unsigned long size;
+	struct videobuf_buffer *vb;
+
+	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,
+				size, DMA_TO_DEVICE);
+	return ret;
 }
 
Quoted 2 lines

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

[Hiremath, Vaibhav] Acked-By: Vaibhav Hiremath <[email protected]>

Thanks,
Vaibhav

Quoted 2 lines

--
1.7.1

author
#5 lore raw

PATCH v2 3/3 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.

---
Changes from v1:
- None.

 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 7d3410a..548f4cd 100644
@@ -1041,10 +1041,7 @@ static int vidioc_enum_fmt_vid_out(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;
 
@@ -1213,10 +1210,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
#6 lore raw

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

Quoted 39 lines

-----Original Message-----
From: JAIN, AMBER
Sent: Thursday, July 07, 2011 5:51 PM
To: [email protected]
Cc: Hiremath, Vaibhav; JAIN, AMBER; Nilofer, Samreen
Subject: [PATCH v2 3/3] V4l2: OMAP: VOUT: Minor Cleanup, removing the unnecessary code.

Minor changes to remove the unused code from omap_vout driver.

---
Changes from v1:
- None.

 drivers/media/video/omap/omap_vout.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
drivers/media/video/omap/omap_vout.c +0 -3
index 7d3410a..548f4cd 100644
@@ -1041,10 +1041,7 @@ static int vidioc_enum_fmt_vid_out(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;

drivers/media/video/omap/omap_vout.c static int vidioc_enum_fmt_vid_overlay(struct file · line 1216

Quoted 10 lines
drivers/media/video/omap/omap_vout.c +0 -3
@@ -1213,10 +1210,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;

[Hiremath, Vaibhav] Acked-By: Vaibhav Hiremath <[email protected]>

Thanks,
Vaibhav

Quoted 2 lines

--
1.7.1