From patchwork Mon May 27 22:35:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 1320 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D25A60E47 for ; Tue, 28 May 2019 00:35:49 +0200 (CEST) Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 596F5D85; Tue, 28 May 2019 00:35:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1558996548; bh=u6oPlq3xg+eYiuGUReIHLLWPjGZ0xy7YeOBDiBWA/l0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LX/34vf+BWiIjfEZzCx+Yul9JNBvVLRytEEZsqikLI4g+HP/R6EDZziXYDuw5Q1sL THf9vBcadScF/MK2XcnKDuOVZO+5qIeOQ8kwnxqWBUlqaB5++a2/X0S9gh5nqCxcHu ZzPULcUlcLohK5pQG53NPIfbGykwT7QXLGN43a5k= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Mon, 27 May 2019 18:35:34 -0400 Message-Id: <20190527223540.21855-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190527223540.21855-1-paul.elder@ideasonboard.com> References: <20190527223540.21855-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/8] libcamera: pipeline: add name, major version, and minor version 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: Mon, 27 May 2019 22:35:49 -0000 In order to match an IPA module with a pipeline handler, the pipeline handler must have a name and a major and minor version. Add these to PipelineHandler as functions, so that they can be automatically defined by REGISTER_PIPELINE_HANDLER. Also update documentation accordingly. Signed-off-by: Paul Elder --- src/libcamera/include/pipeline_handler.h | 20 ++++++++++++++++++-- src/libcamera/pipeline/ipu3/ipu3.cpp | 6 +++++- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 6 +++++- src/libcamera/pipeline/uvcvideo.cpp | 6 +++++- src/libcamera/pipeline/vimc.cpp | 6 +++++- src/libcamera/pipeline_handler.cpp | 20 ++++++++++++++++++++ 6 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index 7da6df1..7963e7a 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -77,6 +77,10 @@ public: bool completeBuffer(Camera *camera, Request *request, Buffer *buffer); void completeRequest(Camera *camera, Request *request); + virtual const char *name() = 0; + virtual int majorVersion() = 0; + virtual int minorVersion() = 0; + protected: void registerCamera(std::shared_ptr camera, std::unique_ptr data); @@ -112,7 +116,7 @@ private: std::string name_; }; -#define REGISTER_PIPELINE_HANDLER(handler) \ +#define REGISTER_PIPELINE_HANDLER(handler, majorV, minorV) \ class handler##Factory final : public PipelineHandlerFactory \ { \ public: \ @@ -122,7 +126,19 @@ public: \ return std::make_shared(manager); \ } \ }; \ -static handler##Factory global_##handler##Factory; +static handler##Factory global_##handler##Factory; \ +const char *handler::name() \ +{ \ + return #handler; \ +} \ +int handler::majorVersion() \ +{ \ + return majorV; \ +} \ +int handler::minorVersion() \ +{ \ + return minorV; \ +} } /* namespace libcamera */ diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 05005c4..a1b06fe 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -212,6 +212,10 @@ public: bool match(DeviceEnumerator *enumerator) override; + const char *name() override; + int majorVersion() override; + int minorVersion() override; + private: IPU3CameraData *cameraData(const Camera *camera) { @@ -1452,6 +1456,6 @@ int CIO2Device::mediaBusToFormat(unsigned int code) } } -REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3); +REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3, 0, 1); } /* namespace libcamera */ diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 9b3eea2..7042e7f 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -92,6 +92,10 @@ public: bool match(DeviceEnumerator *enumerator) override; + const char *name() override; + int majorVersion() override; + int minorVersion() override; + private: RkISP1CameraData *cameraData(const Camera *camera) { @@ -499,6 +503,6 @@ void PipelineHandlerRkISP1::bufferReady(Buffer *buffer) completeRequest(activeCamera_, request); } -REGISTER_PIPELINE_HANDLER(PipelineHandlerRkISP1); +REGISTER_PIPELINE_HANDLER(PipelineHandlerRkISP1, 0, 1); } /* namespace libcamera */ diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 45260f3..27c731e 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -68,6 +68,10 @@ public: bool match(DeviceEnumerator *enumerator) override; + const char *name() override; + int majorVersion() override; + int minorVersion() override; + private: UVCCameraData *cameraData(const Camera *camera) { @@ -263,6 +267,6 @@ void UVCCameraData::bufferReady(Buffer *buffer) pipe_->completeRequest(camera_, request); } -REGISTER_PIPELINE_HANDLER(PipelineHandlerUVC); +REGISTER_PIPELINE_HANDLER(PipelineHandlerUVC, 0, 1); } /* namespace libcamera */ diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 0e4eede..d3ff527 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -71,6 +71,10 @@ public: bool match(DeviceEnumerator *enumerator) override; + const char *name() override; + int majorVersion() override; + int minorVersion() override; + private: VimcCameraData *cameraData(const Camera *camera) { @@ -274,6 +278,6 @@ void VimcCameraData::bufferReady(Buffer *buffer) pipe_->completeRequest(camera_, request); } -REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc); +REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc, 0, 1); } /* namespace libcamera */ diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index dd56907..8f83307 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -505,6 +505,24 @@ 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 + */ + +/** + * \fn PipelineHandler::majorVersion() + * \brief Retrieve the pipeline handler major version + * \return The pipeline handler major version + */ + +/** + * \fn PipelineHandler::minorVersion() + * \brief Retrieve the pipeline handler minor version + * \return The pipeline handler minor version + */ + /** * \class PipelineHandlerFactory * \brief Registration of PipelineHandler classes and creation of instances @@ -586,6 +604,8 @@ std::vector &PipelineHandlerFactory::factories() * \def REGISTER_PIPELINE_HANDLER * \brief Register a pipeline handler with the pipeline handler factory * \param[in] handler Class name of PipelineHandler derived class to register + * \param[in] majorV Major version of the PipelineHandler + * \param[in] minorV Minor version of the PipelineHandler * * Register a PipelineHandler subclass with the factory and make it available to * try and match devices.