diff options
author | Jyri Sarha <jsarha@ti.com> | 2015-09-29 09:33:26 +0300 |
---|---|---|
committer | Jyri Sarha <jsarha@ti.com> | 2015-09-29 12:30:24 +0300 |
commit | 72ae35660c451a9618dbabeefcbc4ec171482e07 (patch) | |
tree | cae70d4534a4c4f641558ff569810f26eb6b4872 /libkms++ | |
parent | 0bdc88a432d0b9581606e86e53d686b91def4002 (diff) |
Add get_mode(const char *mode) to Connector class.
Diffstat (limited to 'libkms++')
-rw-r--r-- | libkms++/connector.cpp | 12 | ||||
-rw-r--r-- | libkms++/connector.h | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/libkms++/connector.cpp b/libkms++/connector.cpp index ee14af9..d26d7e1 100644 --- a/libkms++/connector.cpp +++ b/libkms++/connector.cpp @@ -89,6 +89,18 @@ Videomode Connector::get_default_mode() const 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; diff --git a/libkms++/connector.h b/libkms++/connector.h index b7d975c..b29c071 100644 --- a/libkms++/connector.h +++ b/libkms++/connector.h @@ -34,6 +34,8 @@ public: 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; |