01d22c2ef2e3d405dba2a476ff93fb438ddf9191
[openwrt/staging/stintel.git] /
1 From d3cbabced959831fb1f04565dd424ece48f1b831 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Thu, 31 Mar 2022 15:33:59 +0100
4 Subject: [PATCH] media: i2c: imx258: Allow configuration of clock lane
5 behaviour
6
7 The sensor supports the clock lane either remaining in HS mode
8 during frame blanking, or dropping to LP11.
9
10 Add configuration of the mode via V4L2_MBUS_CSI2_CONTINUOUS_CLOCK.
11
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
13 ---
14 drivers/media/i2c/imx258.c | 14 ++++++++++++++
15 1 file changed, 14 insertions(+)
16
17 --- a/drivers/media/i2c/imx258.c
18 +++ b/drivers/media/i2c/imx258.c
19 @@ -72,6 +72,8 @@
20 /* Test Pattern Control */
21 #define IMX258_REG_TEST_PATTERN 0x0600
22
23 +#define IMX258_CLK_BLANK_STOP 0x4040
24 +
25 /* Orientation */
26 #define REG_MIRROR_FLIP_CONTROL 0x0101
27 #define REG_CONFIG_MIRROR_HFLIP 0x01
28 @@ -848,6 +850,7 @@ struct imx258 {
29 const struct imx258_link_freq_config *link_freq_configs;
30 const s64 *link_freq_menu_items;
31 unsigned int nlanes;
32 + unsigned int csi2_flags;
33
34 /*
35 * Mutex for serialized access:
36 @@ -1300,6 +1303,15 @@ static int imx258_start_streaming(struct
37 return ret;
38 }
39
40 + ret = imx258_write_reg(imx258, IMX258_CLK_BLANK_STOP,
41 + IMX258_REG_VALUE_08BIT,
42 + imx258->csi2_flags & V4L2_MBUS_CSI2_CONTINUOUS_CLOCK ?
43 + 0 : 1);
44 + if (ret) {
45 + dev_err(&client->dev, "%s failed to set clock lane mode\n", __func__);
46 + return ret;
47 + }
48 +
49 /* Apply default values of current mode */
50 reg_list = &imx258->cur_mode->reg_list;
51 ret = imx258_write_regs(imx258, reg_list->regs, reg_list->num_of_regs);
52 @@ -1703,6 +1715,8 @@ static int imx258_probe(struct i2c_clien
53 goto error_endpoint_poweron;
54 }
55
56 + imx258->csi2_flags = ep.bus.mipi_csi2.flags;
57 +
58 /* Initialize subdev */
59 v4l2_i2c_subdev_init(&imx258->sd, client, &imx258_subdev_ops);
60