libcamera: pipeline_handler: Add createIPA() function
IPA proxies are created with a call to IPAManager::createIPA(), which is a static member function. This requires a complicated dance in the createIPA() function to retrieve the IPAManager instance through the camera manager, itself retrieved from the pipeline handler. Simplify the code by turning IPAManager::createIPA() into a non-static member function, and providing a wrapper in the PipelineHandler class to keep instantiation of IPA proxies easy in pipeline handlers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
This commit is contained in:
@@ -17,15 +17,16 @@
|
||||
#include <libcamera/ipa/ipa_module_info.h>
|
||||
|
||||
#include "libcamera/internal/camera_manager.h"
|
||||
#include "libcamera/internal/global_configuration.h"
|
||||
#include "libcamera/internal/ipa_module.h"
|
||||
#include "libcamera/internal/pipeline_handler.h"
|
||||
#include "libcamera/internal/pub_key.h"
|
||||
|
||||
namespace libcamera {
|
||||
|
||||
LOG_DECLARE_CATEGORY(IPAManager)
|
||||
|
||||
class GlobalConfiguration;
|
||||
class IPAModule;
|
||||
class PipelineHandler;
|
||||
|
||||
class IPAManager
|
||||
{
|
||||
public:
|
||||
@@ -33,23 +34,18 @@ public:
|
||||
~IPAManager();
|
||||
|
||||
template<typename T>
|
||||
static std::unique_ptr<T> createIPA(PipelineHandler *pipe,
|
||||
uint32_t minVersion,
|
||||
uint32_t maxVersion)
|
||||
std::unique_ptr<T> createIPA(PipelineHandler *pipe, uint32_t minVersion,
|
||||
uint32_t maxVersion)
|
||||
{
|
||||
CameraManager *cm = pipe->cameraManager();
|
||||
IPAManager *self = cm->_d()->ipaManager();
|
||||
IPAModule *m = self->module(pipe, minVersion, maxVersion);
|
||||
IPAModule *m = module(pipe, minVersion, maxVersion);
|
||||
if (!m)
|
||||
return nullptr;
|
||||
|
||||
const GlobalConfiguration &configuration = cm->_d()->configuration();
|
||||
|
||||
auto proxy = [&]() -> std::unique_ptr<T> {
|
||||
if (self->isSignatureValid(m))
|
||||
return std::make_unique<typename T::Threaded>(m, configuration);
|
||||
if (isSignatureValid(m))
|
||||
return std::make_unique<typename T::Threaded>(m, configuration_);
|
||||
else
|
||||
return std::make_unique<typename T::Isolated>(m, configuration);
|
||||
return std::make_unique<typename T::Isolated>(m, configuration_);
|
||||
}();
|
||||
|
||||
if (!proxy->isValid()) {
|
||||
@@ -77,6 +73,7 @@ private:
|
||||
|
||||
bool isSignatureValid(IPAModule *ipa) const;
|
||||
|
||||
const GlobalConfiguration &configuration_;
|
||||
std::vector<std::unique_ptr<IPAModule>> modules_;
|
||||
|
||||
#if HAVE_IPA_PUBKEY
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
#include <libcamera/controls.h>
|
||||
#include <libcamera/stream.h>
|
||||
|
||||
#include "libcamera/internal/camera_manager.h"
|
||||
#include "libcamera/internal/ipa_manager.h"
|
||||
|
||||
namespace libcamera {
|
||||
|
||||
class Camera;
|
||||
class CameraConfiguration;
|
||||
class CameraManager;
|
||||
class DeviceEnumerator;
|
||||
class DeviceMatch;
|
||||
class FrameBuffer;
|
||||
@@ -70,6 +72,13 @@ public:
|
||||
|
||||
CameraManager *cameraManager() const { return manager_; }
|
||||
|
||||
template<typename T>
|
||||
std::unique_ptr<T> createIPA(uint32_t minVersion, uint32_t maxVersion)
|
||||
{
|
||||
IPAManager *ipaManager = manager_->_d()->ipaManager();
|
||||
return ipaManager->createIPA<T>(this, minVersion, maxVersion);
|
||||
}
|
||||
|
||||
protected:
|
||||
void registerCamera(std::shared_ptr<Camera> camera);
|
||||
void hotplugMediaDevice(std::shared_ptr<MediaDevice> media);
|
||||
|
||||
Reference in New Issue
Block a user