Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_backend.h
Show All 17 Lines | |||||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #ifndef KWIN_DRM_BACKEND_H | 20 | #ifndef KWIN_DRM_BACKEND_H | ||
21 | #define KWIN_DRM_BACKEND_H | 21 | #define KWIN_DRM_BACKEND_H | ||
22 | #include "platform.h" | 22 | #include "platform.h" | ||
23 | #include "input.h" | 23 | #include "input.h" | ||
24 | 24 | | |||
25 | #include "drm_buffer.h" | 25 | #include "drm_buffer.h" | ||
26 | #if HAVE_GBM | ||||
27 | #include "drm_buffer_gbm.h" | ||||
28 | #endif | ||||
26 | #include "drm_inputeventfilter.h" | 29 | #include "drm_inputeventfilter.h" | ||
27 | #include "drm_pointer.h" | 30 | #include "drm_pointer.h" | ||
28 | 31 | | |||
29 | #include <QElapsedTimer> | 32 | #include <QElapsedTimer> | ||
30 | #include <QImage> | 33 | #include <QImage> | ||
31 | #include <QPointer> | 34 | #include <QPointer> | ||
32 | #include <QSize> | 35 | #include <QSize> | ||
33 | #include <xf86drmMode.h> | 36 | #include <xf86drmMode.h> | ||
Show All 16 Lines | |||||
50 | namespace KWin | 53 | namespace KWin | ||
51 | { | 54 | { | ||
52 | 55 | | |||
53 | class Udev; | 56 | class Udev; | ||
54 | class UdevMonitor; | 57 | class UdevMonitor; | ||
55 | 58 | | |||
56 | class DrmOutput; | 59 | class DrmOutput; | ||
57 | class DrmPlane; | 60 | class DrmPlane; | ||
61 | class DrmCrtc; | ||||
62 | class DrmConnector; | ||||
58 | 63 | | |||
59 | 64 | | |||
60 | class KWIN_EXPORT DrmBackend : public Platform | 65 | class KWIN_EXPORT DrmBackend : public Platform | ||
61 | { | 66 | { | ||
62 | Q_OBJECT | 67 | Q_OBJECT | ||
63 | Q_INTERFACES(KWin::Platform) | 68 | Q_INTERFACES(KWin::Platform) | ||
64 | Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "drm.json") | 69 | Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "drm.json") | ||
65 | public: | 70 | public: | ||
66 | explicit DrmBackend(QObject *parent = nullptr); | 71 | explicit DrmBackend(QObject *parent = nullptr); | ||
67 | virtual ~DrmBackend(); | 72 | virtual ~DrmBackend(); | ||
68 | 73 | | |||
69 | void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config) override; | 74 | void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config) override; | ||
70 | Screens *createScreens(QObject *parent = nullptr) override; | 75 | Screens *createScreens(QObject *parent = nullptr) override; | ||
71 | QPainterBackend *createQPainterBackend() override; | 76 | QPainterBackend *createQPainterBackend() override; | ||
72 | OpenGLBackend* createOpenGLBackend() override; | 77 | OpenGLBackend* createOpenGLBackend() override; | ||
73 | 78 | | |||
74 | void init() override; | 79 | void init() override; | ||
75 | DrmBuffer *createBuffer(const QSize &size); | 80 | DrmDumbBuffer *createBuffer(const QSize &size); | ||
76 | DrmBuffer *createBuffer(gbm_surface *surface); | 81 | DrmSurfaceBuffer *createBuffer(gbm_surface *surface); | ||
77 | void present(DrmBuffer *buffer, DrmOutput *output); | 82 | void present(DrmBuffer *buffer, DrmOutput *output); | ||
78 | 83 | | |||
79 | int fd() const { | 84 | int fd() const { | ||
80 | return m_fd; | 85 | return m_fd; | ||
81 | } | 86 | } | ||
82 | QVector<DrmOutput*> outputs() const { | 87 | QVector<DrmOutput*> outputs() const { | ||
83 | return m_outputs; | 88 | return m_outputs; | ||
84 | } | 89 | } | ||
85 | QVector<DrmBuffer*> buffers() const { | | |||
86 | return m_buffers; | | |||
87 | } | | |||
88 | QVector<DrmPlane*> planes() const { | 90 | QVector<DrmPlane*> planes() const { | ||
89 | return m_planes; | 91 | return m_planes; | ||
90 | } | 92 | } | ||
91 | void bufferDestroyed(DrmBuffer *b); | 93 | QVector<DrmPlane*> overlayPlanes() const { | ||
94 | return m_overlayPlanes; | ||||
95 | } | ||||
92 | 96 | | |||
93 | void outputWentOff(); | 97 | void outputWentOff(); | ||
94 | void checkOutputsAreOn(); | 98 | void checkOutputsAreOn(); | ||
95 | 99 | | |||
100 | // QPainter reuses buffers | ||||
101 | bool deleteBufferAfterPageFlip() const { | ||||
102 | return m_deleteBufferAfterPageFlip; | ||||
103 | } | ||||
96 | // returns use of AMS, default is not/legacy | 104 | // returns use of AMS, default is not/legacy | ||
97 | bool atomicModeSetting() const { | 105 | bool atomicModeSetting() const { | ||
98 | return m_atomicModeSetting; | 106 | return m_atomicModeSetting; | ||
99 | } | 107 | } | ||
100 | 108 | | |||
101 | void setGbmDevice(gbm_device *device) { | 109 | void setGbmDevice(gbm_device *device) { | ||
102 | m_gbmDevice = device; | 110 | m_gbmDevice = device; | ||
103 | } | 111 | } | ||
Show All 14 Lines | 123 | protected: | |||
118 | void doShowCursor() override; | 126 | void doShowCursor() override; | ||
119 | 127 | | |||
120 | private: | 128 | private: | ||
121 | static void pageFlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data); | 129 | static void pageFlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data); | ||
122 | void openDrm(); | 130 | void openDrm(); | ||
123 | void activate(bool active); | 131 | void activate(bool active); | ||
124 | void reactivate(); | 132 | void reactivate(); | ||
125 | void deactivate(); | 133 | void deactivate(); | ||
126 | void queryResources(); | 134 | void updateOutputs(); | ||
127 | void setCursor(); | 135 | void setCursor(); | ||
128 | void updateCursor(); | 136 | void updateCursor(); | ||
129 | void moveCursor(); | 137 | void moveCursor(); | ||
130 | void initCursor(); | 138 | void initCursor(); | ||
131 | quint32 findCrtc(drmModeRes *res, drmModeConnector *connector, bool *ok = nullptr); | | |||
132 | bool crtcIsUsed(quint32 crtc); | | |||
133 | void outputDpmsChanged(); | 139 | void outputDpmsChanged(); | ||
134 | void readOutputsConfiguration(); | 140 | void readOutputsConfiguration(); | ||
135 | QByteArray generateOutputConfigurationUuid() const; | 141 | QByteArray generateOutputConfigurationUuid() const; | ||
136 | DrmOutput *findOutput(quint32 connector); | 142 | DrmOutput *findOutput(quint32 connector); | ||
137 | DrmOutput *findOutput(const QByteArray &uuid); | 143 | DrmOutput *findOutput(const QByteArray &uuid); | ||
138 | QScopedPointer<Udev> m_udev; | 144 | QScopedPointer<Udev> m_udev; | ||
139 | QScopedPointer<UdevMonitor> m_udevMonitor; | 145 | QScopedPointer<UdevMonitor> m_udevMonitor; | ||
140 | int m_fd = -1; | 146 | int m_fd = -1; | ||
141 | int m_drmId = 0; | 147 | int m_drmId = 0; | ||
148 | // all crtcs | ||||
149 | QVector<DrmCrtc*> m_crtcs; | ||||
150 | // all connectors | ||||
151 | QVector<DrmConnector*> m_connectors; | ||||
152 | // currently active output pipelines (planes + crtc + encoder + connector) | ||||
142 | QVector<DrmOutput*> m_outputs; | 153 | QVector<DrmOutput*> m_outputs; | ||
143 | DrmBuffer *m_cursor[2]; | 154 | DrmDumbBuffer *m_cursor[2]; | ||
155 | bool m_deleteBufferAfterPageFlip; | ||||
144 | bool m_atomicModeSetting = false; | 156 | bool m_atomicModeSetting = false; | ||
145 | bool m_cursorEnabled = false; | 157 | bool m_cursorEnabled = false; | ||
146 | int m_cursorIndex = 0; | 158 | int m_cursorIndex = 0; | ||
147 | int m_pageFlipsPending = 0; | 159 | int m_pageFlipsPending = 0; | ||
148 | bool m_active = false; | 160 | bool m_active = false; | ||
149 | QVector<DrmBuffer*> m_buffers; | | |||
150 | // all available planes: primarys, cursors and overlays | 161 | // all available planes: primarys, cursors and overlays | ||
151 | QVector<DrmPlane*> m_planes; | 162 | QVector<DrmPlane*> m_planes; | ||
163 | QVector<DrmPlane*> m_overlayPlanes; | ||||
152 | QScopedPointer<DpmsInputEventFilter> m_dpmsFilter; | 164 | QScopedPointer<DpmsInputEventFilter> m_dpmsFilter; | ||
153 | KWayland::Server::OutputManagementInterface *m_outputManagement = nullptr; | 165 | KWayland::Server::OutputManagementInterface *m_outputManagement = nullptr; | ||
154 | gbm_device *m_gbmDevice = nullptr; | 166 | gbm_device *m_gbmDevice = nullptr; | ||
155 | }; | 167 | }; | ||
156 | 168 | | |||
157 | 169 | | |||
158 | } | 170 | } | ||
159 | 171 | | |||
160 | #endif | 172 | #endif | ||
161 | 173 | |