media: i2c: imx258: Make image geometry meet sensor requirements
authorDave Stevenson <dave.stevenson@raspberrypi.com>
Tue, 15 Jun 2021 17:34:38 +0000 (18:34 +0100)
committerPhil Elwell <8911409+pelwell@users.noreply.github.com>
Fri, 8 Apr 2022 13:40:20 +0000 (14:40 +0100)
commit1942d0da85bac79f3d2a1c2d8e797e97bd16b618
tree6d9d6f959b83b2196032d0b03b834d0059cf67bb
parent295b7dff9b18dddea760d4ddfd6668773066f7f6
media: i2c: imx258: Make image geometry meet sensor requirements

The output image is defined as being 4208x3118 pixels in size.
Y_ADD_STA register was set to 0, and Y_ADD_END to 3118, giving
3119 lines total.

The datasheet lists a requirement for Y_ADD_STA to be a multiple
of a power of 2 depending on binning/scaling mode (2 for full pixel,
4 for x2-bin/scale, 8 for (x2-bin)+(x2-subsample) or x4-bin, or 16
for (x4-bin)+(x2-subsample)).
(Y_ADD_END – Y_ADD_STA + 1) also has to be a similar power of 2.

The current configuration for the full res modes breaks that second
requirement, and we can't increase Y_ADD_STA to 1 to retain exactly
the same field of view as that then breaks the first requirement.
For the binned modes, they are worse off as 3118 is not a multiple of
4.

Increase the main mode to 4208x3120 so that it is the same FOV as the
binned modes, with Y_ADD_STA at 0.
Fix Y_ADD_STA and Y_ADD_END for the binned modes so that they meet the
sensor requirements.

This does change the Bayer order as the default configuration is for
H&V flips to be enabled, so readout is from Y_STA_END to Y_ADD_STA,
and this patch has changed Y_STA_END.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
drivers/media/i2c/imx258.c