From patchwork Tue Nov 26 23:36:10 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: 2368 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 3A10F61CC9 for ; Wed, 27 Nov 2019 00:39:40 +0100 (CET) X-Halon-ID: 02b0592e-10a6-11ea-a0b9-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p54ac5865.dip0.t-ipconnect.de [84.172.88.101]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id 02b0592e-10a6-11ea-a0b9-005056917f90; Wed, 27 Nov 2019 00:39:38 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Nov 2019 00:36:10 +0100 Message-Id: <20191126233620.1695316-21-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191126233620.1695316-1-niklas.soderlund@ragnatech.se> References: <20191126233620.1695316-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 20/30] libcamera: stream: Add prototypes for new interface X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Nov 2019 23:39:40 -0000 The buffer allocation rework will remove most of the methods in the Stream class. This change adds the prototypes for the FrameBuffer interface with stub default implementations. Once the new buffer allocation work is completed the prototypes added in this change will be turned into pure virtual functions preventing the base Stream class from being instantiated. Signed-off-by: Niklas Söderlund --- include/libcamera/stream.h | 11 ++++++++ src/libcamera/stream.cpp | 55 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index a404eccf34d9c93b..395148e45d342d92 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -7,6 +7,7 @@ #ifndef __LIBCAMERA_STREAM_H__ #define __LIBCAMERA_STREAM_H__ +#include #include #include #include @@ -74,6 +75,7 @@ class Stream { public: Stream(); + virtual ~Stream(){}; std::unique_ptr createBuffer(unsigned int index); std::unique_ptr createBuffer(const std::array &fds); @@ -86,6 +88,15 @@ public: protected: friend class Camera; + virtual int allocateBuffers(const StreamConfiguration &config, + std::vector *buffers) + { + return -EINVAL; + } + virtual void releaseBuffers() { return; } + virtual int start() { return -EINVAL; } + virtual void stop() { return; } + int mapBuffer(const Buffer *buffer); void unmapBuffer(const Buffer *buffer); diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index e70a1e307ecaa5ba..ba3f571b08cb0c41 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -520,6 +520,61 @@ std::unique_ptr Stream::createBuffer(const std::array &fds) * \return The memory type used by the stream */ +/** + * \fn Stream::allocateBuffers() + * \brief Allocate buffers from the stream + * \param[in] config A configuration describing the buffer(s) to be allocated + * \param[out] buffers Array of buffers successfully allocated + * + * Allocate buffers matching exactly what is described in \a config and return + * then in \a buffers. If buffers matching \a config can't be allocated an error + * shall be returned and no buffers returned in \a buffers. + * + * This is a helper which may be used by libcamera helper classes to allocate + * buffers from the stream itself. The allocated buffers may then be treated + * in the same way as if they where externally allocated. + * + * The only intended caller is buffer allocator helpers and the function must + * be implemeted by all subclasses of Stream. + * + * \return 0 on success or a negative error code otherwise + */ + +/** + * \fn Stream::releaseBuffers() + * \brief Relase buffers allocated from the stram + * + * This is a helper which release buffers allocated using allocateBuffers(). The + * only intended caller is buffer allocator helpers. + * + * The only intended caller is buffer allocator helpers and the function must + * be implemeted by all subclasses of Stream. + */ + +/** + * \fn Stream::start() + * \brief Prepare a stream for capture + * + * The subclss shall prepare the stream for capture and if needed allocate + * resources to allow for that. No buffers may be allocated from the stream + * using allocateBuffers() after a stream have been started. + * + * The only intended caller is the camera base class and the function must be + * implemeted by all subclasses of Stream. + * + * \return 0 on success or a negative error code otherwise + */ + +/** + * \fn Stream::stop() + * \brief Stop a stream after capture + * + * The subclass shall free all resources allocated in start(). + * + * The only intended caller is the camera base class and the function must be + * implemeted by all subclasses of Stream. + */ + /** * \brief Map a Buffer to a buffer memory index * \param[in] buffer The buffer to map to a buffer memory index