summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2019-02-05 16:32:22 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-02-06 06:49:19 +0200
commit83148ce8be55e49d30da9006582a1c1eb6371815 (patch)
treefd54f05c964c395026cb049ea6ad5e4d23b2c06a /include
parentccf7464a6e725ed73e9747980ca16022977bd3d9 (diff)
libcamera: Add Buffer Management
Provide classes that represent frame buffers and pools of frame buffers. An image within the system may use one or more Plane objects to track each plane in the case of multi-planar image formats. The Buffer class manages all of the data required to render or interpret the raw image data. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/buffer.h74
-rw-r--r--include/libcamera/libcamera.h1
-rw-r--r--include/libcamera/meson.build1
3 files changed, 76 insertions, 0 deletions
diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h
new file mode 100644
index 00000000..21a1ec4c
--- /dev/null
+++ b/include/libcamera/buffer.h
@@ -0,0 +1,74 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * buffer.h - Buffer handling
+ */
+#ifndef __LIBCAMERA_BUFFER_H__
+#define __LIBCAMERA_BUFFER_H__
+
+#include <vector>
+
+#include <libcamera/signal.h>
+
+namespace libcamera {
+
+class BufferPool;
+
+class Plane final
+{
+public:
+ Plane();
+ ~Plane();
+
+ int dmabuf() const { return fd_; }
+ int setDmabuf(int fd, unsigned int length);
+
+ void *mem();
+ unsigned int length() const { return length_; }
+
+private:
+ int mmap();
+ int munmap();
+
+ int fd_;
+ unsigned int length_;
+ void *mem_;
+};
+
+class Buffer final
+{
+public:
+ Buffer();
+
+ unsigned int index() const { return index_; }
+ std::vector<Plane> &planes() { return planes_; }
+
+ Signal<Buffer *> completed;
+
+private:
+ friend class BufferPool;
+
+ unsigned int index_;
+
+ std::vector<Plane> planes_;
+};
+
+class BufferPool final
+{
+public:
+ ~BufferPool();
+
+ void createBuffers(unsigned int count);
+ void destroyBuffers();
+
+ unsigned int count() const { return buffers_.size(); }
+ std::vector<Buffer> &buffers() { return buffers_; }
+
+private:
+ std::vector<Buffer> buffers_;
+};
+
+} /* namespace libcamera */
+
+#endif /* __LIBCAMERA_BUFFER_H__ */
diff --git a/include/libcamera/libcamera.h b/include/libcamera/libcamera.h
index 272dfd5e..8167e809 100644
--- a/include/libcamera/libcamera.h
+++ b/include/libcamera/libcamera.h
@@ -7,6 +7,7 @@
#ifndef __LIBCAMERA_LIBCAMERA_H__
#define __LIBCAMERA_LIBCAMERA_H__
+#include <libcamera/buffer.h>
#include <libcamera/camera.h>
#include <libcamera/camera_manager.h>
#include <libcamera/event_dispatcher.h>
diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build
index 54a68078..8c14423b 100644
--- a/include/libcamera/meson.build
+++ b/include/libcamera/meson.build
@@ -1,4 +1,5 @@
libcamera_api = files([
+ 'buffer.h',
'camera.h',
'camera_manager.h',
'event_dispatcher.h',