media: i2c: ov5645: Fix horizontal flip

Message ID (mailing list archive)
State New
Delegated to: Sakari Ailus
Series media: i2c: ov5645: Fix horizontal flip |

Commit Message

Martin Dørum July 26, 2021, 1:50 p.m. UTC
  The ov5645 driver currently handles horizontal flipping by setting the
"sensor mirror" bit (bit 1) in the TIMING_TC_REG21 register. This
just reverses the sensor data readout for each row, which works for the
brightness (Y) bytes, but it ends up reversing the color (U and V)

This fix adds the "ISP mirror" bit (bit 2) in the same register.
The datasheet I have isn't very detailed, but it seems like "ISP mirror"
makes the image sensor processor flip the color byte pairs (so UV -> VU),
so reversing data readout in combination with "ISP mirror" gives us a
horizontally flipped image with correct colors.

Signed-off-by: Martin Dørum <>
 drivers/media/i2c/ov5645.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index 368fa21e675e..c40bcb4b5484 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -52,7 +52,7 @@ 
 #define		OV5645_SENSOR_VFLIP		BIT(1)
 #define		OV5645_ISP_VFLIP		BIT(2)
 #define OV5645_TIMING_TC_REG21		0x3821
-#define		OV5645_SENSOR_MIRROR		BIT(1)
+#define		OV5645_SENSOR_MIRROR		(BIT(1) | BIT(2))
 #define OV5645_MIPI_CTRL00		0x4800
 #define OV5645_PRE_ISP_TEST_SETTING_1	0x503d
 #define		OV5645_TEST_PATTERN_MASK	0x3