Skip to contentSkip to conversation

media: ov08x40: Fix the horizontal flip control

PATCH In review Hao Yao 3 participants 3 messages Apr 25, 2025 – Aug 29, 2025

Subsystems (3)
lore
Share & tools
lore

Hao Yao

author
#0 lore raw

PATCH 1/1 media: ov08x40: Fix the horizontal flip control

The datasheet of ov08x40 doesn't match the hardware behavior. 0x3821[2] == 1 is the original state and 0 the horizontal flip enabled.

---
 drivers/media/i2c/ov08x40.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov08x40.c +1 -1
index cf0e41fc3071..17112c02408a 100644
@@ -1627,7 +1627,7 @@ static int ov08x40_set_ctrl_hflip(struct ov08x40 *ov08x, u32 ctrl_val)
 
 	return ov08x40_write_reg(ov08x, OV08X40_REG_MIRROR,
 				 OV08X40_REG_VALUE_08BIT,
-				 ctrl_val ? val | BIT(2) : val & ~BIT(2));
+				 ctrl_val ? val & ~BIT(2) : val | BIT(2));
 }
 
 static int ov08x40_set_ctrl_vflip(struct ov08x40 *ov08x, u32 ctrl_val)
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Hao Yao

The datasheet of ov08x40 doesn't match the hardware behavior. 0x3821[2] == 1 is the original state and 0 the horizontal flip enabled.

Regards
Stanislaw

Quoted 21 lines
---
 drivers/media/i2c/ov08x40.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov08x40.c +1 -1
index cf0e41fc3071..17112c02408a 100644
@@ -1627,7 +1627,7 @@ static int ov08x40_set_ctrl_hflip(struct ov08x40 *ov08x, u32 ctrl_val)
 
 	return ov08x40_write_reg(ov08x, OV08X40_REG_MIRROR,
 				 OV08X40_REG_VALUE_08BIT,
-				 ctrl_val ? val | BIT(2) : val & ~BIT(2));
+				 ctrl_val ? val & ~BIT(2) : val | BIT(2));
 }
 
 static int ov08x40_set_ctrl_vflip(struct ov08x40 *ov08x, u32 ctrl_val)
Signature · 1 line
2.43.0
Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Hao Yao

Hi,

Quoted 4 lines · Hao Yao

The datasheet of ov08x40 doesn't match the hardware behavior. 0x3821[2] == 1 is the original state and 0 the horizontal flip enabled.

Thanks, patch looks good to me and I've successfully tested this on a ThinkPad X1 Carbon Gen 12 & Gen 13 where the image indeed used to be mirrored.

Regards,

Hans

Quoted 17 lines
---
 drivers/media/i2c/ov08x40.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov08x40.c +1 -1
index cf0e41fc3071..17112c02408a 100644
@@ -1627,7 +1627,7 @@ static int ov08x40_set_ctrl_hflip(struct ov08x40 *ov08x, u32 ctrl_val)
 
 	return ov08x40_write_reg(ov08x, OV08X40_REG_MIRROR,
 				 OV08X40_REG_VALUE_08BIT,
-				 ctrl_val ? val | BIT(2) : val & ~BIT(2));
+				 ctrl_val ? val & ~BIT(2) : val | BIT(2));
 }
 
 static int ov08x40_set_ctrl_vflip(struct ov08x40 *ov08x, u32 ctrl_val)