From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: "Martin Tůma" <martin.tuma@digiteqautomotive.com>,
"Hans Verkuil" <hverkuil+cisco@kernel.org>,
"Sasha Levin" <sashal@kernel.org>,
linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 6.17-6.12] media: pci: mgb4: Fix timings comparison in VIDIOC_S_DV_TIMINGS
Date: Sat, 25 Oct 2025 11:59:21 -0400 [thread overview]
Message-ID: <20251025160905.3857885-330-sashal@kernel.org> (raw)
In-Reply-To: <20251025160905.3857885-1-sashal@kernel.org>
From: Martin Tůma <martin.tuma@digiteqautomotive.com>
[ Upstream commit 0750649b528ff18d1d68aecb45b34ec22d5ab778 ]
Compare the whole v4l2_bt_timings struct, not just the width/height when
setting new timings. Timings with the same resolution and different
pixelclock can now be properly set.
Signed-off-by: Martin Tůma <martin.tuma@digiteqautomotive.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: Prevents a real functional bug where setting DV timings
with the same width/height but different pixelclock (or other BT
fields) was treated as “no change” and ignored. This blocked valid
timing changes (e.g., framerate changes at the same resolution).
- Code change: Replaces a narrow equality check on resolution with a
full DV timings comparison:
- New check: `v4l2_match_dv_timings(timings, &vindev->timings, 0,
false)` in `drivers/media/pci/mgb4/mgb4_vin.c:613`.
- Old behavior (implicit from the diff): only compared `width` and
`height`, causing false “match” for differing
pixelclock/porches/polarities/etc.
- Correct behavior when busy: With the fix, if the queue is streaming
and the requested timings differ in any BT field,
`vidioc_s_dv_timings` returns `-EBUSY` instead of silently returning 0
while not applying the change (see `vb2_is_busy` branch right after
the match check in `drivers/media/pci/mgb4/mgb4_vin.c:615`).
- Scope and risk: Minimal and contained (one-line logic change in a
single driver). No API/ABI change, no architectural impact, only
affects `VIDIOC_S_DV_TIMINGS` behavior in the MGB4 capture driver.
- Uses a proven helper: `v4l2_match_dv_timings` is the standard V4L2
helper that compares the full `v4l2_bt_timings` including
width/height, interlaced, polarities, pixelclock (with tolerance),
porches, vsync, flags, and interlaced-specific fields; see
implementation at `drivers/media/v4l2-core/v4l2-dv-timings.c:267`.
This pattern is used across other drivers.
- User impact: Enables setting legitimate timings that share resolution
but differ in pixelclock (and other BT parameters). Previously such
requests were incorrectly treated as no-ops.
- Stable criteria fit:
- Important bugfix affecting real use (DV timings changes ignored).
- Small, localized change with low regression risk.
- No new features or interface changes.
- Touches only a non-core driver
(`drivers/media/pci/mgb4/mgb4_vin.c`).
- Backport note: Apply to stable kernels that include the MGB4 driver;
the helper `v4l2_match_dv_timings` is long-standing in V4L2 and does
not introduce dependencies.
Overall, this is a low-risk, clear bug fix that improves correctness and
user experience when changing DV timings; it should be backported.
drivers/media/pci/mgb4/mgb4_vin.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/media/pci/mgb4/mgb4_vin.c b/drivers/media/pci/mgb4/mgb4_vin.c
index 989e93f67f75b..42c327bc50e10 100644
--- a/drivers/media/pci/mgb4/mgb4_vin.c
+++ b/drivers/media/pci/mgb4/mgb4_vin.c
@@ -610,8 +610,7 @@ static int vidioc_s_dv_timings(struct file *file, void *fh,
timings->bt.height < video_timings_cap.bt.min_height ||
timings->bt.height > video_timings_cap.bt.max_height)
return -EINVAL;
- if (timings->bt.width == vindev->timings.bt.width &&
- timings->bt.height == vindev->timings.bt.height)
+ if (v4l2_match_dv_timings(timings, &vindev->timings, 0, false))
return 0;
if (vb2_is_busy(&vindev->queue))
return -EBUSY;
--
2.51.0
next prev parent reply other threads:[~2025-10-25 16:24 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 ` [PATCH AUTOSEL 6.17-6.6] media: ov08x40: Fix the horizontal flip control Sasha Levin
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 ` Sasha Levin [this message]
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-330-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=hverkuil+cisco@kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=martin.tuma@digiteqautomotive.com \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
/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