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