Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions device/tegu/NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,76 @@ modules-push`, without a new boot image. Omarchy 4.0.6 on the phone.
removes `/dev/zram0`, and `cat /sys/class/zram-control/hot_add` brings
it back.

## 2026-11-07: the main camera's autofocus (LC898129)

Kernel `7.3.0-rc6-omamobile-push1-gd00d9fd2272f`, a local build: `omamobile`
with kernel #178, #103 and #164's camera device tree merged, the lc898129
driver ([kernel #213](https://github.com/derekross/linux-omarchy-mobile/pull/213)) and a lens node for it (below).

- [V] **The controller:** the main module's focus and OIS controller is an
onsemi LC898129 at `0x24` on the main camera's bus (`hsi2c_5`, i2c-3),
stock's `act-nessie` / `ois-nessie`. 16-bit register addresses, 32-bit
big-endian values. It shares the sensor's supplies and reset and NACKs
unless the sensor is powered (a read while the camera is stopped gives
ENXIO or a timeout).
- [V] **Where the register map comes from:** no public datasheet or driver
for the part. The register numbers and the form of a move came from
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: it reads `0xf010` and
`0x0548` and writes `0xf01a` as `0x0002` in the upper half and the
target in the lower. No code was copied. What the registers do, the
usable range and the direction below were measured on the phone.
- [V] **What was written while working it out:** only `0xf01a`, always
`0x0002` in the upper half, with lower halves from 0 to 32000 (those
above 4095 are the tries with the upper bits set). Every other access
was a register read (the two-byte address, then a 4-byte read):
`0x0000`, `0xf010`, `0xf01a`, `0xf01f`, `0xe00d`, `0xf000`, `0xf001`,
`0xf008`, `0xf00a`, `0xf100`, `0x0538` and `0x0548`. Finding the
address took only read probes: `i2cdetect -r` on the bus and a read of
`0x0000` at four other candidate addresses. The module's calibration
EEPROM, which stock puts at the same address, was never written, and
the driver writes only `0xf01a`.
- [V] **Its focus registers:** after power-up it reads `0xf010` = 7 (servo
on) and `0xf01a` = `0x00000fff` (focus target). Writing `0x0002xxxx` to
`0xf01a` moves the lens. The corrected Hall position at `0x0548` (upper
16 bits, signed) is `0xc005 + 8 * (target & 0xfff)`: linear from -16379
at 0 to 16381 at 4095, the same up and down. Targets with bits above the
low 12 also changed the framing and sharpness in ways that don't follow
the Hall position, so the driver never sets them.
- [V] **Direction:** sweeping 0-4095 with a can at about 25 cm, sharpness
rose steadily towards 0 and fell towards 4095; the picture before the
first write matched 4095. So 0 is the near end and 4095 the far end
[I: the far end not yet checked on a distant scene].
- [V] **The driver:** `lc898129` ([kernel #213](https://github.com/derekross/linux-omarchy-mobile/pull/213)) is a V4L2 lens subdev,
`V4L2_CID_FOCUS_ABSOLUTE` 0-4095 with higher values closer (it writes
4095 minus the value). The `s5kgn1` driver powers it through
`lens-focus` while streaming, as for the 7 Pro's SEM1215SA. The node:

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

with `lens-focus = <&main_lens>;` in `cam_main`. It isn't in #164; it
can go there or follow it.
- [V] **Autofocus in omacam:** the phone ran libcamera 0.7.2-4.22 with the
`Af` lines added by hand to its S5KGN8 tuning file, the same lines
0.7.2-4.23's 0057 adds. libcamera's contrast autofocus scans and settles
on the can in a little over a second, and a full-size photo (3000x3992)
is sharp on it.
- [V] **2026-11-08, the driver as reviewed** (supplies `vio`, `vm`,
`vdda`; kernel `7.3.0-rc6-omamobile-push1-ge8d722982099`, `lc898129.c`
blob `50cce3a5f4c0`, the kernel #213 head): while the main camera
streams, `focus_absolute` 0, 1024, 2048, 3072, 4095, 2048, 0 settles at
Hall 16371, 8179, -7, -8197, -16383, -4, 16369, and the lens is
runtime-suspended after the stream. libcamera's autofocus (still
4.22 with the lines by hand) sweeps 8 coarse steps over the range,
then finely around the peak, and settles there.

## 2026-11-03: the radio backup check with tools/nv-backup

- [V] **NV partitions unchanged (`7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty`):**
Expand Down
2 changes: 1 addition & 1 deletion docs/DEVICES.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions kernel/configs/omamobile.config
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ CONFIG_VIDEO_AK7375=m
# their S5K3J1 and S5KGM5 too; the telephoto's SEM1215SA focus controller.
# Blacklisted; DT nodes disabled until camera-front/camera-tele.
CONFIG_VIDEO_SEM1215=m
# The Pixel 9a's main camera focus: its LC898129 focus and OIS controller,
# powered by the S5KGN8 sensor while it streams (lens-focus).
CONFIG_VIDEO_LC898129=m
# Waydroid (device/cheetah/WAYDROID-PLAN.md W1). Binder, binderfs, PSI,
# memfd, cgroups, namespaces, bridge, veth, tun, overlayfs and fuse are
# already on. The host side (waydroid-net.sh) uses nftables only. What is
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From b621dee1388a6e691dbcf1e364c9a04786a4afd1 Mon Sep 17 00:00:00 2001
From: cbm <omarchy-mobile@kloot.lu>
Date: Sat, 7 Nov 2026 21:47:03 +0100
Subject: [PATCH] ipa: simple: Autofocus on the Pixel 9a's main camera

The S5KGN8 module's focus now has a kernel lens driver (lc898129, a
V4L2 lens subdev linked to the sensor through lens-focus), so turn the
contrast autofocus on in its tuning file, with the coarse and fine
steps the Pixel 7 Pro's main camera uses.

Tested on a Pixel 9a with omacam: a subject at about 25 cm comes into
focus in a little over a second.

Signed-off-by: cbm <omarchy-mobile@kloot.lu>
---
src/ipa/simple/data/s5kgn8.yaml | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/ipa/simple/data/s5kgn8.yaml b/src/ipa/simple/data/s5kgn8.yaml
index 51ca9b0..c6a3d22 100644
--- a/src/ipa/simple/data/s5kgn8.yaml
+++ b/src/ipa/simple/data/s5kgn8.yaml
@@ -2,7 +2,7 @@
#
# Samsung S5KGN8 (the Pixel 9a's main camera), not calibrated yet. The
# black level comes from the sensor's helper. No colour matrix until one is
-# fitted on daylight shots, and no autofocus until the lens has a driver.
+# fitted on daylight shots.
%YAML 1.1
---
version: 1
@@ -19,4 +19,9 @@ algorithms:
denoise: 0.015
chromaDenoise: 0.03
- Agc:
+ # Contrast autofocus through the module's LC898129 lens (0-4095), with
+ # the scan steps of the Pixel 7 Pro's main camera
+ - Af:
+ coarseSteps: 8
+ fineSteps: 32
...
--
2.56.0

14 changes: 10 additions & 4 deletions packages/libcamera/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@
# - 0056-libcamera-Add-the-Samsung-S5KGN8-sensor.patch: the Pixel 9a's main
# camera: its black level (64 at 10 bits, measured), linear gain and an
# uncalibrated tuning file (it ran with no helper before).
# - pkgrel 4.22, so it sorts above Arch Linux ARM's 0.7.2-4.
# - 0057-ipa-simple-Autofocus-on-the-Pixel-9a-s-main-camera.patch: contrast
# autofocus on the Pixel 9a's main camera, through its LC898129 lens driver.
# - pkgrel 4.23, so it sorts above Arch Linux ARM's 0.7.2-4.
#
# Maintainers of the original: David Runge, Carl Smedstad.

Expand All @@ -195,7 +197,7 @@ pkgname=(
python-libcamera
)
pkgver=0.7.2
pkgrel=4.22
pkgrel=4.23
pkgdesc="A complex camera support library for Linux, Android, and ChromeOS (Omarchy Mobile: gs201 CSIS)"
arch=(aarch64)
url="https://libcamera.org/"
Expand Down Expand Up @@ -284,6 +286,7 @@ source=(
0054-pipeline-simple-Pass-the-start-controls-to-the-softw.patch
0055-software_isp-debayer_egl-Correct-defective-pixels-be.patch
0056-libcamera-Add-the-Samsung-S5KGN8-sensor.patch
0057-ipa-simple-Autofocus-on-the-Pixel-9a-s-main-camera.patch
)
sha512sums=('a5656356617a01a7e8feb535380869d38b7c58139c7f99385af355629d3e1927bbd8847f7bec755c753c72f6b065df76de53c15f9af2e5901e83e7a144a2ddcd'
'8b54cbdf6ed767ae8d52a14480a4653f4f3a1c2187c4ccf7ceb65eaa60c819cce514122591d6e0c2dfc39d7482739f8fdd4090dbaf63701445510eefc88fb19f'
Expand Down Expand Up @@ -342,7 +345,8 @@ sha512sums=('a5656356617a01a7e8feb535380869d38b7c58139c7f99385af355629d3e1927bbd
'6717f9f27c9822d5b21fb132b363227d72929ed9e4aa4e0d5521dac1039c101de318672cb25918b963c4b7394bd8a58d85edf418afa61bda7ee3358d482371e4'
'8a80d2c8aa85f15c2fde64cbcb1fb9a55f257bb4414007672583e3602dc3897cce82e829ede22de928245b2f142e4aad09deeb06b9d2b6990a45c840e948e898'
'4f618bd8f45eb5499dce75be70f62f7091fa61f3121a8067fcb38fcdb9eb778cc1d8f2c94daed0f5f9815bb8da1712f0515e2332544273595df18b1a422a0706'
'9bdbac40cf508f2068e4570da62d736509f0ef0617e60723ddcfdfb7f42d04c0d9f856faae52756b74b4d5971e6ada5ac61109f7b411c45a40ccb830b4249ade')
'9bdbac40cf508f2068e4570da62d736509f0ef0617e60723ddcfdfb7f42d04c0d9f856faae52756b74b4d5971e6ada5ac61109f7b411c45a40ccb830b4249ade'
'ce713ca43e1a10001d1a433af097d7720448e6bcda7f6ccce6855bf6ac0fae87df0b0507cceab34d39af62cafb2b4861c790b4f156d4e6ec05b070f80f451f4a')
b2sums=('1dbd3f78f8d9a2484331798b18b871d7585b5928988e91d586366049d85e3f126e7cfc58494400e69feeec99a77894252d582f0d8f183508e5d1b8220e70f3d5'
'4a0e24feed22d32b83b0ec49c9a7616b77deb26cae82c17a38b54a81a0468e982852147bc2d5e3b611ba014ddbd7647acfe2e68591542420da73945ba1c0d6c2'
'cba8b638543a16bf80c2ae7dc0737f3874476fd1ff694639b459184725848e193518778d0336eef3d55ba4329d9bc63981d0aa8d8d9b5507c9ade4f17f7f407d'
Expand Down Expand Up @@ -400,7 +404,8 @@ b2sums=('1dbd3f78f8d9a2484331798b18b871d7585b5928988e91d586366049d85e3f126e7cfc5
'b27b0e12bd345b8590d26cc1401f9cff8fd0777ba40a2d186e3db5e98edae84c8eb54fdf9c9bccd5c301d170907272a77cfd66bc40387a5bf5aaf15c8faad69b'
'63c4bc9556ee28ea34f246ebe2c87a59f5dd50e56218ed5a9e2bb95af16d06672561b0981e3e0475cd885a7b7b8c4112cf203710e7e126cbf9de62e28b6a567f'
'd58a82be4991c6b4d46be10d0c2c21e7c4a5898c0f997bf64bc2b21702c5071e8e04020faf1389e7091b2f9060a71f41f3f15d8d7b491a167fef650588ecf889'
'82d09fef3abf67f5c3c6905d056faba7ba6b20edc3d9f6aa887d50c4372a2af770517e8974a53c3fd460fd0eec045804a3cf64191cfe966ec7fc11d23a61426a')
'82d09fef3abf67f5c3c6905d056faba7ba6b20edc3d9f6aa887d50c4372a2af770517e8974a53c3fd460fd0eec045804a3cf64191cfe966ec7fc11d23a61426a'
'1269473d5f4c8b327560312d1793f9f559bf82e178ecb35bb811d40ecdc5768ee803b27387951cfe62b070f6e60920f84ad669d246dcd0ad1732e3ba6b7f7e7b')

_pick() {
local p="$1" f d; shift
Expand Down Expand Up @@ -471,6 +476,7 @@ prepare() {
patch -Np1 < ../0054-pipeline-simple-Pass-the-start-controls-to-the-softw.patch
patch -Np1 < ../0055-software_isp-debayer_egl-Correct-defective-pixels-be.patch
patch -Np1 < ../0056-libcamera-Add-the-Samsung-S5KGN8-sensor.patch
patch -Np1 < ../0057-ipa-simple-Autofocus-on-the-Pixel-9a-s-main-camera.patch

# add version, so that utils/gen-version.sh may rely on it
printf "%s\n" "$pkgver" > .tarball-version
Expand Down
1 change: 1 addition & 0 deletions packages/libcamera/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ in the table. See `device/cheetah/CAMERA-PLAN.md`, section 5.2.
| `0054-pipeline-simple-Pass-the-start-controls-to-the-softw.patch` | The simple pipeline hands `Camera::start()`'s controls to the software ISP's IPA with the first request; without it a restarted camera kept the previous session's manual exposure mode |
| `0055-software_isp-debayer_egl-Correct-defective-pixels-be.patch` | Defective pixel correction in a pass before the debayer, on the packed bytes: a sample beyond its eight same-colour neighbours' range is clamped to it. `LIBCAMERA_SOFTISP_NO_DPC` turns it off |
| `0056-libcamera-Add-the-Samsung-S5KGN8-sensor.patch` | The S5KGN8 (the Pixel 9a's main camera) sensor helper, with the black level measured on the phone (64 at 10 bits) and the code / 32 gain, its properties, and an uncalibrated tuning file without a colour matrix or autofocus |
| `0057-ipa-simple-Autofocus-on-the-Pixel-9a-s-main-camera.patch` | Contrast autofocus on the S5KGN8, through the module's LC898129 lens driver, with the Pixel 7 Pro main camera's scan steps |
| `libcamera-fix-python3.14-macro-redefinition.patch` | Arch's patch, unchanged (sha512 `8b54cbdf…`) |
| `.SRCINFO` | `makepkg --printsrcinfo` output |

Expand Down