Skip to content

Commit 35b6684

Browse files
committed
ipa: rpi: pisp: Allow an initial decompand curve to be set on the FE
In the current code, decompand will only set a curve in the prepare phase, which will only run after 1-2 frames pass through the FE. This is fixed by adding an initialValues() member function to the decompand algorithm, which will be called in the IPA before we start the hardware streaming. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
1 parent 9f9ab85 commit 35b6684

4 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/ipa/rpi/controller/decompand_algorithm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class DecompandAlgorithm : public Algorithm
1919
: Algorithm(controller)
2020
{
2121
}
22+
/* A decompand algorithm must provide the following: */
23+
virtual void initialValues(libcamera::ipa::Pwl &decompandCurve) = 0;
2224
};
2325

2426
} /* namespace RPiController */

src/ipa/rpi/controller/rpi/decompand.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ void Decompand::switchMode([[maybe_unused]] CameraMode const &cameraMode,
3939
mode_ = cameraMode;
4040
}
4141

42+
void Decompand::initialValues(libcamera::ipa::Pwl &decompandCurve)
43+
{
44+
if (config_.bitdepth == 0 || mode_.bitdepth == config_.bitdepth) {
45+
decompandCurve = config_.decompandCurve;
46+
} else
47+
decompandCurve = {};
48+
}
49+
4250
void Decompand::prepare(Metadata *imageMetadata)
4351
{
4452
DecompandStatus decompandStatus;

src/ipa/rpi/controller/rpi/decompand.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Decompand : public DecompandAlgorithm
2020
int read(const libcamera::YamlObject &params) override;
2121
void initialise() override;
2222
void switchMode(CameraMode const &cameraMode, Metadata *metadata) override;
23+
void initialValues(libcamera::ipa::Pwl &decompandCurve) override;
2324
void prepare(Metadata *imageMetadata) override;
2425

2526
private:

src/ipa/rpi/pisp/pisp.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "controller/cac_status.h"
3333
#include "controller/ccm_status.h"
3434
#include "controller/contrast_status.h"
35+
#include "controller/decompand_algorithm.h"
3536
#include "controller/decompand_status.h"
3637
#include "controller/denoise_algorithm.h"
3738
#include "controller/denoise_status.h"
@@ -335,6 +336,20 @@ int32_t IpaPiSP::platformStart([[maybe_unused]] const ControlList &controls,
335336
/* Cause the stitch block to be reset correctly. */
336337
lastStitchHdrStatus_ = HdrStatus();
337338

339+
/* Setup a default decompand curve on startup if needed. */
340+
RPiController::DecompandAlgorithm *decompand = dynamic_cast<RPiController::DecompandAlgorithm *>(
341+
controller_.getAlgorithm("decompand"));
342+
if (decompand) {
343+
std::scoped_lock<FrontEnd> l(*fe_);
344+
pisp_fe_global_config feGlobal;
345+
DecompandStatus decompandStatus;
346+
347+
fe_->GetGlobal(feGlobal);
348+
decompand->initialValues(decompandStatus.decompandCurve);
349+
applyDecompand(&decompandStatus, feGlobal);
350+
fe_->SetGlobal(feGlobal);
351+
}
352+
338353
return 0;
339354
}
340355

0 commit comments

Comments
 (0)