Repository navigation
media: apple: t8010-isp: Add the A9's torch - #177
Conversation
|
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. |
|
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. |
|
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. |
|
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 (
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! |
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>
|
Merged, thank you! The torch with real measured steps is great work. What we changed on your branch:
It reaches the nightly once orchard takes the new kernel. A quick check on your N66 after that is welcome. |
The rear torch on the A9 (iPhone 6s Plus), through the A10's existing torch path. Three commits, driver only.
What
CH_LED_TORCH_OFF0x602 andCH_LED_TORCH_ON0x603. The 0x603 handler passes the u32 at +0xc on to the strobe task, as on the A10.function-torch_enable. The A9 path already does that.torchflag instruct isp_socsplits the torch from the A10-only controls, and both SoCs set it.V4L2_CID_FLASH_LED_MODEandV4L2_CID_FLASH_TORCH_INTENSITY.white:flashLED registers, through the existingisp_set_torch().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.white:flashhas the same max_brightness.strobe-gpiosis already ins800x-n71.dtsi.Tested on an N66 (Samsung), main a1d07f1 + #176 + this commit:
led_modeandintensity_torch_mode; the front node has neither.white:flashregisters.white:flashhas max_brightness 4.led_mode=2lights the rear LED. Steps 1 to 4 are each brighter than the one before, andled_mode=0turns it off. The firmware boots for it on demand, with no errors in the log.🤖 Generated with Claude Code
https://claude.ai/code/session_01SFMaVeK3LkXZ3zvi9pvxid