Skip to content

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

Closed
RyanTheTide wants to merge 4 commits into
integration/aurorafrom
j713/t8132-ave-272
Closed

RyanTheTide wants to merge 4 commits into
integration/aurorafrom
j713/t8132-ave-272

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

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 (the same on every boot), 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.

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.

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.

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 macOS 27.2 build of the encoder firmware takes the 26A428 Start
commands unchanged, but its H.264 and HEVC Process commands are 0x10
bytes longer (0x6e08 and 0x78c8). Every field the driver writes stays
at its 26A428 offset; the added bytes are left zero.

Share the 26A428 field description between the two layouts and add
ave_layout_26b123 with the longer Process commands. No firmware selects
it yet. A KUnit case checks that the two layouts differ only in the
Process sizes.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
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>

@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.

The driver and DT are right for the J713. Four things to settle before merge: two for the rebase, one for the M4 mini, one for coverage. These are from reading the code and running the AVE host tests, plus DTBs built with cpp+dtc and validated. No kernel build.

  1. Rebase onto integration (4ea3629), which now carries #2644.
    • 435fefa duplicates #2644's layout commit 4c7a63d, so drop it.
    • The driver commit's ave.h hunk (the CRC define) is already in integration.
    • The binding commit, rebased as is, brings back the T6032 placeholder if/then/else that #2644 removed. An enabled T6032 encoder node then fails validation (reg-names and power-domain-names unexpected). It doesn't show today only because those nodes are disabled. Drop that block. We have a rebased and validated version locally if it helps.
  2. ave-drv.c:118: the T8132 variant has no .text_boot_word. On the M4 mini (J773g) on 27.2, the preload's raw TEXT CRC reads f641c64b, and 99fc929a only with the boot word (0x4224) zeroed. So enabling the mini's DT on top of this fails with unsupported firmware (text CRC f641c64b). Adding .text_boot_word = 0x4224 is harmless on the J713. The comment at :115, "the same on every boot", holds on the J713 only.
  3. Coverage: any_gop now reaches the T8132. After the rebase, the T8132 26B123 build admits sessions without B-frames and at other rates. The J713 rows (gst defaults) don't cover that. Please add ffmpeg h264_v4l2m2m Main without B-frames at 30 fps and hevc_v4l2m2m at 60 fps on the J713. On the mini, a lab module passed HEVC at 60 fps without B-frames, while H.264 without B-frames failed inside ffmpeg with no driver error. That's still being looked at.
  4. The SVE idle word (mbox_idle = 0x118). The J713 works without clearing it, and the mini runs with the clear. One A/B that includes a runtime suspend and resume would settle whether the clear is needed.

Nits:

  • ave-fw.c:46 adds another AppleAVE2FW label to the known-CRC list. Checklist item 4 says no Apple strings, so rename the list's labels in one cleanup.
  • Dropping clocks = <&peripheral_clocks 430> from the T8132 node is harmless while the supplier is disabled, but it removes hardware description that the other T8132 nodes keep.
  • t8132-j713-pmgr.dtsi:203 (the ownership file) is shared by every M4 Mac. That's fine, worth a line in the commit message.

#2643 (the mini) will be reworked as a follow-up on top of this once it lands: the J773g enable, the layout test expecting 26B123, and the idle-word clear only if the A/B needs it.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Superseded by #2675: the same commits rebased onto current integration/aurora.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Superseded by #2675 (the same change rebased). Branch kept.

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