Skip to content

media: apple: t8010-isp: Add the A9's torch - #177

Merged
henrikklee merged 3 commits into
OrchardLinux:mainfrom
ricktav:n66/torch
Dec 5, 2026
Merged

henrikklee merged 3 commits into
OrchardLinux:mainfrom
ricktav:n66/torch

Conversation

@ricktav

@ricktav ricktav commented Dec 4, 2026 •

Copy link
Copy Markdown

The rear torch on the A9 (iPhone 6s Plus), through the A10's existing torch path. Three commits, driver only.

What

  • The A9's ISP firmware has the A10's torch commands. The firmware's command table names CH_LED_TORCH_OFF 0x602 and CH_LED_TORCH_ON 0x603. The 0x603 handler passes the u32 at +0xc on to the strobe task, as on the A10.
  • The flash driver sits on the firmware's own I2C. The kernel only raises its enable at power-on: the strobe GPIO, ADT function-torch_enable. The A9 path already does that.
  • A torch flag in struct isp_soc splits the torch from the A10-only controls, and both SoCs set it.
    • The A9's rear camera gets V4L2_CID_FLASH_LED_MODE and V4L2_CID_FLASH_TORCH_INTENSITY.
    • The white:flash LED registers, through the existing isp_set_torch().
    • The A10 is unchanged.
  • The second and third commits give the A9 its real steps.
    • The firmware's flash driver writes the module's calibrated torch code as is for level 6 and up, and scales it for 1–5 (sixths of that current).
    • Read back with CH_LED_TORCH_CURRENTS_GET (0x607) on the N66, levels 1–6 give 22, 22, 46, 46, 68 and 94 mA in all, and 7–9 give 94 mA. So only 1, 3, 5 and 6 are distinct.
    • The match data holds the top step and a table of the firmware's level per step. The A9 has 4 steps (firmware levels 1, 3, 5, 6); the A10 keeps 1–255 with no table. white:flash has the same max_brightness.
  • The torch's enable GPIO comes from the board DT. For the N66 that is arm64: dts: apple: n66: Enable the cameras on both iPhone 6s Plus models #176. On the N71, strobe-gpios is already in s800x-n71.dtsi.
  • The iPads that have this ISP (J81, J171) have no rear flash in their ADT, so nothing changes for them.

Tested on an N66 (Samsung), main a1d07f1 + #176 + this commit:

  • The rear node lists led_mode and intensity_torch_mode; the front node has neither.
  • white:flash registers.
  • The intensity control reads 1–4 (default 2), and white:flash has max_brightness 4.
  • led_mode=2 lights the rear LED. Steps 1 to 4 are each brighter than the one before, and led_mode=0 turns it off. The firmware boots for it on demand, with no errors in the log.
  • Not tested:
    • whether other modules' calibrations give the same four steps (the table is from one N66);
    • the torch while streaming;
    • flash mode;
    • the N71 and the TSMC N66m.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFMaVeK3LkXZ3zvi9pvxid

@ricktav
ricktav marked this pull request as draft December 4, 2026 23:03
@ricktav

ricktav commented Dec 4, 2026

Copy link
Copy Markdown
Author

Converting to draft: please don't merge yet.

On the N66 the brightness stops changing above intensity 6–7, so the 1–255 range here (taken from the A10) does not match what the A9 firmware does with the level. I'm working out the A9's real steps from the firmware and will update this PR so the control's range matches them. I'll mark it ready again once that's in and tested on the device.

@ricktav
ricktav marked this pull request as ready for review December 4, 2026 23:08
@ricktav

ricktav commented Dec 4, 2026

Copy link
Copy Markdown
Author

Updated and ready again: the second commit (0a3dabd) gives the A9 torch its real six levels, from what the firmware does with the level. Tested on the N66: 1–6 each brighter, off works, no firmware errors.

@ricktav

ricktav commented Dec 4, 2026

Copy link
Copy Markdown
Author

Third commit (2402d80): measured with CH_LED_TORCH_CURRENTS_GET on the N66, levels 1–6 give 22, 22, 46, 46, 68 and 94 mA, so the A9 now has the four steps that differ (firmware levels 1, 3, 5, 6). Tested on the device: 1–4 each brighter.

@henrikklee

Copy link
Copy Markdown

Thanks @ricktav, a working torch on the A9 iPhones is a lovely addition, and taking the brightness steps from currents measured on the N66 is a nice touch.

It can't merge as it is: the branch is based on an older main, and #157 (iPhone 7 Plus telephoto, merged) has since rewritten the same code. Cameras are now a per-camera table (struct isp_cam) with a torch flag, and the A9 rear camera already has that flag set. Could you rebase onto current main and:

  1. Key the torch on the per-camera cam->torch flag from iPhone 7 Plus: the rear, telephoto and front cameras #157 instead of the !i (camera index 0) check. That makes the change smaller: what's left is torch_max/torch_levels in isp_soc and the isp_torch_ctrls() split.
  2. Register the torch (the white:flash LED and the flash controls) only on boards that have a flash, for example only when the board's DT has strobe-gpios. As written, A9 iPads would get a torch toggle with no flash behind it.

Squashing the "four real steps" commit into the "six levels" one would also be good, since it corrects that commit in the same PR.

#176 (the 6s Plus cameras) gets merged first; this one follows once it's rebased and CI is green. Thanks!

ricktav and others added 3 commits December 5, 2026 09:26
The A9 cameras had no controls, so the 6s Plus's rear flash could not be
used as a torch. Its firmware has the A10's torch commands: the command
table names CH_LED_TORCH_OFF 0x602 and CH_LED_TORCH_ON 0x603, and the
handler for 0x603 passes the u32 at +0xc on to the strobe task, as the
A10's does with the level. The flash driver sits on the firmware's own
I2C; the kernel only raises its enable (the strobe GPIO, ADT
function-torch_enable) at power-on, which the A9 path already does.

On the A9 the level is not the A10's 1-255 of 50 mA per driver. The
flash driver's torch method writes the module's calibrated torch code
as it is for level 6 and above, and scales it for levels 1-5: the level
is in sixths of the module's calibrated current. Read back with
CH_LED_TORCH_CURRENTS_GET on an N66, levels 1 to 6 give 22, 22, 46, 46,
68 and 94 mA in all: the drivers' current only changes at 1, 3, 5 and 6.

Split the torch from the A10-only controls with its top level in the
match data, 255 on the A10 (unchanged) and 4 on the A9, plus a table of
the firmware's level per step (1, 3, 5, 6) on the A9. The camera with
the torch flag gets the V4L2_CID_FLASH_LED_MODE and
V4L2_CID_FLASH_TORCH_INTENSITY controls (1 to the top level, its middle
as the default) and the "white:flash" LED is registered with the same
max_brightness, both through the existing isp_set_torch().

Tested on an N66 (Samsung): the rear node gets led_mode and
intensity_torch_mode and the white:flash LED registers; the control
reads 1-4, default 2, each step lights the rear LED brighter than the
one before, and led_mode=0 turns it off, with no firmware errors.

[Orchard: rebased onto the per-camera table (OrchardLinux#157), keyed on its torch
flag instead of camera index 0, and squashed the three commits of the
pull request (torch, six levels, four steps) into one]

Signed-off-by: ricktav <82380971+ricktav@users.noreply.github.com>
Assisted-by: LLM
The torch controls and the "white:flash" LED were registered on every
board that runs the ISP, flash or not. The iPads with these ISPs (the
A10 iPads, and the A9's) have no flash, so desktop torch toggles found
an LED that lights nothing.

Only the boards with a flash wire its enable, strobe-gpios: the iPhone
6s and 6s Plus (s800x-6s.dtsi) and the iPhone 7 and 7 Plus
(t8010-7.dtsi). Register the torch only when the DT has it.

Assisted-by: LLM
Signed-off-by: Henrik Klee <henrik@goat-code.com>
Say that strobe-gpios is present only on the boards with a flash, and
that the driver offers the torch only with it.

Assisted-by: LLM
Signed-off-by: Henrik Klee <henrik@goat-code.com>
@henrikklee
henrikklee merged commit f4a55ba into OrchardLinux:main Dec 5, 2026
4 checks passed
@henrikklee

Copy link
Copy Markdown

Merged, thank you! The torch with real measured steps is great work.

What we changed on your branch:

  • Rebased it onto main, where iPhone 7 Plus: the rear, telephoto and front cameras #157 had meanwhile added the per-camera table. The torch now follows that table's torch flag instead of camera index 0.
  • Squashed your three commits (torch, six levels, four steps) into one, with your authorship and sign-off kept and an [Orchard: …] note saying what moved.
  • Added a commit of ours: the torch and the white:flash LED are now registered only on boards whose device tree has strobe-gpios, meaning the iPhones (6s, 6s Plus, 7, 7 Plus). iPads with these ISPs have no flash, so they no longer show a torch toggle that does nothing. A short binding note says the same.

It reaches the nightly once orchard takes the new kernel. A quick check on your N66 after that is welcome.

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