Skip to contentSkip to conversation

rcar-vin: Use bytes per line instead of width for UV offset

PATCH In review Niklas Söderlund 3 participants 3 messages Sep 5, 2019 – Sep 11, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rcar-vin: Use bytes per line instead of width for UV offset

The image size is doubled for NV16 and is calculated as bytesperline * height * 2 to accommodate the split of UV data. When writing the offset to hardware width is used instead of bytesperline, fix this.

---
 drivers/media/platform/rcar-vin/rcar-dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/rcar-vin/rcar-dma.c +2 -2
index c7859b329dd4f02a..af4f774149f08597 100644
@@ -703,8 +703,8 @@ static int rvin_setup(struct rvin_dev *vin)
 	switch (vin->format.pixelformat) {
 	case V4L2_PIX_FMT_NV16:
 		rvin_write(vin,
-			   ALIGN(vin->format.width * vin->format.height, 0x80),
-			   VNUVAOF_REG);
+			   ALIGN(vin->format.bytesperline * vin->format.height,
+				 0x80), VNUVAOF_REG);
 		dmr = VNDMR_DTMD_YCSEP;
 		output_is_yuv = true;
 		break;
Signature · 1 line
2.23.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Niklas,

Quoted 3 lines · Niklas Söderlund

The image size is doubled for NV16 and is calculated as bytesperline * height * 2 to accommodate the split of UV data. When writing the offset to hardware width is used instead of bytesperline, fix this.

s/hardware width/hardware, the width/ ?

Quoted 1 line

Eeep, Subtle bug :)

Quoted 21 lines
---
 drivers/media/platform/rcar-vin/rcar-dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/rcar-vin/rcar-dma.c +2 -2
index c7859b329dd4f02a..af4f774149f08597 100644
@@ -703,8 +703,8 @@ static int rvin_setup(struct rvin_dev *vin)
 	switch (vin->format.pixelformat) {
 	case V4L2_PIX_FMT_NV16:
 		rvin_write(vin,
-			   ALIGN(vin->format.width * vin->format.height, 0x80),
-			   VNUVAOF_REG);
+			   ALIGN(vin->format.bytesperline * vin->format.height,
+				 0x80), VNUVAOF_REG);
 		dmr = VNDMR_DTMD_YCSEP;
 		output_is_yuv = true;
 		break;
#2 lore raw
In reply to Niklas Söderlund

Hello Niklas,

Quoted 14 lines · Niklas Söderlund

The image size is doubled for NV16 and is calculated as bytesperline * height * 2 to accommodate the split of UV data. When writing the offset to hardware width is used instead of bytesperline, fix this.

---
 drivers/media/platform/rcar-vin/rcar-dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/rcar-vin/rcar-dma.c +0 -0
index c7859b329dd4f02a..af4f774149f08597 100644

drivers/media/platform/rcar-vin/rcar-dma.c static int rvin_setup(struct rvin_dev *vin) · line 707

Quoted 7 lines
drivers/media/platform/rcar-vin/rcar-dma.c +2 -2
@@ -703,8 +703,8 @@ static int rvin_setup(struct rvin_dev *vin)
 	switch (vin->format.pixelformat) {
 	case V4L2_PIX_FMT_NV16:
 		rvin_write(vin,
-			   ALIGN(vin->format.width * vin->format.height, 0x80),
-			   VNUVAOF_REG);
+			   ALIGN(vin->format.bytesperline * vin->format.height,
+				 0x80), VNUVAOF_REG);

You can make your life easier by simply pulling the pixel format helper and let someone figure out the math. See v4l2_fill_pixfmt and friends.

Avoiding these type of subtle issues is why we have them.

Eze