Skip to content

media: apple: ave: enable 6070 HEVC Main 10 (P010) and HEVC SPS VUI colorimetry/HDR10 - #3913

Draft
RyanTheTide wants to merge 3 commits into
mainfrom
ave/hevc-6070-main10-vui
Draft

RyanTheTide wants to merge 3 commits into
mainfrom
ave/hevc-6070-main10-vui

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two focused changes to drivers/media/platform/apple/ave/ (~146 non-test lines):

  1. Enable HEVC Main 10 (P010) on the 6070 encoder (M1 Pro / T6000, T8112 13.5):

    • Include AVE_LAYOUT_6070 in ave_main10_supported() and drop the 8-bit-only guard in ave_sess_params().
    • Scale 6070 entropy aux channels alongside the main entropy channels for 10-bit sessions.
    • Set the 6070 CQ min_qp floor to -AVE_QP_BD_OFFSET_10 (-12), clear profile_compatibility_flag[1] (Main) for 10-bit, and populate the 6070 Process reconstruction descriptors for 10-bit frames.
    • Add KUnit coverage (ave_6070_hevc_main10).
  2. Signal HEVC VUI colorimetry and HDR10 transfer in SPS (all AVE layouts):

    • Map V4L2 OUTPUT format colorimetry (colorspace, xfer_func, ycbcr_enc, quantization) to ITU-T H.273 / H.265 Annex E VUI codes (including Rec.709 SDR, BT.2020 + SMPTE ST 2084 PQ HDR10, BT.2020 10-bit, sRGB, and full/limited range).
    • Write the HEVC SPS VUI signal-type and colour-description fields into the Start command across the 9003, 26A428/26B123, and 6070 layouts.
    • Preserve ave_9003_byte_equality unchanged and add KUnit coverage (ave_hevc_vui_colorimetry) across all four layouts.

Verification (exact head 04227a3dd7e7de0490c1b63c58c71c28957b5a5a)

  • scripts/checkpatch.pl --git HEAD~2..HEAD --no-tree: 0 errors, 0 warnings.
  • python3 tools/asahi/run-host-tests.py --only ave: 11/11 PASS (ASan+UBSan).
  • arm64 KUnit (drivers/media/platform/apple/ave/.kunitconfig): 58/58 PASS (incl. ave_9003_byte_equality, ave_6070_hevc_main10, ave_hevc_vui_colorimetry).
  • arm64 LLVM=1 W=1 KCFLAGS="-Werror" drivers/media/platform/apple/ave/: clean (0 warnings, 0 errors).

Exact-Head Hardware Rows (5 Macs / 40 streams verified; M1 Pro 6070.11.1 row pending lock release)

All bitstreams verified with ffprobe (profile, pix_fmt, VUI color_*), ffmpeg software decode (0 errors), and frame-for-frame planar PSNR against deterministic source YUVs. Zero DART faults, zero Oops/BUGs.

Mac / SoC / Firmware Resolution Stream Profile / pix_fmt VUI (space/xfer/prim/range) SW Decode Avg PSNR (Y / U / V dB)
M2 mini (j473, T8112, 26B123) 1080p (60f) NV12 Main SDR Main / yuv420p bt709 / bt709 / bt709 / tv CLEAN 54.25 (56.93 / 51.66 / 51.18)
M2 mini (j473, T8112, 26B123) 1080p (60f) P010 Main 10 SDR Main 10 / yuv420p10le bt709 / bt709 / bt709 / tv CLEAN 57.01 (60.54 / 53.89 / 53.62)
M2 mini (j473, T8112, 26B123) 1080p (30f) P010 HDR10 PQ Main 10 / yuv420p10le bt2020nc / smpte2084 / bt2020 / tv CLEAN 56.81 (59.22 / 54.28 / 54.00)
M2 mini (j473, T8112, 26B123) 1080p (30f) P010 BT.2020 full Main 10 / yuv420p10le bt2020nc / bt2020-10 / bt2020 / pc CLEAN 56.81 (59.22 / 54.28 / 54.00)
M2 mini (j473, T8112, 26B123) 4K (30f) NV12 / P010 SDR / HDR10 / BT.2020 full Main & Main 10 exact VUI (bt709, smpte2084/tv, bt2020-10/pc) CLEAN 54.04 (NV12), 55.37 (P010/HDR10)
M2 Air (j413, T8112, 26B123) 1080p & 4K NV12 / P010 SDR / HDR10 / BT.2020 full Main & Main 10 exact VUI (bt709, smpte2084/tv, bt2020-10/pc) CLEAN 54.25 / 57.01 / 56.81 (1080p), 54.04 / 55.37 (4K)
M3 Air (j615, T8122, 26B123) 1080p & 4K NV12 / P010 SDR / HDR10 / BT.2020 full Main & Main 10 exact VUI (bt709, smpte2084/tv, bt2020-10/pc) CLEAN 54.32 / 56.91 / 56.71 (1080p), 53.99 / 55.43 (4K)
M4 Air (j713, T8132, 26B123) 1080p & 4K NV12 / P010 SDR / HDR10 / BT.2020 full Main & Main 10 exact VUI (bt709, smpte2084/tv, bt2020-10/pc) CLEAN 54.04 / 58.14 / 57.81 (1080p), 53.97 / 56.45 (4K)
Neo (neo, T8140, 9003.78.0) 1080p (60/30f) NV12 / P010 SDR / HDR10 / BT.2020 full Main & Main 10 exact VUI (bt709, smpte2084/tv, bt2020-10/pc) CLEAN 54.02 (NV12), 58.19 (P010), 57.77 (HDR10)
Neo (neo, T8140, 9003.78.0) 4K (30f) NV12 / P010 SDR / HDR10 / BT.2020 full Main & Main 10 exact VUI (bt709, smpte2084/tv, bt2020-10/pc) CLEAN 53.94 (NV12), 56.43 (P010/HDR10)
M1 Pro (m1pro, T6000, 6070.11.1) 1080p & 4K NV12 / P010 Main 10 / HDR10 / BT.2020 full pending lock release pending pending pending

Enable 10-bit HEVC Main 10 encoding from P010 input on the 6070
firmware layout (M1 Pro / T6000 and T8112 13.5).

The 6070 Start layout already maps the profile, compatibility flags,
luma/chroma bit depth, input depth, and 10-bit reconstruction surface
layout, and the session allocator already scales reconstruction and
entropy channel buffers for 10-bit. Lift the layout gate in
ave_main10_supported() and ave_sess_params(), scale the 6070 entropy
aux channels alongside the main entropy channels, adjust the 6070 CQ
QP floor by -12 (QpBdOffset) and Main compatibility flag for 10-bit,
and populate the 6070 Process reconstruction pointers for 10-bit frames.

Add KUnit coverage (ave_6070_hevc_main10) checking the 6070 Main 10
Start and Process command fields.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Map V4L2 OUTPUT format colorimetry (colorspace, xfer_func, ycbcr_enc,
quantization) to ITU-T H.273 / H.265 Annex E VUI parameters and write
them into the HEVC Start command across the 9003, 26A428/26B123, and
6070 firmware layouts.

When V4L2 colorimetry is set (including Rec.709 SDR, BT.2020 + SMPTE
ST 2084 PQ HDR10, and full/limited range), set
vui_parameters_present_flag, video_signal_type_present_flag,
video_format (unspecified), video_full_range_flag,
colour_description_present_flag, colour_primaries,
transfer_characteristics, and matrix_coeffs in the HEVC SPS template
so decoders identify BT.709/BT.2020/HDR10 and range from the bitstream.

Add KUnit coverage (ave_hevc_vui_colorimetry) across all four layouts
while keeping ave_9003_byte_equality unchanged.

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

Copy link
Copy Markdown
Contributor Author

Updated: merged main @7b10eb104ce6 (3514112, clean; main's ave.h and tests/run.py changes auto-merged). No code change.

Local on the merged head: run-host-tests.py --only ave 11/11 PASS; aurora_defconfig (RUST off) LLVM=1 ARCH=arm64 W=1 build of ave-abi-test.o, ave-layout.o, ave-sess.o, ave-v4l2.o, ave-writer.o: no warnings. KUnit runs in CI.

Still needed: the M1 Pro (6070) row, which is the encoder the Main 10 half of this PR enables and is still marked pending in the body; queued in HWROWS for our J314s, with a J473 regression check on the merged head.

@RyanTheTide
RyanTheTide marked this pull request as ready for review December 5, 2026 01:40
@RyanTheTide
RyanTheTide requested review from a team as code owners December 5, 2026 01:40
@github-actions github-actions Bot added area:media Area from CODEOWNERS (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Dec 5, 2026
@github-actions

github-actions Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Merge readiness at 35141126: not ready yet

Check Detail
CI at head running running: host-tests, KUnit ave
Review no needs one approving review from Core, Omarchy Mac or Aurora Maintainers (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 35141126, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text no add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:media

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Dec 5, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Hardware verification at exact head 351411264dac on J316s (MacBook Pro 16" M1 Pro, T6000, AVE fw 6070.11.1): FAIL (blocking bug on 6070.11.1 P010 input pixel packing)

Summary

  • HEVC SPS VUI colorimetry / HDR10 signaling (6070.11.1): PASS — all 3 VUI profiles (bt709/bt709/bt709/tv, bt2020nc/smpte2084/bt2020/tv, bt2020nc/bt2020-10/bt2020/pc) signaled accurately in ffprobe, 0 decode errors, exact frame counts, 0 DART faults, 0 SErrors.
  • 8-bit NV12 regression (6070.11.1): PASS — 1080p NV12 HEVC Main frame-matched PSNR 41.46–42.80 dB (60/60, dec_errs=0); 1080p NV12 H.264 41.98 dB (60/60, dec_errs=0).
  • 10-bit P010 HEVC Main 10 (6070.11.1): FAIL — V4L2 exposes P010 and auto-selects hevc_profile=2 (Main 10), and encodes complete with 0 kernel/decode errors, but the encoded picture is garbled (6.19–8.10 dB PSNR across all 6 P010 streams, 1080p & 4K).

Root Cause Observed on 6070.11.1

Comparing decoded frame 0 (yuv420p10le) against the testsrc2 p010le source (constant Y = 324, stored in little-endian P010 as 0x5100 -> bytes 00 51 00 51 ...):

  • Source row 200 src[0:12]: [324, 324, 324, 324, 324, 324, 324, 324, 324, 324, 324, 324]
  • Decoded row 200 dec[0:12]: [258, 21, 273, 253, 22, 274, 254, 20, 274, 255, 19, 268]

Notice the exact period-3 pattern [256, 20, 272], which is the exact bit-unpacking of the 32-bit little-endian word 0x51005100 as 3 packed 10-bit pixels per 32-bit word (10:10:10:2):

  • 0x51005100 & 0x3ff = 0x100 = 256 (observed 254–258)
  • (0x51005100 >> 10) & 0x3ff = 0x014 = 20 (observed 19–23)
  • (0x51005100 >> 20) & 0x3ff = 0x110 = 272 (observed 268–277)

6070.11.1 is still reading 10-bit input planes as 3-pixels-per-32-bit-word packed 10-bit rather than 16-bit-per-sample P010 (likely missing the 6070 input pixel-packing / format selection bit in ave_start_config() / ave_layout_6070_11_1, where hevc_input_format is currently fixed to 16 and h264_pixel_packing has no HEVC equivalent written).

Exact J316s build, V4L2, and ffprobe/PSNR evidence
  • Build: apple-ave.ko built from exact 351411264dacf9bda86dca9cbb09fe57ddb802de against saved EDGE 7.3.0-1675a62307d2-47318133913.1-aurora-edge (SHA256 186bfac512ddc43f4804197e6f0ac266dd0551c592e757753502468d0bc9cfc3, 0 undefined symbol diffs). Local run-host-tests.py --only ave: 11/11 PASS.
  • VIDIOC_ENUM_FMT (HEVC): NV12, P010; hevc_profile: 2 (Main 10); (H264): NV12 only.
  • Streams on /dev/video16 (DMESG_CLEAN, serror=0, dartfault=0):
    • 1080-nv12-sdr.h265: Main, yuv420p, bt709/bt709/bt709/tv, 60f, dec_errs=0, f0–f5 Y PSNR 41.46–42.80 dB (PASS)
    • 1080-nv12-sdr.h264: Baseline, yuv420p, 60f, dec_errs=0, PSNR 41.98 dB (PASS)
    • 1080-p010-sdr.h265: Main 10, yuv420p10le, bt709/bt709/bt709/tv, 60f, dec_errs=0, PSNR 6.74 dB (f0 8.10 dB) (FAIL)
    • 1080-p010-hdr10.h265: Main 10, yuv420p10le, bt2020nc/smpte2084/bt2020/tv, 30f, dec_errs=0, PSNR 6.83 dB (FAIL)
    • 1080-p010-bt2020full.h265: Main 10, yuv420p10le, bt2020nc/bt2020-10/bt2020/pc, 30f, dec_errs=0, PSNR 6.19 dB (FAIL)
    • 4k-nv12-sdr.h265: Main, yuv420p, bt709/bt709/bt709/tv, 30f, dec_errs=0 (PASS)
    • 4k-p010-sdr.h265: Main 10, yuv420p10le, bt709/bt709/bt709/tv, 30f, dec_errs=0, PSNR 6.73 dB (FAIL)
    • 4k-p010-hdr10.h265: Main 10, yuv420p10le, bt2020nc/smpte2084/bt2020/tv, 30f, dec_errs=0, PSNR 6.82 dB (FAIL)
    • 4k-p010-bt2020full.h265: Main 10, yuv420p10le, bt2020nc/bt2020-10/bt2020/pc, 30f, dec_errs=0, PSNR 6.19 dB (FAIL)
  • Restored m1pro cleanly via reboot to untainted saved EDGE (tainted=4, Enforcing, 0 failed).

Recommendation: Do not merge the 6070 P010 enablement until the 6070.11.1 16-bit P010 vs 3x10-in-32 packed input format selection is fixed and re-verified on 6070.11.1 (the HEVC SPS VUI colorimetry/HDR10 part works cleanly on all 5 SoC families including 6070.11.1).

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Hardware row at exact head 351411264dac on the M1 Pro (J316s, AVE 6070.11.1): FAIL (10-bit picture), same result as the exact-head row above.

  • V4L2 now lists P010 on OUTPUT (base: NV12 only) and HEVC Main 10 encodes complete: 1080p 20 frames and 4K 10 frames, for SDR bt709, HDR10 PQ and BT.2020 full range.
  • VUI is exact on all six P010 streams (ffprobe: tv/bt709/bt709/bt709, tv/bt2020nc/smpte2084/bt2020, pc/bt2020nc/bt2020-10/bt2020), 0 decode errors, all frames decoded.
  • But the decoded P010 picture does not match the source: PSNR Y 8.9-9.2 dB at 1080p and 4K, so the input is still read in the wrong layout.
  • NV12 Main regression ok: 1080p Y 32.6 dB, 4K Y 35.4 dB (base kernel, same clip and encoder settings: 33.6 / 37.7 dB). 0 DART faults, no AVE errors.

How: one combined test kernel for six PRs, not this PR alone. Kernel 7.3.0-aurora-ci = main d0684a06 + merge commits of linux#2804 95b14b2c, #3913 35141126, #2802 fd2472c2, #2403 aca4e954, #1814 775f31d2, #2398 75b30c6c (all merged clean, test commit 837c6334, cloud build https://github.com/aurora-silicon/linux/actions/runs/47474056828). Booted as a one-shot on the lab M1 Pro (J316s, T6000, 13.5 stub) with this kernel's own DTBs in a trial Stage 2 (live aura 1.0.0b19 + U-Boot, only the DTBs swapped), default cmdline. Boot health on the test kernel: 0 error-level kernel lines (base 0), 0 AVC, 0 failed units. Saved default restored after.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Back to draft: the exact-head M1 Pro row above fails. HEVC Main 10 (P010) encodes finish with the exact VUI and no decode errors, but the picture is garbled (Y PSNR about 9 dB at 1080p and 4K); NV12 is fine. That matches the separate M1 Pro row from 16:11. The 6070 Main 10 path needs a fix before this comes out of draft again.

@github-actions github-actions Bot removed needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Dec 5, 2026

This branch has not been deployed

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

Labels

area:media Area from CODEOWNERS (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant