libcamera: stream: Map external buffers to indexes

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 <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
Jacopo Mondi 2019-06-28 15:11:34 +02:00 committed by Laurent Pinchart
parent 689e8916ca
commit 9ed9d9b3c1
4 changed files with 123 additions and 1 deletions

View file

@ -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<std::pair<std::array<int, 3>, unsigned int>> bufferCache_;
};
} /* namespace libcamera */