Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
// Qt-Security score:significant reason:default
6
7
#
include
"qeglfskmsintegration_p.h"
8
#
include
"qeglfskmsscreen_p.h"
9
10
#
include
<
QtKmsSupport
/
private
/
qkmsdevice_p
.
h
>
11
12
#
include
<
QtGui
/
qpa
/
qplatformwindow
.
h
>
13
#
include
<
QtGui
/
QScreen
>
14
15
#
include
<
xf86drm
.
h
>
16
#
include
<
xf86drmMode
.
h
>
17
18
QT_BEGIN_NAMESPACE
19
20
Q_LOGGING_CATEGORY
(qLcEglfsKmsDebug,
"qt.qpa.eglfs.kms"
)
21
22
QEglFSKmsIntegration::QEglFSKmsIntegration()
23
: m_device(
nullptr
)
24
{
25
}
26
27
QEglFSKmsIntegration::~QEglFSKmsIntegration()
28
{
29
}
30
31
void
QEglFSKmsIntegration::platformInit()
32
{
33
qCDebug(qLcEglfsKmsDebug,
"platformInit: Load Screen Config"
);
34
m_screenConfig = createScreenConfig();
35
36
qCDebug(qLcEglfsKmsDebug,
"platformInit: Opening DRM device"
);
37
m_device = createDevice();
38
if
(Q_UNLIKELY(!m_device->open()))
39
qFatal(
"Could not open DRM device"
);
40
}
41
42
void
QEglFSKmsIntegration::platformDestroy()
43
{
44
qCDebug(qLcEglfsKmsDebug,
"platformDestroy: Closing DRM device"
);
45
m_device->close();
46
delete
m_device;
47
m_device =
nullptr
;
48
delete
m_screenConfig;
49
m_screenConfig =
nullptr
;
50
}
51
52
EGLNativeDisplayType QEglFSKmsIntegration::platformDisplay()
const
53
{
54
Q_ASSERT(m_device);
55
return
(EGLNativeDisplayType) m_device->nativeDisplay();
56
}
57
58
bool
QEglFSKmsIntegration::usesDefaultScreen()
59
{
60
return
false
;
61
}
62
63
void
QEglFSKmsIntegration::screenInit()
64
{
65
m_device->createScreens();
66
}
67
68
QSurfaceFormat QEglFSKmsIntegration::surfaceFormatFor(
const
QSurfaceFormat &inputFormat)
const
69
{
70
QSurfaceFormat format(inputFormat);
71
format.setRenderableType(QSurfaceFormat::OpenGLES);
72
format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
73
format.setRedBufferSize(8);
74
format.setGreenBufferSize(8);
75
format.setBlueBufferSize(8);
76
return
format;
77
}
78
79
bool
QEglFSKmsIntegration::hasCapability(QPlatformIntegration::Capability cap)
const
80
{
81
switch
(cap) {
82
case
QPlatformIntegration::ThreadedPixmaps:
83
case
QPlatformIntegration::OpenGL:
84
case
QPlatformIntegration::ThreadedOpenGL:
85
return
true
;
86
default
:
87
return
false
;
88
}
89
}
90
91
void
QEglFSKmsIntegration::waitForVSync(QPlatformSurface *surface)
const
92
{
93
QWindow *window =
static_cast
<QWindow *>(surface->surface());
94
QEglFSKmsScreen *screen =
static_cast
<QEglFSKmsScreen *>(window->screen()->handle());
95
96
screen->waitForFlip();
97
}
98
99
bool
QEglFSKmsIntegration::supportsPBuffers()
const
100
{
101
return
m_screenConfig->supportsPBuffers();
102
}
103
104
void
*QEglFSKmsIntegration::nativeResourceForIntegration(
const
QByteArray &name)
105
{
106
if
(name == QByteArrayLiteral(
"dri_fd"
) && m_device)
107
return
(
void
*) (qintptr) m_device->fd();
108
109
#
if
QT_CONFIG
(
drm_atomic
)
110
if
(name == QByteArrayLiteral(
"dri_atomic_request"
) && m_device)
111
return
(
void
*) (qintptr) m_device->threadLocalAtomicRequest();
112
#
endif
113
return
nullptr
;
114
}
115
116
void
*QEglFSKmsIntegration::nativeResourceForScreen(
const
QByteArray &resource, QScreen *screen)
117
{
118
QEglFSKmsScreen *s =
static_cast
<QEglFSKmsScreen *>(screen->handle());
119
if
(s) {
120
if
(resource == QByteArrayLiteral(
"dri_crtcid"
))
121
return
(
void
*) (qintptr) s->output().crtc_id;
122
if
(resource == QByteArrayLiteral(
"dri_connectorid"
))
123
return
(
void
*) (qintptr) s->output().connector_id;
124
}
125
return
nullptr
;
126
}
127
128
QKmsDevice *QEglFSKmsIntegration::device()
const
129
{
130
return
m_device;
131
}
132
133
QKmsScreenConfig *QEglFSKmsIntegration::screenConfig()
const
134
{
135
return
m_screenConfig;
136
}
137
138
QKmsScreenConfig *QEglFSKmsIntegration::createScreenConfig()
139
{
140
QKmsScreenConfig *screenConfig =
new
QKmsScreenConfig;
141
screenConfig->loadConfig();
142
143
return
screenConfig;
144
}
145
146
QT_END_NAMESPACE
Q_LOGGING_CATEGORY
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
qtbase
src
plugins
platforms
eglfs
deviceintegration
eglfs_kms_support
qeglfskmsintegration.cpp
Generated on
for Qt by
1.18.0