Support for Wayland servers on i.MX6

A wayland compositor on i.MX6 needs to create the wl_display
before creating the EGL display. This wl_display then needs to be
exposed so that QWaylandCompositor can use it.

Change-Id: Id60f6dd2fbba05140ca0671da6f17dbc2ecce3a3
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
This commit is contained in:
Paul Olav Tvete 2015-10-29 14:11:29 +01:00 committed by Laszlo Agocs
parent ab1a5f1003
commit 317b9e9c5f
12 changed files with 299 additions and 2 deletions

View File

@ -0,0 +1,5 @@
SOURCES = wl.cpp
CONFIG -= qt
CONFIG += link_pkgconfig
PKGCONFIG += wayland-server

View File

@ -0,0 +1,40 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the config.tests of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <wayland-server.h>
int main(int, char **)
{
wl_display_create();
return 0;
}

10
configure vendored
View File

@ -681,6 +681,7 @@ CFG_EGLFS_BRCM=no
CFG_EGLFS_EGLDEVICE=no
CFG_EGLFS_MALI=no
CFG_EGLFS_VIV=no
CFG_EGLFS_VIV_WL=no
CFG_DIRECTFB=auto
CFG_GBM=auto
CFG_LINUXFB=auto
@ -5776,6 +5777,11 @@ if [ "$CFG_EGLFS" != "no" ]; then
else
CFG_EGLFS_VIV=no
fi
if [ "$CFG_EGLFS_VIV" = "yes" ] && compileTest qpa/wayland-server "wayland-server"; then
CFG_EGLFS_VIV_WL=yes
else
CFG_EGLFS_VIV_WL=no
fi
else
CFG_EGLFS="no"
fi
@ -6222,6 +6228,9 @@ if [ "$CFG_EGLFS_MALI" = "yes" ]; then
fi
if [ "$CFG_EGLFS_VIV" = "yes" ]; then
QT_CONFIG="$QT_CONFIG eglfs_viv"
if [ "$CFG_EGLFS_VIV_WL" = "yes" ]; then
QT_CONFIG="$QT_CONFIG eglfs_viv_wl"
fi
fi
# enable openvg
@ -7299,6 +7308,7 @@ report_support " QPA backends:"
report_support " DirectFB ............." "$CFG_DIRECTFB"
report_support " EGLFS ................" "$CFG_EGLFS"
report_support " EGLFS i.MX6 ........" "$CFG_EGLFS_VIV"
report_support " EGLFS i.MX6 Wayland." "$CFG_EGLFS_VIV_WL"
report_support " EGLFS EGLDevice ...." "$CFG_EGLFS_EGLDEVICE"
report_support " EGLFS GBM .........." "$CFG_EGLFS_GBM"
report_support " EGLFS Mali ........." "$CFG_EGLFS_MALI"

View File

@ -6,3 +6,4 @@ contains(QT_CONFIG, eglfs_egldevice): SUBDIRS += eglfs_kms_egldevice
contains(QT_CONFIG, eglfs_brcm): SUBDIRS += eglfs_brcm
contains(QT_CONFIG, eglfs_mali): SUBDIRS += eglfs_mali
contains(QT_CONFIG, eglfs_viv): SUBDIRS += eglfs_viv
contains(QT_CONFIG, eglfs_viv_wl): SUBDIRS += eglfs_viv_wl

View File

@ -0,0 +1,3 @@
{
"Keys": [ "eglfs_viv_wl" ]
}

View File

@ -0,0 +1,23 @@
TARGET = qeglfs-viv-wl-integration
PLUGIN_TYPE = egldeviceintegrations
PLUGIN_CLASS_NAME = QEglFSVivWaylandIntegrationPlugin
load(qt_plugin)
QT += core-private gui-private platformsupport-private eglfs_device_lib-private
INCLUDEPATH += $$PWD/../..
CONFIG += egl
DEFINES += LINUX=1 EGL_API_FB=1
LIBS += -lGAL
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
SOURCES += $$PWD/qeglfsvivwlmain.cpp \
$$PWD/qeglfsvivwlintegration.cpp
HEADERS += $$PWD/qeglfsvivwlintegration.h
OTHER_FILES += $$PWD/eglfs_viv_wl.json
CONFIG += link_pkgconfig
PKGCONFIG_PRIVATE += wayland-server

View File

@ -0,0 +1,93 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qeglfsvivwlintegration.h"
#include <EGL/eglvivante.h>
#include <QDebug>
#include <wayland-server.h>
QT_BEGIN_NAMESPACE
void QEglFSVivWaylandIntegration::platformInit()
{
QEGLDeviceIntegration::platformInit();
int width, height;
bool multiBufferNotEnabledYet = qEnvironmentVariableIsEmpty("FB_MULTI_BUFFER");
bool multiBuffer = qEnvironmentVariableIsEmpty("QT_EGLFS_IMX6_NO_FB_MULTI_BUFFER");
if (multiBufferNotEnabledYet && multiBuffer) {
qWarning() << "QEglFSVivWaylandIntegration will set environment variable FB_MULTI_BUFFER=2 to enable double buffering and vsync.\n"
<< "If this is not desired, you can override this via: export QT_EGLFS_IMX6_NO_FB_MULTI_BUFFER=1";
qputenv("FB_MULTI_BUFFER", "2");
}
mWaylandDisplay = wl_display_create();
mNativeDisplay = fbGetDisplay(mWaylandDisplay);
fbGetDisplayGeometry(mNativeDisplay, &width, &height);
mScreenSize.setHeight(height);
mScreenSize.setWidth(width);
}
QSize QEglFSVivWaylandIntegration::screenSize() const
{
return mScreenSize;
}
EGLNativeDisplayType QEglFSVivWaylandIntegration::platformDisplay() const
{
return mNativeDisplay;
}
EGLNativeWindowType QEglFSVivWaylandIntegration::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format)
{
Q_UNUSED(window)
Q_UNUSED(format)
EGLNativeWindowType eglWindow = fbCreateWindow(mNativeDisplay, 0, 0, size.width(), size.height());
return eglWindow;
}
void QEglFSVivWaylandIntegration::destroyNativeWindow(EGLNativeWindowType window)
{
fbDestroyWindow(window);
}
void *QEglFSVivWaylandIntegration::wlDisplay() const
{
return mWaylandDisplay;
}
QT_END_NAMESPACE

View File

@ -0,0 +1,60 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QEGLFSVIVINTEGRATION_H
#define QEGLFSVIVINTEGRATION_H
#include "qeglfsdeviceintegration.h"
struct wl_display;
QT_BEGIN_NAMESPACE
class QEglFSVivWaylandIntegration : public QEGLDeviceIntegration
{
public:
void platformInit() Q_DECL_OVERRIDE;
QSize screenSize() const Q_DECL_OVERRIDE;
EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format) Q_DECL_OVERRIDE;
void destroyNativeWindow(EGLNativeWindowType window) Q_DECL_OVERRIDE;
EGLNativeDisplayType platformDisplay() const Q_DECL_OVERRIDE;
void *wlDisplay() const Q_DECL_OVERRIDE;
private:
QSize mScreenSize;
EGLNativeDisplayType mNativeDisplay;
wl_display *mWaylandDisplay;
};
QT_END_NAMESPACE
#endif

View File

@ -0,0 +1,50 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qeglfsdeviceintegration.h"
#include "qeglfsvivwlintegration.h"
QT_BEGIN_NAMESPACE
class QEglFSVivWaylandIntegrationPlugin : public QEGLDeviceIntegrationPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_viv_wl.json")
public:
QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSVivWaylandIntegration; }
};
QT_END_NAMESPACE
#include "qeglfsvivwlmain.moc"

View File

@ -334,4 +334,9 @@ bool QEGLDeviceIntegration::supportsSurfacelessContexts() const
return true;
}
void *QEGLDeviceIntegration::wlDisplay() const
{
return Q_NULLPTR;
}
QT_END_NAMESPACE

View File

@ -97,6 +97,8 @@ public:
virtual int framebufferIndex() const;
virtual bool supportsPBuffers() const;
virtual bool supportsSurfacelessContexts() const;
virtual void *wlDisplay() const;
};
class Q_EGLFS_EXPORT QEGLDeviceIntegrationPlugin : public QObject

View File

@ -251,7 +251,8 @@ enum ResourceType {
EglContext,
EglConfig,
NativeDisplay,
XlibDisplay
XlibDisplay,
WaylandDisplay
};
static int resourceType(const QByteArray &key)
@ -262,7 +263,8 @@ static int resourceType(const QByteArray &key)
QByteArrayLiteral("eglcontext"),
QByteArrayLiteral("eglconfig"),
QByteArrayLiteral("nativedisplay"),
QByteArrayLiteral("display")
QByteArrayLiteral("display"),
QByteArrayLiteral("wl_display")
};
const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
const QByteArray *result = std::find(names, end, key);
@ -282,6 +284,9 @@ void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource
case NativeDisplay:
result = reinterpret_cast<void*>(nativeDisplay());
break;
case WaylandDisplay:
result = qt_egl_device_integration()->wlDisplay();
break;
default:
break;
}