libcamera: buffer: Add dmabuf file descriptors

In addition to referencing buffer memory by index, add support to
referencing it using dmabuf file descriptors. This will be used to
reference buffer memory allocated outside of libcamera and import it.

The dmabuf file descriptors are stored in an array in the Buffer class,
and a new Stream::createBuffer() overload is added to construct a buffer
from dmabuf file descriptor.

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-07-10 12:07:19 +02:00
committed by Laurent Pinchart
parent 99e1e786b4
commit f1199a1011
5 changed files with 67 additions and 2 deletions
+3
View File
@@ -7,6 +7,7 @@
#ifndef __LIBCAMERA_BUFFER_H__
#define __LIBCAMERA_BUFFER_H__
#include <array>
#include <stdint.h>
#include <vector>
@@ -75,6 +76,7 @@ public:
Buffer &operator=(const Buffer &) = delete;
unsigned int index() const { return index_; }
const std::array<int, 3> &dmabufs() const { return dmabuf_; }
unsigned int bytesused() const { return bytesused_; }
uint64_t timestamp() const { return timestamp_; }
@@ -95,6 +97,7 @@ private:
void setRequest(Request *request) { request_ = request; }
unsigned int index_;
std::array<int, 3> dmabuf_;
unsigned int bytesused_;
uint64_t timestamp_;
+1
View File
@@ -75,6 +75,7 @@ public:
Stream();
std::unique_ptr<Buffer> createBuffer(unsigned int index);
std::unique_ptr<Buffer> createBuffer(const std::array<int, 3> &fds);
BufferPool &bufferPool() { return bufferPool_; }
std::vector<BufferMemory> &buffers() { return bufferPool_.buffers(); }