summaryrefslogtreecommitdiff
path: root/src/libcamera/dma_buf_allocator.cpp
AgeCommit message (Collapse)Author
2024-08-01libcamera: base: Add MemFd helper classLaurent Pinchart
libcamera creates memfds in two locations already, duplicating some code. Move the code to a new MemFd helper class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Milan Zamazal <mzamazal@redhat.com> Tested-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2024-06-05libcamera: dma_buf_allocator: Work around lack of file seals in uClibcLaurent Pinchart
uClibc doesn't provide the macros defining parameters for the file sealing API. Define them manually as a work around. Fixes: ea4baaacc325 ("libcamera: DmaBufAllocator: Support allocating from /dev/udmabuf") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2024-06-05libcamera: dma_buf_allocator: Work around lack of memfd_create() in uClibcLaurent Pinchart
uClibc doesn't provide a memfd_create() implementation. Fix it by using a direct syscall when the function isn't available. Fixes: ea4baaacc325 ("libcamera: DmaBufAllocator: Support allocating from /dev/udmabuf") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2024-06-05libcamera: dma_buf_allocator: Create memfd with CLOEXECLaurent Pinchart
Ensure that the memfd file descriptor won't be leaked to child processes by creating it with MFD_CLOEXEC. Fixes: ea4baaacc325 ("libcamera: DmaBufAllocator: Support allocating from /dev/udmabuf") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-06-04libcamera: DmaBufAllocator: Support allocating from /dev/udmabufHans de Goede
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>
2024-06-04libcamera: Rename DmaHeap class to DmaBufAllocatorHans de Goede
Users of the DmaHeap class really just want some way to allocate dma-buffers from userspace. This can also be done by using /dev/udmabuf instead of using /dev/dma_heap/*. Rename DmaHeap class to DmaBufAllocator in preparation of adding /dev/udmabuf support. And update the DmaHeap class docs to match including replacing references to "dma-heap type" with "dma-buf provider". This is a pure automated rename on the code ('s/DmaHeap/DmaBufAllocator/') + file renames + doc updates. There are no functional changes. The DmaBufAllocator objects in vc4.cpp and software_isp.cpp are left named dmaHeap_ to keep the changes to those 2 files to a minimum. 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>