From patchwork Fri Jan 25 15:33:39 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: 385 X-Patchwork-Delegate: niklas.soderlund@ragnatech.se 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 C897E60C80 for ; Fri, 25 Jan 2019 16:33:54 +0100 (CET) X-Halon-ID: 9e9fa57f-20b6-11e9-874f-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id 9e9fa57f-20b6-11e9-874f-005056917f90; Fri, 25 Jan 2019 16:33:53 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Jan 2019 16:33:39 +0100 Message-Id: <20190125153340.2744-7-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190125153340.2744-1-niklas.soderlund@ragnatech.se> References: <20190125153340.2744-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 6/7] libcamera: camera: integrate streams and 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: Fri, 25 Jan 2019 15:33:55 -0000 Add retrieval and configuration of streams information and configuration. The implementation in the Camera are minimalistic as the heavily lifting are done by the pipeline handler implementations. The single most important thing for the helpers in the Camera object is to perform access control and making sure no request is forwarded to a pipeline handler if the camera have been disconnected. Signed-off-by: Niklas Söderlund --- include/libcamera/camera.h | 7 ++++++ src/libcamera/camera.cpp | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 7e358f8c0aa093cf..c6342ed81598921c 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -9,12 +9,15 @@ #include #include +#include #include namespace libcamera { class PipelineHandler; +class Stream; +class StreamConfiguration; class Camera final { @@ -32,6 +35,10 @@ public: int acquire(); void release(); + std::vector streams() const; + + int configure(std::vector &config); + private: Camera(PipelineHandler *pipe, const std::string &name); ~Camera(); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index fd19e8cf6694cc1b..f90abfecd4e6bb48 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -6,6 +6,9 @@ */ #include +#include + +#include "pipeline_handler.h" #include "log.h" #include "pipeline_handler.h" @@ -160,4 +163,49 @@ void Camera::release() acquired_ = false; } +/** + * \brief Retrieve the supported streams of the camera + * + * \return An array of streams supported by the camera device + */ +std::vector Camera::streams() const +{ + std::vector streams; + + if (pipe_) + streams = pipe_->streams(this); + + return streams; +} + +/** + * \brief Configure the camera device prior to capture + * + * Prior to starting capture, the camera device must be configured to select a + * set of streams. + * + * The requested configuration \a config shall contain at least one stream and + * may contain multiple streams. For each stream an associated StreamFormat + * shall be supplied. Streams supported by the camera device not part of the + * \a config will be disabled. + * + * Exclusive access to the camera device shall be ensured by a call to + * Camera::acquire() before calling this function, otherwise an -EACCES error + * will be returned. + * + * \param[in] config Array of stream configurations to setup + * + * \return 0 on success or a negative error code on error. + */ +int Camera::configure(std::vector &config) +{ + if (!pipe_) + return -ENODEV; + + if (!acquired_) + return -EACCES; + + return pipe_->configure(this, config); +} + } /* namespace libcamera */