[PATCH v2 2/2] media: i2c: ov5693: fix horizontal flip polarity and Bayer phase

From: Jakob Berg Jespersen

Date: Wed Jul 29 2026 - 12:13:36 EST


The sensor's native readout is horizontally mirrored and the FORMAT2
FLIP_HORZ bits (reg 0x3821) un-mirror it; the init table sets them by
default (0x3821 = 0x1e). The driver sets those bits for V4L2_CID_HFLIP=1,
so the control is inverted: HFLIP=1 yields the un-mirrored image and
HFLIP=0 the mirrored one. Invert the polarity so HFLIP=0 yields the
unflipped image.

Clearing the bits also shifts the Bayer phase one column off the fixed
SBGGR10 mbus code the driver reports, giving wrong colors in the HFLIP=1
state. Compensate by offsetting the output window (reg 0x3810) one column
in that state; the crop has a spare column since crop end = crop start +
width (inclusive).

Found on the Surface Pro 7+ front camera (180 degree mount); geometry and
colors verified correct in both flip states.

Fixes: 89aef879cb53 ("media: i2c: Add support for ov5693 sensor")
Cc: stable@xxxxxxxxxxxxxxx
Tested-by: Fernando Rimoli <fernandorimoli11@xxxxxxxxx>
Reviewed-by: Hans de Goede <johannes.goede@xxxxxxxxxxxxxxxx>
Signed-off-by: Jakob Berg Jespersen <dev@xxxxxxx>
---
drivers/media/i2c/ov5693.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c
index 4cc796bbee92..4b016822d561 100644
--- a/drivers/media/i2c/ov5693.c
+++ b/drivers/media/i2c/ov5693.c
@@ -375,8 +375,18 @@ static int ov5693_flip_horz_configure(struct ov5693_device *ov5693,
OV5693_FORMAT2_FLIP_HORZ_SENSOR_EN;
int ret;

+ /* HFLIP is inverted on this sensor: the FLIP_HORZ bits un-mirror the readout. */
ret = cci_update_bits(ov5693->regmap, OV5693_FORMAT2_REG, bits,
- enable ? bits : 0, NULL);
+ enable ? 0 : bits, NULL);
+ if (ret)
+ return ret;
+
+ /*
+ * Clearing the bits shifts the Bayer phase one column off the
+ * reported SBGGR10; offset the output window to compensate.
+ */
+ ret = cci_write(ov5693->regmap, OV5693_OFFSET_START_X_REG,
+ enable ? 1 : 0, NULL);
if (ret)
return ret;


--
2.55.0