Skip to contentSkip to conversation

marvell-ccic: refine mcam_set_contig_buffer function

PATCH Superseded Albert Wang 2 participants 3 messages Nov 23, 2012 – Nov 27, 2012 Media (V4L/DVB)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 5/15 marvell-ccic: refine mcam_set_contig_buffer function

From: Libin Yang <[email protected]>

This patch refines mcam_set_contig_buffer() in mcam core

---
 drivers/media/platform/marvell-ccic/mcam-core.c |   21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/media/platform/marvell-ccic/mcam-core.c +10 -11
index 760e8ea..67d4f2f 100755
@@ -481,22 +481,21 @@ static void mcam_set_contig_buffer(struct mcam_camera *cam, int frame)
 	 */
 	if (list_empty(&cam->buffers)) {
 		buf = cam->vb_bufs[frame ^ 0x1];
-		cam->vb_bufs[frame] = buf;
-		mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR,
-				vb2_dma_contig_plane_dma_addr(&buf->vb_buf, 0));
 		set_bit(CF_SINGLE_BUFFER, &cam->flags);
 		cam->frame_state.singles++;
-		return;
+	} else {
+		/*
+		 * OK, we have a buffer we can use.
+		 */
+		buf = list_first_entry(&cam->buffers, struct mcam_vb_buffer,
+					queue);
+		list_del_init(&buf->queue);
+		clear_bit(CF_SINGLE_BUFFER, &cam->flags);
 	}
-	/*
-	 * OK, we have a buffer we can use.
-	 */
-	buf = list_first_entry(&cam->buffers, struct mcam_vb_buffer, queue);
-	list_del_init(&buf->queue);
+
+	cam->vb_bufs[frame] = buf;
 	mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR,
 			vb2_dma_contig_plane_dma_addr(&buf->vb_buf, 0));
-	cam->vb_bufs[frame] = buf;
-	clear_bit(CF_SINGLE_BUFFER, &cam->flags);
 }
 
 /*
Signature · 1 line
1.7.9.5
Acked-by on v1 5/15
#1 lore raw
Quoted 6 lines · Albert Wang

From: Libin Yang <[email protected]>

This patch refines mcam_set_contig_buffer() in mcam core

Looks good in general, just will have to be tested on currently supported platforms, because it changes the order, in which registers are written. So, if this patch is not too important for you, maybe it would be better to drop it, it doesn't seem to improve any functionality?

If it is decided to use this, you can add my

Thanks
Guennadi

Quoted 44 lines
---
 drivers/media/platform/marvell-ccic/mcam-core.c |   21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/media/platform/marvell-ccic/mcam-core.c +10 -11
index 760e8ea..67d4f2f 100755
@@ -481,22 +481,21 @@ static void mcam_set_contig_buffer(struct mcam_camera *cam, int frame)
 	 */
 	if (list_empty(&cam->buffers)) {
 		buf = cam->vb_bufs[frame ^ 0x1];
-		cam->vb_bufs[frame] = buf;
-		mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR,
-				vb2_dma_contig_plane_dma_addr(&buf->vb_buf, 0));
 		set_bit(CF_SINGLE_BUFFER, &cam->flags);
 		cam->frame_state.singles++;
-		return;
+	} else {
+		/*
+		 * OK, we have a buffer we can use.
+		 */
+		buf = list_first_entry(&cam->buffers, struct mcam_vb_buffer,
+					queue);
+		list_del_init(&buf->queue);
+		clear_bit(CF_SINGLE_BUFFER, &cam->flags);
 	}
-	/*
-	 * OK, we have a buffer we can use.
-	 */
-	buf = list_first_entry(&cam->buffers, struct mcam_vb_buffer, queue);
-	list_del_init(&buf->queue);
+
+	cam->vb_bufs[frame] = buf;
 	mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR,
 			vb2_dma_contig_plane_dma_addr(&buf->vb_buf, 0));
-	cam->vb_bufs[frame] = buf;
-	clear_bit(CF_SINGLE_BUFFER, &cam->flags);
 }
 
 /*
Signature · 1 line
1.7.9.5

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

#2 lore raw

Hi, Guennadi

Quoted 13 lines

-----Original Message-----
From: Guennadi Liakhovetski [mailto:[email protected]]
Sent: Tuesday, 27 November, 2012 19:04
To: Albert Wang
Cc: [email protected]; [email protected]; Libin Yang
Subject: Re: [PATCH 05/15] [media] marvell-ccic: refine mcam_set_contig_buffer function

Quoted 4 lines · Albert Wang

From: Libin Yang <[email protected]>

This patch refines mcam_set_contig_buffer() in mcam core

Quoted 8 lines
Quoted 2 lines

Looks good in general, just will have to be tested on currently supported platforms, because it changes the order, in which registers are written.
So, if this patch is not too important for you, maybe it would be better to drop it, it doesn't seem to improve any functionality?

It didn't improve the functionality, just prepare for the 3 frame buffer support patch. :)

Quoted 58 lines

If it is decided to use this, you can add my

Thanks
Guennadi

drivers/media/platform/marvell-ccic/mcam-core.c static void mcam_set_contig_buffer(struct mcam_camera

Quoted 10 lines
---
 drivers/media/platform/marvell-ccic/mcam-core.c |   21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/media/platform/marvell-ccic/mcam-core.c +0 -0
index 760e8ea..67d4f2f 100755
@@ -481,22 +481,21 @@ static void mcam_set_contig_buffer(struct mcam_camera

*cam, int frame)

Quoted 33 lines
drivers/media/platform/marvell-ccic/mcam-core.c +10 -12
 	 */
 	if (list_empty(&cam->buffers)) {
 		buf = cam->vb_bufs[frame ^ 0x1];
-		cam->vb_bufs[frame] = buf;
-		mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR,
-				vb2_dma_contig_plane_dma_addr(&buf->vb_buf, 0));
 		set_bit(CF_SINGLE_BUFFER, &cam->flags);
 		cam->frame_state.singles++;
-		return;
+	} else {
+		/*
+		 * OK, we have a buffer we can use.
+		 */
+		buf = list_first_entry(&cam->buffers, struct mcam_vb_buffer,
+					queue);
+		list_del_init(&buf->queue);
+		clear_bit(CF_SINGLE_BUFFER, &cam->flags);
 	}
-	/*
-	 * OK, we have a buffer we can use.
-	 */
-	buf = list_first_entry(&cam->buffers, struct mcam_vb_buffer, queue);
-	list_del_init(&buf->queue);
+
+	cam->vb_bufs[frame] = buf;
 	mcam_reg_write(cam, frame == 0 ? REG_Y0BAR : REG_Y1BAR,
 			vb2_dma_contig_plane_dma_addr(&buf->vb_buf, 0));
-	cam->vb_bufs[frame] = buf;
-	clear_bit(CF_SINGLE_BUFFER, &cam->flags);
 }
 
 /*
--
Quoted 2 lines

1.7.9.5

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/