bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0347-media-i2c-imx290-Handle-exposure-correctly-when-vbla.patch
1 From 312748a4a15eba1d63a0861acabb7941c36e69d7 Mon Sep 17 00:00:00 2001
2 From: David Plowman <david.plowman@raspberrypi.com>
3 Date: Thu, 18 Feb 2021 11:58:29 +0000
4 Subject: [PATCH] media: i2c: imx290: Handle exposure correctly when
5 vblank changes
6
7 When vblank changes we must modify the exposure range. Also, with this
8 sensor, the effective exposure time implicitly changes when vblank
9 does, so we have to reset it after every vblank update.
10
11 Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
12 ---
13 drivers/media/i2c/imx290.c | 18 ++++++++++++++++++
14 1 file changed, 18 insertions(+)
15
16 --- a/drivers/media/i2c/imx290.c
17 +++ b/drivers/media/i2c/imx290.c
18 @@ -618,6 +618,24 @@ static int imx290_set_vmax(struct imx290
19 if (ret)
20 dev_err(imx290->dev, "Unable to write vmax\n");
21
22 + /*
23 + * Changing vblank changes the allowed range for exposure.
24 + * We don't supply the current exposure as default here as it
25 + * may lie outside the new range. We will reset it just below.
26 + */
27 + __v4l2_ctrl_modify_range(imx290->exposure,
28 + IMX290_EXPOSURE_MIN,
29 + vmax - 2,
30 + IMX290_EXPOSURE_STEP,
31 + vmax - 2);
32 +
33 + /*
34 + * Becuse of the way exposure works for this sensor, updating
35 + * vblank causes the effective exposure to change, so we must
36 + * set it back to the "new" correct value.
37 + */
38 + imx290_set_exposure(imx290, imx290->exposure->val);
39 +
40 return ret;
41 }
42