aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Valkeinen2017-10-20 03:33:31 -0500
committerTomi Valkeinen2017-10-20 03:33:31 -0500
commit3da8bff960177bbbd2dc86849846e3b6ec97bc79 (patch)
tree1cc343f7dcc8451cf30b6ebcce5d6aeede74d5ae
parent32255b811edae510304389de4e30fe3e4aaa9ab7 (diff)
downloadexternal-kmsxx-3da8bff960177bbbd2dc86849846e3b6ec97bc79.tar.gz
external-kmsxx-3da8bff960177bbbd2dc86849846e3b6ec97bc79.tar.xz
external-kmsxx-3da8bff960177bbbd2dc86849846e3b6ec97bc79.zip
Connector: improve get_mode(string)
-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