From 9ed9d9b3c1a5e6a51e1aa869c758458c57c1a0f1 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 28 Jun 2019 15:11:34 +0200 Subject: libcamera: stream: Map external buffers to indexes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add and use an operation to assign to Buffer representing external memory locations an index at queueRequest() time. The index is used to identify the memory buffer to be queued to the video device once the buffer will be queued in a Request. In order to minimize relocations in the V4L2 backend, this method provides a best-effort caching mechanisms that attempts to reuse BufferMemory previously mapped to the buffer's dmabuf file descriptors, if any. Signed-off-by: Jacopo Mondi Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/buffer.h | 2 ++ include/libcamera/stream.h | 6 ++++++ 2 files changed, 8 insertions(+) (limited to 'include') diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h index fc5c7d4c..7b657509 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/buffer.h @@ -30,6 +30,8 @@ public: unsigned int length() const { return length_; } private: + friend class Stream; + int mmap(); int munmap(); diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index 1883d9e9..2e619cdf 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -85,12 +85,18 @@ public: protected: friend class Camera; + int mapBuffer(const Buffer *buffer); + void unmapBuffer(const Buffer *buffer); + void createBuffers(MemoryType memory, unsigned int count); void destroyBuffers(); BufferPool bufferPool_; StreamConfiguration configuration_; MemoryType memoryType_; + +private: + std::vector, unsigned int>> bufferCache_; }; } /* namespace libcamera */ -- cgit v1.2.1