Skip to content

media: apple: ave: add T8132 (M4) support, with device tree - #1489

Open
EdupugantiAkhil wants to merge 7 commits into
aurora-silicon:mainfrom
EdupugantiAkhil:j713-ave-enable
Open

EdupugantiAkhil wants to merge 7 commits into
aurora-silicon:mainfrom
EdupugantiAkhil:j713-ave-enable

Conversation

@EdupugantiAkhil

@EdupugantiAkhil EdupugantiAkhil commented Nov 10, 2026 •

Copy link
Copy Markdown

This adds hardware video encoding (AVE) on the M4 (T8132). The series:

  1. dt-bindings: media: apple,t8140-ave: describe T8132 like T6041: T8132 was only allowed in the whole-block apple,ave placeholder form, which the driver can't bind. It now uses the T6041/T8140 form: named codec/mailbox/coproc windows, five named power domains, firmware memory regions. The T8132 branch of the placeholder form goes; most of the diff is re-indentation.
  2. media: apple: ave: add T8132 (M4) support: adds the T8132 variant (device 26, type 24), its 9003.78.0 TEXT CRC, the per-boot TEXT word at 0x4224 (as on T6041; found on the J773g), and the CRC mapped to the 9003.78.0 command layout. The commit message gives what the J713 shows: the preloaded firmware's segment sizes and TEXT CRC, the default target in its capability table (device 26, type 24), what the coprocessor start did, and the encode results.
  3. arm64: dts: apple: t8132: describe the video encoder windows: describes the node like the T6041 one, and gives the DARTs venc_sys and the DMA range.
  4. Enables the encoder per board group, one commit each:
    • MacBook Air 13"/15" (J713/J715, including the six VENC power domains disabled in t8132-j713-pmgr.dtsi);
    • Mac mini (J773g), MacBook Pro 14" (J604) and iMac (J623/J624), each stating its six VENC power domains as okay rather than relying on the PMGR policy (on the J773g they came up disabled without it).

Tested on J713 (by me) and J773g (by @DjDeveloperr, with the two changes above). J604 and J623/J624 are untested; drop those commits if you'd rather wait for a tester.

Depends on the aura T8132 AVE firmware handoff (aurora-silicon/aura draft PR, linked below). Without it, aura has no T8132 entry in its AVE handoff list, the node gets no firmware memory regions, and the encoder can't run.

Testing (MacBook Air M4, J713, OS firmware 26.6.2):

  • Driver: this branch's drivers/media/platform/apple/ave/ (integration/aurora 0abc2f3 plus commit 2), built out of tree against the running 7.3.0 kernel after a fresh boot. The out-of-tree build needed two local shims that are not part of this PR: the shared apple-video-nr.h, and a define for V4L2_PIX_FMT_APPLE_L8V0, which the running kernel's uapi headers predate (only the MCTF node uses it). The encoder registered as /dev/video10.

  • Device tree: applied at runtime as an overlay with the same properties. The J713 tree compiled from this branch matches it, apart from the pmgr/fabric windows, which the driver doesn't use on this generation.

  • FFmpeg VA-API, PSNR against the source, all frames decodable:

    Stream PSNR
    H.264 720p CBR 44.73 dB
    H.264 1080p CBR 45.31 dB
    H.264 720p VBR 42.29 dB
    H.264 720p Constrained Baseline 41.45 dB
    H.264 2160p 41.84 dB
    HEVC 720p 43.55 dB
    HEVC 1080p 43.84 dB
    HEVC Main 10 1080p 46.70 dB

    The values, and the Chrome bitstream, are identical to the earlier revisions of this PR.

  • Chrome 156 WebCodecs H.264 hardware encode (VaapiVideoEncodeAccelerator): 60/60 frames, 44.73 dB.

  • Hardware decode, H.264/HEVC/VP9/AV1, unchanged: byte-exact.

  • All six T8132 DTBs compile with no AVE-related DTC warnings (J713's DTC warnings are the same 12 as unmodified integration/aurora).

  • dt-schema (2026.09) locally: dt-doc-validate passes on the binding, and all six T8132 DTBs validate against it with no errors (checked that a deliberately broken copy does fail).

Not done:

  • I haven't booted with the real DTB.

Userspace (VA-API driver) placeholder: https://github.com/EdupugantiAkhil/aurora-ave-vaapi. Refs #1386.

AI disclosure: developed with AI assistance (Claude). Reviewed and hardware-tested by me. The commits carry Assisted-by: LLM.

🤖 Generated with Claude Code

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the T8132 encoder work, and for the PSNR numbers across H.264, HEVC and Main 10.

Before this can go in, please rewrite three pieces of text: the commit message of "media: apple: ave: add T8132 (M4) support", the comment above ave_t8132 in ave-drv.c, and the new comment in ave_layout_for_crc(). They explain the variant values by what a macOS driver build does. They should only say what the J713 hardware shows: the firmware segment sizes and TEXT CRC, the ADT values the variant uses (device id, type), what you saw the coprocessor start do, and the encode results. Please drop the macOS driver names and versions, the internal identifiers and the routine comparisons. The firmware build labels next to the CRCs can stay, as elsewhere in ave-fw.c.

The branch also conflicts with integration/aurora now, so a rebase in the same push would help. I'll run the encode regression on our M1 Pro, M2 and Neo once the rewrite is up.

@RyanTheTide

Copy link
Copy Markdown

One more spot with the same issue: item 2 of the PR description names the macOS driver version. Please drop it there too when you reword the commit message.

@EdupugantiAkhil

Copy link
Copy Markdown
Author

Thanks for the review. Pushed:

  • Rebased onto integration/aurora 8679514. The conflicts were the per-board files (arm64: dts: apple: t8132: describe the video decoder and enable it on M4 boards #1488's decoder nodes, now kept next to the encoder ones) and the binding: T6050 has moved out of the placeholder form, which left T8132 as its only compatible, so that branch is now dropped and the remaining conditions move up one level (mostly re-indentation).
  • Rewrote the commit message of "media: apple: ave: add T8132 (M4) support", the comment above ave_t8132 and the comment in ave_layout_for_crc(). They now state only what the J713 shows: TEXT 0x148000 / DATA 0x12c000 from the ADT segment-ranges, TEXT CRC 9308d2ab, the firmware capability table's default target (device 26, type 24), what the coprocessor start did, and the encode results. No macOS driver names, versions, identifiers or routine comparisons remain; the build label next to the CRC in ave-fw.c stays. Also dropped the macOS version from item 2 of the PR description.
  • One correction to how I described it before: device 26 / type 24 are not ADT properties. They come from the capability table in the preloaded firmware TEXT, and the commit message now says so.

Retested on J713 (the rebased driver, after a fresh boot; the node is now /dev/video10): FFmpeg H.264 720p/1080p/2160p, CBR/VBR, Constrained Baseline, HEVC 720p/1080p and Main 10, and Chrome WebCodecs H.264. Every PSNR is identical to the previous revision. Hardware decode (H.264/HEVC/VP9/AV1, 6 clips) is still byte-exact. dt-schema now runs locally too: the binding passes dt-doc-validate and all six T8132 DTBs validate against it.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rewritten comments and commit message describe only what the J713 shows, and the driver changes are new table entries. The AVE driver also runs on the A18 Pro, M1 Pro and M2, so we will run an encode check on those once aura#152 is in, then merge. Thanks for the PSNR table.

@EdupugantiAkhil

Copy link
Copy Markdown
Author

Rebased onto integration/aurora bf00add to clear the conflict. The only conflict was t8132-j604.dts (the new external-display block); the encoder lines now sit next to the decoder ones there. The driver and binding changes are byte-identical to the tested revision (upstream hasn't touched either since 8679514). All six T8132 DTBs build with the same DTC warnings as unmodified integration/aurora and validate against the binding with dt-schema; the J713 encoder and DART nodes compile byte-identical to before.

@RyanTheTide

Copy link
Copy Markdown

@EdupugantiAkhil #1677 went in first, so this now conflicts in ave-layout.c. Both PRs add their 25G83 text CRC to the same 9003_78_0 check, and the fix is to keep both: AVE_FW_TEXT_CRC_T6040_25G83 || AVE_FW_TEXT_CRC_T6041_25G83 || AVE_FW_TEXT_CRC_T8132_25G83. Could you rebase onto integration/aurora?

Results so far, with that resolution in a test kernel (integration e661192 plus this PR and the others in this round):

  • M1 Pro (T6000): apple-ave binds and H.264 1080p 300/300 is byte-identical to the production kernel (PSNR Y 38.19 dB), before and after 3 s2idle cycles.
  • M4 Pro (J616s): H.264 and HEVC 1080p are byte-identical to production.
  • 0 AVE errors, 0 AVC, 0 DART faults.

The M2 and A18 Pro encode runs are still queued.

@RyanTheTide

Copy link
Copy Markdown

M2 results with this PR's driver code (applied over #1677 with both 25G83 CRCs kept), one-shot test kernel: the M2 encoder binds as before, H.264 1080p is byte-identical to the production kernel (300/300 frames, 23777084 bytes) and HEVC bytes are identical too, before and after 3 s2idle cycles. The conflict in ave-layout.c still needs the rebase described above before this can merge.

@EdupugantiAkhil

Copy link
Copy Markdown
Author

Rebased onto integration/aurora, keeping both 25G83 CRCs (T6041 and T8132). Retested on J713: encode and decode results unchanged.

@DjDeveloperr

Copy link
Copy Markdown

Tested on a J773g (Mac mini M4, 26.6.2 stub, aura with #152): the encoder works, after two changes to this series.

  1. The J773g needs its VENC power domains stated. The board DT uses the shared t8132-pmgr.dtsi, but the T8132 PMGR policy (t8132-platform-handoff.c) gives every domain that the board tree leaves without a status the policy's own status. For the VENC domains that status is disabled (from the J713 pmgr data), so venc_sys ended up disabled at runtime and both encoder DARTs deferred until timeout (-110, then apple-ave: needs a translating IOMMU). In t8132-j773g.dts:
    &ps_venc_sys { status = "okay"; };
    &ps_venc_dma { status = "okay"; };
    &ps_venc_pipe4 { status = "okay"; };
    &ps_venc_pipe5 { status = "okay"; };
    &ps_venc_me0 { status = "okay"; };
    &ps_venc_me1 { status = "okay"; };
    
    The J773g commit message says they are already enabled; on this tree they are not.
  2. The T8132 preload has a per-boot TEXT word at +0x4224, as on T6041. Its TEXT CRC changed on every boot (234aa48e, 8e730d92, ad3a8f99), so the probe failed with unsupported firmware. Two boots' TEXT differed only in the word at 0x4224 (0x005a8000 vs 0x00b08000). With that word zeroed, the CRC is 0x9308d2ab, the J713's: the same 9003.78.0 build (the version string in TEXT says so too). In ave_t8132:
    	.text_boot_word = 0x4224,
    With it, the J713 likely just happened to have a matching word on the boot you measured.

With both changes, on the J773g (1920x1080 testsrc2, yuv420p, 120 frames, -b:v 8M -g 30):

  • h264_v4l2m2m: 120 frames in 1.40 s, Main, PSNR 45.25 dB (min 42.54);
  • hevc_v4l2m2m: 120 frames in 1.43 s, Main, PSNR 46.27 dB (min 44.37);
  • all frames decodable; no DART faults.

The encoder's video14 apple-ave sits next to AVD/JPEG/scaler. Rebased onto the M4 mini GPU stack, your driver commit conflicted only in the T8142 neighbours (ave-drv.c, ave-fw.c, ave.h). Would you fold these two changes in, or shall I open a PR on top of yours?

@EdupugantiAkhil

Copy link
Copy Markdown
Author

Thanks for testing on the J773g! I'll fold both changes into the series, rebase onto integration/aurora and retest on the J713. It should be up in under an hour.

The T8132 (M4) encoder was only allowed in the whole-block "apple,ave"
placeholder form, which the apple-ave driver cannot bind. It is the same
encoder generation as the T6041 (M4 Pro) and T8140 (A18 Pro): describe it
the same way, with the codec, mailbox and coprocessor windows by name, the
five named power domains and the firmware memory regions.

Drop the T8132 branch of the placeholder form, and list T8132 with the
T6041 and T8140 in the named form. The remaining conditions move up one
level, which is most of the diff (re-indentation only).

Assisted-by: LLM
Signed-off-by: Akhil <akhile76@gmail.com>
On the MacBook Air M4 (J713, OS firmware 26.6.2), iBoot preloads the
encoder firmware with TEXT 0x148000 and DATA 0x12c000 (ADT ave
segment-ranges), TEXT CRC 9308d2ab (AppleAVE2FW 9003.78.0). The
capability table in that TEXT has device 26, type 24 as its default
target.

Started with the T6041 (M4 Pro) coprocessor registers and start
sequence, from the code base the bootloader left (checked, not
written), the firmware boots as device 26, accepts the handshake for
type 24 and runs H.264 and HEVC sessions with the 9003.78.0 command
layout.

On the Mac mini M4 (J773g) the same build's TEXT CRC changes on every
boot: two boots' TEXT differ only in the word at 0x4224, and with that
word zeroed the CRC is 9308d2ab, as on the T6041 (M4 Max) preload. The
J713 has read 9308d2ab on every boot tested so far, but give the variant
the same per-boot word so either form is accepted.

Add the variant, its TEXT CRC, and map that CRC to the 9003.78.0
layout.

Tested on J713 with this driver (integration/aurora 0abc2f3 plus
this commit) built against the running 7.3.0 kernel, the encoder
described as in the following DT commits, and the firmware handed over
by aura with the T8132 handoff:
- FFmpeg VA-API H.264 720p/1080p/2160p, CBR/VBR and Constrained
  Baseline: 41.5-45.3 dB PSNR against the source, all frames decodable;
- HEVC Main 720p/1080p (43.5/43.8 dB) and Main 10 1080p (46.7 dB);
- Chrome 156 WebCodecs H.264 hardware encode: 44.7 dB.

Assisted-by: LLM
Signed-off-by: Akhil <akhile76@gmail.com>
Describe the T8132 encoder like the T6041 (M4 Pro) one, as the binding
now asks:
- bind through "apple,t8132-ave";
- give the codec, mailbox and coprocessor windows by name, and drop the
  pmgr and fabric windows, which the driver does not use on this
  generation;
- list the five encoder power domains by name, dropping venc_sys, which
  is the DARTs' domain and the parent of venc_dma;
- give both encoder DARTs venc_sys and the encoder's DMA range.

The nodes stay disabled. The bootloader adds the firmware memory regions.

Tested on a MacBook Air M4 (J713) by applying the same properties at
runtime as an overlay: FFmpeg VA-API H.264 and HEVC (Main, Main 10) and
Chrome WebCodecs H.264 encode, 43.5-45.5 dB PSNR against the source.

Assisted-by: LLM
Signed-off-by: Akhil <akhile76@gmail.com>
Enable the AVE encoder, its two DARTs and the six VENC power domains on
the MacBook Air M4, 13-inch (J713) and 15-inch (J715).
t8132-j713-pmgr.dtsi, shared by the two, had disabled the domains.

The encoder needs the bootloader's firmware handoff for T8132 (aura:
"apple,t8132-ave" in the AVE compatible list). Without it, the bootloader
leaves the node disabled.

Tested on J713 with the equivalent runtime overlay (see the previous
commit). J715 is untested.

Assisted-by: LLM
Signed-off-by: Akhil <akhile76@gmail.com>
Enable the AVE encoder, its two DARTs and its six VENC power domains on
the Mac mini (M4, J773g).

State the VENC domains in the board tree rather than relying on the
T8132 PMGR policy, which gives a domain the board leaves without a status
the policy's own status: on a J773g in review the VENC domains came up
disabled that way, and the encoder DARTs deferred until the probe timed
out.

Tested on a J773g in review (with the per-boot TEXT word in the T8132
variant): H.264 and HEVC 1080p encode, all frames decodable, no DART
faults. It needs the bootloader's T8132 AVE firmware handoff.

Assisted-by: LLM
Signed-off-by: Akhil <akhile76@gmail.com>
Enable the AVE encoder, its two DARTs and its six VENC power domains on
the MacBook Pro (14-inch, M4, J604).

State the VENC domains in the board tree rather than relying on the
T8132 PMGR policy, which gives a domain the board leaves without a status
the policy's own status: on the Mac mini M4 (J773g) the VENC domains came
up disabled that way, and the encoder DARTs deferred until the probe
timed out.

Untested on J604: the encoder and its resources are SoC blocks, the
same as on the MacBook Air M4 (J713) and the Mac mini M4 (J773g), where
this configuration encodes. It needs the bootloader's T8132 AVE firmware
handoff.

Assisted-by: LLM
Signed-off-by: Akhil <akhile76@gmail.com>
Enable the AVE encoder, its two DARTs and its six VENC power domains on
the iMac (24-inch, M4, J623 and J624).

State the VENC domains in the board tree rather than relying on the
T8132 PMGR policy, which gives a domain the board leaves without a status
the policy's own status: on the Mac mini M4 (J773g) the VENC domains came
up disabled that way, and the encoder DARTs deferred until the probe
timed out.

Untested on J623/J624: the encoder and its resources are SoC blocks, the
same as on the MacBook Air M4 (J713) and the Mac mini M4 (J773g), where
this configuration encodes. It needs the bootloader's T8132 AVE firmware
handoff.

Assisted-by: LLM
Signed-off-by: Akhil <akhile76@gmail.com>
@EdupugantiAkhil

Copy link
Copy Markdown
Author

Folded both in and pushed (96882be): .text_boot_word = 0x4224 on T8132, and the six VENC domains set okay on J773g, and also on J604 and J623/J624, which had the same gap. Rebased onto integration/aurora 0abc2f3. Retested on J713: FFmpeg H.264/HEVC/Main 10 and Chrome WebCodecs are byte-identical to the previous revision, decode is unchanged, and there are no DART faults. The J713 has read TEXT CRC 9308d2ab on every boot so far, so the per-boot word only shows up on your J773g. Thanks for testing!

@DjDeveloperr

DjDeveloperr commented Nov 21, 2026 •

Copy link
Copy Markdown

On macOS 27.2 (26B123) firmware, the J773g preloads AppleAVE2FW 9013.55.1 (TEXT 0x154000, CRC 99fc929a), and this series refuses it with "unexpected firmware segment sizes".

The 27.2 AppleAVE2 kext renumbers the M4 as device 23, type 23 (26.6.2: 26/24), so the 27.2 build needs its own start identity. #2643 adds it as a T8132 build table on top of this PR: H.264/HEVC with B-frames encode at 45.6/46.5 dB PSNR on the J773g.

Feel free to fold it in here instead; otherwise #2643 goes in after this one.

Conflicts with current integration/aurora (test merge onto 5b596e6): only in this PR's DT commits. The driver files merge cleanly.

  • t8132-j713-j715.dtsi: integration added a block with display-DART power domains, and, for VENC (and SCODEC/SIO_CPU), /delete-property/ power-domains on &dart_ave0/&dart_ave1, because t8132-j713-pmgr.dtsi now disables VENC on J713 and J715. Your commit enables &dart_ave0, &dart_ave1 and &ave at the same spot. Enabling AVE there now also means re-enabling the VENC states in that file and keeping the DART power domains.
  • t8132-peripherals.dtsi: your commit adds apple,dma-range to both encoder DARTs on the same lines where integration added their power-domains (202ede0, 1bcf59f). Keeping both lines resolves it.

I haven't pushed anything to your branch.

@RyanTheTide

Copy link
Copy Markdown

Blockers: 1.

The driver part is small and reads correctly: a new compatible-selected variant, its CRC added to the known list, and the CRC mapped to the existing 9003.78.0 layout, with the per-boot TEXT word that the J773g needed. The conflicts with integration/aurora and the 27.2 firmware follow-up are already covered in the earlier comments, so I don't repeat them.

  1. All seven commits end with an Assisted-by: LLM trailer. Commits should carry only the human Signed-off-by. Move the disclosure to the PR body's last line as Assisted-by: LLM (Claude:<model>). The body currently ends with a "Generated with Claude Code" line.
  2. Nit: drivers/media/platform/apple/ave/ave.h:181 and ave-layout.c:956 call T8132 "the M4 Air", but this variant serves every T8132 board the series enables (mini, MacBook Pro 14", iMac). "M4 (T8132)" is accurate. In the commit message of "media: apple: ave: add T8132 (M4) support", "with that word zeroed the CRC is 9308d2ab, as on the T6041 (M4 Max) preload" should say "as on the J713".

HW row: J713 booted with the DTB built from this branch (not the runtime overlay) on the default command line: FFmpeg H.264/HEVC/Main 10 encode with the PSNR table above, decode unchanged, 0 DART faults, 0 SELinux denials, 0 failed units, 0 new kernel errors. The same encode row on J604 or J623/J624 before their commits go in; otherwise drop those two commits for now.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown

@EdupugantiAkhil, a tidy-up pass over the open PRs here. These of yours need something:

If any of these are no longer needed, closing them helps; otherwise a merge or rebase onto integration/aurora is usually all they need. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants