Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qeglfskmsscreen.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// Copyright (C) 2017 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
3// Copyright (C) 2016 Pelagicore AG
4// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
5
6#include "qeglfskmsscreen_p.h"
7#include "qeglfskmsdevice_p.h"
8#include <private/qeglfsintegration_p.h>
9
10#include <QtCore/QLoggingCategory>
11
12#include <QtGui/private/qguiapplication_p.h>
13#include <QtFbSupport/private/qfbvthandler_p.h>
14
16
17Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
18
20{
21public:
27
28public slots:
29 void restoreVideoMode() { m_screen->restoreMode(); }
30
31private:
32 QFbVtHandler *m_vtHandler;
33 QEglFSKmsScreen *m_screen;
34};
35
37 : QEglFSScreen(static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration())->display())
38 , m_device(device)
39 , m_output(output)
40 , m_cursorOutOfRange(false)
41 , m_powerState(PowerStateOn)
42 , m_interruptHandler(new QEglFSKmsInterruptHandler(this))
43 , m_headless(headless)
44{
45 m_siblings << this; // gets overridden later
46
47 if (m_output.edid_blob) {
48 QByteArray edid(reinterpret_cast<const char *>(m_output.edid_blob->data), m_output.edid_blob->length);
49 if (m_edid.parse(edid))
50 qCDebug(qLcEglfsKmsDebug, "EDID data for output \"%s\": identifier '%s', manufacturer '%s', model '%s', serial '%s', physical size: %.2fx%.2f",
51 name().toLatin1().constData(),
57 else
58 qCDebug(qLcEglfsKmsDebug) << "Failed to parse EDID data for output" << name(); // keep this debug, not warning
59 } else {
60 qCDebug(qLcEglfsKmsDebug) << "No EDID data for output" << name();
61 }
62}
63
69
74
75// Reimplement rawGeometry(), not geometry(). The base class implementation of
76// geometry() calls rawGeometry() and may apply additional transforms.
78{
79 if (m_headless)
80 return QRect(QPoint(0, 0), m_device->screenConfig()->headlessSize());
81
82 return QRect(m_pos.x(), m_pos.y(),
85}
86
88{
89 return format() == QImage::Format_RGB16 ? 16 : 32;
90}
91
93{
94 // the result can be slightly incorrect, it won't matter in practice
95 switch (m_output.drm_format) {
96 case DRM_FORMAT_ARGB8888:
100 case DRM_FORMAT_BGR565:
102 case DRM_FORMAT_XRGB2101010:
104 case DRM_FORMAT_XBGR2101010:
106 case DRM_FORMAT_ARGB2101010:
108 case DRM_FORMAT_ABGR2101010:
110 default:
112 }
113}
114
116{
118 return m_output.physical_size;
119 } else {
120 const QSize s = geometry().size();
121 return QSizeF(0.254 * s.width(), 0.254 * s.height());
122 }
123}
124
126{
127 return logicalBaseDpi();
128}
129
131{
132 return QDpi(100, 100);
133}
134
139
144
146{
147 return !m_headless ? m_output.name : QStringLiteral("qt_Headless");
148}
149
154
159
164
168
173
175{
176 if (m_headless)
177 return 60;
178
179 quint32 refresh = m_output.modes[m_output.mode].vrefresh;
180 return refresh > 0 ? refresh : 60;
181}
182
183QList<QPlatformScreen::Mode> QEglFSKmsScreen::modes() const
184{
185 QList<QPlatformScreen::Mode> list;
187
188 for (const drmModeModeInfo &info : std::as_const(m_output.modes))
189 list.append({QSize(info.hdisplay, info.vdisplay),
190 qreal(info.vrefresh > 0 ? info.vrefresh : 60)});
191
192 return list;
193}
194
196{
197 return m_output.mode;
198}
199
204
209
214
220
221/* Informs exact page flip timing which can be used rendering optimization.
222 Consider this is from drm event reader thread. */
223void QEglFSKmsScreen::pageFlipped(unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec)
224{
225 Q_UNUSED(sequence);
226 Q_UNUSED(tv_sec);
227 Q_UNUSED(tv_usec);
228}
229
IOBluetoothDevice * device
\inmodule QtCore
Definition qbytearray.h:57
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:124
QSizeF physicalSize
QString model
QString manufacturer
bool parse(const QByteArray &blob)
QString identifier
QString serialNumber
QEglFSKmsInterruptHandler(QEglFSKmsScreen *screen)
QString model() const override
Reimplement this function in subclass to return the model of this screen.
QString name() const override
QString serialNumber() const override
Reimplement this function in subclass to return the serial number of this screen.
void setVirtualPosition(const QPoint &pos)
QEglFSKmsInterruptHandler * m_interruptHandler
QPlatformScreen::PowerState powerState() const override
Returns the current power state.
QString manufacturer() const override
Reimplement this function in subclass to return the manufacturer of this screen.
int preferredMode() const override
Reimplement this function in subclass to return the preferred mode index from the modes list.
QList< QPlatformScreen * > m_siblings
int currentMode() const override
Reimplement this function in subclass to return the index of the current mode from the modes list.
int depth() const override
Reimplement in subclass to return current depth of the screen.
void setPowerState(QPlatformScreen::PowerState state) override
Sets the power state for this screen.
QList< QPlatformScreen::Mode > modes() const override
Reimplement this function in subclass to return the list of modes for this screen.
QDpi logicalDpi() const override
Reimplement this function in subclass to return the logical horizontal and vertical dots per inch met...
QImage::Format format() const override
Reimplement in subclass to return the image format which corresponds to the screen format.
QEglFSKmsDevice * m_device
Qt::ScreenOrientation nativeOrientation() const override
Reimplement this function in subclass to return the native orientation of the screen,...
qreal refreshRate() const override
Reimplement this function in subclass to return the vertical refresh rate of the screen,...
QDpi logicalBaseDpi() const override
Reimplement to return the base logical DPI for the platform.
SubpixelAntialiasingType subpixelAntialiasingTypeHint() const override
Returns a hint about this screen's subpixel layout structure.
QSizeF physicalSize() const override
Reimplement this function in subclass to return the physical size of the screen, in millimeters.
virtual void waitForFlip()
PowerState m_powerState
Qt::ScreenOrientation orientation() const override
Reimplement this function in subclass to return the current orientation of the screen,...
virtual void pageFlipped(unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec)
QRect rawGeometry() const override
QEglFSKmsScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless=false)
QRect geometry() const override
Reimplement in subclass to return the pixel geometry of the screen.
void interrupted()
void aboutToSuspend()
static QPlatformIntegration * platformIntegration()
Format
The following image formats are available in Qt.
Definition qimage.h:41
@ Format_RGB30
Definition qimage.h:63
@ Format_RGB32
Definition qimage.h:46
@ Format_A2BGR30_Premultiplied
Definition qimage.h:62
@ Format_BGR30
Definition qimage.h:61
@ Format_A2RGB30_Premultiplied
Definition qimage.h:64
@ Format_RGB16
Definition qimage.h:49
@ Format_ARGB32
Definition qimage.h:47
QKmsScreenConfig * screenConfig() const
QSize headlessSize() const
qsizetype size() const noexcept
Definition qlist.h:397
void reserve(qsizetype size)
Definition qlist.h:753
void append(parameter_type t)
Definition qlist.h:458
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:25
constexpr int x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:130
constexpr int y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:135
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr QSize size() const noexcept
Returns the size of the rectangle.
Definition qrect.h:242
\inmodule QtCore
Definition qsize.h:208
constexpr qreal width() const noexcept
Returns the width.
Definition qsize.h:332
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
Definition qsize.h:326
constexpr qreal height() const noexcept
Returns the height.
Definition qsize.h:335
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QByteArray toLatin1() const &
Definition qstring.h:630
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
#define this
Definition dialogs.cpp:9
else opt state
[0]
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
ScreenOrientation
Definition qnamespace.h:271
@ PrimaryOrientation
Definition qnamespace.h:272
#define DRM_FORMAT_RGB565
#define DRM_FORMAT_ABGR8888
QPair< qreal, qreal > QDpi
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLdouble s
[6]
Definition qopenglext.h:235
#define QStringLiteral(str)
QScreen * screen
[1]
Definition main.cpp:29
#define slots
#define Q_UNUSED(x)
unsigned int quint32
Definition qtypes.h:50
double qreal
Definition qtypes.h:187
QT_BEGIN_NAMESPACE typedef uchar * output
QList< int > list
[14]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QHostInfo info
[0]
void restoreMode(QKmsDevice *device)
QString name
void setPowerState(QKmsDevice *device, QPlatformScreen::PowerState state)
QList< drmModeModeInfo > modes
drmModePropertyBlobPtr edid_blob
QPlatformScreen::SubpixelAntialiasingType subpixelAntialiasingTypeHint() const
void cleanup(QKmsDevice *device)
QSizeF physical_size
uint32_t drm_format