diff options
Diffstat (limited to 'src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support')
16 files changed, 405 insertions, 654 deletions
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/CMakeLists.txt b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/CMakeLists.txt new file mode 100644 index 0000000000..5fcc0e1b18 --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## EglFsKmsSupportPrivate Module: +##################################################################### + +qt_internal_add_module(EglFsKmsSupportPrivate + CONFIG_MODULE_NAME eglfs_kms_support + INTERNAL_MODULE + SOURCES + qeglfskmsdevice.cpp qeglfskmsdevice_p.h + qeglfskmseventreader.cpp qeglfskmseventreader_p.h + qeglfskmshelpers_p.h + qeglfskmsintegration.cpp qeglfskmsintegration_p.h + qeglfskmsscreen.cpp qeglfskmsscreen_p.h + DEFINES + QT_EGL_NO_X11 + PUBLIC_LIBRARIES + Libdrm::Libdrm + Qt::Core + Qt::CorePrivate + Qt::EglFSDeviceIntegrationPrivate + Qt::Gui + Qt::GuiPrivate + Qt::KmsSupportPrivate + NO_GENERATE_CPP_EXPORTS +) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro deleted file mode 100644 index e51903ed96..0000000000 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro +++ /dev/null @@ -1,24 +0,0 @@ -TARGET = QtEglFsKmsSupport -CONFIG += no_module_headers internal_module -load(qt_module) - -QT += core-private gui-private eglfsdeviceintegration-private kms_support-private edid_support-private - -INCLUDEPATH += $$PWD/../../api - -# Avoid X11 header collision, use generic EGL native types -DEFINES += QT_EGL_NO_X11 - -QMAKE_USE += drm -CONFIG += egl - -SOURCES += $$PWD/qeglfskmsintegration.cpp \ - $$PWD/qeglfskmsdevice.cpp \ - $$PWD/qeglfskmsscreen.cpp \ - $$PWD/qeglfskmseventreader.cpp - -HEADERS += $$PWD/qeglfskmsintegration.h \ - $$PWD/qeglfskmsdevice.h \ - $$PWD/qeglfskmsscreen.h \ - $$PWD/qeglfskmshelpers.h \ - $$PWD/qeglfskmseventreader.h diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp index 4f0b0d7725..037b26f023 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp @@ -1,45 +1,9 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Pelagicore AG -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 Pelagicore AG +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#include "qeglfskmsdevice.h" -#include "qeglfskmsscreen.h" +#include "qeglfskmsdevice_p.h" +#include "qeglfskmsscreen_p.h" #include "private/qeglfsintegration_p.h" #include <QtGui/private/qguiapplication_p.h> diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h deleted file mode 100644 index 34908aa60f..0000000000 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Pelagicore AG -** 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 QEGLFSKMSDEVICE_H -#define QEGLFSKMSDEVICE_H - -#include "private/qeglfsglobal_p.h" -#include "qeglfskmseventreader.h" -#include <QtKmsSupport/private/qkmsdevice_p.h> - -QT_BEGIN_NAMESPACE - -class Q_EGLFS_EXPORT QEglFSKmsDevice : public QKmsDevice -{ -public: - QEglFSKmsDevice(QKmsScreenConfig *screenConfig, const QString &path); - - void registerScreen(QPlatformScreen *screen, - bool isPrimary, - const QPoint &virtualPos, - const QList<QPlatformScreen *> &virtualSiblings) override; - - QEglFSKmsEventReader *eventReader() { return &m_eventReader; } - -protected: - QEglFSKmsEventReader m_eventReader; -}; - -QT_END_NAMESPACE - -#endif // QEGLFSKMSDEVICE_H diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice_p.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice_p.h new file mode 100644 index 0000000000..6e11953a69 --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice_p.h @@ -0,0 +1,37 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 Pelagicore AG +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QEGLFSKMSDEVICE_H +#define QEGLFSKMSDEVICE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qeglfsglobal_p.h" +#include <QtKmsSupport/private/qkmsdevice_p.h> + +QT_BEGIN_NAMESPACE + +class Q_EGLFS_EXPORT QEglFSKmsDevice : public QKmsDevice +{ +public: + QEglFSKmsDevice(QKmsScreenConfig *screenConfig, const QString &path); + + void registerScreen(QPlatformScreen *screen, + bool isPrimary, + const QPoint &virtualPos, + const QList<QPlatformScreen *> &virtualSiblings) override; +}; + +QT_END_NAMESPACE + +#endif // QEGLFSKMSDEVICE_H diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp index 645a0ae2e9..c0c9655496 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp @@ -1,61 +1,26 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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 "qeglfskmseventreader.h" -#include "qeglfskmsdevice.h" +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qeglfskmseventreader_p.h" +#include "qeglfskmsdevice_p.h" +#include "qeglfskmsscreen_p.h" +#include "qeglfskmsintegration_p.h" + #include <QSocketNotifier> #include <QCoreApplication> #include <QLoggingCategory> QT_BEGIN_NAMESPACE -Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug) - static void pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data) { Q_UNUSED(fd); - Q_UNUSED(sequence); - Q_UNUSED(tv_sec); - Q_UNUSED(tv_usec); QEglFSKmsEventReaderThread *t = static_cast<QEglFSKmsEventReaderThread *>(QThread::currentThread()); t->eventHost()->handlePageFlipCompleted(user_data); + + QEglFSKmsScreen *screen = static_cast<QEglFSKmsScreen *>(user_data); + screen->pageFlipped(sequence, tv_sec, tv_usec); } class RegisterWaitFlipEvent : public QEvent @@ -179,7 +144,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device) m_device = device; - qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d", + qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d", m_device, m_device->fd()); m_thread = new QEglFSKmsEventReaderThread(m_device->fd()); diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h deleted file mode 100644 index 4aa285b0fe..0000000000 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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 QEGLFSKKMSEVENTREADER_H -#define QEGLFSKKMSEVENTREADER_H - -#include "private/qeglfsglobal_p.h" -#include <QObject> -#include <QThread> -#include <QMutex> -#include <QWaitCondition> - -QT_BEGIN_NAMESPACE - -class QEglFSKmsDevice; - -struct QEglFSKmsEventHost : public QObject -{ - struct PendingFlipWait { - void *key; - QMutex *mutex; - QWaitCondition *cond; - }; - - static const int MAX_FLIPS = 32; - void *completedFlips[MAX_FLIPS] = {}; - QEglFSKmsEventHost::PendingFlipWait pendingFlipWaits[MAX_FLIPS] = {}; - - bool event(QEvent *event) override; - void updateStatus(); - void handlePageFlipCompleted(void *key); -}; - -class QEglFSKmsEventReaderThread : public QThread -{ -public: - QEglFSKmsEventReaderThread(int fd) : m_fd(fd) { } - void run() override; - QEglFSKmsEventHost *eventHost() { return &m_ev; } - -private: - int m_fd; - QEglFSKmsEventHost m_ev; -}; - -class Q_EGLFS_EXPORT QEglFSKmsEventReader -{ -public: - ~QEglFSKmsEventReader(); - - void create(QEglFSKmsDevice *device); - void destroy(); - - void startWaitFlip(void *key, QMutex *mutex, QWaitCondition *cond); - -private: - QEglFSKmsDevice *m_device = nullptr; - QEglFSKmsEventReaderThread *m_thread = nullptr; -}; - -QT_END_NAMESPACE - -#endif // QEGLFSKKMSEVENTREADER_H diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader_p.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader_p.h new file mode 100644 index 0000000000..295e5c4407 --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader_p.h @@ -0,0 +1,74 @@ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QEGLFSKKMSEVENTREADER_H +#define QEGLFSKKMSEVENTREADER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qeglfsglobal_p.h" +#include <QObject> +#include <QThread> +#include <QMutex> +#include <QWaitCondition> + +QT_BEGIN_NAMESPACE + +class QEglFSKmsDevice; + +struct QEglFSKmsEventHost : public QObject +{ + struct PendingFlipWait { + void *key; + QMutex *mutex; + QWaitCondition *cond; + }; + + static const int MAX_FLIPS = 32; + void *completedFlips[MAX_FLIPS] = {}; + QEglFSKmsEventHost::PendingFlipWait pendingFlipWaits[MAX_FLIPS] = {}; + + bool event(QEvent *event) override; + void updateStatus(); + void handlePageFlipCompleted(void *key); +}; + +class QEglFSKmsEventReaderThread : public QThread +{ +public: + QEglFSKmsEventReaderThread(int fd) : m_fd(fd) { } + void run() override; + QEglFSKmsEventHost *eventHost() { return &m_ev; } + +private: + int m_fd; + QEglFSKmsEventHost m_ev; +}; + +class Q_EGLFS_EXPORT QEglFSKmsEventReader +{ +public: + ~QEglFSKmsEventReader(); + + void create(QEglFSKmsDevice *device); + void destroy(); + + void startWaitFlip(void *key, QMutex *mutex, QWaitCondition *cond); + +private: + QEglFSKmsDevice *m_device = nullptr; + QEglFSKmsEventReaderThread *m_thread = nullptr; +}; + +QT_END_NAMESPACE + +#endif // QEGLFSKKMSEVENTREADER_H diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmshelpers.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmshelpers.h deleted file mode 100644 index c9e5f04a7b..0000000000 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmshelpers.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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 QEGLFSKMSHELPERS_H -#define QEGLFSKMSHELPERS_H - -#include <QString> - -QT_BEGIN_NAMESPACE - -inline QString q_fourccToString(uint code) -{ - QString s; - s.reserve(4); - s.append(code & 0xff); - s.append((code >> 8) & 0xff); - s.append((code >> 16) & 0xff); - s.append((code >> 24) & 0xff); - return s; -} - -QT_END_NAMESPACE - -#endif // QEGLFSKMSHELPERS_H diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmshelpers_p.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmshelpers_p.h new file mode 100644 index 0000000000..5f9935e93b --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmshelpers_p.h @@ -0,0 +1,35 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QEGLFSKMSHELPERS_H +#define QEGLFSKMSHELPERS_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QString> + +QT_BEGIN_NAMESPACE + +inline QString q_fourccToString(uint code) +{ + QString s; + s.reserve(4); + s.append(code & 0xff); + s.append((code >> 8) & 0xff); + s.append((code >> 16) & 0xff); + s.append((code >> 24) & 0xff); + return s; +} + +QT_END_NAMESPACE + +#endif // QEGLFSKMSHELPERS_H diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp index 28b6b7df63..26420b441f 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp @@ -1,46 +1,10 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Pelagicore AG -** 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 "qeglfskmsintegration.h" -#include "qeglfskmsscreen.h" +// Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 Pelagicore AG +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qeglfskmsintegration_p.h" +#include "qeglfskmsscreen_p.h" #include <QtKmsSupport/private/qkmsdevice_p.h> @@ -55,18 +19,19 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(qLcEglfsKmsDebug, "qt.qpa.eglfs.kms") QEglFSKmsIntegration::QEglFSKmsIntegration() - : m_device(nullptr), - m_screenConfig(new QKmsScreenConfig) + : m_device(nullptr) { } QEglFSKmsIntegration::~QEglFSKmsIntegration() { - delete m_screenConfig; } void QEglFSKmsIntegration::platformInit() { + qCDebug(qLcEglfsKmsDebug, "platformInit: Load Screen Config"); + m_screenConfig = createScreenConfig(); + qCDebug(qLcEglfsKmsDebug, "platformInit: Opening DRM device"); m_device = createDevice(); if (Q_UNLIKELY(!m_device->open())) @@ -79,6 +44,8 @@ void QEglFSKmsIntegration::platformDestroy() m_device->close(); delete m_device; m_device = nullptr; + delete m_screenConfig; + m_screenConfig = nullptr; } EGLNativeDisplayType QEglFSKmsIntegration::platformDisplay() const @@ -167,4 +134,12 @@ QKmsScreenConfig *QEglFSKmsIntegration::screenConfig() const return m_screenConfig; } +QKmsScreenConfig *QEglFSKmsIntegration::createScreenConfig() +{ + QKmsScreenConfig *screenConfig = new QKmsScreenConfig; + screenConfig->loadConfig(); + + return screenConfig; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h deleted file mode 100644 index e2c37f60fc..0000000000 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Pelagicore AG -** 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 QEGLFSKMSINTEGRATION_H -#define QEGLFSKMSINTEGRATION_H - -#include "private/qeglfsdeviceintegration_p.h" -#include <QtCore/QMap> -#include <QtCore/QVariant> -#include <QtCore/QLoggingCategory> - -QT_BEGIN_NAMESPACE - -class QKmsDevice; -class QKmsScreenConfig; - -Q_EGLFS_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug) - -class Q_EGLFS_EXPORT QEglFSKmsIntegration : public QEglFSDeviceIntegration -{ -public: - QEglFSKmsIntegration(); - ~QEglFSKmsIntegration(); - - void platformInit() override; - void platformDestroy() override; - EGLNativeDisplayType platformDisplay() const override; - bool usesDefaultScreen() override; - void screenInit() override; - QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &inputFormat) const override; - bool hasCapability(QPlatformIntegration::Capability cap) const override; - void waitForVSync(QPlatformSurface *surface) const override; - bool supportsPBuffers() const override; - void *nativeResourceForIntegration(const QByteArray &name) override; - void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) override; - - QKmsDevice *device() const; - QKmsScreenConfig *screenConfig() const; - -protected: - virtual QKmsDevice *createDevice() = 0; - - QKmsDevice *m_device; - QKmsScreenConfig *m_screenConfig; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration_p.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration_p.h new file mode 100644 index 0000000000..26da231092 --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration_p.h @@ -0,0 +1,63 @@ +// Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 Pelagicore AG +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QEGLFSKMSINTEGRATION_H +#define QEGLFSKMSINTEGRATION_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qeglfsdeviceintegration_p.h" +#include <QtCore/QMap> +#include <QtCore/QVariant> +#include <QtCore/QLoggingCategory> + +QT_BEGIN_NAMESPACE + +class QKmsDevice; +class QKmsScreenConfig; + +QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY(qLcEglfsKmsDebug, Q_EGLFS_EXPORT) + +class Q_EGLFS_EXPORT QEglFSKmsIntegration : public QEglFSDeviceIntegration +{ +public: + QEglFSKmsIntegration(); + ~QEglFSKmsIntegration(); + + void platformInit() override; + void platformDestroy() override; + EGLNativeDisplayType platformDisplay() const override; + bool usesDefaultScreen() override; + void screenInit() override; + QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &inputFormat) const override; + bool hasCapability(QPlatformIntegration::Capability cap) const override; + void waitForVSync(QPlatformSurface *surface) const override; + bool supportsPBuffers() const override; + void *nativeResourceForIntegration(const QByteArray &name) override; + void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) override; + + QKmsDevice *device() const; + QKmsScreenConfig *screenConfig() const; + +protected: + virtual QKmsDevice *createDevice() = 0; + virtual QKmsScreenConfig *createScreenConfig(); + + QKmsDevice *m_device; + QKmsScreenConfig *m_screenConfig = nullptr; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp index 959f17eba3..cc7381fb70 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp @@ -1,47 +1,13 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2016 Pelagicore AG -** 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 "qeglfskmsscreen.h" -#include "qeglfskmsdevice.h" -#include "qeglfsintegration_p.h" +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2016 Pelagicore AG +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qeglfskmsscreen_p.h" +#include "qeglfskmsdevice_p.h" + +#include <private/qeglfsintegration_p.h> +#include <private/qeglfskmsintegration_p.h> #include <QtCore/QLoggingCategory> @@ -50,8 +16,6 @@ QT_BEGIN_NAMESPACE -Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug) - class QEglFSKmsInterruptHandler : public QObject { public: @@ -160,14 +124,12 @@ QSizeF QEglFSKmsScreen::physicalSize() const QDpi QEglFSKmsScreen::logicalDpi() const { - const QSizeF ps = physicalSize(); - const QSize s = geometry().size(); - - if (!ps.isEmpty() && !s.isEmpty()) - return QDpi(25.4 * s.width() / ps.width(), - 25.4 * s.height() / ps.height()); - else - return QDpi(100, 100); + return logicalBaseDpi(); +} + +QDpi QEglFSKmsScreen::logicalBaseDpi() const +{ + return QDpi(100, 100); } Qt::ScreenOrientation QEglFSKmsScreen::nativeOrientation() const @@ -218,12 +180,12 @@ qreal QEglFSKmsScreen::refreshRate() const return refresh > 0 ? refresh : 60; } -QVector<QPlatformScreen::Mode> QEglFSKmsScreen::modes() const +QList<QPlatformScreen::Mode> QEglFSKmsScreen::modes() const { - QVector<QPlatformScreen::Mode> list; + QList<QPlatformScreen::Mode> list; list.reserve(m_output.modes.size()); - for (const drmModeModeInfo &info : qAsConst(m_output.modes)) + for (const drmModeModeInfo &info : std::as_const(m_output.modes)) list.append({QSize(info.hdisplay, info.vdisplay), qreal(info.vrefresh > 0 ? info.vrefresh : 60)}); @@ -256,4 +218,13 @@ void QEglFSKmsScreen::setPowerState(QPlatformScreen::PowerState state) m_powerState = state; } +/* Informs exact page flip timing which can be used rendering optimization. + Consider this is from drm event reader thread. */ +void QEglFSKmsScreen::pageFlipped(unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec) +{ + Q_UNUSED(sequence); + Q_UNUSED(tv_sec); + Q_UNUSED(tv_usec); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h deleted file mode 100644 index a5c8f5b4e8..0000000000 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Pelagicore AG -** 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 QEGLFSKMSSCREEN_H -#define QEGLFSKMSSCREEN_H - -#include "private/qeglfsscreen_p.h" -#include <QtCore/QList> -#include <QtCore/QMutex> - -#include <QtKmsSupport/private/qkmsdevice_p.h> -#include <QtEdidSupport/private/qedidparser_p.h> - -QT_BEGIN_NAMESPACE - -class QEglFSKmsDevice; -class QEglFSKmsInterruptHandler; - -class Q_EGLFS_EXPORT QEglFSKmsScreen : public QEglFSScreen -{ -public: - QEglFSKmsScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless = false); - ~QEglFSKmsScreen(); - - void setVirtualPosition(const QPoint &pos); - - QRect rawGeometry() const override; - - int depth() const override; - QImage::Format format() const override; - - QSizeF physicalSize() const override; - QDpi logicalDpi() const override; - Qt::ScreenOrientation nativeOrientation() const override; - Qt::ScreenOrientation orientation() const override; - - QString name() const override; - - QString manufacturer() const override; - QString model() const override; - QString serialNumber() const override; - - qreal refreshRate() const override; - - QList<QPlatformScreen *> virtualSiblings() const override { return m_siblings; } - void setVirtualSiblings(QList<QPlatformScreen *> sl) { m_siblings = sl; } - - QVector<QPlatformScreen::Mode> modes() const override; - - int currentMode() const override; - int preferredMode() const override; - - QEglFSKmsDevice *device() const { return m_device; } - - virtual void waitForFlip(); - - QKmsOutput &output() { return m_output; } - void restoreMode(); - - SubpixelAntialiasingType subpixelAntialiasingTypeHint() const override; - - QPlatformScreen::PowerState powerState() const override; - void setPowerState(QPlatformScreen::PowerState state) override; - - bool isCursorOutOfRange() const { return m_cursorOutOfRange; } - void setCursorOutOfRange(bool b) { m_cursorOutOfRange = b; } - -protected: - QEglFSKmsDevice *m_device; - - QKmsOutput m_output; - QEdidParser m_edid; - QPoint m_pos; - bool m_cursorOutOfRange; - - QList<QPlatformScreen *> m_siblings; - - PowerState m_powerState; - - QEglFSKmsInterruptHandler *m_interruptHandler; - - bool m_headless; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen_p.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen_p.h new file mode 100644 index 0000000000..6fb1f9a134 --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen_p.h @@ -0,0 +1,102 @@ +// Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> +// Copyright (C) 2016 The Qt Company Ltd. +// Copyright (C) 2016 Pelagicore AG +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QEGLFSKMSSCREEN_H +#define QEGLFSKMSSCREEN_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qeglfsscreen_p.h" +#include <QtCore/QList> +#include <QtCore/QMutex> + +#include <QtKmsSupport/private/qkmsdevice_p.h> +#include <QtGui/private/qedidparser_p.h> + +QT_BEGIN_NAMESPACE + +class QEglFSKmsDevice; +class QEglFSKmsInterruptHandler; + +class Q_EGLFS_EXPORT QEglFSKmsScreen : public QEglFSScreen +{ +public: + QEglFSKmsScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless = false); + ~QEglFSKmsScreen(); + + void setVirtualPosition(const QPoint &pos); + + QRect rawGeometry() const override; + + int depth() const override; + QImage::Format format() const override; + + QSizeF physicalSize() const override; + QDpi logicalDpi() const override; + QDpi logicalBaseDpi() const override; + Qt::ScreenOrientation nativeOrientation() const override; + Qt::ScreenOrientation orientation() const override; + + QString name() const override; + + QString manufacturer() const override; + QString model() const override; + QString serialNumber() const override; + + qreal refreshRate() const override; + + QList<QPlatformScreen *> virtualSiblings() const override { return m_siblings; } + void setVirtualSiblings(QList<QPlatformScreen *> sl) { m_siblings = sl; } + + QList<QPlatformScreen::Mode> modes() const override; + + int currentMode() const override; + int preferredMode() const override; + + QEglFSKmsDevice *device() const { return m_device; } + + virtual void waitForFlip(); + + QKmsOutput &output() { return m_output; } + void restoreMode(); + + SubpixelAntialiasingType subpixelAntialiasingTypeHint() const override; + + QPlatformScreen::PowerState powerState() const override; + void setPowerState(QPlatformScreen::PowerState state) override; + + bool isCursorOutOfRange() const { return m_cursorOutOfRange; } + void setCursorOutOfRange(bool b) { m_cursorOutOfRange = b; } + + virtual void pageFlipped(unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec); +protected: + QEglFSKmsDevice *m_device; + + QKmsOutput m_output; + QEdidParser m_edid; + QPoint m_pos; + bool m_cursorOutOfRange; + + QList<QPlatformScreen *> m_siblings; + + PowerState m_powerState; + + QEglFSKmsInterruptHandler *m_interruptHandler; + + bool m_headless; +}; + +QT_END_NAMESPACE + +#endif |