[libcamera-devel,3/3] ipa: rkisp1: lsc: Move 'enable' to activeState
diff mbox series

Message ID 20230308164028.235638-4-jacopo.mondi@ideasonboard.com
State New
Headers show
Series
  • ipa: rkisp1: lsc: Enable/disable LSC
Related show

Commit Message

Jacopo Mondi March 8, 2023, 4:40 p.m. UTC
Now that the LSC algorithm can be enabled and disabled at run-time,
move the 'enabled' flag from the context's configuration to the
algorithm's active state.

This allows to populate the LensShadingEnable metadata in the process()
function implementation.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/ipa/rkisp1/algorithms/dpf.cpp |  6 +++---
 src/ipa/rkisp1/algorithms/lsc.cpp | 13 +++++++++----
 src/ipa/rkisp1/algorithms/lsc.h   |  4 ++++
 src/ipa/rkisp1/ipa_context.h      |  4 ----
 4 files changed, 16 insertions(+), 11 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp
index 5bd7e59f651c..8f181df5c6c4 100644
--- a/src/ipa/rkisp1/algorithms/dpf.cpp
+++ b/src/ipa/rkisp1/algorithms/dpf.cpp
@@ -222,7 +222,7 @@  void Dpf::prepare(IPAContext &context, const uint32_t frame,
 		params->others.dpf_strength_config = strengthConfig_;
 
 		const auto &awb = context.configuration.awb;
-		const auto &lsc = context.configuration.lsc;
+		const auto &lsc = context.activeState.lsc;
 		auto &mode = params->others.dpf_config.gain.mode;
 
 		/*
@@ -233,11 +233,11 @@  void Dpf::prepare(IPAContext &context, const uint32_t frame,
 		 * LSC modules automatically when they are enabled. Use that
 		 * mode of operation as it simplifies control of the DPF.
 		 */
-		if (awb.enabled && lsc.enabled)
+		if (awb.enabled && lsc.active)
 			mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS;
 		else if (awb.enabled)
 			mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS;
-		else if (lsc.enabled)
+		else if (lsc.active)
 			mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS;
 		else
 			mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED;
diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp
index 0c9f6cbd1dec..8de49e4220ea 100644
--- a/src/ipa/rkisp1/algorithms/lsc.cpp
+++ b/src/ipa/rkisp1/algorithms/lsc.cpp
@@ -149,8 +149,6 @@  int LensShadingCorrection::init([[maybe_unused]] IPAContext &context,
 		return -EINVAL;
 	}
 
-	context.configuration.lsc.enabled = false;
-
 	return 0;
 }
 
@@ -290,12 +288,10 @@  void LensShadingCorrection::prepare(IPAContext &context,
 		if (!lsc->enable) {
 			disableLSC(params);
 			lsc->active = false;
-			context.configuration.lsc.enabled = false;
 			return;
 		}
 
 		lsc->active = true;
-		context.configuration.lsc.enabled = true;
 	}
 
 	/* Nothing more to do here if LSC is not active. */
@@ -387,6 +383,15 @@  void LensShadingCorrection::prepare(IPAContext &context,
 	lastCt_ = { ct, ct };
 }
 
+void LensShadingCorrection::process(IPAContext &context,
+				    [[maybe_unused]] const uint32_t frame,
+				    [[maybe_unused]] IPAFrameContext &frameContext,
+				    [[maybe_unused]] const rkisp1_stat_buffer *stats,
+				    ControlList &metadata)
+{
+	metadata.set(controls::LensShadingEnable, context.activeState.lsc.active);
+}
+
 REGISTER_IPA_ALGORITHM(LensShadingCorrection, "LensShadingCorrection")
 
 } /* namespace ipa::rkisp1::algorithms */
diff --git a/src/ipa/rkisp1/algorithms/lsc.h b/src/ipa/rkisp1/algorithms/lsc.h
index 4708065bcfb7..e9770f4027f4 100644
--- a/src/ipa/rkisp1/algorithms/lsc.h
+++ b/src/ipa/rkisp1/algorithms/lsc.h
@@ -29,6 +29,10 @@  public:
 	void prepare(IPAContext &context, const uint32_t frame,
 		     IPAFrameContext &frameContext,
 		     rkisp1_params_cfg *params) override;
+	void process(IPAContext &context, const uint32_t frame,
+		     IPAFrameContext &frameContext,
+		     const rkisp1_stat_buffer *stats,
+		     ControlList &metadata) override;
 
 private:
 	struct Components {
diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h
index ada995274ebf..bb72f0a40a12 100644
--- a/src/ipa/rkisp1/ipa_context.h
+++ b/src/ipa/rkisp1/ipa_context.h
@@ -30,10 +30,6 @@  struct IPASessionConfiguration {
 		bool enabled;
 	} awb;
 
-	struct {
-		bool enabled;
-	} lsc;
-
 	struct {
 		utils::Duration minShutterSpeed;
 		utils::Duration maxShutterSpeed;