11210a6a2f63664d191313d559ffaf11191fac74
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0815-media-i2c-imx258-Make-V4L2_CID_VBLANK-configurable.patch
1 From 2df16ebeea66a589195944bd2b501783c3cab60f Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Tue, 15 Jun 2021 18:56:33 +0100
4 Subject: [PATCH] media: i2c: imx258: Make V4L2_CID_VBLANK
5 configurable.
6
7 The values and ranges of V4L2_CID_VBLANK are all computed,
8 so there is no reason for it to be a read only control.
9 Remove the register values from the mode lists, add the
10 handler, and remove the read only flag.
11
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
13 ---
14 drivers/media/i2c/imx258.c | 16 +++++++---------
15 1 file changed, 7 insertions(+), 9 deletions(-)
16
17 --- a/drivers/media/i2c/imx258.c
18 +++ b/drivers/media/i2c/imx258.c
19 @@ -30,6 +30,8 @@
20 #define IMX258_VTS_30FPS_VGA 0x034c
21 #define IMX258_VTS_MAX 0xffff
22
23 +#define IMX258_REG_VTS 0x0340
24 +
25 /* HBLANK control - read only */
26 #define IMX258_PPL_DEFAULT 5352
27
28 @@ -203,8 +205,6 @@ static const struct imx258_reg mode_4208
29 { 0x0114, 0x03 },
30 { 0x0342, 0x14 },
31 { 0x0343, 0xE8 },
32 - { 0x0340, 0x0C },
33 - { 0x0341, 0x50 },
34 { 0x0344, 0x00 },
35 { 0x0345, 0x00 },
36 { 0x0346, 0x00 },
37 @@ -320,8 +320,6 @@ static const struct imx258_reg mode_2104
38 { 0x0114, 0x03 },
39 { 0x0342, 0x14 },
40 { 0x0343, 0xE8 },
41 - { 0x0340, 0x06 },
42 - { 0x0341, 0x38 },
43 { 0x0344, 0x00 },
44 { 0x0345, 0x00 },
45 { 0x0346, 0x00 },
46 @@ -437,8 +435,6 @@ static const struct imx258_reg mode_1048
47 { 0x0114, 0x03 },
48 { 0x0342, 0x14 },
49 { 0x0343, 0xE8 },
50 - { 0x0340, 0x03 },
51 - { 0x0341, 0x4C },
52 { 0x0344, 0x00 },
53 { 0x0345, 0x00 },
54 { 0x0346, 0x00 },
55 @@ -831,6 +827,11 @@ static int imx258_set_ctrl(struct v4l2_c
56 BIT(IMX258_HDR_RATIO_MAX));
57 }
58 break;
59 + case V4L2_CID_VBLANK:
60 + ret = imx258_write_reg(imx258, IMX258_REG_VTS,
61 + IMX258_REG_VALUE_16BIT,
62 + imx258->cur_mode->height + ctrl->val);
63 + break;
64 case V4L2_CID_VFLIP:
65 case V4L2_CID_HFLIP:
66 ret = imx258_write_reg(imx258, REG_MIRROR_FLIP_CONTROL,
67 @@ -1233,9 +1234,6 @@ static int imx258_init_controls(struct i
68 IMX258_VTS_MAX - imx258->cur_mode->height, 1,
69 vblank_def);
70
71 - if (imx258->vblank)
72 - imx258->vblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
73 -
74 imx258->hblank = v4l2_ctrl_new_std(
75 ctrl_hdlr, &imx258_ctrl_ops, V4L2_CID_HBLANK,
76 IMX258_PPL_DEFAULT - imx258->cur_mode->width,