]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: i2c: imx219: Replace exposure magic value with named constant
authorTarang Raval <tarang.raval@siliconsignals.io>
Fri, 31 Oct 2025 11:48:35 +0000 (17:18 +0530)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Thu, 13 Nov 2025 09:57:52 +0000 (10:57 +0100)
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.

Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/i2c/imx219.c

index 40693635c0c3d6e2f0383c85220a7935d1079159..bc55fe2a93b44e66e8e02205b104d58f93488857 100644 (file)
@@ -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,