summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4780d98)
raw | patch | inline | side by side (parent: 4780d98)
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Mon, 15 Aug 2016 09:25:47 +0000 (12:25 +0300) | ||
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Mon, 15 Aug 2016 09:28:04 +0000 (12:28 +0300) |
index 6ccc9599973a6eefc4372aeb6381d1495d4a57ee..ccd77281eebd1df686ac7caadbfc1963b46009b1 100644 (file)
Videomode get_default_mode() const;
Videomode get_mode(const std::string& mode) const;
- Videomode get_mode(unsigned xres, unsigned yres, unsigned refresh, bool ilace) const;
+ Videomode get_mode(unsigned xres, unsigned yres, float vrefresh, bool ilace) const;
Crtc* get_current_crtc() const;
std::vector<Crtc*> get_possible_crtcs() const;
index 43c7afcf2bc925c2a0c62525a1012d98eba01039..b6447c653b1cdd8503d05c5d1e5689250d3ed3a5 100644 (file)
--- a/kms++/inc/kms++/modedb.h
+++ b/kms++/inc/kms++/modedb.h
extern const Videomode dmt_modes[];
extern const Videomode cea_modes[];
-const Videomode& find_dmt(uint32_t width, uint32_t height, uint32_t vrefresh, bool ilace);
-const Videomode& find_cea(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);
+const Videomode& find_cea(uint32_t width, uint32_t height, float vrefresh, bool ilace);
}
index ec37d5d3562222743abaef4a22055e4689c660cd..92700af0961440919fd7e0a43605cca9b6e2c69d 100644 (file)
--- a/kms++/src/connector.cpp
+++ b/kms++/src/connector.cpp
#include <unistd.h>
#include <fcntl.h>
#include <cassert>
+#include <cmath>
#include <kms++/kms++.h>
#include "helpers.h"
throw invalid_argument(mode + ": mode not found");
}
-Videomode Connector::get_mode(unsigned xres, unsigned yres, unsigned refresh, bool ilace) const
+Videomode Connector::get_mode(unsigned xres, unsigned yres, float vrefresh, bool ilace) const
{
auto c = m_priv->drm_connector;
for (int i = 0; i < c->count_modes; i++) {
- drmModeModeInfo& m = c->modes[i];
+ Videomode m = drm_mode_to_video_mode(c->modes[i]);
if (m.hdisplay != xres || m.vdisplay != yres)
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 drm_mode_to_video_mode(c->modes[i]);
+ return m;
}
throw invalid_argument("mode not found");
diff --git a/kms++/src/modedb.cpp b/kms++/src/modedb.cpp
index 24d6f63d1d22de2e9e64d9ddf0734f00fcda2be2..858c3d07f26ed428454d1d4499fdf65781d52340 100644 (file)
--- a/kms++/src/modedb.cpp
+++ b/kms++/src/modedb.cpp
#include <xf86drm.h>
#include <stdexcept>
+#include <cmath>
#include <kms++/modedb.h>
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];
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;
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);
}
}
diff --git a/py/pykmsbase.cpp b/py/pykmsbase.cpp
index 637e4f59cdc7e896b1ca21f69fe1f3c6a14c7dc3..3ce56761752b5e957d9adedb3a639ae1701b332d 100644 (file)
--- a/py/pykmsbase.cpp
+++ b/py/pykmsbase.cpp
.def("get_possible_crtcs", &Connector::get_possible_crtcs)
.def("get_modes", &Connector::get_modes)
.def("get_mode", (Videomode (Connector::*)(const string& mode) const)&Connector::get_mode)
- .def("get_mode", (Videomode (Connector::*)(unsigned xres, unsigned yres, unsigned refresh, bool ilace) const)&Connector::get_mode)
+ .def("get_mode", (Videomode (Connector::*)(unsigned xres, unsigned yres, float refresh, bool ilace) const)&Connector::get_mode)
.def("__repr__", [](const Connector& o) { return "<pykms.Connector " + to_string(o.id()) + ">"; })
;
diff --git a/utils/testpat.cpp b/utils/testpat.cpp
index 4cde7c1783fe4fe1d3c6e0ade9dfd2520726b0dd..ccddccbc7f27d6db9a89c48199179c3e20af1296 100644 (file)
--- a/utils/testpat.cpp
+++ b/utils/testpat.cpp
static void parse_crtc(Card& card, const string& crtc_str, OutputInfo& output)
{
// @12:1920x1200@60
- const regex mode_re("(?:(@?)(\\d+):)?(?:(\\d+)x(\\d+)(i)?)(?:@(\\d+))?");
+ const regex mode_re("(?:(@?)(\\d+):)?(?:(\\d+)x(\\d+)(i)?)(?:@([\\d\\.]+))?");
smatch sm;
if (!regex_match(crtc_str, sm, mode_re))
unsigned w = stoul(sm[3]);
unsigned h = stoul(sm[4]);
bool ilace = sm[5].matched ? true : false;
- unsigned refresh = sm[6].matched ? stoul(sm[6]) : 0;
+ float refresh = sm[6].matched ? stof(sm[6]) : 0;
bool found_mode = false;