summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorHarvey Yang <chenghaoyang@chromium.org>2024-11-21 05:51:31 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2024-11-28 16:44:08 +0000
commit39482d59fe7160740ea5dd61f3ed965a88d848ce (patch)
treebc6b51bf536d5c7b14f5e88ba7e1be975f1d04e6 /include
parent562b6335d91fbebd5ab3122ea69a686cea7efa10 (diff)
DmaBufAllocator: Add Dma Buffer synchronization function & helper class
To synchronize CPU access with mmap and hardware access on DMA buffers, using `DMA_BUF_IOCTL_SYNC` is required. This patch adds a function and a helper class to allow users to sync buffers more easily. Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org> Co-developed-by: Harvey Yang <chenghaoyang@chromium.org> Signed-off-by: Harvey Yang <chenghaoyang@chromium.org> Reviewed-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/internal/dma_buf_allocator.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/libcamera/internal/dma_buf_allocator.h b/include/libcamera/internal/dma_buf_allocator.h
index 9211d483..fc5de2c1 100644
--- a/include/libcamera/internal/dma_buf_allocator.h
+++ b/include/libcamera/internal/dma_buf_allocator.h
@@ -12,6 +12,7 @@
#include <vector>
#include <libcamera/base/flags.h>
+#include <libcamera/base/shared_fd.h>
#include <libcamera/base/unique_fd.h>
namespace libcamera {
@@ -48,6 +49,26 @@ private:
DmaBufAllocatorFlag type_;
};
+class DmaSyncer final
+{
+public:
+ enum class SyncType {
+ Read = 0,
+ Write,
+ ReadWrite,
+ };
+
+ explicit DmaSyncer(SharedFD fd, SyncType type = SyncType::ReadWrite);
+
+ ~DmaSyncer();
+
+private:
+ void sync(uint64_t step);
+
+ SharedFD fd_;
+ uint64_t flags_ = 0;
+};
+
LIBCAMERA_FLAGS_ENABLE_OPERATORS(DmaBufAllocator::DmaBufAllocatorFlag)
} /* namespace libcamera */