summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohannes Zellner <johannes.zellner@nokia.com>2012-06-18 15:18:43 -0700
committerQt by Nokia <qt-info@nokia.com>2012-06-19 00:38:02 +0200
commite7836e6a9a470ba4a5db0b6b48a595faa2df336b (patch)
treee528b341b355db37d95ea2bab19599c71a4f06b4 /src
parent95427b0f40857c42ccf87e66d7bbf6fd2cc3ab83 (diff)
platform hooks: provide defaults for screen size and depth hooks
Default hooks for querying screen size and color depth based on linux fbdev API. Change-Id: I7fc75c0df5e0f507cf679439416fe68c8f62f91d Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/eglfs/qeglfshooks_stub.cpp44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
index 487e483b62..25bf1fdfea 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
+++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
@@ -41,6 +41,11 @@
#include "qeglfshooks.h"
+#include <fcntl.h>
+#include <unistd.h>
+#include <linux/fb.h>
+#include <sys/ioctl.h>
+
QT_BEGIN_NAMESPACE
void QEglFSHooks::platformInit()
@@ -58,13 +63,48 @@ EGLNativeDisplayType QEglFSHooks::platformDisplay() const
QSize QEglFSHooks::screenSize() const
{
- return QSize();
+ static QSize size;
+
+ if (size.isEmpty()) {
+ struct fb_var_screeninfo vinfo;
+ int fd = open("/dev/fb0", O_RDONLY);
+
+ if (fd != -1) {
+ if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) == -1)
+ qWarning("Could not query variable screen info.");
+ else
+ size = QSize(vinfo.xres, vinfo.yres);
+
+ close(fd);
+ } else {
+ qWarning("Failed to open /dev/fb0 to detect screen resolution.");
+ }
+ }
+
+ return size;
}
int QEglFSHooks::screenDepth() const
{
static int depth = qgetenv("QT_QPA_EGLFS_DEPTH").toInt();
- return depth == 16 ? 16 : 32;
+
+ if (depth == 0) {
+ struct fb_var_screeninfo vinfo;
+ int fd = open("/dev/fb0", O_RDONLY);
+
+ if (fd != -1) {
+ if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) == -1)
+ qWarning("Could not query variable screen info.");
+ else
+ depth = vinfo.bits_per_pixel;
+
+ close(fd);
+ } else {
+ qWarning("Failed to open /dev/fb0 to detect screen depth.");
+ }
+ }
+
+ return depth == 0 ? 32 : depth;
}
QImage::Format QEglFSHooks::screenFormat() const