[{"id":30679,"web_url":"https://patchwork.libcamera.org/comment/30679/","msgid":"<172303659920.1687952.7153297006095869796@ping.linuxembedded.co.uk>","date":"2024-08-07T13:16:39","subject":"Re: [PATCH] libcamera: ipa_manager: Remove singleton requirement","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2024-08-03 22:28:32)\n> The IPAManager class implements a singleton pattern due to the need of\n> accessing the instance in a static member function. The function now\n> takes a pointer to a PipelineHandler, which we can use to access the\n> CameraManager, and from there, the IPAManager.\n> \n> Add accessors to the internal API to expose the CameraManager from the\n> PipelineHandler, and the IPAManager from the CameraManager. This\n> requires allocating the IPAManager dynamically to avoid a loop in\n> includes. Use those accessors to replace the IPAManager singleton.\n> \n> Update the IPA interface unit test to instantiate a CameraManager\n> instead of an IPAManager and ProcessManager, to reflect the new way that\n> the IPAManager is accessed.\n\nI guess that's a bit more heavyweight for a unit test, but nothing out\nof the ordinary given 'CameraManager' is a core component of libcamera.\n\nNo objection to this, and removing seems worthwhile - but I'm curious\nwhat the motivation was.\n\nAnyway, I haven't spotted any errors so:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  include/libcamera/internal/camera_manager.h   |  7 +++++--\n>  include/libcamera/internal/ipa_manager.h      |  9 +++++----\n>  include/libcamera/internal/pipeline_handler.h |  2 ++\n>  src/libcamera/camera_manager.cpp              |  9 +++++++++\n>  src/libcamera/ipa_manager.cpp                 | 10 ----------\n>  src/libcamera/pipeline_handler.cpp            |  7 +++++++\n>  test/ipa/ipa_interface_test.cpp               | 12 +++++-------\n>  7 files changed, 33 insertions(+), 23 deletions(-)\n> \n> diff --git a/include/libcamera/internal/camera_manager.h b/include/libcamera/internal/camera_manager.h\n> index af9ed60a0353..e098cb69aa43 100644\n> --- a/include/libcamera/internal/camera_manager.h\n> +++ b/include/libcamera/internal/camera_manager.h\n> @@ -19,13 +19,14 @@\n>  #include <libcamera/base/thread.h>\n>  #include <libcamera/base/thread_annotations.h>\n>  \n> -#include \"libcamera/internal/ipa_manager.h\"\n>  #include \"libcamera/internal/process.h\"\n>  \n>  namespace libcamera {\n>  \n>  class Camera;\n>  class DeviceEnumerator;\n> +class IPAManager;\n> +class PipelineHandlerFactoryBase;\n>  \n>  class CameraManager::Private : public Extensible::Private, public Thread\n>  {\n> @@ -38,6 +39,8 @@ public:\n>         void addCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);\n>         void removeCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);\n>  \n> +       IPAManager *ipaManager() const { return ipaManager_.get(); }\n> +\n>  protected:\n>         void run() override;\n>  \n> @@ -62,7 +65,7 @@ private:\n>  \n>         std::unique_ptr<DeviceEnumerator> enumerator_;\n>  \n> -       IPAManager ipaManager_;\n> +       std::unique_ptr<IPAManager> ipaManager_;\n>         ProcessManager processManager_;\n>  };\n>  \n> diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h\n> index c6f74e11c434..16dede0c5a7e 100644\n> --- a/include/libcamera/internal/ipa_manager.h\n> +++ b/include/libcamera/internal/ipa_manager.h\n> @@ -15,6 +15,7 @@\n>  #include <libcamera/ipa/ipa_interface.h>\n>  #include <libcamera/ipa/ipa_module_info.h>\n>  \n> +#include \"libcamera/internal/camera_manager.h\"\n>  #include \"libcamera/internal/ipa_module.h\"\n>  #include \"libcamera/internal/pipeline_handler.h\"\n>  #include \"libcamera/internal/pub_key.h\"\n> @@ -34,11 +35,13 @@ public:\n>                                             uint32_t minVersion,\n>                                             uint32_t maxVersion)\n>         {\n> -               IPAModule *m = self_->module(pipe, minVersion, maxVersion);\n> +               CameraManager *cm = pipe->cameraManager();\n> +               IPAManager *self = cm->_d()->ipaManager();\n> +               IPAModule *m = self->module(pipe, minVersion, maxVersion);\n>                 if (!m)\n>                         return nullptr;\n>  \n> -               std::unique_ptr<T> proxy = std::make_unique<T>(m, !self_->isSignatureValid(m));\n> +               std::unique_ptr<T> proxy = std::make_unique<T>(m, !self->isSignatureValid(m));\n>                 if (!proxy->isValid()) {\n>                         LOG(IPAManager, Error) << \"Failed to load proxy\";\n>                         return nullptr;\n> @@ -55,8 +58,6 @@ public:\n>  #endif\n>  \n>  private:\n> -       static IPAManager *self_;\n> -\n>         void parseDir(const char *libDir, unsigned int maxDepth,\n>                       std::vector<std::string> &files);\n>         unsigned int addDir(const char *libDir, unsigned int maxDepth = 0);\n> diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> index 746a34f8e7bd..cad5812f640c 100644\n> --- a/include/libcamera/internal/pipeline_handler.h\n> +++ b/include/libcamera/internal/pipeline_handler.h\n> @@ -70,6 +70,8 @@ public:\n>  \n>         const char *name() const { return name_; }\n>  \n> +       CameraManager *cameraManager() const { return manager_; }\n> +\n>  protected:\n>         void registerCamera(std::shared_ptr<Camera> camera);\n>         void hotplugMediaDevice(MediaDevice *media);\n> diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\n> index 95a9e3264526..31760a8680cc 100644\n> --- a/src/libcamera/camera_manager.cpp\n> +++ b/src/libcamera/camera_manager.cpp\n> @@ -15,6 +15,7 @@\n>  \n>  #include \"libcamera/internal/camera.h\"\n>  #include \"libcamera/internal/device_enumerator.h\"\n> +#include \"libcamera/internal/ipa_manager.h\"\n>  #include \"libcamera/internal/pipeline_handler.h\"\n>  \n>  /**\n> @@ -37,6 +38,7 @@ LOG_DEFINE_CATEGORY(Camera)\n>  CameraManager::Private::Private()\n>         : initialized_(false)\n>  {\n> +       ipaManager_ = std::make_unique<IPAManager>();\n>  }\n>  \n>  int CameraManager::Private::start()\n> @@ -249,6 +251,13 @@ void CameraManager::Private::removeCamera(std::shared_ptr<Camera> camera)\n>         o->cameraRemoved.emit(camera);\n>  }\n>  \n> +/**\n> + * \\fn CameraManager::Private::ipaManager() const\n> + * \\brief Retrieve the IPAManager\n> + * \\context This function is \\threadsafe.\n> + * \\return The IPAManager for this CameraManager\n> + */\n> +\n>  /**\n>   * \\class CameraManager\n>   * \\brief Provide access and manage all cameras in the system\n> diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp\n> index f4e0b6339f08..cfc24d389c4f 100644\n> --- a/src/libcamera/ipa_manager.cpp\n> +++ b/src/libcamera/ipa_manager.cpp\n> @@ -95,8 +95,6 @@ LOG_DEFINE_CATEGORY(IPAManager)\n>   * IPC.\n>   */\n>  \n> -IPAManager *IPAManager::self_ = nullptr;\n> -\n>  /**\n>   * \\brief Construct an IPAManager instance\n>   *\n> @@ -105,10 +103,6 @@ IPAManager *IPAManager::self_ = nullptr;\n>   */\n>  IPAManager::IPAManager()\n>  {\n> -       if (self_)\n> -               LOG(IPAManager, Fatal)\n> -                       << \"Multiple IPAManager objects are not allowed\";\n> -\n>  #if HAVE_IPA_PUBKEY\n>         if (!pubKey_.isValid())\n>                 LOG(IPAManager, Warning) << \"Public key not valid\";\n> @@ -153,16 +147,12 @@ IPAManager::IPAManager()\n>         if (!ipaCount)\n>                 LOG(IPAManager, Warning)\n>                         << \"No IPA found in '\" IPA_MODULE_DIR \"'\";\n> -\n> -       self_ = this;\n>  }\n>  \n>  IPAManager::~IPAManager()\n>  {\n>         for (IPAModule *module : modules_)\n>                 delete module;\n> -\n> -       self_ = nullptr;\n>  }\n>  \n>  /**\n> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> index 5ea2ca780b63..5a6de685b292 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -719,6 +719,13 @@ void PipelineHandler::disconnect()\n>   * \\return The pipeline handler name\n>   */\n>  \n> +/**\n> + * \\fn PipelineHandler::cameraManager() const\n> + * \\brief Retrieve the CameraManager that this pipeline handler belongs to\n> + * \\context This function is \\threadsafe.\n> + * \\return The CameraManager for this pipeline handler\n> + */\n> +\n>  /**\n>   * \\class PipelineHandlerFactoryBase\n>   * \\brief Base class for pipeline handler factories\n> diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp\n> index e840f6ab17c4..b81783664977 100644\n> --- a/test/ipa/ipa_interface_test.cpp\n> +++ b/test/ipa/ipa_interface_test.cpp\n> @@ -20,11 +20,11 @@\n>  #include <libcamera/base/thread.h>\n>  #include <libcamera/base/timer.h>\n>  \n> +#include \"libcamera/internal/camera_manager.h\"\n>  #include \"libcamera/internal/device_enumerator.h\"\n>  #include \"libcamera/internal/ipa_manager.h\"\n>  #include \"libcamera/internal/ipa_module.h\"\n>  #include \"libcamera/internal/pipeline_handler.h\"\n> -#include \"libcamera/internal/process.h\"\n>  \n>  #include \"test.h\"\n>  \n> @@ -44,20 +44,20 @@ public:\n>         {\n>                 delete notifier_;\n>                 ipa_.reset();\n> -               ipaManager_.reset();\n> +               cameraManager_.reset();\n>         }\n>  \n>  protected:\n>         int init() override\n>         {\n> -               ipaManager_ = make_unique<IPAManager>();\n> +               cameraManager_ = make_unique<CameraManager>();\n>  \n>                 /* Create a pipeline handler for vimc. */\n>                 const std::vector<PipelineHandlerFactoryBase *> &factories =\n>                         PipelineHandlerFactoryBase::factories();\n>                 for (const PipelineHandlerFactoryBase *factory : factories) {\n>                         if (factory->name() == \"vimc\") {\n> -                               pipe_ = factory->create(nullptr);\n> +                               pipe_ = factory->create(cameraManager_.get());\n>                                 break;\n>                         }\n>                 }\n> @@ -171,11 +171,9 @@ private:\n>                 }\n>         }\n>  \n> -       ProcessManager processManager_;\n> -\n>         std::shared_ptr<PipelineHandler> pipe_;\n>         std::unique_ptr<ipa::vimc::IPAProxyVimc> ipa_;\n> -       std::unique_ptr<IPAManager> ipaManager_;\n> +       std::unique_ptr<CameraManager> cameraManager_;\n>         enum ipa::vimc::IPAOperationCode trace_;\n>         EventNotifier *notifier_;\n>         int fd_;\n> \n> base-commit: 19bbca3c0b376ba0183f5db53472c8c46cd402b5\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0DBF1BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Aug 2024 13:16:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B8E7163393;\n\tWed,  7 Aug 2024 15:16:43 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C2106337E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Aug 2024 15:16:42 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 871936AF;\n\tWed,  7 Aug 2024 15:15:49 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"hTBRDEBQ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1723036549;\n\tbh=ID8hNS2m6CZPx1bsfozSjoTmlAb+3JRMRfRr7L8PTXg=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=hTBRDEBQxOzqIQRccIqgeuEyvYUdOAl5fsyqkkX32KV6ZT91zkprx468SWKDIaein\n\tozPMgrxASfXwtRYEHQbds8tKAYL/gLDyKgdV7up18EctjVzjI1CusXyYLm3fCnGWSW\n\t4XPxLCFF4V5gAOi6JQXu6EUMgoVw6piTfKKZfqws=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240803212832.22766-1-laurent.pinchart@ideasonboard.com>","References":"<20240803212832.22766-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH] libcamera: ipa_manager: Remove singleton requirement","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 07 Aug 2024 14:16:39 +0100","Message-ID":"<172303659920.1687952.7153297006095869796@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":30680,"web_url":"https://patchwork.libcamera.org/comment/30680/","msgid":"<20240807132847.GA8071@pendragon.ideasonboard.com>","date":"2024-08-07T13:28:47","subject":"Re: [PATCH] libcamera: ipa_manager: Remove singleton requirement","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Aug 07, 2024 at 02:16:39PM +0100, Kieran Bingham wrote:\n> Quoting Laurent Pinchart (2024-08-03 22:28:32)\n> > The IPAManager class implements a singleton pattern due to the need of\n> > accessing the instance in a static member function. The function now\n> > takes a pointer to a PipelineHandler, which we can use to access the\n> > CameraManager, and from there, the IPAManager.\n> > \n> > Add accessors to the internal API to expose the CameraManager from the\n> > PipelineHandler, and the IPAManager from the CameraManager. This\n> > requires allocating the IPAManager dynamically to avoid a loop in\n> > includes. Use those accessors to replace the IPAManager singleton.\n> > \n> > Update the IPA interface unit test to instantiate a CameraManager\n> > instead of an IPAManager and ProcessManager, to reflect the new way that\n> > the IPAManager is accessed.\n> \n> I guess that's a bit more heavyweight for a unit test, but nothing out\n> of the ordinary given 'CameraManager' is a core component of libcamera.\n> \n> No objection to this, and removing seems worthwhile - but I'm curious\n> what the motivation was.\n\nI was trying to remove all singletons. Some are more difficult, so this\nis still work in progress.\n\n> Anyway, I haven't spotted any errors so:\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  include/libcamera/internal/camera_manager.h   |  7 +++++--\n> >  include/libcamera/internal/ipa_manager.h      |  9 +++++----\n> >  include/libcamera/internal/pipeline_handler.h |  2 ++\n> >  src/libcamera/camera_manager.cpp              |  9 +++++++++\n> >  src/libcamera/ipa_manager.cpp                 | 10 ----------\n> >  src/libcamera/pipeline_handler.cpp            |  7 +++++++\n> >  test/ipa/ipa_interface_test.cpp               | 12 +++++-------\n> >  7 files changed, 33 insertions(+), 23 deletions(-)\n> > \n> > diff --git a/include/libcamera/internal/camera_manager.h b/include/libcamera/internal/camera_manager.h\n> > index af9ed60a0353..e098cb69aa43 100644\n> > --- a/include/libcamera/internal/camera_manager.h\n> > +++ b/include/libcamera/internal/camera_manager.h\n> > @@ -19,13 +19,14 @@\n> >  #include <libcamera/base/thread.h>\n> >  #include <libcamera/base/thread_annotations.h>\n> >  \n> > -#include \"libcamera/internal/ipa_manager.h\"\n> >  #include \"libcamera/internal/process.h\"\n> >  \n> >  namespace libcamera {\n> >  \n> >  class Camera;\n> >  class DeviceEnumerator;\n> > +class IPAManager;\n> > +class PipelineHandlerFactoryBase;\n> >  \n> >  class CameraManager::Private : public Extensible::Private, public Thread\n> >  {\n> > @@ -38,6 +39,8 @@ public:\n> >         void addCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);\n> >         void removeCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);\n> >  \n> > +       IPAManager *ipaManager() const { return ipaManager_.get(); }\n> > +\n> >  protected:\n> >         void run() override;\n> >  \n> > @@ -62,7 +65,7 @@ private:\n> >  \n> >         std::unique_ptr<DeviceEnumerator> enumerator_;\n> >  \n> > -       IPAManager ipaManager_;\n> > +       std::unique_ptr<IPAManager> ipaManager_;\n> >         ProcessManager processManager_;\n> >  };\n> >  \n> > diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h\n> > index c6f74e11c434..16dede0c5a7e 100644\n> > --- a/include/libcamera/internal/ipa_manager.h\n> > +++ b/include/libcamera/internal/ipa_manager.h\n> > @@ -15,6 +15,7 @@\n> >  #include <libcamera/ipa/ipa_interface.h>\n> >  #include <libcamera/ipa/ipa_module_info.h>\n> >  \n> > +#include \"libcamera/internal/camera_manager.h\"\n> >  #include \"libcamera/internal/ipa_module.h\"\n> >  #include \"libcamera/internal/pipeline_handler.h\"\n> >  #include \"libcamera/internal/pub_key.h\"\n> > @@ -34,11 +35,13 @@ public:\n> >                                             uint32_t minVersion,\n> >                                             uint32_t maxVersion)\n> >         {\n> > -               IPAModule *m = self_->module(pipe, minVersion, maxVersion);\n> > +               CameraManager *cm = pipe->cameraManager();\n> > +               IPAManager *self = cm->_d()->ipaManager();\n> > +               IPAModule *m = self->module(pipe, minVersion, maxVersion);\n> >                 if (!m)\n> >                         return nullptr;\n> >  \n> > -               std::unique_ptr<T> proxy = std::make_unique<T>(m, !self_->isSignatureValid(m));\n> > +               std::unique_ptr<T> proxy = std::make_unique<T>(m, !self->isSignatureValid(m));\n> >                 if (!proxy->isValid()) {\n> >                         LOG(IPAManager, Error) << \"Failed to load proxy\";\n> >                         return nullptr;\n> > @@ -55,8 +58,6 @@ public:\n> >  #endif\n> >  \n> >  private:\n> > -       static IPAManager *self_;\n> > -\n> >         void parseDir(const char *libDir, unsigned int maxDepth,\n> >                       std::vector<std::string> &files);\n> >         unsigned int addDir(const char *libDir, unsigned int maxDepth = 0);\n> > diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> > index 746a34f8e7bd..cad5812f640c 100644\n> > --- a/include/libcamera/internal/pipeline_handler.h\n> > +++ b/include/libcamera/internal/pipeline_handler.h\n> > @@ -70,6 +70,8 @@ public:\n> >  \n> >         const char *name() const { return name_; }\n> >  \n> > +       CameraManager *cameraManager() const { return manager_; }\n> > +\n> >  protected:\n> >         void registerCamera(std::shared_ptr<Camera> camera);\n> >         void hotplugMediaDevice(MediaDevice *media);\n> > diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\n> > index 95a9e3264526..31760a8680cc 100644\n> > --- a/src/libcamera/camera_manager.cpp\n> > +++ b/src/libcamera/camera_manager.cpp\n> > @@ -15,6 +15,7 @@\n> >  \n> >  #include \"libcamera/internal/camera.h\"\n> >  #include \"libcamera/internal/device_enumerator.h\"\n> > +#include \"libcamera/internal/ipa_manager.h\"\n> >  #include \"libcamera/internal/pipeline_handler.h\"\n> >  \n> >  /**\n> > @@ -37,6 +38,7 @@ LOG_DEFINE_CATEGORY(Camera)\n> >  CameraManager::Private::Private()\n> >         : initialized_(false)\n> >  {\n> > +       ipaManager_ = std::make_unique<IPAManager>();\n> >  }\n> >  \n> >  int CameraManager::Private::start()\n> > @@ -249,6 +251,13 @@ void CameraManager::Private::removeCamera(std::shared_ptr<Camera> camera)\n> >         o->cameraRemoved.emit(camera);\n> >  }\n> >  \n> > +/**\n> > + * \\fn CameraManager::Private::ipaManager() const\n> > + * \\brief Retrieve the IPAManager\n> > + * \\context This function is \\threadsafe.\n> > + * \\return The IPAManager for this CameraManager\n> > + */\n> > +\n> >  /**\n> >   * \\class CameraManager\n> >   * \\brief Provide access and manage all cameras in the system\n> > diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp\n> > index f4e0b6339f08..cfc24d389c4f 100644\n> > --- a/src/libcamera/ipa_manager.cpp\n> > +++ b/src/libcamera/ipa_manager.cpp\n> > @@ -95,8 +95,6 @@ LOG_DEFINE_CATEGORY(IPAManager)\n> >   * IPC.\n> >   */\n> >  \n> > -IPAManager *IPAManager::self_ = nullptr;\n> > -\n> >  /**\n> >   * \\brief Construct an IPAManager instance\n> >   *\n> > @@ -105,10 +103,6 @@ IPAManager *IPAManager::self_ = nullptr;\n> >   */\n> >  IPAManager::IPAManager()\n> >  {\n> > -       if (self_)\n> > -               LOG(IPAManager, Fatal)\n> > -                       << \"Multiple IPAManager objects are not allowed\";\n> > -\n> >  #if HAVE_IPA_PUBKEY\n> >         if (!pubKey_.isValid())\n> >                 LOG(IPAManager, Warning) << \"Public key not valid\";\n> > @@ -153,16 +147,12 @@ IPAManager::IPAManager()\n> >         if (!ipaCount)\n> >                 LOG(IPAManager, Warning)\n> >                         << \"No IPA found in '\" IPA_MODULE_DIR \"'\";\n> > -\n> > -       self_ = this;\n> >  }\n> >  \n> >  IPAManager::~IPAManager()\n> >  {\n> >         for (IPAModule *module : modules_)\n> >                 delete module;\n> > -\n> > -       self_ = nullptr;\n> >  }\n> >  \n> >  /**\n> > diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> > index 5ea2ca780b63..5a6de685b292 100644\n> > --- a/src/libcamera/pipeline_handler.cpp\n> > +++ b/src/libcamera/pipeline_handler.cpp\n> > @@ -719,6 +719,13 @@ void PipelineHandler::disconnect()\n> >   * \\return The pipeline handler name\n> >   */\n> >  \n> > +/**\n> > + * \\fn PipelineHandler::cameraManager() const\n> > + * \\brief Retrieve the CameraManager that this pipeline handler belongs to\n> > + * \\context This function is \\threadsafe.\n> > + * \\return The CameraManager for this pipeline handler\n> > + */\n> > +\n> >  /**\n> >   * \\class PipelineHandlerFactoryBase\n> >   * \\brief Base class for pipeline handler factories\n> > diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp\n> > index e840f6ab17c4..b81783664977 100644\n> > --- a/test/ipa/ipa_interface_test.cpp\n> > +++ b/test/ipa/ipa_interface_test.cpp\n> > @@ -20,11 +20,11 @@\n> >  #include <libcamera/base/thread.h>\n> >  #include <libcamera/base/timer.h>\n> >  \n> > +#include \"libcamera/internal/camera_manager.h\"\n> >  #include \"libcamera/internal/device_enumerator.h\"\n> >  #include \"libcamera/internal/ipa_manager.h\"\n> >  #include \"libcamera/internal/ipa_module.h\"\n> >  #include \"libcamera/internal/pipeline_handler.h\"\n> > -#include \"libcamera/internal/process.h\"\n> >  \n> >  #include \"test.h\"\n> >  \n> > @@ -44,20 +44,20 @@ public:\n> >         {\n> >                 delete notifier_;\n> >                 ipa_.reset();\n> > -               ipaManager_.reset();\n> > +               cameraManager_.reset();\n> >         }\n> >  \n> >  protected:\n> >         int init() override\n> >         {\n> > -               ipaManager_ = make_unique<IPAManager>();\n> > +               cameraManager_ = make_unique<CameraManager>();\n> >  \n> >                 /* Create a pipeline handler for vimc. */\n> >                 const std::vector<PipelineHandlerFactoryBase *> &factories =\n> >                         PipelineHandlerFactoryBase::factories();\n> >                 for (const PipelineHandlerFactoryBase *factory : factories) {\n> >                         if (factory->name() == \"vimc\") {\n> > -                               pipe_ = factory->create(nullptr);\n> > +                               pipe_ = factory->create(cameraManager_.get());\n> >                                 break;\n> >                         }\n> >                 }\n> > @@ -171,11 +171,9 @@ private:\n> >                 }\n> >         }\n> >  \n> > -       ProcessManager processManager_;\n> > -\n> >         std::shared_ptr<PipelineHandler> pipe_;\n> >         std::unique_ptr<ipa::vimc::IPAProxyVimc> ipa_;\n> > -       std::unique_ptr<IPAManager> ipaManager_;\n> > +       std::unique_ptr<CameraManager> cameraManager_;\n> >         enum ipa::vimc::IPAOperationCode trace_;\n> >         EventNotifier *notifier_;\n> >         int fd_;\n> > \n> > base-commit: 19bbca3c0b376ba0183f5db53472c8c46cd402b5","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 4C878C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Aug 2024 13:29:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3B93963393;\n\tWed,  7 Aug 2024 15:29:12 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8834F6337F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Aug 2024 15:29:10 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 693B76AF;\n\tWed,  7 Aug 2024 15:28:17 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"nSwmxi3f\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1723037297;\n\tbh=iVba9Agy/XetElITYdXBjm8+No9Vkc4wxotOutw4qQE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=nSwmxi3fYVuEdekkjKFtde4Vtnlqtz7IrTl/B0Mmi/hlVfclzOPsbzG/H4Xu94aF7\n\tYtc+KSlGFFsn2fbuhcN6Q3yqGBgJZBHqfDW9h8OaCo66g4yG6wwcUX+jUr2ZxdjlVS\n\twvQNqr/EBp9/6v4W/qlGjEJeeP01SgTQMeMjIW9I=","Date":"Wed, 7 Aug 2024 16:28:47 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] libcamera: ipa_manager: Remove singleton requirement","Message-ID":"<20240807132847.GA8071@pendragon.ideasonboard.com>","References":"<20240803212832.22766-1-laurent.pinchart@ideasonboard.com>\n\t<172303659920.1687952.7153297006095869796@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<172303659920.1687952.7153297006095869796@ping.linuxembedded.co.uk>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]