Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: vsp1: Fix offset calculation for plane cropping

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).

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

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>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Michael Rodin and committed by
Mauro Carvalho Chehab
5f25abec bf7d5ee1

+3 -3
+3 -3
drivers/media/platform/renesas/vsp1/vsp1_rpf.c
··· 291 291 + crop.left * fmtinfo->bpp[0] / 8; 292 292 293 293 if (format->num_planes > 1) { 294 + unsigned int bpl = format->plane_fmt[1].bytesperline; 294 295 unsigned int offset; 295 296 296 - offset = crop.top * format->plane_fmt[1].bytesperline 297 - + crop.left / fmtinfo->hsub 298 - * fmtinfo->bpp[1] / 8; 297 + offset = crop.top / fmtinfo->vsub * bpl 298 + + crop.left / fmtinfo->hsub * fmtinfo->bpp[1] / 8; 299 299 mem.addr[1] += offset; 300 300 mem.addr[2] += offset; 301 301 }