summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/eglconvenience/qeglconvenience.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-03-13 11:47:25 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-03-14 17:33:21 +0000
commitf925c13c0125b9d8159116c9b41bb01d2702bf5f (patch)
tree6e402d8525327a00ebca36ab8d515068d55ec905 /src/platformsupport/eglconvenience/qeglconvenience.cpp
parent4da66d5dbf6b1752bdaff5d13b20531608081b70 (diff)
eglfs: Report the QScreen refresh rate from eglfs
For KMS we can always know the correct rate so report it from the backend's custom screen implementation. For the rest, query from the framebuffer. If the fb driver publishes the timings then we can calculate the vertical refresh rate from them. If not, default to 60. Task-number: QTBUG-44971 Change-Id: I854a34e7c0d652790cc2ac967715828ec76f5733 Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
Diffstat (limited to 'src/platformsupport/eglconvenience/qeglconvenience.cpp')
-rw-r--r--src/platformsupport/eglconvenience/qeglconvenience.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp
index 011e2c2961..922455c96f 100644
--- a/src/platformsupport/eglconvenience/qeglconvenience.cpp
+++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp
@@ -576,6 +576,33 @@ int q_screenDepthFromFb(int framebufferDevice)
return depth;
}
+qreal q_refreshRateFromFb(int framebufferDevice)
+{
+ static qreal rate = 0;
+
+#ifdef Q_OS_LINUX
+ if (rate == 0) {
+ if (framebufferDevice != -1) {
+ struct fb_var_screeninfo vinfo;
+ if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, &vinfo) != -1) {
+ const quint64 quot = quint64(vinfo.left_margin + vinfo.right_margin + vinfo.xres + vinfo.hsync_len)
+ * quint64(vinfo.upper_margin + vinfo.lower_margin + vinfo.yres + vinfo.vsync_len)
+ * vinfo.pixclock;
+ if (quot)
+ rate = 1000000000000LLU / quot;
+ } else {
+ qWarning("eglconvenience: Could not query screen info");
+ }
+ }
+ }
+#endif
+
+ if (rate == 0)
+ rate = 60;
+
+ return rate;
+}
+
#endif // Q_OS_UNIX
QT_END_NAMESPACE