diff options
author | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2023-03-08 15:01:22 +0100 |
---|---|---|
committer | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2023-03-08 15:38:15 +0100 |
commit | 70e2fd6dff3a4257fb2a94442e62ea0b5b5bd8c1 (patch) | |
tree | b4827b249c0e12d322d9012c19ed01fa0b9fb8b7 /src/ipa/rkisp1/algorithms/lsc.cpp | |
parent | da6c0a692af5d3a21d76ce3915f8e09c454c8d66 (diff) |
ipa: rkisp1: lsc: Enable/disable LSC algorithm
Implement LSC algorithm enable/disable by parsing the
"LensShadingEnable" control in queueRequest().
Start with the LSC algorithm enabled by default and disable it
on application request.
The 'lsc' filed in the context configuration could also be removed but
other algorithms inspect it. Do not remove it for now.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Diffstat (limited to 'src/ipa/rkisp1/algorithms/lsc.cpp')
-rw-r--r-- | src/ipa/rkisp1/algorithms/lsc.cpp | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp index a7ccedb1..0c9f6cbd 100644 --- a/src/ipa/rkisp1/algorithms/lsc.cpp +++ b/src/ipa/rkisp1/algorithms/lsc.cpp @@ -14,6 +14,8 @@ #include <libcamera/base/log.h> #include <libcamera/base/utils.h> +#include <libcamera/control_ids.h> + #include "libcamera/internal/yaml_parser.h" #include "linux/rkisp1-config.h" @@ -147,6 +149,8 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context, return -EINVAL; } + context.configuration.lsc.enabled = false; + return 0; } @@ -181,10 +185,20 @@ int LensShadingCorrection::configure(IPAContext &context, yGrad_[i] = std::round(32768 / ySizes_[i]); } - context.configuration.lsc.enabled = true; + /* Enable LSC on first run unless explicitly disabled by application. */ + context.activeState.lsc.enable = true; + context.activeState.lsc.active = false; + return 0; } +void LensShadingCorrection::disableLSC(rkisp1_params_cfg *params) +{ + params->module_en_update |= RKISP1_CIF_ISP_MODULE_LSC; + params->module_ens &= ~RKISP1_CIF_ISP_MODULE_LSC; + params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_LSC; +} + void LensShadingCorrection::setParameters(rkisp1_params_cfg *params) { struct rkisp1_cif_isp_lsc_config &config = params->others.lsc_config; @@ -243,6 +257,25 @@ void LensShadingCorrection::interpolateTable(rkisp1_cif_isp_lsc_config &config, } /** + * \copydoc libcamera::ipa::Algorithm::queueRequest + */ +void LensShadingCorrection::queueRequest(IPAContext &context, + [[maybe_unused]] const uint32_t frame, + [[maybe_unused]] IPAFrameContext &frameContext, + const ControlList &controls) +{ + auto lsc = &context.activeState.lsc; + + const auto lscEnable = controls.get(controls::LensShadingEnable); + if (lscEnable && *lscEnable != lsc->enable) { + LOG(RkISP1Lsc, Debug) + << (*lscEnable ? "Enabling" : "Disabling") << " LSC"; + + lsc->enable = *lscEnable; + } +} + +/** * \copydoc libcamera::ipa::Algorithm::prepare */ void LensShadingCorrection::prepare(IPAContext &context, @@ -250,6 +283,25 @@ void LensShadingCorrection::prepare(IPAContext &context, [[maybe_unused]] IPAFrameContext &frameContext, rkisp1_params_cfg *params) { + auto lsc = &context.activeState.lsc; + + if (lsc->enable != lsc->active) { + /* If LSC has to be disabled, disable it and return here. */ + if (!lsc->enable) { + disableLSC(params); + lsc->active = false; + context.configuration.lsc.enabled = false; + return; + } + + lsc->active = true; + context.configuration.lsc.enabled = true; + } + + /* Nothing more to do here if LSC is not active. */ + if (!lsc->active) + return; + struct rkisp1_cif_isp_lsc_config &config = params->others.lsc_config; /* |