[PATCH 3/5] ipa: rkisp1: blc: Query black levels from camera sensor helper
Stefan Klug
stefan.klug at ideasonboard.com
Mon Jul 1 16:38:26 CEST 2024
The black levels from the camera sensor helper are then used to do the
black level correction. Black levels can still be overwritten by the
tuning file.
Signed-off-by: Stefan Klug <stefan.klug at ideasonboard.com>
---
src/ipa/rkisp1/algorithms/blc.cpp | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp
index d2e743541c99..0c39c3b47da5 100644
--- a/src/ipa/rkisp1/algorithms/blc.cpp
+++ b/src/ipa/rkisp1/algorithms/blc.cpp
@@ -46,10 +46,30 @@ BlackLevelCorrection::BlackLevelCorrection()
int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context,
const YamlObject &tuningData)
{
- blackLevelRed_ = tuningData["R"].get<int16_t>(256);
- blackLevelGreenR_ = tuningData["Gr"].get<int16_t>(256);
- blackLevelGreenB_ = tuningData["Gb"].get<int16_t>(256);
- blackLevelBlue_ = tuningData["B"].get<int16_t>(256);
+ auto blackLevels = context.camHelper->blackLevels();
+ if (blackLevels) {
+ Span<const int32_t, 4> levels = *blackLevels;
+ blackLevelRed_ = levels[0];
+ blackLevelGreenR_ = levels[1];
+ blackLevelGreenB_ = levels[2];
+ blackLevelBlue_ = levels[3];
+ } else
+ LOG(RkISP1Blc, Warning)
+ << "No black levels provided by camera sensor helper";
+
+ if (!blackLevels || (tuningData.contains("R") &&
+ tuningData.contains("Gr") &&
+ tuningData.contains("Gb") &&
+ tuningData.contains("B"))) {
+ blackLevelRed_ = tuningData["R"].get<int16_t>(256);
+ blackLevelGreenR_ = tuningData["Gr"].get<int16_t>(256);
+ blackLevelGreenB_ = tuningData["Gb"].get<int16_t>(256);
+ blackLevelBlue_ = tuningData["B"].get<int16_t>(256);
+
+ if (blackLevels)
+ LOG(RkISP1Blc, Warning)
+ << "Black levels overwritten by tuning file";
+ }
tuningParameters_ = true;
--
2.43.0
More information about the libcamera-devel
mailing list