From e04bbf938ce258898565274b8542684295ee6cd4 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 15 Aug 2016 12:25:47 +0300 Subject: support finding fractional vrefresh --- kms++/src/modedb.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'kms++/src/modedb.cpp') diff --git a/kms++/src/modedb.cpp b/kms++/src/modedb.cpp index 24d6f63..858c3d0 100644 --- a/kms++/src/modedb.cpp +++ b/kms++/src/modedb.cpp @@ -1,5 +1,6 @@ #include #include +#include #include @@ -8,7 +9,7 @@ using namespace std; namespace kms { -static const Videomode& find_from_table(const Videomode* modes, uint32_t width, uint32_t height, uint32_t refresh, bool ilace) +static const Videomode& find_from_table(const Videomode* modes, uint32_t width, uint32_t height, float vrefresh, bool ilace) { for (unsigned i = 0; modes[i].clock; ++i) { const Videomode& m = modes[i]; @@ -16,10 +17,10 @@ static const Videomode& find_from_table(const Videomode* modes, uint32_t width, if (m.hdisplay != width || m.vdisplay != height) 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 m; @@ -28,14 +29,14 @@ static const Videomode& find_from_table(const Videomode* modes, uint32_t width, throw invalid_argument("mode not found"); } -const Videomode& find_dmt(uint32_t width, uint32_t height, uint32_t refresh, bool ilace) +const Videomode& find_dmt(uint32_t width, uint32_t height, float vrefresh, bool ilace) { - return find_from_table(dmt_modes, width, height, refresh, ilace); + return find_from_table(dmt_modes, width, height, vrefresh, ilace); } -const Videomode& find_cea(uint32_t width, uint32_t height, uint32_t refresh, bool ilace) +const Videomode& find_cea(uint32_t width, uint32_t height, float vrefresh, bool ilace) { - return find_from_table(cea_modes, width, height, refresh, ilace); + return find_from_table(cea_modes, width, height, vrefresh, ilace); } } -- cgit v1.2.3