[libcamera-devel,1/3] src: ipa: raspberrypi: Avoid AGC filtering when both gain and shutter specified
diff mbox series

Message ID 20201125113640.20246-2-david.plowman@raspberrypi.com
State Accepted
Headers show
Series
  • Raspberry Pi AGC improvements
Related show

Commit Message

David Plowman Nov. 25, 2020, 11:36 a.m. UTC
When both gain and shutter have been directly specified, do not filter
slowly towards those target values, but adopt them immediately. This
should match user expectations better.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 src/ipa/raspberrypi/controller/rpi/agc.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Naushir Patuck Nov. 26, 2020, 9:26 a.m. UTC | #1
Hi David,

Thank you for your patch.

On Wed, 25 Nov 2020 at 11:36, David Plowman <david.plowman@raspberrypi.com>
wrote:

> When both gain and shutter have been directly specified, do not filter
> slowly towards those target values, but adopt them immediately. This
> should match user expectations better.
>
> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
>

Reviewed-by: Naushir Patuck <naush@raspberrypi.com>


> ---
>  src/ipa/raspberrypi/controller/rpi/agc.cpp | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp
> b/src/ipa/raspberrypi/controller/rpi/agc.cpp
> index 4c56bdc9..30a1c1c1 100644
> --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp
> +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp
> @@ -588,7 +588,12 @@ bool Agc::applyDigitalGain(double gain, double
> target_Y)
>
>  void Agc::filterExposure(bool desaturate)
>  {
> -       double speed = frame_count_ <= config_.startup_frames ? 1.0 :
> config_.speed;
> +       double speed = config_.speed;
> +       // AGC adapts instantly if both shutter and gain are directly
> specified
> +       // or we're in the startup phase.
> +       if ((status_.fixed_shutter && status_.fixed_analogue_gain) ||
> +           frame_count_ <= config_.startup_frames)
> +               speed = 1.0;
>         if (filtered_.total_exposure == 0.0) {
>                 filtered_.total_exposure = target_.total_exposure;
>                 filtered_.total_exposure_no_dg =
> target_.total_exposure_no_dg;
> --
> 2.20.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
>
Laurent Pinchart Nov. 26, 2020, 10 a.m. UTC | #2
Hi David,

Thank you for the patch.

On Wed, Nov 25, 2020 at 11:36:38AM +0000, David Plowman wrote:
> When both gain and shutter have been directly specified, do not filter
> slowly towards those target values, but adopt them immediately. This
> should match user expectations better.
> 
> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>

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

> ---
>  src/ipa/raspberrypi/controller/rpi/agc.cpp | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp
> index 4c56bdc9..30a1c1c1 100644
> --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp
> +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp
> @@ -588,7 +588,12 @@ bool Agc::applyDigitalGain(double gain, double target_Y)
>  
>  void Agc::filterExposure(bool desaturate)
>  {
> -	double speed = frame_count_ <= config_.startup_frames ? 1.0 : config_.speed;
> +	double speed = config_.speed;
> +	// AGC adapts instantly if both shutter and gain are directly specified
> +	// or we're in the startup phase.
> +	if ((status_.fixed_shutter && status_.fixed_analogue_gain) ||
> +	    frame_count_ <= config_.startup_frames)
> +		speed = 1.0;
>  	if (filtered_.total_exposure == 0.0) {
>  		filtered_.total_exposure = target_.total_exposure;
>  		filtered_.total_exposure_no_dg = target_.total_exposure_no_dg;

Patch
diff mbox series

diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp
index 4c56bdc9..30a1c1c1 100644
--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp
@@ -588,7 +588,12 @@  bool Agc::applyDigitalGain(double gain, double target_Y)
 
 void Agc::filterExposure(bool desaturate)
 {
-	double speed = frame_count_ <= config_.startup_frames ? 1.0 : config_.speed;
+	double speed = config_.speed;
+	// AGC adapts instantly if both shutter and gain are directly specified
+	// or we're in the startup phase.
+	if ((status_.fixed_shutter && status_.fixed_analogue_gain) ||
+	    frame_count_ <= config_.startup_frames)
+		speed = 1.0;
 	if (filtered_.total_exposure == 0.0) {
 		filtered_.total_exposure = target_.total_exposure;
 		filtered_.total_exposure_no_dg = target_.total_exposure_no_dg;