@@ -229,7 +229,7 @@ void Dpf::prepare(IPAContext &context, const uint32_t frame,
*config = config_;
const auto &awb = context.configuration.awb;
- const auto &lsc = context.configuration.lsc;
+ const auto &lsc = context.activeState.lsc;
auto &mode = config->gain.mode;
@@ -366,6 +366,8 @@ LensShadingCorrection::LensShadingCorrection()
int LensShadingCorrection::init([[maybe_unused]] IPAContext &context,
const YamlObject &tuningData)
{
+ context.ctrlMap[&controls::LensShadingEnable] = ControlInfo(false, true, true);
+
xSize_ = parseSizes(tuningData, "x-size");
ySize_ = parseSizes(tuningData, "y-size");
@@ -449,7 +451,7 @@ int LensShadingCorrection::configure(IPAContext &context,
sets_.setData(std::move(shadingData));
- context.configuration.lsc.enabled = true;
+ context.activeState.lsc.enabled = true;
return 0;
}
@@ -470,6 +472,27 @@ void LensShadingCorrection::copyTable(rkisp1_cif_isp_lsc_config &config,
std::copy(set.b.begin(), set.b.end(), &config.b_data_tbl[0][0]);
}
+/**
+ * \copydoc libcamera::ipa::Algorithm::queueRequest
+ */
+void LensShadingCorrection::queueRequest(IPAContext &context,
+ [[maybe_unused]] const uint32_t frame,
+ IPAFrameContext &frameContext,
+ const ControlList &controls)
+{
+ auto &lsc = context.activeState.lsc;
+
+ const auto &lscEnable = controls.get(controls::LensShadingEnable);
+ if (lscEnable && *lscEnable != lsc.enabled) {
+ lsc.enabled = *lscEnable;
+
+ LOG(RkISP1Lsc, Debug)
+ << (*lscEnable ? "Enabling" : "Disabling") << " Lsc";
+
+ frameContext.lsc.update = true;
+ }
+}
+
/**
* \copydoc libcamera::ipa::Algorithm::prepare
*/
@@ -479,16 +502,26 @@ void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context,
RkISP1Params *params)
{
uint32_t ct = frameContext.awb.temperatureK;
- if (std::abs(static_cast<int>(ct) - static_cast<int>(lastAppliedCt_)) <
+
+ if (!frameContext.lsc.update && !context.activeState.lsc.enabled)
+ return;
+
+ if (!frameContext.lsc.update &&
+ std::abs(static_cast<int>(ct) - static_cast<int>(lastAppliedCt_)) <
kColourTemperatureChangeThreshhold)
return;
+
unsigned int quantizedCt;
const Components &set = sets_.getInterpolated(ct, &quantizedCt);
- if (lastAppliedQuantizedCt_ == quantizedCt)
+ if (!frameContext.lsc.update && lastAppliedQuantizedCt_ == quantizedCt)
return;
auto config = params->block<BlockType::Lsc>();
- config.setEnabled(true);
+ config.setEnabled(context.activeState.lsc.enabled);
+
+ if (!context.activeState.lsc.enabled)
+ return;
+
setParameters(*config);
copyTable(*config, set);
@@ -29,6 +29,9 @@ public:
void prepare(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
RkISP1Params *params) override;
+ void queueRequest(IPAContext &context, const uint32_t frame,
+ IPAFrameContext &frameContext,
+ const ControlList &controls) override;
struct Components {
std::vector<uint16_t> r;
@@ -55,10 +55,6 @@ struct IPASessionConfiguration {
bool supported;
} compress;
- struct {
- bool enabled;
- } lsc;
-
struct {
utils::Duration minExposureTime;
utils::Duration maxExposureTime;
@@ -139,6 +135,10 @@ struct IPAActiveState {
double gain;
double strength;
} wdr;
+
+ struct {
+ bool enabled;
+ } lsc;
};
struct IPAFrameContext : public FrameContext {
@@ -214,6 +214,10 @@ struct IPAFrameContext : public FrameContext {
double strength;
double gain;
} wdr;
+
+ struct {
+ bool update;
+ } lsc;
};
struct IPAContext {
@@ -1352,4 +1352,7 @@ controls:
description: |
Enable or disable the lens shading algorithm.
+ This control is only available when there are valid lens shading
+ correction parameters available in the tuning file.
+
...
Implement the LensShadingEnable control for rkisp1. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> --- src/ipa/rkisp1/algorithms/dpf.cpp | 2 +- src/ipa/rkisp1/algorithms/lsc.cpp | 41 ++++++++++++++++++++++++++--- src/ipa/rkisp1/algorithms/lsc.h | 3 +++ src/ipa/rkisp1/ipa_context.h | 12 ++++++--- src/libcamera/control_ids_core.yaml | 3 +++ 5 files changed, 52 insertions(+), 9 deletions(-)