]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/blob - kms++/src/modedb.cpp
24d6f63d1d22de2e9e64d9ddf0734f00fcda2be2
[android/external-libkmsxx.git] / kms++ / src / modedb.cpp
1 #include <xf86drm.h>
2 #include <stdexcept>
4 #include <kms++/modedb.h>
6 using namespace std;
8 namespace kms
9 {
11 static const Videomode& find_from_table(const Videomode* modes, uint32_t width, uint32_t height, uint32_t refresh, bool ilace)
12 {
13         for (unsigned i = 0; modes[i].clock; ++i) {
14                 const Videomode& m = modes[i];
16                 if (m.hdisplay != width || m.vdisplay != height)
17                         continue;
19                 if (refresh && m.vrefresh != refresh)
20                         continue;
22                 if (ilace != !!(m.flags & DRM_MODE_FLAG_INTERLACE))
23                         continue;
25                 return m;
26         }
28         throw invalid_argument("mode not found");
29 }
31 const Videomode& find_dmt(uint32_t width, uint32_t height, uint32_t refresh, bool ilace)
32 {
33         return find_from_table(dmt_modes, width, height, refresh, ilace);
34 }
36 const Videomode& find_cea(uint32_t width, uint32_t height, uint32_t refresh, bool ilace)
37 {
38         return find_from_table(cea_modes, width, height, refresh, ilace);
39 }
41 }