Skip to content

media, phy: the Pixel 9a (zumapro) camera receiver on gs201-csis and the DC-PHY driver - #63

Open
W4HO-ham wants to merge 14 commits into
derekross:omamobilefrom
W4HO-ham:tegu-camera-zumapro
Open

W4HO-ham wants to merge 14 commits into
derekross:omamobilefrom
W4HO-ham:tegu-camera-zumapro

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

This brings up the Pixel 9a's camera receiver on top of your gs201 drivers: all three of its cameras (main S5KGN8 over C-PHY, ultrawide and front IMX712 over D-PHY) now stream through libcamera's simple pipeline, and the Camera app shows a live preview.

DC-PHY (2 commits). zumapro has nine slaves for twelve CSIS links, the clock lane first on each, one reset bit per slave in the ISP-FE sysreg at +0x500, and three clock-only slaves that links 4 and 6 enable beside their own in four-lane D-PHY. The layout is a per-SoC table now; the data file format is unchanged, and tools/extract-camera-data (omarchy-mobile #68) builds the 9a's file from the owner's HAL.

CSIS (8 commits). The link is gs201's (version 0x08010000 against 0x05040000, same layout), but frames reach memory through the ISP front end's CSIS core: an image logical channel (LoCH) and its Bayer WDMA. The new path routes the link's VC 0 into LoCH 0, writes packed RAW10, and programs the batch slot only at start of frame (a mid-frame write is a "late config" and stalls the LoCH, so frames with no queued buffer go to a scratch buffer). Three link bits differ from gs201, all from the zumapro HAL: pixel mode 3, CMN_CTRL bit 12, and DBG_OPTION_SUITE cleared. Your bit 23 there makes the link hand out unpacked 16-bit words, which gs201's WDMA wants and zumapro's core scrambles. The main camera's 18.8 Gbps C-PHY link also overran the front end until its NOC clock went from ABL's 111 MHz to 332 MHz, so the driver raises the INT DVFS domain (its rail, through ACPM) and then the clock while a link streams. The gs201 path keeps its defaults: .wdma, .dbg_bit23 and .phy_cmn_ctrl are true for gs201, and the bring-up parameters default to the SoC's values.

S5KGN8 (2 commits): the 9a's main camera, model 0x08e8, as a fourth s5kgn1 variant (stock's power order with a second 2.9 V supply and a board-switched digital supply).

Testing, on the palmtop (7.3.0-rc6-omamobile-tegu-s2mpg15-m1): the solid colour test pattern reads back exactly in RAW10 and RAW16 on the ultrawide; colour bars land whole on all three cameras; libcamera streams each at about 29 fps; the stream counters show no link CRC/ECC/SOT errors on the D-PHY links. tools/kernel-pr-check: sign-offs, prefixes and policy pass; checkpatch has one long format string (matching the file's style) and the MAINTAINERS note for the new header, which the existing gs201-csis directory entry covers. dt-doc-validate and yamllint pass on the three bindings.

Not tested: cheetah. The gs201 values are unchanged by design, but I have no Pixel 7 Pro here; could you run a capture on cheetah with this series?

The 9a's DT, clock (CIS clocks, USI3/USI5, the ISP-FE NOC clock) and PMIC GPIO pieces these use come in separate PRs.

The Tensor G4 (zumapro) camera front end has the same Samsung DC-PHY
receiver with nine slaves for its twelve CSIS links, the clock lane
first on each and one reset bit per slave. Add its compatible; the PHY
cell is the CSIS link.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
zumapro's DC-PHY slaves sit at 0x1c100000 with the bias block at +0x1000
as on gs201, but every slave has its clock lane first and up to four data
lanes (three C-PHY trios) after it, and three slaves are a clock lane
only, which links 4 and 6 enable next to their own in four-lane D-PHY
mode. The layout comes from the Pixel 9a camera HAL's register table and
Google's GPL zuma DT; the reset bits are one per slave in the ISP-FE
system registers at +0x500.

Make the link layout per SoC with the reset bits and the partner clock
lane in it, and add zumapro's four-lane links (0, 1, 2, 4 and 6). The
data file format is unchanged.

On the Pixel 9a, link 1 (the ultrawide IMX712, four lanes at
1105.92 Mbps) powers on with settle 55, and the CSIS link receives about
30 frames a second with no SOT, CRC or ECC errors.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
zumapro has the same CSIS link (version 0x08010000 against gs201's
0x05040000, the same register layout) with twelve link contexts, but a
different DMA path. Add its compatible with the link registers and the
link interrupt only.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
zumapro's CSIS link has gs201's layout, but its frames reach memory
through the ISP front end's CSIS core, which this driver doesn't drive
yet. Add a zumapro match that maps the link only and always runs as
link_only does: PHY, link and sensor, counting frames, with no WDMA, no
routing and none of gs201's CSIS sysreg accesses (an unknown sysreg word
aborted gs201).

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
On zumapro a link's frames reach memory through the ISP front end's CSIS
core, one page shared by all links, with one interrupt for all of them.
Describe it as an optional second register range and interrupt of a
zumapro link, with the image logical channel the link writes through.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
zumapro's CSIS core takes a link's data type on one virtual channel into
an image logical channel (LoCH) and writes it to memory through its Bayer
WDMA. The register layout and fields come from the Pixel 9a camera HAL's
register table and value packers and, for the interrupt bits, Google's
GPL zuma ISP event description.

Route the link's channel 0 into a LoCH, write packed RAW10 (or RAW8) at
the stride the video node set, and program the batch slot at each start
of frame only: a configuration written during a frame is a late config
and stops the LoCH, so frames with no queued buffer go to a scratch
buffer. A status queue page takes the LoCH's per-frame record.

The link differs from gs201 in three bits the zumapro HAL sets or clears:
pixel mode 3, CMN_CTRL bit 12, and DBG_OPTION_SUITE cleared. gs201 sets
DBG_OPTION_SUITE bit 23, and with it the link hands out unpacked 16-bit
words, which gs201's WDMA expects; zumapro's core reads them as packed
RAW10 and scrambles every pixel.

On the Pixel 9a the ultrawide's solid colour test pattern (R 1023, Gr 0,
B 341, Gb 682) reads back exactly in RAW10 and RAW16, and libcamera's
simple pipeline streams it at 30 fps.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
The Pixel 9a main camera is a Samsung part with model ID 0x08e8 that
takes the GN1's register layout and data file, with a second auxiliary
supply and its digital supply switched by the board.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
The Pixel 9a main camera (model 0x08e8) powers up as stock's module power
sequence has it: the interface supply, two 2.9 V auxiliary supplies, the
analog and the digital supply, reset released, then the clock and 10 ms.
Its soft reset goes through the direct page, its standard registers too,
and its horizontal addresses count pixels. Its initialisation and modes
come from the data file, as for the other parts.

On the Pixel 9a it identifies at 0x56 and streams 2000x1128 over three
C-PHY trios.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
All zumapro links write through image LoCH 0, so a stream that stopped
with the LoCH in error (the main camera's first C-PHY attempts) left it
taking a few frames and then nothing for the next link. Disable, abort
and clear the LoCH before routing it. Count the core interrupts each link
handles in debugfs, with the last aggregate and processing sources.

Bring-up parameters for the link and the core (pixel and parallel mode,
CMN_CTRL bits, LoCH data type and memory format) stay for the C-PHY work.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
zumapro's camera software never writes the link's PHY_CMN_CTRL: its PHY
lanes are enabled in the DC-PHY transaction. Write it on gs201 only. The
ultrawide and front cameras stream as before without it.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
…ocks

A zumapro link takes the INT DVFS domain, the rail of the ISP front end's
NOC clock, and that clock, as "int" and "fe". gs201 keeps its "cam" and
"int" DVFS domains.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
ABL leaves the ISP front end's NOC clock at a sixth of SHARED3 (111 MHz).
The Pixel 9a main camera's three C-PHY trios at 2740 Msps (18.8 Gbps)
overrun the front end at that rate: the link reports ERR_DESKEW_OVER and
the LoCH a size mismatch and stream error, with a few hundred bytes of
each frame in memory. At 332 MHz every frame lands whole.

Take the INT DVFS domain (the clock's rail, through ACPM) and the front
end clock as "int" and "fe", and raise both while a link streams, the
rail first, restoring them in reverse afterwards.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
The Pixel 9a's ultrawide and front cameras are Sony IMX712s (model
0x0712), with the IMX386's register map and their own initialisation and
modes in the data file.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
The Pixel 9a's ultrawide and front cameras answer with model 0x0712 at the
IMX386's chip ID register and take the same CCS-style register map. Take
the expected model ID from the compatible, for the probe's check and the
data file's header. Both cameras stream 4208x3072 RAW10 on four D-PHY
lanes on the palmtop with their data file from the 9a's camera HAL.

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Added two commits: the IMX712 compatible for sony,imx386 and its model ID in imx386 (the 9a's ultrawide and front cameras). I'd missed them when splitting the series out of my integration tree. dt-doc-validate passes on the binding.

@derekross

Copy link
Copy Markdown
Owner

Thank you for this. It's a big series and it reads well: the per-SoC tables, the LoCH path and the clock raise are all gated on the zumapro match, and I could follow every zumapro branch back to a soc field or csis->core.

What I checked:

  • The gates pass on today's base (clean merge, sign-offs, checkpatch with the two warnings you named, W=1 on the four files, CI's dt_binding_check on the four bindings). I also built each of the 14 commits' touched objects on their own with W=1: every one builds, no warnings.
  • Cheetah: the series touches no device tree, and I validated cheetah's, felix's, lynx's, oriole's and raven's DTBs against the full binding set at the base and at your head: identical, and a cheetah CSIS node with google,image-loch added is rejected by the new schema as intended. In the code, every new gs201 field carries the old constant (wdma, 8 links, pixel mode 2, 32 address bits, bit 23, PHY_CMN_CTRL; reset_bits = BIT(i), no partner clock), so the gs201 path is the same by inspection. Since the objects still change, I'll do one camera capture on my Pixel 7 Pro with the series before merging, as you asked. The only visible difference there is pixel_mode reading -1 in sysfs; our runbooks set it explicitly, so fine.
  • Sources: Google's zuma-isp.dtsi (kernel/devices/google/zuma, the tegu branch) has the DC-PHY slaves at 0x1200/0x1700/0x2200/0x2700/0x2c00/0x3100/0x3600 with reset bits 0-6 in the sysreg at 0x1C020500, matching your table. For the LoCH, zuma-isp-event-info.dtsi gives the interrupt registers (img_proc 0x20424/0x20430, img_err 0x20438/0x20444, img_abort_done 0x20404, the aggregate 0x2008c/0x20094, LoCH 1 at 0x20824) and isp_fe.h the bits (SOF 0, EOF 1, shadow 3, DMA done 4, frame done 5; errors 0-13), all matching zumapro-csis-core.h. And the S5KGN8 order is rear_main_camera_power_seq in Google's public zuma-tegu-camera.dtsi (kernel/devices/google/tegu), 1 ms each and 10 ms after the clock, as your variant has it.

Nothing blocking. Small things for a follow-up PR, since I know you can't rewrite the commits:

  1. Cite zuma-isp-event-info.dtsi in the header for the LoCH register offsets too, not only for the bits, and name zuma-tegu-camera.dtsi in the S5KGN8 comment (its ldo4 "AF Driver IC VM" and ldo5 "VCM_DRV_ANA" comments also answer the [I] there).
  2. ZP_STRIDE_ALIGN is defined and unused (CSIS_STRIDE_ALIGN is 64, so every stride already satisfies it).
  3. The zumapro branch of the binding could also set google,wdma-input: false, like the other WDMA properties.
  4. MAINTAINERS has no entry for gs201-csis, the DC-PHY driver or the sensor drivers at all, so the checkpatch note isn't covered by an existing one; a block for the four would be welcome.
  5. One question, not a request: start_streaming programs the first slot (gs201_csis_next_buffer) before zp_core_route aborts and clears the LoCH. Your frames land whole, so the abort evidently leaves the batch address alone, but routing first would read as intended.

Two evidence asks: the tested release 7.3.0-rc6-omamobile-tegu-s2mpg15-m1 has no commit id, so could you confirm the tested gs201-csis.c and phy-gs201-mipi-dcphy-rx.c match this head (git rev-parse <commit>:<path> on both)? And please put the camera results (release, the test-pattern reads, the three cameras' cam lines and the smoke test's camera block) into the next tegu notes PR, with the DEVICES.md camera cell, so the matrix follows the evidence.

I'll merge this (rebase) after the cheetah capture, before the three userspace PRs.

@W4HO-ham

Copy link
Copy Markdown
Contributor Author

The evidence you asked for. The tested 9a ran 7.3.0-rc6-omamobile-tegu-s2mpg15-m1 from my integration tree:

  • phy-gs201-mipi-dcphy-rx.c there is this head's file (blob ed3dacc7f958).
  • gs201-csis.c there (acd8d7d0987a) differs from this head's (3dc18d2fe898) in one comment line, the PHY_CMN_CTRL note, and nothing else.

The small things are in a follow-up PR stacked on this one, #103. On your question 5: I tried programming the first slot after zp_core_route() on the palmtop. It made no difference to the frames, and none to the separate first-capture-after-a-camera-switch issue, so I left the order as it is. The camera results and the DEVICES cell go into the next tegu notes PR.

@derekross

Copy link
Copy Markdown
Owner

Thank you for the blob ids. phy-gs201-mipi-dcphy-rx.c at this head is ed3dacc7f958, exactly the file you tested, and gs201-csis.c is 3dc18d2fe898. A one-comment-line difference there doesn't change what the test covered. Thanks also for trying the slot order on the phone: a direct answer is better than my guess, and the order can stay.

I went through #103 as well. It covers the LoCH citation, the unused ZP_STRIDE_ALIGN, the S5KGN8 source and its ldo4/ldo5 roles, and the MAINTAINERS block. A correction to my own list: I asked for google,wdma-input: false in the zumapro branch of the binding, but no such property exists. The WDMA input slot is google,ebuf, and your zumapro branch already sets it to false, along with google,wdma-context and google,csis-sysreg. So there was nothing to do there. Sorry for the noise.

This branch still merges cleanly onto today's omamobile and passes the gate there: 14 sign-offs, checkpatch with the same two notes as before, and W=1 on the touched files.

What's left is on my side: one capture per camera on my Pixel 7 Pro with this series, since the gs201 path is unchanged by the tables but its objects still change. #103 goes on the same test kernel, so the one run covers both. If it's clean, I'll merge this, then #103. The camera results and the DEVICES cell in the next tegu notes PR are still welcome.

W4HO-ham added a commit to W4HO-ham/linux-omarchy-mobile that referenced this pull request Nov 1, 2026
…s#63) into tegu-dt-cameras

Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
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