fp6-img/aports/temp/libcamera/imx896.yaml
Jorijn van der Graaf 48cedac3c3 libcamera: stabilize AWB with a white point locus clamp + damping (r8)
The softISP AWB is pure gray world, so panning swings ColourGains with
the frame average (white wall renders green when the frame is
warm-dominated, dark desk renders red when cool-dominated) and the CCM,
interpolated over a CT estimated from those gains, amplifies and
quantizes the swings.

Patch 0015 (ours, original work) adds optional per-sensor Awb tuning to
the simple IPA: a piecewise-linear locus of calibrated illuminant white
points in gain space that the gray-world estimate is clamped to
(clampMargin), a per-stats-frame EMA on the applied gains (damping)
with a fast-converge path for persistent illuminant changes, and CT
interpolated from the applied gains' position along the locus - on the
same scale as the tuning file's ccms table - instead of the generic
estimateCCT(). Tuning files without whitePoints keep the previous
behaviour exactly, so every other sensor is unaffected.

imx896.yaml gains the locus from the stock tuning blob's 10-point
per-illuminant AWB calibration (white points and their exactly
reciprocal gain triplets, cross-validated): the 7 on-locus points as
nodes, the 3 fluorescent points admitted via clampMargin 0.35. The
5000 K label is the blob's own proven anchor; 2856 K (A) is locked by
the fluorescent trio projecting onto the 2856-5000 chord at ~3960 K
(TL84); the rest are geometry-derived approximations.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-17 03:24:56 +02:00

77 lines
3.6 KiB
YAML

# libcamera softISP tuning for the Fairphone 6 main camera (Sony IMX896).
#
# CCMs extracted from the FP6 stock Android tuning blob
# com.qti.tuned.fp6_tsp_imx896.bin (vendor_a.img, sha256 0500766f...c1a5d29f),
# CamX cc13_ope_v2 module, tree root at 0x2709fe: 3 lux zones, 3-5 CCT
# regions each, offsets all zero, rows sum to 1.0. This file carries the
# BRIGHT zone (lux-index trigger 1-200) — the true-color tuning, same
# convention as the sibling ov13b10.yaml. Note the bright zone has only
# three CT nodes and merges D50/D65 into one 4800-6700 K region (node
# placed at its 5750 K midpoint); the lowlight zone has proper 5000/6500 K
# nodes but at reduced saturation (chroma-noise hiding) — see
# chromatix/imx896-ccm-awb-extracted.txt for all 12 matrices.
# CT nodes = the chromatix CCT trigger midpoints: 2800 (A), 4000 (TL84),
# 5750 (merged D50/D65 region).
#
# blackLevel: measured on the FP6 2026-08-17 (raw RDI dark frames, phone
# face-down, min analogue gain): 10-bit pedestal 64.0 exact (mean 63.98,
# median 64, p1/p99 63/65) -> 4096 on the 16-bit scale. The softISP's
# dynamic estimate ran at 48, leaving a 16-code residual the CCM amplified
# into colour casts in dark regions.
#
# Awb whitePoints: the 10-point per-illuminant AWB calibration from the
# same blob (white points @0x1c69ed, gain triplets @0x1c2dba — exact
# reciprocals of each other, cross-validated to float precision). The
# locus below carries the 7 on-locus points as (R gain, B gain), warm to
# cool. The 3 fluorescent points (idx 4-6) are deliberately NOT locus
# nodes: they sit ~0.33 gain units off the A-D50 chord (green side) and
# would zigzag the locus; clampMargin 0.35 admits them instead. CT
# labels: 5000 K is PROVEN (the blob's default gain + CCT anchor at
# index 3); 2856 K (illuminant A) is locked by two independent checks —
# sensor-typical A ratios AND the fluorescent trio projecting onto the
# 2856-5000 chord at ~3960 K, i.e. exactly TL84; the remaining labels
# are geometry-derived approximations (the blob stores no CCT list).
# Same ct scale as the ccms table below. damping = per-stats-frame EMA
# (stats run every 4th frame), ~1 s settling at 30 fps.
#
# PROVENANCE / LICENSE: the matrices are numeric calibration data read out
# of the proprietary vendor blob (measured spectral response of this
# sensor, not authored expression). Shipping decided 2026-08-17 by the
# project owner, consistent with existing practice in this image; NOT
# marked CC0. Durable replacement: measure our own matrices from a colour
# chart with libcamera's tuning tooling.
%YAML 1.1
---
version: 1
algorithms:
- BlackLevel:
blackLevel: 4096
- Awb:
whitePoints:
- { ct: 1900, gains: [ 0.878997, 4.771635 ] }
- { ct: 2300, gains: [ 1.119141, 3.340533 ] }
- { ct: 2856, gains: [ 1.377957, 2.769483 ] }
- { ct: 5000, gains: [ 2.037341, 1.809127 ] }
- { ct: 6504, gains: [ 2.367133, 1.574040 ] }
- { ct: 7504, gains: [ 2.741927, 1.357219 ] }
- { ct: 9500, gains: [ 4.508486, 1.012164 ] }
clampMargin: 0.35
damping: 0.8
- Ccm:
ccms:
- ct: 2800
ccm: [ 1.593410, -0.552769, -0.040641,
-0.166429, 1.170414, -0.003985,
0.004114, -0.855526, 1.851411 ]
- ct: 4000
ccm: [ 1.612519, -0.785270, 0.172751,
-0.110672, 1.189965, -0.079293,
0.091939, -0.965137, 1.873197 ]
- ct: 5750
ccm: [ 1.900000, -0.581250, -0.318750,
-0.292500, 1.778126, -0.485626,
0.014573, -0.734843, 1.720270 ]
- Adjust:
- Agc:
- Af:
...