Skip to content

media: apple: isp: Load the camera module tuning the DT names (J815: IMX958 2226_02) - #2194

Closed
m0d16l14n1 wants to merge 3 commits into
aurora-silicon:integration/aurorafrom
m0d16l14n1:j815/isp-imx958-2226
Closed

m0d16l14n1 wants to merge 3 commits into
aurora-silicon:integration/aurorafrom
m0d16l14n1:j815/isp-imx958-2226

Conversation

@m0d16l14n1

@m0d16l14n1 m0d16l14n1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

The J813 and the J815 both have an IMX958 front camera, and both run the sensor's default 2224_01 setfile. macOS's camera daemon carries two tunings for the J815's camera module, 2226_01 and 2226_02, in the H17-native form (lens-shading records without the xx24 stride). With 2224_01, the J815's raw picture is dark in the corners.

Corner/centre brightness on one J815, raw camera, same scene, each file loaded into a freshly started firmware:

setfile corners / centre
2224_01 (now) 0.50
2226_01 0.63
2226_02 0.85

Change:

  1. dt-bindings: apple,module-tuning on the ISP node names the camera module's own setfile, e.g. "2226_02".
  2. media: apple: isp:
    • The driver loads the setfile that property names.
    • A board without the property, or with a name that isn't a setfile of its sensor, keeps the sensor's default; the second case logs a warning.
    • If a 2226 file isn't installed, the driver falls back to 2224_01 instead of streaming untuned. Today's vendorfw doesn't have these files; vendor firmware: collect the J815's IMX958 module tunings (2226_01, 2226_02) aurora-installer#151 extracts them from appleh16camerad.
    • The machine check and the setfile module parameter are gone.
    • KUnit: isp_test_module_tuning (match, another sensor's file, unknown names) and isp_test_setfile_fallbacks (each fallback is the same sensor, no larger, and final).
  3. t8142-j815.dts: apple,module-tuning = "2226_02".

Tested on J815: all three files load and stream with no command timeouts, and 2226_02 also across camera restarts. At the time the file was picked by the module parameter. The DT-named run was on 3728bcc, and the driver patch is unchanged since then apart from the comments.

Not run yet: J815 with the 2226 files absent (the fallback line, streaming on 2224_01), and J813 at this head (no property: 2224_01, no warning).

Checks (rebased onto integration/aurora bb9f8ec):

  • ISP KUnit (arm64, QEMU, LLVM): 61 tests, 60 pass. The one failure, isp_test_sensor_sysfs, also fails on plain bb9f8ec (59 tests, 58 pass).
  • checkpatch --strict clean on all three commits.
  • The J815 DTB builds.
  • Earlier, at 70eba1a: W=1 build clean, dt_binding_check clean on apple,t8140-isp.yaml, and the J704, J813 and J815 CHECK_DTBS output the same as on integration. Not rerun here; the binding and DTS commits are unchanged.

Part of the J815 bring-up; board results are summarised in #135.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for finding the J815's own module tuning; the corner shading improvement is clear.

We select hardware differences through the device tree rather than machine checks in the driver. Here the setfile is chosen by of_machine_is_compatible("apple,j815") (drivers/media/platform/apple/isp/isp-cam.c:222), and a new setfile module parameter can switch it (:110). The J813, with the same IMX958 sensor, loads 2224_01, so the module tuning really belongs to the board's camera module.

Could you describe it in the J815 DT instead, for example a property on the ISP/camera node naming the module tuning (2226_02), and fall back to the sensor default when it is absent? Then any board with that module only needs a DT line. If the parameter is only for experiments, please leave it out of this PR or make it debug-only. We are happy to help test on other machines.

@m0d16l14n1 m0d16l14n1 changed the title media: apple: isp: J815: load the J815 module tuning (IMX958 2226_02) media: apple: isp: Load the camera module tuning the DT names (J815: IMX958 2226_02) Nov 19, 2026
@m0d16l14n1

m0d16l14n1 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

@RyanTheTide done, new head 3728bcc, in three commits:

  • dt-bindings: apple,module-tuning on the ISP node, e.g. "2226_02".
  • driver: loads the setfile that property names. If the property is absent, or names a file that isn't a setfile of the sensor, it keeps the sensor default; the second case logs a warning. The machine check and the setfile module parameter are gone. A 2226 file missing from vendorfw still falls back to 2224_01.
  • J815 DTS: apple,module-tuning = "2226_02".

Any other board with that module now only needs the DT line. ISP KUnit 48/48, checkpatch --strict and dt_binding_check clean, and the DTB checks are unchanged against 0abc2f3. The J815 run with the DT-named file is in the next test build.

@m0d16l14n1

Copy link
Copy Markdown
Contributor Author

J815 run on head 3728bcc (integration/aurora 0abc2f3 + the T8142 PR stack). The camera opened, and the driver took the tuning that the J815 DT names:

apple-isp 4a0000000.isp: ch 0: sensor 0x958, 13 configs, platform 0x72, setfile apple/isp_2226_02XX.dat

No 2224_01 fallback line.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for 3728bcc and the J815 log: the module tuning named in the DT, with the sensor default as fallback and no module parameter, is the shape we were after.

@m0d16l14n1
m0d16l14n1 force-pushed the j815/isp-imx958-2226 branch 2 times, most recently from fd73cb3 to 6988300 Compare November 20, 2026 12:12
@m0d16l14n1

m0d16l14n1 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased onto current integration/aurora (d91db38): new head 6988300. It had started to conflict.

The only conflict was in isp-cam.c: the setfile table now carries the sensor name and snf_centre_dy.

  • The two J815 module tunings (2226_01, 2226_02) take the same values as the IMX958 2224_01 entry they fall back to: "imx958-uw", ISP_TEMPORAL_FILTER_BAND0, centre offset −156. It's the same sensor.
  • The struct keeps both new fields, snf_centre_dy and fallback.
  • The DT property, the binding and the J815 DTS commit are unchanged.

Checks

  • checkpatch: clean on all three commits.
  • KUnit (isp/.kunitconfig, arm64 QEMU, LLVM): 52/53. The failing case is isp_test_sensor_sysfs, and it fails the same way on plain integration/aurora d91db38 without this PR. The test passes a 32-byte stack buffer to sensor_show(), and sysfs_emit() refuses a buffer that isn't page-aligned (WARN, returns 0). A PAGE_SIZE buffer from kunit_kzalloc() in the test would fix it. I left that out of this PR.

@RyanTheTide

Copy link
Copy Markdown
Contributor

A note on state: this branch now conflicts with integration/aurora, so GitHub can't merge it as it is. Could you rebase 6988300 onto the current base? Nothing about the change itself needs to move. The apple,module-tuning property, its binding and your J815 row stand as they are, so a rebase-only push is enough. CI on the rebased head will then confirm it.

@m0d16l14n1

m0d16l14n1 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@RyanTheTide rebased onto current integration/aurora (b4cd7b3e15f4). The new head is 70eba1a3, and GitHub reports it mergeable again.

  • Conflict: one, in the binding. apple,camera-indicator (ffba3cb) now sits next to apple,module-tuning; both properties are kept. Nothing else moved:
    • the driver commit is patch-id identical;
    • the J815 DTS commit only has shifted context.
  • checkpatch --strict: 0/0/0 on all three commits.
  • J815 DTB: builds.
  • KUnit (isp/.kunitconfig, arm64 QEMU, LLVM): 58/59. The failing case is the same isp_test_sensor_sysfs as before, and it fails on plain integration too.
  • W=1: stops on isp-drv.c:1349, an unused apple_isp_hw_t6040 that comes from integration itself (3161362), not from this PR.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the rebase. 70eba1a merges cleanly again, the driver commit is unchanged, and keeping both apple,camera-indicator and apple,module-tuning in the binding is the right resolution. The KUnit failure is the same pre-existing case, and the W=1 stop is in integration, not this PR. Nothing more needed from our side.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train adversarial review (MERGETRAIN-LINUX2) at 70eba1a: NO BLOCKERS.

Code read only, nothing built here. Before the merge it still needs Dj's verdict at this head; the missing rows are listed below.

Full review

#2194 media: apple: isp: Load the camera module tuning the DT names (J815: IMX958 2226_02) @70eba1a3

VERDICT: NO BLOCKERS

Code checks out:

  • The old of_machine_is_compatible("apple,j815") gate and the setfile module parameter are gone. Selection is by the DT property apple,module-tuning (isp-drv.c:894-896, binding pattern ^[0-9]{4}_[0-9]{2}$).
  • Lookup, isp-cam.c:118-133:
    • The 48-byte path buffer is plenty for the 7-character name.
    • A match must also have the default's sensor version, so a board cannot load another sensor's file.
    • Unknown names warn and keep the default.
  • It is called only for sensor 0x958 (:220). Other IMX958 boards (J613/J616s/T8132/J813/K116s) have no property and keep 2224_01.
  • Fallback, isp-cam.c:855-861:
    • When a 2226 file is missing, len, size, magic, snf_centre_dy and the stride fixup all follow the 2224 entry, because setfile is reassigned before any of them is used.
    • The -ENOSPC check at :851 used the larger 2226 size (0x7040 ≥ 0x6ff4), so the fallback stays within bounds.
    • The values still keyed by fmt->id (temporal filter :956, sensor name :646, supported-sensor list :526-529) are identical for all three IMX958 rows.
  • isp_setfile_fixup_h17() (:662-692) only zeroes a value equal to 2 × width, so it does nothing to the H17-native 2226 files.
  • Inserting two enum values before ISP_VD56G0_* (isp-drv.h:337-338) is safe: every user indexes by name (designated initializers, KUnit), and no table or UAPI depends on the numeric values.

Nits:

  • All three commits carry Assisted-by: Claude Opus 5.5 (already pushed). The sign-off is "Nick", which is not a full real name.
  • isp-drv.h:337 names the macOS daemon (appleh16camerad) in a code comment. That is not a kext class or method, but it is the source binary of Apple tuning data. Saying "macOS module tunings" would be safer.
  • The 2226 rows reuse 2224_01's snf_centre_dy = -156 (isp-cam.c:103, :106), the optical centre of a different module and lens. That is plausible for the same sensor but was not measured for the 2226 module.
  • No KUnit case was added for isp_module_tuning() (match, wrong-sensor, unknown) or the -ENOENT fallback. Both are easy with the existing static stubs.

Missing rows:

  • The J815 DT-named run was on 3728bcc. The driver patch at 70eba1a is patch-id identical, so that run still counts.
  • Not run: J815 with the 2226 files absent (fallback line, stream works on 2224_01).
  • Not run: J813 at this head (no property, still 2224_01, no warning). J813 shares the T8142 ISP and the IMX958.

Some Macs pair a sensor with a camera module that has its own tuning
file. Let the ISP node name it, e.g. "2226_02" for the J815's IMX958.

Signed-off-by: Nick <[email protected]>
The J813 and the J815 (MacBook Air 13" and 15" M5) both have an IMX958
sensor, and both have run its default 2224_01 setfile. The J815's camera
module has its own tunings, 2226_01 and 2226_02, in the H17-native form
(lens-shading records without the xx24 stride). With 2224_01 the J815's
raw picture is dark in the corners. Corner/centre brightness on one
J815, raw camera, same scene, each file loaded into a freshly started
firmware:

  2224_01  0.50
  2226_01  0.63
  2226_02  0.85

Load the tuning the ISP node's apple,module-tuning names. A board
without the property, or with a name that is not a setfile of its
sensor, keeps the sensor's default. The 2226 files are not in every
vendor firmware set yet, so a missing one falls back to 2224_01 instead
of leaving the camera untuned.

Tested on J815, with the file picked by a module parameter at the time:
all three files load and stream (no command timeouts), 2226_02 also
across several camera restarts.

KUnit: isp_test_module_tuning (match, another sensor, unknown names)
and isp_test_setfile_fallbacks (each fallback is the same sensor, no
larger, and final).

Signed-off-by: Nick <[email protected]>
The J815's IMX958 module runs 2226_02: with the sensor's default
2224_01 its corners read half the centre's brightness, with 2226_02
0.85 of it.

Signed-off-by: Nick <[email protected]>
@m0d16l14n1

m0d16l14n1 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

@RyanTheTide thanks for the review. I force-pushed 988af2c7, rebased onto integration/aurora bb9f8ec. These are your nits:

  • Trailers: none in the three commits; they carry only Signed-off-by.
  • appleh16camerad in isp-drv.h: the comment now says "the J815's macOS module tunings".
  • snf_centre_dy: the 2226 rows still use 2224_01's -156. The comment above them now says it is the same sensor's centre, not measured for this module.
  • KUnit:
    • isp_test_module_tuning covers no property, 2226_02/2226_01/2224_01, an unknown name, another sensor's file (7523_01) and a partial name.
    • isp_test_setfile_fallbacks checks that each fallback is the same sensor, no larger than the file it replaces, and has no fallback of its own. That is what keeps the -ENOENT path within the size checked before it.
    • The -ENOENT branch itself is not stubbed. firmware_request_nowarn() has no static stub, and I didn't want to add a test-only hook to the load path. Tell me if you'd prefer one.
    • Results: 61 tests, 60 pass. The one failure, isp_test_sensor_sysfs, also fails on plain bb9f8ec.

checkpatch --strict is clean on all three commits, and the J815 DTB builds. The two runs you listed are still owed: J815 with the 2226 files absent, and J813 at this head.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train re-check at 988af2c: git range-diff against our reviewed 70eba1a shows the rebase onto bb9f8ec, the review nits addressed (agent trailers gone from all three commits, the setfile comments reworded, no daemon name in isp-drv.h) and the new KUnit cases isp_test_module_tuning / isp_test_setfile_fallbacks. No functional change to the driver path. Our no-blockers verdict carries to this head; waiting on Dj's review.

@m0d16l14n1

m0d16l14n1 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Closing this: I'm taking the J815 camera work out of the upstream trees for now and continuing it on my own machine. Thanks for the reviews.

@m0d16l14n1 m0d16l14n1 closed this Nov 22, 2026
@m0d16l14n1
m0d16l14n1 deleted the j815/isp-imx958-2226 branch November 22, 2026 19:01
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.

2 participants