summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2023-09-30 16:08:56 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-08-07 18:58:55 +0300
commit1045522af99c9f26e0f583aa2310174f7ff42178 (patch)
treee68ea3bb13c35a74154b89b59e8f410483d48309 /include
parent6f1df8d6060c1a584c553479cb9e18fe4d1d0b5e (diff)
libcamera: ipa_manager: Remove singleton requirement
The IPAManager class implements a singleton pattern due to the need of accessing the instance in a static member function. The function now takes a pointer to a PipelineHandler, which we can use to access the CameraManager, and from there, the IPAManager. Add accessors to the internal API to expose the CameraManager from the PipelineHandler, and the IPAManager from the CameraManager. This requires allocating the IPAManager dynamically to avoid a loop in includes. Use those accessors to replace the IPAManager singleton. Update the IPA interface unit test to instantiate a CameraManager instead of an IPAManager and ProcessManager, to reflect the new way that the IPAManager is accessed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/internal/camera_manager.h7
-rw-r--r--include/libcamera/internal/ipa_manager.h9
-rw-r--r--include/libcamera/internal/pipeline_handler.h2
3 files changed, 12 insertions, 6 deletions
diff --git a/include/libcamera/internal/camera_manager.h b/include/libcamera/internal/camera_manager.h
index af9ed60a..e098cb69 100644
--- a/include/libcamera/internal/camera_manager.h
+++ b/include/libcamera/internal/camera_manager.h
@@ -19,13 +19,14 @@
#include <libcamera/base/thread.h>
#include <libcamera/base/thread_annotations.h>
-#include "libcamera/internal/ipa_manager.h"
#include "libcamera/internal/process.h"
namespace libcamera {
class Camera;
class DeviceEnumerator;
+class IPAManager;
+class PipelineHandlerFactoryBase;
class CameraManager::Private : public Extensible::Private, public Thread
{
@@ -38,6 +39,8 @@ public:
void addCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);
void removeCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);
+ IPAManager *ipaManager() const { return ipaManager_.get(); }
+
protected:
void run() override;
@@ -62,7 +65,7 @@ private:
std::unique_ptr<DeviceEnumerator> enumerator_;
- IPAManager ipaManager_;
+ std::unique_ptr<IPAManager> ipaManager_;
ProcessManager processManager_;
};
diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h
index c6f74e11..16dede0c 100644
--- a/include/libcamera/internal/ipa_manager.h
+++ b/include/libcamera/internal/ipa_manager.h
@@ -15,6 +15,7 @@
#include <libcamera/ipa/ipa_interface.h>
#include <libcamera/ipa/ipa_module_info.h>
+#include "libcamera/internal/camera_manager.h"
#include "libcamera/internal/ipa_module.h"
#include "libcamera/internal/pipeline_handler.h"
#include "libcamera/internal/pub_key.h"
@@ -34,11 +35,13 @@ public:
uint32_t minVersion,
uint32_t maxVersion)
{
- IPAModule *m = self_->module(pipe, minVersion, maxVersion);
+ CameraManager *cm = pipe->cameraManager();
+ IPAManager *self = cm->_d()->ipaManager();
+ IPAModule *m = self->module(pipe, minVersion, maxVersion);
if (!m)
return nullptr;
- std::unique_ptr<T> proxy = std::make_unique<T>(m, !self_->isSignatureValid(m));
+ std::unique_ptr<T> proxy = std::make_unique<T>(m, !self->isSignatureValid(m));
if (!proxy->isValid()) {
LOG(IPAManager, Error) << "Failed to load proxy";
return nullptr;
@@ -55,8 +58,6 @@ public:
#endif
private:
- static IPAManager *self_;
-
void parseDir(const char *libDir, unsigned int maxDepth,
std::vector<std::string> &files);
unsigned int addDir(const char *libDir, unsigned int maxDepth = 0);
diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h
index 746a34f8..cad5812f 100644
--- a/include/libcamera/internal/pipeline_handler.h
+++ b/include/libcamera/internal/pipeline_handler.h
@@ -70,6 +70,8 @@ public:
const char *name() const { return name_; }
+ CameraManager *cameraManager() const { return manager_; }
+
protected:
void registerCamera(std::shared_ptr<Camera> camera);
void hotplugMediaDevice(MediaDevice *media);