Linux Media Controller development
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Hao Yao <hao.yao@intel.com>, Hans de Goede <hansg@kernel.org>,
	Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Hans Verkuil <hverkuil+cisco@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	jason.z.chen@intel.com, linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 6.17-6.6] media: ov08x40: Fix the horizontal flip control
Date: Sat, 25 Oct 2025 11:54:59 -0400	[thread overview]
Message-ID: <20251025160905.3857885-68-sashal@kernel.org> (raw)
In-Reply-To: <20251025160905.3857885-1-sashal@kernel.org>

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)
-- 
2.51.0


  parent reply	other threads:[~2025-10-25 16:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20251025160905.3857885-1-sashal@kernel.org>
2025-10-25 15:53 ` [PATCH AUTOSEL 6.17] media: nxp: imx8-isi: Fix streaming cleanup on release Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17] drm/xe: improve dma-resv handling for backup object Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-5.15] media: adv7180: Only validate format in querystd Sasha Levin
2025-10-25 15:54 ` Sasha Levin [this message]
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-5.15] media: em28xx: add special case for legacy gpiolib interface Sasha Levin
2025-10-27  9:24   ` Arnd Bergmann
2025-11-04 13:55     ` Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17-5.15] media: adv7180: Do not write format to device in set_fmt Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17] media: imx-mipi-csis: Only set clock rate when specified in DT Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17] media: qcom: camss: csiphy-3ph: Add CSIPHY 2ph DPHY v2.0.1 init sequence Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.4] media: redrat3: use int type to store negative error codes Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-5.4] media: pci: ivtv: Don't create fake v4l2_fh Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-5.4] media: imon: make send_packet() more robust Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-5.15] media: adv7180: Add missing lock in suspend callback Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.1] media: verisilicon: Explicitly disable selection api ioctls for decoders Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.12] media: pci: mgb4: Fix timings comparison in VIDIOC_S_DV_TIMINGS Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.12] media: ipu6: isys: Set embedded data type correctly for metadata formats Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.1] media: i2c: og01a1b: Specify monochrome media bus format instead of Bayer Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-6.1] media: amphion: Delete v4l2_fh synchronously in .release() Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251025160905.3857885-68-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=hansg@kernel.org \
    --cc=hao.yao@intel.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=jason.z.chen@intel.com \
    --cc=linux-media@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=sakari.ailus@linux.intel.com \
    --cc=stable@vger.kernel.org \
    --cc=stanislaw.gruszka@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox