From 17d180891f1e237ea5d25835999a8b23a6e7946d Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Sat, 11 Jun 2016 20:17:35 +0300 Subject: rename dirs --- kms++/modedb.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 kms++/modedb.cpp (limited to 'kms++/modedb.cpp') diff --git a/kms++/modedb.cpp b/kms++/modedb.cpp new file mode 100644 index 0000000..53dcfcf --- /dev/null +++ b/kms++/modedb.cpp @@ -0,0 +1,42 @@ +#include +#include + +#include "modedb.h" +#include "videomode.h" + +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) +{ + for (unsigned i = 0; modes[i].clock; ++i) { + const Videomode& m = modes[i]; + + if (m.hdisplay != width || m.vdisplay != height) + continue; + + if (refresh && m.vrefresh != refresh) + continue; + + if (ilace != !!(m.flags & DRM_MODE_FLAG_INTERLACE)) + continue; + + return m; + } + + throw invalid_argument("mode not found"); +} + +const Videomode& find_dmt(uint32_t width, uint32_t height, uint32_t refresh, bool ilace) +{ + return find_from_table(dmt_modes, width, height, refresh, ilace); +} + +const Videomode& find_cea(uint32_t width, uint32_t height, uint32_t refresh, bool ilace) +{ + return find_from_table(cea_modes, width, height, refresh, ilace); +} + +} -- cgit v1.2.3