aboutsummaryrefslogtreecommitdiffci
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
authorGravatar Saya Andy <saya.andy@posteo.com> 2026-09-07 18:28:41 +0700
committerGravatar Saya Andy <saya.andy@posteo.com> 2026-09-07 18:28:41 +0700
commitbc5afb8aeb1009749dc310729cd456949ecb6fd6 (patch)
tree49f076486b36d9b9265f93fd26382e7031a726a9
parent3fe9661487038d66add7c609d16f1dfd2854b7ab (diff)
downloadlibcamera-bc5afb8aeb1009749dc310729cd456949ecb6fd6.tar.gz
libcamera-bc5afb8aeb1009749dc310729cd456949ecb6fd6.zip
feat: ipa: simple: awb: keep the gains across reconfigurationfedora-45-libcamera-sp12in2main
fixes the issue with green tinted photos on front camera
-rw-r--r--README.md3
-rw-r--r--patches/0004-ipa-simple-awb-keep-gains-across-reconfiguration.patch63
2 files changed, 66 insertions, 0 deletions
diff --git a/README.md b/README.md
index 0b3b0ca..880b7ca 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,9 @@ which matches the kernel driver, where `OV02C10_REG_ANALOG_GAIN` runs from
| Patch | Fixes |
| --- | --- |
| `patches/0001-libipa-camera_sensor-add-ov02c10.patch` | Adds the `ov02c10` `CameraSensorHelper` (gain `code/16`, black level `0x40` at 10 bits) and its `camera_sensor_properties` entry. |
+| `patches/0002-pipeline-simple-capture-bayer-order-from-mbus-code.patch` | Takes the capture device's Bayer order from the media bus code the pipeline reports instead of deriving it from the transform, so the rear camera streams. |
+| `patches/0003-ipa-simple-data-add-ov02c10-tuning-file.patch` | Adds `ov02c10.yaml`, enabling a CCM for the front camera. Hand-tuned, not measured against a colour target. |
+| `patches/0004-ipa-simple-awb-keep-gains-across-reconfiguration.patch` | Keeps the AWB gains over a reconfiguration, so a still captured right after one is not rendered with the sensor's raw white balance. |
## Versioning
diff --git a/patches/0004-ipa-simple-awb-keep-gains-across-reconfiguration.patch b/patches/0004-ipa-simple-awb-keep-gains-across-reconfiguration.patch
new file mode 100644
index 0000000..8bc5628
--- /dev/null
+++ b/patches/0004-ipa-simple-awb-keep-gains-across-reconfiguration.patch
@@ -0,0 +1,63 @@
+ipa: simple: awb: Keep the gains across a reconfiguration
+
+Awb::configure() resets the colour gains to 1.0, so every reconfiguration
+throws away the white balance the previous one had converged on and the first
+frames of the new configuration are rendered with the sensor's raw white
+balance.
+
+An application that reconfigures the camera and captures immediately therefore
+gets a tinted image, which is what taking a still picture with GNOME Snapshot
+does on the Surface Pro 12in: its preview is correctly balanced, and the
+picture it writes is heavily green, because the still is captured at a
+different resolution than the preview and the frame it keeps is the first one
+after the reconfiguration. Captured through PipeWire, the front camera needs
+two frames to converge:
+
+ frame R/G B/G
+ 0 0.709 0.805
+ 1 0.516 0.734
+ 2 1.045 0.920
+ 44 1.044 0.905
+
+The gains describe the scene in front of the sensor, not the stream
+configuration, so keep them and only initialise them once.
+
+--- a/src/ipa/simple/algorithms/awb.h
++++ b/src/ipa/simple/algorithms/awb.h
+@@ -29,6 +29,9 @@
+ IPAFrameContext &frameContext,
+ const SwIspStats *stats,
+ ControlList &metadata) override;
++
++private:
++ bool initialised_ = false;
+ };
+
+ } /* namespace ipa::soft::algorithms */
+--- a/src/ipa/simple/algorithms/awb.cpp
++++ b/src/ipa/simple/algorithms/awb.cpp
+@@ -26,8 +26,24 @@
+ int Awb::configure(IPAContext &context,
+ [[maybe_unused]] const IPAConfigInfo &configInfo)
+ {
++ /*
++ * Initialise the gains on the first configuration only.
++ *
++ * A camera can be reconfigured while it keeps looking at the same
++ * scene, which is what an application does when it captures a still
++ * picture at a different resolution than the one its preview runs at.
++ * Discarding the gains that the previous configuration converged on
++ * then paints the first frames of the new one with the sensor's raw
++ * white balance, and an application that captures straight away gets a
++ * tinted picture. The gains are a property of the scene rather than of
++ * the stream configuration, so carry them over.
++ */
++ if (initialised_)
++ return 0;
++
+ auto &gains = context.activeState.awb.gains;
+ gains = { { 1.0, 1.0, 1.0 } };
++ initialised_ = true;
+
+ return 0;
+ }