| Message ID | 20260805183517.228901-6-mzamazal@redhat.com |
|---|---|
| State | Superseded |
| Headers | show |
| Series |
|
| Related | show |
2026. 08. 05. 20:35 keltezéssel, Milan Zamazal írta: > 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. > > Reviewed-by: Bryan O'Donoghue <bod.linux@nxsw.ie> > Signed-off-by: Milan Zamazal <mzamazal@redhat.com> > --- It follows the same pattern as `ccmEnabled`, so I think it's fine. But I suppose after a point there should be a "features" struct of bool / bitmask instead of endless boolean out params. > include/libcamera/internal/software_isp/software_isp.h | 1 + > include/libcamera/ipa/soft.mojom | 4 +++- > src/ipa/simple/algorithms/lsc.cpp | 8 +++++++- > 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, 34 insertions(+), 11 deletions(-) > > [...] > diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h > index 30e51a477..a64dc925a 100644 > --- a/src/libcamera/software_isp/debayer_egl.h > +++ b/src/libcamera/software_isp/debayer_egl.h > @@ -45,7 +45,8 @@ public: > > int configure(const StreamConfiguration &inputCfg, > const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs, > - bool ccmEnabled) override; > + bool ccmEnabled, > + bool lscEnabled) override; > > Size patternSize(PixelFormat inputFormat) override; > > @@ -82,6 +83,7 @@ private: > unsigned int inputBufferCount_; > unsigned int outputBufferCount_; > > + bool lscEnabled_; = false Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > /* Shader parameters */ > float firstRed_x_; > float firstRed_y_; > diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp > index c7165771c..7e01acf57 100644 > --- a/src/libcamera/software_isp/software_isp.cpp > +++ b/src/libcamera/software_isp/software_isp.cpp > @@ -164,7 +164,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(); > @@ -293,7 +294,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; >
Barnabás Pőcze <barnabas.pocze@ideasonboard.com> writes: > 2026. 08. 05. 20:35 keltezéssel, Milan Zamazal írta: >> 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. >> Reviewed-by: Bryan O'Donoghue <bod.linux@nxsw.ie> >> Signed-off-by: Milan Zamazal <mzamazal@redhat.com> >> --- > > It follows the same pattern as `ccmEnabled`, so I think it's fine. > But I suppose after a point there should be a "features" struct of bool / bitmask > instead of endless boolean out params. > > >> include/libcamera/internal/software_isp/software_isp.h | 1 + >> include/libcamera/ipa/soft.mojom | 4 +++- >> src/ipa/simple/algorithms/lsc.cpp | 8 +++++++- >> 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, 34 insertions(+), 11 deletions(-) >> [...] >> diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h >> index 30e51a477..a64dc925a 100644 >> --- a/src/libcamera/software_isp/debayer_egl.h >> +++ b/src/libcamera/software_isp/debayer_egl.h >> @@ -45,7 +45,8 @@ public: >> int configure(const StreamConfiguration &inputCfg, >> const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs, >> - bool ccmEnabled) override; >> + bool ccmEnabled, >> + bool lscEnabled) override; >> Size patternSize(PixelFormat inputFormat) override; >> @@ -82,6 +83,7 @@ private: >> unsigned int inputBufferCount_; >> unsigned int outputBufferCount_; >> + bool lscEnabled_; > > = false Why? There is no intended initial value, the value is set in DebayerEGL::configure. > Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > > >> /* Shader parameters */ >> float firstRed_x_; >> float firstRed_y_; >> diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp >> index c7165771c..7e01acf57 100644 >> --- a/src/libcamera/software_isp/software_isp.cpp >> +++ b/src/libcamera/software_isp/software_isp.cpp >> @@ -164,7 +164,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(); >> @@ -293,7 +294,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; >>
2026. 08. 06. 19:04 keltezéssel, Milan Zamazal írta: > Barnabás Pőcze <barnabas.pocze@ideasonboard.com> writes: > >> 2026. 08. 05. 20:35 keltezéssel, Milan Zamazal írta: >>> 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. >>> Reviewed-by: Bryan O'Donoghue <bod.linux@nxsw.ie> >>> Signed-off-by: Milan Zamazal <mzamazal@redhat.com> >>> --- >> >> It follows the same pattern as `ccmEnabled`, so I think it's fine. >> But I suppose after a point there should be a "features" struct of bool / bitmask >> instead of endless boolean out params. >> >> >>> include/libcamera/internal/software_isp/software_isp.h | 1 + >>> include/libcamera/ipa/soft.mojom | 4 +++- >>> src/ipa/simple/algorithms/lsc.cpp | 8 +++++++- >>> 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, 34 insertions(+), 11 deletions(-) >>> [...] >>> diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h >>> index 30e51a477..a64dc925a 100644 >>> --- a/src/libcamera/software_isp/debayer_egl.h >>> +++ b/src/libcamera/software_isp/debayer_egl.h >>> @@ -45,7 +45,8 @@ public: >>> int configure(const StreamConfiguration &inputCfg, >>> const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs, >>> - bool ccmEnabled) override; >>> + bool ccmEnabled, >>> + bool lscEnabled) override; >>> Size patternSize(PixelFormat inputFormat) override; >>> @@ -82,6 +83,7 @@ private: >>> unsigned int inputBufferCount_; >>> unsigned int outputBufferCount_; >>> + bool lscEnabled_; >> >> = false > > Why? There is no intended initial value, the value is set in > DebayerEGL::configure. I suppose it's a matter of preference. I just don't like uninitialized values in such contexts. But arguably this class is already violating that, so fine, let's leave it as it is. > >> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> >> >> >>> /* Shader parameters */ >>> float firstRed_x_; >>> float firstRed_y_; >>> diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp >>> index c7165771c..7e01acf57 100644 >>> --- a/src/libcamera/software_isp/software_isp.cpp >>> +++ b/src/libcamera/software_isp/software_isp.cpp >>> @@ -164,7 +164,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(); >>> @@ -293,7 +294,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; >>> >
diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index 4f72dce9b..f24c04890 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -100,6 +100,7 @@ private: DebayerParams debayerParams_; DmaBufAllocator dmaHeap_; bool ccmEnabled_; + bool lscEnabled_; std::unique_ptr<ipa::soft::IPAProxySoft> ipa_; std::deque<FrameBuffer *> queuedInputBuffers_; diff --git a/include/libcamera/ipa/soft.mojom b/include/libcamera/ipa/soft.mojom index 77328c5fd..aaefd50c4 100644 --- a/include/libcamera/ipa/soft.mojom +++ b/include/libcamera/ipa/soft.mojom @@ -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) diff --git a/src/ipa/simple/algorithms/lsc.cpp b/src/ipa/simple/algorithms/lsc.cpp index 02d8cf48c..cd1208623 100644 --- a/src/ipa/simple/algorithms/lsc.cpp +++ b/src/ipa/simple/algorithms/lsc.cpp @@ -20,11 +20,17 @@ int Lsc::init(IPAContext &context, const ValueNode &tuningData) for (unsigned int i = 0; i < kGridSize; i++) gridPos_.push_back(static_cast<double>(i) / (kGridSize - 1)); - return lscAlgo_.init(tuningData, context.ctrlMap, + int ret = lscAlgo_.init(tuningData, context.ctrlMap, { .keys = { "r", "g", "b" }, .numHSamples = kGridSize, .numVSamples = kGridSize, .sensorSize = context.sensorInfo.activeAreaSize }); + if (ret) + return ret; + + context.lscEnabled = true; + + return 0; } int Lsc::configure(IPAContext &context, diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h index 23c2cfd0a..0ac36a4a8 100644 --- a/src/ipa/simple/ipa_context.h +++ b/src/ipa/simple/ipa_context.h @@ -93,6 +93,7 @@ struct IPAContext { FCQueue<IPAFrameContext> frameContexts; ControlInfoMap::Map ctrlMap; bool ccmEnabled = false; + bool lscEnabled = false; ipa::lsc::ActiveState lsc; }; diff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp index 629e1a32d..4c724183a 100644 --- a/src/ipa/simple/soft_simple.cpp +++ b/src/ipa/simple/soft_simple.cpp @@ -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; diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 82cdf1dc2..801c28fc9 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -99,6 +99,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 */ diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index 556852260..e30a05279 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -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; diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index c6d5d1e18..acff87fc0 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -624,7 +624,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; diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index 2c88c9e1a..ae570893b 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -37,7 +37,8 @@ public: int configure(const StreamConfiguration &inputCfg, const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs, - bool ccmEnabled) override; + bool ccmEnabled, + bool lscEnabled) override; Size patternSize(PixelFormat inputFormat) override; std::vector<PixelFormat> formats(PixelFormat input) override; std::tuple<unsigned int, unsigned int> diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index c7f27508a..e03fef684 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -273,7 +273,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; @@ -290,6 +291,8 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg, return -EINVAL; } + lscEnabled_ = lscEnabled; + inputConfig_.stride = inputCfg.stride; inputPixelFormat_ = inputCfg.pixelFormat; width_ = inputCfg.size.width; diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index 30e51a477..a64dc925a 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -45,7 +45,8 @@ public: int configure(const StreamConfiguration &inputCfg, const std::vector<std::reference_wrapper<const StreamConfiguration>> &outputCfgs, - bool ccmEnabled) override; + bool ccmEnabled, + bool lscEnabled) override; Size patternSize(PixelFormat inputFormat) override; @@ -82,6 +83,7 @@ private: unsigned int inputBufferCount_; unsigned int outputBufferCount_; + bool lscEnabled_; /* Shader parameters */ float firstRed_x_; float firstRed_y_; diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index c7165771c..7e01acf57 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -164,7 +164,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(); @@ -293,7 +294,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;