From 87d2fa5f849b0877b75d29113ec7dd3613827904 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 16 Jan 2014 14:01:04 +0100 Subject: eglfs: Allow using a different framebuffer device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Right now /dev/fb0 is hardcoded. This is not ideal. Therefore QT_QPA_EGLFS_FB is introduced. This environment variable can be set to a different framebuffer device. Once it is set, eglfs will use the specific device. This is similar to linuxfb's fb=... plugin parameter. The actual behavior depends on the board-specific implementations. For now only iMX6 has real support. It extracts the index from the device name as bind the EGL display to the corresponding framebuffer using the vendor-specific fbGetDisplayByIndex(). Other hooks can follow suit later on. With this patch eglfs is at least on par with linuxfb, meaning that, if the board supports it, different apps can run on different screens. Task-number: QTBUG-36113 Change-Id: Ia3c88bd06e108bc668433e3c5c3fce34a5a0e73d Reviewed-by: Jørgen Lind --- src/plugins/platforms/eglfs/qeglfshooks.h | 3 ++- src/plugins/platforms/eglfs/qeglfshooks_stub.cpp | 26 ++++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) (limited to 'src') 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 #include #include @@ -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() -- cgit v1.2.3