[PATCH v2 17/25] media: i2c: imx283: Crop leading lines with user clamp

From: Kieran Bingham

Date: Fri Feb 13 2026 - 09:07:35 EST


The IMX283 introduces an extra line on the all-pixel scan out modes to
prevent bayer re-ordering on flip handling.

This is undesireable as it introduces the line in all crop
configurations when the image is not flipped.

The OB_SIZE_V register determines how many lines from the output will be
directed into the custom data type for optical black region.

To overcome the extra line which is forcefully added, utilise the
vertical optical black region to redirect the extra line. An additional
line also needs to be redirected to once again retain the bayer order.

Signed-off-by: Kieran Bingham <kieran.bingham@xxxxxxxxxxxxxxxx>
---
drivers/media/i2c/imx283.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/drivers/media/i2c/imx283.c b/drivers/media/i2c/imx283.c
index c3a44d2c6508..07958cd1889e 100644
--- a/drivers/media/i2c/imx283.c
+++ b/drivers/media/i2c/imx283.c
@@ -1169,6 +1169,29 @@ static int imx283_start_streaming(struct imx283 *imx283,
/* Clamp our top position now that VOB is handled */
top = max_t(s16, 0, top);

+ /*
+ * The all-pixel scan modes introduce an 'extra line' at the
+ * start of the image when not flipped. This is understood to be
+ * a mechanism to preserve bayer ordering regardless of vflip
+ * however it introduces an undesirable line of black pixels.
+ *
+ * Crop this by adding two extra lines and moving them into the
+ * OB data type without impacting the effective image height or
+ * positioning.
+ *
+ * It's ok for top to go negative here as the sensor does in
+ * fact have extra 'hidden' lines in this region and the sensor
+ * supports negative vertical cropping positions. (estimated
+ * about 48 extra lines)
+ */
+ if ((scan_mode(mode->scan, IMX283_MODE_0) ||
+ scan_mode(mode->scan, IMX283_MODE_1)) &&
+ imx283->vflip->val == 0) {
+ top -= 2;
+ v_ob += 2;
+ write_v_size += 2;
+ }
+
if (imx283->vflip->val)
top = -top;


--
2.52.0