Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_output.h
Show All 32 Lines | |||||
33 | namespace KWayland | 33 | namespace KWayland | ||
34 | { | 34 | { | ||
35 | namespace Server | 35 | namespace Server | ||
36 | { | 36 | { | ||
37 | class OutputInterface; | 37 | class OutputInterface; | ||
38 | class OutputDeviceInterface; | 38 | class OutputDeviceInterface; | ||
39 | class OutputChangeSet; | 39 | class OutputChangeSet; | ||
40 | class OutputManagementInterface; | 40 | class OutputManagementInterface; | ||
41 | class BufferInterface; | ||||
41 | } | 42 | } | ||
42 | } | 43 | } | ||
43 | 44 | | |||
44 | namespace KWin | 45 | namespace KWin | ||
45 | { | 46 | { | ||
46 | 47 | | |||
47 | class DrmBackend; | 48 | class DrmBackend; | ||
48 | class DrmBuffer; | 49 | class DrmBuffer; | ||
50 | class DrmDumbBuffer; | ||||
49 | class DrmPlane; | 51 | class DrmPlane; | ||
50 | class DrmConnector; | 52 | class DrmConnector; | ||
51 | class DrmCrtc; | 53 | class DrmCrtc; | ||
52 | 54 | | |||
53 | class DrmOutput : public QObject | 55 | class DrmOutput : public QObject | ||
54 | { | 56 | { | ||
55 | Q_OBJECT | 57 | Q_OBJECT | ||
56 | public: | 58 | public: | ||
57 | struct Edid { | 59 | struct Edid { | ||
58 | QByteArray eisaId; | 60 | QByteArray eisaId; | ||
59 | QByteArray monitorName; | 61 | QByteArray monitorName; | ||
60 | QByteArray serialNumber; | 62 | QByteArray serialNumber; | ||
61 | QSize physicalSize; | 63 | QSize physicalSize; | ||
62 | }; | 64 | }; | ||
63 | virtual ~DrmOutput(); | 65 | virtual ~DrmOutput(); | ||
64 | void showCursor(DrmBuffer *buffer); | 66 | void showCursor(DrmDumbBuffer *buffer); | ||
65 | void hideCursor(); | 67 | void hideCursor(); | ||
66 | void moveCursor(const QPoint &globalPos); | 68 | void moveCursor(const QPoint &globalPos); | ||
67 | bool init(drmModeConnector *connector); | 69 | bool init(drmModeConnector *connector); | ||
70 | bool assignClientPlane(KWayland::Server::BufferInterface *buffer); | ||||
68 | bool present(DrmBuffer *buffer); | 71 | bool present(DrmBuffer *buffer); | ||
69 | void pageFlipped(); | 72 | void pageFlipped(); | ||
70 | void restoreSaved(); | 73 | void restoreSaved(); | ||
71 | bool blank(); | 74 | bool blank(); | ||
72 | 75 | | |||
73 | /** | 76 | /** | ||
74 | * This sets the changes and tests them against the DRM output | 77 | * This sets the changes and tests them against the DRM output | ||
75 | */ | 78 | */ | ||
76 | void setChanges(KWayland::Server::OutputChangeSet *changeset); | 79 | void setChanges(KWayland::Server::OutputChangeSet *changeset); | ||
77 | bool commitChanges(); | 80 | bool commitChanges(); | ||
78 | 81 | | |||
79 | QSize size() const; | 82 | QSize size() const; | ||
80 | QRect geometry() const; | 83 | QRect geometry() const; | ||
81 | QString name() const; | 84 | QString name() const; | ||
82 | int currentRefreshRate() const; | 85 | int currentRefreshRate() const; | ||
83 | // These values are defined by the kernel | 86 | // These values are defined by the kernel | ||
84 | enum class DpmsMode { | 87 | enum class DpmsMode { | ||
85 | On = DRM_MODE_DPMS_ON, | 88 | On = DRM_MODE_DPMS_ON, | ||
86 | Standby = DRM_MODE_DPMS_STANDBY, | 89 | Standby = DRM_MODE_DPMS_STANDBY, | ||
87 | Suspend = DRM_MODE_DPMS_SUSPEND, | 90 | Suspend = DRM_MODE_DPMS_SUSPEND, | ||
88 | Off = DRM_MODE_DPMS_OFF | 91 | Off = DRM_MODE_DPMS_OFF | ||
89 | }; | 92 | }; | ||
90 | void setDpms(DpmsMode mode); | 93 | void setDpms(DpmsMode mode); | ||
91 | bool isDpmsEnabled() const { | 94 | bool isDpmsEnabled() const { | ||
92 | return m_dpmsMode == DpmsMode::On; | 95 | // We care for current aswell as pending mode in order to allow first present in AMS. | ||
96 | return m_dpmsModePending == DpmsMode::On; | ||||
93 | } | 97 | } | ||
94 | 98 | | |||
95 | QByteArray uuid() const { | 99 | QByteArray uuid() const { | ||
96 | return m_uuid; | 100 | return m_uuid; | ||
97 | } | 101 | } | ||
98 | 102 | | |||
99 | Q_SIGNALS: | 103 | Q_SIGNALS: | ||
100 | void dpmsChanged(); | 104 | void dpmsChanged(); | ||
101 | 105 | | |||
102 | private: | 106 | private: | ||
103 | friend class DrmBackend; | 107 | friend class DrmBackend; | ||
104 | DrmOutput(DrmBackend *backend); | 108 | DrmOutput(DrmBackend *backend); | ||
105 | void cleanupBlackBuffer(); | 109 | void cleanupBlackBuffer(); | ||
106 | bool presentAtomically(DrmBuffer *buffer); | 110 | bool presentAtomically(DrmBuffer *buffer); | ||
111 | | ||||
112 | enum class AtomicCommitMode { | ||||
113 | Test, | ||||
114 | Real | ||||
115 | }; | ||||
116 | bool doAtomicCommit(AtomicCommitMode mode); | ||||
117 | | ||||
107 | bool presentLegacy(DrmBuffer *buffer); | 118 | bool presentLegacy(DrmBuffer *buffer); | ||
108 | bool setModeLegacy(DrmBuffer *buffer); | 119 | bool setModeLegacy(DrmBuffer *buffer); | ||
109 | void initEdid(drmModeConnector *connector); | 120 | void initEdid(drmModeConnector *connector); | ||
110 | void initDpms(drmModeConnector *connector); | 121 | void initDpms(drmModeConnector *connector); | ||
111 | bool isCurrentMode(const drmModeModeInfo *mode) const; | 122 | bool isCurrentMode(const drmModeModeInfo *mode) const; | ||
112 | void initUuid(); | 123 | void initUuid(); | ||
113 | void setGlobalPos(const QPoint &pos); | 124 | void setGlobalPos(const QPoint &pos); | ||
114 | 125 | | |||
115 | void pageFlippedBufferRemover(DrmBuffer *oldbuffer, DrmBuffer *newbuffer); | | |||
116 | bool initPrimaryPlane(); | 126 | bool initPrimaryPlane(); | ||
117 | bool initCursorPlane(); | 127 | bool initCursorPlane(); | ||
118 | DrmObject::AtomicReturn atomicReqModesetPopulate(drmModeAtomicReq *req, bool enable); | 128 | | ||
129 | void dpmsOnHandler(); | ||||
130 | void dpmsOffHandler(); | ||||
131 | bool dpmsOffAtomically(); | ||||
132 | bool atomicReqModesetPopulate(drmModeAtomicReq *req, bool enable); | ||||
119 | 133 | | |||
120 | DrmBackend *m_backend; | 134 | DrmBackend *m_backend; | ||
121 | QPoint m_globalPos; | 135 | QPoint m_globalPos; | ||
122 | quint32 m_crtcId = 0; | | |||
123 | quint32 m_connector = 0; | | |||
124 | quint32 m_lastStride = 0; | 136 | quint32 m_lastStride = 0; | ||
romangg: Remove | |||||
125 | bool m_lastGbm = false; | 137 | bool m_lastGbm = false; | ||
126 | drmModeModeInfo m_mode; | 138 | drmModeModeInfo m_mode; | ||
127 | DrmBuffer *m_currentBuffer = nullptr; | 139 | DrmBuffer *m_currentBuffer = nullptr; | ||
128 | DrmBuffer *m_nextBuffer = nullptr; | 140 | DrmBuffer *m_nextBuffer = nullptr; | ||
129 | DrmBuffer *m_blackBuffer = nullptr; | 141 | DrmDumbBuffer *m_blackBuffer = nullptr; | ||
130 | struct CrtcCleanup { | 142 | struct CrtcCleanup { | ||
131 | static void inline cleanup(_drmModeCrtc *ptr) { | 143 | static void inline cleanup(_drmModeCrtc *ptr) { | ||
132 | drmModeFreeCrtc(ptr); // TODO: Atomically? See compositor-drm.c l.3670 | 144 | drmModeFreeCrtc(ptr); // TODO: Atomically? See compositor-drm.c l.3670 | ||
133 | } | 145 | } | ||
134 | }; | 146 | }; | ||
135 | Edid m_edid; | 147 | Edid m_edid; | ||
136 | QScopedPointer<_drmModeCrtc, CrtcCleanup> m_savedCrtc; | 148 | QScopedPointer<_drmModeCrtc, CrtcCleanup> m_savedCrtc; | ||
137 | QPointer<KWayland::Server::OutputInterface> m_waylandOutput; | 149 | QPointer<KWayland::Server::OutputInterface> m_waylandOutput; | ||
138 | QPointer<KWayland::Server::OutputDeviceInterface> m_waylandOutputDevice; | 150 | QPointer<KWayland::Server::OutputDeviceInterface> m_waylandOutputDevice; | ||
139 | QPointer<KWayland::Server::OutputChangeSet> m_changeset; | 151 | QPointer<KWayland::Server::OutputChangeSet> m_changeset; | ||
140 | KWin::ScopedDrmPointer<_drmModeProperty, &drmModeFreeProperty> m_dpms; | 152 | KWin::ScopedDrmPointer<_drmModeProperty, &drmModeFreeProperty> m_dpms; | ||
141 | DpmsMode m_dpmsMode = DpmsMode::On; | 153 | DpmsMode m_dpmsMode = DpmsMode::On; | ||
154 | DpmsMode m_dpmsModePending = DpmsMode::On; | ||||
142 | QByteArray m_uuid; | 155 | QByteArray m_uuid; | ||
143 | 156 | | |||
144 | DrmConnector *m_conn = nullptr; | 157 | DrmConnector *m_conn = nullptr; | ||
145 | DrmCrtc *m_crtc = nullptr; | 158 | DrmCrtc *m_crtc = nullptr; | ||
146 | uint32_t m_blobId = 0; | 159 | uint32_t m_blobId = 0; | ||
147 | DrmPlane* m_primaryPlane = nullptr; | 160 | DrmPlane* m_primaryPlane = nullptr; | ||
148 | DrmPlane* m_cursorPlane = nullptr; | 161 | DrmPlane* m_cursorPlane = nullptr; | ||
149 | QVector<DrmPlane*> m_planesFlipList; | 162 | QVector<DrmPlane*> m_nextPlanesFlipList; | ||
163 | bool m_pageFlipPending = false; | ||||
150 | }; | 164 | }; | ||
151 | 165 | | |||
152 | } | 166 | } | ||
153 | 167 | | |||
154 | Q_DECLARE_METATYPE(KWin::DrmOutput*) | 168 | Q_DECLARE_METATYPE(KWin::DrmOutput*) | ||
155 | 169 | | |||
156 | #endif | 170 | #endif | ||
157 | 171 | |
Remove