]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: renesas: vsp1: rpf: Fix crop width and height clamping
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Wed, 18 Mar 2026 23:58:59 +0000 (01:58 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Wed, 25 Mar 2026 09:25:48 +0000 (10:25 +0100)
The vsp1 driver doesn't enforce a minimum value on the RPF crop rectangle
width and height. Empty rectangles are accepted, leading to incorrect
hardware behaviour. Fix it by adding minimum width and height
constraints to the value clamping.

Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # HiHope RZ/G2M
Link: https://patch.msgid.link/20260318235907.831556-6-laurent.pinchart+renesas@ideasonboard.com
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/renesas/vsp1/vsp1_rwpf.c

index ffc1b3ab54e2494127aa19eef4ae11a013e6ac2e..ccc7608f538d6c2f0246255eb838bda0f1dd002d 100644 (file)
@@ -261,9 +261,9 @@ static int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
 
        sel->r.left = clamp_t(int, sel->r.left, 0, format->width - min_width);
        sel->r.top = clamp_t(int, sel->r.top, 0, format->height - min_height);
-       sel->r.width = min_t(unsigned int, sel->r.width,
+       sel->r.width = clamp(sel->r.width, min_width,
                             format->width - sel->r.left);
-       sel->r.height = min_t(unsigned int, sel->r.height,
+       sel->r.height = clamp(sel->r.height, min_height,
                              format->height - sel->r.top);
 
        crop = v4l2_subdev_state_get_crop(state, RWPF_PAD_SINK);