libcamera: software_isp: Reset stored exposure in black level
diff mbox series

Message ID 20250317112658.15084-1-mzamazal@redhat.com
State New
Headers show
Series
  • libcamera: software_isp: Reset stored exposure in black level
Related show

Commit Message

Milan Zamazal March 17, 2025, 11:26 a.m. UTC
Automatic black level setting in software ISP updates the determined
black level value when exposure or gain change.  It stores the last
exposure and gain values to detect the change.

BlackLevel::configure() resets the stored black level value but not the
exposure and gain values.  This can prevent updating the black value and
cause bad image output e.g. after suspending and resuming a camera, if
exposure and gain remain unchanged.

Let's reset the stored exposure and gain values in
BlackLevel::configure() to fix the problem.

Bug: https://bugs.libcamera.org/show_bug.cgi?id=259
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 src/ipa/simple/algorithms/blc.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Robert Mader March 17, 2025, 11:40 a.m. UTC | #1
Thanks!

Tested-by: Robert Mader <robert.mader@collabora.com>

On 17.03.25 12:26, Milan Zamazal wrote:
> Automatic black level setting in software ISP updates the determined
> black level value when exposure or gain change.  It stores the last
> exposure and gain values to detect the change.
>
> BlackLevel::configure() resets the stored black level value but not the
> exposure and gain values.  This can prevent updating the black value and
> cause bad image output e.g. after suspending and resuming a camera, if
> exposure and gain remain unchanged.
>
> Let's reset the stored exposure and gain values in
> BlackLevel::configure() to fix the problem.
>
> Bug: https://bugs.libcamera.org/show_bug.cgi?id=259
> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
> ---
>   src/ipa/simple/algorithms/blc.cpp | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp
> index 1d7d370b..14cf31bf 100644
> --- a/src/ipa/simple/algorithms/blc.cpp
> +++ b/src/ipa/simple/algorithms/blc.cpp
> @@ -1,6 +1,6 @@
>   /* SPDX-License-Identifier: LGPL-2.1-or-later */
>   /*
> - * Copyright (C) 2024, Red Hat Inc.
> + * Copyright (C) 2024-2025, Red Hat Inc.
>    *
>    * Black level handling
>    */
> @@ -38,6 +38,9 @@ int BlackLevel::init([[maybe_unused]] IPAContext &context,
>   int BlackLevel::configure(IPAContext &context,
>   			  [[maybe_unused]] const IPAConfigInfo &configInfo)
>   {
> +	exposure_ = 0;
> +	gain_ = 0;
> +
>   	if (definedLevel_.has_value())
>   		context.configuration.black.level = definedLevel_;
>   	context.activeState.blc.level =

Patch
diff mbox series

diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp
index 1d7d370b..14cf31bf 100644
--- a/src/ipa/simple/algorithms/blc.cpp
+++ b/src/ipa/simple/algorithms/blc.cpp
@@ -1,6 +1,6 @@ 
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 /*
- * Copyright (C) 2024, Red Hat Inc.
+ * Copyright (C) 2024-2025, Red Hat Inc.
  *
  * Black level handling
  */
@@ -38,6 +38,9 @@  int BlackLevel::init([[maybe_unused]] IPAContext &context,
 int BlackLevel::configure(IPAContext &context,
 			  [[maybe_unused]] const IPAConfigInfo &configInfo)
 {
+	exposure_ = 0;
+	gain_ = 0;
+
 	if (definedLevel_.has_value())
 		context.configuration.black.level = definedLevel_;
 	context.activeState.blc.level =