| Message ID | 20260818140548.179663-2-johannes.goede@oss.qualcomm.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
2026. 08. 18. 16:05 keltezéssel, Hans de Goede írta: > Currently createIPA() / IPAManager::module() assume that there is a 1:1 > relationship between pipeline handlers and IPAs and IPA matching is done > based on matching the pipe to ipaModuleInfo.pipelineName[]. > > One way to allow using a single IPA with multiple pipelines would be to > allow the IPA to declare itself compatible with more than one pipeline, > turning ipaModuleInfo.pipelineName[] into e.g. a vector. But the way > ipaModuleInfo is loaded as an ELF symbol requires it to be a simple flat > C-struct. > > Instead, move the IPA creation procedure to be name-based, introducing > a PipelineHandler::createIPA(name, minVer, maxVer) overload that allows > to specify the name of the IPA module to match. Pipeline handlers that > wants to use their name as matching criteria can continue doing so using > the already existing PipelineHandler::createIPA(minVer, maxVer) overload. > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> > Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com> > --- Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > Changes in v9: > - Remove no longer needed PipelineHandler forward decl. from ipa_manager.h > - Remove no longer needed pipeline_handler.h include from ipa_manager.cpp, > ipa_module.[cpp|h] > > Changes in v5: > - Rebase on top of db998e618aaa ("libcamera: pipeline_handler: Add > createIPA() function") which moved the createIPA() wrapper for > pipeline-handlers into the PipelineHandler class > > Changes in v4: > - Rebase, change author to Hans' new email address > > Changes in v1 from Hans' original patch: > - Slightly different approach addressing the review comments on Hans' v1 > by creating an overload for PipelineHandler::createIPA() that allows > pipelines to specify the IPA module name. > --- > include/libcamera/internal/ipa_manager.h | 7 +++--- > include/libcamera/internal/ipa_module.h | 6 ++--- > include/libcamera/internal/pipeline_handler.h | 9 ++++++- > src/libcamera/ipa_manager.cpp | 9 +++---- > src/libcamera/ipa_module.cpp | 16 ++++++------ > src/libcamera/pipeline_handler.cpp | 25 +++++++++++++++++-- > test/ipa/ipa_interface_test.cpp | 2 +- > 7 files changed, 48 insertions(+), 26 deletions(-) > > diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h > index aaa3ca37c..23c262b14 100644 > --- a/include/libcamera/internal/ipa_manager.h > +++ b/include/libcamera/internal/ipa_manager.h > @@ -25,7 +25,6 @@ LOG_DECLARE_CATEGORY(IPAManager) > class CameraManager; > class GlobalConfiguration; > class IPAModule; > -class PipelineHandler; > > class IPAManager > { > @@ -34,10 +33,10 @@ public: > ~IPAManager(); > > template<typename T> > - std::unique_ptr<T> createIPA(PipelineHandler *pipe, uint32_t minVersion, > + std::unique_ptr<T> createIPA(const char *name, uint32_t minVersion, > uint32_t maxVersion) > { > - IPAModule *m = module(pipe, minVersion, maxVersion); > + IPAModule *m = module(name, minVersion, maxVersion); > if (!m) > return nullptr; > > @@ -68,7 +67,7 @@ private: > std::vector<std::string> &files); > unsigned int addDir(const char *libDir, unsigned int maxDepth = 0); > > - IPAModule *module(PipelineHandler *pipe, uint32_t minVersion, > + IPAModule *module(const char *name, uint32_t minVersion, > uint32_t maxVersion); > > bool isSignatureValid(IPAModule *ipa) const; > diff --git a/include/libcamera/internal/ipa_module.h b/include/libcamera/internal/ipa_module.h > index 15f19492c..a4cfe864c 100644 > --- a/include/libcamera/internal/ipa_module.h > +++ b/include/libcamera/internal/ipa_module.h > @@ -16,8 +16,6 @@ > #include <libcamera/ipa/ipa_interface.h> > #include <libcamera/ipa/ipa_module_info.h> > > -#include "libcamera/internal/pipeline_handler.h" > - > namespace libcamera { > > class IPAModule : public Loggable > @@ -36,8 +34,8 @@ public: > > IPAInterface *createInterface(); > > - bool match(PipelineHandler *pipe, > - uint32_t minVersion, uint32_t maxVersion) const; > + bool match(const char *name, uint32_t minVersion, > + uint32_t maxVersion) const; > > protected: > std::string logPrefix() const override; > diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h > index 6922ce18e..b60c07b13 100644 > --- a/include/libcamera/internal/pipeline_handler.h > +++ b/include/libcamera/internal/pipeline_handler.h > @@ -76,7 +76,14 @@ public: > std::unique_ptr<T> createIPA(uint32_t minVersion, uint32_t maxVersion) > { > IPAManager *ipaManager = manager_->_d()->ipaManager(); > - return ipaManager->createIPA<T>(this, minVersion, maxVersion); > + return ipaManager->createIPA<T>(name_, minVersion, maxVersion); > + } > + > + template<typename T> > + std::unique_ptr<T> createIPA(const char *ipaName, uint32_t minVersion, uint32_t maxVersion) > + { > + IPAManager *ipaManager = manager_->_d()->ipaManager(); > + return ipaManager->createIPA<T>(ipaName, minVersion, maxVersion); > } > > protected: > diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp > index 41918e4c2..845a09f10 100644 > --- a/src/libcamera/ipa_manager.cpp > +++ b/src/libcamera/ipa_manager.cpp > @@ -21,7 +21,6 @@ > #include "libcamera/internal/global_configuration.h" > #include "libcamera/internal/ipa_module.h" > #include "libcamera/internal/ipa_proxy.h" > -#include "libcamera/internal/pipeline_handler.h" > > /** > * \file ipa_manager.h > @@ -248,15 +247,15 @@ unsigned int IPAManager::addDir(const char *libDir, unsigned int maxDepth) > > /** > * \brief Retrieve an IPA module that matches a given pipeline handler > - * \param[in] pipe The pipeline handler > + * \param[in] name The IPA module string identifier > * \param[in] minVersion Minimum acceptable version of IPA module > * \param[in] maxVersion Maximum acceptable version of IPA module > */ > -IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion, > +IPAModule *IPAManager::module(const char *name, uint32_t minVersion, > uint32_t maxVersion) > { > for (const auto &module : modules_) { > - if (module->match(pipe, minVersion, maxVersion)) > + if (module->match(name, minVersion, maxVersion)) > return module.get(); > } > > @@ -266,7 +265,7 @@ IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion, > /** > * \fn IPAManager::createIPA() > * \brief Create an IPA proxy that matches a given pipeline handler > - * \param[in] pipe The pipeline handler that wants a matching IPA proxy > + * \param[in] name The IPA module name > * \param[in] minVersion Minimum acceptable version of IPA module > * \param[in] maxVersion Maximum acceptable version of IPA module > * > diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp > index e6ea61e44..b7d770444 100644 > --- a/src/libcamera/ipa_module.cpp > +++ b/src/libcamera/ipa_module.cpp > @@ -24,8 +24,6 @@ > #include <libcamera/base/span.h> > #include <libcamera/base/utils.h> > > -#include "libcamera/internal/pipeline_handler.h" > - > /** > * \file ipa_module.h > * \brief Image Processing Algorithm module > @@ -462,22 +460,22 @@ IPAInterface *IPAModule::createInterface() > } > > /** > - * \brief Verify if the IPA module matches a given pipeline handler > - * \param[in] pipe Pipeline handler to match with > + * \brief Verify if the IPA module matches a given name > + * \param[in] name The IPA module name > * \param[in] minVersion Minimum acceptable version of IPA module > * \param[in] maxVersion Maximum acceptable version of IPA module > * > - * This function checks if this IPA module matches the \a pipe pipeline handler, > + * This function checks if this IPA module matches the requested \a name > * and the input version range. > * > - * \return True if the pipeline handler matches the IPA module, or false otherwise > + * \return True if the IPA module matches, or false otherwise > */ > -bool IPAModule::match(PipelineHandler *pipe, > - uint32_t minVersion, uint32_t maxVersion) const > +bool IPAModule::match(const char *name, uint32_t minVersion, > + uint32_t maxVersion) const > { > return info_.pipelineVersion >= minVersion && > info_.pipelineVersion <= maxVersion && > - !strcmp(info_.pipelineName, pipe->name()); > + !strcmp(info_.name, name); > } > > std::string IPAModule::logPrefix() const > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp > index e7145c1d4..25fc11989 100644 > --- a/src/libcamera/pipeline_handler.cpp > +++ b/src/libcamera/pipeline_handler.cpp > @@ -836,11 +836,32 @@ void PipelineHandler::disconnect() > */ > > /** > - * \fn PipelineHandler::createIPA() > - * \brief Create an IPA proxy that matches this pipeline handler > + * \fn PipelineHandler::createIPA(const char *ipaName, uint32_t minVersion, uint32_t maxVersion) > + * \brief Create an IPA proxy that matches the requested name and version > + * \param[in] ipaName The IPA module name > * \param[in] minVersion Minimum acceptable version of IPA module > * \param[in] maxVersion Maximum acceptable version of IPA module > * > + * Create an IPA module using \a ipaName as the matching identifier. This > + * overload allows pipeline handlers to create an IPA module by specifying its > + * name instead of relying on the fact that the IPA module matches the pipeline > + * handler's one. > + * > + * \return A newly created IPA proxy, or nullptr if no matching IPA module is > + * found or if the IPA proxy fails to initialize > + */ > + > +/** > + * \fn PipelineHandler::createIPA(uint32_t minVersion, uint32_t maxVersion) > + * \brief Create an IPA proxy that matches the pipeline handler name and the > + * requested version > + * \param[in] minVersion Minimum acceptable version of IPA module > + * \param[in] maxVersion Maximum acceptable version of IPA module > + * > + * Create an IPA module using the pipeline handler name as the matching > + * identifier. This overload allows pipeline handler to create an IPA module > + * whose name matches the pipeline handler one. > + * > * \return A newly created IPA proxy, or nullptr if no matching IPA module is > * found or if the IPA proxy fails to initialize > */ > diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp > index 271c4e2c9..0b01a396e 100644 > --- a/test/ipa/ipa_interface_test.cpp > +++ b/test/ipa/ipa_interface_test.cpp > @@ -99,7 +99,7 @@ protected: > EventDispatcher *dispatcher = thread()->eventDispatcher(); > Timer timer; > > - ipa_ = ipaManager_->createIPA<ipa::vimc::IPAProxyVimc>(pipe_.get(), 0, 0); > + ipa_ = ipaManager_->createIPA<ipa::vimc::IPAProxyVimc>(pipe_->name(), 0, 0); > if (!ipa_) { > cerr << "Failed to create VIMC IPA interface" << endl; > return TestFail;
diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h index aaa3ca37c..23c262b14 100644 --- a/include/libcamera/internal/ipa_manager.h +++ b/include/libcamera/internal/ipa_manager.h @@ -25,7 +25,6 @@ LOG_DECLARE_CATEGORY(IPAManager) class CameraManager; class GlobalConfiguration; class IPAModule; -class PipelineHandler; class IPAManager { @@ -34,10 +33,10 @@ public: ~IPAManager(); template<typename T> - std::unique_ptr<T> createIPA(PipelineHandler *pipe, uint32_t minVersion, + std::unique_ptr<T> createIPA(const char *name, uint32_t minVersion, uint32_t maxVersion) { - IPAModule *m = module(pipe, minVersion, maxVersion); + IPAModule *m = module(name, minVersion, maxVersion); if (!m) return nullptr; @@ -68,7 +67,7 @@ private: std::vector<std::string> &files); unsigned int addDir(const char *libDir, unsigned int maxDepth = 0); - IPAModule *module(PipelineHandler *pipe, uint32_t minVersion, + IPAModule *module(const char *name, uint32_t minVersion, uint32_t maxVersion); bool isSignatureValid(IPAModule *ipa) const; diff --git a/include/libcamera/internal/ipa_module.h b/include/libcamera/internal/ipa_module.h index 15f19492c..a4cfe864c 100644 --- a/include/libcamera/internal/ipa_module.h +++ b/include/libcamera/internal/ipa_module.h @@ -16,8 +16,6 @@ #include <libcamera/ipa/ipa_interface.h> #include <libcamera/ipa/ipa_module_info.h> -#include "libcamera/internal/pipeline_handler.h" - namespace libcamera { class IPAModule : public Loggable @@ -36,8 +34,8 @@ public: IPAInterface *createInterface(); - bool match(PipelineHandler *pipe, - uint32_t minVersion, uint32_t maxVersion) const; + bool match(const char *name, uint32_t minVersion, + uint32_t maxVersion) const; protected: std::string logPrefix() const override; diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index 6922ce18e..b60c07b13 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -76,7 +76,14 @@ public: std::unique_ptr<T> createIPA(uint32_t minVersion, uint32_t maxVersion) { IPAManager *ipaManager = manager_->_d()->ipaManager(); - return ipaManager->createIPA<T>(this, minVersion, maxVersion); + return ipaManager->createIPA<T>(name_, minVersion, maxVersion); + } + + template<typename T> + std::unique_ptr<T> createIPA(const char *ipaName, uint32_t minVersion, uint32_t maxVersion) + { + IPAManager *ipaManager = manager_->_d()->ipaManager(); + return ipaManager->createIPA<T>(ipaName, minVersion, maxVersion); } protected: diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 41918e4c2..845a09f10 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -21,7 +21,6 @@ #include "libcamera/internal/global_configuration.h" #include "libcamera/internal/ipa_module.h" #include "libcamera/internal/ipa_proxy.h" -#include "libcamera/internal/pipeline_handler.h" /** * \file ipa_manager.h @@ -248,15 +247,15 @@ unsigned int IPAManager::addDir(const char *libDir, unsigned int maxDepth) /** * \brief Retrieve an IPA module that matches a given pipeline handler - * \param[in] pipe The pipeline handler + * \param[in] name The IPA module string identifier * \param[in] minVersion Minimum acceptable version of IPA module * \param[in] maxVersion Maximum acceptable version of IPA module */ -IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion, +IPAModule *IPAManager::module(const char *name, uint32_t minVersion, uint32_t maxVersion) { for (const auto &module : modules_) { - if (module->match(pipe, minVersion, maxVersion)) + if (module->match(name, minVersion, maxVersion)) return module.get(); } @@ -266,7 +265,7 @@ IPAModule *IPAManager::module(PipelineHandler *pipe, uint32_t minVersion, /** * \fn IPAManager::createIPA() * \brief Create an IPA proxy that matches a given pipeline handler - * \param[in] pipe The pipeline handler that wants a matching IPA proxy + * \param[in] name The IPA module name * \param[in] minVersion Minimum acceptable version of IPA module * \param[in] maxVersion Maximum acceptable version of IPA module * diff --git a/src/libcamera/ipa_module.cpp b/src/libcamera/ipa_module.cpp index e6ea61e44..b7d770444 100644 --- a/src/libcamera/ipa_module.cpp +++ b/src/libcamera/ipa_module.cpp @@ -24,8 +24,6 @@ #include <libcamera/base/span.h> #include <libcamera/base/utils.h> -#include "libcamera/internal/pipeline_handler.h" - /** * \file ipa_module.h * \brief Image Processing Algorithm module @@ -462,22 +460,22 @@ IPAInterface *IPAModule::createInterface() } /** - * \brief Verify if the IPA module matches a given pipeline handler - * \param[in] pipe Pipeline handler to match with + * \brief Verify if the IPA module matches a given name + * \param[in] name The IPA module name * \param[in] minVersion Minimum acceptable version of IPA module * \param[in] maxVersion Maximum acceptable version of IPA module * - * This function checks if this IPA module matches the \a pipe pipeline handler, + * This function checks if this IPA module matches the requested \a name * and the input version range. * - * \return True if the pipeline handler matches the IPA module, or false otherwise + * \return True if the IPA module matches, or false otherwise */ -bool IPAModule::match(PipelineHandler *pipe, - uint32_t minVersion, uint32_t maxVersion) const +bool IPAModule::match(const char *name, uint32_t minVersion, + uint32_t maxVersion) const { return info_.pipelineVersion >= minVersion && info_.pipelineVersion <= maxVersion && - !strcmp(info_.pipelineName, pipe->name()); + !strcmp(info_.name, name); } std::string IPAModule::logPrefix() const diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index e7145c1d4..25fc11989 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -836,11 +836,32 @@ void PipelineHandler::disconnect() */ /** - * \fn PipelineHandler::createIPA() - * \brief Create an IPA proxy that matches this pipeline handler + * \fn PipelineHandler::createIPA(const char *ipaName, uint32_t minVersion, uint32_t maxVersion) + * \brief Create an IPA proxy that matches the requested name and version + * \param[in] ipaName The IPA module name * \param[in] minVersion Minimum acceptable version of IPA module * \param[in] maxVersion Maximum acceptable version of IPA module * + * Create an IPA module using \a ipaName as the matching identifier. This + * overload allows pipeline handlers to create an IPA module by specifying its + * name instead of relying on the fact that the IPA module matches the pipeline + * handler's one. + * + * \return A newly created IPA proxy, or nullptr if no matching IPA module is + * found or if the IPA proxy fails to initialize + */ + +/** + * \fn PipelineHandler::createIPA(uint32_t minVersion, uint32_t maxVersion) + * \brief Create an IPA proxy that matches the pipeline handler name and the + * requested version + * \param[in] minVersion Minimum acceptable version of IPA module + * \param[in] maxVersion Maximum acceptable version of IPA module + * + * Create an IPA module using the pipeline handler name as the matching + * identifier. This overload allows pipeline handler to create an IPA module + * whose name matches the pipeline handler one. + * * \return A newly created IPA proxy, or nullptr if no matching IPA module is * found or if the IPA proxy fails to initialize */ diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp index 271c4e2c9..0b01a396e 100644 --- a/test/ipa/ipa_interface_test.cpp +++ b/test/ipa/ipa_interface_test.cpp @@ -99,7 +99,7 @@ protected: EventDispatcher *dispatcher = thread()->eventDispatcher(); Timer timer; - ipa_ = ipaManager_->createIPA<ipa::vimc::IPAProxyVimc>(pipe_.get(), 0, 0); + ipa_ = ipaManager_->createIPA<ipa::vimc::IPAProxyVimc>(pipe_->name(), 0, 0); if (!ipa_) { cerr << "Failed to create VIMC IPA interface" << endl; return TestFail;