From dffa01a438f971089f6609bc8c2406ca19fba724 Mon Sep 17 00:00:00 2001 From: Timo Aarnipuro Date: Tue, 21 Nov 2017 13:09:09 +0200 Subject: Add EGLFS integration plugin for Salvator-X on INTEGRITY Multivisor This plugin uses the Renesas RISP Window Manager. Change-Id: If813c46ab8d39e966c0a969610841867885dd473 Reviewed-by: Laszlo Agocs --- .../eglfs/deviceintegration/deviceintegration.pro | 1 + .../deviceintegration/eglfs_rcar/eglfs_rcar.json | 3 + .../deviceintegration/eglfs_rcar/eglfs_rcar.pro | 19 +++ .../eglfs_rcar/qeglfsrcarintegration.cpp | 159 +++++++++++++++++++++ .../eglfs_rcar/qeglfsrcarintegration.h | 66 +++++++++ .../eglfs_rcar/qeglfsrcarmain.cpp | 57 ++++++++ 6 files changed, 305 insertions(+) create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/eglfs_rcar.json create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/eglfs_rcar.pro create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.cpp create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.h create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarmain.cpp (limited to 'src/plugins') diff --git a/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro b/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro index 2cddbe9beb..92ee83fd8f 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro @@ -7,6 +7,7 @@ qtConfig(eglfs_egldevice): SUBDIRS *= eglfs_kms_support eglfs_kms_egldevice qtConfig(eglfs_brcm): SUBDIRS += eglfs_brcm qtConfig(eglfs_mali): SUBDIRS += eglfs_mali qtConfig(eglfs_viv): SUBDIRS += eglfs_viv +qtConfig(eglfs_rcar): SUBDIRS += eglfs_rcar qtConfig(eglfs_viv_wl): SUBDIRS += eglfs_viv_wl qtConfig(eglfs_openwfd): SUBDIRS += eglfs_openwfd qtConfig(opengl): SUBDIRS += eglfs_emu diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/eglfs_rcar.json b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/eglfs_rcar.json new file mode 100644 index 0000000000..77b3083eef --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/eglfs_rcar.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "eglfs_rcar" ] +} diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/eglfs_rcar.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/eglfs_rcar.pro new file mode 100644 index 0000000000..04236449a0 --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/eglfs_rcar.pro @@ -0,0 +1,19 @@ +TARGET = qeglfs-rcar-integration + +QT += core-private gui-private eglfsdeviceintegration-private + +INCLUDEPATH += $$PWD/../../api +CONFIG += egl +DEFINES += LINUX=1 EGL_API_FB=1 +QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF + +SOURCES += $$PWD/qeglfsrcarmain.cpp \ + $$PWD/qeglfsrcarintegration.cpp + +HEADERS += $$PWD/qeglfsrcarintegration.h + +OTHER_FILES += $$PWD/eglfs_rcar.json + +PLUGIN_TYPE = egldeviceintegrations +PLUGIN_CLASS_NAME = QEglFSRcarIntegrationPlugin +load(qt_plugin) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.cpp new file mode 100644 index 0000000000..98cf1d3bfb --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include "INTEGRITY.h" +#include "qeglfsrcarintegration.h" + +#define RCAR_DEFAULT_DISPLAY 1 +#define RCAR_DEFAULT_WM_LAYER 2 + +extern "C" unsigned long PVRGrfxServerInit(void); + +QT_BEGIN_NAMESPACE + +void QEglFSRcarIntegration::platformInit() +{ + QEglFSDeviceIntegration::platformInit(); + + PVRGrfxServerInit(); + + mScreenSize = q_screenSizeFromFb(0); + mNativeDisplay = (NativeDisplayType)EGL_DEFAULT_DISPLAY; +} + +QSize QEglFSRcarIntegration::screenSize() const +{ + return mScreenSize; +} + +EGLNativeDisplayType QEglFSRcarIntegration::platformDisplay() const +{ + return mNativeDisplay; +} + +static r_wm_WinColorFmt_t getWMColorFormat(const QSurfaceFormat &format) +{ + const int a = format.alphaBufferSize(); + const int r = format.redBufferSize(); + const int g = format.greenBufferSize(); + const int b = format.blueBufferSize(); + + switch (r) { + case 4: + if (g == 4 && b == 4 && a == 4) + return R_WM_COLORFMT_ARGB4444; + break; + case 5: + if (g == 6 && b == 5 && a == 0) + return R_WM_COLORFMT_RGB565; + else if (g == 5 && b == 5 && a == 1) + return R_WM_COLORFMT_ARGB1555; + break; + case 8: + if (g == 8 && b == 8 && a == 0) + return R_WM_COLORFMT_RGB0888; + else if (g == 8 && b == 8 && a == 8) + return R_WM_COLORFMT_ARGB8888; + break; + } + + qFatal("Unsupported color format: R:%d G:%d B:%d A:%d", r, g, b, a); + return R_WM_COLORFMT_LAST; +} + +EGLNativeWindowType QEglFSRcarIntegration::createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format) +{ + bool ok; + + mNativeDisplayID = qEnvironmentVariableIntValue("QT_QPA_WM_DISP_ID", &ok); + if (!ok) + mNativeDisplayID = RCAR_DEFAULT_DISPLAY; + + r_wm_Error_t wm_err = R_WM_DevInit(mNativeDisplayID); + if (wm_err != R_WM_ERR_OK) + qFatal("Failed to init WM Dev: %d, error: %d", mNativeDisplayID, wm_err); + + mNativeWindow = (EGLNativeWindowTypeREL*)malloc(sizeof(EGLNativeWindowTypeREL)); + memset(mNativeWindow, 0, sizeof(EGLNativeWindowTypeREL)); + + mNativeWindow->ColorFmt = getWMColorFormat(format); + mNativeWindow->PosX = 0; + mNativeWindow->PosY = 0; + mNativeWindow->PosZ = qEnvironmentVariableIntValue("QT_QPA_WM_LAYER", &ok); + if (!ok) + mNativeWindow->PosZ = RCAR_DEFAULT_WM_LAYER; + mNativeWindow->Pitch = size.width(); + mNativeWindow->Width = size.width(); + mNativeWindow->Height = size.height(); + mNativeWindow->Alpha = format.alphaBufferSize(); + + if (format.swapBehavior() == QSurfaceFormat::DefaultSwapBehavior) + mNativeWindow->Surface.BufNum = 3; + else + mNativeWindow->Surface.BufNum = format.swapBehavior(); + + mNativeWindow->Surface.Type = R_WM_SURFACE_FB; + mNativeWindow->Surface.BufMode = R_WM_WINBUF_ALLOC_INTERNAL; + + wm_err = R_WM_WindowCreate(mNativeDisplayID, mNativeWindow); + if (wm_err != R_WM_ERR_OK) + qFatal("Failed to create window layer: %d", wm_err); + wm_err = R_WM_DevEventRegister(mNativeDisplayID, R_WM_EVENT_VBLANK, 0); + if (wm_err != R_WM_ERR_OK) + qFatal("Failed to Register vsync event: %d", wm_err); + wm_err = R_WM_WindowEnable(mNativeDisplayID, mNativeWindow); + if (wm_err != R_WM_ERR_OK) + qFatal("Failed to Enable window surface: %d", wm_err); + + return static_cast(mNativeWindow); +} + +void QEglFSRcarIntegration::destroyNativeWindow(EGLNativeWindowType window) +{ + R_WM_WindowDisable(mNativeDisplayID, mNativeWindow); + usleep(100000); //Needed to allow Window Manager make the window transparent + R_WM_WindowDelete(mNativeDisplayID, mNativeWindow); + R_WM_DevDeinit(mNativeDisplayID); + free(mNativeWindow); +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.h new file mode 100644 index 0000000000..08911594f9 --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QEGLFSVIVINTEGRATION_H +#define QEGLFSVIVINTEGRATION_H + +#include "private/qeglfsdeviceintegration_p.h" +#include "EGL/eglext_REL.h" + +QT_BEGIN_NAMESPACE + +class QEglFSRcarIntegration : public QEglFSDeviceIntegration +{ +public: + void platformInit() override; + QSize screenSize() const override; + EGLNativeWindowType createNativeWindow(QPlatformWindow *window, const QSize &size, const QSurfaceFormat &format) override; + void destroyNativeWindow(EGLNativeWindowType window) override; + EGLNativeDisplayType platformDisplay() const override; + +private: + QSize mScreenSize; + EGLNativeDisplayType mNativeDisplay; + EGLNativeWindowTypeREL *mNativeWindow; + int mNativeDisplayID; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarmain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarmain.cpp new file mode 100644 index 0000000000..6cf3e1387d --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarmain.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "INTEGRITY.h" +#include "private/qeglfsdeviceintegration_p.h" +#include "qeglfsrcarintegration.h" + +QT_BEGIN_NAMESPACE + +class QEglFSRcarIntegrationPlugin : public QEglFSDeviceIntegrationPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_rcar.json") + +public: + QEglFSDeviceIntegration *create() override { return new QEglFSRcarIntegration; } +}; + +QT_END_NAMESPACE + +#include "qeglfsrcarmain.moc" -- cgit v1.2.3