All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: v4l: vsp1: Fix offset calculation for plane cropping
@ 2022-02-28 12:00 Laurent Pinchart
  2022-02-28 12:35 ` Kieran Bingham
  2022-03-02 11:00 ` Michael Rodin
  0 siblings, 2 replies; 7+ messages in thread
From: Laurent Pinchart @ 2022-02-28 12:00 UTC (permalink / raw)
  To: linux-media; +Cc: linux-renesas-soc, Michael Rodin, LUU HOAI, Kieran Bingham

From: Michael Rodin <mrodin@de.adit-jv.com>

The vertical subsampling factor is currently not considered in the
offset calculation for plane cropping done in rpf_configure_partition.
This causes a distortion (shift of the color plane) when formats with
the vsub factor larger than 1 are used (e.g. NV12, see
vsp1_video_formats in vsp1_pipe.c). This commit considers vsub factor
for all planes except plane 0 (luminance).

Fixes: e5ad37b64de9 ("[media] v4l: vsp1: Add cropping support")
Signed-off-by: Michael Rodin <mrodin@de.adit-jv.com>
Signed-off-by: LUU HOAI <hoai.luu.ub@renesas.com>

Drop generalization of the offset calculation to reduce the binary size.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/vsp1/vsp1_rpf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c
index 85587c1b6a37..75083cb234fe 100644
--- a/drivers/media/platform/vsp1/vsp1_rpf.c
+++ b/drivers/media/platform/vsp1/vsp1_rpf.c
@@ -291,11 +291,11 @@ static void rpf_configure_partition(struct vsp1_entity *entity,
 		     + crop.left * fmtinfo->bpp[0] / 8;
 
 	if (format->num_planes > 1) {
+		unsigned int bpl = format->plane_fmt[1].bytesperline;
 		unsigned int offset;
 
-		offset = crop.top * format->plane_fmt[1].bytesperline
-		       + crop.left / fmtinfo->hsub
-		       * fmtinfo->bpp[1] / 8;
+		offset = crop.top / fmtinfo->vsub * bpl
+		       + crop.left / fmtinfo->hsub * fmtinfo->bpp[1] / 8;
 		mem.addr[1] += offset;
 		mem.addr[2] += offset;
 	}
-- 
Regards,

Laurent Pinchart


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-05-07 21:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28 12:00 [PATCH] media: v4l: vsp1: Fix offset calculation for plane cropping Laurent Pinchart
2022-02-28 12:35 ` Kieran Bingham
2022-03-02 11:00 ` Michael Rodin
2022-04-14 14:20   ` Laurent Pinchart
2022-04-19 10:22     ` Michael Rodin
2022-05-06  9:58       ` Michael Rodin
2022-05-07 21:16         ` Laurent Pinchart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.