| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> | - | ||||||||||||
| 4 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
| 5 | ** Copyright (C) 2016 Pelagicore AG | - | ||||||||||||
| 6 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** This file is part of the plugins of the Qt Toolkit. | - | ||||||||||||
| 9 | ** | - | ||||||||||||
| 10 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
| 11 | ** Commercial License Usage | - | ||||||||||||
| 12 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 13 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 14 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 15 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 16 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 17 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
| 18 | ** | - | ||||||||||||
| 19 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 20 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 21 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
| 22 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
| 23 | ** packaging of this file. Please review the following information to | - | ||||||||||||
| 24 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
| 25 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
| 26 | ** | - | ||||||||||||
| 27 | ** GNU General Public License Usage | - | ||||||||||||
| 28 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
| 29 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
| 30 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
| 31 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
| 32 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
| 33 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
| 34 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
| 35 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
| 36 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
| 37 | ** | - | ||||||||||||
| 38 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 39 | ** | - | ||||||||||||
| 40 | ****************************************************************************/ | - | ||||||||||||
| 41 | - | |||||||||||||
| 42 | #include "qeglfskmsscreen.h" | - | ||||||||||||
| 43 | #include "qeglfskmsdevice.h" | - | ||||||||||||
| 44 | #include "qeglfsintegration.h" | - | ||||||||||||
| 45 | - | |||||||||||||
| 46 | #include <QtCore/QLoggingCategory> | - | ||||||||||||
| 47 | - | |||||||||||||
| 48 | #include <QtGui/private/qguiapplication_p.h> | - | ||||||||||||
| 49 | #include <QtPlatformSupport/private/qfbvthandler_p.h> | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 52 | - | |||||||||||||
| 53 | Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug) | - | ||||||||||||
| 54 | - | |||||||||||||
| 55 | class QEglFSKmsInterruptHandler : public QObject | - | ||||||||||||
| 56 | { | - | ||||||||||||
| 57 | public: | - | ||||||||||||
| 58 | QEglFSKmsInterruptHandler(QEglFSKmsScreen *screen) : m_screen(screen) { | - | ||||||||||||
| 59 | m_vtHandler = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration())->vtHandler(); | - | ||||||||||||
| 60 | connect(m_vtHandler, &QFbVtHandler::interrupted, this, &QEglFSKmsInterruptHandler::restoreVideoMode); | - | ||||||||||||
| 61 | connect(m_vtHandler, &QFbVtHandler::aboutToSuspend, this, &QEglFSKmsInterruptHandler::restoreVideoMode); | - | ||||||||||||
| 62 | } never executed: end of block | 0 | ||||||||||||
| 63 | - | |||||||||||||
| 64 | public slots: | - | ||||||||||||
| 65 | void restoreVideoMode() { m_screen->restoreMode(); } never executed: end of block | 0 | ||||||||||||
| 66 | - | |||||||||||||
| 67 | private: | - | ||||||||||||
| 68 | QFbVtHandler *m_vtHandler; | - | ||||||||||||
| 69 | QEglFSKmsScreen *m_screen; | - | ||||||||||||
| 70 | }; | - | ||||||||||||
| 71 | - | |||||||||||||
| 72 | QEglFSKmsScreen::QEglFSKmsScreen(QEglFSKmsIntegration *integration, | - | ||||||||||||
| 73 | QEglFSKmsDevice *device, | - | ||||||||||||
| 74 | QEglFSKmsOutput output, | - | ||||||||||||
| 75 | QPoint position) | - | ||||||||||||
| 76 | : QEglFSScreen(eglGetDisplay(device->nativeDisplay())) | - | ||||||||||||
| 77 | , m_integration(integration) | - | ||||||||||||
| 78 | , m_device(device) | - | ||||||||||||
| 79 | , m_output(output) | - | ||||||||||||
| 80 | , m_pos(position) | - | ||||||||||||
| 81 | , m_powerState(PowerStateOn) | - | ||||||||||||
| 82 | , m_interruptHandler(new QEglFSKmsInterruptHandler(this)) | - | ||||||||||||
| 83 | { | - | ||||||||||||
| 84 | m_siblings << this; | - | ||||||||||||
| 85 | } never executed: end of block | 0 | ||||||||||||
| 86 | - | |||||||||||||
| 87 | QEglFSKmsScreen::~QEglFSKmsScreen() | - | ||||||||||||
| 88 | { | - | ||||||||||||
| 89 | if (m_output.dpms_prop) {
| 0 | ||||||||||||
| 90 | drmModeFreeProperty(m_output.dpms_prop); | - | ||||||||||||
| 91 | m_output.dpms_prop = Q_NULLPTR; | - | ||||||||||||
| 92 | } never executed: end of block | 0 | ||||||||||||
| 93 | restoreMode(); | - | ||||||||||||
| 94 | if (m_output.saved_crtc) {
| 0 | ||||||||||||
| 95 | drmModeFreeCrtc(m_output.saved_crtc); | - | ||||||||||||
| 96 | m_output.saved_crtc = Q_NULLPTR; | - | ||||||||||||
| 97 | } never executed: end of block | 0 | ||||||||||||
| 98 | delete m_interruptHandler; | - | ||||||||||||
| 99 | } never executed: end of block | 0 | ||||||||||||
| 100 | - | |||||||||||||
| 101 | QRect QEglFSKmsScreen::geometry() const | - | ||||||||||||
| 102 | { | - | ||||||||||||
| 103 | const int mode = m_output.mode; | - | ||||||||||||
| 104 | return QRect(m_pos.x(), m_pos.y(), never executed: return QRect(m_pos.x(), m_pos.y(), m_output.modes[mode].hdisplay, m_output.modes[mode].vdisplay); | 0 | ||||||||||||
| 105 | m_output.modes[mode].hdisplay, never executed: return QRect(m_pos.x(), m_pos.y(), m_output.modes[mode].hdisplay, m_output.modes[mode].vdisplay); | 0 | ||||||||||||
| 106 | m_output.modes[mode].vdisplay); never executed: return QRect(m_pos.x(), m_pos.y(), m_output.modes[mode].hdisplay, m_output.modes[mode].vdisplay); | 0 | ||||||||||||
| 107 | } | - | ||||||||||||
| 108 | - | |||||||||||||
| 109 | int QEglFSKmsScreen::depth() const | - | ||||||||||||
| 110 | { | - | ||||||||||||
| 111 | return 32; never executed: return 32; | 0 | ||||||||||||
| 112 | } | - | ||||||||||||
| 113 | - | |||||||||||||
| 114 | QImage::Format QEglFSKmsScreen::format() const | - | ||||||||||||
| 115 | { | - | ||||||||||||
| 116 | return QImage::Format_RGB32; never executed: return QImage::Format_RGB32; | 0 | ||||||||||||
| 117 | } | - | ||||||||||||
| 118 | - | |||||||||||||
| 119 | QSizeF QEglFSKmsScreen::physicalSize() const | - | ||||||||||||
| 120 | { | - | ||||||||||||
| 121 | return m_output.physical_size; never executed: return m_output.physical_size; | 0 | ||||||||||||
| 122 | } | - | ||||||||||||
| 123 | - | |||||||||||||
| 124 | QDpi QEglFSKmsScreen::logicalDpi() const | - | ||||||||||||
| 125 | { | - | ||||||||||||
| 126 | const QSizeF ps = physicalSize(); | - | ||||||||||||
| 127 | const QSize s = geometry().size(); | - | ||||||||||||
| 128 | - | |||||||||||||
| 129 | if (!ps.isEmpty() && !s.isEmpty())
| 0 | ||||||||||||
| 130 | return QDpi(25.4 * s.width() / ps.width(), never executed: return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height()); | 0 | ||||||||||||
| 131 | 25.4 * s.height() / ps.height()); never executed: return QDpi(25.4 * s.width() / ps.width(), 25.4 * s.height() / ps.height()); | 0 | ||||||||||||
| 132 | else | - | ||||||||||||
| 133 | return QDpi(100, 100); never executed: return QDpi(100, 100); | 0 | ||||||||||||
| 134 | } | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | Qt::ScreenOrientation QEglFSKmsScreen::nativeOrientation() const | - | ||||||||||||
| 137 | { | - | ||||||||||||
| 138 | return Qt::PrimaryOrientation; never executed: return Qt::PrimaryOrientation; | 0 | ||||||||||||
| 139 | } | - | ||||||||||||
| 140 | - | |||||||||||||
| 141 | Qt::ScreenOrientation QEglFSKmsScreen::orientation() const | - | ||||||||||||
| 142 | { | - | ||||||||||||
| 143 | return Qt::PrimaryOrientation; never executed: return Qt::PrimaryOrientation; | 0 | ||||||||||||
| 144 | } | - | ||||||||||||
| 145 | - | |||||||||||||
| 146 | QString QEglFSKmsScreen::name() const | - | ||||||||||||
| 147 | { | - | ||||||||||||
| 148 | return m_output.name; never executed: return m_output.name; | 0 | ||||||||||||
| 149 | } | - | ||||||||||||
| 150 | - | |||||||||||||
| 151 | void QEglFSKmsScreen::destroySurface() | - | ||||||||||||
| 152 | { | - | ||||||||||||
| 153 | } | - | ||||||||||||
| 154 | - | |||||||||||||
| 155 | void QEglFSKmsScreen::waitForFlip() | - | ||||||||||||
| 156 | { | - | ||||||||||||
| 157 | } | - | ||||||||||||
| 158 | - | |||||||||||||
| 159 | void QEglFSKmsScreen::flip() | - | ||||||||||||
| 160 | { | - | ||||||||||||
| 161 | } | - | ||||||||||||
| 162 | - | |||||||||||||
| 163 | void QEglFSKmsScreen::flipFinished() | - | ||||||||||||
| 164 | { | - | ||||||||||||
| 165 | } | - | ||||||||||||
| 166 | - | |||||||||||||
| 167 | void QEglFSKmsScreen::restoreMode() | - | ||||||||||||
| 168 | { | - | ||||||||||||
| 169 | if (m_output.mode_set && m_output.saved_crtc) {
| 0 | ||||||||||||
| 170 | drmModeSetCrtc(m_device->fd(), | - | ||||||||||||
| 171 | m_output.saved_crtc->crtc_id, | - | ||||||||||||
| 172 | m_output.saved_crtc->buffer_id, | - | ||||||||||||
| 173 | 0, 0, | - | ||||||||||||
| 174 | &m_output.connector_id, 1, | - | ||||||||||||
| 175 | &m_output.saved_crtc->mode); | - | ||||||||||||
| 176 | - | |||||||||||||
| 177 | m_output.mode_set = false; | - | ||||||||||||
| 178 | } never executed: end of block | 0 | ||||||||||||
| 179 | } never executed: end of block | 0 | ||||||||||||
| 180 | - | |||||||||||||
| 181 | qreal QEglFSKmsScreen::refreshRate() const | - | ||||||||||||
| 182 | { | - | ||||||||||||
| 183 | quint32 refresh = m_output.modes[m_output.mode].vrefresh; | - | ||||||||||||
| 184 | return refresh > 0 ? refresh : 60; never executed: return refresh > 0 ? refresh : 60; | 0 | ||||||||||||
| 185 | } | - | ||||||||||||
| 186 | - | |||||||||||||
| 187 | QPlatformScreen::SubpixelAntialiasingType QEglFSKmsScreen::subpixelAntialiasingTypeHint() const | - | ||||||||||||
| 188 | { | - | ||||||||||||
| 189 | switch (m_output.subpixel) { | - | ||||||||||||
| 190 | default: never executed: default: | 0 | ||||||||||||
| 191 | case DRM_MODE_SUBPIXEL_UNKNOWN: never executed: case DRM_MODE_SUBPIXEL_UNKNOWN: | 0 | ||||||||||||
| 192 | case DRM_MODE_SUBPIXEL_NONE: never executed: case DRM_MODE_SUBPIXEL_NONE: | 0 | ||||||||||||
| 193 | return Subpixel_None; never executed: return Subpixel_None; | 0 | ||||||||||||
| 194 | case DRM_MODE_SUBPIXEL_HORIZONTAL_RGB: never executed: case DRM_MODE_SUBPIXEL_HORIZONTAL_RGB: | 0 | ||||||||||||
| 195 | return Subpixel_RGB; never executed: return Subpixel_RGB; | 0 | ||||||||||||
| 196 | case DRM_MODE_SUBPIXEL_HORIZONTAL_BGR: never executed: case DRM_MODE_SUBPIXEL_HORIZONTAL_BGR: | 0 | ||||||||||||
| 197 | return Subpixel_BGR; never executed: return Subpixel_BGR; | 0 | ||||||||||||
| 198 | case DRM_MODE_SUBPIXEL_VERTICAL_RGB: never executed: case DRM_MODE_SUBPIXEL_VERTICAL_RGB: | 0 | ||||||||||||
| 199 | return Subpixel_VRGB; never executed: return Subpixel_VRGB; | 0 | ||||||||||||
| 200 | case DRM_MODE_SUBPIXEL_VERTICAL_BGR: never executed: case DRM_MODE_SUBPIXEL_VERTICAL_BGR: | 0 | ||||||||||||
| 201 | return Subpixel_VBGR; never executed: return Subpixel_VBGR; | 0 | ||||||||||||
| 202 | } | - | ||||||||||||
| 203 | } | - | ||||||||||||
| 204 | - | |||||||||||||
| 205 | QPlatformScreen::PowerState QEglFSKmsScreen::powerState() const | - | ||||||||||||
| 206 | { | - | ||||||||||||
| 207 | return m_powerState; never executed: return m_powerState; | 0 | ||||||||||||
| 208 | } | - | ||||||||||||
| 209 | - | |||||||||||||
| 210 | void QEglFSKmsScreen::setPowerState(QPlatformScreen::PowerState state) | - | ||||||||||||
| 211 | { | - | ||||||||||||
| 212 | if (!m_output.dpms_prop)
| 0 | ||||||||||||
| 213 | return; never executed: return; | 0 | ||||||||||||
| 214 | - | |||||||||||||
| 215 | drmModeConnectorSetProperty(m_device->fd(), m_output.connector_id, | - | ||||||||||||
| 216 | m_output.dpms_prop->prop_id, (int)state); | - | ||||||||||||
| 217 | m_powerState = state; | - | ||||||||||||
| 218 | } never executed: end of block | 0 | ||||||||||||
| 219 | - | |||||||||||||
| 220 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |