summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libkms++/connector.cpp19
-rw-r--r--libkms++/connector.h1
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;