From: Sakari Ailus Date: Wed, 11 Mar 2026 13:27:30 +0000 (+0200) Subject: media: imx219: Set horizontal blanking on mode change X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=224a4333fab19b7ccb321accdbbd969de0cc247f;p=thirdparty%2Flinux.git media: imx219: Set horizontal blanking on mode change The driver UAPI is mode-based, allowing the user to choose a mode from a small list based on the output size. The vertical blanking is set based on the mode, do the same for horizontal blanking so the frame rate obtained is constant. Additionally, it's best to use a known-good horizontal blanking value as choosing the value freely may affect image quality. While the minimum value may not be the best value for horizontal blanking, at least it is constant rather than a minimum value of a different configuration. Signed-off-by: Sakari Ailus Reviewed-by: Dave Stevenson Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index 0b9ff639e9f7..223d3753cc93 100644 --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -837,11 +837,9 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *format; struct v4l2_rect *crop; u8 bin_h, bin_v, binning; - u32 prev_line_len; int ret; format = v4l2_subdev_state_get_format(state, 0); - prev_line_len = format->width + imx219->hblank->val; /* * Adjust the requested format to match the closest mode. The Bayer @@ -882,7 +880,7 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd, if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) { int exposure_max; int exposure_def; - int hblank, llp_min; + int llp_min; int pixel_rate; /* Update limits and set FPS to default */ @@ -924,15 +922,8 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd, llp_min - mode->width); if (ret) return ret; - /* - * Retain PPL setting from previous mode so that the - * line time does not change on a mode change. - * Limits have to be recomputed as the controls define - * the blanking only, so PPL values need to have the - * mode width subtracted. - */ - hblank = prev_line_len - mode->width; - ret = __v4l2_ctrl_s_ctrl(imx219->hblank, hblank); + + ret = __v4l2_ctrl_s_ctrl(imx219->hblank, llp_min - mode->width); if (ret) return ret;