aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Valkeinen2017-10-20 03:32:18 -0500
committerTomi Valkeinen2017-10-20 03:32:18 -0500
commit34a3e4916fc076d4a687d96ac4ad4484ad046d6d (patch)
tree38a7ae95e8bc23ea1f973fd9ba085dccaa354a18
parentf32b82c17cd357ae1c8ed2636266113955293feb (diff)
downloadexternal-kmsxx-34a3e4916fc076d4a687d96ac4ad4484ad046d6d.tar.gz
external-kmsxx-34a3e4916fc076d4a687d96ac4ad4484ad046d6d.tar.xz
external-kmsxx-34a3e4916fc076d4a687d96ac4ad4484ad046d6d.zip
Videomode: add to_string()
-rw-r--r--kms++/inc/kms++/videomode.h2
-rw-r--r--kms++/src/videomode.cpp11
2 files changed, 13 insertions, 0 deletions
diff --git a/kms++/inc/kms++/videomode.h b/kms++/inc/kms++/videomode.h
index 39e5639..d7f5258 100644
--- a/kms++/inc/kms++/videomode.h
+++ b/kms++/inc/kms++/videomode.h
@@ -48,6 +48,8 @@ struct Videomode
48 void set_interlace(bool ilace); 48 void set_interlace(bool ilace);
49 void set_hsync(SyncPolarity pol); 49 void set_hsync(SyncPolarity pol);
50 void set_vsync(SyncPolarity pol); 50 void set_vsync(SyncPolarity pol);
51
52 std::string to_string() const;
51}; 53};
52 54
53struct Videomode videomode_from_timings(uint32_t clock_khz, 55struct Videomode videomode_from_timings(uint32_t clock_khz,
diff --git a/kms++/src/videomode.cpp b/kms++/src/videomode.cpp
index 4964a57..b8bd797 100644
--- a/kms++/src/videomode.cpp
+++ b/kms++/src/videomode.cpp
@@ -1,6 +1,7 @@
1#include <xf86drm.h> 1#include <xf86drm.h>
2#include <xf86drmMode.h> 2#include <xf86drmMode.h>
3#include <math.h> 3#include <math.h>
4#include <sstream>
4 5
5#include <kms++/kms++.h> 6#include <kms++/kms++.h>
6#include "helpers.h" 7#include "helpers.h"
@@ -87,6 +88,16 @@ void Videomode::set_vsync(SyncPolarity pol)
87 } 88 }
88} 89}
89 90
91string Videomode::to_string() const
92{
93 std::stringstream ss;
94 ss << hdisplay << "x" << vdisplay;
95 if (interlace())
96 ss << "i";
97 ss << "@" << calculated_vrefresh();
98 return ss.str();
99}
100
90Videomode videomode_from_timings(uint32_t clock_khz, 101Videomode videomode_from_timings(uint32_t clock_khz,
91 uint16_t hact, uint16_t hfp, uint16_t hsw, uint16_t hbp, 102 uint16_t hact, uint16_t hfp, uint16_t hsw, uint16_t hbp,
92 uint16_t vact, uint16_t vfp, uint16_t vsw, uint16_t vbp) 103 uint16_t vact, uint16_t vfp, uint16_t vsw, uint16_t vbp)