diff options
Diffstat (limited to 'src/plugins/platforms/eglfs')
4 files changed, 94 insertions, 30 deletions
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp index 4742143121..c3151e1fd0 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp @@ -47,6 +47,7 @@ #include <QtCore/QLoggingCategory> #include <QtGui/private/qguiapplication_p.h> +#include <QtGui/private/qtguiglobal_p.h> #include <QtFbSupport/private/qfbvthandler_p.h> #include <errno.h> @@ -210,17 +211,29 @@ void QEglFSKmsGbmScreen::ensureModeSet(uint32_t fb) if (doModeSet) { qCDebug(qLcEglfsKmsDebug, "Setting mode for screen %s", qPrintable(name())); - int ret = drmModeSetCrtc(fd, - op.crtc_id, - fb, - 0, 0, - &op.connector_id, 1, - &op.modes[op.mode]); - - if (ret == 0) - setPowerState(PowerStateOn); - else - qErrnoWarning(errno, "Could not set DRM mode for screen %s", qPrintable(name())); + + if (device()->hasAtomicSupport()) { +#if QT_CONFIG(drm_atomic) + drmModeAtomicReq *request = device()->atomic_request(); + if (request) { + drmModeAtomicAddProperty(request, op.connector_id, op.crtcIdPropertyId, op.crtc_id); + drmModeAtomicAddProperty(request, op.crtc_id, op.modeIdPropertyId, op.mode_blob_id); + drmModeAtomicAddProperty(request, op.crtc_id, op.activePropertyId, 1); + } +#endif + } else { + int ret = drmModeSetCrtc(fd, + op.crtc_id, + fb, + 0, 0, + &op.connector_id, 1, + &op.modes[op.mode]); + + if (ret == 0) + setPowerState(PowerStateOn); + else + qErrnoWarning(errno, "Could not set DRM mode for screen %s", qPrintable(name())); + } } } } @@ -243,6 +256,11 @@ void QEglFSKmsGbmScreen::waitForFlip() drmEvent.page_flip_handler = pageFlipHandler; drmHandleEvent(device()->fd(), &drmEvent); } + +#if QT_CONFIG(drm_atomic) + if (device()->hasAtomicSupport()) + device()->atomicReset(); +#endif } void QEglFSKmsGbmScreen::flip() @@ -274,34 +292,75 @@ void QEglFSKmsGbmScreen::flip() QKmsOutput &op(output()); const int fd = device()->fd(); m_flipPending = true; - int ret = drmModePageFlip(fd, + + if (device()->hasAtomicSupport()) { +#if QT_CONFIG(drm_atomic) + drmModeAtomicReq *request = device()->atomic_request(); + if (request) { + drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->framebufferPropertyId, fb->fb); + drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcPropertyId, op.crtc_id); + drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcwidthPropertyId, + output().size.width() << 16); + drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcXPropertyId, 0); + drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcYPropertyId, 0); + drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcheightPropertyId, + output().size.height() << 16); + drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcXPropertyId, 0); + drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcYPropertyId, 0); + drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcwidthPropertyId, + m_output.modes[m_output.mode].hdisplay); + drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcheightPropertyId, + m_output.modes[m_output.mode].vdisplay); + } +#endif + } else { + int ret = drmModePageFlip(fd, op.crtc_id, fb->fb, DRM_MODE_PAGE_FLIP_EVENT, this); - if (ret) { - qErrnoWarning("Could not queue DRM page flip on screen %s", qPrintable(name())); - m_flipPending = false; - gbm_surface_release_buffer(m_gbm_surface, m_gbm_bo_next); - m_gbm_bo_next = nullptr; - return; + if (ret) { + qErrnoWarning("Could not queue DRM page flip on screen %s", qPrintable(name())); + m_flipPending = false; + gbm_surface_release_buffer(m_gbm_surface, m_gbm_bo_next); + m_gbm_bo_next = nullptr; + return; + } } for (CloneDestination &d : m_cloneDests) { if (d.screen != this) { d.screen->ensureModeSet(fb->fb); d.cloneFlipPending = true; - int ret = drmModePageFlip(fd, - d.screen->output().crtc_id, - fb->fb, - DRM_MODE_PAGE_FLIP_EVENT, - d.screen); - if (ret) { - qErrnoWarning("Could not queue DRM page flip for clone screen %s", qPrintable(name())); - d.cloneFlipPending = false; + + if (device()->hasAtomicSupport()) { +#if QT_CONFIG(drm_atomic) + drmModeAtomicReq *request = device()->atomic_request(); + if (request) { + drmModeAtomicAddProperty(request, d.screen->output().eglfs_plane->id, + d.screen->output().eglfs_plane->framebufferPropertyId, fb->fb); + drmModeAtomicAddProperty(request, d.screen->output().eglfs_plane->id, + d.screen->output().eglfs_plane->crtcPropertyId, op.crtc_id); + } +#endif + } else { + int ret = drmModePageFlip(fd, + d.screen->output().crtc_id, + fb->fb, + DRM_MODE_PAGE_FLIP_EVENT, + d.screen); + if (ret) { + qErrnoWarning("Could not queue DRM page flip for clone screen %s", qPrintable(name())); + d.cloneFlipPending = false; + } } } } + +#if QT_CONFIG(drm_atomic) + if (device()->hasAtomicSupport()) + device()->atomicCommit(this); +#endif } void QEglFSKmsGbmScreen::pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp index 531b73d1dc..1626c86239 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp @@ -112,7 +112,7 @@ void QEglFSKmsEglDeviceScreen::waitForFlip() qCDebug(qLcEglfsKmsDebug, "Setting plane %u", op.forced_plane_id); int ret = drmModeSetPlane(fd, op.forced_plane_id, op.crtc_id, uint32_t(-1), 0, 0, 0, w, h, - 0 << 16, 0 << 16, w << 16, h << 16); + 0 << 16, 0 << 16, op.size.width() << 16, op.size.height() << 16); if (ret == -1) qErrnoWarning(errno, "drmModeSetPlane failed"); } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp index 06bc272050..a6aac61506 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp @@ -138,6 +138,10 @@ void *QEglFSKmsIntegration::nativeResourceForIntegration(const QByteArray &name) if (name == QByteArrayLiteral("dri_fd") && m_device) return (void *) (qintptr) m_device->fd(); +#if QT_CONFIG(drm_atomic) + if (name == QByteArrayLiteral("dri_atomic_request") && m_device) + return (void *) (qintptr) m_device->atomic_request(); +#endif return nullptr; } @@ -147,6 +151,8 @@ void *QEglFSKmsIntegration::nativeResourceForScreen(const QByteArray &resource, if (s) { if (resource == QByteArrayLiteral("dri_crtcid")) return (void *) (qintptr) s->output().crtc_id; + if (resource == QByteArrayLiteral("dri_connectorid")) + return (void *) (qintptr) s->output().connector_id; } return nullptr; } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp index 5e45b42abe..e5354d97bd 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp @@ -113,10 +113,9 @@ QRect QEglFSKmsScreen::rawGeometry() const if (m_headless) return QRect(QPoint(0, 0), m_device->screenConfig()->headlessSize()); - const int mode = m_output.mode; return QRect(m_pos.x(), m_pos.y(), - m_output.modes[mode].hdisplay, - m_output.modes[mode].vdisplay); + m_output.size.width(), + m_output.size.height()); } int QEglFSKmsScreen::depth() const |