Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_backend.cpp
Show First 20 Lines • Show All 315 Lines • ▼ Show 20 Line(s) | 296 | if (m_atomicModeSetting) { | |||
---|---|---|---|---|---|
316 | } | 316 | } | ||
317 | } | 317 | } | ||
318 | } else { | 318 | } else { | ||
319 | qCWarning(KWIN_DRM) << "drmSetClientCap for Atomic Mode Setting failed. Using legacy mode."; | 319 | qCWarning(KWIN_DRM) << "drmSetClientCap for Atomic Mode Setting failed. Using legacy mode."; | ||
320 | } | 320 | } | ||
321 | } | 321 | } | ||
322 | 322 | | |||
323 | initCursor(); | 323 | initCursor(); | ||
324 | DrmScopedPointer<drmModeRes> resources(drmModeGetResources(m_fd)); | ||||
325 | for (int i = 0; resources && i < resources->count_crtcs; ++i) { | ||||
326 | const uint32_t currentCrtc = resources->crtcs[i]; | ||||
327 | auto c = new DrmCrtc(currentCrtc, this, i); | ||||
328 | if (m_atomicModeSetting && !c->atomicInit()) { | ||||
329 | delete c; | ||||
330 | continue; | ||||
331 | } | ||||
332 | m_crtcs << c; | ||||
333 | } | ||||
324 | if (!updateOutputs()) | 334 | if (!updateOutputs()) | ||
325 | return; | 335 | return; | ||
326 | 336 | | |||
327 | if (m_outputs.isEmpty()) { | 337 | if (m_outputs.isEmpty()) { | ||
328 | qCDebug(KWIN_DRM) << "No connected outputs found on startup."; | 338 | qCDebug(KWIN_DRM) << "No connected outputs found on startup."; | ||
329 | } | 339 | } | ||
330 | 340 | | |||
331 | // setup udevMonitor | 341 | // setup udevMonitor | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 387 | if (m_atomicModeSetting && !c->atomicInit()) { | |||
379 | continue; | 389 | continue; | ||
380 | } | 390 | } | ||
381 | m_connectors << c; | 391 | m_connectors << c; | ||
382 | } else { | 392 | } else { | ||
383 | oldConnectors.removeOne(*it); | 393 | oldConnectors.removeOne(*it); | ||
384 | } | 394 | } | ||
385 | } | 395 | } | ||
386 | 396 | | |||
387 | auto oldCrtcs = m_crtcs; | | |||
388 | for (int i = 0; i < resources->count_crtcs; ++i) { | | |||
389 | const uint32_t currentCrtc = resources->crtcs[i]; | | |||
390 | auto it = std::find_if(m_crtcs.constBegin(), m_crtcs.constEnd(), [currentCrtc] (DrmCrtc *c) { return c->id() == currentCrtc; }); | | |||
391 | if (it == m_crtcs.constEnd()) { | | |||
392 | auto c = new DrmCrtc(currentCrtc, this, i); | | |||
393 | if (m_atomicModeSetting && !c->atomicInit()) { | | |||
394 | delete c; | | |||
395 | continue; | | |||
396 | } | | |||
397 | m_crtcs << c; | | |||
398 | } else { | | |||
399 | oldCrtcs.removeOne(*it); | | |||
400 | } | | |||
401 | } | | |||
402 | | ||||
403 | for (auto c : qAsConst(oldConnectors)) { | 397 | for (auto c : qAsConst(oldConnectors)) { | ||
404 | m_connectors.removeOne(c); | 398 | m_connectors.removeOne(c); | ||
405 | } | 399 | } | ||
406 | for (auto c : qAsConst(oldCrtcs)) { | | |||
407 | m_crtcs.removeOne(c); | | |||
408 | } | | |||
409 | 400 | | |||
410 | QVector<DrmOutput*> connectedOutputs; | 401 | QVector<DrmOutput*> connectedOutputs; | ||
411 | QVector<DrmConnector*> pendingConnectors; | 402 | QVector<DrmConnector*> pendingConnectors; | ||
412 | 403 | | |||
413 | // split up connected connectors in already or not yet assigned ones | 404 | // split up connected connectors in already or not yet assigned ones | ||
414 | for (DrmConnector *con : qAsConst(m_connectors)) { | 405 | for (DrmConnector *con : qAsConst(m_connectors)) { | ||
415 | if (!con->isConnected()) { | 406 | if (!con->isConnected()) { | ||
416 | continue; | 407 | continue; | ||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | |||||
514 | m_enabledOutputs = connectedOutputs; | 505 | m_enabledOutputs = connectedOutputs; | ||
515 | readOutputsConfiguration(); | 506 | readOutputsConfiguration(); | ||
516 | updateOutputsEnabled(); | 507 | updateOutputsEnabled(); | ||
517 | if (!m_outputs.isEmpty()) { | 508 | if (!m_outputs.isEmpty()) { | ||
518 | emit screensQueried(); | 509 | emit screensQueried(); | ||
519 | } | 510 | } | ||
520 | 511 | | |||
521 | qDeleteAll(oldConnectors); | 512 | qDeleteAll(oldConnectors); | ||
522 | qDeleteAll(oldCrtcs); | | |||
523 | return true; | 513 | return true; | ||
524 | } | 514 | } | ||
525 | 515 | | |||
526 | void DrmBackend::readOutputsConfiguration() | 516 | void DrmBackend::readOutputsConfiguration() | ||
527 | { | 517 | { | ||
528 | if (m_outputs.isEmpty()) { | 518 | if (m_outputs.isEmpty()) { | ||
529 | return; | 519 | return; | ||
530 | } | 520 | } | ||
▲ Show 20 Lines • Show All 290 Lines • Show Last 20 Lines |