Add an argument to the constructor to specify dma heaps type(s) to use. Can be DmaHeapFlag::Cma and/or DmaHeapFlag::System. By default DmaHeapFlag::Cma is used. If both DmaHeapFlag::Cma and DmaHeapFlag::System are set, CMA heap is tried first. Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s Tested-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Pavel Machek <pavel@ucw.cz> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
39 lines
718 B
C++
39 lines
718 B
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2020, Raspberry Pi Ltd
|
|
*
|
|
* dma_heaps.h - Helper class for dma-heap allocations.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <libcamera/base/flags.h>
|
|
#include <libcamera/base/unique_fd.h>
|
|
|
|
namespace libcamera {
|
|
|
|
class DmaHeap
|
|
{
|
|
public:
|
|
enum class DmaHeapFlag {
|
|
Cma = 1 << 0,
|
|
System = 1 << 1,
|
|
};
|
|
|
|
using DmaHeapFlags = Flags<DmaHeapFlag>;
|
|
|
|
DmaHeap(DmaHeapFlags flags = DmaHeapFlag::Cma);
|
|
~DmaHeap();
|
|
bool isValid() const { return dmaHeapHandle_.isValid(); }
|
|
UniqueFD alloc(const char *name, std::size_t size);
|
|
|
|
private:
|
|
UniqueFD dmaHeapHandle_;
|
|
};
|
|
|
|
LIBCAMERA_FLAGS_ENABLE_OPERATORS(DmaHeap::DmaHeapFlag)
|
|
|
|
} /* namespace libcamera */
|