Repository navigation
drm/vc4: Use the HVS field bit for interlaced scanout position - #7763
Merged
Merged
Conversation
vc4_crtc_get_scanout_position() adds half a line to hpos on one of the
two fields of an interlaced mode, and picks that field from the parity
of the HVS frame counter. The frame counter is free running and is not
cleared when the channel is reset, so its parity has no fixed relation
to the field being output. Depending on the history of the channel the
correction lands on the wrong field, and the vblank timestamps then
alternate by two lines.
The HVS status register already read in this function reports the
active field: SCALER6_DISPX_STATUS_OFIELD on BCM2712, and bit 27 of
SCALER_DISPSTATX on earlier generations. Use it instead. The correction
applies when the bit is clear.
Measured as the median change between consecutive vblank timestamp
intervals over 200 fields, with 1080i60, 1080i50, 480i and 576i on
HDMI, and NTSC and PAL on Pi 4 composite:
- frame counter parity: 0 or 2 lines, depending on the modeset
(Pi 5 and Pi 4; Pi 3 happened to be right in every run)
- field bit, set: 2 lines on Pi 3, Pi 4 and Pi 5
- field bit, clear: 0-2 us on Pi 3, Pi 4 and Pi 5 in every run
Fixes: e538092 ("drm/vc4: Enable precise vblank timestamping for interlaced modes.")
Fixes: 7687a12 ("drm/vc4: hvs: Add support for BCM2712 HVS")
Link: raspberrypi#7757
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
Collaborator
Author
|
Reported working in #7757 |
pelwell
approved these changes
Nov 16, 2026
popcornmix
added a commit
to raspberrypi/firmware
that referenced
this pull request
Nov 17, 2026
kernel: spi: rp2040-gpio-bridge: Fix fast_xfer with strict RP1 pinmux See: raspberrypi/linux#7728 kernel: drm/vc4: hdmi: Reset the MAI FIFO when preparing audio See: raspberrypi/linux#7751 kernel: configs: Enable NET_SWITCHDEV and ADIN1110 support See: raspberrypi/linux#7687 kernel: drm/vc4: Use the HVS field bit for interlaced scanout position See: raspberrypi/linux#7763 kernel: xhci: drop the VL805 XHCI_EP_CTX_BROKEN_DCS cycle-state quirk See: raspberrypi/linux#7754
popcornmix
added a commit
to raspberrypi/rpi-firmware
that referenced
this pull request
Nov 17, 2026
kernel: spi: rp2040-gpio-bridge: Fix fast_xfer with strict RP1 pinmux See: raspberrypi/linux#7728 kernel: drm/vc4: hdmi: Reset the MAI FIFO when preparing audio See: raspberrypi/linux#7751 kernel: configs: Enable NET_SWITCHDEV and ADIN1110 support See: raspberrypi/linux#7687 kernel: drm/vc4: Use the HVS field bit for interlaced scanout position See: raspberrypi/linux#7763 kernel: xhci: drop the VL805 XHCI_EP_CTX_BROKEN_DCS cycle-state quirk See: raspberrypi/linux#7754
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7757.
vc4_crtc_get_scanout_position()chose the field for the half-line correction from the parity of the HVS frame counter, which is free running and not cleared on channel reset. The HVS status register it already reads has a field bit (SCALER6_DISPX_STATUS_OFIELDon BCM2712, bit 27 ofSCALER_DISPSTATXon earlier HVS). Use that instead, on all generations.Tested on Pi 5 (Pi 500+), Pi 4 and Pi 3B+, measuring the median change between consecutive vblank timestamp intervals: