@@ -100,6 +100,7 @@ private:
DebayerParams debayerParams_;
DmaBufAllocator dmaHeap_;
bool ccmEnabled_;
+ bool lscEnabled_;
std::unique_ptr<ipa::soft::IPAProxySoft> ipa_;
std::deque<FrameBuffer *> queuedInputBuffers_;
@@ -18,7 +18,9 @@ interface IPASoftInterface {
libcamera.SharedFD fdParams,
libcamera.IPACameraSensorInfo sensorInfo,
libcamera.ControlInfoMap sensorControls)
- => (int32 ret, libcamera.ControlInfoMap ipaControls, bool ccmEnabled);
+ => (int32 ret,
+ libcamera.ControlInfoMap ipaControls,
+ bool ccmEnabled, bool lscEnabled);
start() => (int32 ret);
stop();
configure(IPAConfigInfo configInfo)
@@ -15,7 +15,7 @@ namespace ipa::soft::algorithms {
LOG_DEFINE_CATEGORY(IPASoftLsc)
-int Lsc::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)
+int Lsc::init(IPAContext &context, const YamlObject &tuningData)
{
int ret_r = lscR.readYaml(tuningData["grids"], "ct", "r");
int ret_g = lscG.readYaml(tuningData["grids"], "ct", "g");
@@ -27,6 +27,8 @@ int Lsc::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData
return -EINVAL;
}
+ context.lscEnabled = true;
+
return 0;
}
@@ -93,6 +93,7 @@ struct IPAContext {
FCQueue<IPAFrameContext> frameContexts;
ControlInfoMap::Map ctrlMap;
bool ccmEnabled = false;
+ bool lscEnabled = false;
};
} /* namespace ipa::soft */
@@ -57,7 +57,8 @@ public:
const IPACameraSensorInfo &sensorInfo,
const ControlInfoMap &sensorControls,
ControlInfoMap *ipaControls,
- bool *ccmEnabled) override;
+ bool *ccmEnabled,
+ bool *lscEnabled) override;
int configure(const IPAConfigInfo &configInfo) override;
int start() override;
@@ -97,7 +98,8 @@ int IPASoftSimple::init(const IPASettings &settings,
const IPACameraSensorInfo &sensorInfo,
const ControlInfoMap &sensorControls,
ControlInfoMap *ipaControls,
- bool *ccmEnabled)
+ bool *ccmEnabled,
+ bool *lscEnabled)
{
camHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel);
if (!camHelper_) {
@@ -136,6 +138,7 @@ int IPASoftSimple::init(const IPASettings &settings,
return ret;
*ccmEnabled = context_.ccmEnabled;
+ *lscEnabled = context_.lscEnabled;
params_ = nullptr;
stats_ = nullptr;
@@ -91,6 +91,7 @@ Debayer::~Debayer()
* \param[in] inputCfg The input configuration
* \param[in] outputCfgs The output configurations
* \param[in] ccmEnabled Whether a color correction matrix is applied
+ * \param[in] lscEnabled Whether lens shading correction grid is provided
*
* \return 0 on success, a negative errno on failure
*/
@@ -40,7 +40,8 @@ public:
virtual int configure(const StreamConfiguration &inputCfg,
const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
- bool ccmEnabled) = 0;
+ bool ccmEnabled,
+ bool lscEnabled) = 0;
virtual std::vector<PixelFormat> formats(PixelFormat inputFormat) = 0;
@@ -541,7 +541,8 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat,
int DebayerCpu::configure(const StreamConfiguration &inputCfg,
const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
- bool ccmEnabled)
+ bool ccmEnabled,
+ [[maybe_unused]] bool lscEnabled)
{
if (getInputConfig(inputCfg.pixelFormat, inputConfig_) != 0)
return -EINVAL;
@@ -36,7 +36,8 @@ public:
int configure(const StreamConfiguration &inputCfg,
const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
- bool ccmEnabled);
+ bool ccmEnabled,
+ bool lscEnabled);
Size patternSize(PixelFormat inputFormat);
std::vector<PixelFormat> formats(PixelFormat input);
std::tuple<unsigned int, unsigned int>
@@ -278,7 +278,8 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm
int DebayerEGL::configure(const StreamConfiguration &inputCfg,
const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
- [[maybe_unused]] bool ccmEnabled)
+ [[maybe_unused]] bool ccmEnabled,
+ bool lscEnabled)
{
if (getInputConfig(inputCfg.pixelFormat, inputConfig_) != 0)
return -EINVAL;
@@ -295,6 +296,8 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg,
return -EINVAL;
}
+ lscEnabled_ = lscEnabled;
+
inputConfig_.stride = inputCfg.stride;
inputPixelFormat_ = inputCfg.pixelFormat;
width_ = inputCfg.size.width;
@@ -43,7 +43,8 @@ public:
int configure(const StreamConfiguration &inputCfg,
const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs,
- bool ccmEnabled);
+ bool ccmEnabled,
+ bool lscEnabled);
Size patternSize(PixelFormat inputFormat);
@@ -84,6 +85,7 @@ private:
std::unique_ptr<eGLImage> eglImageBayerIn_;
std::unique_ptr<eGLImage> eglImageBayerOut_;
+ bool lscEnabled_;
/* Shader parameters */
float firstRed_x_;
float firstRed_y_;
@@ -155,7 +155,8 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor,
sensorInfo,
sensor->controls(),
ipaControls,
- &ccmEnabled_);
+ &ccmEnabled_,
+ &lscEnabled_);
if (ret) {
LOG(SoftwareIsp, Error) << "IPA init failed";
debayer_.reset();
@@ -271,7 +272,7 @@ int SoftwareIsp::configure(const StreamConfiguration &inputCfg,
if (ret < 0)
return ret;
- ret = debayer_->configure(inputCfg, outputCfgs, ccmEnabled_);
+ ret = debayer_->configure(inputCfg, outputCfgs, ccmEnabled_, lscEnabled_);
if (ret < 0)
return ret;
The lens shading algorithm may or may not be enabled in the tuning file. Debayering configuration needs this information to arrange things accordingly, e.g. to set up shader parameters. Let's add a corresponding flag that is set in the LSC algorithm (if present) and passed to Debayer::configure. This is similar to what we already do with CCM availability. The flag is ignored by CPU ISP, where LSC is not going to be implemented for now. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> --- include/libcamera/internal/software_isp/software_isp.h | 1 + include/libcamera/ipa/soft.mojom | 4 +++- src/ipa/simple/algorithms/lsc.cpp | 4 +++- src/ipa/simple/ipa_context.h | 1 + src/ipa/simple/soft_simple.cpp | 7 +++++-- src/libcamera/software_isp/debayer.cpp | 1 + src/libcamera/software_isp/debayer.h | 3 ++- src/libcamera/software_isp/debayer_cpu.cpp | 3 ++- src/libcamera/software_isp/debayer_cpu.h | 3 ++- src/libcamera/software_isp/debayer_egl.cpp | 5 ++++- src/libcamera/software_isp/debayer_egl.h | 4 +++- src/libcamera/software_isp/software_isp.cpp | 5 +++-- 12 files changed, 30 insertions(+), 11 deletions(-)