libcamera
v0.3.1+12-19bbca3c
Supporting cameras in Linux since 2019
|
Helper class for dma-buf allocations. More...
Public Types | |
enum | DmaBufAllocatorFlag { DmaBufAllocatorFlag::CmaHeap = 1 << 0, DmaBufAllocatorFlag::SystemHeap = 1 << 1, DmaBufAllocatorFlag::UDmaBuf = 1 << 2 } |
Type of the dma-buf provider. More... | |
using | DmaBufAllocatorFlags = Flags< DmaBufAllocatorFlag > |
A bitwise combination of DmaBufAllocator::DmaBufAllocatorFlag values. | |
Public Member Functions | |
DmaBufAllocator (DmaBufAllocatorFlags flags=DmaBufAllocatorFlag::CmaHeap) | |
Construct a DmaBufAllocator of a given type. More... | |
~DmaBufAllocator () | |
Destroy the DmaBufAllocator instance. | |
bool | isValid () const |
Check if the DmaBufAllocator instance is valid. More... | |
UniqueFD | alloc (const char *name, std::size_t size) |
Allocate a dma-buf from the DmaBufAllocator. More... | |
Helper class for dma-buf allocations.
This class wraps a userspace dma-buf provider selected at construction time, and exposes functions to allocate dma-buffers from this provider.
Different providers may provide dma-buffers with different properties for the underlying memory. Which providers are acceptable is specified through the type argument passed to the DmaBufAllocator() constructor.
|
strong |
libcamera::DmaBufAllocator::DmaBufAllocator | ( | DmaBufAllocatorFlags | type = DmaBufAllocatorFlag::CmaHeap | ) |
Construct a DmaBufAllocator of a given type.
[in] | type | The type(s) of the dma-buf providers to allocate from |
The dma-buf provider type is selected with the type parameter, which defaults to the CMA heap. If no provider of the given type can be accessed, the constructed DmaBufAllocator instance is invalid as indicated by the isValid() function.
Multiple types can be selected by combining type flags, in which case the constructed DmaBufAllocator will match one of the types. If multiple requested types can work on the system, which provider is used is undefined.
UniqueFD libcamera::DmaBufAllocator::alloc | ( | const char * | name, |
std::size_t | size | ||
) |
Allocate a dma-buf from the DmaBufAllocator.
[in] | name | The name to set for the allocated buffer |
[in] | size | The size of the buffer to allocate |
Allocates a dma-buf with read/write access.
If the allocation fails, return an invalid UniqueFD.
|
inline |
Check if the DmaBufAllocator instance is valid.