From: Laurent Pinchart Date: Wed, 18 Mar 2026 23:59:02 +0000 (+0200) Subject: media: renesas: vsp1: hsit: Fix size enumeration X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae16c0d6baabcf2b0779a14508a71a0e742552ff;p=thirdparty%2Fkernel%2Fstable.git media: renesas: vsp1: hsit: Fix size enumeration The HSIT entity performs format conversion, which leads to incorrect results with the vsp1_subdev_enum_frame_size() helper. Implement a custom .enum_frame_size() handler that correctly validates the media bus code. Size validation is identical to the helper. Tested-by: Lad Prabhakar # HiHope RZ/G2M Link: https://patch.msgid.link/20260318235907.831556-9-laurent.pinchart+renesas@ideasonboard.com Signed-off-by: Laurent Pinchart Signed-off-by: Hans Verkuil --- diff --git a/drivers/media/platform/renesas/vsp1/vsp1_hsit.c b/drivers/media/platform/renesas/vsp1/vsp1_hsit.c index 8260934db789..830e124beb7b 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_hsit.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_hsit.c @@ -9,6 +9,7 @@ #include #include +#include #include @@ -57,6 +58,56 @@ static int hsit_enum_mbus_code(struct v4l2_subdev *subdev, return 0; } +static int hsit_enum_frame_size(struct v4l2_subdev *subdev, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_frame_size_enum *fse) +{ + struct vsp1_entity *entity = to_vsp1_entity(subdev); + struct vsp1_hsit *hsit = to_hsit(subdev); + u32 code; + + if (fse->index) + return -EINVAL; + + if ((fse->pad == HSIT_PAD_SINK && !hsit->inverse) | + (fse->pad == HSIT_PAD_SOURCE && hsit->inverse)) + code = MEDIA_BUS_FMT_ARGB8888_1X32; + else + code = MEDIA_BUS_FMT_AHSV8888_1X32; + + if (fse->code != code) + return -EINVAL; + + if (fse->pad == 0) { + fse->min_width = entity->min_width; + fse->max_width = entity->max_width; + fse->min_height = entity->min_height; + fse->max_height = entity->max_height; + } else { + struct v4l2_subdev_state *state; + struct v4l2_mbus_framefmt *format; + + state = vsp1_entity_get_state(entity, sd_state, fse->which); + if (!state) + return -EINVAL; + + /* + * The size on the source pad is fixed and always identical to + * the sink pad. + */ + format = v4l2_subdev_state_get_format(state, HSIT_PAD_SINK); + + guard(mutex)(&entity->lock); + + fse->min_width = format->width; + fse->max_width = format->width; + fse->min_height = format->height; + fse->max_height = format->height; + } + + return 0; +} + static int hsit_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_format *fmt) @@ -117,7 +168,7 @@ done: static const struct v4l2_subdev_pad_ops hsit_pad_ops = { .enum_mbus_code = hsit_enum_mbus_code, - .enum_frame_size = vsp1_subdev_enum_frame_size, + .enum_frame_size = hsit_enum_frame_size, .get_fmt = vsp1_subdev_get_pad_format, .set_fmt = hsit_set_format, };