summaryrefslogtreecommitdiff
path: root/kms++/src/modedb.cpp
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-11 21:46:24 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-11 21:46:24 +0300
commit9916712a62169606d845510028a3ea6f84bd442f (patch)
treeaca4e1bec39500812111c43a8ecee862edae0002 /kms++/src/modedb.cpp
parent736b295100ce441e800457bcbd08cb36db543ff2 (diff)
kms++: organize into subdirs
Diffstat (limited to 'kms++/src/modedb.cpp')
-rw-r--r--kms++/src/modedb.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/kms++/src/modedb.cpp b/kms++/src/modedb.cpp
new file mode 100644
index 0000000..24d6f63
--- /dev/null
+++ b/kms++/src/modedb.cpp
@@ -0,0 +1,41 @@
+#include <xf86drm.h>
+#include <stdexcept>
+
+#include <kms++/modedb.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);
+}
+
+}