Videomode: add to_string()
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 20 Oct 2017 08:32:18 +0000 (11:32 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 20 Oct 2017 08:32:18 +0000 (11:32 +0300)
kms++/inc/kms++/videomode.h
kms++/src/videomode.cpp

index 39e56395c91193c1043ab6c4062a38f13b38d9ae..d7f5258c039dfbff3f640d2d975786d882ca971e 100644 (file)
@@ -48,6 +48,8 @@ struct Videomode
        void set_interlace(bool ilace);
        void set_hsync(SyncPolarity pol);
        void set_vsync(SyncPolarity pol);
+
+       std::string to_string() const;
 };
 
 struct Videomode videomode_from_timings(uint32_t clock_khz,
index 4964a577573c4ca7200e4e33970f4e62bbc37c5d..b8bd797107600c5c886875c816ca6814a9ece921 100644 (file)
@@ -1,6 +1,7 @@
 #include <xf86drm.h>
 #include <xf86drmMode.h>
 #include <math.h>
+#include <sstream>
 
 #include <kms++/kms++.h>
 #include "helpers.h"
@@ -87,6 +88,16 @@ void Videomode::set_vsync(SyncPolarity pol)
        }
 }
 
+string Videomode::to_string() const
+{
+       std::stringstream ss;
+       ss << hdisplay << "x" << vdisplay;
+       if (interlace())
+               ss << "i";
+       ss << "@" << calculated_vrefresh();
+       return ss.str();
+}
+
 Videomode videomode_from_timings(uint32_t clock_khz,
                                 uint16_t hact, uint16_t hfp, uint16_t hsw, uint16_t hbp,
                                 uint16_t vact, uint16_t vfp, uint16_t vsw, uint16_t vbp)