Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_output.cpp
Show All 25 Lines | |||||
26 | #include "composite.h" | 26 | #include "composite.h" | ||
27 | #include "cursor.h" | 27 | #include "cursor.h" | ||
28 | #include "logind.h" | 28 | #include "logind.h" | ||
29 | #include "logging.h" | 29 | #include "logging.h" | ||
30 | #include "main.h" | 30 | #include "main.h" | ||
31 | #include "screens_drm.h" | 31 | #include "screens_drm.h" | ||
32 | #include "wayland_server.h" | 32 | #include "wayland_server.h" | ||
33 | // KWayland | 33 | // KWayland | ||
34 | #include <KWayland/Server/output_interface.h> | 34 | #include <KWaylandServer/output_interface.h> | ||
35 | // KF5 | 35 | // KF5 | ||
36 | #include <KConfigGroup> | 36 | #include <KConfigGroup> | ||
37 | #include <KLocalizedString> | 37 | #include <KLocalizedString> | ||
38 | #include <KSharedConfig> | 38 | #include <KSharedConfig> | ||
39 | // Qt | 39 | // Qt | ||
40 | #include <QMatrix4x4> | 40 | #include <QMatrix4x4> | ||
41 | #include <QCryptographicHash> | 41 | #include <QCryptographicHash> | ||
42 | #include <QPainter> | 42 | #include <QPainter> | ||
▲ Show 20 Lines • Show All 234 Lines • ▼ Show 20 Line(s) | 265 | { | |||
277 | setDpmsSupported(true); | 277 | setDpmsSupported(true); | ||
278 | initOutputDevice(connector); | 278 | initOutputDevice(connector); | ||
279 | 279 | | |||
280 | if (!m_backend->atomicModeSetting() && !m_crtc->blank()) { | 280 | if (!m_backend->atomicModeSetting() && !m_crtc->blank()) { | ||
281 | // We use legacy mode and the initial output blank failed. | 281 | // We use legacy mode and the initial output blank failed. | ||
282 | return false; | 282 | return false; | ||
283 | } | 283 | } | ||
284 | 284 | | |||
285 | updateDpms(KWayland::Server::OutputInterface::DpmsMode::On); | 285 | updateDpms(KWaylandServer::OutputInterface::DpmsMode::On); | ||
286 | return true; | 286 | return true; | ||
287 | } | 287 | } | ||
288 | 288 | | |||
289 | void DrmOutput::initUuid() | 289 | void DrmOutput::initUuid() | ||
290 | { | 290 | { | ||
291 | QCryptographicHash hash(QCryptographicHash::Md5); | 291 | QCryptographicHash hash(QCryptographicHash::Md5); | ||
292 | hash.addData(QByteArray::number(m_conn->id())); | 292 | hash.addData(QByteArray::number(m_conn->id())); | ||
293 | hash.addData(m_edid.eisaId()); | 293 | hash.addData(m_edid.eisaId()); | ||
Show All 25 Lines | 318 | } else if (!m_edid.serialNumber().isEmpty()) { | |||
319 | modelName = QString::fromLatin1(m_edid.serialNumber()); | 319 | modelName = QString::fromLatin1(m_edid.serialNumber()); | ||
320 | } else { | 320 | } else { | ||
321 | modelName = i18n("unknown"); | 321 | modelName = i18n("unknown"); | ||
322 | } | 322 | } | ||
323 | 323 | | |||
324 | const QString model = connectorName + QStringLiteral("-") + modelName; | 324 | const QString model = connectorName + QStringLiteral("-") + modelName; | ||
325 | 325 | | |||
326 | // read in mode information | 326 | // read in mode information | ||
327 | QVector<KWayland::Server::OutputDeviceInterface::Mode> modes; | 327 | QVector<KWaylandServer::OutputDeviceInterface::Mode> modes; | ||
328 | for (int i = 0; i < connector->count_modes; ++i) { | 328 | for (int i = 0; i < connector->count_modes; ++i) { | ||
329 | // TODO: in AMS here we could read and store for later every mode's blob_id | 329 | // TODO: in AMS here we could read and store for later every mode's blob_id | ||
330 | // would simplify isCurrentMode(..) and presentAtomically(..) in case of mode set | 330 | // would simplify isCurrentMode(..) and presentAtomically(..) in case of mode set | ||
331 | auto *m = &connector->modes[i]; | 331 | auto *m = &connector->modes[i]; | ||
332 | KWayland::Server::OutputDeviceInterface::ModeFlags deviceflags; | 332 | KWaylandServer::OutputDeviceInterface::ModeFlags deviceflags; | ||
333 | if (isCurrentMode(m)) { | 333 | if (isCurrentMode(m)) { | ||
334 | deviceflags |= KWayland::Server::OutputDeviceInterface::ModeFlag::Current; | 334 | deviceflags |= KWaylandServer::OutputDeviceInterface::ModeFlag::Current; | ||
335 | } | 335 | } | ||
336 | if (m->type & DRM_MODE_TYPE_PREFERRED) { | 336 | if (m->type & DRM_MODE_TYPE_PREFERRED) { | ||
337 | deviceflags |= KWayland::Server::OutputDeviceInterface::ModeFlag::Preferred; | 337 | deviceflags |= KWaylandServer::OutputDeviceInterface::ModeFlag::Preferred; | ||
338 | } | 338 | } | ||
339 | 339 | | |||
340 | KWayland::Server::OutputDeviceInterface::Mode mode; | 340 | KWaylandServer::OutputDeviceInterface::Mode mode; | ||
341 | mode.id = i; | 341 | mode.id = i; | ||
342 | mode.size = QSize(m->hdisplay, m->vdisplay); | 342 | mode.size = QSize(m->hdisplay, m->vdisplay); | ||
343 | mode.flags = deviceflags; | 343 | mode.flags = deviceflags; | ||
344 | mode.refreshRate = refreshRateForMode(m); | 344 | mode.refreshRate = refreshRateForMode(m); | ||
345 | modes << mode; | 345 | modes << mode; | ||
346 | } | 346 | } | ||
347 | 347 | | |||
348 | QSize physicalSize = !m_edid.physicalSize().isEmpty() ? m_edid.physicalSize() : QSize(connector->mmWidth, connector->mmHeight); | 348 | QSize physicalSize = !m_edid.physicalSize().isEmpty() ? m_edid.physicalSize() : QSize(connector->mmWidth, connector->mmHeight); | ||
▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Line(s) | 528 | { | |||
530 | 530 | | |||
531 | m_backend->enableOutput(this, false); | 531 | m_backend->enableOutput(this, false); | ||
532 | m_atomicOffPending = true; | 532 | m_atomicOffPending = true; | ||
533 | if (!m_pageFlipPending) { | 533 | if (!m_pageFlipPending) { | ||
534 | dpmsAtomicOff(); | 534 | dpmsAtomicOff(); | ||
535 | } | 535 | } | ||
536 | } | 536 | } | ||
537 | 537 | | |||
538 | static DrmOutput::DpmsMode fromWaylandDpmsMode(KWayland::Server::OutputInterface::DpmsMode wlMode) | 538 | static DrmOutput::DpmsMode fromWaylandDpmsMode(KWaylandServer::OutputInterface::DpmsMode wlMode) | ||
539 | { | 539 | { | ||
540 | using namespace KWayland::Server; | 540 | using namespace KWaylandServer; | ||
541 | switch (wlMode) { | 541 | switch (wlMode) { | ||
542 | case OutputInterface::DpmsMode::On: | 542 | case OutputInterface::DpmsMode::On: | ||
543 | return DrmOutput::DpmsMode::On; | 543 | return DrmOutput::DpmsMode::On; | ||
544 | case OutputInterface::DpmsMode::Standby: | 544 | case OutputInterface::DpmsMode::Standby: | ||
545 | return DrmOutput::DpmsMode::Standby; | 545 | return DrmOutput::DpmsMode::Standby; | ||
546 | case OutputInterface::DpmsMode::Suspend: | 546 | case OutputInterface::DpmsMode::Suspend: | ||
547 | return DrmOutput::DpmsMode::Suspend; | 547 | return DrmOutput::DpmsMode::Suspend; | ||
548 | case OutputInterface::DpmsMode::Off: | 548 | case OutputInterface::DpmsMode::Off: | ||
549 | return DrmOutput::DpmsMode::Off; | 549 | return DrmOutput::DpmsMode::Off; | ||
550 | default: | 550 | default: | ||
551 | Q_UNREACHABLE(); | 551 | Q_UNREACHABLE(); | ||
552 | } | 552 | } | ||
553 | } | 553 | } | ||
554 | 554 | | |||
555 | static KWayland::Server::OutputInterface::DpmsMode toWaylandDpmsMode(DrmOutput::DpmsMode mode) | 555 | static KWaylandServer::OutputInterface::DpmsMode toWaylandDpmsMode(DrmOutput::DpmsMode mode) | ||
556 | { | 556 | { | ||
557 | using namespace KWayland::Server; | 557 | using namespace KWaylandServer; | ||
558 | switch (mode) { | 558 | switch (mode) { | ||
559 | case DrmOutput::DpmsMode::On: | 559 | case DrmOutput::DpmsMode::On: | ||
560 | return OutputInterface::DpmsMode::On; | 560 | return OutputInterface::DpmsMode::On; | ||
561 | case DrmOutput::DpmsMode::Standby: | 561 | case DrmOutput::DpmsMode::Standby: | ||
562 | return OutputInterface::DpmsMode::Standby; | 562 | return OutputInterface::DpmsMode::Standby; | ||
563 | case DrmOutput::DpmsMode::Suspend: | 563 | case DrmOutput::DpmsMode::Suspend: | ||
564 | return OutputInterface::DpmsMode::Suspend; | 564 | return OutputInterface::DpmsMode::Suspend; | ||
565 | case DrmOutput::DpmsMode::Off: | 565 | case DrmOutput::DpmsMode::Off: | ||
566 | return OutputInterface::DpmsMode::Off; | 566 | return OutputInterface::DpmsMode::Off; | ||
567 | default: | 567 | default: | ||
568 | Q_UNREACHABLE(); | 568 | Q_UNREACHABLE(); | ||
569 | } | 569 | } | ||
570 | } | 570 | } | ||
571 | 571 | | |||
572 | void DrmOutput::updateDpms(KWayland::Server::OutputInterface::DpmsMode mode) | 572 | void DrmOutput::updateDpms(KWaylandServer::OutputInterface::DpmsMode mode) | ||
573 | { | 573 | { | ||
574 | if (m_dpms.isNull() || !isEnabled()) { | 574 | if (m_dpms.isNull() || !isEnabled()) { | ||
575 | return; | 575 | return; | ||
576 | } | 576 | } | ||
577 | 577 | | |||
578 | const auto drmMode = fromWaylandDpmsMode(mode); | 578 | const auto drmMode = fromWaylandDpmsMode(mode); | ||
579 | 579 | | |||
580 | if (drmMode == m_dpmsModePending) { | 580 | if (drmMode == m_dpmsModePending) { | ||
▲ Show 20 Lines • Show All 523 Lines • Show Last 20 Lines |