| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.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 "qeglfskmsdevice.h" | - | ||||||||||||||||||||||||
| 43 | #include "qeglfskmsscreen.h" | - | ||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | #include "qeglfsintegration.h" | - | ||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||
| 47 | #include <QtCore/QLoggingCategory> | - | ||||||||||||||||||||||||
| 48 | #include <QtCore/private/qcore_unix_p.h> | - | ||||||||||||||||||||||||
| 49 | #include <QtGui/private/qguiapplication_p.h> | - | ||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) | - | ||||||||||||||||||||||||
| 52 | - | |||||||||||||||||||||||||
| 53 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
| 54 | - | |||||||||||||||||||||||||
| 55 | Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug) | - | ||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||
| 57 | enum OutputConfiguration { | - | ||||||||||||||||||||||||
| 58 | OutputConfigOff, | - | ||||||||||||||||||||||||
| 59 | OutputConfigPreferred, | - | ||||||||||||||||||||||||
| 60 | OutputConfigCurrent, | - | ||||||||||||||||||||||||
| 61 | OutputConfigMode, | - | ||||||||||||||||||||||||
| 62 | OutputConfigModeline | - | ||||||||||||||||||||||||
| 63 | }; | - | ||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | int QEglFSKmsDevice::crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector) | - | ||||||||||||||||||||||||
| 66 | { | - | ||||||||||||||||||||||||
| 67 |     for (int i = 0; i < connector->count_encoders; i++) {
  | 0 | ||||||||||||||||||||||||
| 68 | drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->encoders[i]); | - | ||||||||||||||||||||||||
| 69 |         if (!encoder) {
  | 0 | ||||||||||||||||||||||||
| 70 | qWarning("Failed to get encoder"); | - | ||||||||||||||||||||||||
| 71 |             continue; never executed:  continue; | 0 | ||||||||||||||||||||||||
| 72 | } | - | ||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||
| 74 | quint32 possibleCrtcs = encoder->possible_crtcs; | - | ||||||||||||||||||||||||
| 75 | drmModeFreeEncoder(encoder); | - | ||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||
| 77 |         for (int j = 0; j < resources->count_crtcs; j++) {
  | 0 | ||||||||||||||||||||||||
| 78 | bool isPossible = possibleCrtcs & (1 << j); | - | ||||||||||||||||||||||||
| 79 | bool isAvailable = !(m_crtc_allocator & 1 << resources->crtcs[j]); | - | ||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||
| 81 |             if (isPossible && isAvailable)
 
  | 0 | ||||||||||||||||||||||||
| 82 |                 return j; never executed:  return j; | 0 | ||||||||||||||||||||||||
| 83 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 84 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 85 | - | |||||||||||||||||||||||||
| 86 |     return -1; never executed:  return -1; | 0 | ||||||||||||||||||||||||
| 87 | } | - | ||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | static const char * const connector_type_names[] = { | - | ||||||||||||||||||||||||
| 90 | "None", | - | ||||||||||||||||||||||||
| 91 | "VGA", | - | ||||||||||||||||||||||||
| 92 | "DVI", | - | ||||||||||||||||||||||||
| 93 | "DVI", | - | ||||||||||||||||||||||||
| 94 | "DVI", | - | ||||||||||||||||||||||||
| 95 | "Composite", | - | ||||||||||||||||||||||||
| 96 | "TV", | - | ||||||||||||||||||||||||
| 97 | "LVDS", | - | ||||||||||||||||||||||||
| 98 | "CTV", | - | ||||||||||||||||||||||||
| 99 | "DIN", | - | ||||||||||||||||||||||||
| 100 | "DP", | - | ||||||||||||||||||||||||
| 101 | "HDMI", | - | ||||||||||||||||||||||||
| 102 | "HDMI", | - | ||||||||||||||||||||||||
| 103 | "TV", | - | ||||||||||||||||||||||||
| 104 | "eDP", | - | ||||||||||||||||||||||||
| 105 | }; | - | ||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||
| 107 | static QByteArray nameForConnector(const drmModeConnectorPtr connector) | - | ||||||||||||||||||||||||
| 108 | { | - | ||||||||||||||||||||||||
| 109 | QByteArray connectorName("UNKNOWN"); | - | ||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 |     if (connector->connector_type < ARRAY_LENGTH(connector_type_names))
  | 0 | ||||||||||||||||||||||||
| 112 |         connectorName = connector_type_names[connector->connector_type]; never executed:  connectorName = connector_type_names[connector->connector_type]; | 0 | ||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||
| 114 | connectorName += QByteArray::number(connector->connector_type_id); | - | ||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||
| 116 |     return connectorName; never executed:  return connectorName; | 0 | ||||||||||||||||||||||||
| 117 | } | - | ||||||||||||||||||||||||
| 118 | - | |||||||||||||||||||||||||
| 119 | static bool parseModeline(const QByteArray &text, drmModeModeInfoPtr mode) | - | ||||||||||||||||||||||||
| 120 | { | - | ||||||||||||||||||||||||
| 121 | char hsync[16]; | - | ||||||||||||||||||||||||
| 122 | char vsync[16]; | - | ||||||||||||||||||||||||
| 123 | float fclock; | - | ||||||||||||||||||||||||
| 124 | - | |||||||||||||||||||||||||
| 125 | mode->type = DRM_MODE_TYPE_USERDEF; | - | ||||||||||||||||||||||||
| 126 | mode->hskew = 0; | - | ||||||||||||||||||||||||
| 127 | mode->vscan = 0; | - | ||||||||||||||||||||||||
| 128 | mode->vrefresh = 0; | - | ||||||||||||||||||||||||
| 129 | mode->flags = 0; | - | ||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 |     if (sscanf(text.constData(), "%f %hd %hd %hd %hd %hd %hd %hd %hd %15s %15s",
  | 0 | ||||||||||||||||||||||||
| 132 |                &fclock,
  | 0 | ||||||||||||||||||||||||
| 133 |                &mode->hdisplay,
  | 0 | ||||||||||||||||||||||||
| 134 |                &mode->hsync_start,
  | 0 | ||||||||||||||||||||||||
| 135 |                &mode->hsync_end,
  | 0 | ||||||||||||||||||||||||
| 136 |                &mode->htotal,
  | 0 | ||||||||||||||||||||||||
| 137 |                &mode->vdisplay,
  | 0 | ||||||||||||||||||||||||
| 138 |                &mode->vsync_start,
  | 0 | ||||||||||||||||||||||||
| 139 |                &mode->vsync_end,
  | 0 | ||||||||||||||||||||||||
| 140 |                &mode->vtotal, hsync, vsync) != 11)
  | 0 | ||||||||||||||||||||||||
| 141 |         return false; never executed:  return false; | 0 | ||||||||||||||||||||||||
| 142 | - | |||||||||||||||||||||||||
| 143 | mode->clock = fclock * 1000; | - | ||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||
| 145 |     if (strcmp(hsync, "+hsync") == 0)
  | 0 | ||||||||||||||||||||||||
| 146 |         mode->flags |= DRM_MODE_FLAG_PHSYNC; never executed:  mode->flags |= (1<<0); | 0 | ||||||||||||||||||||||||
| 147 |     else if (strcmp(hsync, "-hsync") == 0)
  | 0 | ||||||||||||||||||||||||
| 148 |         mode->flags |= DRM_MODE_FLAG_NHSYNC; never executed:  mode->flags |= (1<<1); | 0 | ||||||||||||||||||||||||
| 149 | else | - | ||||||||||||||||||||||||
| 150 |         return false; never executed:  return false; | 0 | ||||||||||||||||||||||||
| 151 | - | |||||||||||||||||||||||||
| 152 |     if (strcmp(vsync, "+vsync") == 0)
  | 0 | ||||||||||||||||||||||||
| 153 |         mode->flags |= DRM_MODE_FLAG_PVSYNC; never executed:  mode->flags |= (1<<2); | 0 | ||||||||||||||||||||||||
| 154 |     else if (strcmp(vsync, "-vsync") == 0)
  | 0 | ||||||||||||||||||||||||
| 155 |         mode->flags |= DRM_MODE_FLAG_NVSYNC; never executed:  mode->flags |= (1<<3); | 0 | ||||||||||||||||||||||||
| 156 | else | - | ||||||||||||||||||||||||
| 157 |         return false; never executed:  return false; | 0 | ||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||
| 159 |     return true; never executed:  return true; | 0 | ||||||||||||||||||||||||
| 160 | } | - | ||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||
| 162 | QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos) | - | ||||||||||||||||||||||||
| 163 | { | - | ||||||||||||||||||||||||
| 164 | const QByteArray connectorName = nameForConnector(connector); | - | ||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | const int crtc = crtcForConnector(resources, connector); | - | ||||||||||||||||||||||||
| 167 |     if (crtc < 0) {
  | 0 | ||||||||||||||||||||||||
| 168 | qWarning() << "No usable crtc/encoder pair for connector" << connectorName; | - | ||||||||||||||||||||||||
| 169 |         return Q_NULLPTR; never executed:  return nullptr; | 0 | ||||||||||||||||||||||||
| 170 | } | - | ||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||
| 172 | OutputConfiguration configuration; | - | ||||||||||||||||||||||||
| 173 | QSize configurationSize; | - | ||||||||||||||||||||||||
| 174 | drmModeModeInfo configurationModeline; | - | ||||||||||||||||||||||||
| 175 | - | |||||||||||||||||||||||||
| 176 | const QByteArray mode = m_integration->outputSettings().value(QString::fromUtf8(connectorName)) | - | ||||||||||||||||||||||||
| 177 |             .value(QStringLiteral("mode"), QStringLiteral("preferred")).toByteArray().toLower(); never executed:  return qstring_literal_temp;never executed:  return qstring_literal_temp; | 0 | ||||||||||||||||||||||||
| 178 |     if (mode == "off") {
  | 0 | ||||||||||||||||||||||||
| 179 | configuration = OutputConfigOff; | - | ||||||||||||||||||||||||
| 180 |     } else if (mode == "preferred") { never executed:  end of block
  | 0 | ||||||||||||||||||||||||
| 181 | configuration = OutputConfigPreferred; | - | ||||||||||||||||||||||||
| 182 |     } else if (mode == "current") { never executed:  end of block
  | 0 | ||||||||||||||||||||||||
| 183 | configuration = OutputConfigCurrent; | - | ||||||||||||||||||||||||
| 184 |     } else if (sscanf(mode.constData(), "%dx%d", &configurationSize.rwidth(), &configurationSize.rheight()) == 2) { never executed:  end of block
  | 0 | ||||||||||||||||||||||||
| 185 | configuration = OutputConfigMode; | - | ||||||||||||||||||||||||
| 186 |     } else if (parseModeline(mode, &configurationModeline)) { never executed:  end of block
  | 0 | ||||||||||||||||||||||||
| 187 | configuration = OutputConfigModeline; | - | ||||||||||||||||||||||||
| 188 |     } else { never executed:  end of block | 0 | ||||||||||||||||||||||||
| 189 | qWarning("Invalid mode \"%s\" for output %s", mode.constData(), connectorName.constData()); | - | ||||||||||||||||||||||||
| 190 | configuration = OutputConfigPreferred; | - | ||||||||||||||||||||||||
| 191 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||
| 193 | const uint32_t crtc_id = resources->crtcs[crtc]; | - | ||||||||||||||||||||||||
| 194 | - | |||||||||||||||||||||||||
| 195 |     if (configuration == OutputConfigOff) {
  | 0 | ||||||||||||||||||||||||
| 196 |         qCDebug(qLcEglfsKmsDebug) << "Turning off output" << connectorName; never executed:  QMessageLogger(__FILE__, 196, __PRETTY_FUNCTION__, qLcEglfsKmsDebug().categoryName()).debug() << "Turning off output" << connectorName;
  | 0 | ||||||||||||||||||||||||
| 197 | drmModeSetCrtc(m_dri_fd, crtc_id, 0, 0, 0, 0, 0, Q_NULLPTR); | - | ||||||||||||||||||||||||
| 198 |         return Q_NULLPTR; never executed:  return nullptr; | 0 | ||||||||||||||||||||||||
| 199 | } | - | ||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||
| 201 | // Skip disconnected output | - | ||||||||||||||||||||||||
| 202 |     
 
 
 
  | 0 | ||||||||||||||||||||||||
| 203 |         qCDebug(qLcEglfsKmsDebug) << "Skipping disconnected output" << connectorName; never executed:  QMessageLogger(__FILE__, 203, __PRETTY_FUNCTION__, qLcEglfsKmsDebug().categoryName()).debug() << "Skipping disconnected output" << connectorName;
  | 0 | ||||||||||||||||||||||||
| 204 |         return Q_NULLPTR; never executed:  return nullptr; | 0 | ||||||||||||||||||||||||
| 205 | } | - | ||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | // Get the current mode on the current crtc | - | ||||||||||||||||||||||||
| 208 | drmModeModeInfo crtc_mode; | - | ||||||||||||||||||||||||
| 209 | memset(&crtc_mode, 0, sizeof crtc_mode); | - | ||||||||||||||||||||||||
| 210 |     if (drmModeEncoderPtr encoder = drmModeGetEncoder(m_dri_fd, connector->connector_id)) {
  | 0 | ||||||||||||||||||||||||
| 211 | drmModeCrtcPtr crtc = drmModeGetCrtc(m_dri_fd, encoder->crtc_id); | - | ||||||||||||||||||||||||
| 212 | drmModeFreeEncoder(encoder); | - | ||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||
| 214 |         if (!crtc)
  | 0 | ||||||||||||||||||||||||
| 215 |             return Q_NULLPTR; never executed:  return nullptr; | 0 | ||||||||||||||||||||||||
| 216 | - | |||||||||||||||||||||||||
| 217 |         if (crtc->mode_valid)
  | 0 | ||||||||||||||||||||||||
| 218 |             crtc_mode = crtc->mode; never executed:  crtc_mode = crtc->mode; | 0 | ||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||
| 220 | drmModeFreeCrtc(crtc); | - | ||||||||||||||||||||||||
| 221 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 222 | - | |||||||||||||||||||||||||
| 223 | QList<drmModeModeInfo> modes; | - | ||||||||||||||||||||||||
| 224 | modes.reserve(connector->count_modes); | - | ||||||||||||||||||||||||
| 225 |     qCDebug(qLcEglfsKmsDebug) << connectorName << "mode count:" << connector->count_modes; never executed:  QMessageLogger(__FILE__, 225, __PRETTY_FUNCTION__, qLcEglfsKmsDebug().categoryName()).debug() << connectorName << "mode count:" << connector->count_modes;
  | 0 | ||||||||||||||||||||||||
| 226 |     for (int i = 0; i < connector->count_modes; i++) {
  | 0 | ||||||||||||||||||||||||
| 227 | const drmModeModeInfo &mode = connector->modes[i]; | - | ||||||||||||||||||||||||
| 228 |         qCDebug(qLcEglfsKmsDebug) << "mode" << i << mode.hdisplay << "x" << mode.vdisplay never executed:  QMessageLogger(__FILE__, 228, __PRETTY_FUNCTION__, qLcEglfsKmsDebug().categoryName()).debug() << "mode" << i << mode.hdisplay << "x" << mode.vdisplay << '@' << mode.vrefresh << "hz";
  | 0 | ||||||||||||||||||||||||
| 229 |                                   << '@' << mode.vrefresh << "hz"; never executed:  QMessageLogger(__FILE__, 228, __PRETTY_FUNCTION__, qLcEglfsKmsDebug().categoryName()).debug() << "mode" << i << mode.hdisplay << "x" << mode.vdisplay << '@' << mode.vrefresh << "hz"; | 0 | ||||||||||||||||||||||||
| 230 | modes << connector->modes[i]; | - | ||||||||||||||||||||||||
| 231 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 232 | - | |||||||||||||||||||||||||
| 233 | int preferred = -1; | - | ||||||||||||||||||||||||
| 234 | int current = -1; | - | ||||||||||||||||||||||||
| 235 | int configured = -1; | - | ||||||||||||||||||||||||
| 236 | int best = -1; | - | ||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||
| 238 |     for (int i = modes.size() - 1; i >= 0; i--) {
  | 0 | ||||||||||||||||||||||||
| 239 | const drmModeModeInfo &m = modes.at(i); | - | ||||||||||||||||||||||||
| 240 | - | |||||||||||||||||||||||||
| 241 |         if (configuration == OutputConfigMode &&
  | 0 | ||||||||||||||||||||||||
| 242 |                 m.hdisplay == configurationSize.width() &&
  | 0 | ||||||||||||||||||||||||
| 243 |                 m.vdisplay == configurationSize.height()) {
  | 0 | ||||||||||||||||||||||||
| 244 | configured = i; | - | ||||||||||||||||||||||||
| 245 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||
| 247 |         if (!memcmp(&crtc_mode, &m, sizeof m))
  | 0 | ||||||||||||||||||||||||
| 248 |             current = i; never executed:  current = i; | 0 | ||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||
| 250 |         if (m.type & DRM_MODE_TYPE_PREFERRED)
  | 0 | ||||||||||||||||||||||||
| 251 |             preferred = i; never executed:  preferred = i; | 0 | ||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||
| 253 | best = i; | - | ||||||||||||||||||||||||
| 254 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||
| 256 |     if (configuration == OutputConfigModeline) {
  | 0 | ||||||||||||||||||||||||
| 257 | modes << configurationModeline; | - | ||||||||||||||||||||||||
| 258 | configured = modes.size() - 1; | - | ||||||||||||||||||||||||
| 259 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 |     if (current < 0 && crtc_mode.clock != 0) {
 
  | 0 | ||||||||||||||||||||||||
| 262 | modes << crtc_mode; | - | ||||||||||||||||||||||||
| 263 | current = mode.size() - 1; | - | ||||||||||||||||||||||||
| 264 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 265 | - | |||||||||||||||||||||||||
| 266 |     if (configuration == OutputConfigCurrent)
  | 0 | ||||||||||||||||||||||||
| 267 |         configured = current; never executed:  configured = current; | 0 | ||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | int selected_mode = -1; | - | ||||||||||||||||||||||||
| 270 | - | |||||||||||||||||||||||||
| 271 |     if (configured >= 0)
  | 0 | ||||||||||||||||||||||||
| 272 |         selected_mode = configured; never executed:  selected_mode = configured; | 0 | ||||||||||||||||||||||||
| 273 |     else if (preferred >= 0)
  | 0 | ||||||||||||||||||||||||
| 274 |         selected_mode = preferred; never executed:  selected_mode = preferred; | 0 | ||||||||||||||||||||||||
| 275 |     else if (current >= 0)
  | 0 | ||||||||||||||||||||||||
| 276 |         selected_mode = current; never executed:  selected_mode = current; | 0 | ||||||||||||||||||||||||
| 277 |     else if (best >= 0)
  | 0 | ||||||||||||||||||||||||
| 278 |         selected_mode = best; never executed:  selected_mode = best; | 0 | ||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||
| 280 |     if (selected_mode < 0) {
  | 0 | ||||||||||||||||||||||||
| 281 | qWarning() << "No modes available for output" << connectorName; | - | ||||||||||||||||||||||||
| 282 |         return Q_NULLPTR; never executed:  return nullptr; | 0 | ||||||||||||||||||||||||
| 283 | } else { | - | ||||||||||||||||||||||||
| 284 | int width = modes[selected_mode].hdisplay; | - | ||||||||||||||||||||||||
| 285 | int height = modes[selected_mode].vdisplay; | - | ||||||||||||||||||||||||
| 286 | int refresh = modes[selected_mode].vrefresh; | - | ||||||||||||||||||||||||
| 287 |         qCDebug(qLcEglfsKmsDebug) << "Selected mode" << selected_mode << ":" << width << "x" << height never executed:  QMessageLogger(__FILE__, 287, __PRETTY_FUNCTION__, qLcEglfsKmsDebug().categoryName()).debug() << "Selected mode" << selected_mode << ":" << width << "x" << height << '@' << refresh << "hz for output" << connectorName;
  | 0 | ||||||||||||||||||||||||
| 288 |                                   << '@' << refresh << "hz for output" << connectorName; never executed:  QMessageLogger(__FILE__, 287, __PRETTY_FUNCTION__, qLcEglfsKmsDebug().categoryName()).debug() << "Selected mode" << selected_mode << ":" << width << "x" << height << '@' << refresh << "hz for output" << connectorName; | 0 | ||||||||||||||||||||||||
| 289 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 290 | static const int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_WIDTH"); | - | ||||||||||||||||||||||||
| 291 | static const int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_HEIGHT"); | - | ||||||||||||||||||||||||
| 292 | QSizeF size(width, height); | - | ||||||||||||||||||||||||
| 293 |     if (size.isEmpty()) {
  | 0 | ||||||||||||||||||||||||
| 294 | size.setWidth(connector->mmWidth); | - | ||||||||||||||||||||||||
| 295 | size.setHeight(connector->mmHeight); | - | ||||||||||||||||||||||||
| 296 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 297 | QEglFSKmsOutput output = { | - | ||||||||||||||||||||||||
| 298 | QString::fromUtf8(connectorName), | - | ||||||||||||||||||||||||
| 299 | connector->connector_id, | - | ||||||||||||||||||||||||
| 300 | crtc_id, | - | ||||||||||||||||||||||||
| 301 | size, | - | ||||||||||||||||||||||||
| 302 | selected_mode, | - | ||||||||||||||||||||||||
| 303 | false, | - | ||||||||||||||||||||||||
| 304 | drmModeGetCrtc(m_dri_fd, crtc_id), | - | ||||||||||||||||||||||||
| 305 | modes, | - | ||||||||||||||||||||||||
| 306 | connector->subpixel, | - | ||||||||||||||||||||||||
| 307 |         connectorProperty(connector, QByteArrayLiteral("DPMS")) never executed:  return ba; | 0 | ||||||||||||||||||||||||
| 308 | }; | - | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | m_crtc_allocator |= (1 << output.crtc_id); | - | ||||||||||||||||||||||||
| 311 | m_connector_allocator |= (1 << output.connector_id); | - | ||||||||||||||||||||||||
| 312 | - | |||||||||||||||||||||||||
| 313 |     return createScreen(m_integration, this, output, pos); never executed:  return createScreen(m_integration, this, output, pos); | 0 | ||||||||||||||||||||||||
| 314 | } | - | ||||||||||||||||||||||||
| 315 | - | |||||||||||||||||||||||||
| 316 | drmModePropertyPtr QEglFSKmsDevice::connectorProperty(drmModeConnectorPtr connector, const QByteArray &name) | - | ||||||||||||||||||||||||
| 317 | { | - | ||||||||||||||||||||||||
| 318 | drmModePropertyPtr prop; | - | ||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||
| 320 |     for (int i = 0; i < connector->count_props; i++) {
  | 0 | ||||||||||||||||||||||||
| 321 | prop = drmModeGetProperty(m_dri_fd, connector->props[i]); | - | ||||||||||||||||||||||||
| 322 |         if (!prop)
  | 0 | ||||||||||||||||||||||||
| 323 |             continue; never executed:  continue; | 0 | ||||||||||||||||||||||||
| 324 |         if (strcmp(prop->name, name.constData()) == 0)
  | 0 | ||||||||||||||||||||||||
| 325 |             return prop; never executed:  return prop; | 0 | ||||||||||||||||||||||||
| 326 | drmModeFreeProperty(prop); | - | ||||||||||||||||||||||||
| 327 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 328 | - | |||||||||||||||||||||||||
| 329 |     return Q_NULLPTR; never executed:  return nullptr; | 0 | ||||||||||||||||||||||||
| 330 | } | - | ||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||
| 332 | QEglFSKmsDevice::QEglFSKmsDevice(QEglFSKmsIntegration *integration, const QString &path) | - | ||||||||||||||||||||||||
| 333 | : m_integration(integration) | - | ||||||||||||||||||||||||
| 334 | , m_path(path) | - | ||||||||||||||||||||||||
| 335 | , m_dri_fd(-1) | - | ||||||||||||||||||||||||
| 336 | , m_crtc_allocator(0) | - | ||||||||||||||||||||||||
| 337 | , m_connector_allocator(0) | - | ||||||||||||||||||||||||
| 338 | { | - | ||||||||||||||||||||||||
| 339 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||
| 341 | QEglFSKmsDevice::~QEglFSKmsDevice() | - | ||||||||||||||||||||||||
| 342 | { | - | ||||||||||||||||||||||||
| 343 | } | - | ||||||||||||||||||||||||
| 344 | - | |||||||||||||||||||||||||
| 345 | void QEglFSKmsDevice::createScreens() | - | ||||||||||||||||||||||||
| 346 | { | - | ||||||||||||||||||||||||
| 347 | drmModeResPtr resources = drmModeGetResources(m_dri_fd); | - | ||||||||||||||||||||||||
| 348 |     if (!resources) {
  | 0 | ||||||||||||||||||||||||
| 349 | qWarning("drmModeGetResources failed"); | - | ||||||||||||||||||||||||
| 350 |         return; never executed:  return; | 0 | ||||||||||||||||||||||||
| 351 | } | - | ||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||
| 353 | QEglFSKmsScreen *primaryScreen = Q_NULLPTR; | - | ||||||||||||||||||||||||
| 354 | QList<QPlatformScreen *> siblings; | - | ||||||||||||||||||||||||
| 355 | QPoint pos(0, 0); | - | ||||||||||||||||||||||||
| 356 | QEglFSIntegration *integration = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration()); | - | ||||||||||||||||||||||||
| 357 | - | |||||||||||||||||||||||||
| 358 |     for (int i = 0; i < resources->count_connectors; i++) {
  | 0 | ||||||||||||||||||||||||
| 359 | drmModeConnectorPtr connector = drmModeGetConnector(m_dri_fd, resources->connectors[i]); | - | ||||||||||||||||||||||||
| 360 |         if (!connector)
  | 0 | ||||||||||||||||||||||||
| 361 |             continue; never executed:  continue; | 0 | ||||||||||||||||||||||||
| 362 | - | |||||||||||||||||||||||||
| 363 | QEglFSKmsScreen *screen = screenForConnector(resources, connector, pos); | - | ||||||||||||||||||||||||
| 364 |         if (screen) {
  | 0 | ||||||||||||||||||||||||
| 365 | integration->addScreen(screen); | - | ||||||||||||||||||||||||
| 366 | pos.rx() += screen->geometry().width(); | - | ||||||||||||||||||||||||
| 367 | siblings << screen; | - | ||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||
| 369 |             if (!primaryScreen)
  | 0 | ||||||||||||||||||||||||
| 370 |                 primaryScreen = screen; never executed:  primaryScreen = screen; | 0 | ||||||||||||||||||||||||
| 371 |         } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||
| 373 | drmModeFreeConnector(connector); | - | ||||||||||||||||||||||||
| 374 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 375 | - | |||||||||||||||||||||||||
| 376 | drmModeFreeResources(resources); | - | ||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||
| 378 |     if (!m_integration->separateScreens()) {
  | 0 | ||||||||||||||||||||||||
| 379 | Q_FOREACH (QPlatformScreen *screen, siblings) | - | ||||||||||||||||||||||||
| 380 |             static_cast<QEglFSKmsScreen *>(screen)->setVirtualSiblings(siblings); never executed:  static_cast<QEglFSKmsScreen *>(screen)->setVirtualSiblings(siblings); | 0 | ||||||||||||||||||||||||
| 381 |     } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 382 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||
| 384 | int QEglFSKmsDevice::fd() const | - | ||||||||||||||||||||||||
| 385 | { | - | ||||||||||||||||||||||||
| 386 |     return m_dri_fd; never executed:  return m_dri_fd; | 0 | ||||||||||||||||||||||||
| 387 | } | - | ||||||||||||||||||||||||
| 388 | - | |||||||||||||||||||||||||
| 389 | QString QEglFSKmsDevice::devicePath() const | - | ||||||||||||||||||||||||
| 390 | { | - | ||||||||||||||||||||||||
| 391 |     return m_path; never executed:  return m_path; | 0 | ||||||||||||||||||||||||
| 392 | } | - | ||||||||||||||||||||||||
| 393 | - | |||||||||||||||||||||||||
| 394 | QEglFSKmsScreen *QEglFSKmsDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position) | - | ||||||||||||||||||||||||
| 395 | { | - | ||||||||||||||||||||||||
| 396 |     return new QEglFSKmsScreen(integration, device, output, position); never executed:  return new QEglFSKmsScreen(integration, device, output, position); | 0 | ||||||||||||||||||||||||
| 397 | } | - | ||||||||||||||||||||||||
| 398 | - | |||||||||||||||||||||||||
| 399 | void QEglFSKmsDevice::setFd(int fd) | - | ||||||||||||||||||||||||
| 400 | { | - | ||||||||||||||||||||||||
| 401 | m_dri_fd = fd; | - | ||||||||||||||||||||||||
| 402 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 403 | - | |||||||||||||||||||||||||
| 404 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |