1 From 03c77d0b8ef969c88e00729dbbf488eba081aa7d Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Tue, 15 Jun 2021 18:34:38 +0100
4 Subject: [PATCH] media: i2c: imx258: Make image geometry meet sensor
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 The output image is defined as being 4208x3118 pixels in size.
11 Y_ADD_STA register was set to 0, and Y_ADD_END to 3118, giving
14 The datasheet lists a requirement for Y_ADD_STA to be a multiple
15 of a power of 2 depending on binning/scaling mode (2 for full pixel,
16 4 for x2-bin/scale, 8 for (x2-bin)+(x2-subsample) or x4-bin, or 16
17 for (x4-bin)+(x2-subsample)).
18 (Y_ADD_END – Y_ADD_STA + 1) also has to be a similar power of 2.
20 The current configuration for the full res modes breaks that second
21 requirement, and we can't increase Y_ADD_STA to 1 to retain exactly
22 the same field of view as that then breaks the first requirement.
23 For the binned modes, they are worse off as 3118 is not a multiple of
26 Increase the main mode to 4208x3120 so that it is the same FOV as the
27 binned modes, with Y_ADD_STA at 0.
28 Fix Y_ADD_STA and Y_ADD_END for the binned modes so that they meet the
31 This does change the Bayer order as the default configuration is for
32 H&V flips to be enabled, so readout is from Y_STA_END to Y_ADD_STA,
33 and this patch has changed Y_STA_END.
35 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
37 drivers/media/i2c/imx258.c | 26 +++++++++++++-------------
38 1 file changed, 13 insertions(+), 13 deletions(-)
40 --- a/drivers/media/i2c/imx258.c
41 +++ b/drivers/media/i2c/imx258.c
42 @@ -110,7 +110,7 @@ struct imx258_mode {
43 struct imx258_reg_list reg_list;
46 -/* 4208x3118 needs 1267Mbps/lane, 4 lanes */
47 +/* 4208x3120 needs 1267Mbps/lane, 4 lanes */
48 static const struct imx258_reg mipi_data_rate_1267mbps[] = {
51 @@ -147,7 +147,7 @@ static const struct imx258_reg mipi_data
55 -static const struct imx258_reg mode_4208x3118_regs[] = {
56 +static const struct imx258_reg mode_4208x3120_regs[] = {
60 @@ -209,7 +209,7 @@ static const struct imx258_reg mode_4208
69 @@ -328,7 +328,7 @@ static const struct imx258_reg mode_2104
78 @@ -447,7 +447,7 @@ static const struct imx258_reg mode_1048
87 @@ -561,12 +561,12 @@ static const struct imx258_link_freq_con
88 static const struct imx258_mode supported_modes[] = {
93 .vts_def = IMX258_VTS_30FPS,
94 .vts_min = IMX258_VTS_30FPS,
96 - .num_of_regs = ARRAY_SIZE(mode_4208x3118_regs),
97 - .regs = mode_4208x3118_regs,
98 + .num_of_regs = ARRAY_SIZE(mode_4208x3120_regs),
99 + .regs = mode_4208x3120_regs,
101 .link_freq_index = IMX258_LINK_FREQ_1267MBPS,
103 @@ -709,7 +709,7 @@ static int imx258_open(struct v4l2_subde
104 /* Initialize try_fmt */
105 try_fmt->width = supported_modes[0].width;
106 try_fmt->height = supported_modes[0].height;
107 - try_fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
108 + try_fmt->code = MEDIA_BUS_FMT_SBGGR10_1X10;
109 try_fmt->field = V4L2_FIELD_NONE;
112 @@ -821,7 +821,7 @@ static int imx258_enum_mbus_code(struct
116 - code->code = MEDIA_BUS_FMT_SGRBG10_1X10;
117 + code->code = MEDIA_BUS_FMT_SBGGR10_1X10;
121 @@ -833,7 +833,7 @@ static int imx258_enum_frame_size(struct
122 if (fse->index >= ARRAY_SIZE(supported_modes))
125 - if (fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
126 + if (fse->code != MEDIA_BUS_FMT_SBGGR10_1X10)
129 fse->min_width = supported_modes[fse->index].width;
130 @@ -849,7 +849,7 @@ static void imx258_update_pad_format(con
132 fmt->format.width = mode->width;
133 fmt->format.height = mode->height;
134 - fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
135 + fmt->format.code = MEDIA_BUS_FMT_SBGGR10_1X10;
136 fmt->format.field = V4L2_FIELD_NONE;
139 @@ -897,7 +897,7 @@ static int imx258_set_pad_format(struct
140 mutex_lock(&imx258->mutex);
142 /* Only one raw bayer(GBRG) order is supported */
143 - fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
144 + fmt->format.code = MEDIA_BUS_FMT_SBGGR10_1X10;
146 mode = v4l2_find_nearest_size(supported_modes,
147 ARRAY_SIZE(supported_modes), width, height,