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

[media] v4l: vsp1: Align crop rectangle to even boundary for YUV formats

Make sure that there are valid values in the crop rectangle to ensure
that the color plane doesn't get shifted when cropping.
Since there is no distinction between 12bit and 16bit YUV formats in
at the subdev level, use the more restrictive 12bit limits for all YUV
formats.

Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Damian Hobson-Garcia and committed by
Mauro Carvalho Chehab
85a0638b 1c991fee

+11
+11
drivers/media/platform/vsp1/vsp1_rwpf.c
··· 197 197 */ 198 198 format = vsp1_entity_get_pad_format(&rwpf->entity, cfg, RWPF_PAD_SINK, 199 199 sel->which); 200 + 201 + /* Restrict the crop rectangle coordinates to multiples of 2 to avoid 202 + * shifting the color plane. 203 + */ 204 + if (format->code == MEDIA_BUS_FMT_AYUV8_1X32) { 205 + sel->r.left = ALIGN(sel->r.left, 2); 206 + sel->r.top = ALIGN(sel->r.top, 2); 207 + sel->r.width = round_down(sel->r.width, 2); 208 + sel->r.height = round_down(sel->r.height, 2); 209 + } 210 + 200 211 sel->r.left = min_t(unsigned int, sel->r.left, format->width - 2); 201 212 sel->r.top = min_t(unsigned int, sel->r.top, format->height - 2); 202 213 if (rwpf->entity.type == VSP1_ENTITY_WPF) {