[v4,0/3] Simple pipeline: proportional AGC, AWB stats fix, OV2740 black level
mbox series

Message ID 20260306-agc-proportional-v4-0-e87c7e0d837a@jetm.me
Headers show
Series
  • Simple pipeline: proportional AGC, AWB stats fix, OV2740 black level
Related show

Message

Javier Tia March 6, 2026, 6:46 p.m. UTC
This series fixes AGC oscillation and an AWB statistics bug in the
Simple pipeline, and adds the OV2740 black level to the sensor helper.

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).

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 the OV2740 black level (4096, i.e. 0x40 at 10-bit) to
CameraSensorHelperOv2740, following the established pattern used by
OV5675, IMX219, and other sensors.

Changes since v3:
- Patch 1: Removed kExpMaxStep and the std::clamp - the proportional
  gain is applied directly, since the maximum error of ~2.5 already
  bounds the step to ~10%. (Barnabas)
- Patch 2: Replaced per-case sumShift_ assignments with
  sumShift_ = bayerFormat.bitDepth - 8. (Barnabas)
- Patch 3: No changes.

Changes since v2:
- Dropped the OV2740 tuning file patch (identical to uncalibrated.yaml
  without a CCM). A follow-up with calibrated CCMs is planned.
- Rebased onto current master.

Signed-off-by: Javier Tia <floss@jetm.me>
---
Javier Tia (3):
      ipa: simple: agc: Replace bang-bang controller with proportional
      libcamera: software_isp: Normalize statistics sums to 8-bit
      ipa: libipa: camera_sensor_helper: Add OV2740 black level

 .../libcamera/internal/software_isp/swstats_cpu.h  |  1 +
 src/ipa/libipa/camera_sensor_helper.cpp            |  2 +
 src/ipa/simple/algorithms/agc.cpp                  | 65 ++++++++++++++--------
 src/libcamera/software_isp/swstats_cpu.cpp         |  7 +++
 4 files changed, 51 insertions(+), 24 deletions(-)
---
base-commit: 14ba4d168085dd27aed9bcb043996d6a5f28867e
change-id: 20260305-agc-proportional-ba20bf95f40b

Best regards,