[libcamera-devel,2/2] ipa: rkisp1: agc: Restore minimum analogue gain limit
diff mbox series

Message ID 20230529123926.74775-2-jacopo.mondi@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel,1/2] ipa: ipu3: agc: Drop hard-codec analogue gain max
Related show

Commit Message

Jacopo Mondi May 29, 2023, 12:39 p.m. UTC
Commit a3178dd0391f ("ipa: rkisp1: agc: drop hard-coded analogue gain range")
removed both minimum and maximum limits for the analogue gain value.

However, as some sensors can potentially have a minimum gain lower than
1.0, restore the check for the minimum limit.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/ipa/rkisp1/algorithms/agc.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--
2.40.1

Comments

Laurent Pinchart May 29, 2023, 12:47 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Mon, May 29, 2023 at 02:39:26PM +0200, Jacopo Mondi via libcamera-devel wrote:
> Commit a3178dd0391f ("ipa: rkisp1: agc: drop hard-coded analogue gain range")
> removed both minimum and maximum limits for the analogue gain value.
> 
> However, as some sensors can potentially have a minimum gain lower than
> 1.0, restore the check for the minimum limit.
> 
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/ipa/rkisp1/algorithms/agc.cpp | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
> index a4e5500e72d6..e5aeb3426eff 100644
> --- a/src/ipa/rkisp1/algorithms/agc.cpp
> +++ b/src/ipa/rkisp1/algorithms/agc.cpp
> @@ -36,6 +36,9 @@ namespace ipa::rkisp1::algorithms {
> 
>  LOG_DEFINE_CATEGORY(RkISP1Agc)
> 
> +/* Minimum limit for analogue gain value */
> +static constexpr double kMinAnalogueGain = 1.0;
> +
>  /* \todo Honour the FrameDurationLimits control instead of hardcoding a limit */
>  static constexpr utils::Duration kMaxShutterSpeed = 60ms;
> 
> @@ -254,7 +257,8 @@ void Agc::computeExposure(IPAContext &context, IPAFrameContext &frameContext,
>  	utils::Duration maxShutterSpeed = std::min(configuration.sensor.maxShutterSpeed,
>  						   kMaxShutterSpeed);
> 
> -	double minAnalogueGain = configuration.sensor.minAnalogueGain;
> +	double minAnalogueGain = std::max(configuration.sensor.minAnalogueGain,
> +					  kMinAnalogueGain);
>  	double maxAnalogueGain = configuration.sensor.maxAnalogueGain;
> 
>  	/* Consider within 1% of the target as correctly exposed. */

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
index a4e5500e72d6..e5aeb3426eff 100644
--- a/src/ipa/rkisp1/algorithms/agc.cpp
+++ b/src/ipa/rkisp1/algorithms/agc.cpp
@@ -36,6 +36,9 @@  namespace ipa::rkisp1::algorithms {

 LOG_DEFINE_CATEGORY(RkISP1Agc)

+/* Minimum limit for analogue gain value */
+static constexpr double kMinAnalogueGain = 1.0;
+
 /* \todo Honour the FrameDurationLimits control instead of hardcoding a limit */
 static constexpr utils::Duration kMaxShutterSpeed = 60ms;

@@ -254,7 +257,8 @@  void Agc::computeExposure(IPAContext &context, IPAFrameContext &frameContext,
 	utils::Duration maxShutterSpeed = std::min(configuration.sensor.maxShutterSpeed,
 						   kMaxShutterSpeed);

-	double minAnalogueGain = configuration.sensor.minAnalogueGain;
+	double minAnalogueGain = std::max(configuration.sensor.minAnalogueGain,
+					  kMinAnalogueGain);
 	double maxAnalogueGain = configuration.sensor.maxAnalogueGain;

 	/* Consider within 1% of the target as correctly exposed. */