From patchwork Wed Jun 5 00:53:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1350 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DF4D964715 for ; Wed, 5 Jun 2019 02:53:28 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3A4012D1; Wed, 5 Jun 2019 02:53:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559696008; bh=mkRO0aFvSt525vcU6vZxJM/oAHUmGZr2juS9gswQcck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OxyipHXunKP+98SFhuyARWtEfhUNmyil6ZjbpSqQt9h5TY97gqG6pa3v+cWdtoqjs aryd3BOS4E7fSRiXdT1aXTH66bddL23LG4NW32Bdo8xohDob1k9cE5GlS1lc+MZFZF IC6QveVkUBFYTc+qbPUW9KUcg9UiTpmgZoBgE5e8= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 4 Jun 2019 20:53:08 -0400 Message-Id: <20190605005316.4835-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605005316.4835-1-paul.elder@ideasonboard.com> References: <20190605005316.4835-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 02/10] libcamera: pipeline: add name X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 00:53:29 -0000 In order to match an IPA module with a pipeline handler, the pipeline handler must have a name. Add a name attribute and getter to PipelineHandler such that it can automatically be defined by REGISTER_PIPELINE_HANDLER. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v3: - remove version completely from the pipeline hander's side, as the pipeline handler will now specify its acceptable version range when it asks the IPAManager for an IPAInterface (so IPAModules still need a pipeline version) - nicer, less intrusive way of setting the pipeline names by making the pipeline handler factory a friend class of pipeline handler Changes in v2: - make the name and version getters into methods of the base PipelineHandler class, so that the specialized pipeline handlers no longer have to specify overriding - add PIPELINE_VERSION macro to create one version number from major and minor pair src/libcamera/include/pipeline_handler.h | 14 +++++++++++++- src/libcamera/pipeline_handler.cpp | 17 +++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index 7da6df1..84307e4 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -77,6 +77,8 @@ public: bool completeBuffer(Camera *camera, Request *request, Buffer *buffer); void completeRequest(Camera *camera, Request *request); + const char *name() const { return name_; } + protected: void registerCamera(std::shared_ptr camera, std::unique_ptr data); @@ -93,6 +95,10 @@ private: std::vector> mediaDevices_; std::vector> cameras_; std::map> cameraData_; + + const char *name_; + + friend class PipelineHandlerFactory; }; class PipelineHandlerFactory @@ -108,6 +114,9 @@ public: static void registerType(PipelineHandlerFactory *factory); static std::vector &factories(); +protected: + void setInfo(PipelineHandler *handler, const char *name); + private: std::string name_; }; @@ -119,7 +128,10 @@ public: \ handler##Factory() : PipelineHandlerFactory(#handler) {} \ std::shared_ptr create(CameraManager *manager) \ { \ - return std::make_shared(manager); \ + std::shared_ptr h = \ + std::make_shared(manager); \ + setInfo(h.get(), #handler); \ + return h; \ } \ }; \ static handler##Factory global_##handler##Factory; diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index dd56907..800931d 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -505,6 +505,12 @@ CameraData *PipelineHandler::cameraData(const Camera *camera) * constant for the whole lifetime of the pipeline handler. */ +/** + * \fn PipelineHandler::name() + * \brief Retrieve the pipeline handler name + * \return The pipeline handler name + */ + /** * \class PipelineHandlerFactory * \brief Registration of PipelineHandler classes and creation of instances @@ -582,6 +588,17 @@ std::vector &PipelineHandlerFactory::factories() return factories; } +/** + * \brief Set the information of a given pipeline handler + * \param[in] handler The handler whose info is to be set + * \param[in] name The name of the pipeline handler + */ +void PipelineHandlerFactory::setInfo(PipelineHandler *handler, + const char *name) +{ + handler->name_ = name; +} + /** * \def REGISTER_PIPELINE_HANDLER * \brief Register a pipeline handler with the pipeline handler factory