From: Hao Yao hao.yao@intel.com
[ Upstream commit c7df6f339af94689fdc433887f9fbb480bf8a4ed ]
The datasheet of ov08x40 doesn't match the hardware behavior. 0x3821[2] == 1 is the original state and 0 the horizontal flip enabled.
Signed-off-by: Hao Yao hao.yao@intel.com Reviewed-by: Hans de Goede hansg@kernel.org Tested-by: Hans de Goede hansg@kernel.org # ThinkPad X1 Carbon Gen 12 & Gen 13 Reviewed-by: Stanislaw Gruszka stanislaw.gruszka@linux.intel.com Signed-off-by: Sakari Ailus sakari.ailus@linux.intel.com Signed-off-by: Hans Verkuil hverkuil+cisco@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES
- What it fixes: The horizontal flip (HFLIP) control polarity was wrong for the OV08X40 sensor. Hardware enables H-mirror when bit 2 of register 0x3821 is cleared, but the driver treated setting the bit as “flip on”. The fix inverts this polarity so V4L2_CID_HFLIP now matches actual hardware behavior. - Precise change: In `ov08x40_set_ctrl_hflip()`, the write toggling `OV08X40_REG_MIRROR` bit 2 is flipped: - Before: `ctrl_val ? val | BIT(2) : val & ~BIT(2)` - After: `ctrl_val ? val & ~BIT(2) : val | BIT(2)` - Location: drivers/media/i2c/ov08x40.c:1651 - Scope and containment: - Only one line in a single driver file is changed: `drivers/media/i2c/ov08x40.c`. - The function reads the current register value first and only changes bit 2, preserving other bits (drivers/media/i2c/ov08x40.c:1646, 1651). - Vertical flip handling remains unchanged and continues to set bit 2 of 0x3820 when enabled (drivers/media/i2c/ov08x40.c:1666), showing the change is isolated to HFLIP. - The HFLIP control is wired through the standard control path (`ov08x40_set_ctrl()` case V4L2_CID_HFLIP → `ov08x40_set_ctrl_hflip()`, drivers/media/i2c/ov08x40.c:1735) and HFLIP is created as a standard V4L2 control (drivers/media/i2c/ov08x40.c:2153). - User impact: Without this fix, user-space sees inverted behavior for HFLIP (enabling the control does not produce the expected mirror), which is a clear functional bug affecting image orientation and any applications relying on correct orientation metadata/control. - Risk assessment: - Minimal risk: a single-bit polarity correction in a register write, no ABI/API change, no architectural changes, and constrained to the ov08x40 driver. - Safe behavior: other bits are preserved; change is applied only when the device is powered/streaming via existing PM checks. - Real-world validation: Reviewed and Tested-by are present, including testing on ThinkPad X1 Carbon Gen 12/13, which reduces regression risk.
This is a small, targeted, and user-visible bugfix that aligns with stable backporting rules and should be backported.
drivers/media/i2c/ov08x40.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c index e0094305ca2ab..90887fc54fb0e 100644 --- a/drivers/media/i2c/ov08x40.c +++ b/drivers/media/i2c/ov08x40.c @@ -1648,7 +1648,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)