1 From 953826015a003f08f033d33e09799a5380c1b5ae Mon Sep 17 00:00:00 2001
2 From: Alexander Stein <alexander.stein@ew.tq-group.com>
3 Date: Fri, 17 Feb 2023 10:52:21 +0100
4 Subject: [PATCH] media: i2c: imx290: Add support for imx327 variant
6 Should be upstream commit 3c3f66b8125a
8 Both sensors are quite similar. Their specs only differ regarding LVDS
9 and parallel output but are identical regarding MIPI-CSI-2 interface.
10 But they use a different init setting of hard-coded values, taken from
13 Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
14 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
16 drivers/media/i2c/imx290.c | 44 ++++++++++++++++++++++++++++++++++++--
17 1 file changed, 42 insertions(+), 2 deletions(-)
19 --- a/drivers/media/i2c/imx290.c
20 +++ b/drivers/media/i2c/imx290.c
21 @@ -176,10 +176,14 @@ enum imx290_colour_variant {
23 IMX290_MODEL_IMX290LQR,
24 IMX290_MODEL_IMX290LLR,
25 + IMX290_MODEL_IMX327LQR,
28 struct imx290_model_info {
29 enum imx290_colour_variant colour_variant;
30 + const struct imx290_regval *init_regs;
31 + size_t init_regs_num;
35 enum imx290_clk_freq {
36 @@ -275,10 +279,14 @@ static const struct imx290_regval imx290
37 { IMX290_WINWV, 1097 },
38 { IMX290_XSOUTSEL, IMX290_XSOUTSEL_XVSOUTSEL_VSYNC |
39 IMX290_XSOUTSEL_XHSOUTSEL_HSYNC },
40 - { IMX290_REG_8BIT(0x300f), 0x00 },
41 - { IMX290_REG_8BIT(0x3010), 0x21 },
42 + { IMX290_REG_8BIT(0x3011), 0x02 },
43 { IMX290_REG_8BIT(0x3012), 0x64 },
44 { IMX290_REG_8BIT(0x3013), 0x00 },
47 +static const struct imx290_regval imx290_global_init_settings_290[] = {
48 + { IMX290_REG_8BIT(0x300f), 0x00 },
49 + { IMX290_REG_8BIT(0x3010), 0x21 },
50 { IMX290_REG_8BIT(0x3016), 0x09 },
51 { IMX290_REG_8BIT(0x3070), 0x02 },
52 { IMX290_REG_8BIT(0x3071), 0x11 },
53 @@ -331,6 +339,12 @@ static const struct imx290_regval xclk_r
57 +static const struct imx290_regval imx290_global_init_settings_327[] = {
58 + { IMX290_REG_8BIT(0x309e), 0x4A },
59 + { IMX290_REG_8BIT(0x309f), 0x4A },
60 + { IMX290_REG_8BIT(0x313b), 0x61 },
63 static const struct imx290_regval imx290_1080p_settings[] = {
65 { IMX290_WINWV_OB, 12 },
66 @@ -1009,6 +1023,14 @@ static int imx290_start_streaming(struct
70 + /* Set mdel specific init register settings */
71 + ret = imx290_set_register_array(imx290, imx290->model->init_regs,
72 + imx290->model->init_regs_num);
74 + dev_err(imx290->dev, "Could not set model specific init registers\n");
78 /* Set clock parameters based on mode and xclk */
79 ret = imx290_set_clock(imx290);
81 @@ -1477,9 +1499,21 @@ static s64 imx290_check_link_freqs(const
82 static const struct imx290_model_info imx290_models[] = {
83 [IMX290_MODEL_IMX290LQR] = {
84 .colour_variant = IMX290_VARIANT_COLOUR,
85 + .init_regs = imx290_global_init_settings_290,
86 + .init_regs_num = ARRAY_SIZE(imx290_global_init_settings_290),
89 [IMX290_MODEL_IMX290LLR] = {
90 .colour_variant = IMX290_VARIANT_MONO,
91 + .init_regs = imx290_global_init_settings_290,
92 + .init_regs_num = ARRAY_SIZE(imx290_global_init_settings_290),
95 + [IMX290_MODEL_IMX327LQR] = {
96 + .colour_variant = IMX290_VARIANT_COLOUR,
97 + .init_regs = imx290_global_init_settings_327,
98 + .init_regs_num = ARRAY_SIZE(imx290_global_init_settings_327),
103 @@ -1612,6 +1646,9 @@ static int imx290_probe(struct i2c_clien
107 + v4l2_i2c_subdev_set_name(&imx290->sd, client,
108 + imx290->model->name, NULL);
111 * Finally, register the V4L2 subdev. This must be done after
112 * initializing everything as the subdev can be used immediately after
113 @@ -1670,6 +1707,9 @@ static const struct of_device_id imx290_
115 .compatible = "sony,imx290llr",
116 .data = &imx290_models[IMX290_MODEL_IMX290LLR],
118 + .compatible = "sony,imx327lqr",
119 + .data = &imx290_models[IMX290_MODEL_IMX327LQR],