bcm27xx: 6.1: add kernel patches
[openwrt/staging/nbd.git] / target / linux / bcm27xx / patches-6.1 / 950-0622-media-i2c-imx290-Add-exposure-time-control.patch
1 From ead4ef32c120f20ee9b1d8f9f0a4f75c2dc14af3 Mon Sep 17 00:00:00 2001
2 From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
3 Date: Sun, 16 Oct 2022 09:15:15 +0300
4 Subject: [PATCH] media: i2c: imx290: Add exposure time control
5
6 Upstream commit 827c7e69cb2d.
7
8 Support configuring the exposure time, which is expressed as the
9 complement of the exposure time (frame period minus integration time).
10 The frame period is currently fixed.
11
12 Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
13 Acked-by: Alexander Stein <alexander.stein@ew.tq-group.com>
14 Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
15 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
16 ---
17 drivers/media/i2c/imx290.c | 16 ++++++++++++++--
18 1 file changed, 14 insertions(+), 2 deletions(-)
19
20 --- a/drivers/media/i2c/imx290.c
21 +++ b/drivers/media/i2c/imx290.c
22 @@ -103,6 +103,8 @@
23 #define IMX290_PGCTRL_THRU BIT(1)
24 #define IMX290_PGCTRL_MODE(n) ((n) << 4)
25
26 +#define IMX290_VMAX_DEFAULT 1125
27 +
28 static const char * const imx290_supply_name[] = {
29 "vdda",
30 "vddd",
31 @@ -176,7 +178,7 @@ static const char * const imx290_test_pa
32
33 static const struct imx290_regval imx290_global_init_settings[] = {
34 { IMX290_CTRL_07, IMX290_WINMODE_1080P },
35 - { IMX290_VMAX, 1125 },
36 + { IMX290_VMAX, IMX290_VMAX_DEFAULT },
37 { IMX290_EXTCK_FREQ, 0x2520 },
38 { IMX290_WINWV_OB, 12 },
39 { IMX290_WINPH, 0 },
40 @@ -480,6 +482,12 @@ static int imx290_set_ctrl(struct v4l2_c
41 case V4L2_CID_GAIN:
42 ret = imx290_write(imx290, IMX290_GAIN, ctrl->val, NULL);
43 break;
44 +
45 + case V4L2_CID_EXPOSURE:
46 + ret = imx290_write(imx290, IMX290_SHS1,
47 + IMX290_VMAX_DEFAULT - ctrl->val - 1, NULL);
48 + break;
49 +
50 case V4L2_CID_TEST_PATTERN:
51 if (ctrl->val) {
52 imx290_write(imx290, IMX290_BLKLEVEL, 0, &ret);
53 @@ -1008,12 +1016,16 @@ static int imx290_probe(struct i2c_clien
54 */
55 imx290_entity_init_cfg(&imx290->sd, NULL);
56
57 - v4l2_ctrl_handler_init(&imx290->ctrls, 4);
58 + v4l2_ctrl_handler_init(&imx290->ctrls, 5);
59 imx290->ctrls.lock = &imx290->lock;
60
61 v4l2_ctrl_new_std(&imx290->ctrls, &imx290_ctrl_ops,
62 V4L2_CID_GAIN, 0, 72, 1, 0);
63
64 + v4l2_ctrl_new_std(&imx290->ctrls, &imx290_ctrl_ops,
65 + V4L2_CID_EXPOSURE, 1, IMX290_VMAX_DEFAULT - 2, 1,
66 + IMX290_VMAX_DEFAULT - 2);
67 +
68 imx290->link_freq =
69 v4l2_ctrl_new_int_menu(&imx290->ctrls, &imx290_ctrl_ops,
70 V4L2_CID_LINK_FREQ,