Skip to content

media: i2c: imx386: IMX787 (Pixel 9 Pro Fold main camera); ak7375: focus after standby and sensor-owned power - #272

Open
kdegeek wants to merge 4 commits into
derekross:omamobilefrom
kdegeek:comet-imx787-ak7375
Open

kdegeek wants to merge 4 commits into
derekross:omamobilefrom
kdegeek:comet-imx787-ak7375

Conversation

@kdegeek

@kdegeek kdegeek commented Nov 18, 2026 •

Copy link
Copy Markdown

Summary

  1. Describe the Sony IMX787 C-PHY variant and its additional supplies in the IMX386 binding.
  2. Add variant-specific supplies, chip ID, shared XCLR reset and subdev name. IMX386 passes D-PHY to the endpoint parser as before. IMX787 passes C-PHY and an explicitly D-PHY endpoint fails parse. Without a mode data file, IMX787 powers up to read its model ID, powers down and stops probing.
  3. Give IMX787 its 960 analogue gain limit for the 10-bit gain curve.
  4. Wait one 1 ms control step after the standby mode write for every ak7375. Defer open_powers to the S5K3LU series where the sensor's runtime PM reference can be tested with the driver policy.

Evidence

On earlier Comet integration kernels, IMX787 reported model 0x0787 without a mode data file. With the data file it streamed 4000×3000 RAW10 on the three-trio C-PHY link into CSIS. Libcamera's simple pipeline gave upright images.

Raw fixed-exposure frames followed the IMX787 gain curve 1024 / (1024 - code), reaching measured gains of 3.2×, 5.3× and 15.1× at codes 720, 840 and 960. The 960 cap let auto exposure in the dim test scene settle at 15.75×. Frame means rose from 28/34/31 to 91/94/95 (B/G/R) without clipping.

Comet's ultrawide actuator refused the first position write after standby with ak7375_vcm_resume I2C failure: -6. With the 1 ms wait, three power cycles finished without an I2C error and the saved positions read back as 0x0000, 0x0c80 and 0x1900. Derek saw the same position-loop message on both Pixel 7 Pro lenses at wake on November 15, with a kernel that already retries the mode write.

Checks

The local v2 merges cleanly. checkpatch --strict, W=1 builds of imx386.c and ak7375.c, and the Sony binding check passed. The Comet, Tegu and Cheetah DT checks showed no new diagnostics. The Pixel 7 Pro still needs Derek's probe, capture, focus moves on both lenses and two sleep cycles before merge.

Before IMX787 can stream from the published tree

  • Land the Comet camera device tree, including the C-PHY receiver graph.
  • Add an imx787 case to tools/extract-camera-data that writes chip ID 0x0787. The published extractor writes 0x0386 for the IMX386 data format.
  • Enable CONFIG_RESET_GPIO in the config fragment for shared XCLR.

The mode data is generated from the owner's factory image.

🤖 Generated with Claude Code

@derekross

Copy link
Copy Markdown
Owner

Thanks, Nate. This is careful work, and it checks out where I could check it: the IMX787's power-up order is rear_main_camera_power_seq in Google's zuma-comet-camera.dtsi supply for supply, the sensor, EEPROM, actuator and OIS nodes there all share gpp10-2, and the commit messages each carry their own measurements. The gate passes (clean merge, sign-offs, checkpatch --strict with 0 warnings, W=1 on both files), and I ran the binding through dtschema by hand: both examples validate, and the new one is rejected by the base's schema, as it should be. CI is waiting for my approval; I'll approve it.

One thing the description doesn't account for: both drivers run on the Pixel 7 Pro at every boot. Its ultrawide is the IMX386 and both of its lens actuators are ak7375 nodes (enabled by overlays, loaded 40 s into the boot). So "nothing changes for existing boards" has to hold there, and for two lines it doesn't quite:

  1. The 1 ms wait after leaving standby (commit 4) applies to every ak7375, mine included. I think that's right, as it happens: my 7 Pro logged ak7375_vcm_resume I2C failure: -6 on both lenses at a wake from sleep on 11-15, on a kernel that already retries the mode write, and that line comes only from the position loop. So it looks like the same refusal you saw. But a change to what the 7 Pro does needs a run on it before it merges, so I'll boot it on mine: probe, a capture, a focus move on each lens, and two sleeps with that line counted. Could you reword the message to say the wait is for every ak7375 (and you're welcome to cite the 7 Pro's line)?

  2. imx386_check_link_freqs() now parses the endpoint as "unknown bus" for the IMX386 too. For the 7 Pro's endpoint (four data lanes, no bus-type) the parser guesses D-PHY and I read the result as the same, but I'd rather it stayed the same call. Could the variant carry its bus type (V4L2_MBUS_CSI2_DPHY for the IMX386, V4L2_MBUS_CSI2_CPHY for the IMX787) and the parse use it? Then the IMX386 path is unchanged by construction, and an IMX787 wired to a D-PHY endpoint is refused by the parser instead of by a later check.

Everything else on the IMX386 path I walked through and it is what it was: the same five supplies in the same order with the same two optional, the GPIO reset, the name, the 480 gain cap.

Smaller things, none of them blocking:

  • open_powers (commit 5) has no user in this tree until the S5K3LU series, and a module-wide switch sets the policy for every ak7375 in a phone. It's inert at its default, so I can take it here, but it would read better next to the sensor change that needs it. Your call.
  • What is the ultrawide's actuator, exactly? If its ID register names a part, its own compatible would give the standby wait a home in the chip data.
  • Three things the published tree needs before an IMX787 can stream, worth a line in the description so nobody expects it sooner: the comet camera device tree, an imx787 case in tools/extract-camera-data (it writes chip ID 0x0386 only), and CONFIG_RESET_GPIO in our config fragment for the shared reset.

@derekross derekross left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI has run on this head and passes: clean merge onto today's omamobile, sign-offs, prefixes, checkpatch --strict, W=1 builds of imx386.c and ak7375.c, and dt_binding_check on sony,imx386.yaml. The one skipped line is "device trees: none touched", so CI didn't validate the 7 Pro's device tree against the changed binding; my hand run of that (the same two messages before and after) still stands in for it.

The two requests in my comment above are unchanged. I'll do the 7 Pro run once they are in, so that it tests the commits that will land.

The Pixel 9 Pro Fold's main camera is a Sony IMX787: the IMX386's
register map behind a MIPI CSI-2 C-PHY output, in a module whose AF/OIS
controller shares the sensor's XCLR line and adds its own supplies.

Add the sony,imx787 compatible, its vaux, vaux2 and vana2 supplies
(rejected for the IMX386), and a bus-type that allows C-PHY, with
data-lanes then counting trios. The IMX386's properties and requirements
are unchanged.

Assisted-by: LLM
Signed-off-by: Nate Crawford <nate@kdegeek.com>
The Pixel 9 Pro Fold's main camera is a Sony IMX787. It reports model
0x0787 at 0x0016 and has the IMX386's CCS-style register map, so the
mode, exposure and gain registers this driver writes apply unchanged;
its initialisation and readout tables come from the data file, as the
IMX386's do. Three things differ:

 - the module has eight supplies, powered in the order of Google's GPL
   zuma-comet-camera.dtsi (rear_main_camera_power_seq): the board's vbb
   and vbuck, then vif, the AF/OIS controller's vaux and vaux2, vana,
   vana2 and vdig. The AF/OIS and board supplies are optional;
 - its XCLR reset line is shared with that AF/OIS controller, so it is
   taken through the reset framework as a shared reset, not as a GPIO;
 - it sends over a three-trio MIPI CSI-2 C-PHY link.

Make the supplies, chip ID, reset sharing and subdev name per variant
(libcamera picks its sensor helper by name, so the IMX787 registers as
imx787), and check the data file against the matched chip ID. Pass the
matched variant's bus type to the endpoint parser: D-PHY for IMX386
and C-PHY for IMX787. The parser rejects an explicitly mismatched type.

Without a data file, power up the IMX787, read and log its model ID,
power it down and fail the probe. A board can check its wiring with no
data file and without writing to the sensor. The IMX386 keeps its
existing D-PHY parse and missing-data behavior.

Tested on a Pixel 9 Pro Fold with a v7.3-rc6 based kernel: without a
data file the sensor identifies as 0x0787 and the probe stops there;
with one it streams 4000x3000 RAW10 over the C-PHY link into the CSIS
receiver, and libcamera's simple pipeline gives correct images (the
gain range is fixed in the next patch). The explicit endpoint type
is part of this revision.

Assisted-by: LLM
Signed-off-by: Nate Crawford <nate@kdegeek.com>
The driver caps the analogue gain control at code 480, the IMX386's 16x
under its 512 / (512 - code) curve, and every variant shares that cap.
The IMX787 follows another curve. On a Pixel 9 Pro Fold, raw frames of a
fixed scene at fixed exposure, with the black level of 64 subtracted
(it matched a minimum-exposure frame), measure 1.14x, 1.29x, 1.53x,
1.67x and 1.86x at codes 120, 240, 360, 420 and 480. Codes written to
0x0204 past the control's limit read back as written and give 3.2x,
5.3x and 15.1x at 720, 840 and 960. That is 1024 / (1024 - code): the
register holds 10 bits and 960 is 16x. Capped at 480, the main camera
never got more than 1.88x and stayed dark indoors.

Let a variant set its own maximum code, and give the IMX787 960. The data
file's again_max still bounds the control, as before.

Tested on a Pixel 9 Pro Fold with a v7.3-rc6 based kernel, a data file
allowing 960 and libcamera's gain helper on the same curve: the control
runs 0-960, auto exposure in a dim room settles at a real 15.75x instead
of the 1.88x it was held to, and the mean of the same scene rose from
28/34/31 to 91/94/95 (B/G/R) without clipping.

Assisted-by: LLM
Signed-off-by: Nate Crawford <nate@kdegeek.com>
On the Pixel 9 Pro Fold's ultrawide (an AK73xx-family actuator at 0x0c,
driven as ak7375), every power-up logged "ak7375_vcm_resume I2C failure:
-6": the mode write that leaves standby is accepted, but the position
write that follows at once is refused, so the actuator kept its reset
position (0xfffc) instead of the control's value until userspace moved
it again. Later position writes land exactly (a set of 300 reads back as
0x12c0).

Wait one control step (ctrl_delay_us, 1 ms) between the mode write and
the first position write for every ak7375. On a Pixel 7 Pro, both
lenses logged the same position-loop error on a resume on November 15,
2026, with a kernel that already retries the standby mode write.

Tested on a Pixel 9 Pro Fold with a v7.3-rc6 based kernel: three power
cycles with no I2C error, and after each power-up the position registers
hold the control's last value (0x0000, 0x0c80, 0x1900).

Assisted-by: LLM
Signed-off-by: Nate Crawford <nate@kdegeek.com>
@kdegeek
kdegeek force-pushed the comet-imx787-ak7375 branch from 2e37587 to 2884aa5 Compare November 18, 2026 19:29
@kdegeek

kdegeek commented Nov 18, 2026

Copy link
Copy Markdown
Author

Derek,

I reworded the standby patch to say the 1 ms wait applies to every ak7375. I included your November 15 Pixel 7 Pro observation: both lenses logged ak7375_vcm_resume I2C failure: -6 on wake with the mode-write retry already present. Your 7 Pro probe, capture, focus move on each lens and two sleep cycles are still the check before this merges.

The variant now passes its bus type to the endpoint parser. IMX386 supplies D-PHY as it did before the series. IMX787 supplies C-PHY, so an explicit D-PHY endpoint is rejected by the parser.

I moved open_powers out of this series. The S5K3LU work is where we can show the sensor taking and releasing the actuator's runtime PM reference. Since the switch changes policy for every ak7375 on a phone, that series can show the actual caller and test focus during streaming and rail shutdown at idle together.

Google's Comet camera DTS calls the ultrawide actuator CORNERFOLK at 0x0c. The bring-up notes identify it as Ak73Family and record AK7375-format position readback. I have no chip ID or part-number evidence that would justify a new compatible.

I added the three streaming prerequisites to the description: the Comet camera DT, an IMX787 extractor case emitting 0x0787, and CONFIG_RESET_GPIO. The v2 changes have been checked offline. The Comet measurements in the description are from the earlier integration kernels.

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