1 #pragma once 2 3 #include <string> 4 #include <cstdint> 5 #include <memory> 6 7 #include "blob.h" 8 9 namespace kms 10 { 11 enum class SyncPolarity { 12 Undefined, 13 Positive, 14 Negative, 15 }; 16 17 struct Videomode { 18 std::string name; 19 20 uint32_t clock; 21 uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew; 22 uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan; 23 24 uint32_t vrefresh; 25 26 uint32_t flags; // DRM_MODE_FLAG_* 27 uint32_t type; // DRM_MODE_TYPE_* 28 29 std::unique_ptr<Blob> to_blob(Card& card) const; 30 hfpVideomode31 uint16_t hfp() const { return hsync_start - hdisplay; } hswVideomode32 uint16_t hsw() const { return hsync_end - hsync_start; } hbpVideomode33 uint16_t hbp() const { return htotal - hsync_end; } 34 vfpVideomode35 uint16_t vfp() const { return vsync_start - vdisplay; } vswVideomode36 uint16_t vsw() const { return vsync_end - vsync_start; } vbpVideomode37 uint16_t vbp() const { return vtotal - vsync_end; } 38 39 float calculated_vrefresh() const; 40 41 bool interlace() const; 42 SyncPolarity hsync() const; 43 SyncPolarity vsync() const; 44 45 void set_interlace(bool ilace); 46 void set_hsync(SyncPolarity pol); 47 void set_vsync(SyncPolarity pol); 48 49 std::string to_string_short() const; 50 std::string to_string_long() const; 51 std::string to_string_long_padded() const; 52 53 bool valid() const; 54 }; 55 56 struct Videomode videomode_from_timings(uint32_t clock_khz, 57 uint16_t hact, uint16_t hfp, uint16_t hsw, uint16_t hbp, 58 uint16_t vact, uint16_t vfp, uint16_t vsw, uint16_t vbp); 59 } // namespace kms 60