[RFC,v5,08/10] ipa: simple: Add LSC type
diff mbox series

Message ID 20260512123619.120068-9-mzamazal@redhat.com
State New
Headers show
Series
  • LSC for SoftISP simple pipeline
Related show

Commit Message

Milan Zamazal May 12, 2026, 12:36 p.m. UTC
Add a `type' YAML item to the lens shading correction algorithm, in
order to distinguish between different methods and their parameters.  It
is the same as in rkisp1 IPA.  A corresponding class variable is added
to Lsc.

The only supported type for the moment is `table', for the grid-based
LSC already implemented.

The LSC type will be passed through the IPA interface in a followup
patch.  For this reason, it's defined as an enum based on uint32_t
rather than as an `enum class', so that it can be passed through the
Mojo interface as a simple integer without further arrangements.

The Lsc algorithm YAML definition has now a new required item

  type: table

to indicate the LSC method to be used.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 .../internal/software_isp/debayer_params.h    |  3 +++
 src/ipa/simple/algorithms/lsc.cpp             | 23 +++++++++++++------
 src/ipa/simple/algorithms/lsc.h               |  1 +
 src/libcamera/software_isp/debayer.cpp        | 10 ++++++++
 4 files changed, 30 insertions(+), 7 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h
index 5b1c8b508..9e6c9ddb8 100644
--- a/include/libcamera/internal/software_isp/debayer_params.h
+++ b/include/libcamera/internal/software_isp/debayer_params.h
@@ -34,6 +34,9 @@  struct DebayerParams {
 		kLscValuesPerCell * sizeof(LscValueType);
 	using LscLookupTable =
 		std::array<LscValueType, kLscGridSize * kLscGridSize * kLscValuesPerCell>;
+	enum LscType : uint32_t {
+		LscTable,
+	};
 	LscLookupTable lscLut{};
 };
 
diff --git a/src/ipa/simple/algorithms/lsc.cpp b/src/ipa/simple/algorithms/lsc.cpp
index 4b821005f..87023bc9b 100644
--- a/src/ipa/simple/algorithms/lsc.cpp
+++ b/src/ipa/simple/algorithms/lsc.cpp
@@ -17,13 +17,22 @@  LOG_DEFINE_CATEGORY(IPASoftLsc)
 
 int Lsc::init(IPAContext &context, const ValueNode &tuningData)
 {
-	int retR = lscR_.readYaml(tuningData["sets"], "ct", "r");
-	int retG = lscG_.readYaml(tuningData["sets"], "ct", "g");
-	int retB = lscB_.readYaml(tuningData["sets"], "ct", "b");
-
-	if (retR < 0 || retG < 0 || retB < 0) {
-		LOG(IPASoftLsc, Error)
-			<< "Failed to parse 'lsc' parameter from tuning file.";
+	std::string type = tuningData["type"].get<std::string>("table");
+
+	if (type == "table") {
+		int retR = lscR_.readYaml(tuningData["sets"], "ct", "r");
+		int retG = lscG_.readYaml(tuningData["sets"], "ct", "g");
+		int retB = lscB_.readYaml(tuningData["sets"], "ct", "b");
+
+		if (retR < 0 || retG < 0 || retB < 0) {
+			LOG(IPASoftLsc, Error)
+				<< "Failed to parse 'lsc' parameter from tuning file.";
+			return -EINVAL;
+		}
+
+		type_ = DebayerParams::LscTable;
+	} else {
+		LOG(IPASoftLsc, Error) << "LSC: type " << type << " not supported";
 		return -EINVAL;
 	}
 
diff --git a/src/ipa/simple/algorithms/lsc.h b/src/ipa/simple/algorithms/lsc.h
index 16950c5af..d7d7c9559 100644
--- a/src/ipa/simple/algorithms/lsc.h
+++ b/src/ipa/simple/algorithms/lsc.h
@@ -31,6 +31,7 @@  public:
 
 private:
 	using LscMatrix = Matrix<float, DebayerParams::kLscGridSize, DebayerParams::kLscGridSize>;
+	DebayerParams::LscType type_;
 	Interpolator<LscMatrix> lscR_;
 	Interpolator<LscMatrix> lscG_;
 	Interpolator<LscMatrix> lscB_;
diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp
index cc1dbb2d0..12c2ec9fd 100644
--- a/src/libcamera/software_isp/debayer.cpp
+++ b/src/libcamera/software_isp/debayer.cpp
@@ -53,6 +53,16 @@  namespace libcamera {
  * \brief Number of pixel values per each of the lens shading grid areas
  */
 
+/**
+ * \enum DebayerParams::LscType
+ * \brief Type of lens shading correction to apply
+ */
+
+/**
+ * \var DebayerParams::LscTable
+ * \brief Lens shading correction using a lookup table
+ */
+
 /**
  * \typedef DebayerParams::LscValueType
  * \brief Type of LSC grid values