summaryrefslogtreecommitdiff
path: root/kms++/src/modedb.cpp
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2016-09-29 10:55:19 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-09-29 11:21:20 +0300
commit8e3d7e30e34ffb181a600e12e74727737e0c1f76 (patch)
tree631d2ef472a9ce9c51a58393bbbdaa9cbef3c0f7 /kms++/src/modedb.cpp
parent8170f7a37747c3a414b8ad45bb587adcdac6e0da (diff)
Improve mode finding
Change calculated_vrefresh to round to 2 decimals, and do two rounds when looking for a mode: first look for exact vrefresh match, then look for rounded match. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'kms++/src/modedb.cpp')
-rw-r--r--kms++/src/modedb.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/kms++/src/modedb.cpp b/kms++/src/modedb.cpp
index 858c3d0..5d5d373 100644
--- a/kms++/src/modedb.cpp
+++ b/kms++/src/modedb.cpp
@@ -20,7 +20,24 @@ static const Videomode& find_from_table(const Videomode* modes, uint32_t width,
if (ilace != m.interlace())
continue;
- if (vrefresh && std::abs(m.calculated_vrefresh() - vrefresh) >= 0.001)
+ if (vrefresh && vrefresh != m.calculated_vrefresh())
+ continue;
+
+ return m;
+ }
+
+ // If not found, do another round using rounded vrefresh
+
+ for (unsigned i = 0; modes[i].clock; ++i) {
+ const Videomode& m = modes[i];
+
+ if (m.hdisplay != width || m.vdisplay != height)
+ continue;
+
+ if (ilace != m.interlace())
+ continue;
+
+ if (vrefresh && vrefresh != roundf(m.calculated_vrefresh()))
continue;
return m;