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>bb10
parent
4da66d5dbf
commit
f925c13c01
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ void q_printEglConfig(EGLDisplay display, EGLConfig config);
|
|||
QSizeF q_physicalScreenSizeFromFb(int framebufferDevice, const QSize &screenSize = QSize());
|
||||
QSize q_screenSizeFromFb(int framebufferDevice);
|
||||
int q_screenDepthFromFb(int framebufferDevice);
|
||||
qreal q_refreshRateFromFb(int framebufferDevice);
|
||||
#endif
|
||||
|
||||
class QEglConfigChooser
|
||||
|
|
|
|||
|
|
@ -303,4 +303,10 @@ void QEglFSKmsScreen::restoreMode()
|
|||
}
|
||||
}
|
||||
|
||||
qreal QEglFSKmsScreen::refreshRate() const
|
||||
{
|
||||
quint32 refresh = m_output.modes[m_output.mode].vrefresh;
|
||||
return refresh > 0 ? refresh : 60;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ public:
|
|||
|
||||
QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
|
||||
|
||||
qreal refreshRate() const Q_DECL_OVERRIDE;
|
||||
|
||||
QEglFSKmsDevice *device() const { return m_device; }
|
||||
|
||||
gbm_surface *surface() const { return m_gbm_surface; }
|
||||
|
|
|
|||
|
|
@ -225,6 +225,11 @@ QImage::Format QEGLDeviceIntegration::screenFormat() const
|
|||
return screenDepth() == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
|
||||
}
|
||||
|
||||
qreal QEGLDeviceIntegration::refreshRate() const
|
||||
{
|
||||
return q_refreshRateFromFb(framebuffer);
|
||||
}
|
||||
|
||||
QSurfaceFormat QEGLDeviceIntegration::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
|
||||
{
|
||||
QSurfaceFormat format = inputFormat;
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ public:
|
|||
virtual Qt::ScreenOrientation orientation() const;
|
||||
virtual int screenDepth() const;
|
||||
virtual QImage::Format screenFormat() const;
|
||||
virtual qreal refreshRate() const;
|
||||
virtual QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &inputFormat) const;
|
||||
virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *platformWindow,
|
||||
const QSize &size,
|
||||
|
|
|
|||
|
|
@ -93,6 +93,11 @@ QPlatformCursor *QEglFSScreen::cursor() const
|
|||
return m_cursor;
|
||||
}
|
||||
|
||||
qreal QEglFSScreen::refreshRate() const
|
||||
{
|
||||
return qt_egl_device_integration()->refreshRate();
|
||||
}
|
||||
|
||||
void QEglFSScreen::setPrimarySurface(EGLSurface surface)
|
||||
{
|
||||
m_surface = surface;
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ public:
|
|||
|
||||
QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
|
||||
|
||||
qreal refreshRate() const Q_DECL_OVERRIDE;
|
||||
|
||||
EGLSurface primarySurface() const { return m_surface; }
|
||||
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Reference in New Issue