@@ -14,6 +14,8 @@
#include "simple/ipa_context.h"
+#include "control_ids.h"
+
namespace libcamera {
LOG_DEFINE_CATEGORY(IPASoftAwb)
@@ -29,15 +31,32 @@ int Awb::configure(IPAContext &context,
return 0;
}
+void Awb::prepare(IPAContext &context,
+ [[maybe_unused]] const uint32_t frame,
+ IPAFrameContext &frameContext,
+ [[maybe_unused]] DebayerParams *params)
+{
+ auto &gains = context.activeState.gains;
+ frameContext.gains.red = gains.red;
+ frameContext.gains.blue = gains.blue;
+}
+
void Awb::process(IPAContext &context,
[[maybe_unused]] const uint32_t frame,
- [[maybe_unused]] IPAFrameContext &frameContext,
+ IPAFrameContext &frameContext,
const SwIspStats *stats,
- [[maybe_unused]] ControlList &metadata)
+ ControlList &metadata)
{
const SwIspStats::Histogram &histogram = stats->yHistogram;
const uint8_t blackLevel = context.activeState.blc.level;
+ const float maxGain = 1024.0;
+ const float mdGains[] = {
+ static_cast<float>(frameContext.gains.red / maxGain),
+ static_cast<float>(frameContext.gains.blue / maxGain)
+ };
+ metadata.set(controls::ColourGains, mdGains);
+
/*
* Black level must be subtracted to get the correct AWB ratios, they
* would be off if they were computed from the whole brightness range
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
- * Copyright (C) 2024, Red Hat Inc.
+ * Copyright (C) 2024-2025 Red Hat Inc.
*
* Auto white balance
*/
@@ -20,6 +20,10 @@ public:
~Awb() = default;
int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
+ void prepare(IPAContext &context,
+ const uint32_t frame,
+ IPAFrameContext &frameContext,
+ DebayerParams *params) override;
void process(IPAContext &context,
const uint32_t frame,
IPAFrameContext &frameContext,
@@ -58,6 +58,10 @@ struct IPAFrameContext : public FrameContext {
int32_t exposure;
double gain;
} sensor;
+ struct {
+ double red;
+ double blue;
+ } gains;
};
struct IPAContext {