Repository navigation
media: apple: ave: H.264 encoding on the M1 Pro and M2 - #1550
Merged
Merged
Conversation
…ycle A 6070 restart (M1 Pro, M2) now and then reaches RUN without the firmware posting its hello: on the M2 a stress run of short sessions hit it on the 14th restart, right after a gap that matched the 2 s autosuspend. The boot error path then marked the firmware broken, and runtime suspend refuses to power down a broken 6070 firmware, so every later session failed until reboot. Such a firmware has no rings, no session and no command in flight. Stop the core, and once CTRL reads back zero treat it like a confirmed Halt: return -EAGAIN so the session attach cycles the VENC power and boots it again from reset. If the core does not stop, keep the old behaviour. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The 6070 path refuses every rate-control mode but constant quality, yet the bitrate-mode control still defaulted to VBR. A client that keeps the defaults, such as GStreamer's v4l2h264enc without extra-controls or FFmpeg's h264_v4l2m2m, therefore got EOPNOTSUPP at stream start. On the 6070 register the menu with constant quality as its only and default entry. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Every session the firmware saw is quarantined with its buffers when it closes, and is meant to be freed once the coprocessor provably went through reset. Only the 9003 restart path ever reaped the quarantine, so on the 6070 (M1 Pro, M2) each session kept its DMA buffers until the module was removed. On an 8 GB M2 a run of short 1080p sessions used up the memory after about a hundred encodes and the machine stopped. Reap in the 6070 restart path: the firmware confirmed its Halt through scratch0, the core read back stopped, and runtime PM cycled the VENC power before the state left HALTED. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Enable the AVE encoder and its two DARTs on the M1 Pro (T6000) and the M2 (T8112). The bootloader hands over the firmware iBoot preloads, at the start of the encoder's DART window, and admits the preloaded code in the M1 Pro's CPU DART filter. With an older bootloader the driver finds the firmware outside its window and refuses to probe, so the encoder stays off. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide
marked this pull request as ready for review
November 11, 2026 13:48
This was referenced Nov 20, 2026
Closed
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.
Turns on hardware H.264 encoding for M1 Pro (T6000) and M2 (T8112) users. Both chips run the 6070 encoder firmware. The driver's encode path was already merged (#1440, #1484), but the encoder was still disabled in the device trees, and three driver problems showed up as soon as it ran outside lab boots.
HEVC stays refused on the 6070 for now. The parameter sets are fixed on a separate branch, but the slice headers still do not decode.
Tests
gst-launch-1.0 ... ! v4l2h264enc ! h264parse ! mp4muxwith no extra controls andffmpeg -c:v h264_v4l2m2mproduce 300/300 frames;hevc_v4l2m2mgets EOPNOTSUPP as intended.🤖 Generated with Claude Code