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
qeglfskmsintegration.cpp
Go to the documentation of this file.
1// Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// Copyright (C) 2016 The Qt Company Ltd.
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
7#include "qeglfskmsscreen_p.h"
8
9#include <QtKmsSupport/private/qkmsdevice_p.h>
10
11#include <QtGui/qpa/qplatformwindow.h>
12#include <QtGui/QScreen>
13
14#include <xf86drm.h>
15#include <xf86drmMode.h>
16
18
19Q_LOGGING_CATEGORY(qLcEglfsKmsDebug, "qt.qpa.eglfs.kms")
20
22 : m_device(nullptr)
23{
24}
25
29
31{
32 qCDebug(qLcEglfsKmsDebug, "platformInit: Load Screen Config");
34
35 qCDebug(qLcEglfsKmsDebug, "platformInit: Opening DRM device");
37 if (Q_UNLIKELY(!m_device->open()))
38 qFatal("Could not open DRM device");
39}
40
42{
43 qCDebug(qLcEglfsKmsDebug, "platformDestroy: Closing DRM device");
44 m_device->close();
45 delete m_device;
46 m_device = nullptr;
47 delete m_screenConfig;
48 m_screenConfig = nullptr;
49}
50
51EGLNativeDisplayType QEglFSKmsIntegration::platformDisplay() const
52{
54 return (EGLNativeDisplayType) m_device->nativeDisplay();
55}
56
58{
59 return false;
60}
61
66
68{
69 QSurfaceFormat format(inputFormat);
70 format.setRenderableType(QSurfaceFormat::OpenGLES);
71 format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
72 format.setRedBufferSize(8);
73 format.setGreenBufferSize(8);
74 format.setBlueBufferSize(8);
75 return format;
76}
77
79{
80 switch (cap) {
84 return true;
85 default:
86 return false;
87 }
88}
89
91{
92 QWindow *window = static_cast<QWindow *>(surface->surface());
93 QEglFSKmsScreen *screen = static_cast<QEglFSKmsScreen *>(window->screen()->handle());
94
95 screen->waitForFlip();
96}
97
102
104{
105 if (name == QByteArrayLiteral("dri_fd") && m_device)
106 return (void *) (qintptr) m_device->fd();
107
108#if QT_CONFIG(drm_atomic)
109 if (name == QByteArrayLiteral("dri_atomic_request") && m_device)
110 return (void *) (qintptr) m_device->threadLocalAtomicRequest();
111#endif
112 return nullptr;
113}
114
116{
117 QEglFSKmsScreen *s = static_cast<QEglFSKmsScreen *>(screen->handle());
118 if (s) {
119 if (resource == QByteArrayLiteral("dri_crtcid"))
120 return (void *) (qintptr) s->output().crtc_id;
121 if (resource == QByteArrayLiteral("dri_connectorid"))
122 return (void *) (qintptr) s->output().connector_id;
123 }
124 return nullptr;
125}
126
128{
129 return m_device;
130}
131
136
144
\inmodule QtCore
Definition qbytearray.h:57
QKmsScreenConfig * screenConfig() const
virtual QKmsScreenConfig * createScreenConfig()
QSurfaceFormat surfaceFormatFor(const QSurfaceFormat &inputFormat) const override
QKmsScreenConfig * m_screenConfig
bool hasCapability(QPlatformIntegration::Capability cap) const override
void * nativeResourceForIntegration(const QByteArray &name) override
virtual QKmsDevice * createDevice()=0
void * nativeResourceForScreen(const QByteArray &resource, QScreen *screen) override
bool supportsPBuffers() const override
bool usesDefaultScreen() override
QKmsDevice * device() const
void waitForVSync(QPlatformSurface *surface) const override
EGLNativeDisplayType platformDisplay() const override
QKmsOutput & output()
virtual void * nativeDisplay() const =0
int fd() const
void createScreens()
virtual void close()=0
virtual bool open()=0
virtual void loadConfig()
bool supportsPBuffers() const
Capability
Capabilities are used to determine specific features of a platform integration.
The QPlatformSurface class provides an abstraction for a surface.
QSurface * surface() const
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
QPlatformScreen * handle() const
Get the platform screen handle.
Definition qscreen.cpp:83
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
\inmodule QtGui
Definition qwindow.h:63
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
#define Q_UNLIKELY(x)
#define qFatal
Definition qlogging.h:168
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLuint name
GLint GLsizei GLsizei GLenum format
GLdouble s
[6]
Definition qopenglext.h:235
GLenum cap
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QScreen * screen
[1]
Definition main.cpp:29
ptrdiff_t qintptr
Definition qtypes.h:166
aWidget window() -> setWindowTitle("New Window Title")
[2]
uint32_t crtc_id