[PATCH v2 16/25] media: i2c: imx283: Account for clamp region coordinates

From: Kieran Bingham

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


The user clamp region is included in the pixel native area coordinates
but is not included in the sensor vertical coordinates when configuring
the VWINPOS.

Remove the 16 line offset from the top position to account for this
and in the event that a crop position requested vertical optical
black, reduce the OB_SIZE_V register which causes those lines to be
output in the main image data type instead.

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

diff --git a/drivers/media/i2c/imx283.c b/drivers/media/i2c/imx283.c
index f9cf2bb0e10d..c3a44d2c6508 100644
--- a/drivers/media/i2c/imx283.c
+++ b/drivers/media/i2c/imx283.c
@@ -1144,15 +1144,31 @@ static int imx283_start_streaming(struct imx283 *imx283,
/* Vertical Configuration */
{
u32 y_out_size = mode->crop.height / mode->scan->vbin_ratio;
- u32 write_v_size = y_out_size + mode->scan->vertical_ob;

- s16 top = mode->crop.top;
+ /*
+ * The CLAMP region contains the Vertical Optical Black (VOB)
+ * lines, which are not included in the effective image height
+ * and 0 of the VWIDPOS corresponds to the first line after.
+ *
+ * This puts any request to view VOB as negative positions.
+ */
+ s16 top = mode->crop.top - 16;
u16 veff = mode->scan->veff;
u16 cut = veff - min(veff, y_out_size);

u32 v_widcut;
s32 v_pos;

+ /*
+ * Reduce the v_ob when the requested crop position is below
+ * zero to output the VOB on image data.
+ */
+ u8 v_ob = mode->scan->vertical_ob + min_t(s16, 0, top);
+ u32 write_v_size = y_out_size + v_ob;
+
+ /* Clamp our top position now that VOB is handled */
+ top = max_t(s16, 0, top);
+
if (imx283->vflip->val)
top = -top;

@@ -1168,7 +1184,7 @@ static int imx283_start_streaming(struct imx283 *imx283,
cci_write(imx283->cci, IMX283_REG_VWIDCUT, v_widcut, &ret);
cci_write(imx283->cci, IMX283_REG_VWINPOS, v_pos, &ret);

- cci_write(imx283->cci, IMX283_REG_OB_SIZE_V, mode->scan->vertical_ob, &ret);
+ cci_write(imx283->cci, IMX283_REG_OB_SIZE_V, v_ob, &ret);
}

/* Horizontal Configuration */

--
2.52.0