From 1045522af99c9f26e0f583aa2310174f7ff42178 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 30 Sep 2023 16:08:56 +0300 Subject: 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 Reviewed-by: Kieran Bingham --- test/ipa/ipa_interface_test.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp index e840f6ab..b8178366 100644 --- a/test/ipa/ipa_interface_test.cpp +++ b/test/ipa/ipa_interface_test.cpp @@ -20,11 +20,11 @@ #include #include +#include "libcamera/internal/camera_manager.h" #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/ipa_manager.h" #include "libcamera/internal/ipa_module.h" #include "libcamera/internal/pipeline_handler.h" -#include "libcamera/internal/process.h" #include "test.h" @@ -44,20 +44,20 @@ public: { delete notifier_; ipa_.reset(); - ipaManager_.reset(); + cameraManager_.reset(); } protected: int init() override { - ipaManager_ = make_unique(); + cameraManager_ = make_unique(); /* Create a pipeline handler for vimc. */ const std::vector &factories = PipelineHandlerFactoryBase::factories(); for (const PipelineHandlerFactoryBase *factory : factories) { if (factory->name() == "vimc") { - pipe_ = factory->create(nullptr); + pipe_ = factory->create(cameraManager_.get()); break; } } @@ -171,11 +171,9 @@ private: } } - ProcessManager processManager_; - std::shared_ptr pipe_; std::unique_ptr ipa_; - std::unique_ptr ipaManager_; + std::unique_ptr cameraManager_; enum ipa::vimc::IPAOperationCode trace_; EventNotifier *notifier_; int fd_; -- cgit v1.2.1