eglfs: Introduce hooks for the eglfs plugin

EGL provides an api to create a rendering context for khronos APIs
on native surfaces. The board initialization and window creation
is platform specific.

This commit adds platform hooks/extensions to the EGLFS plugin and
implements them for the Amlogic 8726M. The hook interface is internal
and there are no ABI/API guarantees.

EGLFS is now linked with -Wl,-no-undefined to make sure that a hook does not
add unresolvable symbols.

Change-Id: I7f4fcdb422aacbf00de468f4d8e85ae5368bfacf
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
Girish Ramakrishnan 2012-03-16 16:52:39 -07:00 committed by Qt by Nokia
parent 246c16e000
commit 24afb1097d
7 changed files with 197 additions and 8 deletions

View File

@ -0,0 +1,95 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the qmake spec of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qeglfs_hooks.h"
#include <EGL/fbdev_window.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/fb.h>
void QEglFSHooks::platformInit()
{
}
void QEglFSHooks::platformDestroy()
{
}
EGLNativeDisplayType QEglFSHooks::platformDisplay() const
{
return EGL_DEFAULT_DISPLAY;
}
QSize QEglFSHooks::screenSize() const
{
int fd = open("/dev/fb0", O_RDONLY);
if (fd == -1) {
qFatal("Failed to open fb to detect screen resolution!");
}
struct fb_var_screeninfo vinfo;
if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) == -1) {
qFatal("Could not get variable screen info");
}
close(fd);
return QSize(vinfo.xres, vinfo.yres);
}
EGLNativeWindowType QEglFSHooks::createNativeWindow(const QSize &size)
{
fbdev_window *window = new fbdev_window;
window->width = size.width();
window->height = size.height();
return window;
}
void QEglFSHooks::destroyNativeWindow(EGLNativeWindowType window)
{
delete window;
}
QEglFSHooks platform_hooks;

View File

@ -31,4 +31,6 @@ QMAKE_CXXFLAGS_RELEASE += $$QMAKE_CFLAGS_RELEASE
deviceSanityCheckCompiler()
EGLFS_PLATFORM_HOOKS_SOURCES = $$PWD/qeglfs_hooks_8726m.cpp
load(qt_config)

View File

@ -21,7 +21,16 @@ SOURCES = main.cpp \
HEADERS = qeglfsintegration.h \
qeglfswindow.h \
qeglfsbackingstore.h \
qeglfsscreen.h
qeglfsscreen.h \
qeglfs_hooks.h
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
!isEmpty(EGLFS_PLATFORM_HOOKS_SOURCES) {
HEADERS += $$EGLFS_PLATFORM_HOOKS_HEADERS
SOURCES += $$EGLFS_PLATFORM_HOOKS_SOURCES
DEFINES += EGLFS_PLATFORM_HOOKS
}
CONFIG += egl qpa/genericunixfontdatabase

View File

@ -0,0 +1,61 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QEGLFS_HOOKS_H
#define QEGLFS_HOOKS_H
#include "qplatformintegration_qpa.h"
#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
struct QEglFSHooks {
void platformInit();
void platformDestroy();
EGLNativeDisplayType platformDisplay() const;
QSize screenSize() const;
EGLNativeWindowType createNativeWindow(const QSize &size);
void destroyNativeWindow(EGLNativeWindowType window);
};
QT_END_NAMESPACE
#endif

View File

@ -43,6 +43,7 @@
#include "qeglfswindow.h"
#include "qeglfsbackingstore.h"
#include "qeglfs_hooks.h"
#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
@ -57,7 +58,7 @@
QT_BEGIN_NAMESPACE
QEglFSIntegration::QEglFSIntegration()
: mFontDb(new QGenericUnixFontDatabase()), mScreen(new QEglFSScreen(EGL_DEFAULT_DISPLAY))
: mFontDb(new QGenericUnixFontDatabase()), mScreen(new QEglFSScreen)
{
screenAdded(mScreen);

View File

@ -41,6 +41,7 @@
#include "qeglfsscreen.h"
#include "qeglfswindow.h"
#include "qeglfs_hooks.h"
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
@ -52,6 +53,13 @@
QT_BEGIN_NAMESPACE
#ifdef EGLFS_PLATFORM_HOOKS
extern QEglFSHooks platform_hooks;
static QEglFSHooks *hooks = &platform_hooks;
#else
static QEglFSHooks *hooks = 0;
#endif
// #define QEGL_EXTRA_DEBUG
#ifdef QEGL_EXTRA_DEBUG
@ -104,16 +112,20 @@ public:
}
};
QEglFSScreen::QEglFSScreen(EGLNativeDisplayType display)
QEglFSScreen::QEglFSScreen()
: m_depth(32)
, m_format(QImage::Format_Invalid)
, m_platformContext(0)
, m_surface(0)
, m_window(0)
{
#ifdef QEGL_EXTRA_DEBUG
qWarning("QEglScreen %p\n", this);
#endif
if (hooks)
hooks->platformInit();
EGLint major, minor;
if (!eglBindAPI(EGL_OPENGL_ES_API)) {
@ -121,7 +133,7 @@ QEglFSScreen::QEglFSScreen(EGLNativeDisplayType display)
qFatal("EGL error");
}
m_dpy = eglGetDisplay(display);
m_dpy = eglGetDisplay(hooks ? hooks->platformDisplay() : EGL_DEFAULT_DISPLAY);
if (m_dpy == EGL_NO_DISPLAY) {
qWarning("Could not open egl display\n");
qFatal("EGL error");
@ -151,7 +163,13 @@ QEglFSScreen::~QEglFSScreen()
if (m_surface)
eglDestroySurface(m_dpy, m_surface);
if (hooks)
hooks->destroyNativeWindow(m_window);
eglTerminate(m_dpy);
if (hooks)
hooks->platformDestroy();
}
void QEglFSScreen::createAndSetPlatformContext() const {
@ -185,14 +203,16 @@ void QEglFSScreen::createAndSetPlatformContext()
EGLConfig config = q_configFromGLFormat(m_dpy, platformFormat);
EGLNativeWindowType eglWindow = 0;
#ifdef Q_OPENKODE
if (kdInitializeNV() == KD_ENOTINITIALIZED) {
qFatal("Did not manage to initialize openkode");
}
KDWindow *window = kdCreateWindow(m_dpy,config,0);
kdRealizeWindow(window,&eglWindow);
kdRealizeWindow(window, &m_window);
#else
if (hooks)
m_window = hooks->createNativeWindow(hooks->screenSize());
#endif
#ifdef QEGL_EXTRA_DEBUG
@ -209,7 +229,7 @@ void QEglFSScreen::createAndSetPlatformContext()
qWarning("\n");
#endif
m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow, NULL);
m_surface = eglCreateWindowSurface(m_dpy, config, m_window, NULL);
if (m_surface == EGL_NO_SURFACE) {
qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError());
eglTerminate(m_dpy);

View File

@ -55,7 +55,7 @@ class QPlatformOpenGLContext;
class QEglFSScreen : public QPlatformScreen //huh: FullScreenScreen ;) just to follow namespace
{
public:
QEglFSScreen(EGLNativeDisplayType display);
QEglFSScreen();
~QEglFSScreen();
QRect geometry() const;
@ -76,6 +76,7 @@ private:
QPlatformOpenGLContext *m_platformContext;
EGLDisplay m_dpy;
EGLSurface m_surface;
EGLNativeWindowType m_window;
};
QT_END_NAMESPACE