summaryrefslogtreecommitdiff
path: root/src/ipa/rkisp1/algorithms/awb.cpp
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2022-08-18 18:01:08 +0900
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-08-19 18:14:16 +0300
commit3200bb635ccd64d5997bc372d9fa6bc894b2f9d0 (patch)
tree8c292ff45a868d26b000286607f848725f2753e1 /src/ipa/rkisp1/algorithms/awb.cpp
parentbf3dbaece91e7f9be00923a225a62a918bf71f5b (diff)
ipa: rkisp1: Add manual color gains
Add support for manually controlling the color gains on the rkisp1 IPA. To that end, add and plumb the AwbEnable and ColourGains controls. As per-frame controls aren't supported yet in the rkisp1 IPA, simply apply and perform checks on the controls immediately. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/ipa/rkisp1/algorithms/awb.cpp')
-rw-r--r--src/ipa/rkisp1/algorithms/awb.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
index 9f00364d..a3c14a9a 100644
--- a/src/ipa/rkisp1/algorithms/awb.cpp
+++ b/src/ipa/rkisp1/algorithms/awb.cpp
@@ -12,6 +12,7 @@
#include <libcamera/base/log.h>
+#include <libcamera/control_ids.h>
#include <libcamera/ipa/core_ipa_interface.h>
/**
@@ -38,6 +39,7 @@ int Awb::configure(IPAContext &context,
context.frameContext.awb.gains.red = 1.0;
context.frameContext.awb.gains.blue = 1.0;
context.frameContext.awb.gains.green = 1.0;
+ context.frameContext.awb.autoEnabled = true;
/*
* Define the measurement window for AWB as a centered rectangle
@@ -117,6 +119,34 @@ void Awb::prepare(IPAContext &context, rkisp1_params_cfg *params)
}
/**
+ * \copydoc libcamera::ipa::Algorithm::queueRequest
+ */
+void Awb::queueRequest(IPAContext &context,
+ [[maybe_unused]] const uint32_t frame,
+ const ControlList &controls)
+{
+ auto &awb = context.frameContext.awb;
+
+ const auto &awbEnable = controls.get(controls::AwbEnable);
+ if (awbEnable && *awbEnable != awb.autoEnabled) {
+ awb.autoEnabled = *awbEnable;
+
+ LOG(RkISP1Awb, Debug)
+ << (*awbEnable ? "Enabling" : "Disabling") << " AWB";
+ }
+
+ const auto &colourGains = controls.get(controls::ColourGains);
+ if (colourGains && !awb.autoEnabled) {
+ awb.gains.red = (*colourGains)[0];
+ awb.gains.blue = (*colourGains)[1];
+
+ LOG(RkISP1Awb, Debug)
+ << "Set colour gains to red: " << awb.gains.red
+ << ", blue: " << awb.gains.blue;
+ }
+}
+
+/**
* \copydoc libcamera::ipa::Algorithm::process
*/
void Awb::process([[maybe_unused]] IPAContext &context,
@@ -164,8 +194,10 @@ void Awb::process([[maybe_unused]] IPAContext &context,
* Gain values are unsigned integer value, range 0 to 4 with 8 bit
* fractional part.
*/
- frameContext.awb.gains.red = std::clamp(redGain, 0.0, 1023.0 / 256);
- frameContext.awb.gains.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);
+ if (frameContext.awb.autoEnabled) {
+ frameContext.awb.gains.red = std::clamp(redGain, 0.0, 1023.0 / 256);
+ frameContext.awb.gains.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);
+ }
/* Hardcode the green gain to 1.0. */
frameContext.awb.gains.green = 1.0;