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 14 Lines | |||||
81 | 69 | | |||
82 | /** | 70 | /** | ||
83 | * Enable or disable the output. | 71 | * Enable or disable the output. | ||
84 | * This differs from setDpms as it also | 72 | * This differs from setDpms as it also | ||
85 | * removes the wl_output | 73 | * removes the wl_output | ||
86 | * The default is on | 74 | * The default is on | ||
87 | */ | 75 | */ | ||
88 | void setEnabled(bool enabled); | 76 | void setEnabled(bool enabled); | ||
89 | bool isEnabled() const; | | |||
90 | | ||||
91 | /** | | |||
92 | * This sets the changes and tests them against the DRM output | | |||
93 | */ | | |||
94 | void setChanges(KWayland::Server::OutputChangeSet *changeset); | | |||
95 | bool commitChanges(); | | |||
96 | 77 | | |||
97 | QSize pixelSize() const; | 78 | bool commitChanges() override; | ||
zzag: `virtual` is redundant. It's already virtual. | |||||
98 | qreal scale() const; | | |||
99 | 79 | | |||
100 | /* | 80 | QSize pixelSize() const override; | ||
101 | * The geometry of this output in global compositor co-ordinates (i.e scaled) | | |||
102 | */ | | |||
103 | QRect geometry() const; | | |||
104 | 81 | | |||
105 | QString name() const; | | |||
106 | int currentRefreshRate() const; | 82 | int currentRefreshRate() const; | ||
107 | // These values are defined by the kernel | 83 | // These values are defined by the kernel | ||
108 | enum class DpmsMode { | 84 | enum class DpmsMode { | ||
109 | On = DRM_MODE_DPMS_ON, | 85 | On = DRM_MODE_DPMS_ON, | ||
110 | Standby = DRM_MODE_DPMS_STANDBY, | 86 | Standby = DRM_MODE_DPMS_STANDBY, | ||
111 | Suspend = DRM_MODE_DPMS_SUSPEND, | 87 | Suspend = DRM_MODE_DPMS_SUSPEND, | ||
112 | Off = DRM_MODE_DPMS_OFF | 88 | Off = DRM_MODE_DPMS_OFF | ||
113 | }; | 89 | }; | ||
114 | void setDpms(DpmsMode mode); | 90 | void setDpms(DpmsMode mode); | ||
115 | bool isDpmsEnabled() const { | 91 | bool isDpmsEnabled() const { | ||
116 | // We care for current as well as pending mode in order to allow first present in AMS. | 92 | // We care for current as well as pending mode in order to allow first present in AMS. | ||
117 | return m_dpmsModePending == DpmsMode::On; | 93 | return m_dpmsModePending == DpmsMode::On; | ||
118 | } | 94 | } | ||
119 | 95 | | |||
120 | QByteArray uuid() const { | 96 | QByteArray uuid() const { | ||
121 | return m_uuid; | 97 | return m_uuid; | ||
122 | } | 98 | } | ||
123 | 99 | | |||
124 | QSize physicalSize() const; | | |||
125 | | ||||
126 | bool initCursor(const QSize &cursorSize); | 100 | bool initCursor(const QSize &cursorSize); | ||
127 | 101 | | |||
128 | bool supportsTransformations() const; | 102 | bool supportsTransformations() const; | ||
129 | 103 | | |||
130 | bool isInternal() const { | | |||
131 | return m_internal; | | |||
132 | } | | |||
133 | | ||||
134 | Qt::ScreenOrientation orientation() const { | | |||
135 | return m_orientation; | | |||
136 | } | | |||
137 | | ||||
138 | const QPointer<KWayland::Server::OutputInterface> getWaylandInterface() const { | | |||
139 | return m_waylandOutput; | | |||
140 | } | | |||
141 | | ||||
142 | Q_SIGNALS: | 104 | Q_SIGNALS: | ||
143 | void dpmsChanged(); | 105 | void dpmsChanged(); | ||
144 | void modeChanged(); | 106 | void modeChanged(); | ||
145 | 107 | | |||
146 | private: | 108 | private: | ||
147 | friend class DrmBackend; | 109 | friend class DrmBackend; | ||
148 | friend class DrmCrtc; // TODO: For use of setModeLegacy. Remove later when we allow multiple connectors per crtc | 110 | friend class DrmCrtc; // TODO: For use of setModeLegacy. Remove later when we allow multiple connectors per crtc | ||
149 | // and save the connector ids in the DrmCrtc instance. | 111 | // and save the connector ids in the DrmCrtc instance. | ||
Show All 10 Lines | |||||
160 | bool presentLegacy(DrmBuffer *buffer); | 122 | bool presentLegacy(DrmBuffer *buffer); | ||
161 | bool setModeLegacy(DrmBuffer *buffer); | 123 | bool setModeLegacy(DrmBuffer *buffer); | ||
162 | void initEdid(drmModeConnector *connector); | 124 | void initEdid(drmModeConnector *connector); | ||
163 | void initDpms(drmModeConnector *connector); | 125 | void initDpms(drmModeConnector *connector); | ||
164 | void initOutputDevice(drmModeConnector *connector); | 126 | void initOutputDevice(drmModeConnector *connector); | ||
165 | 127 | | |||
166 | bool isCurrentMode(const drmModeModeInfo *mode) const; | 128 | bool isCurrentMode(const drmModeModeInfo *mode) const; | ||
167 | void initUuid(); | 129 | void initUuid(); | ||
168 | void setGlobalPos(const QPoint &pos); | | |||
169 | void setScale(qreal scale); | | |||
170 | void initOutput(); | 130 | void initOutput(); | ||
171 | bool initPrimaryPlane(); | 131 | bool initPrimaryPlane(); | ||
172 | bool initCursorPlane(); | 132 | bool initCursorPlane(); | ||
173 | 133 | | |||
174 | void dpmsOnHandler(); | 134 | void dpmsOnHandler(); | ||
175 | void dpmsOffHandler(); | 135 | void dpmsOffHandler(); | ||
176 | bool dpmsAtomicOff(); | 136 | bool dpmsAtomicOff(); | ||
177 | bool atomicReqModesetPopulate(drmModeAtomicReq *req, bool enable); | 137 | bool atomicReqModesetPopulate(drmModeAtomicReq *req, bool enable); | ||
178 | void updateMode(int modeIndex); | 138 | void updateMode(int modeIndex); | ||
179 | 139 | | |||
180 | void transform(KWayland::Server::OutputDeviceInterface::Transform transform); | 140 | void transform(KWayland::Server::OutputDeviceInterface::Transform transform); | ||
181 | void automaticRotation(); | 141 | void automaticRotation(); | ||
182 | 142 | | |||
183 | DrmBackend *m_backend; | 143 | DrmBackend *m_backend; | ||
184 | DrmConnector *m_conn = nullptr; | 144 | DrmConnector *m_conn = nullptr; | ||
185 | DrmCrtc *m_crtc = nullptr; | 145 | DrmCrtc *m_crtc = nullptr; | ||
186 | QPoint m_globalPos; | | |||
187 | qreal m_scale = 1; | | |||
188 | bool m_lastGbm = false; | 146 | bool m_lastGbm = false; | ||
189 | drmModeModeInfo m_mode; | 147 | drmModeModeInfo m_mode; | ||
190 | Edid m_edid; | 148 | Edid m_edid; | ||
191 | QPointer<KWayland::Server::OutputInterface> m_waylandOutput; | | |||
192 | QPointer<KWayland::Server::XdgOutputInterface> m_xdgOutput; | | |||
193 | QPointer<KWayland::Server::OutputDeviceInterface> m_waylandOutputDevice; | | |||
194 | QPointer<KWayland::Server::OutputChangeSet> m_changeset; | | |||
195 | KWin::ScopedDrmPointer<_drmModeProperty, &drmModeFreeProperty> m_dpms; | 149 | KWin::ScopedDrmPointer<_drmModeProperty, &drmModeFreeProperty> m_dpms; | ||
196 | DpmsMode m_dpmsMode = DpmsMode::On; | 150 | DpmsMode m_dpmsMode = DpmsMode::On; | ||
197 | DpmsMode m_dpmsModePending = DpmsMode::On; | 151 | DpmsMode m_dpmsModePending = DpmsMode::On; | ||
198 | QByteArray m_uuid; | 152 | QByteArray m_uuid; | ||
199 | 153 | | |||
200 | uint32_t m_blobId = 0; | 154 | uint32_t m_blobId = 0; | ||
201 | DrmPlane* m_primaryPlane = nullptr; | 155 | DrmPlane* m_primaryPlane = nullptr; | ||
202 | DrmPlane* m_cursorPlane = nullptr; | 156 | DrmPlane* m_cursorPlane = nullptr; | ||
203 | QVector<DrmPlane*> m_nextPlanesFlipList; | 157 | QVector<DrmPlane*> m_nextPlanesFlipList; | ||
204 | bool m_pageFlipPending = false; | 158 | bool m_pageFlipPending = false; | ||
205 | bool m_dpmsAtomicOffPending = false; | 159 | bool m_dpmsAtomicOffPending = false; | ||
206 | bool m_modesetRequested = true; | 160 | bool m_modesetRequested = true; | ||
207 | QSize m_physicalSize; | | |||
208 | Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation; | | |||
209 | 161 | | |||
210 | struct { | 162 | struct { | ||
211 | Qt::ScreenOrientation orientation; | 163 | Qt::ScreenOrientation orientation; | ||
212 | drmModeModeInfo mode; | 164 | drmModeModeInfo mode; | ||
213 | DrmPlane::Transformations planeTransformations; | 165 | DrmPlane::Transformations planeTransformations; | ||
214 | QPoint globalPos; | 166 | QPoint globalPos; | ||
215 | bool valid = false; | 167 | bool valid = false; | ||
216 | } m_lastWorkingState; | 168 | } m_lastWorkingState; | ||
Show All 13 Lines |
virtual is redundant. It's already virtual.