From patchwork Tue Jan 22 23:45:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 339 Return-Path: Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9466C60C98 for ; Wed, 23 Jan 2019 00:46:42 +0100 (CET) X-Halon-ID: eb2ce716-1e9f-11e9-911a-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id eb2ce716-1e9f-11e9-911a-0050569116f7; Wed, 23 Jan 2019 00:46:20 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 23 Jan 2019 00:45:02 +0100 Message-Id: <20190122234505.32634-6-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190122234505.32634-1-niklas.soderlund@ragnatech.se> References: <20190122234505.32634-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/8] libcamera: pipelines: add method to configure streams 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: Tue, 22 Jan 2019 23:46:42 -0000 All the streams which are to be used needs to be configured at the same time, that is passed from the application to the pipeline handler in a single call. This would allow the pipeline handler to take any dependences between the different streams and there configuration into account when setting up the hardware. This implementation do not interact with any hardware, instead it extends all pipeline handlers with the argument validation needed to make sure the configuration request is sound. It then proceeds to print the requested frame dimensions to the log. Future work based on more components are needed to make the pipeline specific implementations truly useful. Signed-off-by: Niklas Söderlund --- src/libcamera/include/pipeline_handler.h | 3 +++ src/libcamera/pipeline/ipu3/ipu3.cpp | 24 ++++++++++++++++++++++++ src/libcamera/pipeline/uvcvideo.cpp | 24 ++++++++++++++++++++++++ src/libcamera/pipeline/vimc.cpp | 24 ++++++++++++++++++++++++ src/libcamera/pipeline_handler.cpp | 18 ++++++++++++++++++ 5 files changed, 93 insertions(+) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index d4473bf173b815af..751eb4e1bb4bf69b 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -18,6 +18,7 @@ namespace libcamera { class CameraManager; class DeviceEnumerator; class Stream; +class StreamConfiguration; class PipelineHandler { @@ -26,6 +27,8 @@ public: virtual std::vector streams(const Camera *camera) const = 0; + virtual int configure(const Camera *camera, std::vector &config) = 0; + virtual bool match(CameraManager *manager, DeviceEnumerator *enumerator) = 0; }; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index f73479125ed5e21d..5252fab226a1da71 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -29,6 +29,8 @@ public: std::vector streams(const Camera *camera) const; + int configure(const Camera *camera, std::vector &config); + bool match(CameraManager *manager, DeviceEnumerator *enumerator); private: @@ -74,6 +76,28 @@ std::vector PipelineHandlerIPU3::streams(const Camera *camera) const return streams; } +int PipelineHandlerIPU3::configure(const Camera *camera, + std::vector &config) +{ + StreamConfiguration *cfg; + + if (!handleCamera(camera)) + return -EINVAL; + + if (config.size() != 1) + return -EINVAL; + + cfg = config.front(); + + if (!cfg || cfg->id() != 0) + return -EINVAL; + + LOG(IPU3, Info) << "TODO: Configure the camera for resolution " << + cfg->width() << "x" << cfg->height(); + + return 0; +} + bool PipelineHandlerIPU3::match(CameraManager *manager, DeviceEnumerator *enumerator) { DeviceMatch cio2_dm("ipu3-cio2"); diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 87b556ba0ae17696..dd494d2599bef813 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -26,6 +26,8 @@ public: std::vector streams(const Camera *camera) const; + int configure(const Camera *camera, std::vector &config); + bool match(CameraManager *manager, DeviceEnumerator *enumerator); private: @@ -59,6 +61,28 @@ std::vector PipelineHandlerUVC::streams(const Camera *camera) const return streams; } +int PipelineHandlerUVC::configure(const Camera *camera, + std::vector &config) +{ + StreamConfiguration *cfg; + + if (!camera || camera != camera_.get()) + return -EINVAL; + + if (config.size() != 1) + return -EINVAL; + + cfg = config.front(); + + if (!cfg || cfg->id() != 0) + return -EINVAL; + + LOG(UVC, Info) << "TODO: Configure the camera for resolution " << + cfg->width() << "x" << cfg->height(); + + return 0; +} + bool PipelineHandlerUVC::match(CameraManager *manager, DeviceEnumerator *enumerator) { DeviceMatch dm("uvcvideo"); diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index e894367ba6706aaf..31b08a766cb32702 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -26,6 +26,8 @@ public: std::vector streams(const Camera *camera) const; + int configure(const Camera *camera, std::vector &config); + bool match(CameraManager *manager, DeviceEnumerator *enumerator); private: @@ -59,6 +61,28 @@ std::vector PipeHandlerVimc::streams(const Camera *camera) const return streams; } +int PipeHandlerVimc::configure(const Camera *camera, + std::vector &config) +{ + StreamConfiguration *cfg; + + if (!camera || camera != camera_.get()) + return -EINVAL; + + if (config.size() != 1) + return -EINVAL; + + cfg = config.front(); + + if (!cfg || cfg->id() != 0) + return -EINVAL; + + LOG(VIMC, Info) << "TODO: Configure the camera for resolution " << + cfg->width() << "x" << cfg->height(); + + return 0; +} + bool PipeHandlerVimc::match(CameraManager *manager, DeviceEnumerator *enumerator) { DeviceMatch dm("vimc"); diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index c2bed924dece0ac0..533ee64d6ce318c4 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -46,6 +46,24 @@ LOG_DEFINE_CATEGORY(Pipeline) * is not part of the PipelineHandler. */ +/** + * \fn PipelineHandler::configure(const Camera *camera, std::vector &config) + * \brief Configure a set of streams for a camera + * \param[in] camera The camera to configure streams for + * \param[in] config A array of stream configurations to try and setup + * + * This function is the interface to configure one or more streams of a camera + * for capture. The intended user for this interface is the Camera class which + * will receive the array of configurations to apply from the application. + * + * The caller needs to verify the StreamConfiguration objects in the passed + * array after the call as it might remove one or more to satisfy hardware + * limitations. The call might also alter any or all of the configuration + * parameters of any stream to fit within valid operational conditions. + * + * \return 0 on success or a negative error code on error. + */ + /** * \fn PipelineHandler::match(DeviceEnumerator *enumerator) * \brief Match media devices and create camera instances