[v2,0/4] Simple pipeline: proportional AGC, AWB stats fix, OV2740 tuning
mbox series

Message ID 20260304232519.335E61EA006B@mailuser.phl.internal
Headers show
Series
  • Simple pipeline: proportional AGC, AWB stats fix, OV2740 tuning
Related show

Message

Javier Tia March 4, 2026, 11 p.m. UTC
This series fixes AGC oscillation and an AWB statistics bug in the
Simple pipeline, and adds the first sensor-specific tuning file for
the SoftISP.

Patch 1 replaces the fixed 10% bang-bang step in the AGC with a
proportional controller where step size scales with the MSV error.
This eliminates the brightness flicker observed on sensors with
non-trivial control latency (tested on OV2740 behind Intel
IPU6/IVSC). Unchanged from v1.

Patch 2 fixes a bit-depth mismatch in the statistics gathering.
The SWSTATS_ACCUMULATE_LINE_STATS() macro divides the luminance value
for the histogram to normalize it to 8-bit range, but does not apply
the same normalization to the RGB sums. For 10-bit and 12-bit
unpacked Bayer formats, the sums are accumulated at native bit depth
while the AWB subtracts an 8-bit black level, under-correcting by 4x
or 16x respectively. This skews the AWB grey world gains, producing a
visible color cast (~9% green on the OV2740 with BLC=16). The fix
right-shifts the RGB sums in finishFrame() to normalize them to 8-bit
scale, matching the histogram and the 8-bit BLC used by AWB.

Patch 3 adds an OV2740 tuning file. With the AWB fix from patch 2,
no CCM is needed - AWB grey world convergence gives R/G ~ 0.98 and
B/G ~ 0.99 under 6500K lighting.

Patch 4 adds the OV2740 black level (4096, i.e. 0x40 at 10-bit) to
CameraSensorHelperOv2740, following the established pattern used by
OV5675, IMX219, and other sensors. This is the canonical location for
sensor calibration data and is used across all pipeline handlers.

Changes since v1:
- Patch 2: New. Fixes the AWB/BLC bit-depth mismatch for >8-bit
  sensors, eliminating the green cast without needing a CCM.
- Patch 3 (was patch 2 in v1): Removed CCM - no longer needed with
  the AWB fix. Removed explicit blackLevel from the tuning file;
  the value is now provided by CameraSensorHelperOv2740 (patch 4)
  as suggested by Robert Mader.
- Patch 4 (was patch 3 in v1): Unchanged.

Tested on ThinkPad X1 Carbon Gen 10 (Alder Lake, OV2740, IPU6 ISYS,
CachyOS kernel 6.19.3, libcamera 0.7.0).

Test results (converged frames, 6500K lighting, no CCM):

  With AWB fix (v2):    R/G=0.984  B/G=0.985  (~1.5% residual)
  Without fix (v1):     R/G=0.910  B/G=0.904  (~9% green cast)
  BLC=0 control:        R/G=1.000  B/G=1.001  (proves the mismatch)

Javier Tia (4):
  ipa: simple: agc: Replace bang-bang controller with proportional
  libcamera: software_isp: Normalize statistics sums to 8-bit
  ipa: simple: data: Add OV2740 tuning file
  ipa: libipa: camera_sensor_helper: Add OV2740 black level

 .../internal/software_isp/swstats_cpu.h       |  1 +
 src/ipa/libipa/camera_sensor_helper.cpp       |  2 +
 src/ipa/simple/algorithms/agc.cpp             | 73 +++++++++++++------
 src/ipa/simple/data/meson.build               |  1 +
 src/ipa/simple/data/ov2740.yaml               | 13 ++++
 src/libcamera/software_isp/swstats_cpu.cpp    |  9 +++
 6 files changed, 75 insertions(+), 24 deletions(-)
 create mode 100644 src/ipa/simple/data/ov2740.yaml