aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'kms++/src/connector.cpp')
-rw-r--r--kms++/src/connector.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/kms++/src/connector.cpp b/kms++/src/connector.cpp
index 9141431..47759be 100644
--- a/kms++/src/connector.cpp
+++ b/kms++/src/connector.cpp
@@ -130,11 +130,24 @@ Videomode Connector::get_mode(const string& mode) const
130{ 130{
131 auto c = m_priv->drm_connector; 131 auto c = m_priv->drm_connector;
132 132
133 for (int i = 0; i < c->count_modes; i++) 133 size_t idx = mode.find('@');
134 if (mode == c->modes[i].name)
135 return drm_mode_to_video_mode(c->modes[i]);
136 134
137 throw invalid_argument(mode + ": mode not found"); 135 string name = idx == string::npos ? mode : mode.substr(0, idx);
136 float vrefresh = idx == string::npos ? 0.0 : stod(mode.substr(idx + 1));
137
138 for (int i = 0; i < c->count_modes; i++) {
139 Videomode m = drm_mode_to_video_mode(c->modes[i]);
140
141 if (m.name != name)
142 continue;
143
144 if (vrefresh && vrefresh != m.calculated_vrefresh())
145 continue;
146
147 return m;
148 }
149
150 throw invalid_argument(mode + ": mode not found");
138} 151}
139 152
140Videomode Connector::get_mode(unsigned xres, unsigned yres, float vrefresh, bool ilace) const 153Videomode Connector::get_mode(unsigned xres, unsigned yres, float vrefresh, bool ilace) const