Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qeglfskmsegldevicescreen.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 Pelagicore AG
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6#include <QGuiApplication>
7#include <QLoggingCategory>
8#include <errno.h>
9
11
12Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
13
16{
17}
18
20{
21 const int remainingScreenCount = qGuiApp->screens().size();
22 qCDebug(qLcEglfsKmsDebug, "Screen dtor. Remaining screens: %d", remainingScreenCount);
23 if (!remainingScreenCount && !device()->screenConfig()->separateScreens())
24 static_cast<QEglFSKmsEglDevice *>(device())->destroyGlobalCursor();
25}
26
28{
29 // The base class creates a cursor via integration->createCursor()
30 // in its ctor. With separateScreens just use that. Otherwise
31 // there's a virtual desktop and the device has a global cursor
32 // and the base class has no dedicated cursor at all.
33 // config->hwCursor() is ignored for now, just use the standard OpenGL cursor.
36 : static_cast<QEglFSKmsEglDevice *>(device())->globalCursor();
37}
38
40{
41 QKmsOutput &op(output());
42 const int fd = device()->fd();
43 const uint32_t w = op.modes[op.mode].hdisplay;
44 const uint32_t h = op.modes[op.mode].vdisplay;
45
46 if (!op.mode_set) {
47 op.mode_set = true;
48
49 drmModeCrtcPtr currentMode = drmModeGetCrtc(fd, op.crtc_id);
50 const bool alreadySet = currentMode && currentMode->width == w && currentMode->height == h;
51 if (currentMode)
52 drmModeFreeCrtc(currentMode);
53 if (alreadySet) {
54 // Maybe detecting the DPMS mode could help here, but there are no properties
55 // exposed on the connector apparently. So rely on an env var for now.
56 static bool alwaysDoSet = qEnvironmentVariableIntValue("QT_QPA_EGLFS_ALWAYS_SET_MODE");
57 if (!alwaysDoSet) {
58 qCDebug(qLcEglfsKmsDebug, "Mode already set");
59 return;
60 }
61 }
62
63 qCDebug(qLcEglfsKmsDebug, "Setting mode");
64 int ret = drmModeSetCrtc(fd, op.crtc_id,
65 uint32_t(-1), 0, 0,
66 &op.connector_id, 1,
67 &op.modes[op.mode]);
68 if (ret)
69 qErrnoWarning(errno, "drmModeSetCrtc failed");
70 }
71
72 if (!op.forced_plane_set) {
73 op.forced_plane_set = true;
74
75 if (op.wants_forced_plane) {
76 qCDebug(qLcEglfsKmsDebug, "Setting plane %u", op.forced_plane_id);
77 int ret = drmModeSetPlane(fd, op.forced_plane_id, op.crtc_id, uint32_t(-1), 0,
78 0, 0, w, h,
79 0 << 16, 0 << 16, op.size.width() << 16, op.size.height() << 16);
80 if (ret == -1)
81 qErrnoWarning(errno, "drmModeSetPlane failed");
82 }
83 }
84}
85
IOBluetoothDevice * device
QPlatformCursor * cursor() const override
Reimplement this function in subclass to return the cursor of the screen.
QKmsOutput & output()
int currentMode() const override
Reimplement this function in subclass to return the index of the current mode from the modes list.
QEglFSKmsDevice * device() const
QPlatformCursor * cursor() const override
Reimplement this function in subclass to return the cursor of the screen.
int fd() const
QKmsScreenConfig * screenConfig() const
bool separateScreens() const
The QPlatformCursor class provides information about pointer device events (movement,...
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:132
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:129
void qErrnoWarning(const char *msg,...)
Combined button and popup list for selecting options.
#define qGuiApp
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
return ret
GLfloat GLfloat GLfloat w
[0]
GLuint64 GLenum GLint fd
GLfloat GLfloat GLfloat GLfloat h
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
QT_BEGIN_NAMESPACE typedef uchar * output
uint32_t forced_plane_id
uint32_t crtc_id
bool forced_plane_set
QList< drmModeModeInfo > modes
bool wants_forced_plane
uint32_t connector_id