Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_object_crtc.cpp
Show All 12 Lines | |||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
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 | #include "drm_object_crtc.h" | 20 | #include "drm_object_crtc.h" | ||
21 | #include "drm_backend.h" | ||||
22 | #include "drm_output.h" | ||||
23 | #include "drm_buffer.h" | ||||
21 | #include "logging.h" | 24 | #include "logging.h" | ||
22 | 25 | | |||
23 | namespace KWin | 26 | namespace KWin | ||
24 | { | 27 | { | ||
25 | 28 | | |||
26 | DrmCrtc::DrmCrtc(uint32_t crtc_id, int fd) | 29 | DrmCrtc::DrmCrtc(uint32_t crtc_id, int fd, int resIndex) | ||
27 | : DrmObject(crtc_id, fd) | 30 | : DrmObject(crtc_id, fd), | ||
31 | m_resIndex(resIndex) | ||||
28 | { | 32 | { | ||
29 | } | 33 | } | ||
30 | 34 | | |||
31 | DrmCrtc::~DrmCrtc() = default; | 35 | DrmCrtc::~DrmCrtc() | ||
36 | { | ||||
37 | } | ||||
32 | 38 | | |||
33 | bool DrmCrtc::init() | 39 | bool DrmCrtc::init() | ||
34 | { | 40 | { | ||
35 | qCDebug(KWIN_DRM) << "Creating CRTC" << m_id; | 41 | qCDebug(KWIN_DRM) << "Atomic init for CRTC:" << resIndex() << "id:" << m_id; | ||
36 | 42 | | |||
37 | if (!initProps()) { | 43 | if (!initProps()) { | ||
38 | return false; | 44 | return false; | ||
39 | } | 45 | } | ||
40 | return true; | 46 | return true; | ||
41 | } | 47 | } | ||
42 | 48 | | |||
43 | bool DrmCrtc::initProps() | 49 | bool DrmCrtc::initProps() | ||
Show All 12 Lines | 50 | { | |||
56 | int propCount = int(PropertyIndex::Count); | 62 | int propCount = int(PropertyIndex::Count); | ||
57 | for (int j = 0; j < propCount; ++j) { | 63 | for (int j = 0; j < propCount; ++j) { | ||
58 | initProp(j, properties); | 64 | initProp(j, properties); | ||
59 | } | 65 | } | ||
60 | drmModeFreeObjectProperties(properties); | 66 | drmModeFreeObjectProperties(properties); | ||
61 | return true; | 67 | return true; | ||
62 | } | 68 | } | ||
63 | 69 | | |||
70 | void DrmCrtc::flipBuffer() | ||||
71 | { | ||||
72 | if (m_currentBuffer && m_output->m_backend->deleteBufferAfterPageFlip() && m_currentBuffer != m_nextBuffer) { | ||||
73 | delete m_currentBuffer; | ||||
74 | } | ||||
75 | m_currentBuffer = m_nextBuffer; | ||||
76 | m_nextBuffer = nullptr; | ||||
77 | | ||||
78 | delete m_blackBuffer; | ||||
79 | m_blackBuffer = nullptr; | ||||
80 | } | ||||
81 | | ||||
82 | bool DrmCrtc::blank() | ||||
83 | { | ||||
84 | if (!m_blackBuffer) { | ||||
85 | DrmDumbBuffer *blackBuffer = m_output->m_backend->createBuffer(m_output->pixelSize()); | ||||
86 | if (!blackBuffer->map()) { | ||||
87 | delete blackBuffer; | ||||
88 | return false; | ||||
89 | } | ||||
90 | blackBuffer->image()->fill(Qt::black); | ||||
91 | m_blackBuffer = blackBuffer; | ||||
92 | } | ||||
93 | | ||||
94 | // TODO: Do this atomically | ||||
95 | if (m_output->setModeLegacy(m_blackBuffer)) { | ||||
96 | if (m_currentBuffer && m_output->m_backend->deleteBufferAfterPageFlip()) { | ||||
97 | delete m_currentBuffer; | ||||
98 | delete m_nextBuffer; | ||||
99 | } | ||||
100 | m_currentBuffer = nullptr; | ||||
101 | m_nextBuffer = nullptr; | ||||
102 | return true; | ||||
103 | } | ||||
104 | return false; | ||||
105 | } | ||||
106 | | ||||
64 | } | 107 | } |