Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_output.h
Show All 14 Lines | |||||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
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_OUTPUT_H | 20 | #ifndef KWIN_DRM_OUTPUT_H | ||
21 | #define KWIN_DRM_OUTPUT_H | 21 | #define KWIN_DRM_OUTPUT_H | ||
22 | 22 | | |||
23 | #include "abstract_output.h" | ||||
23 | #include "drm_pointer.h" | 24 | #include "drm_pointer.h" | ||
24 | #include "drm_object.h" | 25 | #include "drm_object.h" | ||
25 | #include "drm_object_plane.h" | 26 | #include "drm_object_plane.h" | ||
26 | 27 | | |||
27 | #include <QObject> | 28 | #include <QObject> | ||
28 | #include <QPoint> | 29 | #include <QPoint> | ||
29 | #include <QPointer> | | |||
30 | #include <QSize> | 30 | #include <QSize> | ||
31 | #include <QVector> | 31 | #include <QVector> | ||
32 | #include <xf86drmMode.h> | 32 | #include <xf86drmMode.h> | ||
33 | 33 | | |||
34 | #include <KWayland/Server/outputdevice_interface.h> | 34 | #include <KWayland/Server/outputdevice_interface.h> | ||
35 | 35 | | |||
36 | namespace KWayland | | |||
37 | { | | |||
38 | namespace Server | | |||
39 | { | | |||
40 | class OutputInterface; | | |||
41 | class OutputDeviceInterface; | | |||
42 | class OutputChangeSet; | | |||
43 | class OutputManagementInterface; | | |||
44 | class XdgOutputInterface; | | |||
45 | } | | |||
46 | } | | |||
47 | | ||||
48 | namespace KWin | 36 | namespace KWin | ||
49 | { | 37 | { | ||
50 | 38 | | |||
51 | class DrmBackend; | 39 | class DrmBackend; | ||
52 | class DrmBuffer; | 40 | class DrmBuffer; | ||
53 | class DrmDumbBuffer; | 41 | class DrmDumbBuffer; | ||
54 | class DrmPlane; | 42 | class DrmPlane; | ||
55 | class DrmConnector; | 43 | class DrmConnector; | ||
56 | class DrmCrtc; | 44 | class DrmCrtc; | ||
57 | 45 | | |||
58 | class DrmOutput : public QObject | 46 | class KWIN_EXPORT DrmOutput : public AbstractOutput | ||
59 | { | 47 | { | ||
60 | Q_OBJECT | 48 | Q_OBJECT | ||
61 | public: | 49 | public: | ||
62 | struct Edid { | 50 | struct Edid { | ||
63 | QByteArray eisaId; | 51 | QByteArray eisaId; | ||
64 | QByteArray monitorName; | 52 | QByteArray monitorName; | ||
65 | QByteArray serialNumber; | 53 | QByteArray serialNumber; | ||
66 | QSize physicalSize; | 54 | QSize physicalSize; | ||
Show All 11 Lines | |||||
78 | 66 | | |||
79 | /** | 67 | /** | ||
80 | * Enable or disable the output. | 68 | * Enable or disable the output. | ||
81 | * This differs from setDpms as it also | 69 | * This differs from setDpms as it also | ||
82 | * removes the wl_output | 70 | * removes the wl_output | ||
83 | * The default is on | 71 | * The default is on | ||
84 | */ | 72 | */ | ||
85 | void setEnabled(bool enabled); | 73 | void setEnabled(bool enabled); | ||
86 | bool isEnabled() const; | | |||
87 | | ||||
88 | /** | | |||
89 | * This sets the changes and tests them against the DRM output | | |||
90 | */ | | |||
91 | void setChanges(KWayland::Server::OutputChangeSet *changeset); | | |||
92 | bool commitChanges(); | | |||
93 | 74 | | |||
94 | QSize pixelSize() const; | 75 | bool commitChanges() override; | ||
zzag: `virtual` is redundant. It's already virtual. | |||||
95 | qreal scale() const; | | |||
96 | 76 | | |||
97 | /* | 77 | QSize pixelSize() const override; | ||
98 | * The geometry of this output in global compositor co-ordinates (i.e scaled) | | |||
99 | */ | | |||
100 | QRect geometry() const; | | |||
101 | 78 | | |||
102 | QString name() const; | | |||
103 | int currentRefreshRate() const; | 79 | int currentRefreshRate() const; | ||
104 | // These values are defined by the kernel | 80 | // These values are defined by the kernel | ||
105 | enum class DpmsMode { | 81 | enum class DpmsMode { | ||
106 | On = DRM_MODE_DPMS_ON, | 82 | On = DRM_MODE_DPMS_ON, | ||
107 | Standby = DRM_MODE_DPMS_STANDBY, | 83 | Standby = DRM_MODE_DPMS_STANDBY, | ||
108 | Suspend = DRM_MODE_DPMS_SUSPEND, | 84 | Suspend = DRM_MODE_DPMS_SUSPEND, | ||
109 | Off = DRM_MODE_DPMS_OFF | 85 | Off = DRM_MODE_DPMS_OFF | ||
110 | }; | 86 | }; | ||
111 | void setDpms(DpmsMode mode); | 87 | void setDpms(DpmsMode mode); | ||
112 | bool isDpmsEnabled() const { | 88 | bool isDpmsEnabled() const { | ||
113 | // We care for current as well as pending mode in order to allow first present in AMS. | 89 | // We care for current as well as pending mode in order to allow first present in AMS. | ||
114 | return m_dpmsModePending == DpmsMode::On; | 90 | return m_dpmsModePending == DpmsMode::On; | ||
115 | } | 91 | } | ||
116 | 92 | | |||
117 | QByteArray uuid() const { | 93 | QByteArray uuid() const { | ||
118 | return m_uuid; | 94 | return m_uuid; | ||
119 | } | 95 | } | ||
120 | 96 | | |||
121 | QSize physicalSize() const; | | |||
122 | | ||||
123 | bool initCursor(const QSize &cursorSize); | 97 | bool initCursor(const QSize &cursorSize); | ||
124 | 98 | | |||
125 | bool supportsTransformations() const; | 99 | bool supportsTransformations() const; | ||
126 | 100 | | |||
127 | bool isInternal() const { | | |||
128 | return m_internal; | | |||
129 | } | | |||
130 | | ||||
131 | Qt::ScreenOrientation orientation() const { | | |||
132 | return m_orientation; | | |||
133 | } | | |||
134 | | ||||
135 | const QPointer<KWayland::Server::OutputInterface> getWaylandInterface() const { | | |||
136 | return m_waylandOutput; | | |||
137 | } | | |||
138 | | ||||
139 | Q_SIGNALS: | 101 | Q_SIGNALS: | ||
140 | void dpmsChanged(); | 102 | void dpmsChanged(); | ||
141 | void modeChanged(); | 103 | void modeChanged(); | ||
142 | 104 | | |||
143 | private: | 105 | private: | ||
144 | friend class DrmBackend; | 106 | friend class DrmBackend; | ||
145 | friend class DrmCrtc; // TODO: For use of setModeLegacy. Remove later when we allow multiple connectors per crtc | 107 | friend class DrmCrtc; // TODO: For use of setModeLegacy. Remove later when we allow multiple connectors per crtc | ||
146 | // and save the connector ids in the DrmCrtc instance. | 108 | // and save the connector ids in the DrmCrtc instance. | ||
Show All 9 Lines | |||||
156 | bool presentLegacy(DrmBuffer *buffer); | 118 | bool presentLegacy(DrmBuffer *buffer); | ||
157 | bool setModeLegacy(DrmBuffer *buffer); | 119 | bool setModeLegacy(DrmBuffer *buffer); | ||
158 | void initEdid(drmModeConnector *connector); | 120 | void initEdid(drmModeConnector *connector); | ||
159 | void initDpms(drmModeConnector *connector); | 121 | void initDpms(drmModeConnector *connector); | ||
160 | void initOutputDevice(drmModeConnector *connector); | 122 | void initOutputDevice(drmModeConnector *connector); | ||
161 | 123 | | |||
162 | bool isCurrentMode(const drmModeModeInfo *mode) const; | 124 | bool isCurrentMode(const drmModeModeInfo *mode) const; | ||
163 | void initUuid(); | 125 | void initUuid(); | ||
164 | void setGlobalPos(const QPoint &pos); | | |||
165 | void setScale(qreal scale); | | |||
166 | void initOutput(); | 126 | void initOutput(); | ||
167 | bool initPrimaryPlane(); | 127 | bool initPrimaryPlane(); | ||
168 | bool initCursorPlane(); | 128 | bool initCursorPlane(); | ||
169 | 129 | | |||
170 | void dpmsOnHandler(); | 130 | void dpmsOnHandler(); | ||
171 | void dpmsOffHandler(); | 131 | void dpmsOffHandler(); | ||
172 | bool dpmsAtomicOff(); | 132 | bool dpmsAtomicOff(); | ||
173 | bool atomicReqModesetPopulate(drmModeAtomicReq *req, bool enable); | 133 | bool atomicReqModesetPopulate(drmModeAtomicReq *req, bool enable); | ||
174 | void updateMode(int modeIndex); | 134 | void updateMode(int modeIndex); | ||
175 | 135 | | |||
176 | void transform(KWayland::Server::OutputDeviceInterface::Transform transform); | 136 | void transform(KWayland::Server::OutputDeviceInterface::Transform transform); | ||
177 | void automaticRotation(); | 137 | void automaticRotation(); | ||
178 | 138 | | |||
179 | DrmBackend *m_backend; | 139 | DrmBackend *m_backend; | ||
180 | DrmConnector *m_conn = nullptr; | 140 | DrmConnector *m_conn = nullptr; | ||
181 | DrmCrtc *m_crtc = nullptr; | 141 | DrmCrtc *m_crtc = nullptr; | ||
182 | QPoint m_globalPos; | | |||
183 | qreal m_scale = 1; | | |||
184 | bool m_lastGbm = false; | 142 | bool m_lastGbm = false; | ||
185 | drmModeModeInfo m_mode; | 143 | drmModeModeInfo m_mode; | ||
186 | Edid m_edid; | 144 | Edid m_edid; | ||
187 | QPointer<KWayland::Server::OutputInterface> m_waylandOutput; | | |||
188 | QPointer<KWayland::Server::XdgOutputInterface> m_xdgOutput; | | |||
189 | QPointer<KWayland::Server::OutputDeviceInterface> m_waylandOutputDevice; | | |||
190 | QPointer<KWayland::Server::OutputChangeSet> m_changeset; | | |||
191 | KWin::ScopedDrmPointer<_drmModeProperty, &drmModeFreeProperty> m_dpms; | 145 | KWin::ScopedDrmPointer<_drmModeProperty, &drmModeFreeProperty> m_dpms; | ||
192 | DpmsMode m_dpmsMode = DpmsMode::On; | 146 | DpmsMode m_dpmsMode = DpmsMode::On; | ||
193 | DpmsMode m_dpmsModePending = DpmsMode::On; | 147 | DpmsMode m_dpmsModePending = DpmsMode::On; | ||
194 | QByteArray m_uuid; | 148 | QByteArray m_uuid; | ||
195 | 149 | | |||
196 | uint32_t m_blobId = 0; | 150 | uint32_t m_blobId = 0; | ||
197 | DrmPlane* m_primaryPlane = nullptr; | 151 | DrmPlane* m_primaryPlane = nullptr; | ||
198 | DrmPlane* m_cursorPlane = nullptr; | 152 | DrmPlane* m_cursorPlane = nullptr; | ||
199 | QVector<DrmPlane*> m_nextPlanesFlipList; | 153 | QVector<DrmPlane*> m_nextPlanesFlipList; | ||
200 | bool m_pageFlipPending = false; | 154 | bool m_pageFlipPending = false; | ||
201 | bool m_dpmsAtomicOffPending = false; | 155 | bool m_dpmsAtomicOffPending = false; | ||
202 | bool m_modesetRequested = true; | 156 | bool m_modesetRequested = true; | ||
203 | QSize m_physicalSize; | | |||
204 | Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation; | | |||
205 | 157 | | |||
206 | struct { | 158 | struct { | ||
207 | Qt::ScreenOrientation orientation; | 159 | Qt::ScreenOrientation orientation; | ||
208 | drmModeModeInfo mode; | 160 | drmModeModeInfo mode; | ||
209 | DrmPlane::Transformations planeTransformations; | 161 | DrmPlane::Transformations planeTransformations; | ||
210 | QPoint globalPos; | 162 | QPoint globalPos; | ||
211 | bool valid = false; | 163 | bool valid = false; | ||
212 | } m_lastWorkingState; | 164 | } m_lastWorkingState; | ||
213 | DrmDumbBuffer *m_cursor[2] = {nullptr, nullptr}; | 165 | DrmDumbBuffer *m_cursor[2] = {nullptr, nullptr}; | ||
214 | int m_cursorIndex = 0; | 166 | int m_cursorIndex = 0; | ||
215 | bool m_hasNewCursor = false; | 167 | bool m_hasNewCursor = false; | ||
216 | bool m_internal = false; | | |||
217 | }; | 168 | }; | ||
218 | 169 | | |||
219 | } | 170 | } | ||
220 | 171 | | |||
221 | Q_DECLARE_METATYPE(KWin::DrmOutput*) | 172 | Q_DECLARE_METATYPE(KWin::DrmOutput*) | ||
222 | 173 | | |||
223 | #endif | 174 | #endif | ||
224 | 175 | |
virtual is redundant. It's already virtual.