Repository navigation
media: apple: avd: T6040 (M4 Pro) decoder (H.264, VP9, AV1), AV1 segmentation map, v5 HEVC header - #373
Merged
RyanTheTide merged 5 commits intoOct 23, 2026
Conversation
The AV1 instruction stream has a slot next to the segmentation map that was set to the poison address 0xb0b0b0b0b0b0. The AVD reads the previous segment ids from it whenever segmentation is enabled, so on the T6040 every such frame raised thousands of DART translation faults. The single per-context map was also reallocated, and so zeroed, every frame that updated it. Keep the map with each frame, below its CDFs in the capture buffer, as the spec saves it (7.20). The AVD writes the frame's map there, and reads the previous one from the primary reference frame if that frame has the same MiCols and MiRows, as libdav1d checks, or from a zeroed buffer otherwise (load_previous_segment_ids()). It writes the map only when update_map is set, so for other frames fill in the one the spec saves: zeroes without segmentation, else the previous map. The map, the CDFs and the color data are placed from the end of the capture buffer by the frame's size, so refuse a frame larger than the capture format, and fail the job if a buffer whose CDFs or map the CPU copies has no kernel mapping. Tested on T6040 against libdav1d: rav1e (segmentation, update_map) and libaom (aq-mode 1: update_map 0 and temporal update; aq-mode 3) clips, 8 and 10 bit, plus YouTube 1080p and 2160p, all bit-exact with no DART faults. The frame size and mapping checks came after these tests. Signed-off-by: Jonathan Goyvaerts <[email protected]> Assisted-by: LLM
The AV1 decoder in this tree is aurora's, which matched software decoding on the T8140 (same AVD generation). Offer AV1 on the T6040 too; HEVC stays off because a stream with wavefront parallel processing stalled the VP. Signed-off-by: Jonathan Goyvaerts <[email protected]> Assisted-by: LLM
The only HEVC run on T6040 (a 1080p x265 Main clip) timed out on its first job, an I-frame, with the VP reporting neither completion nor error. That kernel sent the pre-v5 HEVC header. T8140 needed the v5 layout for HEVC (the DMA configuration words and the reserved scratch slot between scratch 4 and 8, as in Apple's v5 program reproduced in avd-fw's Tansy transport), and T6040 runs the same v5 firmware generation (avd-fw-v5-t1, hardware revision 4) with the same VP layout. A VP reading every later header word from the wrong slot hangs exactly like this; the WPP flag on the other hand already reaches the hardware (PPS flags bit 12), and whole-slice WPP streams decode on the older AVDs. AVD_QUIRK_HEVC_V5_HEADER also selected T8140's submission pacing (pace only HEVC, 100-150 us back-off). Split that into AVD_QUIRK_V5_QUEUE_PACING so T6040 gets only the header change and its H.264, VP9 and AV1 submissions are unchanged. T8140 keeps both. HEVC stays out of T6040's capabilities: this only changes what an HEVC job would send once the decoder offers HEVC after a test on the hardware. Signed-off-by: Jonathan Goyvaerts <[email protected]> Assisted-by: LLM
The T6040 (M4 Pro) video decoder is the T8132 (M4) one: its MCU firmware programs the same register family, so it falls back to apple,t8132-avd. The driver already matches apple,t8132-avd; document it as well. Signed-off-by: Jonathan Goyvaerts <[email protected]> Assisted-by: LLM
The T6040 (M4 Pro) decoder is the T8132 one, but only H.264 and VP9 have been seen to decode correctly there. An HEVC stream with wavefront parallel processing stalled the VP on its first job, and AV1 has not been tried. The decoder binds at boot, so any V4L2 client (GStreamer v4l2codecs, VA-API) could submit those formats. Bind apple,t6041-avd to its own variant with the T8132 layout and only H.264 and VP9 in its capabilities. The other variants are unchanged. Signed-off-by: Jonathan Goyvaerts <[email protected]> Assisted-by: LLM
This was referenced Nov 19, 2026
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.
apple,t6041-avdwith theapple,t8132-avdfallback, and document the existingapple,t8132-avd.had there. The AVD read that address whenever segmentation was on, which caused thousands of DART faults per frame on T6040.
stays hidden from V4L2 clients until it is verified.
Builds on Chris Kearney's "align AV1 tails in imported capture planes", already in integration/aurora (6d8f574).
Naming: the SoC blocks use
apple,t6041-*, after the T6041 (M4 Max) die the M4 Pro is cut from. Apple's device tree on an M4 Pro names the SoCarm-io,t6041, and Yureka Lilian's acked t604x bindings already use t6041 for the blocks.apple,t6040stays the machine compatible.Hardware tested on: Apple MacBook Pro (16-inch, M4 Pro, 2024), J616s / T6040, macOS 26.x firmware, booted by our own loader with our private T6040 device tree.
How tested: On the J616s, H.264 and VP9 run daily (mpv, Firefox via v4l2 request). AV1 is bit-exact against libdav1d for rav1e
(segmentation, update_map) and libaom (aq-mode 1 and 3) clips, 8 and 10 bit, plus YouTube 1080p/2160p, with no DART
faults. AV1 is now in daily use (mpv).
Not tested / limits: HEVC on T6040 (only the header changes, and HEVC is not offered). The frame-size and mapping checks of the AV1 commit came
after the clip tests.
Base:
integration/aurora(44d5afc). Built and checked there (aurora's defconfig, W=1 on every touched object, checkpatch --strict, dt_binding_check with dtschema 2026.9). Hardware testing was done on our daily tree, which is based on aurora-wip (Linux 7.1.12) and runs this code. Merges cleanly with #366 and #367.🤖 Generated with Claude Code
https://claude.ai/code/session_01K4TC3f2CpzFxhnEziL9wcg