From ea4baaacc3250eadb929fcef59bb9ddefb012952 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 3 Jun 2024 13:12:58 +0200 Subject: libcamera: DmaBufAllocator: Support allocating from /dev/udmabuf The dma-buf allocator currently allocates from CMA and system heaps. Extend the dma-buf allocator to support allocating dma-buffers by creating memfd-s and turning those into dma-buffers using /dev/udmabuf. The buffers allocated through memfd/udmabuf are not suitable for zero-copy buffer sharing with other devices. Co-developed-by: Harvey Yang Signed-off-by: Harvey Yang Reviewed-by: Kieran Bingham Tested-by: Bryan O'Donoghue # Lenovo-x13s Reviewed-by: Laurent Pinchart Signed-off-by: Hans de Goede Signed-off-by: Kieran Bingham --- include/libcamera/internal/dma_buf_allocator.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/libcamera/internal/dma_buf_allocator.h b/include/libcamera/internal/dma_buf_allocator.h index a881042e..36ec1696 100644 --- a/include/libcamera/internal/dma_buf_allocator.h +++ b/include/libcamera/internal/dma_buf_allocator.h @@ -20,6 +20,7 @@ public: enum class DmaBufAllocatorFlag { CmaHeap = 1 << 0, SystemHeap = 1 << 1, + UDmaBuf = 1 << 2, }; using DmaBufAllocatorFlags = Flags; @@ -30,7 +31,10 @@ public: UniqueFD alloc(const char *name, std::size_t size); private: + UniqueFD allocFromHeap(const char *name, std::size_t size); + UniqueFD allocFromUDmaBuf(const char *name, std::size_t size); UniqueFD providerHandle_; + DmaBufAllocatorFlag type_; }; LIBCAMERA_FLAGS_ENABLE_OPERATORS(DmaBufAllocator::DmaBufAllocatorFlag) -- cgit v1.2.1