[v4,2/3] ipa: rkisp1: Fix algorithm controls vanish after configure
diff mbox series

Message ID 20240605095417.157703-3-stefan.klug@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: Add gamma control for rkisp1
Related show

Commit Message

Stefan Klug June 5, 2024, 9:53 a.m. UTC
std::unordered_map::merge(source) has the side effect of actually moving items
from source to target. In this case the controls were removed from the source
maps on the first call to updateControls() and on the second call to
updateControls() they were missing in the source maps and therefore also
removed from the camera. Fix this by using insert() instead of merge(). This is
most likely cheaper than copy-contructing the source map.

Fixes: 4c5152843a2a ("ipa: rkisp1: Derive rkisp1::algorithms::Agc from AgcMeanLuminance")
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/ipa/rkisp1/rkisp1.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paul Elder June 10, 2024, 10:27 a.m. UTC | #1
On Wed, Jun 05, 2024 at 11:53:50AM +0200, Stefan Klug wrote:
> std::unordered_map::merge(source) has the side effect of actually moving items
> from source to target. In this case the controls were removed from the source
> maps on the first call to updateControls() and on the second call to
> updateControls() they were missing in the source maps and therefore also
> removed from the camera. Fix this by using insert() instead of merge(). This is
> most likely cheaper than copy-contructing the source map.
> 
> Fixes: 4c5152843a2a ("ipa: rkisp1: Derive rkisp1::algorithms::Agc from AgcMeanLuminance")
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  src/ipa/rkisp1/rkisp1.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
> index 6687c91e7fb0..17474408ed2d 100644
> --- a/src/ipa/rkisp1/rkisp1.cpp
> +++ b/src/ipa/rkisp1/rkisp1.cpp
> @@ -427,7 +427,7 @@ void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo,
>  							      frameDurations[1],
>  							      frameDurations[2]);
>  
> -	ctrlMap.merge(context_.ctrlMap);
> +	ctrlMap.insert(context_.ctrlMap.begin(), context_.ctrlMap.end());
>  	*ipaControls = ControlInfoMap(std::move(ctrlMap), controls::controls);
>  }
>  
> -- 
> 2.43.0
>

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
index 6687c91e7fb0..17474408ed2d 100644
--- a/src/ipa/rkisp1/rkisp1.cpp
+++ b/src/ipa/rkisp1/rkisp1.cpp
@@ -427,7 +427,7 @@  void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo,
 							      frameDurations[1],
 							      frameDurations[2]);
 
-	ctrlMap.merge(context_.ctrlMap);
+	ctrlMap.insert(context_.ctrlMap.begin(), context_.ctrlMap.end());
 	*ipaControls = ControlInfoMap(std::move(ctrlMap), controls::controls);
 }