diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2016-08-15 12:25:47 +0300 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2016-08-15 12:28:04 +0300 |
commit | e04bbf938ce258898565274b8542684295ee6cd4 (patch) | |
tree | a57f457333ea8a520eb10f0b70dedf15a88a8422 /kms++/src/connector.cpp | |
parent | 4780d98bfde87f03754c0e0e2fabe68d02958df9 (diff) |
support finding fractional vrefresh
Diffstat (limited to 'kms++/src/connector.cpp')
-rw-r--r-- | kms++/src/connector.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/kms++/src/connector.cpp b/kms++/src/connector.cpp index ec37d5d..92700af 100644 --- a/kms++/src/connector.cpp +++ b/kms++/src/connector.cpp @@ -3,6 +3,7 @@ #include <unistd.h> #include <fcntl.h> #include <cassert> +#include <cmath> #include <kms++/kms++.h> #include "helpers.h" @@ -118,23 +119,23 @@ 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, bool ilace) const +Videomode Connector::get_mode(unsigned xres, unsigned yres, float vrefresh, bool ilace) const { auto c = m_priv->drm_connector; for (int i = 0; i < c->count_modes; i++) { - drmModeModeInfo& m = c->modes[i]; + Videomode m = drm_mode_to_video_mode(c->modes[i]); if (m.hdisplay != xres || m.vdisplay != yres) continue; - if (refresh && m.vrefresh != refresh) + if (ilace != m.interlace()) continue; - if (ilace != !!(m.flags & DRM_MODE_FLAG_INTERLACE)) + if (vrefresh && std::abs(m.calculated_vrefresh() - vrefresh) >= 0.001) continue; - return drm_mode_to_video_mode(c->modes[i]); + return m; } throw invalid_argument("mode not found"); |