[PATCH v2 1/2] media: i2c: ov8865: fix horizontal flip control polarity

From: Jakob Berg Jespersen

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


The sensor's native readout is horizontally mirrored and the FORMAT2
FLIP_HORZ bits (reg 0x3821) un-mirror it. 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, the opposite of what is
requested.

Invert the polarity so HFLIP=0 yields the unflipped image.

Found on the Surface Pro 7+ rear camera (180 degree mount), where
libcamera's HFLIP=1+VFLIP=1 correction otherwise produces a mirrored
image.

Fixes: 11c0d8fdccc5 ("media: i2c: Add support for the OV8865 image sensor")
Cc: stable@xxxxxxxxxxxxxxx
Reviewed-by: Hans de Goede <johannes.goede@xxxxxxxxxxxxxxxx>
Signed-off-by: Jakob Berg Jespersen <dev@xxxxxxx>
---
drivers/media/i2c/ov8865.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c
index c6d53c3d55ca..ccda33839246 100644
--- a/drivers/media/i2c/ov8865.c
+++ b/drivers/media/i2c/ov8865.c
@@ -2204,8 +2204,9 @@ static int ov8865_flip_horz_configure(struct ov8865_sensor *sensor, bool enable)
u8 bits = OV8865_FORMAT2_FLIP_HORZ_ISP_EN |
OV8865_FORMAT2_FLIP_HORZ_SENSOR_EN;

+ /* HFLIP is inverted on this sensor: the FLIP_HORZ bits un-mirror the readout. */
return ov8865_update_bits(sensor, OV8865_FORMAT2_REG, bits,
- enable ? bits : 0);
+ enable ? 0 : bits);
}

/* Test Pattern */

--
2.55.0