forked from notaz/mesa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpps_device.h
53 lines (41 loc) · 1.26 KB
/
pps_device.h
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Copyright © 2020 Collabora, Ltd.
* Author: Antonio Caggiano <[email protected]>
* Author: Rohan Garg <[email protected]>
* Author: Robert Beckett <[email protected]>
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <optional>
#include <string>
#include <vector>
namespace pps
{
/// @brief Helper class for a DRM device
class DrmDevice
{
public:
/// @return The number of DRM devices available in the system
static uint32_t device_count();
/// @return All DRM devices available in the system
static std::vector<DrmDevice> create_all();
/// @return A DRM device selected by its number in the system, nullopt otherwise
static std::optional<DrmDevice> create(int32_t gpu_num);
/// @brief Prefer calling create instead of default constructor
DrmDevice() = default;
// Allow move
DrmDevice(DrmDevice &&);
DrmDevice &operator=(DrmDevice &&);
// Forbid copy
DrmDevice(const DrmDevice &) = delete;
DrmDevice &operator=(const DrmDevice &) = delete;
~DrmDevice();
/// @return Whether a device has a valid name
operator bool() const;
/// File descriptor of the device opened in read/write mode
int fd = -1;
int32_t gpu_num = -1;
std::string name = "";
};
} // namespace pps