Skip to content

media: i2c: onsemi LC898129 lens driver (Pixel 9a main camera focus) - #213

Merged
derekross merged 2 commits into
derekross:omamobilefrom
den-kloot:omamobile-lc898129
Nov 8, 2026
Merged

derekross merged 2 commits into
derekross:omamobilefrom
den-kloot:omamobile-lc898129

Conversation

@den-kloot

Copy link
Copy Markdown
Contributor

A V4L2 lens driver for the Pixel 9a's main camera focus, so libcamera's contrast autofocus can drive it, as on the Pixel 7 Pro (announced in omarchy-mobile#28).

The main module's focus and OIS controller is an onsemi LC898129 (stock act-nessie / ois-nessie) at 0x24 on the main camera's bus. It shares the S5KGN8's supplies and reset and only answers while the sensor is powered, so it works like the SEM1215SA: runtime PM only, taken by s5kgn1 through lens-focus while streaming.

  • dt-bindings: media: i2c: add onsemi LC898129: the binding. Supplies optional: the sensor powers the module.
  • media: i2c: add an onsemi LC898129 lens driver: V4L2_CID_FOCUS_ABSOLUTE 0-4095, higher = closer. It writes only the focus target (0xf01a = 0x0002xxxx). The OIS and calibration memory are never written. The commit message has the measurements: the Hall read-back follows the low 12 bits of the target linearly, and 0 is the near end.

Not in this PR: the board's lens node. The 9a's camera nodes are still in #164, so the node can't go on omamobile yet. It is four lines, in zumapro-tegu.dts next to cam_main:

main_lens: lens@24 {
	compatible = "onnn,lc898129";
	reg = <0x24>;
	vio-supply = <&cam_1v8>;
};

plus lens-focus = <&main_lens>; in cam_main. It can go into #164, or into a follow-up once #164 is in, whichever you and @W4HO-ham prefer.

Tested on a Pixel 9a, kernel 7.3.0-rc6-omamobile-push1-gd00d9fd2272f (a local build: omamobile + #178, #103 and #164's camera device tree, these two commits and the lens node above):

  • the driver probes at boot (lc898129 3-0024), shows up as a lens subdev, and powers up with the sensor;
  • the lens follows the control across 0-4095 (Hall read-back with debug_position), and sharpness changes steadily with it;
  • with Af in the S5KGN8 tuning file (companion omarchy-mobile PR), omacam's contrast autofocus settles on a subject at about 25 cm in a little over a second, and a full-size photo (3000x3992) is sharp.
  • Not tested yet: the far end on a distant scene.

tools/kernel-pr-check --build OUT --merge origin/omamobile: merge, sign-off, prefix, policy and dt_binding_check pass, and checkpatch --strict has no errors. Its two warnings are the MAINTAINERS question for the new files, as for sem1215. The W=1 build of lc898129.c is clean (no warnings). On this laptop it needed bc for timeconst.h, so I ran it by hand with that one header generated in the kbuild container.

The changes were written with an AI assistant (Claude). I tested them on my phone and signed them off.

🤖 Generated with Claude Code

@derekross

Copy link
Copy Markdown
Owner

Thanks for this, and for keeping it to the focus part: writing one register,
leaving the OIS and the calibration memory alone, and modelling it on the
SEM1215SA path makes it easy to follow. The measurements in the message (the
Hall read-back over the whole stroke, the direction) are exactly what I want
to see. I ran the gate merged onto today's omamobile: clean merge,
checkpatch with only the MAINTAINERS warnings, a clean W=1 build, and I
validated the binding and its example with dtschema locally (CI is waiting
for my approval; I'll start it).

One thing before I merge:

  • Where did the register map come from? Google's tegu camera DT
    confirms 0x24 on hsi2c_5, 16-bit addresses and 32-bit values, but
    nothing public that I can find names 0xf010, 0xf01a with its 0x0002
    upper half, or the Hall position at 0x0548. Could you add a sentence to
    the driver commit's message on how you found them? If it was from the
    camera HAL's configuration or files on the phone's vendor partition,
    please say so in those words (we can describe a protocol, never copy
    code); if it was a public GPL driver for the part, please cite the file
    and commit.

Smaller points, none blocking:

  • The binding lists me as its maintainer. I'd rather it named you, since you
    wrote it and have the hardware (both of us is fine too).
  • Stock's actuator node gives the AF part two module rails besides I/O:
    LDO4 "AF Driver IC VM" and LDO5 "VCM_DRV_ANA (VDDA)". Since a binding
    describes the hardware, vm-supply and vdda-supply would match it
    better than one vdd-supply. Nothing uses it yet, so now is the cheap
    time to change it.
  • Because stock puts the module's EEPROM at the same address, could the 9a
    notes say which registers you wrote while working out the protocol (only
    0xf01a, I assume, including the tries with the upper bits set)? I'd like
    the record to show nothing else was touched.
  • If you still have the tested tree, the blob id of the lc898129.c you
    ran (git hash-object) would tie the test to this commit; the head's is
    3d86990b6acc.

The board's lens node can go into #164 or follow it, whichever W4HO-ham
prefers. On the omarchy-mobile side, #494 merges after this one.

cbm added 2 commits November 8, 2026 07:58
The LC898129 is a microcontroller that drives a camera module's focus
and optical image stabilisation actuators and holds the module's
calibration memory, over I2C with 16-bit register addresses and 32-bit
values. The Google Pixel 9a's main camera module has one. It shares the
module's supplies and reset with the image sensor, so the sensor powers
it while streaming through its lens-focus property. The supplies follow
the stock device tree's actuator node: the I/O supply, the actuator
driver's VM and its analogue VDDA. All are optional, since the sensor
already switches them; listed, they only keep the rails counted.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: cbm <omarchy-mobile@kloot.lu>
The Pixel 9a's main camera focuses through an LC898129, which also runs
the module's optical image stabilisation. Add a V4L2 lens subdev for its
focus part only, so libcamera's contrast autofocus can drive it like the
other focus drivers.

The controller shares the module's supplies and reset with the sensor
and answers only while the sensor is powered, so, as for the SEM1215SA,
it is powered through runtime PM only: the sensor driver holds its
lens-focus device while streaming. Power-up waits until the controller
answers a read of its servo mode (0xf010), up to 200 ms, then moves the
lens to the control's value.

There is no public datasheet or driver for the part. The register
numbers and the form of a move were found by disassembling Google's
camera HAL for the Pixel 9a: the LC898129 actuator code in
liblyric_hwl.so, from the com.google.pixel.camera.hal APEX on the vendor
partition of factory image BP3A.250905.014. That code reads 0xf010 and
0x0548 and writes 0xf01a with 0x0002 in the upper half and the target
in the lower half. No code was copied. What the registers do, the
usable range and the direction were worked out on the phone, by reading
registers and writing 0xf01a alone while measuring the picture's
sharpness.

After power-up the controller runs its focus servo by itself (0xf010
reads 7) and holds the lens at 0x0fff in the focus target register,
0xf01a. A move writes 0x0002 in the upper half of 0xf01a and the target
in the lower half. On the phone the corrected Hall position (0x0548,
upper half) followed the target's low 12 bits linearly over the whole
stroke, from -16379 at 0 to 16381 at 4095, and was the same going up and
down; setting bits above those also moved the picture in other ways, so
the driver keeps to 0-4095. Register 0 is the near end and 4095 the far
end, so the control counts the other way round: higher values focus
closer, as V4L2_CID_FOCUS_ABSOLUTE expects. Its default, 0, is where the
controller parks the lens itself.

Only 0xf01a is written. The OIS and the calibration memory are left
alone, so the control spans the whole stroke rather than the module's
calibrated infinity-to-macro range. debug_position logs the Hall
position read back after each move.

Tested on a Pixel 9a with 7.3.0-rc6-omamobile-push1-ge8d722982099, on
top of the camera device tree of linux-omarchy-mobile#164, whose
lc898129.c is this commit's (blob 50cce3a): while the main camera
streams, focus_absolute 0, 1024, 2048, 3072, 4095, 2048, 0 settle at a
Hall position of 16371, 8179, -7, -8197, -16383, -4 and 16369, and the
lens is runtime-suspended again after the stream. libcamera's contrast
autofocus (simple pipeline, soft ISP) sweeps the range in 8 coarse
steps, then finely around the peak, and settles there; in omacam it
brings a subject at about 25 cm into focus.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: cbm <omarchy-mobile@kloot.lu>
@den-kloot

Copy link
Copy Markdown
Contributor Author

Thanks for the careful read. Force-pushed:

  • Where the register map came from: the driver commit says so now. There is no public datasheet or driver for the part. I found the register numbers and the form of a move by disassembling the LC898129 actuator code in Google's camera HAL: liblyric_hwl.so, in the com.google.pixel.camera.hal APEX on the vendor partition of factory image BP3A.250905.014. That code reads 0xf010 and 0x0548 and writes 0xf01a with 0x0002 in the upper half. No code was copied. What the registers do, the usable range, the direction and the Hall scale I measured on the phone.
  • Maintainer: the binding names me now.
  • Supplies: vm-supply and vdda-supply replace vdd-supply, after stock's LDO4 and LDO5. The driver asks for vio, vm and vdda, all optional as before.
  • What was written: the 9a notes (in omarchy-mobile#494) list it. Only 0xf01a was ever written, always with 0x0002 in the upper half, with lower halves from 0 to 32000; the ones above 4095 were the tries with the upper bits set. Every other access was a register read, and the notes list each register read. Finding the address took only read probes. The EEPROM was never written.
  • The tested tree: because the supplies change the file, I rebuilt and re-tested on 7.3.0-rc6-omamobile-push1-ge8d722982099, whose lc898129.c is the new head's (50cce3a5f4c0). The Tested paragraph names that build and blob and gives the results:
    • focus_absolute 0, 1024, 2048, 3072, 4095, 2048, 0 settled at Hall 16371, 8179, -7, -8197, -16383, -4, 16369;
    • the lens is runtime-suspended after the stream;
    • libcamera's autofocus does its coarse and fine sweep and settles.

tools/kernel-pr-check --build merged onto today's omamobile (d349a61dd): all ok. Clean W=1 build, dt_binding_check ok, and only the MAINTAINERS warnings.

On the lens node: whatever W4HO-ham prefers. I can send it as a small follow-up once #164 lands.

@derekross

Copy link
Copy Markdown
Owner

Thanks for working through all of these. The provenance paragraph is
exactly what I hoped for: it says where the four register numbers and the
form of a move came from, that no code was copied, and that what the
registers do was measured on the phone. That's the way we describe a
protocol here, and it's checkable.

I checked the rest on my side:

  • The supply split matches stock's actuator node. I validated the binding
    with dtschema locally: the example passes, a node with vio, vm and
    vdda passes, and one with the old vdd-supply is now rejected.
  • The lc898129.c blob you name (50cce3a5f4c0) is the head's, so the new
    Tested numbers are on the code that lands, supplies included.
  • The list of registers you wrote and read in the 9a notes (#494) is what I
    wanted for a part that shares its address with the calibration EEPROM.
    Thank you for being so thorough about it.

The gate passes merged onto today's omamobile: clean W=1 build, only the
MAINTAINERS warnings. The CI run on this push shows as cancelled before it
started, so I'll re-run it and merge once it's green, then #494 on the
omarchy-mobile side. A small follow-up for the lens node once #164 lands
sounds right to me.

@derekross
derekross merged commit b24d7c8 into derekross:omamobile Nov 8, 2026
1 of 2 checks passed
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