Add get_mode(const char *mode) to Connector class.
authorJyri Sarha <jsarha@ti.com>
Tue, 29 Sep 2015 06:33:26 +0000 (09:33 +0300)
committerJyri Sarha <jsarha@ti.com>
Tue, 29 Sep 2015 09:30:24 +0000 (12:30 +0300)
libkms++/connector.cpp
libkms++/connector.h

index ee14af9388c34b0741b6cba3d33a2a0ceab899d6..d26d7e16267f6b780fdaae1ab13b09b97d1018bc 100644 (file)
@@ -89,6 +89,18 @@ Videomode Connector::get_default_mode() const
        return drm_mode_to_video_mode(drmmode);
 }
 
        return drm_mode_to_video_mode(drmmode);
 }
 
+Videomode Connector::get_mode(const char *mode) const
+{
+       auto c = m_priv->drm_connector;
+       string sMode(mode);
+
+       for (int i = 0; i < c->count_modes; i++)
+                if (sMode == c->modes[i].name)
+                        return drm_mode_to_video_mode(c->modes[i]);
+
+        throw invalid_argument((sMode + ": mode not found").c_str());
+}
+
 bool Connector::connected()
 {
        return m_priv->drm_connector->connection == DRM_MODE_CONNECTED;
 bool Connector::connected()
 {
        return m_priv->drm_connector->connection == DRM_MODE_CONNECTED;
index b7d975c16858d4624d1ca95e5096a549b0b9774f..b29c0714491d4e5c0c69880e5470320b79cd633b 100644 (file)
@@ -34,6 +34,8 @@ public:
 
        Videomode get_default_mode() const;
 
 
        Videomode get_default_mode() const;
 
+       Videomode get_mode(const char *mode) const;
+
        Crtc* get_current_crtc() const { return m_current_crtc; }
        std::vector<Crtc*> get_possible_crtcs() const;
 
        Crtc* get_current_crtc() const { return m_current_crtc; }
        std::vector<Crtc*> get_possible_crtcs() const;