9caf98942dfddfb4dc634ad884112d4a9b5f221a
[openwrt/staging/stintel.git] /
1 From 2b7aa91757952e3214ddfd335ae527b89240ecb8 Mon Sep 17 00:00:00 2001
2 From: David Plowman <david.plowman@raspberrypi.com>
3 Date: Wed, 17 Feb 2021 18:08:12 +0000
4 Subject: [PATCH] media: i2c: imx290: Fix up exposure calcuations and
5 ranges
6
7 Should now correspond exactly to the datasheet.
8
9 Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
10 ---
11 drivers/media/i2c/imx290.c | 14 +++++++-------
12 1 file changed, 7 insertions(+), 7 deletions(-)
13
14 --- a/drivers/media/i2c/imx290.c
15 +++ b/drivers/media/i2c/imx290.c
16 @@ -50,7 +50,7 @@ enum imx290_clk_index {
17 #define IMX290_HMAX_MIN_4LANE 2200 /* Min of 2200 pixels = 60fps */
18 #define IMX290_HMAX_MAX 0xffff
19
20 -#define IMX290_EXPOSURE_MIN 2
21 +#define IMX290_EXPOSURE_MIN 1
22 #define IMX290_EXPOSURE_STEP 1
23 #define IMX290_EXPOSURE_LOW 0x3020
24 #define IMX290_PGCTRL 0x308c
25 @@ -584,7 +584,7 @@ static int imx290_set_gain(struct imx290
26 static int imx290_set_exposure(struct imx290 *imx290, u32 value)
27 {
28 u32 exposure = (imx290->current_mode->height + imx290->vblank->val) -
29 - value;
30 + value - 1;
31 int ret;
32
33 ret = imx290_write_buffered_reg(imx290, IMX290_EXPOSURE_LOW, 3,
34 @@ -855,10 +855,10 @@ static int imx290_set_fmt(struct v4l2_su
35 }
36 if (imx290->exposure)
37 __v4l2_ctrl_modify_range(imx290->exposure,
38 - mode->vmax - mode->height,
39 - mode->vmax - 4,
40 + IMX290_EXPOSURE_MIN,
41 + mode->vmax - 2,
42 IMX290_EXPOSURE_STEP,
43 - mode->vmax - 4);
44 + mode->vmax - 2);
45 }
46
47 *format = fmt->format;
48 @@ -1349,9 +1349,9 @@ static int imx290_probe(struct i2c_clien
49 imx290->exposure = v4l2_ctrl_new_std(&imx290->ctrls, &imx290_ctrl_ops,
50 V4L2_CID_EXPOSURE,
51 IMX290_EXPOSURE_MIN,
52 - mode->vmax - 4,
53 + mode->vmax - 2,
54 IMX290_EXPOSURE_STEP,
55 - mode->vmax - 4);
56 + mode->vmax - 2);
57
58 imx290->hflip = v4l2_ctrl_new_std(&imx290->ctrls, &imx290_ctrl_ops,
59 V4L2_CID_HFLIP, 0, 1, 1, 0);