summaryrefslogtreecommitdiff
path: root/include/libcamera/internal/dma_heaps.h
blob: 80bf29e7f78d419a1848742cbf4a841bfbc75847 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* 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 */