[v7,20/26] libcamera: software_isp: ccm: Implement a static init() routine
diff mbox series

Message ID 20251210005354.44726-21-bryan.odonoghue@linaro.org
State Superseded
Headers show
Series
  • Add GLES 2.0 GPUISP to libcamera
Related show

Commit Message

Bryan O'Donoghue Dec. 10, 2025, 12:53 a.m. UTC
This is an overloaded init() routine that allows the CCM class to self
enumerate a default identity CCM at colour temperature 6500k.

This is required for the case where we are running GPUISP but don't have a
CCM for the sensor. In this case we want to generate a default CCM and use
it instead of using the CPUISP's lookup tables.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 src/ipa/simple/algorithms/ccm.cpp | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

Comments

Milan Zamazal Dec. 10, 2025, 4:38 p.m. UTC | #1
Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:

> This is an overloaded init() 

No longer overloaded in the C++ sense, right?

> routine that allows the CCM class to self enumerate a default identity
> CCM at colour temperature 6500k.
>
> This is required for the case where we are running GPUISP but don't have a
> CCM for the sensor. In this case we want to generate a default CCM and use
> it instead of using the CPUISP's lookup tables.
>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>  src/ipa/simple/algorithms/ccm.cpp | 25 +++++++++++++++++++------
>  1 file changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/src/ipa/simple/algorithms/ccm.cpp b/src/ipa/simple/algorithms/ccm.cpp
> index 0a98406c1..38c18806e 100644
> --- a/src/ipa/simple/algorithms/ccm.cpp
> +++ b/src/ipa/simple/algorithms/ccm.cpp
> @@ -27,13 +27,26 @@ namespace ipa::soft::algorithms {
>  
>  LOG_DEFINE_CATEGORY(IPASoftCcm)
>  
> -int Ccm::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)
> +int Ccm::init([[maybe_unused]] IPAContext &context,[[maybe_unused]] const YamlObject &tuningData)
>  {
> -	int ret = ccm_.readYaml(tuningData["ccms"], "ct", "ccm");
> -	if (ret < 0) {
> -		LOG(IPASoftCcm, Error)
> -			<< "Failed to parse 'ccm' parameter from tuning file.";
> -		return ret;
> +	if (!context.selfInitialising) {
> +		int ret = ccm_.readYaml(tuningData["ccms"], "ct", "ccm");
> +		if (ret < 0) {
> +			LOG(IPASoftCcm, Error)
> +				<< "Failed to parse 'ccm' parameter from tuning file.";
> +			return ret;
> +		}
> +	} else {
> +		/* Initialize with identity CCM at standard D65 color temperature */
> +		float identity[] = { 1, 0, 0,
> +				     0, 1, 0,
> +				     0, 0, 1 };
> +		Matrix<float, 3, 3> identityMatrix(identity);

We have a common definition that can be used here:

  Matrix<float, 3, 3> identityMatrix = Matrix<float, 3, 3>::identity();

> +		std::map<unsigned int, Matrix<float, 3, 3>> ccmData;
> +		ccmData[6500] = identityMatrix;
> +
> +		ccm_ = Interpolator<Matrix<float, 3, 3>>(std::move(ccmData));
>  	}
>  
>  	context.ccmEnabled = true;
Milan Zamazal Dec. 10, 2025, 4:40 p.m. UTC | #2
Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:

> This is an overloaded init() routine that allows the CCM class to self
> enumerate a default identity CCM at colour temperature 6500k.
>
> This is required for the case where we are running GPUISP but don't have a
> CCM for the sensor. In this case we want to generate a default CCM and use
> it instead of using the CPUISP's lookup tables.
>
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> ---
>  src/ipa/simple/algorithms/ccm.cpp | 25 +++++++++++++++++++------
>  1 file changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/src/ipa/simple/algorithms/ccm.cpp b/src/ipa/simple/algorithms/ccm.cpp
> index 0a98406c1..38c18806e 100644
> --- a/src/ipa/simple/algorithms/ccm.cpp
> +++ b/src/ipa/simple/algorithms/ccm.cpp
> @@ -27,13 +27,26 @@ namespace ipa::soft::algorithms {
>  
>  LOG_DEFINE_CATEGORY(IPASoftCcm)
>  
> -int Ccm::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)
> +int Ccm::init([[maybe_unused]] IPAContext &context,[[maybe_unused]] const YamlObject &tuningData)

And a missing space after the comma.

>  {
> -	int ret = ccm_.readYaml(tuningData["ccms"], "ct", "ccm");
> -	if (ret < 0) {
> -		LOG(IPASoftCcm, Error)
> -			<< "Failed to parse 'ccm' parameter from tuning file.";
> -		return ret;
> +	if (!context.selfInitialising) {
> +		int ret = ccm_.readYaml(tuningData["ccms"], "ct", "ccm");
> +		if (ret < 0) {
> +			LOG(IPASoftCcm, Error)
> +				<< "Failed to parse 'ccm' parameter from tuning file.";
> +			return ret;
> +		}
> +	} else {
> +		/* Initialize with identity CCM at standard D65 color temperature */
> +		float identity[] = { 1, 0, 0,
> +				     0, 1, 0,
> +				     0, 0, 1 };
> +		Matrix<float, 3, 3> identityMatrix(identity);
> +
> +		std::map<unsigned int, Matrix<float, 3, 3>> ccmData;
> +		ccmData[6500] = identityMatrix;
> +
> +		ccm_ = Interpolator<Matrix<float, 3, 3>>(std::move(ccmData));
>  	}
>  
>  	context.ccmEnabled = true;

Patch
diff mbox series

diff --git a/src/ipa/simple/algorithms/ccm.cpp b/src/ipa/simple/algorithms/ccm.cpp
index 0a98406c1..38c18806e 100644
--- a/src/ipa/simple/algorithms/ccm.cpp
+++ b/src/ipa/simple/algorithms/ccm.cpp
@@ -27,13 +27,26 @@  namespace ipa::soft::algorithms {
 
 LOG_DEFINE_CATEGORY(IPASoftCcm)
 
-int Ccm::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)
+int Ccm::init([[maybe_unused]] IPAContext &context,[[maybe_unused]] const YamlObject &tuningData)
 {
-	int ret = ccm_.readYaml(tuningData["ccms"], "ct", "ccm");
-	if (ret < 0) {
-		LOG(IPASoftCcm, Error)
-			<< "Failed to parse 'ccm' parameter from tuning file.";
-		return ret;
+	if (!context.selfInitialising) {
+		int ret = ccm_.readYaml(tuningData["ccms"], "ct", "ccm");
+		if (ret < 0) {
+			LOG(IPASoftCcm, Error)
+				<< "Failed to parse 'ccm' parameter from tuning file.";
+			return ret;
+		}
+	} else {
+		/* Initialize with identity CCM at standard D65 color temperature */
+		float identity[] = { 1, 0, 0,
+				     0, 1, 0,
+				     0, 0, 1 };
+		Matrix<float, 3, 3> identityMatrix(identity);
+
+		std::map<unsigned int, Matrix<float, 3, 3>> ccmData;
+		ccmData[6500] = identityMatrix;
+
+		ccm_ = Interpolator<Matrix<float, 3, 3>>(std::move(ccmData));
 	}
 
 	context.ccmEnabled = true;