diff options
author | Hans de Goede <hdegoede@redhat.com> | 2024-06-03 13:12:58 +0200 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2024-06-04 16:19:33 +0100 |
commit | ea4baaacc3250eadb929fcef59bb9ddefb012952 (patch) | |
tree | 2bb3870c0da614a0d0a5f0c6f195f1a40ee62391 /include | |
parent | 447da4a11f06f0d950fe75c20c7bb9f5d5408880 (diff) |
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 <chenghaoyang@chromium.org>
Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # Lenovo-x13s
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/libcamera/internal/dma_buf_allocator.h | 4 |
1 files changed, 4 insertions, 0 deletions
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<DmaBufAllocatorFlag>; @@ -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) |