Repository navigation
Conversation
With the ISP's endpoint set, the H16 firmware asks the host to map the ISP's surfaces into its domain by the ID the ISP firmware got for each of them: a SHAREDMALLOC request with zero DVA and size, and the ID in the third word. The host answers with the DVA (bit 0 set), the size and the ID. The firmware gives a surface back with an ordinary FREE of its DVA, answered 1, 0, 0. Add optional peer_map and peer_unmap transport ops for that. A FREE of a DVA the peer does not know stays an ordinary FREE. The request and answer shapes come from a written summary of a hypervisor trace of macOS 27.0 starting the camera on a J616s. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
On the J616s the ISP firmware runs its ML video noise reduction (MLVNR)
on the ANE. When the camera starts, macOS gives the ANE firmware the
ISP's endpoint with these IO commands, each answered in place:
MCACHE_SIZE_GET (0x0026) the firmware answers the mcache size it
wants (0x300000)
MCACHE_DSID_SET (0x002e) a count of 2, then (3, 0) for the
prefetch and (4, 0xe) for the
intermediate spill of the networks
LOAD_AFPP (0x0205) the ISP's networks, one buffer
IPC_ENDPOINT_SET2 (0x002a) endpoint index, the ring the engine
reads, the ring it writes, the ISP's
doorbell and its value
and when it stops, IPC_ENDPOINT_UNSET2 (0x002b), after which the
firmware asks to unmap the ISP's surfaces, then UNLOAD_AFPP (0x0206).
Add the commands and the session calls for them. Gating stays off while
an endpoint is set, since the ISP hands the firmware work on its own.
The firmware is served outside any request, as the ISP's work runs while
no host request waits: SHAREDMALLOC for the ISP's surfaces, and its
reports on IO_T2H, each of which holds one of its command slots until
read. A failed command logs its ID and prints the firmware's log before
the recovery boots it again.
The command names are from macOS's ANE driver log (27.2.1, request and
teardown lines), the layouts from written summaries of hypervisor traces
of macOS 27.0 starting the camera on a J616s. Three facts are from runs
on the J616s, through the firmware's own log: the networks must be
loaded before SET2 (it asserts "AFPPLoaded" otherwise), the spill DSID
must be set (it asserts "afppInterSpillDsid != (0xFF)" on the first
frame otherwise), and its reports must be read while the ISP runs (it
asserts "out of command cache" within seconds otherwise). The ring
order is from the same runs: with the ring the engine writes first, the
firmware takes the ISP's doorbell but never reads its ring.
Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Add <linux/soc/apple/ane.h> for the ISP driver: it finds the engine by its apple,ane phandle and attaches its two rings, its doorbell and its networks file. The engine then stays up (a runtime PM reference), the rings and the networks are mapped, the endpoint is set up with the spill DSID from the platform data, and the engine's doorbell for the ISP goes back to the ISP: engine window + 0x1660000, value 1 on the J616s, as macOS gives them to the ISP firmware there. The firmware's map requests and reports come while nothing waits, so with a peer attached the channel IRQ queues a work item that serves them. Peer surfaces come from the program window and are unmapped when the firmware frees them or the peer detaches, which also unmaps the rings and the networks. A device link orders system sleep: the ISP suspends first. The doorbells and the spill DSID are those macOS uses on the J616s (its camera and ANE driver logs, and a written summary of a hypervisor trace of macOS 27.0 there). Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
The ISP firmware runs its ML noise reduction on the Neural Engine; the ADT links the two (isp0's function-ane_ep_control, -data_param_set and -data_param_get point at ane0). Describe that link. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
A crashed firmware is forced off: the stop command times out ("coproc
not in WFI"), so the firmware never sends the camera module its
power-down. The sensor stays powered, and its green status light stays
on until the next camera use. Seen on J815 (2026-11-21) after an ISP
firmware assert.
On hardware whose firmware starts again (hw->fw_restart), a halt after
an IPC error now schedules fw_recover_work. It boots the firmware once
more and stops it the normal way, which
powers the module down. It runs once: a second crash is left as it is.
On J815 the light went off after the crash, and the log said "crashed
firmware: restarted and stopped it to power the camera down".
Signed-off-by: Nick <nekreshen@yandex.ru>
(cherry picked from commit 69dc771)
The ISP firmware runs MLVNR, its ML video noise reduction, on the Neural Engine. When the camera starts, macOS loads the camera's networks into the ANE, gives the ANE firmware the ISP's two 16 KiB rings and the ISP's doorbell, and then gives the ISP firmware the same rings and the ANE's doorbell (CISP_CMD_IPC_ENDPOINT_SET2). Without it the ISP firmware's ANE client is never set up, and MLVNR asserts in its allocator. Do the same after START when the device tree links the ISP to an ANE that is up (apple,ane) and the networks are installed: apple/ispane-<board>.afpp, macOS's /System/Library/Isp/afpp/<board>/ ispane.afpp from the Mac's own install, read once. On T604x the ANE may write the ISP's doorbell (t604x.dtsi). Without the file, the link or the ANE, one line says so and the camera runs as before. - The ANE firmware names the ISP's surfaces by the ID the ISP firmware got for each at SHAREDMALLOC, which macOS hands out there; hand out IDs too. A surface the ANE still maps is freed only once it lets go. - Before the firmware stops, it unsets the endpoint, and the ANE detaches while the ISP is still powered: until then the ANE firmware may ring the ISP's doorbell, and an access to the powered-down block would hang the fabric. - The camera must work without MLVNR: a stream that fails to start with an endpoint no stream has used yet, or a firmware that has to be stopped by force with the endpoint attached, ends the endpoint until the driver loads again. The sequence and the values are from macOS's camera and ANE driver logs on the J616s (27.2.1) and the ISP firmware's own log of the commands it receives, on macOS and on Linux. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
The restart that powers the camera module down after a crash only ran
when an IPC error was set at the halt. A firmware that hangs without
one is forced off too: on J616s, with the ISP firmware's ANE client
stalled, the stop command timed out ("IO: failed to send OPCODE
0x0101", "firmware did not stop, stopping the coprocessor") and the
camera light stayed on until the next camera use. No IPC error was
set, so no restart followed.
Schedule the restart whenever the stop was forced. That covers the IPC
error case too: a firmware with an IPC error takes no stop command, so
its stop is always forced.
The restart work was cancelled before the last halt in remove, the
failed probe and shutdown, and before the halt in
apple_isp_firmware_flush(): a forced stop there left it queued, to
boot firmware on a removed device. Cancel it after those halts.
Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
macOS configures MLVNR on the J616s before each stream with APPLE_CH_MLVNR_MODE_CONFIG_SET (0xc11f): automatic (2), entering at a total gain of 3584 and leaving below 2816, at 30 fps either way, fading out over 30 frames. The ISP firmware logs these words under those names when it receives them. Send the same when the ANE endpoint is set, with the thresholds per sensor (the IMX958), whichever setfile is loaded. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
The ISP firmware runs MLVNR on the Neural Engine (ADT isp0's function-ane_ep_control, -data_param_set and -data_param_get point at ane0). The ANE's address filter already lets it ring the ISP's doorbell (0x581668000), and the ISP's the ANE's (0x485660000). Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Extend the H17 cold-boot ANE backend (ane_fw_cold) with the same ISP peer endpoint support that ane_h16_backend provides for T604x: - Implement ane_fw_cold_peer_find(), ane_fw_cold_peer_attach(), and ane_fw_cold_peer_detach(), mapping the ISP's rings, AFPP networks, and SHAREDMALLOC peer surfaces into the ANE DART window and draining IO_T2H reports via peer_work while attached. - Dispatch apple_ane_get()/put()/peer_attach()/peer_detach() across both ane_h16_backend and ane_fw_cold. - Populate T8142 platform data (irq_role = ANE_FW_IRQ_CHANNELS, peer_doorbell = 0x1660000 from J813 ADT dart-isp dapf-instance-0 0x421660000..0x421660003, peer_doorbell_value = 0x1, peer_spill_dsid = 0xe). Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Wire the T8142 ISP-side peer doorbell (0x4a1668000, value 0x10, matching J813 ADT dart-ane dapf-instance-0 0x4a1668000..0x4a1668003) into apple_isp_hw_t8142. On J813, the IMX958 ispane-j813.afpp archive contains 11 compiled MLVNR networks covering full-resolution sensor modes (including 3040x2880 and 1920x1080) and none for the 2x2 binned 1520x1440 mode. Configuring MLVNR on a 1520x1440 preset triggers a NetInputCheck firmware assert (actual: 3072, 1440; CMLVNRProcImp.cpp:1046) as soon as gain crosses enter_gain. Explicitly disable MLVNR (mode 0) when streaming IMX958 at 1520x1440 and add a KUnit test covering the guard. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
…ig 7 Link the J813 ISP node to the H17 ANE (apple,ane = <&ane>) and restore the full-resolution config 7 (3040x2880) sensor presets so the ISP firmware can run MLVNR on the ANE, with centred two-thirds-width crops inside the ultra-wide IMX958 lens's illuminated circle (matching J714s and avoiding dark outer corners while keeping every preset >= 1920x1080). J813 previously switched from config 7 to 2x2 binned config 8 (1520x1440) to reduce indoor noise without MLVNR, but ispane-j813.afpp has no network for 1520x1440. With MLVNR active on config 7, J813 achieves lower luma and chroma temporal noise than binned config 8 (1.07 vs 1.69 luma std, 0.23 vs 0.53 chroma std) while keeping full 3040x2880 sensor resolution. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
sithglan
force-pushed
the
feat/t8142-mlvnr
branch
from
December 5, 2026 09:04
3e5b89f to
424b841
Compare
Lower the IMX958 MLVNR enter/exit gain thresholds from 3584/2816 (14x/11x gain) to 200/100 (below 256 = 1x unity gain) so MLVNR runs in indoor daylight as well as low light. On J813 config 7 (3040x2880), normal indoor lighting stays below 3584, leaving unbinned frames visibly grainier (luma_std 4.11, chroma_std 1.05) than binned config 8 (1.69 / 0.53). Keeping MLVNR active reduces noise to luma_std 1.07 / chroma_std 0.23 across all lighting at a measured system power cost of ~0.65 W while streaming (7.65 W vs 6.98 W on macsmc_hwmon Total System Power; 0 W once closed and the ANE parks). Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Contributor
|
@sithglan, J815 notes for this stack. They come from our own J815 ISP↔ANE driver (same T8142 H17 cold-boot ANE), not from your head. I can't boot your head on the J815 today, and I'll post a Tested row for it when I can. J815 data (our driver, 7.3 nightly):
In the
Would you rather fold 1, 3 and 5 into this PR, or have me send them as patches on top once I've run them on the J815? |
Document the optional apple,ane phandle property on T8140/T8142 ISP nodes so CHECK_DTBS passes for t8142 boards linking the ISP to the ANE for MLVNR, matching Documentation/devicetree/bindings/media/apple,isp.yaml. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: Stacked follow-up on #4445 (commits
e22360f6fe0d..336dcaaa5435on top of #4445c9e775b7f51f) extending ISP↔ANE MLVNR to M5 (T8142: J813/J815/J704) on the H17 cold-boot ANE backend (ane_fw_cold), guarding against configuring MLVNR on 2×2 binned IMX9581520x1440presets, restoring full-resolution config 7 (3040x2880) sensor presets int8142-j813-isp.dtsiwith centred two-thirds-width crops inside the ultra-wide IMX958 lens circle (matching J714s, eliminating dark outer corners while keeping every preset >= 1920×1080), and lowering the IMX958 MLVNR thresholds from3584/2816to200/100so MLVNR stays active in indoor daylight as well as low light.Tested: J813 M5 MacBook Air (
aura 1.0.0b18-100-g99488019Stage 1 → Stage 2ESP_STAGE2=1,7.3.0-aurora-j813-mlvnr+,apple/ispane-j813.afpp12,951,616 bytes):200/100) active from boot (appledrmDCP +apple,ane-cold-boot = raw-no-xnu-ane-untouched-v1):1280x720,1440x1080,1080x1080,1920x1080,640x480,1080x1920,1760x1328,1328x1760,1552x1552,1280x960,960x1280,2024x2024).<508 870 2024 1140>for 16:9) eliminated dark circular lens corners on live 1080p capture (50×50 corner luma mean:TL=130.1, TR=179.0, BL=198.7, BR=115.9vsTL=29.1, TR=38.1, BL=15.8, BR=15.7on full-width<0 584 3040 1710>).ane_fw_cold(mcache 0x300000,SHAREDMALLOCsurface map/unmap, cleanH17 peer endpoint unset+ ANE idle park/unpark, 0 DART/ANE/ISP/DCP faults).200/100thresholds:29.96 fps, ANE IRQs+199over 50 frames (~120 IRQs/s), measured system power delta (macsmc_hwmonTotal System Power, ABA):7.35 W/7.94 W(mean7.65 W) ON vs6.98 WOFF (~0.65 W while streaming,0 Wonce closed and ANE parks).1280x720 NV12, 60 frames) on config 7 (3040x2880) and config 5 (1920x1080):luma_std=1.071,chroma_std=0.227, ANE IRQs+229,Load Program 0.6–0.7 ms, 0 asserts (5/5 consecutive start/stop cycles clean).luma_std=4.113,chroma_std=1.053, ANE IRQs+0.luma_std=1.674,chroma_std=0.341, ANE IRQs+150, 0 asserts vs OFFluma_std=3.285,chroma_std=0.957.1520x1440binned) OFF:luma_std=1.694,chroma_std=0.533.1520x1440(config 8) hitsNetInputCheck, 1046: wrong input buffer size: actual: 3072, 1440→ASSERT: CMLVNRProcImp.cpp:1046once gain crossesenter_gain, and that#4445's forced-stop restart cleanly recovers the camera and turns off the indicator light.336dcaaa5435:make W=1clean ondrivers/accel/ane/,drivers/media/platform/apple/isp/, and all three T8142 DTBs (t8142-j813.dtb,t8142-j815.dtb,t8142-j704.dtb); KUnit (arm64 QEMU):apple-isp67/67 PASS (includingisp_test_mlvnr_binned_disabled),accel/ane(transport.kunitconfig) 343/343 PASS;checkpatch --strict0 errors, 0 warnings, 0 checks across all 4 commits.Risk: two-way — T8142-only platform data + shared
t8142-j813-isp.dtsi(J813,J815,J704; all three DTBs compile cleanly, hardware verified onJ813, boards withoutispane-<board>.afppstill stream on config 7 without the ANE endpoint), an additive IMX9581520x1440MLVNR disable guard inisp-cam.c, and lowering the IMX958 threshold from3584/2816to200/100(~0.65 W extra power while streaming, 0 W idle).Not yet: Rebase onto
mainafter #4445 merges and collect live J815/J704 confirmation (or confirmispane-j815.afpp/ispane-j704.afpponce aurora-silicon/aurora-installer#355 lands).