libcamera: software_isp: Actually apply black level from tuning data

The black level obtained from the tuning file in software ISP is
retrieved in init (because this is the standard algorithm method with
access to tuning data) and stored into context.  But the context gets
reset in configure and the black level is lost and never applied.

Let's store the black level from the tuning file into an algorithm
instance variable and put it into the context only later in configure.
This is similar to what rkisp1 IPA does with the values obtained from
the tuning file.

Fixes: 41e3d61c74 ("libcamera: software_isp: Clear IPA context on configure and stop")
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Tested-by: Robert Mader <robert.mader@collabora.com>
Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Milan Zamazal 2024-12-03 10:38:13 +01:00 committed by Kieran Bingham
parent a43ea7ff70
commit 2a9b0b34f8
3 changed files with 10 additions and 4 deletions

View file

@ -21,7 +21,8 @@ BlackLevel::BlackLevel()
{ {
} }
int BlackLevel::init(IPAContext &context, const YamlObject &tuningData) int BlackLevel::init([[maybe_unused]] IPAContext &context,
const YamlObject &tuningData)
{ {
auto blackLevel = tuningData["blackLevel"].get<int16_t>(); auto blackLevel = tuningData["blackLevel"].get<int16_t>();
if (blackLevel.has_value()) { if (blackLevel.has_value()) {
@ -29,7 +30,7 @@ int BlackLevel::init(IPAContext &context, const YamlObject &tuningData)
* Convert 16 bit values from the tuning file to 8 bit black * Convert 16 bit values from the tuning file to 8 bit black
* level for the SoftISP. * level for the SoftISP.
*/ */
context.configuration.black.level = blackLevel.value() >> 8; definedLevel_ = blackLevel.value() >> 8;
} }
return 0; return 0;
} }
@ -37,6 +38,8 @@ int BlackLevel::init(IPAContext &context, const YamlObject &tuningData)
int BlackLevel::configure(IPAContext &context, int BlackLevel::configure(IPAContext &context,
[[maybe_unused]] const IPAConfigInfo &configInfo) [[maybe_unused]] const IPAConfigInfo &configInfo)
{ {
if (definedLevel_.has_value())
context.configuration.black.level = definedLevel_;
context.activeState.blc.level = context.activeState.blc.level =
context.configuration.black.level.value_or(255); context.configuration.black.level.value_or(255);
return 0; return 0;

View file

@ -7,6 +7,9 @@
#pragma once #pragma once
#include <optional>
#include <stdint.h>
#include "algorithm.h" #include "algorithm.h"
namespace libcamera { namespace libcamera {
@ -29,6 +32,7 @@ public:
private: private:
int32_t exposure_; int32_t exposure_;
double gain_; double gain_;
std::optional<uint8_t> definedLevel_;
}; };
} /* namespace ipa::soft::algorithms */ } /* namespace ipa::soft::algorithms */

View file

@ -206,8 +206,7 @@ int IPASoftSimple::configure(const IPAConfigInfo &configInfo)
(context_.configuration.agc.againMax - (context_.configuration.agc.againMax -
context_.configuration.agc.againMin) / context_.configuration.agc.againMin) /
100.0; 100.0;
if (!context_.configuration.black.level.has_value() && if (camHelper_->blackLevel().has_value()) {
camHelper_->blackLevel().has_value()) {
/* /*
* The black level from camHelper_ is a 16 bit value, software ISP * The black level from camHelper_ is a 16 bit value, software ISP
* works with 8 bit pixel values, both regardless of the actual * works with 8 bit pixel values, both regardless of the actual