aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'kms++/inc/kms++/videomode.h')
-rw-r--r--kms++/inc/kms++/videomode.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/kms++/inc/kms++/videomode.h b/kms++/inc/kms++/videomode.h
new file mode 100644
index 0000000..d7f5258
--- /dev/null
+++ b/kms++/inc/kms++/videomode.h
@@ -0,0 +1,58 @@
1#pragma once
2
3#include <string>
4#include <cstdint>
5#include <memory>
6
7#include "blob.h"
8
9namespace kms
10{
11
12enum class SyncPolarity
13{
14 Undefined,
15 Positive,
16 Negative,
17};
18
19struct Videomode
20{
21 std::string name;
22
23 uint32_t clock;
24 uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew;
25 uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan;
26
27 uint32_t vrefresh;
28
29 uint32_t flags; // DRM_MODE_FLAG_*
30 uint32_t type; // DRM_MODE_TYPE_*
31
32 std::unique_ptr<Blob> to_blob(Card& card) const;
33
34 uint16_t hfp() const { return hsync_start - hdisplay; }
35 uint16_t hsw() const { return hsync_end - hsync_start; }
36 uint16_t hbp() const { return htotal - hsync_end; }
37
38 uint16_t vfp() const { return vsync_start - vdisplay; }
39 uint16_t vsw() const { return vsync_end - vsync_start; }
40 uint16_t vbp() const { return vtotal - vsync_end; }
41
42 float calculated_vrefresh() const;
43
44 bool interlace() const;
45 SyncPolarity hsync() const;
46 SyncPolarity vsync() const;
47
48 void set_interlace(bool ilace);
49 void set_hsync(SyncPolarity pol);
50 void set_vsync(SyncPolarity pol);
51
52 std::string to_string() const;
53};
54
55struct Videomode videomode_from_timings(uint32_t clock_khz,
56 uint16_t hact, uint16_t hfp, uint16_t hsw, uint16_t hbp,
57 uint16_t vact, uint16_t vfp, uint16_t vsw, uint16_t vbp);
58}