• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #pragma once
2 
3 #include <string>
4 #include <cstdint>
5 #include <memory>
6 
7 #include "blob.h"
8 
9 namespace kms
10 {
11 
12 enum class SyncPolarity
13 {
14 	Undefined,
15 	Positive,
16 	Negative,
17 };
18 
19 struct 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 
hfpVideomode34 	uint16_t hfp() const { return hsync_start - hdisplay; }
hswVideomode35 	uint16_t hsw() const { return hsync_end - hsync_start; }
hbpVideomode36 	uint16_t hbp() const { return htotal - hsync_end; }
37 
vfpVideomode38 	uint16_t vfp() const { return vsync_start - vdisplay; }
vswVideomode39 	uint16_t vsw() const { return vsync_end - vsync_start; }
vbpVideomode40 	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 
55 struct 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 }
59