summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp2
-rw-r--r--src/plugins/platforms/eglfs/qeglfshooks.h3
-rw-r--r--src/plugins/platforms/eglfs/qeglfshooks_stub.cpp26
3 files changed, 25 insertions, 6 deletions
diff --git a/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp b/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp
index c351e3dbc4..91c29b5ea9 100644
--- a/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp
+++ b/mkspecs/devices/linux-imx6-g++/qeglfshooks_imx6.cpp
@@ -72,7 +72,7 @@ QEglFSImx6Hooks::QEglFSImx6Hooks()
qputenv("FB_MULTI_BUFFER", "2");
}
- mNativeDisplay = fbGetDisplayByIndex(0);
+ mNativeDisplay = fbGetDisplayByIndex(framebufferIndex());
fbGetDisplayGeometry(mNativeDisplay, &width, &height);
mScreenSize.setHeight(height);
mScreenSize.setWidth(width);
diff --git a/src/plugins/platforms/eglfs/qeglfshooks.h b/src/plugins/platforms/eglfs/qeglfshooks.h
index 1cd1380994..0251e27f96 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks.h
+++ b/src/plugins/platforms/eglfs/qeglfshooks.h
@@ -77,7 +77,8 @@ public:
virtual bool filterConfig(EGLDisplay display, EGLConfig config) const;
virtual void waitForVSync() const;
- virtual const char *fbDeviceName() const;
+ virtual QByteArray fbDeviceName() const;
+ virtual int framebufferIndex() const;
static QEglFSHooks *hooks()
{
diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
index 4dc0783d43..4368f37e50 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
+++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
@@ -41,6 +41,7 @@
#include "qeglfshooks.h"
#include "qeglfscursor.h"
+#include <QtCore/QRegularExpression>
#include <fcntl.h>
#include <unistd.h>
@@ -56,17 +57,34 @@ QT_BEGIN_NAMESPACE
// this is a global static to keep the QEglFSHooks interface as clean as possible
static int framebuffer = -1;
-const char *QEglFSHooks::fbDeviceName() const
+QByteArray QEglFSHooks::fbDeviceName() const
{
- return "/dev/fb0";
+ QByteArray fbDev = qgetenv("QT_QPA_EGLFS_FB");
+ if (fbDev.isEmpty())
+ fbDev = QByteArrayLiteral("/dev/fb0");
+
+ return fbDev;
+}
+
+int QEglFSHooks::framebufferIndex() const
+{
+ int fbIndex = 0;
+ QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)"));
+ QRegularExpressionMatch match = fbIndexRx.match(fbDeviceName());
+ if (match.hasMatch())
+ fbIndex = match.captured(1).toInt();
+
+ return fbIndex;
}
void QEglFSHooks::platformInit()
{
- framebuffer = qt_safe_open(fbDeviceName(), O_RDONLY);
+ QByteArray fbDev = fbDeviceName();
+
+ framebuffer = qt_safe_open(fbDev, O_RDONLY);
if (framebuffer == -1)
- qWarning("EGLFS: Failed to open %s", fbDeviceName());
+ qWarning("EGLFS: Failed to open %s", qPrintable(fbDev));
}
void QEglFSHooks::platformDestroy()