[v1,11/11] ipa: rkisp1: blc: Add support for BLS in compand
diff mbox series

Message ID 20240703225230.3530-12-laurent.pinchart@ideasonboard.com
State Superseded
Headers show
Series
  • rkisp1: Support BLS on i.MX8MP
Related show

Commit Message

Laurent Pinchart July 3, 2024, 10:52 p.m. UTC
From: Paul Elder <paul.elder@ideasonboard.com>

Add support for black level subtraction to use the BLS in the compand
block, for versions of the ISP (such as the one on the i.MX8MP) that
lack the dedicated BLS block but have BLS in the companding block.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/ipa/rkisp1/algorithms/blc.cpp | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

Comments

Jacopo Mondi July 4, 2024, 1:41 p.m. UTC | #1
Hi LAurent

On Thu, Jul 04, 2024 at 01:52:30AM GMT, Laurent Pinchart wrote:
> From: Paul Elder <paul.elder@ideasonboard.com>
>
> Add support for black level subtraction to use the BLS in the compand

BLS is 'black level subtraction' so this reads as

Add support for BLS to use BLS in the compand block

I would

Extend the RkISP1 BLC algorithm to use the ISP 'companding' block
for versions of the ISP  (such as the one on the i.MX8MP) that
lack a dedicated block but implement BLS in the companding one.

or something similar

> block, for versions of the ISP (such as the one on the i.MX8MP) that
> lack the dedicated BLS block but have BLS in the companding block.
>
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/ipa/rkisp1/algorithms/blc.cpp | 30 ++++++++++++++++++++++--------
>  1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp
> index 464a0e066dd4..bc329ea035aa 100644
> --- a/src/ipa/rkisp1/algorithms/blc.cpp
> +++ b/src/ipa/rkisp1/algorithms/blc.cpp
> @@ -110,7 +110,7 @@ int BlackLevelCorrection::init(IPAContext &context, const YamlObject &tuningData
>  /**
>   * \copydoc libcamera::ipa::Algorithm::prepare
>   */
> -void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
> +void BlackLevelCorrection::prepare(IPAContext &context,
>  				   const uint32_t frame,
>  				   [[maybe_unused]] IPAFrameContext &frameContext,
>  				   RkISP1Params *params)
> @@ -124,14 +124,28 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
>  	if (!tuningParameters_)
>  		return;
>
> -	auto config = params->block<Block::Bls>(RkISP1Params::State::Enable);
> +	if (context.hw->compand) {
> +		auto config = params->block<Block::CompandBls>(RkISP1Params::State::Enable);
>
> -	config->enable_auto = 0;
> -	/* The rkisp1 uses 12bit based black levels. Scale down accordingly. */
> -	config->fixed_val.r = blackLevelRed_ >> 4;
> -	config->fixed_val.gr = blackLevelGreenR_ >> 4;
> -	config->fixed_val.gb = blackLevelGreenB_ >> 4;
> -	config->fixed_val.b = blackLevelBlue_ >> 4;
> +		/*
> +		 * Scale up to the 20-bit black levels used by the companding
> +		 * block.
> +		 */
> +		config->r = blackLevelRed_ << 4;
> +		config->gr = blackLevelGreenR_ << 4;
> +		config->gb = blackLevelGreenB_ << 4;
> +		config->b = blackLevelBlue_ << 4;

If you return you could save one indentation level, but it's a minor
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Thanks
  j

> +	} else {
> +		auto config = params->block<Block::Bls>(RkISP1Params::State::Enable);
> +
> +		config->enable_auto = 0;
> +
> +		/* Scale down to the 12-bit black levels used by the BLS block. */
> +		config->fixed_val.r = blackLevelRed_ >> 4;
> +		config->fixed_val.gr = blackLevelGreenR_ >> 4;
> +		config->fixed_val.gb = blackLevelGreenB_ >> 4;
> +		config->fixed_val.b = blackLevelBlue_ >> 4;
> +	}
>  }
>
>  /**
> --
> Regards,
>
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp
index 464a0e066dd4..bc329ea035aa 100644
--- a/src/ipa/rkisp1/algorithms/blc.cpp
+++ b/src/ipa/rkisp1/algorithms/blc.cpp
@@ -110,7 +110,7 @@  int BlackLevelCorrection::init(IPAContext &context, const YamlObject &tuningData
 /**
  * \copydoc libcamera::ipa::Algorithm::prepare
  */
-void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
+void BlackLevelCorrection::prepare(IPAContext &context,
 				   const uint32_t frame,
 				   [[maybe_unused]] IPAFrameContext &frameContext,
 				   RkISP1Params *params)
@@ -124,14 +124,28 @@  void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
 	if (!tuningParameters_)
 		return;
 
-	auto config = params->block<Block::Bls>(RkISP1Params::State::Enable);
+	if (context.hw->compand) {
+		auto config = params->block<Block::CompandBls>(RkISP1Params::State::Enable);
 
-	config->enable_auto = 0;
-	/* The rkisp1 uses 12bit based black levels. Scale down accordingly. */
-	config->fixed_val.r = blackLevelRed_ >> 4;
-	config->fixed_val.gr = blackLevelGreenR_ >> 4;
-	config->fixed_val.gb = blackLevelGreenB_ >> 4;
-	config->fixed_val.b = blackLevelBlue_ >> 4;
+		/*
+		 * Scale up to the 20-bit black levels used by the companding
+		 * block.
+		 */
+		config->r = blackLevelRed_ << 4;
+		config->gr = blackLevelGreenR_ << 4;
+		config->gb = blackLevelGreenB_ << 4;
+		config->b = blackLevelBlue_ << 4;
+	} else {
+		auto config = params->block<Block::Bls>(RkISP1Params::State::Enable);
+
+		config->enable_auto = 0;
+
+		/* Scale down to the 12-bit black levels used by the BLS block. */
+		config->fixed_val.r = blackLevelRed_ >> 4;
+		config->fixed_val.gr = blackLevelGreenR_ >> 4;
+		config->fixed_val.gb = blackLevelGreenB_ >> 4;
+		config->fixed_val.b = blackLevelBlue_ >> 4;
+	}
 }
 
 /**