Skip to content

media: apple: ave: T8132 (M4 Air) encoder on the macOS 27.2 stub, with device tree - #2675

Merged
RyanTheTide merged 7 commits into
integration/aurorafrom
j713/t8132-ave-272-rebase-20261121
Nov 22, 2026
Merged

RyanTheTide merged 7 commits into
integration/aurorafrom
j713/t8132-ave-272-rebase-20261121

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #2668, rebased onto current integration/aurora (conflicts in drivers/media/platform/apple/ave/{ave-drv.c,ave-fw.c,ave.h} and Documentation/devicetree/bindings/media/apple,t8140-ave.yaml: kept the base's T8122 variant and CRC next to T8132, and with the base's T6032 branch already gone, dropped the T8132 branch and listed T8132 in the shared and T6041 groups). The 26B123 layout commit is already on the base as 4c7a63d (with the T8132 CRC and layout lookup), so this carries the other three commits.

Problem. The M4 MacBook Air (J713, T8132) on the macOS 27.2 stub has no video encoder. The encoder node is disabled, the driver has no T8132 entry, and on the Air's loader tree the T8132 platform handoff keeps the VENC power states off. So only the decoder, JPEG and scaler nodes exist.

Change.

  • Add the macOS 27.2 (26B123) command layout. Its Start commands are 26A428's. Its Process commands are 0x10 bytes longer (H.264 0x6e08, HEVC 0x78c8). Every field the driver writes keeps its 26A428 offset, and the added bytes stay zero. The two layouts share one field description, and a KUnit case checks that only the Process sizes differ.
  • Add T8132, using the M4 Pro's coprocessor registers and start sequence: TEXT 0x154000 and DATA 0x12c000, TEXT CRC 99fc929a with the per-boot word at 0x4224 zeroed (the J713 loader leaves it zero; the J773g loader sets it, so an unknown CRC is retried with it zeroed, as for T6041), boot device 23, handshake type 23, and the 26B123 layout.
  • Describe the T8132 encoder in the T6041 shape: named banks, named power states, and the DART window at 0x100_0000_0000 where the loader maps the firmware. Enable the VENC states in the J713/J715 PMGR ownership file, then enable the two encoder DARTs and the encoder. The binding lists T8132 with T6041.

Review follow-up (Dj's #2668 review, f20c54a).

  • T8132 gets .text_boot_word = 0x4224 (351ec42), so the J773g's raw CRC f641c64b is retried as 99fc929a. A known CRC is used as it is, so the J713 is unchanged. KUnit checks the T8132 word and CRC.
  • The encoder keeps clocks = <&peripheral_clocks 430> (f20c54a). Its commit message notes that t8132-j713-pmgr.dtsi is shared by every M4 Mac.
  • The Apple component names are gone from the driver's comments and known-CRC list (d84656f). No code change.
  • No SVE idle-word clear for T8132: on the J713 the word reads 0 before every firmware start after a runtime suspend, and runs with and without the clear give byte-identical output (rows below).

Testing. J713 on the 27.2 stub, kernel = the J713 lab default plus these commits, Stage 2 DTB with the same DT changes. apple-ave binds at boot (/dev/video13). gst v4l2h264enc/v4l2h265enc passed 8/8 rows. 6 of the 8 bitstreams are byte-identical to the same rows on an M4 Pro (J616s, stock driver). The other two are long H.264 Baseline runs, within 0.3 % in size and 0.01 dB PSNR. Every stream decodes with no errors and the full frame count. The DART audit showed 0 unsafe streams, with 0 faults and 0 AVC denials. KUnit apple-ave: 30/30 passed (arm64 QEMU). dt_binding_check and dtbs_check passed on T8132 J713/J773g/J604 plus 19 other AVE boards. checkpatch --strict: clean. Rebased tree (buildbox, 2026-11-21): drivers/media/platform/apple/ave/ arm64 LLVM=1 W=1 built with 0 warnings; KUnit apple-ave* 46/46 passed (arm64 QEMU); dt_binding_check apple,t8140-ave.yaml clean; dtbs_check against it clean on all 59 Apple boards with an encoder node (T8132 J604/J623/J624/J713/J715/J773g included), and the base binding fails the new J713 node as a control; run-host-tests.py --only ave 6/6; checkpatch --strict clean.

Review rows on the J713 (B8 default, 7.3.0-bj713x9+), driver = f20c54a: ffmpeg h264_v4l2m2m Main without B-frames at 30 fps and hevc_v4l2m2m without B-frames at 60 fps, plus High at 24/30/60 fps, Baseline and HEVC at 30 fps. All 7 decode clean with the full frame count, 40-45 dB. gst 6/6 clean. Runtime PM: 2 legs x 3 suspend/restart cycles; mailbox 0x118 read 0 at every start, and both legs give byte-identical bitstreams. 0 SError, 0 DART faults. After the rebase and fixes: KUnit apple-ave 46/46, W=1 0 warnings, dt_binding_check and CHECK_DTBS on all 6 T8132 boards clean, checkpatch --strict clean.

Still to run. J715 (same tree, no unit here). Short rows and 4K H.264 are slower than on the M4 Pro (see the table); the performance floor is not looked at yet. The 26.6.2 stub firmware (#1489 25G83 image) is not admitted by this change. That would need a second build entry with its own device numbers.

Review rows (J713, f20c54a)

Driver from f20c54a, built for the B8 default kernel (7.3.0-bj713x9+); swapped in once on a boot where the stock driver had not started the firmware. For the idle-word legs the lab build also had a LAB-only toggle (off = the PR's behaviour) that logs mailbox 0x118 at every start. Evidence: traces/codec/20261121-j713-ave2 on the lab store.

session frames decode errors PSNR-Y
ffmpeg h264_v4l2m2m Main -bf 0, 30 fps 300/300 0 43.7 dB
ffmpeg hevc_v4l2m2m -bf 0, 60 fps 300/300 0 41.0 dB
h264_v4l2m2m High 0-B 30 / 60 / 24 fps 300 / 300 / 240 0 43.7 / 40.0 / 30.9* dB
h264_v4l2m2m Baseline 30 fps 300/300 0 42.8 dB
hevc_v4l2m2m 0-B 30 fps 300/300 0 44.5 dB
gst v4l2h264enc / v4l2h265enc: 0-B 30, default 30, default-B 60 6 x 300 0 -

*The 24 fps value is identical on the M3 (J615, 30.87 dB), so it comes from the checker's 24 fps source, not the encoder.

Idle word: leg A (no clear) and leg B (clear 0x118 before each start), 3 cycles each of runtime suspended (sysfs) -> new session -> firmware restart. Word read 0x0 before all 6 starts. The 3 H.264 and 3 HEVC outputs of both legs share one hash per codec.

Rows (J713 vs J616s, same script)

gst videotestsrc smpte NV12 -> v4l2h26Xenc -> parse -> file; fps best of 2 (whole pipeline wall time); PSNR computed off-device against the regenerated source (md5 matches the on-device source).

row J713 fps J616s fps bitstream vs J616s PSNR-Y J713 (J616s)
H.264 1080p x300 241.7 226.8 5027522 vs 5027907 B 26.469 (26.469)
HEVC 1080p x300 217.0 213.7 identical 27.248
H.264 4K x120 42.5 60.8 2004475 vs 2018932 B 24.406 (24.412)
HEVC 4K x120 53.3 59.1 identical 24.754
H.264 High 1080p x60 176.7 194.4 identical 27.559
H.264 Main B=3 x60 99.3 193.7 identical 27.528
HEVC B=3 x60 98.2 186.3 identical 27.218
H.264 1922x1090 x60 103.9 189.7 identical (odd-size compare artifact on both)

Low absolute PSNR is the driver's default rate on a fast-moving test pattern, the same on both Macs.

Why the platform-handoff change: on the Air's loader tree, t8132-platform-handoff applies t8132-j713-pmgr.dtsi as the PMGR ownership policy. A first boot with only the board DT enabled showed the six VENC states forced to disabled. The encoder DARTs then waited on their power state until the deferred-probe timeout, and the encoder refused with "needs a translating IOMMU". With the states enabled in the ownership file, both DARTs probe and the encoder binds.

Assisted-by: LLM (Claude:Opus 5.5)

The M4 MacBook Air (J713) with the macOS 27.2 stub has its encoder
firmware preloaded with TEXT 0x154000 and DATA 0x12c000, TEXT CRC
99fc929a, the same on every boot. The coprocessor and its start
sequence are the M4 Pro's (T6041); the build boots as device 23 and
takes handshake type 23, and speaks the 26B123 command layout.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The T8132 (M4) encoder has the T6041 resource layout: codec, mailbox
and coprocessor banks by name and five named VENC power states. Drop
its separate five-bank branch and list it with the T6041 group.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Describe the T8132 encoder like the T6041 one: the codec, mailbox and
coprocessor banks by name, its five VENC power states by name, and the
DART window above 0x100_00000000 that the bootloader maps the firmware
into. Drop the unused pmgr and fabric banks and the clock reference to
the disabled peripheral clock provider.

On J713/J715 the VENC power states are enabled in the board's PMGR
ownership file, so the T8132 platform handoff, which applies that file
on the Air's loader tree, keeps them; the encoder's two DARTs get their
power state again, and they and the encoder are enabled.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The known-CRC list and a few comments named the firmware and the macOS
driver by their Apple component names. Call them "encoder firmware" and
"the macOS driver" instead; the version numbers and build ids that
identify each image stay. No code change.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…eroed

The 27.2 (26B123) T8132 build has the per-boot word at TEXT 0x4224 that
the M4 Max build has. The MacBook Air (J713) loader leaves it zero, so
its raw TEXT CRC is the known 99fc929a; the Mac mini (J773g) loader sets
it on every boot, so its raw CRC reads f641c64b and probe refused it as
unsupported firmware. Give the T8132 variant .text_boot_word = 0x4224:
an unknown CRC is retried with that word zeroed, as for T6041, and a
known one is used as it is, so nothing changes on the J713.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The encoder node lost clocks = <&peripheral_clocks 430> when it was
described like T6041. The driver does not use the clock, but it is
hardware description the other T8132 nodes keep, and the binding allows
it. The provider is disabled today; fw_devlink ignores a disabled
supplier, as for the enabled jpeg0/jpeg1 nodes that point at the same
provider, so the encoder still probes.

Note for the VENC states enabled in t8132-j713-pmgr.dtsi by the encoder
enable: that ownership file is shared by every M4 Mac, so the VENC
states are now enabled on all of them; each board still enables the
encoder node itself.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Follow-up to the review on #2668, which carries over to this PR. Pushed f20c54a as three commits on top, with no force push:

  1. Rebase: done when this PR was opened. The duplicate layout commit and the T6032 if/then/else are gone, and dt_binding_check plus CHECK_DTBS on all six T8132 boards are clean.
  2. .text_boot_word: 351ec42 gives T8132 .text_boot_word = 0x4224, and the variant comment now says the J713 loader leaves the word zero while the J773g sets it. KUnit checks the word and the CRC (46/46). On the J713 the known CRC is taken as it is, so behaviour there is unchanged; the rows below ran on this head.
  3. Coverage: J713 on the B8 default with this head's driver. ffmpeg h264_v4l2m2m Main -bf 0 at 30 fps gave 300/300 frames, 0 decode errors, 43.7 dB. hevc_v4l2m2m -bf 0 at 60 fps gave 300/300, 0 errors, 41.0 dB. High at 24/30/60 fps, Baseline and HEVC at 30 fps were clean too, as were six gst sessions. Unlike the mini, H.264 without B-frames works in ffmpeg here.
  4. SVE idle word: a lab build of the same driver had a toggle (off = this PR) that logs mailbox 0x118 at every firmware start. I ran 2 legs x 3 cycles, each a runtime suspend confirmed in sysfs, then a new session and a firmware restart. The word read 0x0 before all 6 starts, and the legs without and with the clear give byte-identical bitstreams. So the J713 needs no clear, and this PR leaves mbox_idle unset. Whether the mini needs it is still for media: apple: ave: T8132: start the macOS 27.2 encoder firmware (on #1489) #2643.

Nits: the Apple component names are dropped from the driver's comments and the known-CRC list (d84656f, comments only). clocks = <&peripheral_clocks 430> is back (f20c54a); the J713's bound jpeg0/jpeg1 point at the same disabled provider, so the supplier doesn't block probe. f20c54a's message carries the note that the pmgr ownership file is shared by every M4 Mac.

The body has the row table. Evidence is in traces/codec/20261121-j713-ave2 on the lab store.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J713 (M4 Air, macOS 27.2 stub) row: this PR's head merged into a candidate default kernel. That kernel carries the J713 deep-sleep, display and GPU series plus #2670, #2700 and #2694. Stage 2 was aura main tip + #404 + #379, on the stock command line, booted once with no module swaps.

  • apple-ave binds at boot with the in-tree driver, and /chosen carries the encoder TEXT CRC.
  • gst v4l2h264enc / v4l2h265enc at 1080p (120 frames) and 4K (30 frames): every run finished, and two runs of each are byte-identical. H.264 1080p ran at 102-194 fps and HEVC 4K at 35-44 fps; the boot was still settling, so the fps numbers are noisy.
  • No DART faults, 0 failed units, 0 SELinux denials.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

No blockers. Admission fails closed: ave_t8132 pins the segment sizes and ave_fw_probe() accepts only TEXT CRC 99fc929a. The 0x4224 boot-word retry only recomputes the CRC, and the J713's raw CRC skips it. The node, binding and DART dma-range match the T6041/T6050 shape, and the four points from the #2668 review are covered on this head. Two rows before merge. First, t8132-j713-pmgr.dtsi now marks the six VENC states okay, and t8132_pmgr_policy() gives that status to any status-less pwrstate node on every M4 tree the handoff runs on, so please boot one non-Air M4 (J773g or an iMac) on this head and confirm the VENC domains probe and power off with no new errors. Second, run one s2idle/deep-sleep cycle on the J713 with apple-ave bound, then encode again after resume. Nit: the T8142 comment at ave-drv.c:217 now says device 27 "comes from the ADT", but the ADT only gives the soc-id string. Please reword it so it doesn't name the wrong source, and say in the T8132 commit how device/handshake 23 was observed.

Merge-train batch 1 merged #1900 (T8142 AVE on 27.2), which touched the
same firmware tables. Resolution: keep this branch's neutral firmware
wording in ave-fw.c and ave-drv.c and add the T8142 27.2 CRC entry from
#1900 to the known-CRC list beside the T8132 27.2 one. No code change
beyond the union of both sides.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merged integration/aurora 606d37e into the branch (2f5b721, plain merge, no force push): batch 1's #1900 had touched the same AVE firmware tables. The resolution keeps this branch's neutral firmware wording and adds the T8142 27.2 CRC from #1900 next to the T8132 one. There is no other code change. drivers/media/platform/apple/ave builds clean on the fleet config (arm64, LLVM). Dj's verdict is still needed at this head.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J713 sleep-then-encode row, run on the J713 default kernel (7.3.0-bj713t6+, default cmdline, macOS 27.2). That kernel carries this PR at f20c54a. The only AVE driver difference to 2f5b721 is the M5 (T8142) 27.2 build entries, so the T8132 path is the same code.

I encoded H.264 and HEVC with gst v4l2h264enc/v4l2h265enc at 1080p (120 frames) and 4K (30 frames), twice each, at three points: before sleeping, after one 15 s s2idle, and after one 15 s deep sleep.

  • Both sleeps returned rc 0. Every encode returned rc 0, and the output md5 was identical before and after both sleeps for all four streams.
  • 1080p ran at 99-184 fps and 4K at 25-47 fps. There were no DART faults, no SError and no AVE error lines.

The J713 default promotion gate also passed 13 deep sleeps with encode after the full-row deeps. Still owed from the list: a non-Air M4 boot showing the VENC domains, and Dj's verdict at 2f5b721.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adversarial Pre-PR Checklist Review (head 2f5b721a67be)

0 code/policy/attribution/CI blockers. Holding only for the remaining §5 hardware row below.

Checklist Summary (§1–§6)

  • §1 No model gating: Pass. ave_t8132 matches via apple,t8132-ave, segment sizes, and TEXT CRC (0x99fc929a) with .text_boot_word = 0x4224 fallback retry in ave_fw_text_boot_id(), handling both J713 (raw CRC matches directly) and J773g (per-boot word set) without board gating.
  • §2 Production-ready: Pass. Default command line, fail-closed firmware admission, clocks = <&peripheral_clocks 430> preserved, apple,dma-range and named banks/power domains match the T6041/T6050 shape.
  • §3 Safety: Pass. Firmware segment bounds, DART mapping verification, and CRC checks fail closed; ave_fw_text_boot_crc() bounds-checks word_off.
  • §4 Clean-room & attribution: Pass. All 7 commits carry human identity (Ryan Murray) and Signed-off-by: with no agent trailers; PR body carries Assisted-by:. Commit d84656f2 removed Apple component names from comments and ave_known_text_crc[].
    • Non-blocking nit: drivers/media/platform/apple/ave/ave-drv.c:218 now says "The chip identity comes from the ADT (ave soc-id "t8142"): device 27, generation 16", whereas the ADT carries only the soc-id string, not the numeric device 27, generation 16 pair. Fine to clean up in a follow-up.
  • §6 Naming: Pass. Uses aurora,ave-text-crc32; no disallowed names introduced.
  • CI: Green (dt-checks SUCCESS, host-tests SUCCESS; mergeable=MERGEABLE).

Remaining §5 HW Row Before Approve

  • Non-Air M4 boot (e.g., J773g Mac mini or iMac J623/J624) on this head: arch/arm64/boot/dts/apple/t8132-j713-pmgr.dtsi is applied across M4 trees and now marks all six VENC power states (ps_venc_sys, ps_venc_dma, ps_venc_pipe4, ps_venc_pipe5, ps_venc_me0, ps_venc_me1) status = "okay". Please confirm on one non-Air M4 that the VENC domains probe and idle/power off cleanly with 0 new kernel errors, 0 SELinux denials, and 0 failed units. (J713 full encode/runtime-PM/s2idle/deep-sleep rows are complete.)

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

On the non-Air M4 row: at 2f5b721 this PR doesn't turn on anything on a non-Air M4, so a J773g/J623 boot would not exercise it.

t8132-j713-pmgr.dtsi, where the VENC power states are set to okay, is included only by t8132-j713-j715.dtsi (git grep t8132-j713-pmgr.dtsi 2f5b721a returns just that file). The desktops and the J604 take t8132-pmgr.dtsi, which this PR doesn't touch.

To check it, I compiled every T8132 board's DTB at the base (606d37e) and at 2f5b721 and diffed the decompiled trees:

  • J773g, J623, J624, J604: the same 8-line delta on each. All of it is on nodes that stay status = "disabled": apple,dma-range on dart_ave0/dart_ave2, plus the encoder node's new named reg / power-domains shape. No ps_venc_* node changes on those boards, and nothing new is enabled.
  • J713, J715: the encoder, its DARTs and the VENC states are enabled. That is covered by the J713 rows at this head (fleet80c default: encode md5 identical to the previous default, runtime PM, s2idle 3/3, deep sleeps 10/10).

When a non-Air M4 gets an encoder enable of its own, that PR will carry its own boot row.

Diff method

cpp + dtc with the kbuild include paths, one detached worktree per commit, dtc -I dtb -O dts -s, then diff. The J773g delta:

> apple,dma-range = <0x100 0x4000 0x00 0xffffc000>;   (dart_ave0, status disabled)
> apple,dma-range = <0x100 0x4000 0x00 0xffffc000>;   (dart_ave2, status disabled)
< power-domains = <0x34 0xb4 0xb5 0x36 0xb6 0x35>;
< reg = <... 6 banks ...>;
> power-domain-names = "dma", "pipe4", "pipe5", "me0", "me1";
> power-domains = <0x35 0xb4 0xb5 0x36 0xb6>;
> reg = <0x04 0x21100000 0x00 0x45c000 0x04 0x21050000 0x00 0x4000 0x04 0x21800000 0x00 0x800000>;
> reg-names = "codec", "mailbox", "coproc";            (video-encoder@421100000, status disabled)

Lab store: traces/kernel/20261122-t8132-ave-dt-nonair/.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pre-PR Checklist Re-check — Upgrading to APPROVE (head 2f5b721a67be)

The sole remaining §5 hold (non-Air M4 VENC power-domain check) is resolved and independently verified against 2f5b721a67be:

  • arch/arm64/boot/dts/apple/t8132-j713-pmgr.dtsi (where ps_venc_{sys,dma,pipe4,pipe5,me0,me1} are set to status = "okay") is included only by t8132-j713-j715.dtsi (t8132-j713.dts and t8132-j715.dts).
  • Non-Air M4 boards (t8132-j773g.dts, t8132-j623.dts, t8132-j624.dts, t8132-j604.dts) include t8132-pmgr.dtsi (untouched by this PR); the only t8132-peripherals.dtsi changes visible in their compiled DTBs are on dart_ave0, dart_ave2, and ave, all of which remain status = "disabled".
  • J713 hardware rows (ffmpeg + GStreamer H.264/HEVC 1080p/4K encode with byte-identical outputs, runtime PM / SVE idle word check, s2idle, deep sleep, 0 DART faults, 0 SELinux denials, 0 failed units) and CI (dt-checks, host-tests) are all green with 0 code blockers.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide
RyanTheTide merged commit f5f023b into integration/aurora Nov 22, 2026
2 checks passed
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.

2 participants