Skip to content

media: apple: scaler: M3 family engines, keep CAPTURE at the OUTPUT size - #2804

Draft
RyanTheTide wants to merge 6 commits into
mainfrom
m3-media/scaler-v2
Draft

RyanTheTide wants to merge 6 commits into
mainfrom
m3-media/scaler-v2

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What: media: apple: scaler: M3 family engines, keep CAPTURE at the OUTPUT size. This PR now carries these drafts as one feature (merge commits, the commits themselves unchanged):

Tested: each part as tested on its own PR (folded bodies below; no hardware row on this head yet). Combined with current main (ba29027) together with the other folds of 11-25: full arm64 build (Image, modules, dtbs; fleet89 config, clang 22, rustc 1.97.1) clean.

Risk: two-way · M3, M3 Pro/Max/Ultra (scaler)

Not yet: a scaler row on an M3 Mac (J615) on this head.

#2804 original description

Replaces #2429 (same change, commit trailers fixed). It sits on #2793 (which replaced #2252) and merges after it.

Stacked on #2793 (M2 Pro/Max/Ultra engines): this branch contains #2793's three commits (head 6f0d2c1) plus one M3 commit. Review only the top commit; merge after #2793.

Problem

The scaler (MSR) driver matched no M3-generation engine, so the disabled scaler and scaler-DART nodes for T8122, T6030, T6031/T6034 and T6032 (added by Ryan Murray in 982f330 and 4c28191) had no driver and stayed off. The rule is that a block is on by default on every machine that has it, chosen by a hardware property, with no per-chip copies of the driver.

Change

  • Driver: two variant entries keyed on the MSR hardware version: 16 (T8122: three ranges) and 17 (T6030, T6031, T6032: four ranges, the extra one being the PMGR-facing range of the later engines). apple,t6031-scaler and apple,t6032-scaler reuse the T6030 data, so there is no per-chip code. Both run the common job that hardware-version 12/13/14 engines already run, without the MSR20 control block.
  • DT: enable the existing scaler and scaler-DART nodes in the SoC dtsi files: one engine on M3 and M3 Pro, two on M3 Max (T6031 and T6034), four on M3 Ultra (two per die). Every board of each SoC has these engines, so no board files change.
  • Binding: apple,scaler.yaml already lists the M3 compatibles. This adds tighter limits: exactly three ranges on T8122, four on T6030/T6031, and both DART streams on all three.

Testing

  • make W=1 drivers/media/platform/apple/scaler/ (arm64, LLVM): in progress at PR time (the first attempt failed in modules_prepare on a Rust bindings error from the shared config, so it is being rebuilt with Rust off). The result will be posted as a comment.
  • All M3 DTBs (T8122 x8, T6030 x2, T6031/T6034 x4, T6032 x1) built before and after: T8122 (7 DTBs) and T6031/T6034/T6032 (5 DTBs) build with 0 new dtc warnings, and the only change is the status of the scaler and scaler-DART nodes (2 lines on T8122, 4 on T6031/T6034, 8 on J575d). The two T6030 DTBs (j514s, j516s) fail in dtc both before and after this change, on the float literals in t6030-gpu.dtsi:102, which this PR does not touch, so the T6030 nodes were checked in the source only.
  • Binding: dt-doc-validate and yamllint pass. The J615, J514c, J575d and J516m DTBs pass dt-validate against the updated schema, and a J615 DTB edited to give the scaler four ranges is rejected as expected.
  • KUnit apple-scaler (arm64): not run yet. The tests cover the CSC, format and job tables, not the match table, and this PR does not change any of them.
  • The node values were checked against the ADT of each M3 board and against our own IODeviceTree capture of a J615 under macOS 27.2.

Still to run

  • Scaler module W=1 result and scaler KUnit (posted as a comment when done).
  • T6030 DTB build once the t6030-gpu.dtsi float literals are fixed.
  • No M3 hardware test yet: the M3 Air (J615) is still in macOS. On first boot, the J615 row needs one probe line (hardware-version 16 and the engine id) with no DART faults, v4l2-compliance -s, and NV12/P010 to BGRx plus BGRx to NV12 at 1080p compared with a software reference. If the first job times out, the first thing to test is the MSR20 control block (see below). M3 Pro/Max/Ultra rows will come from community owners.
Per-SoC hardware facts (ADT of each board)
SoC boards engines hw-version MSR range ranges IRQs DART
T8122 j433 j434 j504 j613 j615 scaler0 @31d000000 16 0x30000 3 751, 753 @31d200000 irq 752, SID 0 pixel / 1 PIODMA mapper
T6030 j514s j516s scaler0 @391000000 17 0x30000 4 (+@390000000 0x8000) 860, 862 @391200000 irq 861
T6031/T6034 j514c j516c j514m j516m scaler0 @407000000, scaler1 @3c7000000 17 0x30000 4 1291/1293, 1297/1299 @407200000 irq 1292, @3c7200000 irq 1298
T6032 j575d scaler0-1 on die 0, scaler2-3 on die 1 (same offsets, die-1 AIC) 17 0x30000 4 as T6031 per die as T6031 per die

Power domains: the DT nodes use the MSR (or MSRn) pwrstate and the MSR ASE core below it. The PMGR device list confirms both (T8122 0x428/0x498, T6030 0x508/0x560, T6031 MSR0 0x518/0x590, MSR1 0x508/0x538). The ADT MSR-V and MSRn-DART gates are aliases of those same pwrstates, so the DART node's MSR domain is correct. The SOC-VNOM/VMAX entries are performance votes, not power domains, and are not modelled. Only status changes in the DT.

Compared with the engines the driver already supports:

  • hardware-version 10-14: 0x28000 MSR range, 2-3 ranges, common job only
  • hardware-version 16/17: 0x30000, 3 (T8122) or 4 (T603x) ranges
  • hardware-version 20-22: 0x38000, 4 ranges, common job plus the MSR20 control block at 0x2e300
Open question: the MSR20 control block on hardware-version 16/17

The M3 MSR range (0x30000) is large enough to hold the 0x2e300-0x2e318 words that the MSR20 engines program. The hardware description shows the size of the range but not which blocks are inside it. This PR uses the job that hardware-version 12, 13 and 14 engines run without that block, because more generations have been tested with it. A wrong guess fails safely: the job times out (500 ms watchdog), the engine is reset, and the buffer is returned with an error. If the J615 times out, the next step is a one-line test build with .msr20 = true in apple_scaler_t8122.

The scaler DARTs keep the full DART input address space, as on T8112 and T8132. The ADT DVA window (base 1 TiB) is not added as apple,dma-range until a DART probe on M3 confirms the input address width.

#2971 original description

Problem

An odd RGB OUTPUT size can be paired with a 4:2:0 CAPTURE format that rounds one or both dimensions up. The format ioctls succeed, but the same-size hardware job builder rejects the pair.

Change

Keep the active OUTPUT dimensions. Use the existing RGB fallback when the requested CAPTURE format cannot represent those dimensions. TRY_FMT, CAPTURE S_FMT and CAPTURE revalidation after OUTPUT S_FMT use the same helper.

Testing

Stock J413 fleet85 reproduced four format failures on the 13.5 stub. All three compatible controls passed, with zero new kernel errors, SELinux AVCs or failed units. J413 stock row

Format and build results
Check Stock Candidate
Host format and bounds 7/10 10/10
Host CAPTURE-first and queue state 4/5 5/5
J413 format ioctls 3/7, including CAPTURE-first G_FMT at 642 × 482 NV12M for 641 × 481 OUTPUT Pending
ARM64 fleet85 module Reference source W=1 build, modpost, BTF and signature passed

The native and emulated ARM64 host harnesses execute the scaler format callbacks and the V4L2 multiplanar fill helper. They use simulated format metadata and queue state. The candidate's CAPTURE-first sequence returns 641 × 481 ARGB32, and the four compatible state controls agree. Strict checkpatch reported zero errors, warnings or checks.

Still to run

Run the signed-candidate ioctls and stream a CAPTURE-first frame on the default command line. Run the stock and candidate controls on J473 and other available Macs with the scaler. Check kernel errors, AVCs and failed units.

…ery laptop

The AOP accelerometer and gyroscope children were described only in
t6000-j316s.dts and t8112-j413.dts, the two machines whose Apple device
trees were at hand. The other 14" and 16" M1 Pro/Max MacBook Pros
(J314s, J314c, J316c) and the other M2 laptops (J415, J493) share the
same AOP and are left without them.

Nothing in the description is board specific. The AOP core creates a
service device only when the firmware announces the "accel" or "gyro"
service, and gives it the AOP child of the same name. The driver then
starts the sensor only with the calibration the bootloader copies into
that child from the Apple device tree, and returns -ENODEV with one
info line otherwise. On a machine without the sensor the child stays
unused.

Move the children to t600x-j314-j316.dtsi, next to the AOP enable of
every M1 Pro/Max laptop, and to the AOP node in t8112.dtsi, next to the
las and als services that are already there. The T8112 Mac mini (J473)
keeps its AOP disabled, so the children are inert there.

The J316s and J413 DTBs are byte-identical before and after.

Fixes: 165f4bd ("arm64: dts: apple: describe reference Mac motion and peripheral endpoints")
Signed-off-by: Ryan Murray <[email protected]>
The Mac Pro's die 0 HDMI port has its audio controller (dpaudio1)
enabled, and that controller takes its DMA from the die 0 SIO. The
loader sets up and enables each SIO it finds through an alias, and
t6022-jxxxd.dtsi only aliases the die 1 SIO (sio1), so the die 0 SIO
stays disabled and the die 0 HDMI port has no audio.

Add the sio alias for the die 0 SIO. The Mac Studio (J475d) is not
changed: all its display outputs, and their audio, run from die 1.

This is the SIO hunk of linux#1115, split from that PR's Neural
Engine changes so it can be reviewed on its own.

Signed-off-by: Ryan Murray <[email protected]>
The scaler matched T8103, T6000, T8112 and the M4/A18 Pro engines, but
not T6020, T6021 or T6022. Their device trees describe the MSR engines
(one on M2 Pro, two on M2 Max, four on M2 Ultra) and keep them disabled
because nothing would bind.

The driver needs two things from a variant: the number of register
ranges and whether the engine has the MSR20 control block (M4 and
later). The T602x nodes have the T8112 register map: three ranges of
0x28000, 0x4000 and 0x4000 bytes at +0, +0x210000 and +0x204000, two
DART streams, and the "apple,scaler" fallback. The scaler binding
already puts apple,t6020/t6021/t6022-scaler in the same constraint
group as apple,t8112-scaler. They are M2-generation engines, before
MSR20. Use the T8112 data for them.

Enable the engines and their DARTs in the T6020, T6021 and T6022
peripheral trees, so every board with the SoC gets them. The DARTs name
the MSR domain of their own die since
commit 4109497 ("arm64: dts: apple: t602x: give the scaler and external DCP DARTs their power domains"),
so the DART's first register read finds its block powered.
The engines additionally vote the T602x media fabric domain (ps_afr),
which the driver links through its power-domain list.

T8103, T6000/T6001/T6002 and T8112 device trees are unchanged.

Signed-off-by: Ryan Murray <[email protected]>
The scaler driver did not match the M3 generation, so the disabled
scaler and scaler-DART nodes Ryan Murray described for T8122, T6030,
T6031 (also used by T6034) and T6032 in 982f330 and 4c28191
had no driver and stayed off.

The M3 engines report hardware-version 16 (T8122) and 17 (T6030, T6031,
T6032) in the hardware description of every M3 board. Compared with the
engines the driver already knows:

  - MSR aperture 0x30000: larger than the 0x28000 of hardware-version
    10 to 14, smaller than the 0x38000 of the MSR20 engines (20 to 22).
  - Two interrupts (MSR, PIODMA) and a T8110 DART with the pixel stream
    at SID 0 and the PIODMA mapper at SID 1, as on every other engine.
  - T8122: three register ranges like T6000/T8112. T6030/T6031/T6032:
    the fourth, PMGR-facing range of the later engines.

Add one variant for each hardware version and run them on the common
job without the MSR20 control block, the job that hardware-version 12,
13 and 14 engines already run. Whether hardware-version 16/17 also has
the MSR20 block inside its larger aperture is not visible in the
hardware description; a job that does not complete is caught by the
500 ms watchdog.

Enable the scaler and its DART in the SoC dtsi files: one engine on
M3 and M3 Pro, two on M3 Max, four on M3 Ultra (two per die). Every
board of each SoC has these engines. The existing nodes were checked
against the hardware description of each board and our own
IODeviceTree capture of a J615: register ranges, interrupts, DART SIDs
and the MSR / MSR ASE core power domains all match, so only the status
changes.

In the binding, require exactly three ranges on T8122, four on
T6030/T6031, and both DART streams on all three.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at b693335 (non-author, draft). Blocked on #2793 (its three commits are underneath; top commit reviewed only). No blocker in the delta itself, but it should not leave draft before one M3 machine has booted it.

  • The branch contains arm64: dts: apple: AOP motion sensors on every laptop, J180d die 0 SIO alias, M2 Pro/Max/Ultra scaler #2793's current head 6f0d2c1, and merges cleanly on integration/aurora 6748d83. The top commit has human trailers only.
  • Driver: two new variant entries, hardware-version 16 with three ranges and 17 with four; T6031 and T6032 reuse the T6030 entry. Selection is by the block's compatible. hw_version is only printed; num_reg is the only field that changes behaviour (probe refuses a node with fewer ranges), and msr20 stays false.
  • DT: only status changes. The nodes at the head match what the variants expect: T8122 scaler0 has three ranges and power-domains = <&ps_msr>, <&ps_msr_ase_core>; T6030 and the T6032 engines have four; each scaler DART is in the matching MSR domain; both DART streams are listed.
  • Binding: the new rules sit inside the existing M3 branch and agree with the nodes (three ranges for T8122, four for T6030/T6031, two iommus).

Small points, not blocking:

  • The four-range rule lists apple,t6030-scaler and apple,t6031-scaler but not apple,t6032-scaler, although the T6032 nodes use "apple,t6032-scaler", "apple,scaler" and the driver requires four ranges for it. Add it to the enum.
  • This turns a DART and an engine on for every M3, M3 Pro, M3 Max and M3 Ultra board without a boot on any of them. A DART that probes in the wrong power state takes the machine down early in boot, not just the scaler, so the J615 row (probe line, no DART fault, v4l2-compliance -s, one NV12/P010 conversion against a software reference, s2idle with the device bound) should be in before merge. The body still says the J615 is in macOS; please update it.
  • The MSR20 question in the body is open by design. If the first J615 job times out, please record the watchdog line and the result of the .msr20 = true build in this PR either way, so the T603x owners know which variant they are testing.
  • Still to run per the body: the W=1 module build and scaler KUnit result (promised as a comment, not posted yet), and the two T6030 DTBs, which currently do not build for an unrelated reason, so their scaler nodes are checked in source only.

Assisted-by: LLM (Claude:Opus 5.5)

An odd RGB OUTPUT size and a 4:2:0 CAPTURE request round the CAPTURE
dimensions up. The format ioctls succeed, but the job builder rejects
the resulting unequal-size pair.

Keep the active OUTPUT dimensions for CAPTURE and use the existing RGB
fallback if the requested format cannot represent them. Preserve
compatible format requests and existing OUTPUT negotiation.

Signed-off-by: Ryan Murray <[email protected]>
…PUT size

Folds #2971 into this PR unchanged.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide RyanTheTide changed the title media: apple: scaler: add the M3, M3 Pro, Max and Ultra engines (on #2793) media: apple: scaler: M3 family engines, keep CAPTURE at the OUTPUT size Nov 25, 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant