Skip to content

media: apple: scaler: fill alpha for XRGB32 like ARGB32 - #3217

Merged
RyanTheTide merged 3 commits into
mainfrom
fix/scaler-yuv-to-xrgb-alpha-fill
Dec 1, 2026
Merged

RyanTheTide merged 3 commits into
mainfrom
fix/scaler-yuv-to-xrgb-alpha-fill

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What: XRGB32 output from a Y'CbCr source had the alpha fill off, unlike ARGB32. Every Y'CbCr to R'G'B' job macOS runs in our capture has the fill on, and P010 to XRGB32 at 1280x720 times out on the M4 and the A18 Pro (#3216). An XRGB32 destination is now programmed write for write like ARGB32. Fixes #3216.

Tested: the module and the KUnit object build W=1-clean (clang, arm64). The new KUnit case asc_test_job_xrgb checks the job against ARGB32 for five source formats. J700 (Neo) at f65e84d956d1, with #3204, in the combined candidate 7.3.0-neo-combined1126, which carries it unchanged: P010 to XRGB32 at 1280x720 completes (it times out on base). NV12 and P010 to XRGB32 give the same CRCs as to ARGB32, the other conversions match base, and nothing times out. 0 DART faults.

Risk: two-way · M1 and M4 families and the Neo. Only XRGB32 output from a source without alpha changes (one register bit); every traced job keeps its register values.

Not yet: the M4 mini row (the same matrix with the old and new module).

Details
  • 0x8c bit 31 is the alpha fill. It was set only when the destination has alpha and the source has none, so a Y'CbCr source written as XRGB32 had it off. The engine writes four bytes per pixel for XRGB32 as for ARGB32, and XRGB32 and ARGB32 share layout, code, sampling and swizzle words.
  • The traced jobs (KUnit asc_test_job, asc_test_job_lossless): NV12 to ARGB32 and P010 to ARGB32 have the fill on (0x8000ffff); ARGB32 to NV12 and NV12 to and from lossless have it off (0x0000ffff). The new rule, fill on for an R'G'B' destination whose source has no alpha, keeps all of them.
  • The fourth byte of XRGB32 output becomes 0xff, as ARGB32's alpha is. So an XRGB32 conversion now has the same CRC as the ARGB32 conversion of the same input, which the row checks.
  • The Neo row confirms this is the hang: with the fill on, the 1280x720 P010 to XRGB32 job completes, while on base it times out.
Evidence
  • make M=drivers/media/platform/apple/scaler LLVM=1 W=1 modules and apple-scaler-test.o against a configured 7.3 tree: no warnings.
  • KUnit apple-scaler: CI at this head.

A Y'CbCr source converted to XRGB32 had the alpha fill (0x8c bit 31)
off, while the same source converted to ARGB32 has it on. The engine
writes four bytes per pixel for both formats. Without source alpha and
with the fill off, nothing supplies the fourth component, and every
Y'CbCr to R'G'B' job macOS runs in our capture has the fill on. XRGB32
was the one such job the driver programmed differently, and P010 to
XRGB32 at 1280x720 times out on the M4 and the A18 Pro.

Turn the fill on for any R'G'B' destination whose source has no alpha.
An XRGB32 destination is now programmed write for write like ARGB32,
and its fourth byte is 0xff like ARGB32's alpha. Every traced job keeps
its register values: Y'CbCr destinations and sources with alpha leave
the fill off as before.

Add a KUnit case: for NV12, NV12M, P010, ARGB32 and XRGB32 sources, the
XRGB32 job equals the ARGB32 job write for write, and the fill is on
exactly when the source has no alpha.

Refs: #3216
Signed-off-by: DjDeveloperr <[email protected]>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J773g (M4 Mac mini, T8132 scaler, MSR hardware-version 20) at f65e84d956d1: PASS. With this PR, XRGB32 output no longer times out, and XRGB32 CRCs match ARGB32 for both NV12 and P010 input. The #3216 timeout doesn't reproduce.

How it was run: one boot of kernel main b12781353833 plus #3200, #3204, #3209, #3211, #3213 and #3210, with no overlapping files.

So OLD and NEW differ only by this PR. Tools: scaler-diag sha256 efc4827a…7bbd, scaler-row ae50a441…253.

scaler-diag matrix OLD (#3204) NEW (#3204 + this PR)
NV12 → ARGB32 1280×720 ok 8699d632 ok 8699d632
NV12 → XRGB32 1280×720 error (job timed out) ok 8699d632
P010 → ARGB32 1280×720 ok 250e3103 ok 250e3103
P010 → XRGB32 1280×720 error (job timed out) ok 250e3103
P010 → ARGB32 1920×1080 ok 67b54a70 ok 67b54a70
P010 → NV12 1280×720 ok 6d717918 ok 6d717918
ARGB32 → XRGB32 1280×720 ok 8a03ce74 ok 8a03ce74
NV12 → ARGB32 1920×1080 (after) ok 87c952e0 ok 87c952e0
result 2 failed, XRGB32 ≠ ARGB32 0 failed, XRGB32 == ARGB32 (NV12 and P010)

scaler-row convert with NEW: 0 failed. P010 → XRGB32 1280×720 completes with CRC 250e3103, the same as P010 → ARGB32. NV12 → ARGB32 is 87c952e0, ARGB32 → NV12 is 0047e4e3 and NV12 → L8V0 → NV12 is 92ea3acb, all as in the #3204 row.

Kernel log over the A/B:

NEW was unloaded afterwards and the kernel's module reloaded. Then the Mac went back to the stock kernel, and the modules and kit were removed from it.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Verdict at f65e84d956d1: ready

Blockers: none

Checked:

  • Only XRGB32 destinations change. The format table has two R'G'B' formats, ARGB32 (alpha) and XRGB32 (no alpha), and four Y'CbCr ones (NV12, NV12M, P010, L8V0), all without alpha.
    • The old fill condition d->alpha && !s->alpha and the new !d->yuv && !s->alpha agree for every pair except an XRGB32 destination from a source without alpha.
    • For an ARGB32 destination, !d->yuv equals d->alpha. For a Y'CbCr destination, both conditions are false. So ARGB32, NV12, NV12M, P010 and L8V0 outputs program exactly as before.
    • The only other write that differs between XRGB32 and ARGB32 would be in asc_emit_image(), and the two formats share layout, code, sampling, swizzle and bpp, so an XRGB32 job is now identical to the ARGB32 one.
  • The KUnit case pins the fill rule from both sides.
    • asc_test_job_xrgb builds the XRGB32 and the ARGB32 job for NV12, NV12M, P010, ARGB32 and XRGB32 sources. It requires them to be equal write for write, and requires 0x8c to be 0x8000ffff exactly when the source has no alpha. A missing 0x8c write would read 0 and fail too.
    • With the old apple-scaler-hw.c, it fails for the four sources without alpha (NV12, NM12, P010, BX24) and passes ARGB32.
    • The other half of the rule, that a Y'CbCr destination keeps the fill off, is held by the existing traced cases. When I changed the condition to !s->alpha alone, asc_test_job_lossless failed.
  • Merged-code rules: no runtime switch and no SoC or board gate. The fill bit is the same BIT(31) as before.
  • Not blocking: an L8V0 (lossless) source to XRGB32 is also allowed and also changes. The rule gives it the same programming as L8V0 to ARGB32, but the new case's source list doesn't include L8V0. Adding it would cover every source.
Evidence
  • Build at f65e84d956d1 with the asahi profile (LLVM) and W=1: drivers/media/platform/apple/scaler/, exit 0, 0 warnings.
  • KUnit drivers/media/platform/apple/scaler/.kunitconfig (arm64 QEMU, run locally because CI's KUnit scaler was still queued; CONFIG_WERROR off for this host's clang 23, with no warnings in the scaler files):
    • this head: 18/18, including asc_test_job_xrgb;
    • this head with apple-scaler-hw.c from the base b12781353833: 17/18. asc_test_job_xrgb fails for NV12, NM12, P010 and BX24;
    • this head with the fill condition changed to !s->alpha: 17/18. asc_test_job_lossless fails.
  • CI at this head: host-tests and apple-build succeed.
  • The J773g row at this head (the comment above) and the J700 row in the PR body: XRGB32 no longer times out, and XRGB32 CRCs match ARGB32 for NV12 and P010.

@github-actions github-actions Bot added area:media Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at 69173086: not ready yet

Check Detail
CI at head no failing: apple-build, host-tests, pr-text / pr-text, KUnit ane-boot, KUnit ane-pm, KUnit dcp-fabric
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head ok comment at 69173086
Conflicts ok none
PR text ok Risk: two-way · M1 and M4 families and the Neo. Only XRGB32 output from a source without alpha changes (one register bit); every traced job keeps its register values.

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) merge-conflict Conflicts with the base branch (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 26, 2026

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: FINISH, then merge at 781c65a2

Blockers:

  1. Merge conflict (CONFLICTING) against main; rebase onto current main and re-run CI (12 checks were cancelled at 781c65a2).
  2. Missing hardware row at head (needs-hw-row).

Checked:

  • Verified mergeability (CONFLICTING), cancelled CI checks, and needs-hw-row status.
  • Deferred final approval until rebased cleanly onto main with green CI and an exact-head hardware row.
Evidence
  • Head 781c65a2 vs main: CONFLICTING; CI 7 passed, 12 cancelled.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 30, 2026
Resolve apple-scaler-test.c: keep the XRGB32 job case from this branch beside the cases main added.

Signed-off-by: DjDeveloperr <[email protected]>

@aurora-silicon-review aurora-silicon-review Bot 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 forward merge retains the XRGB32 job test alongside main’s format additions. The earlier J700 and J773g results address the reported timeout and cover the unchanged XRGB32 conversion. Current build and KUnit checks remain pending. I am not asking for another hardware platform for this fix.

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

Reviewed the conflict-pass merge commit 6917308 only: single-file union, no hand edits. The resolution keeps what each side had and adds nothing outside the conflict. Approved for the merge-up; merging still waits on CI and the rows at this head.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 2026

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: MERGE at 691730862531

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: Code reviewed in the earlier App review at this head (6122660605).

Follow-ups (not blocking): current build and KUnit checks

@RyanTheTide

Copy link
Copy Markdown
Contributor

J616s (MacBook Pro 14", M4 Pro, T6040) at 6917308625318335361e1f0e28c36f444582dd7c: PASS - apple-scaler, one job each with v4l2-ctl: NV12 and P010 to XRGB32 (BX24) at 1280x720 and 1920x1080 all complete, and each output is byte-identical to the same conversion to ARGB32 (md5 505e398f, 776ba627, bc394500, 11741a6e), with the fourth byte 0xff on every pixel. ARGB32 to XRGB32 gives the same output as on the default kernel (9e6991b0). 0 job timeouts, 0 DART faults. The same matrix on the Mac's default kernel (7.3.0-aurora-edge 933f822): all 4 Y'CbCr to XRGB32 jobs time out (job timed out (running 0x1), 0 bytes written). Repeated on a second boot with the same result. Kernel = main 27d585c8dfb3 + #2161 #3224 #3117 #3217 #3413 (exact heads), one grub2-reboot one-shot boot, default command line and Stage 2.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at 691730862531 (B2 merge train, 12-01 merge bar). Approval at this head: RyanTheTide,aurora-silicon-review[bot]. Row: J616s (M4 Pro) row at this head (B2 rows kernel = main 27d585c + #2161 #3224 #3117 #3217 #3413), posted on this PR. CI: linux train L7 = main 27d585c + #2161 #3224 #3117 #3217: Apple driver compile pass, planned KUnit dcp-topology/jpeg/scaler/asahi/sep/aop pass. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit 4e4603f into main Dec 1, 2026
6 of 27 checks passed
@RyanTheTide
RyanTheTide deleted the fix/scaler-yuv-to-xrgb-alpha-fill branch December 1, 2026 11:05
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) blast:m1 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apple scaler: P010 to XRGB32 conversion times out and wedges the engine (T8132, T8140)

2 participants