From patchwork Wed Jan 30 11:56:14 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: 451 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 51DE560B2D for ; Wed, 30 Jan 2019 12:57:01 +0100 (CET) X-Halon-ID: 241ddefd-2486-11e9-911a-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from wyvern.c.hoisthospitality.com (unknown [217.64.245.162]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 241ddefd-2486-11e9-911a-0050569116f7; Wed, 30 Jan 2019 12:56:58 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 30 Jan 2019 12:56:14 +0100 Message-Id: <20190130115615.17362-6-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190130115615.17362-1-niklas.soderlund@ragnatech.se> References: <20190130115615.17362-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 5/6] libcamera: pipeline: extend pipelines to support stream configuration 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, 30 Jan 2019 11:57:01 -0000 All streams which are to be used for capture need to be configured at the same time. This allows the pipeline handler to take any dependencies between the different streams and their configuration into account when setting up the hardware. Extend the pipeline API and all pipeline implementations with two new functions, one to read a default configuration and one to set a new configuration. Both functions operate on a group of streams which the pipeline handler should consider when performing the operations. In the current implemented pipelines this is rather easy as they only have one stream each per camera. Furthermore as there is yet no way for the pipeline handlers to interact with the hardware all they do is return a null format and logs that a default configuration have been requested and log that a new configuration have been requested. Future work based on more components are needed to make the pipelines return a good default format and actually interact with the hardware. Signed-off-by: Niklas Söderlund --- src/libcamera/include/pipeline_handler.h | 7 +++++ src/libcamera/pipeline/ipu3/ipu3.cpp | 36 ++++++++++++++++++++++++ src/libcamera/pipeline/uvcvideo.cpp | 35 +++++++++++++++++++++++ src/libcamera/pipeline/vimc.cpp | 35 +++++++++++++++++++++++ src/libcamera/pipeline_handler.cpp | 34 ++++++++++++++++++++++ 5 files changed, 147 insertions(+) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index 080997e22e545e01..b4321f0fa0f765be 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -18,6 +18,8 @@ class Camera; class CameraManager; class DeviceEnumerator; class MediaDevice; +class Stream; +class StreamConfiguration; class CameraData { @@ -38,6 +40,11 @@ public: PipelineHandler(CameraManager *manager); virtual ~PipelineHandler(); + virtual std::map + streamConfiguration(Camera *camera, std::vector &streams) = 0; + virtual int configureStreams(Camera *camera, + std::map &config) = 0; + virtual bool match(DeviceEnumerator *enumerator) = 0; protected: diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 52844da78419943d..39553b7c19823a52 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -28,6 +28,12 @@ public: PipelineHandlerIPU3(CameraManager *manager); ~PipelineHandlerIPU3(); + std::map + streamConfiguration(Camera *camera, + std::vector &streams); + int configureStreams(Camera *camera, + std::map &config); + bool match(DeviceEnumerator *enumerator); private: @@ -68,6 +74,36 @@ PipelineHandlerIPU3::~PipelineHandlerIPU3() imgu_->release(); } +std::map +PipelineHandlerIPU3::streamConfiguration(Camera *camera, + std::vector &streams) +{ + IPU3CameraData *data = dynamic_cast(cameraData(camera)); + + std::map configs; + + StreamConfiguration config{}; + + LOG(IPU3, Info) << "TODO: Return a good default format"; + + configs[&data->stream_] = config; + + return configs; +} + +int PipelineHandlerIPU3::configureStreams(Camera *camera, + std::map &config) +{ + IPU3CameraData *data = dynamic_cast(cameraData(camera)); + + StreamConfiguration *cfg = &config[&data->stream_]; + + LOG(IPU3, Info) << "TODO: Configure the camera for resolution " << + cfg->width << "x" << cfg->height; + + return 0; +} + bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator) { DeviceMatch cio2_dm("ipu3-cio2"); diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 8ea7ac74d2a5395d..4647ed95e929940a 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -9,18 +9,27 @@ #include #include "device_enumerator.h" +#include "log.h" #include "media_device.h" #include "pipeline_handler.h" #include "v4l2_device.h" namespace libcamera { +LOG_DEFINE_CATEGORY(UVC) + class PipelineHandlerUVC : public PipelineHandler { public: PipelineHandlerUVC(CameraManager *manager); ~PipelineHandlerUVC(); + std::map + streamConfiguration(Camera *camera, + std::vector &streams); + int configureStreams(Camera *camera, + std::map &config); + bool match(DeviceEnumerator *enumerator); private: @@ -43,6 +52,32 @@ PipelineHandlerUVC::~PipelineHandlerUVC() media_->release(); } +std::map +PipelineHandlerUVC::streamConfiguration(Camera *camera, + std::vector &streams) +{ + std::map configs; + + StreamConfiguration config{}; + + LOG(UVC, Info) << "TODO: Return a good default format"; + + configs[&stream_] = config; + + return configs; +} + +int PipelineHandlerUVC::configureStreams(Camera *camera, + std::map &config) +{ + StreamConfiguration *cfg = &config[&stream_]; + + LOG(UVC, Info) << "TODO: Configure the camera for resolution " << + cfg->width << "x" << cfg->height; + + return 0; +} + bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) { DeviceMatch dm("uvcvideo"); diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 9e1cf11a20c7a7e3..835f8f512c4ac53a 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -9,17 +9,26 @@ #include #include "device_enumerator.h" +#include "log.h" #include "media_device.h" #include "pipeline_handler.h" namespace libcamera { +LOG_DEFINE_CATEGORY(VIMC) + class PipeHandlerVimc : public PipelineHandler { public: PipeHandlerVimc(CameraManager *manager); ~PipeHandlerVimc(); + std::map + streamConfiguration(Camera *camera, + std::vector &streams); + int configureStreams(Camera *camera, + std::map &config); + bool match(DeviceEnumerator *enumerator); private: @@ -38,6 +47,32 @@ PipeHandlerVimc::~PipeHandlerVimc() media_->release(); } +std::map +PipeHandlerVimc::streamConfiguration(Camera *camera, + std::vector &streams) +{ + std::map configs; + + StreamConfiguration config{}; + + LOG(VIMC, Info) << "TODO: Return a good default format"; + + configs[&stream_] = config; + + return configs; +} + +int PipeHandlerVimc::configureStreams(Camera *camera, + std::map &config) +{ + StreamConfiguration *cfg = &config[&stream_]; + + LOG(VIMC, Info) << "TODO: Configure the camera for resolution " << + cfg->width << "x" << cfg->height; + + return 0; +} + bool PipeHandlerVimc::match(DeviceEnumerator *enumerator) { DeviceMatch dm("vimc"); diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 1c8640799f714686..3a560e10c442717f 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -75,6 +75,40 @@ PipelineHandler::~PipelineHandler() { }; + +/** + * \fn PipelineHandler::streamConfiguration() + * \brief Retrieve a group of stream configurations for a specified camera + * \param[in] camera The camera to fetch default configuration from + * \param[in] streams An array of streams to fetch information about + * + * Retrieve the species camera's default configuration for a specified group of + * streams. The caller shall populate the \a streams array with the streams it + * wish to fetch the configuration from. The map of streams and configuration + * returned can then be examined by the caller to learn about the defualt + * parameters for the specified streams. + * + * The intended companion to this is \a configureStreams() which can be used to + * change the group of streams parameters. + * + * \return A map of successfully retrieved streams and configurations or an + * empty map on error. + */ + +/** + * \fn PipelineHandler::configureStreams() + * \brief Configure a group of streams for capture + * \param[in] camera The camera to configure + * \param[in] config A map of stream configurations to apply + * + * Configure the specified group of streams for \a camera according to the + * configuration specified in \a configs. The intended caller of this interface + * is the Camera class which will receive configuration to apply from the + * application. + * + * \return 0 on success or a negative error code on error. + */ + /** * \fn PipelineHandler::match(DeviceEnumerator *enumerator) * \brief Match media devices and create camera instances