@@ -99,6 +99,7 @@ void Agc::process(IPAContext &context,
.yHist = yHist,
.exposure = frameContext.sensor.exposure,
.gain = frameContext.sensor.gain,
+ .lux = frameContext.lux.lux,
}}, metadata);
} else {
agc_.process(context.configuration.agc, context.activeState.agc, frameContext.agc, {}, metadata);
@@ -19,11 +19,6 @@ LOG_DEFINE_CATEGORY(IPASoftIspAwb)
namespace ipa::softisp::algorithms {
-/*
- * \todo Replace it with a proper Lux algorithm
- */
-static constexpr unsigned int kDefaultLux = 500;
-
class SoftIspAwbStats final : public AwbStats
{
public:
@@ -160,7 +155,7 @@ void Awb::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
SoftIspAwbStats awbStats = calculateRgbMeans(context, stats);
awbAlgo_.process(context.activeState.awb, frameContext.awb, awbStats,
- kDefaultLux, metadata);
+ frameContext.lux.lux, metadata);
}
REGISTER_IPA_ALGORITHM(Awb, "Awb")
new file mode 100644
@@ -0,0 +1,82 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Ideas On Board
+ *
+ * SoftISP Lux control
+ */
+
+#include "lux.h"
+
+#include <libcamera/base/log.h>
+
+#include <libcamera/control_ids.h>
+
+#include "libipa/histogram.h"
+#include "libipa/lux.h"
+
+/**
+ * \file lux.h
+ */
+
+namespace libcamera {
+
+namespace ipa::softisp::algorithms {
+
+/**
+ * \class Lux
+ * \brief SoftISP Lux control
+ *
+ * The Lux algorithm is responsible for estimating the lux level of the image.
+ * It doesn't take or generate any controls, but it provides a lux level for
+ * other algorithms (such as AGC) to use.
+ */
+
+/**
+ * \copydoc libcamera::ipa::Algorithm::init
+ */
+int Lux::init([[maybe_unused]] IPAContext &context, const ValueNode &tuningData)
+{
+ return lux_.init(tuningData);
+}
+
+/**
+ * \copydoc libcamera::ipa::Algorithm::prepare
+ */
+void Lux::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
+ IPAFrameContext &frameContext,
+ [[maybe_unused]] DebayerParams *params)
+{
+ lux_.prepare(context.activeState.lux, frameContext.lux);
+}
+
+/**
+ * \copydoc libcamera::ipa::Algorithm::process
+ */
+void Lux::process(IPAContext &context,
+ [[maybe_unused]] const uint32_t frame,
+ IPAFrameContext &frameContext,
+ const SwIspStats *stats,
+ ControlList &metadata)
+{
+ if (!stats) {
+ lux_.process(context.activeState.lux, frameContext.lux, metadata, {});
+ return;
+ }
+
+ Histogram yHist(stats->yHistogram);
+
+ lux_.process(context.activeState.lux, frameContext.lux, metadata,
+ { {
+ .exposureTime = context.configuration.agc.lineDuration *
+ frameContext.sensor.exposure,
+ .analogueGain = frameContext.sensor.gain,
+ .digitalGain = 1,
+ .yHist = yHist,
+ } });
+}
+
+REGISTER_IPA_ALGORITHM(Lux, "Lux")
+
+} /* namespace ipa::softisp::algorithms */
+
+} /* namespace libcamera */
new file mode 100644
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2026, Ideas On Board
+ *
+ * RkISP1 Lux control
+ */
+
+#pragma once
+
+#include <sys/types.h>
+
+#include "libipa/lux.h"
+
+#include "algorithm.h"
+
+namespace libcamera {
+
+namespace ipa::softisp::algorithms {
+
+class Lux : public Algorithm
+{
+public:
+ int init(IPAContext &context, const ValueNode &tuningData) override;
+ void prepare(IPAContext &context, const uint32_t frame,
+ IPAFrameContext &frameContext,
+ DebayerParams *params) override;
+ void process(IPAContext &context, const uint32_t frame,
+ IPAFrameContext &frameContext,
+ const SwIspStats *stats,
+ ControlList &metadata) override;
+
+private:
+ ipa::LuxAlgorithm lux_;
+};
+
+} /* namespace ipa::softisp::algorithms */
+} /* namespace libcamera */
@@ -7,4 +7,5 @@ softisp_ipa_algorithms = files([
'blc.cpp',
'ccm.cpp',
'lsc.cpp',
+ 'lux.cpp',
])
@@ -22,7 +22,8 @@
#include <libipa/camera_sensor_helper.h>
#include <libipa/ccm.h>
#include <libipa/fc_queue.h>
-#include "libipa/lsc.h"
+#include <libipa/lsc.h>
+#include <libipa/lux.h>
#include "core_ipa_interface.h"
@@ -58,6 +59,7 @@ struct IPAActiveState {
} knobs;
ipa::lsc::ActiveState lsc;
+ ipa::lux::ActiveState lux;
};
struct IPAFrameContext : public FrameContext {
@@ -74,6 +76,7 @@ struct IPAFrameContext : public FrameContext {
std::optional<float> contrast;
std::optional<float> saturation;
ipa::lsc::FrameContext lsc;
+ ipa::lux::FrameContext lux;
};
struct IPAContext {
Utilise the lux component of libipa to map in the lux estimate process using the yHistgram of the Soft ISP statistics. Tie this into both the Agc and Awb process calls to make use of the data where possible. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> --- Note: Untested / locally compile tested only, and depends on Series:6358 from Barnabas to bring in the libipa lux support. https://patchwork.libcamera.org/project/libcamera/list/?series=6358 src/ipa/softisp/algorithms/agc.cpp | 1 + src/ipa/softisp/algorithms/awb.cpp | 7 +-- src/ipa/softisp/algorithms/lux.cpp | 82 ++++++++++++++++++++++++++ src/ipa/softisp/algorithms/lux.h | 37 ++++++++++++ src/ipa/softisp/algorithms/meson.build | 1 + src/ipa/softisp/ipa_context.h | 5 +- 6 files changed, 126 insertions(+), 7 deletions(-) create mode 100644 src/ipa/softisp/algorithms/lux.cpp create mode 100644 src/ipa/softisp/algorithms/lux.h