Repository navigation
Add the J714c (M5 Max) front camera - #422
edimoldovan wants to merge 46 commits into
Conversation
The T6050 SART keeps the per-entry config, physical address and size words in three arrays at 0x00, 0x60 and 0xc0. Addresses and sizes are in 4 KiB units, sizes up to 30 bits. Add the v4 accessors and match "apple,t6050-sart". Tested on J714c (MacBook Pro 14-inch, M5 Max) in the bring-up tree these changes come from: the NVMe controller's SART ranges are read and the internal SSD works. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The T6050 cluster performance controllers take the same commands and report the same state as T8142's. Match "apple,t6050-cluster-cpufreq" with the T8142 data. Tested on J714c (MacBook Pro 14-inch, M5 Max) in the bring-up tree these changes come from: cpufreq on all three clusters. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On T6050 the coprocessors come up with the handshake the boot loader uses: - the system endpoints start in the loader's order (debug, crashlog, syslog, ioreport, oslog), and tracekit is not started; - oslog notifications are not acknowledged, as on T8140 and T8142; - the boot waits until the IOP reports the ON power state, since it can acknowledge intermediate states first; - the AP power state ACK gets a 200 ms window and is not required: the loader never waits for it, and macsmc starts its endpoint right after the wake, before the SMC ACK arrives. All four are limited to "apple,t6050" machines. Tested on J714c (MacBook Pro 14-inch, M5 Max) in the bring-up tree these changes come from: ANS boots and the internal SSD works. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The T6050 ANS2 takes the T8140 queue setup with three differences, all behind a new keep_cc_fields flag in its hardware description: - the boot loader hands the controller over disabled while the RTKit session stays live, so an enabled CC with no fatal status is enough to adopt it; - the controller reports ready only when CC keeps the entry-size fields the firmware set (IOSQES 7, 128-byte entries), so the enable keeps them instead of composing CC in nvme_enable_ctrl(); - the admin queue uses the full queue depth, the linear submission queue enable is ORed into the register, and the NVMMU TCB bases, ASQ, ACQ and AQA are written in the loader's order. Match "apple,t6050-nvme-ans2". Tested on J714c (MacBook Pro 14-inch, M5 Max) in the bring-up tree these changes come from: the internal SSD holds the Omarchy root file system. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The T6050 MTP firmware, like T8142's, waits for the AP power state before it acknowledges its own power state. Wake "apple,t6050-mtp" with apple_rtkit_wake_early_ap() as "apple,t8142-mtp" is. Tested on J714c (MacBook Pro 14-inch, M5 Max) in the bring-up tree these changes come from: the MTP boots and the keyboard and trackpad work. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Probe initialised critical_work twice: once through devm_work_autocancel() and again, with dbg_log_work, after blocking_notifier_chain_register(). An SMC critical-battery event arriving between the two would have its queued work re-initialised under the workqueue. Initialise both before the notifier is registered and drop the second INIT_WORK(). Link: https://github.com/rolotrealanis98/m5pro-linux/blob/main/contrib/pending/smc/patches/linux/0011-power-supply-macsmc-power-init-work-before-notifier.patch Signed-off-by: Rolando Trevino <rolotrealanis@gmail.com> Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Before its display coprocessor driver runs, a built-in Apple panel is a simpledrm framebuffer whose connector is Unknown-1. Omarchy treats every connector that is not eDP, LVDS or DSI as an external monitor, so closing the lid kept the session in clamshell mode instead of locking it. Give a framebuffer node with apple,internal-panel an eDP connector. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the T6050 (M5 Max) SoC and the MacBook Pro (14-inch, M5 Max) board to the Apple platform binding, and the T6050 compatibles to the bindings of the blocks its device tree describes: PMGR and its power states, ASC mailbox, cluster cpufreq, I2C, DART, AICv3, watchdog, FPWM, GPIO, ANS2 NVMe, SART, SPMI, the abbey PMIC NVMEM, SMC, MTP and DockChannel. Its CPU cores are "apple,sotra". Where the device tree keeps an intermediate fallback the drivers match (the MTP DART and AIC on T8142, the GPIO block and NVMe on T8140), the binding lists the T6050 chain as it is. The T6050 NVMe controller has the NVMMU region of T8132 and a fourth power domain, the PCIe lane PHY of its storage link. simple-framebuffer gains apple,internal-panel, which marks a framebuffer as an Apple laptop's built-in panel. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the Apple T6050 (M5 Max) SoC and the 14-inch MacBook Pro with it (J714c), from the J714c Apple Device Tree: - t6050-base.dtsi: 18 CPUs in two M clusters and one P cluster with their OPP tables, the timer and the reference clocks; - t6050-die0.dtsi: AICv3, the serial port, the six PMGR blocks, the cluster cpufreq controllers, the watchdog, the keyboard backlight PWM, the GPIO block, I2C1-3, and the MTP with its mailbox, DART and DockChannel; - t6050-pmgr.dtsi: 302 power domains. The four Type-C ports' CIO domains and atc3_common stay with the firmware: powering them at boot breaks the loader's USB 2.0 host setup; - t6050-nvme.dtsi: the ANS2 NVMe controller with its mailbox and SART; - t6050-smc.dtsi: the SMC with its GPIO, hwmon, RTC and (disabled) reboot children, and nub-spmi0 with the abbey PMIC NVMEM cells the RTC and reboot children read. Based on omarchy-m5's dt/t6050-smc.dtsi (github.com/betizzel/omarchy-m5, GPL-2.0+ OR MIT), with the full 0x4000 nub-spmi0 window from rolotrealanis98's m5pro-linux. nub-spmi0 is polled: the gen 4 SPMI driver has no interrupt support. smc_reboot stays disabled: its restart handler would take over from the watchdog's, and its PMIC scratchpad offsets are not verified; - t6050-j714c.dts: memory, the boot framebuffer marked as the built-in panel, the serial console, the keyboard and trackpad (trackpad firmware apple/tpmtfw-j714c.bin, power method 2 with firmware-managed reset: with power method 1 the MTP firmware answers the power-state request with "unknown power state"), the keyboard backlight (pwm-leds, 40000 ns period), and the SMC with the common, dual-fan and laptop sensors. The J714c SMC spells the fan mode keys F0md and F1md, so the board overrides apple,fan-mode. The keyboard and trackpad need the loader to program the MTP DAPF (m1n1 on T6050). Tested on J714c, this series booted over the resident m1n1 into the Omarchy root on the internal SSD: 18 CPUs with cpufreq on all three clusters, the MTP keyboard and multi-touch devices, the SMC power/lid input, kbd_backlight, AC and battery, the RTC, 13 hwmon inputs, and the panel as eDP-1. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The firmware's lens shading thread (FlowLSC200) faulted on every
CH_SET_FILE_LOAD on T6040, printing "SetLSParamFullImage baseHi
R=120" where macOS prints R=0, and reading 0xf00000 past the setfile.
A setfile is a chain of { size, 0, tag, payload } sections, and the
lens shading tables are described by 18-byte records whose fifth
halfword is the row stride (2 * width) in the xx24 setfiles. The H17
firmware reads that halfword as the high half of the table offset.
Apple's xx25 setfiles are their xx24 twins with exactly these
halfwords zeroed (7524 -> 7525 and 8824 -> 8825 match byte for byte
apart from the header version), and only xx24 files exist for the
IMX958 module, so macOS must zero them as well.
Do the same for H17 firmware after copying the setfile. Setfiles
that already have the field zeroed are left alone.
Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Assisted-by: LLM
(cherry picked from commit ed7b2a4 in aurora-silicon/linux)
Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
The T6040 (M4 Pro/Max) ISP is the T8140 coprocessor with the same H17
firmware interface: its register map in the macOS kext has the T8140
reset, control, fabric and interrupt words, and its firmware asks for
the 0x290-byte H16 boot descriptor. What differs is taken from how
macOS 26.6.2 boots it on the J616s (the firmware's own log of the boot
and of every command it receives) and from aurora's m1n1 proxy captures
on that machine:
- The firmware is started as iBoot left it, with no reset sequence.
The coprocessor must not have run yet and its reset vector must be
the firmware text at the base of the heap region; the driver checks
both instead of starting something else.
- No clock enable word, legacy boot mode 1 in GPIO 6.
- The boot descriptor carries the board's camera connection layout and
a 0xde600000-byte shared window, as macOS passes it.
- The broadcast-clear command takes four windows in eight slots, the
unused ones all ones. Generalise the H17 command to several windows;
T8140 still sends its single one.
- Like T8140, the firmware reaches PMGR, PMP and DSID registers through
its DART at their physical addresses, among them the clock and
bandwidth scratch words named in PMP_CTRL_SET and the broadcast-clear
bases. Map the J616s ADT's DART address filter ranges for the ISP
1:1, rounded out to 16 KiB pages.
- The firmware's main memory is 32 MiB at IOVA 0. iBoot loads __TEXT
and __DATA into it, and they end 80 KiB short of the top (0x1fec000
of 0x2000000). The rest is the host's to back, as macOS does; left
unbacked, the firmware's first writes there take DART translation
faults and it never answers its first command. Read the end of the
"data" memory-region and map zeroed pages from there to the heap top
for as long as the firmware surfaces live.
- Output goes through scaler 1, so the rendered pool is the scaler 1
pool, as the buffers submitted to it already were.
- There is no capture metadata pool or capture watchdog. Skip that
pool and its size check on H17 firmware that has none.
The front camera is an IMX958 (sensor 0x958, lens 0x29). Of the 32
setfiles in macOS's appleh16camerad, only module 2224 revision 01 names
it in section 0x50f, where each setfile names the sensor it tunes; 2924
and 2921 name the IMX614. With 2924 the firmware streams, but reports
a lens shading calibration for a 3744-pixel-wide sensor on every frame
("fullRes (3072 x 3024) lsCalibRes (3744 x 3024) not match!") and never
logs the module match macOS logs once the setfile has loaded. 2224
carries a 3072 x 3024 calibration. The file is 0x6ff4 bytes up to the
end of its section chain.
T6040 sets none of T8140's fw_iova_mask, mbox2_offset and
mbox_irq_route. The firmware's own addresses are at 0x100_0000_0000,
above the 36 bits T8140 keeps, so no mask is applied. Its doorbells have
a register window of their own in Apple's device tree, described as
"mbox2", instead of sitting inside the mailbox window. Only the base
interrupt enable is written; T8140's extra enable and routing words are
not needed on T6040.
Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Assisted-by: LLM
(cherry picked from commit 3161362 in aurora-silicon/linux)
Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
…aths Two changes in the T6040 series also act on the T8140 (MacBook Neo), which runs the same H17 firmware interface: - Commit ed7b2a4 ("media: apple: isp: Zero the lens shading strides of H17 setfiles") rewrites the lens shading records of every setfile loaded on H17 firmware. It was only seen to matter on T6040, and the T8140 camera streams with its setfiles unchanged. - Commit 3161362 ("media: apple: isp: Add T6040 support") reads a "data" memory-region for every SoC, maps zeroed pages above it, and fails the probe when it does not fit the heap. The T8140 regions come from the bootloader, and nothing has checked how that would behave there. Limit both to ISP_GEN_T6040, so the T8140 boot and capture paths stay as they were until they are tested on that machine. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 7d20cd4 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Port the processed config-5 preview command sequence from our m1n1 J616s work, with contiguous V4L2 P010 strides and pool geometry. Query all advertised H17 sensor configs and retain the board defaults while appending consistent output modes. Keep NV12 the default and scope the new path to T6040/IMX958. Retire output and metadata leases after the report ACK, restart an empty P010 queue on requeue, bound ring servicing and latch malformed or timed-out command replies. Add command-byte, geometry, ownership and ring-wrap coverage. These source corrections still require sustained capture validation on 26.6.2. Builds on Jonathan Goyvaerts’ T6040 camera support in PR omacom#384. Protocol reference: our m1n1 PR omacom#20 at 9be380c8a5 and Linux PR omacom#231 at a4e7ee8. No firmware payload is included. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit be1528a in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Check the command deadline before advancing the ring cursor, including when an ACK arrives at the wait timeout boundary. Keep the failed channel latched until coprocessor stop. Cover the boundary in KUnit. Emit the capture stress result after cleanup so a failed STREAMOFF cannot leave a passing result. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> [ed: dropped the apple-isp-stress selftest hunk: the selftest is not in this tree] (cherry picked from commit 3bd32e8 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Apply the empty-queue restart to both processed IMX958 formats. Exercise 10,000 empty-to-submitted transitions for each of P010 and NV12. Other sensors retain their queue policy. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit b17a883 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
The buffer wire carries 64-bit addresses, while the proxy observed zero-extended low words on its firmware. Accept either complete canonical pair for a submitted lease and reject mixed or unrelated upper bits. Keep pool, plane and fresh-tag checks. Also assert that NV12 stays first in format enumeration. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 946458f in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Remove the inherited multiplanar module parameter. T6040/IMX958 supports normal V4L2 negotiation for contiguous NV12 and P010 through either API, with one memory plane containing the two ISP components. Keep NV12 first and initial; other sensors retain their shipped single-planar API. Do not advertise the old non-contiguous NV12M alias. Cache complete sensor configuration replies with the video state and print them on the standard log-status ioctl, so collecting the firmware list needs no driver or boot parameter. Free the cache on probe failure and final video release, and test failed discovery without publishing partial state. No module/kernel parameters or platform Kconfig options are added. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit e7b7607 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Acquire the validity word, copy the complete message object after the DMA read barrier and restore that captured word. Copying seven payload words through the arg1 field violates FORTIFY field bounds. Cover all eight copied words and keep the ownership ordering unchanged. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit f57db61 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Remove the parameter-gated multi-planar hooks, which changed the queue type without reinitialising its cached plane semantics. Both contiguous NV12 and P010 use the existing single-planar queue. Keep format negotiation explicit through S_FMT. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 1bd911c in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
VIDIOC_REQBUFS fails with ENOMEM for P010 at any size and count, while NV12 works. The P010 rendered pool has two slots, and queue_setup limits the queue to the pool. vb2 allocates at least min_queued_buffers + 1 buffers, three with ISP_MIN_FRAMES, so __vb2_queue_alloc gets two and vb2_core_reqbufs returns -ENOMEM. P010 has failed this way since it was added; the IOVA allocator and the DART window are not involved (the two buffers map fine and are torn down again). Set the queue minimum from the format whenever S_FMT changes it, which only happens with no buffers: one queued buffer starts a P010 stream, so vb2 needs two. NV12 keeps ISP_MIN_FRAMES. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit e84b0b5 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
NV12 setup ignored every setfile error except EINTR, including a bad header, a short file and a rejected firmware upload. This made an unusable tuning file look like a stream running with model tuning. Keep absent tuning optional, but fail setup for other read, validation and upload errors. Log failed uploads and add a debug message for a successful upload. Exercise failure propagation and missing-file fallback at the capture setup boundary with KUnit static stubs. Distinguish model-wide sensor setfiles from per-module iCCl factory data in Kconfig and document the existing NR commands, P010 omissions and the unimplemented factory calibration/ANE interfaces. Do not change the qualified preview sequence or guess undocumented firmware parameters. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 64357f8 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
The preview fixture describes P010, whose flicker request has no output. The new tuning failure cases use NV12, whose existing flicker request returns a 12-byte record. Keep both expectations in the shared transport stub so the tests validate the appropriate command ABI. Clarify that a completed tuning upload is a transport result rather than proof that the firmware applied every coefficient; its NV12 reply fields remain undecoded. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 0ab62d2 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Userspace has no way to tell how hard the sensor is working. Gain is the signal a camera pipeline needs to decide when the picture is noisy enough to denoise, and the firmware already writes it into every frame's metadata buffer, which the driver maps but never reads. The metadata buffer opens with a table of section offsets. On H17 firmware the fourth section starts with the frame's exposure: the integration time in microseconds, then the total sensor gain in 1/256 steps with 256 as unity. This was established on T6040 and T8140 by watching auto exposure converge on a fixed scene, where the gain climbed from 260 to its final value once the integration time hit the frame period, and by stepping the frame rate, which capped the integration time at the frame period. Read the section when a metadata buffer comes back, through the table and bounded by the buffer size, and report the last values as read-only, volatile V4L2_CID_GAIN and V4L2_CID_EXPOSURE_ABSOLUTE controls. Only hardware whose match data says its metadata carries the report gets the controls. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 3c54411 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Add common call resolutions when an established processed crop contains an exact-aspect, chroma-aligned crop at least as large as the output. Keep the sensor configuration, pixel-format eligibility and original preset order, and avoid duplicate sizes. Also offer a sensor-sized square and smaller 4:3 outputs when larger call sizes do not fit. Do not use sensor input heights as output capabilities: they can include stacked exposures. Leave sizes requiring enlargement or unestablished crop extents unavailable. Add KUnit tests for geometry and size tables, and document enumeration and capture qualification. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit aaab795 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
The driver hands out its IOVA ranges with drm_mm, which is part of the DRM core, but VIDEO_APPLE_ISP does not depend on DRM. With DRM=n, or with DRM=m and the ISP built in, the drm_mm symbols are missing and the build fails at link time. A V4L2 camera driver should not need the DRM core for this. Track the ranges in a maple tree with MT_FLAGS_ALLOC_RANGE instead, indexed in IOMMU pages, and store the owning surface as the entry. mtree_alloc_range() returns the lowest free range, the bottom-up order the old comment asked for, and the tree has its own lock, so iovad_lock goes away. The range and the page granule are unchanged. The Kconfig entry also selects APPLE_PMP_REPORT, which depends on PM. Depend on PM so the select cannot leave that dependency unmet. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit f729605 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
A P010 command or buffer batch that timed out set ipc_failed. From then on every command failed with -EIO, and stopping the stream halted the coprocessor. T6040 firmware is resident and cannot be started again, so one timeout left the camera unusable until the next system boot. The latch guards against a real race. A timed-out request still owns its ring slot, and every request on the IO and BUF_H2T rings carries the same arg0, the command area address. A late answer would be taken for the answer to the next request written to that slot, and the firmware would then expect that request in the following slot. The next request would also overwrite the command area while the firmware may still read the old one. Keep the timed-out channel in ipc_stale instead. Before anything else writes the command area or a ring, isp_ipc_resync() rings the doorbell once more and waits up to one second for the late answer. If it comes, it is consumed, the cursor moves on and the ring is in step again, so the next command and the next stream work. If it does not, ipc_failed is set as before and the stream stop halts the firmware before its buffer leases are released. Both outcomes are logged once. Stopping the camera resolves a pending timeout the same way before it frees anything the firmware may still use. A buffer batch that timed out in buf_queue now errors the queue and keeps its leases until the stream stops, instead of halting the firmware straight away. An answered but malformed reply leaves the ring in step, so it fails only its own command. A fresh firmware boot clears both flags. Add KUnit cases for a late answer, for no answer at all and for a late ACK that must not answer the next request. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 504cb5d in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
On the H17 interface macOS does not start the ISP's temporal noise filter the same way for every sensor. For the IMX958 (J616s) it sends a longer start record, (1, 0, 0), then turns high-strength filtering and band 0 modulation off and sets the band 0 strength thresholds to 120 and 100 in 1/256 steps, before the motion history and the enable. For the IMX558 (J700) it starts nothing: it disables the filter and stops the motion history and the filter, since the firmware keeps that state between streams. These values come from Daybreak's reading of the macOS 27.0 camera stack. Linux sent the short start with the apple,temporal-filter value on every sensor, 1 on the J700. On the Neo, starting the filter with 0 instead of 1 already leaves about 13% less luma noise and 18% less chroma noise on a still scene. Keep the per-sensor choice next to the setfile of each sensor and leave every other sensor on the original sequence. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit 7f96113 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
The H17 firmware's auto exposure keeps exposure times in step with the mains frequency so that lights do not flicker or band in the picture. macOS tells it the frequency for every camera, 50 Hz unless the country uses 60 Hz, as Hz in 16.16 fixed point. Linux never sent it. Add the standard V4L2 power line frequency control on H17 hardware, 50 Hz by default as on macOS, and send it with the stream setup. It is applied when the stream starts, like the exposure priority. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> (cherry picked from commit e16d7ec in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
On T8132 the ADT gives the first ISP DART address filter windows for the fixed MMIO windows the ISP's coprocessor reaches, among them the ISP power states and the DSID broadcast-clear windows. The filter loses its windows whenever ISP_SYS is off and powers up with arbitrary contents. The camera streams with the filter cleared and with it left as it powers up, but program it as the ADT describes rather than leave it undefined. Take an optional per-SoC window list, find the filter registers on the first iommus DART, and program and verify the windows after every power-up, before the coprocessor starts. The windows lie inside the fw_mmio windows that the driver already maps into that DART for the firmware, so the list belongs next to fw_mmio; the DART driver itself has no use for them. Two KUnit cases check that every SoC's windows lie inside its fw_mmio windows, and the register image the writer produces. Signed-off-by: Erik Bourget <erik@ebourget.net> (cherry picked from commit 7e4f610 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Resident firmware is started at probe and runs while the driver is bound, so the ISP stays powered from boot even when the camera is never used. On the J713 (T8132) that costs about 100 mW, at idle and in suspend-to-idle. The video device can be registered without the firmware: its formats come from the device tree presets. Let a SoC defer the firmware start and the camera detection to the first stream start; from then on the firmware stays resident as before. Opening the device or listing its formats does not start it, as desktop services open every video node at login. On the J713 the deferred start, from power-up to a detected camera, adds about 0.2 s to the first VIDIOC_STREAMON. Deferring moves what detection checks to that first stream: an unsupported sensor, unexpected metadata sizes or a missing channel now fail it instead of probe, and leave the camera unusable until the next boot, like any failed resident start. Presets the firmware lacks can no longer be dropped from the formats userspace has already seen, so a stream on one is refused with -EINVAL instead. For the same reason a deferred start keeps the device tree presets: the IMX958 configuration discovery and P010 preview, which add formats at detection, stay with starts at probe. A KUnit case checks that only resident firmware defers its start. Signed-off-by: Erik Bourget <erik@ebourget.net> (cherry picked from commit 6d95eef in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
The T8132 (M4) ISP is T6040's: the same coprocessor layout, firmware interface and boot path, with the bootloader's firmware described as reserved memory. It differs in: - two AMCCs (ADT mcc amcc_aperture_count), so two DSID broadcast-clear windows, passed one per AMCC without padding slots; - no PMP_CTRL_SET: T8132's PMP scratch offsets are not established, and the camera streams without the command. The firmware's MMIO windows still cover those PMP registers; - the firmware's MMIO windows are also opened in the DART's address filter. The firmware is resident as on T6040 and T8140. A second start after its domains were cycled fails on T8132 too: the ISP CPU cores then do not reach their active power state. So it runs while the driver is bound, and T8132 defers its start to the first stream, keeping the ISP off until the camera is used. T6040 and T8140 have not been tested with the deferred start and keep starting at probe. Signed-off-by: Erik Bourget <erik@ebourget.net> (cherry picked from commit df3431c in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
…tart Firmware that the boot loader loads changes its data segment while it runs, and does not start again from that state. Add hw->fw_restore: probe keeps a copy of the data segment, taken before the firmware first runs, and every start puts it back and clears the firmware main memory above it. Stopping the firmware puts it back too, also after a start that failed, and a shutdown stops a stream and such firmware, so that a rebound driver or a kexec'd kernel finds the firmware as it was loaded. No SoC uses it yet. Signed-off-by: Erik Bourget <erik@ebourget.net> (cherry picked from commit 1ffdbc0 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Firmware that is started again after it stopped (hw->fw_restore) has to be stopped for good. SUSPEND leaves the camera module powered, with its light on, and it stays so even across a reboot. Send STOP before POWER_DOWN instead, which also powers the module down; POWER_DOWN follows even if STOP failed. This replaces the unused STOP sequence that was kept under #if 0. Some coprocessors also need a quiesce before their domains go down. Its CPU core domains otherwise stay busy after the power-down and never run again, so the next start of the firmware fails. Add hw->coproc_quiesce, the register whose bit 25 requests the quiesce and reads back once it has happened, and hw->coproc_status. With a quiesce register, the power-down of a coprocessor that was started waits for it to reach WFI, stops it, quiesces it, and only then powers its domains down. A start that fails after the coprocessor was started thus also leaves it ready for the next one. No SoC uses them yet. Signed-off-by: Erik Bourget <erik@ebourget.net> (cherry picked from commit b156325 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
T8132 firmware starts again after it stopped, from its data segment as loaded, once the coprocessor was quiesced before the power-down. Stop keeping it resident: restore its data before each start, quiesce it before each power-down, and power the ISP down after every stream, as the older SoCs do. The camera then costs nothing when it is not in use, not only until its first use, and can be used again after the firmware stopped (for example across hibernation). The deferred start no longer needs resident firmware, so it becomes deferred_start: the camera is detected at the first stream, which with firmware that starts again boots it a second time to stream. A deferred detection that fails is reported to the stream instead of deferring a probe. Metadata buffers are reset for each stream of firmware that starts again, as for resident firmware: none survives the restart. Signed-off-by: Erik Bourget <erik@ebourget.net> (cherry picked from commit 140a821 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
The J813's ISP is the A18 Pro's ISP17a: the T8140 generation with the H17 firmware ABI, its own MMIO windows (the J813 ADT's dart-isp dapf-instance-0 ranges, including a DSID window and two new ranges), the PMP clock and bandwidth scratch registers, the T6031 mailbox interrupt enable and the SCL1 output path (T8142 has no BES scaler). Its IMX958 setfile (isp_2224_01XX.dat, the one macOS's appleh16camerad selects for sensor 0x958) keeps the lens shading row strides where H17 reads the offset's high half, as the T6040's do: setfile_stride_fixup zeroes them on T8142 too. The camera streams at 1280x720 and 1920x1080 (NV12). White balance stays at the setfile's default gains: the H17 firmware's AWB is semantic AWB, which needs the ANE. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de> (cherry picked from commit 38c26d2 in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
The 1280x720 preset cropped the top-left 1280x720 corner of the 1920x1080 window that firmware configuration 5 delivers, without scaling. A 720p stream, which video calls often ask for, therefore showed an off-centre view about two thirds as wide as the 1080p one. Crop the whole 1920x1080 window and let the scaler bring it down to 1280x720, as the driver already does for the sizes it derives itself (such as 640x480 from the 1080p crop). The driver offered P010 only for presets whose crop equals their output, so the scaled preset would lose it and a 1280x720 P010 request would fall back to 1280x960. Accept a crop at the origin with the output's aspect ratio that is no smaller than the output instead. Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com> Assisted-by: LLM [ed: dropped the t604x-j614-j616.dtsi hunk: that board file is not in this tree] (cherry picked from commit 99ec97e in aurora-silicon/linux) Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
aurora-silicon/linux's ISP driver, carried in its own pull request: the camera below runs on it.
The T6050 (M5 Max) ISP sits at T6040's addresses and boots as T6040: the
mailbox at +0x2924000 answers from the AP, and its firmware main memory
is 32 MiB at IOVA 0x100_0000_0000 with __TEXT and __DATA ending at
0x1fec000. Its firmware reaches PMGR, PMP and DSID registers through its
DART at the J714c ADT's dart-isp0 address filter ranges.
The J714c's IMX958 is attached over LPDP ("ch0: SIF 0 (LPDP)"); without
the LPDP receiver tuning every frame is black. The PMP clock scratch word
is not known, so no PMP control is sent.
Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the J714c the camera light belongs to the exclave indicator controller, which Linux does not run: the sensor streams with the light off. Frames pass only while the controller's ISP watchdog (eic mmio-wd-isp) is fed. Make the light the driver's: before every stream start, drive the light pin (ADT eic cil-gpio-offset 141 in gpio0, cil-gpio-config 0x474002) as an output at its on level with its input buffer on, and refuse the stream unless the pin reads back at that level. Turn it off only after the stream stops, a start fails or the firmware halts. Feed the capture watchdog only while the light is on. A T6050 ISP without a described light does not probe. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The firmware reaches its fixed MMIO windows through dart-isp0's address filter. Program the J714c ADT's 15 windows from the driver, with the ADT's r20 word (0xcc3), so the camera does not depend on the boot loader for it. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
macOS's appleh16camerad carries three setfiles naming sensor 0x958: 2224_01, 2226_01 and 2226_02. The J714c module reports build revision 2, and with 2226_02 its noise is far lower and its colour neutral, where 2224_01 leaves heavy grain and a green cast. Add 2226_02 and select it for T6050; T8142 and T6040 keep 2224_01. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A firmware that dies mid-start can leave the sensor powered, and a powered sensor lights the camera light with its pin released: after a failed start the light stayed on until the next reset. Once the firmware is halted no frame can reach the host, so drive the light off then. A halted resident firmware does not start again. Remember the boot loader's pin setting at probe instead of at the first stream. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the J714c's ISP, booted as the T6040 one, and its three DARTs: - the mailbox, GPIO and doorbell windows at +0x2924000; - the seven ISP power domains in pmgr1, by ADT device id from ISP_SYS, and ISPSENS0; - the firmware's text, data and heap regions (iBoot mBoot-20457.60.65.0.1), with no "isp" alias, so the boot loader leaves the node alone; - dart-isp0's address filter window; - the camera light (ADT eic pin 141 in gpio0, active high) and the eic's ISP watchdog; - presets from the full IMX958 (configuration 7), cropped to the centre, inside the lens circle. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… gains The IMX958 setfile 2226_02 carries its noise reduction radial gains (record 0xc404) flat: every bin 4096. macOS's appleh16camerad computes them from the setfile's lens shading table (record 0xc003) before loading it: for each of 257 radius bins, 4096 over the mean shading gain of the four Bayer planes along the rays to the four image corners, around the optical centre 156 rows above the image centre. Do the same for T6050. On the J714c the grain on a flat wall drops by about 30% at the centre and 40% at the edges, where the shading gain is highest. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
macOS's appleh16camerad sets the IMX958's lens shading ideal percent to 84 before loading its setfile (CH_LSC_IDEAL_PERCENT_SET, 0x0a4e), and sends the face-detection scene metering setup that this driver skips on H17 firmware. The T6050 firmware takes both. Add the command, and make the percent and the scene metering T6050 hardware data. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
macOS streams the J714c's IMX958 in firmware configuration 6: two exposures, 3040x5760, merged by the ISP to 3040x2880. Use it for the 1920x1080 and 2560x1440 presets, with the same centre crops; it looks better than configuration 7. 1280x720 stays on configuration 7. Signed-off-by: Eduard Moldovan <edimoldovan@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Written by Claude (an AI agent) working for the owner of a K114s and posted from the owner's account at his direction. @edimoldovan, a K114s result for the T6050 camera commits of this PR, and one question. Tested on a 14-inch M5 Pro OLED (K114s, T6050, ISP platform id
Upstream has since moved on the same files: aurora-silicon/linux#2233 (computed noise filter, setfile 2224_01 and binned config for the J714s) and aurora-silicon/linux#2561 (the software indicator) are merged, and betizzel/omarchy-m5#33 notes that its series dropped your old camera patches in the rebase. Do you plan to send the T6050 setfile selection and the lens shading command to aurora-silicon/linux, rebased on that? I could not find a pull request there. No reply needed if you are already on it. |
Adds the front camera of the MacBook Pro 14-inch M5 Max (J714c): T6050's ISP and its IMX958 sensor.
Stacked on #404, which adds the J714c device tree, and on #421, the aurora-silicon ISP driver carry, which the camera runs on. Until both are merged, this diff also shows their commits.
Requires the macOS 27.3 beta 1 system and OS firmware (iBoot mBoot-20457.60.65.0.1).
Commits:
media: apple: isp: Add T6050 support
media: apple: isp: Drive the J714c camera light from the driver
media: apple: isp: Program the T6050 ISP's DART address filter
media: apple: isp: Tune the J714c IMX958 with setfile 2226_02
appleh16cameradcarries three setfiles naming sensor 0x958.apple/isp_2226_02XX.dat.2224_01.media: apple: isp: Turn the J714c camera light off after a firmware halt
arm64: dts: apple: t6050-j714c: Add the camera
media: apple: isp: Compute the T6050 setfile's noise reduction radial gains
media: apple: isp: Set the J714c lens shading target and scene metering
arm64: dts: apple: t6050-j714c: Stream the camera in configuration 6
The setfile is extracted from macOS by the installer (omacom/omarchy-mac-installer, separate pull request) to
/lib/firmware/apple/isp_2226_02XX.dat.The last three commits were tested on the J714c by capture (1920x1080 and 2560x1440 NV12, with the grain measured on a flat wall). The rest was tested on the J714c with linux-aurora 7.2.11.aurora14-111, whose camera driver and device tree are these commits':
Build:
defconfig+asahi.configwithVIDEO_APPLE_ISP=mand its KUnit tests: the driver builds clean with W=1, and the Apple DTBs build.VIDEO_APPLE_ISP=ybuilds.Co-Authored-By:trailer form.🤖 Generated with Claude Code