Skip to content

config, main, data: key camera profiles on sysfs sensor name ([sensor:imx958-uw]) - #14

Merged
DjDeveloperr merged 2 commits into
aurora-silicon:mainfrom
astaff:j616c-board-profile
Nov 19, 2026
Merged

DjDeveloperr merged 2 commits into
aurora-silicon:mainfrom
astaff:j616c-board-profile

Conversation

@astaff

@astaff astaff commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Pair with aurora-silicon/linux#2216 (apple-isp device/sensor sysfs attribute) to select camera low-light thresholds and framing capabilities by sensor module rather than per-board lists:

  • Replace [apple,j616s] in data/boards.conf with [sensor:imx958-uw], covering J614s, J616s, J614c, J616c, and other 12 MP Center Stage IMX958 ultra-wide machines from a single section while keeping [<compatible>] (such as [apple,j700]) as fallback when device/sensor is absent or has no sensor-specific section.
  • Check /sys/class/video4linux/<dev>/device/sensor at startup, on PipeWire V4L2 node discovery, and when input streaming begins (so deferred_start ISPs that return -ENODATA until apple_isp_start_camera() runs upgrade cleanly to [sensor:...] on first stream).
  • Add unit tests in tests/test_config.c covering [sensor:imx958-uw] precedence, user denoise.conf overrides, driver symlink filtering, and deferred sensor population.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for bringing the J616c up and for checking the stream live on it.

One thing about where the values live. data/boards.conf keys the denoise thresholds by the machine compatible, but the numbers describe the sensor: the new [apple,j616c] block repeats the [apple,j616s] values for the same IMX958 ultra-wide module, as its own comment says. Each new Mac with that module would need another copy, and a Mac nobody has added gets no tuning at all even though its sensor is known.

We would rather key these profiles by the sensor module the camera driver reports (the ISP's sensor identity), so every Mac with an IMX958 picks up the same block and only a genuinely different module needs a new entry. We'll look at exposing that key from the daemon side; if you'd like to take it on instead, a section name like [sensor:imx958-uw] with a lookup from the ISP's reported sensor would cover the J614c/J616c/J614s/J616s at once. Happy to run it on our M4 Pro and A18 Pro.

Replace per-board [apple,j616s] / [apple,j616c] entries in boards.conf
with [sensor:imx958-uw], covering J614s, J616s, J614c, J616c, and other
12 MP Center Stage IMX958 ultra-wide machines from a single section.

Read /sys/class/video4linux/<dev>/device/sensor at startup, on V4L2 node
discovery, and once streaming begins (handling deferred-start ISPs that
return -ENODATA until the first stream), falling back to [<compatible>]
when the sensor attribute is absent or has no sensor-specific section.

Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
@astaff
astaff force-pushed the j616c-board-profile branch from 84e9529 to e321770 Compare November 19, 2026 18:10
@astaff astaff changed the title data: add [apple,j616c] board profile for MacBook Pro 16" (M4 Max) config, main, data: key camera profiles on sysfs sensor name ([sensor:imx958-uw]) Nov 19, 2026
@astaff

astaff commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Makes complete sense — thank you! Paired this 1:1 with b4018aeb078d on aurora-silicon/linux#2216 (media: apple: isp: expose detected camera sensor name in sysfs, exposing /sys/class/video4linux/videoX/device/sensor from isp_setfiles[] and returning -ENODATA until camera_detected is set on deferred_start SoCs):

  1. Replaced [apple,j616s] and [apple,j616c] in data/boards.conf with a single [sensor:imx958-uw] section covering J614s/J616s/J614c/J616c together, keeping [<compatible>] ([apple,j700]) fallback when device/sensor is absent or has no matching [sensor:...] section.
  2. Updated config.c and main.c (e321770) to read /sys/class/video4linux/<dev>/device/sensor at startup, at PipeWire V4L2 source discovery, and when the input stream enters STREAMING (handling deferred_start hardware where sensor detection happens inside apple_isp_start_camera()).
  3. Added unit tests in tests/test_config.c covering [sensor:imx958-uw] precedence over board compatibles, user denoise.conf overrides, driver symlink filtering, and deferred -ENODATA -> "imx958-uw" upgrade.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thank you for taking this on, including the kernel side: one [sensor:imx958-uw] section with a compatible fallback is exactly what we had in mind. We'll run it on our M4 Pro once aurora-silicon/linux#2216 is in.

[sensor:imx958-uw] replaced [apple,j616s], but the sensor key comes
from the apple-isp sysfs attribute that only kernels with
aurora-silicon/linux#2216 have, and those report it only once the
camera has been detected. Until then the J616s matched no section and
lost its low-light thresholds and framing capability.

Keep [apple,j616s] with the same values as the compatible fallback, and
test that the J616s without a sensor still gets it.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor

@astaff I added 7b32b8f. [sensor:imx958-uw] replaced [apple,j616s], but the sensor key only exists on kernels with aurora-silicon/linux#2216, and even there only after the camera has been detected. Until then the J616s matched no section and fell back to defaults (enter/exit gain 0, no framing). 7b32b8f keeps [apple,j616s] with the same values as the compatible fallback, and tests/test_config.c gains a case for it (the case was written first and fails on e321770).

I ran the real parser (src/config.c + shipped data/boards.conf) on 7b32b8f:

compat sensor section enter/exit framing
j616s none apple,j616s 3584/2816 1.0..6.0, default 1.5
j616s imx958-uw sensor:imx958-uw 3584/2816 1.0..6.0, default 1.5
j616c none none (defaults, as on main) 0/0 off
j616c imx958-uw sensor:imx958-uw 3584/2816 1.0..6.0, default 1.5
j700 none / imx558 apple,j700 (unchanged) 2304/1792 off

main.c passes -fsyntax-only -Wall -Wextra against PipeWire 1.x headers, on main and on this branch.

Review notes (none blocking):

  1. on_in_process() calls refresh_cam_sensor() on every frame until a sensor has been read. On a kernel without the attribute, which is every Neo kernel today, that's a failed open() per frame for the whole stream. Could cdn_v4l2_sensor() tell ENOENT (no attribute: stop asking) apart from ENODATA (not detected yet: ask again)?
  2. On the first frame after detection, refresh_cam_sensor() reloads the config and calls apply_config_to_cams(), which re-inits the trigger and re-runs setup_backend()/setup_effects() mid-stream, even when the matched section doesn't change (the Neo reports imx558, which has no section, so it stays on [apple,j700]). Could it skip the re-apply when cfg.board and the values are unchanged?
  3. Any Mac whose ISP reports imx958-uw now gets the J616s thresholds and framing, which is the point. If the M5 Pro's front sensor also identifies as 0x958, it moves from defaults to this profile once #2216 is in. We'll check device/sensor on our M5 row.

@DjDeveloperr
DjDeveloperr merged commit 03cd679 into aurora-silicon:main Nov 19, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Merged as 03cd679 after linux#2216. tests/test_config.c passes (gcc). Real-parser matrix: j616s keeps its values without the sensor attribute, j616c/j616s use [sensor:imx958-uw] when reported, j700 is unchanged (Neo TEST: sensor imx558, falls back to apple,j700).

@RyanTheTide

Copy link
Copy Markdown
Contributor

M4 Pro (J616s) row on 7b32b8f: pass.

I ran the real loader from libcdn-core.a (cdn_sysfs_find_sensor() + cdn_config_load_sensor(), built on the J616s) against the shipped data/boards.conf:

kernel device/sensor section enter / exit gain noise on / off
fleet75 production absent apple,j616s 3584 / 2816 7 / 5
linux#1954 d3a9ec73 absent apple,j616s 3584 / 2816 7 / 5
linux#2216 5f250583 imx958-uw sensor:imx958-uw 3584 / 2816 7 / 5
main aa7a42f (control) n/a apple,j616s 3584 / 2816 7 / 5

fps <= 30 and the 30-frame ramp are the same in every row. meson test gives 6/6 for both the PR and main on the J616s. The PipeWire daemon was not run, and no camera frames were kept.

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.

3 participants