Re: [PATCH v1 2/2] media: i2c: imx219: Replace exposure magic value with named constant

From: Kieran Bingham

Date: Fri Oct 31 2025 - 11:08:31 EST


Quoting Tarang Raval (2025-10-31 11:48:35)
> Introduce IMX219_EXPOSURE_OFFSET (4) and use it instead of the literal
> '4' when computing the maximum coarse exposure. The IMX219 datasheet
> specifies the maximum storage time as frame_length_lines - 4.
> (Ref: Datasheet section 5-7-1)
>
> Also fix one indentation issue for consistency.


Reviewed-by: Kieran Bingham <kieran.bingham@xxxxxxxxxxxxxxxx>

>
> Signed-off-by: Tarang Raval <tarang.raval@xxxxxxxxxxxxxxxxx>
> ---
> drivers/media/i2c/imx219.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
> index 40693635c0c3..e87d5a18fe87 100644
> --- a/drivers/media/i2c/imx219.c
> +++ b/drivers/media/i2c/imx219.c
> @@ -68,6 +68,7 @@
> #define IMX219_EXPOSURE_STEP 1
> #define IMX219_EXPOSURE_DEFAULT 0x640
> #define IMX219_EXPOSURE_MAX 65535
> +#define IMX219_EXPOSURE_OFFSET 4
>
> /* V_TIMING internal */
> #define IMX219_REG_FRM_LENGTH_A CCI_REG16(0x0160)
> @@ -450,9 +451,9 @@ static int imx219_set_ctrl(struct v4l2_ctrl *ctrl)
> int exposure_max, exposure_def;
>
> /* Update max exposure while meeting expected vblanking */
> - exposure_max = format->height + ctrl->val - 4;
> + exposure_max = format->height + ctrl->val - IMX219_EXPOSURE_OFFSET;
> exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ?
> - exposure_max : IMX219_EXPOSURE_DEFAULT;
> + exposure_max : IMX219_EXPOSURE_DEFAULT;
> ret = __v4l2_ctrl_modify_range(imx219->exposure,
> imx219->exposure->minimum,
> exposure_max,
> @@ -579,9 +580,9 @@ static int imx219_init_controls(struct imx219 *imx219)
> IMX219_LLP_MIN - mode->width,
> IMX219_LLP_MAX - mode->width, 1,
> IMX219_LLP_MIN - mode->width);
> - exposure_max = mode->fll_def - 4;
> + exposure_max = mode->fll_def - IMX219_EXPOSURE_OFFSET;
> exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ?
> - exposure_max : IMX219_EXPOSURE_DEFAULT;
> + exposure_max : IMX219_EXPOSURE_DEFAULT;
> imx219->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx219_ctrl_ops,
> V4L2_CID_EXPOSURE,
> IMX219_EXPOSURE_MIN, exposure_max,
> @@ -900,9 +901,9 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd,
> return ret;
>
> /* Update max exposure while meeting expected vblanking */
> - exposure_max = mode->fll_def - 4;
> + exposure_max = mode->fll_def - IMX219_EXPOSURE_OFFSET;
> exposure_def = (exposure_max < IMX219_EXPOSURE_DEFAULT) ?
> - exposure_max : IMX219_EXPOSURE_DEFAULT;
> + exposure_max : IMX219_EXPOSURE_DEFAULT;
> ret = __v4l2_ctrl_modify_range(imx219->exposure,
> imx219->exposure->minimum,
> exposure_max,
> --
> 2.34.1
>