Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_backend.cpp
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Line(s) | 136 | { | |||
---|---|---|---|---|---|
137 | return m_outputs; | 137 | return m_outputs; | ||
138 | } | 138 | } | ||
139 | 139 | | |||
140 | Outputs DrmBackend::enabledOutputs() const | 140 | Outputs DrmBackend::enabledOutputs() const | ||
141 | { | 141 | { | ||
142 | return m_enabledOutputs; | 142 | return m_enabledOutputs; | ||
143 | } | 143 | } | ||
144 | 144 | | |||
145 | void DrmBackend::outputWentOff() | 145 | void DrmBackend::createDpmsFilter() | ||
146 | { | 146 | { | ||
147 | if (!m_dpmsFilter.isNull()) { | 147 | if (!m_dpmsFilter.isNull()) { | ||
148 | // already another output is off | 148 | // already another output is off | ||
149 | return; | 149 | return; | ||
150 | } | 150 | } | ||
151 | m_dpmsFilter.reset(new DpmsInputEventFilter(this)); | 151 | m_dpmsFilter.reset(new DpmsInputEventFilter(this)); | ||
152 | input()->prependInputEventFilter(m_dpmsFilter.data()); | 152 | input()->prependInputEventFilter(m_dpmsFilter.data()); | ||
153 | } | 153 | } | ||
Show All 40 Lines | 191 | { | |||
194 | } | 194 | } | ||
195 | m_active = true; | 195 | m_active = true; | ||
196 | if (!usesSoftwareCursor()) { | 196 | if (!usesSoftwareCursor()) { | ||
197 | const QPoint cp = Cursor::pos() - softwareCursorHotspot(); | 197 | const QPoint cp = Cursor::pos() - softwareCursorHotspot(); | ||
198 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | 198 | for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { | ||
199 | DrmOutput *o = *it; | 199 | DrmOutput *o = *it; | ||
200 | // only relevant in atomic mode | 200 | // only relevant in atomic mode | ||
201 | o->m_modesetRequested = true; | 201 | o->m_modesetRequested = true; | ||
202 | o->pageFlipped(); // TODO: Do we really need this? | | |||
203 | o->m_crtc->blank(); | 202 | o->m_crtc->blank(); | ||
204 | o->showCursor(); | 203 | o->showCursor(); | ||
205 | o->moveCursor(cp); | 204 | o->moveCursor(cp); | ||
206 | } | 205 | } | ||
207 | } | 206 | } | ||
208 | // restart compositor | 207 | // restart compositor | ||
209 | m_pageFlipsPending = 0; | 208 | m_pageFlipsPending = 0; | ||
210 | if (Compositor *compositor = Compositor::self()) { | 209 | if (Compositor *compositor = Compositor::self()) { | ||
Show All 21 Lines | |||||
232 | 231 | | |||
233 | void DrmBackend::pageFlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data) | 232 | void DrmBackend::pageFlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data) | ||
234 | { | 233 | { | ||
235 | Q_UNUSED(fd) | 234 | Q_UNUSED(fd) | ||
236 | Q_UNUSED(frame) | 235 | Q_UNUSED(frame) | ||
237 | Q_UNUSED(sec) | 236 | Q_UNUSED(sec) | ||
238 | Q_UNUSED(usec) | 237 | Q_UNUSED(usec) | ||
239 | auto output = reinterpret_cast<DrmOutput*>(data); | 238 | auto output = reinterpret_cast<DrmOutput*>(data); | ||
239 | | ||||
240 | output->pageFlipped(); | 240 | output->pageFlipped(); | ||
241 | output->m_backend->m_pageFlipsPending--; | 241 | output->m_backend->m_pageFlipsPending--; | ||
242 | if (output->m_backend->m_pageFlipsPending == 0) { | 242 | if (output->m_backend->m_pageFlipsPending == 0) { | ||
243 | // TODO: improve, this currently means we wait for all page flips or all outputs. | 243 | // TODO: improve, this currently means we wait for all page flips or all outputs. | ||
244 | // It would be better to driver the repaint per output | 244 | // It would be better to driver the repaint per output | ||
245 | 245 | | |||
246 | if (output->m_dpmsAtomicOffPending) { | | |||
247 | output->m_modesetRequested = true; | | |||
248 | output->dpmsAtomicOff(); | | |||
249 | } | | |||
250 | | ||||
251 | if (Compositor::self()) { | 246 | if (Compositor::self()) { | ||
252 | Compositor::self()->bufferSwapComplete(); | 247 | Compositor::self()->bufferSwapComplete(); | ||
253 | } | 248 | } | ||
254 | } | 249 | } | ||
255 | } | 250 | } | ||
256 | 251 | | |||
257 | void DrmBackend::openDrm() | 252 | void DrmBackend::openDrm() | ||
258 | { | 253 | { | ||
▲ Show 20 Lines • Show All 210 Lines • ▼ Show 20 Line(s) | 463 | if (!modeCrtc) { | |||
469 | continue; | 464 | continue; | ||
470 | } | 465 | } | ||
471 | 466 | | |||
472 | DrmOutput *output = new DrmOutput(this); | 467 | DrmOutput *output = new DrmOutput(this); | ||
473 | con->setOutput(output); | 468 | con->setOutput(output); | ||
474 | output->m_conn = con; | 469 | output->m_conn = con; | ||
475 | crtc->setOutput(output); | 470 | crtc->setOutput(output); | ||
476 | output->m_crtc = crtc; | 471 | output->m_crtc = crtc; | ||
477 | connect(output, &DrmOutput::dpmsChanged, this, &DrmBackend::outputDpmsChanged); | | |||
478 | 472 | | |||
479 | if (modeCrtc->mode_valid) { | 473 | if (modeCrtc->mode_valid) { | ||
480 | output->m_mode = modeCrtc->mode; | 474 | output->m_mode = modeCrtc->mode; | ||
481 | } else { | 475 | } else { | ||
482 | output->m_mode = connector->modes[0]; | 476 | output->m_mode = connector->modes[0]; | ||
483 | } | 477 | } | ||
484 | qCDebug(KWIN_DRM) << "For new output use mode " << output->m_mode.name; | 478 | qCDebug(KWIN_DRM) << "For new output use mode " << output->m_mode.name; | ||
485 | 479 | | |||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 546 | { | |||
557 | } | 551 | } | ||
558 | QCryptographicHash hash(QCryptographicHash::Md5); | 552 | QCryptographicHash hash(QCryptographicHash::Md5); | ||
559 | for (; it != m_outputs.constEnd(); ++it) { | 553 | for (; it != m_outputs.constEnd(); ++it) { | ||
560 | hash.addData((*it)->uuid()); | 554 | hash.addData((*it)->uuid()); | ||
561 | } | 555 | } | ||
562 | return hash.result().toHex().left(10); | 556 | return hash.result().toHex().left(10); | ||
563 | } | 557 | } | ||
564 | 558 | | |||
565 | void DrmBackend::enableOutput(AbstractOutput *output, bool enable) | 559 | void DrmBackend::enableOutput(DrmOutput *output, bool enable) | ||
566 | { | 560 | { | ||
567 | auto *drmOutput = static_cast<DrmOutput*>(output); | | |||
568 | if (enable) { | 561 | if (enable) { | ||
569 | m_enabledOutputs << drmOutput; | 562 | Q_ASSERT(!m_enabledOutputs.contains(output)); | ||
570 | emit outputAdded(drmOutput); | 563 | m_enabledOutputs << output; | ||
564 | emit outputAdded(output); | ||||
571 | } else { | 565 | } else { | ||
572 | m_enabledOutputs.removeOne(drmOutput); | 566 | Q_ASSERT(m_enabledOutputs.contains(output)); | ||
573 | emit outputRemoved(drmOutput); | 567 | m_enabledOutputs.removeOne(output); | ||
568 | Q_ASSERT(!m_enabledOutputs.contains(output)); | ||||
569 | emit outputRemoved(output); | ||||
574 | } | 570 | } | ||
571 | updateOutputsEnabled(); | ||||
572 | checkOutputsAreOn(); | ||||
573 | emit screensQueried(); | ||||
575 | } | 574 | } | ||
576 | 575 | | |||
577 | DrmOutput *DrmBackend::findOutput(quint32 connector) | 576 | DrmOutput *DrmBackend::findOutput(quint32 connector) | ||
578 | { | 577 | { | ||
579 | auto it = std::find_if(m_outputs.constBegin(), m_outputs.constEnd(), [connector] (DrmOutput *o) { | 578 | auto it = std::find_if(m_outputs.constBegin(), m_outputs.constEnd(), [connector] (DrmOutput *o) { | ||
580 | return o->m_conn->id() == connector; | 579 | return o->m_conn->id() == connector; | ||
581 | }); | 580 | }); | ||
582 | if (it != m_outputs.constEnd()) { | 581 | if (it != m_outputs.constEnd()) { | ||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Line(s) | |||||
748 | #if HAVE_GBM | 747 | #if HAVE_GBM | ||
749 | DrmSurfaceBuffer *DrmBackend::createBuffer(const std::shared_ptr<GbmSurface> &surface) | 748 | DrmSurfaceBuffer *DrmBackend::createBuffer(const std::shared_ptr<GbmSurface> &surface) | ||
750 | { | 749 | { | ||
751 | DrmSurfaceBuffer *b = new DrmSurfaceBuffer(m_fd, surface); | 750 | DrmSurfaceBuffer *b = new DrmSurfaceBuffer(m_fd, surface); | ||
752 | return b; | 751 | return b; | ||
753 | } | 752 | } | ||
754 | #endif | 753 | #endif | ||
755 | 754 | | |||
756 | void DrmBackend::outputDpmsChanged() | 755 | void DrmBackend::updateOutputsEnabled() | ||
757 | { | 756 | { | ||
758 | if (m_enabledOutputs.isEmpty()) { | 757 | if (m_enabledOutputs.isEmpty()) { | ||
759 | return; | 758 | return; | ||
760 | } | 759 | } | ||
761 | bool enabled = false; | 760 | bool enabled = false; | ||
762 | for (auto it = m_enabledOutputs.constBegin(); it != m_enabledOutputs.constEnd(); ++it) { | 761 | for (auto it = m_enabledOutputs.constBegin(); it != m_enabledOutputs.constEnd(); ++it) { | ||
763 | enabled = enabled || (*it)->isDpmsEnabled(); | 762 | enabled = enabled || (*it)->isDpmsEnabled(); | ||
764 | } | 763 | } | ||
Show All 34 Lines |