[v2,20/22] libcamera: software_isp: blacklevel: Make black level available in debayer params
diff mbox series

Message ID 20251127022256.178929-21-bryan.odonoghue@linaro.org
State New
Headers show
Series
  • GPUISP precursor series
Related show

Commit Message

Bryan O'Donoghue Nov. 27, 2025, 2:22 a.m. UTC
Populate black level gain in blacklevel::prepare(). A copy is made of the gain
value in the DebayerParams structure.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 include/libcamera/internal/software_isp/debayer_params.h | 2 ++
 src/ipa/simple/algorithms/blc.cpp                        | 9 +++++++++
 src/ipa/simple/algorithms/blc.h                          | 4 ++++
 src/libcamera/software_isp/debayer.cpp                   | 5 +++++
 4 files changed, 20 insertions(+)

Comments

Kieran Bingham Nov. 27, 2025, 9:55 a.m. UTC | #1
Quoting Bryan O'Donoghue (2025-11-27 02:22:52)
> Populate black level gain in blacklevel::prepare(). A copy is made of the gain
> value in the DebayerParams structure.
> 
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  include/libcamera/internal/software_isp/debayer_params.h | 2 ++
>  src/ipa/simple/algorithms/blc.cpp                        | 9 +++++++++
>  src/ipa/simple/algorithms/blc.h                          | 4 ++++
>  src/libcamera/software_isp/debayer.cpp                   | 5 +++++
>  4 files changed, 20 insertions(+)
> 
> diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h
> index 4b203e211..5a0d9438f 100644
> --- a/include/libcamera/internal/software_isp/debayer_params.h
> +++ b/include/libcamera/internal/software_isp/debayer_params.h
> @@ -14,6 +14,7 @@
>  #include <stdint.h>
>  
>  #include "libcamera/internal/matrix.h"
> +#include "libcamera/internal/vector.h"
>  
>  namespace libcamera {
>  
> @@ -56,6 +57,7 @@ struct DebayerParams {
>          * Per frame corrections as calculated by the IPA
>          */
>         Matrix<float, 3, 3> ccm;
> +       RGB<float> blackLevel;
>  };
>  
>  } /* namespace libcamera */
> diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp
> index 370385afc..464e43c27 100644
> --- a/src/ipa/simple/algorithms/blc.cpp
> +++ b/src/ipa/simple/algorithms/blc.cpp
> @@ -47,6 +47,15 @@ int BlackLevel::configure(IPAContext &context,
>         return 0;
>  }
>  
> +void BlackLevel::prepare(IPAContext &context,
> +                        [[maybe_unused]] const uint32_t frame,
> +                        [[maybe_unused]] IPAFrameContext &frameContext,
> +                        DebayerParams *params)
> +{
> +       /* Latch the blacklevel gain so GPUISP can apply. */
> +       params->blackLevel = RGB<float>(context.activeState.blc.level / 255.0f);
> +}
> +
>  void BlackLevel::process(IPAContext &context,
>                          [[maybe_unused]] const uint32_t frame,
>                          IPAFrameContext &frameContext,
> diff --git a/src/ipa/simple/algorithms/blc.h b/src/ipa/simple/algorithms/blc.h
> index db9e6d639..a5592d087 100644
> --- a/src/ipa/simple/algorithms/blc.h
> +++ b/src/ipa/simple/algorithms/blc.h
> @@ -24,6 +24,10 @@ public:
>  
>         int init(IPAContext &context, const YamlObject &tuningData) override;
>         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,
>                      const SwIspStats *stats,
> diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp
> index 4ec76dce6..1034912e7 100644
> --- a/src/libcamera/software_isp/debayer.cpp
> +++ b/src/libcamera/software_isp/debayer.cpp
> @@ -105,6 +105,11 @@ namespace libcamera {
>    * \brief Per frame colour correction matrix for GPUISP
>    */
>  
> +/**
> + * \var DebayerParams::blackLevel
> + * \brief Blacklevel gains for the GPUISP
> + */
> +
>  /**
>   * \class Debayer
>   * \brief Base debayering class
> -- 
> 2.51.2
>

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 4b203e211..5a0d9438f 100644
--- a/include/libcamera/internal/software_isp/debayer_params.h
+++ b/include/libcamera/internal/software_isp/debayer_params.h
@@ -14,6 +14,7 @@ 
 #include <stdint.h>
 
 #include "libcamera/internal/matrix.h"
+#include "libcamera/internal/vector.h"
 
 namespace libcamera {
 
@@ -56,6 +57,7 @@  struct DebayerParams {
 	 * Per frame corrections as calculated by the IPA
 	 */
 	Matrix<float, 3, 3> ccm;
+	RGB<float> blackLevel;
 };
 
 } /* namespace libcamera */
diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp
index 370385afc..464e43c27 100644
--- a/src/ipa/simple/algorithms/blc.cpp
+++ b/src/ipa/simple/algorithms/blc.cpp
@@ -47,6 +47,15 @@  int BlackLevel::configure(IPAContext &context,
 	return 0;
 }
 
+void BlackLevel::prepare(IPAContext &context,
+			 [[maybe_unused]] const uint32_t frame,
+			 [[maybe_unused]] IPAFrameContext &frameContext,
+			 DebayerParams *params)
+{
+	/* Latch the blacklevel gain so GPUISP can apply. */
+	params->blackLevel = RGB<float>(context.activeState.blc.level / 255.0f);
+}
+
 void BlackLevel::process(IPAContext &context,
 			 [[maybe_unused]] const uint32_t frame,
 			 IPAFrameContext &frameContext,
diff --git a/src/ipa/simple/algorithms/blc.h b/src/ipa/simple/algorithms/blc.h
index db9e6d639..a5592d087 100644
--- a/src/ipa/simple/algorithms/blc.h
+++ b/src/ipa/simple/algorithms/blc.h
@@ -24,6 +24,10 @@  public:
 
 	int init(IPAContext &context, const YamlObject &tuningData) override;
 	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,
 		     const SwIspStats *stats,
diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp
index 4ec76dce6..1034912e7 100644
--- a/src/libcamera/software_isp/debayer.cpp
+++ b/src/libcamera/software_isp/debayer.cpp
@@ -105,6 +105,11 @@  namespace libcamera {
   * \brief Per frame colour correction matrix for GPUISP
   */
 
+/**
+ * \var DebayerParams::blackLevel
+ * \brief Blacklevel gains for the GPUISP
+ */
+
 /**
  * \class Debayer
  * \brief Base debayering class