diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2015-11-13 19:26:02 +0200 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2015-11-13 22:12:41 +0200 |
commit | 98773593e11a399dcfe3cf0656dca5022a9b2547 (patch) | |
tree | 15c893cbe98ac9cc3c722cf6ed429be543bb863d | |
parent | de716254d983a05402a593793480ee1e5ee9e97e (diff) |
Connector: add get_mode(xres, yres, refresh)
-rw-r--r-- | libkms++/connector.cpp | 19 | ||||
-rw-r--r-- | libkms++/connector.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/libkms++/connector.cpp b/libkms++/connector.cpp index e507c9e..5a6fdd9 100644 --- a/libkms++/connector.cpp +++ b/libkms++/connector.cpp @@ -114,6 +114,25 @@ Videomode Connector::get_mode(const string& mode) const throw invalid_argument(mode + ": mode not found"); } +Videomode Connector::get_mode(unsigned xres, unsigned yres, unsigned refresh) const +{ + auto c = m_priv->drm_connector; + + for (int i = 0; i < c->count_modes; i++) { + drmModeModeInfo& m = c->modes[i]; + + if (m.hdisplay != xres || m.vdisplay != yres) + continue; + + if (refresh && m.vrefresh != refresh) + continue; + + return drm_mode_to_video_mode(c->modes[i]); + } + + throw invalid_argument("mode not found"); +} + bool Connector::connected() const { return m_priv->drm_connector->connection == DRM_MODE_CONNECTED || diff --git a/libkms++/connector.h b/libkms++/connector.h index a897d31..cc04d52 100644 --- a/libkms++/connector.h +++ b/libkms++/connector.h @@ -17,6 +17,7 @@ public: Videomode get_default_mode() const; Videomode get_mode(const std::string& mode) const; + Videomode get_mode(unsigned xres, unsigned yres, unsigned refresh) const; Crtc* get_current_crtc() const; std::vector<Crtc*> get_possible_crtcs() const; |