[PATCH] libcamera: dma_heaps: Add support for using udmabuf to alloc DMA heaps

Kieran Bingham kieran.bingham at ideasonboard.com
Wed May 29 01:07:08 CEST 2024


Quoting Hans de Goede (2024-05-27 15:16:47)
> Add support for using udmabuf to alloc DMA heaps, this is basically:
> https://patchwork.libcamera.org/patch/18922/
> 
> ported from the never merged HeapAllocator class to the current DmaHeap
> class.
> 
> Co-developed-by: Harvey Yang <chenghaoyang at chromium.org>
> Signed-off-by: Harvey Yang <chenghaoyang at chromium.org>
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  include/libcamera/internal/dma_heaps.h |   3 +
>  src/libcamera/dma_heaps.cpp            | 127 +++++++++++++++++++++----
>  2 files changed, 109 insertions(+), 21 deletions(-)
> 
> diff --git a/include/libcamera/internal/dma_heaps.h b/include/libcamera/internal/dma_heaps.h
> index f0a8aa5d..7e1271ed 100644
> --- a/include/libcamera/internal/dma_heaps.h
> +++ b/include/libcamera/internal/dma_heaps.h
> @@ -30,7 +30,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 dmaHeapHandle_;
> +       bool useUDmaBuf_;
>  };
>  
>  LIBCAMERA_FLAGS_ENABLE_OPERATORS(DmaHeap::DmaHeapFlag)
> diff --git a/src/libcamera/dma_heaps.cpp b/src/libcamera/dma_heaps.cpp
> index d4cb880b..bb707786 100644
> --- a/src/libcamera/dma_heaps.cpp
> +++ b/src/libcamera/dma_heaps.cpp
> @@ -10,10 +10,14 @@
>  #include <array>
>  #include <fcntl.h>
>  #include <sys/ioctl.h>
> +#include <sys/mman.h>
> +#include <sys/stat.h>
> +#include <sys/types.h>
>  #include <unistd.h>
>  
>  #include <linux/dma-buf.h>
>  #include <linux/dma-heap.h>
> +#include <linux/udmabuf.h>

Hrm. this fails on CI. Perhaps it's a new header, and we might have to
bring this into include/linux in libcamera.

 - https://gitlab.freedesktop.org/camera/libcamera/-/jobs/59258127

--
Kieran


More information about the libcamera-devel mailing list