From patchwork Mon Jan 21 23:06:40 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: 320 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4220460C83 for ; Tue, 22 Jan 2019 00:07:20 +0100 (CET) X-Halon-ID: 4a933f3d-1dd1-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 4a933f3d-1dd1-11e9-874f-005056917f90; Tue, 22 Jan 2019 00:07:16 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Jan 2019 00:06:40 +0100 Message-Id: <20190121230640.8783-5-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121230640.8783-1-niklas.soderlund@ragnatech.se> References: <20190121230640.8783-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 4/4] 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: Mon, 21 Jan 2019 23:07:20 -0000 Implement stubs for retrieving the streams of a camera and configuration of the same. This just add stubs and further building blocks are needed to make this useful. Signed-off-by: Niklas Söderlund --- include/libcamera/camera.h | 9 ++++++++ src/libcamera/camera.cpp | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 03b285c840c246e1..13395d994bade85a 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -7,11 +7,16 @@ #ifndef __LIBCAMERA_CAMERA_H__ #define __LIBCAMERA_CAMERA_H__ +#include #include #include +#include namespace libcamera { +class Stream; +class StreamFormat; + class Camera final { public: @@ -22,6 +27,10 @@ public: const std::string &name() const; + std::vector streams() const; + + int configure(const std::map &config); + int acquire(); void release(); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index b80bc36e410a6e0a..ad9cf948135c03bd 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -6,6 +6,7 @@ */ #include +#include #include "log.h" @@ -83,6 +84,51 @@ const std::string &Camera::name() const return name_; } +/** + * \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; + + /* TODO: Call into pipeline handler and get streams. */ + /* HACK: Hard code a single stream with ID 0. */ + streams.push_back(Stream(0)); + + 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(const std::map &config) +{ + if (!acquired_) + return -EACCES; + + /* TODO: Call into pipeline handler to configure the hardware. */ + + return 0; +} + Camera::Camera(const std::string &name) : name_(name) {