From patchwork Tue Jan 22 23:45:04 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: 341 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 19FE060C9A for ; Wed, 23 Jan 2019 00:46:44 +0100 (CET) X-Halon-ID: ec281263-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 ec281263-1e9f-11e9-911a-0050569116f7; Wed, 23 Jan 2019 00:46:22 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 23 Jan 2019 00:45:04 +0100 Message-Id: <20190122234505.32634-8-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 7/8] 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: Tue, 22 Jan 2019 23:46:44 -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 3cb1ab62b791ab87..9337fa970d26b0df 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -9,10 +9,13 @@ #include #include +#include namespace libcamera { class PipelineHandler; +class Stream; +class StreamConfiguration; class Camera final { @@ -30,6 +33,10 @@ public: int acquire(); void release(); + std::vector streams() const; + + int configure(std::vector &config); + private: explicit Camera(const std::string &name, class PipelineHandler *pipe); ~Camera(); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index ee5e6dedb242a1fd..6cae82669e454e35 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -6,6 +6,9 @@ */ #include +#include + +#include "pipeline_handler.h" #include "log.h" @@ -144,4 +147,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 */