diff options
Diffstat (limited to 'src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice')
8 files changed, 62 insertions, 58 deletions
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro index a625021aba..a2dc9c4a50 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro @@ -1,6 +1,6 @@ TARGET = qeglfs-kms-egldevice-integration -QT += core-private gui-private eglfsdeviceintegration-private eglfs_kms_support-private +QT += core-private gui-private eglfsdeviceintegration-private eglfs_kms_support-private kms_support-private INCLUDEPATH += $$PWD/../../api $$PWD/../eglfs_kms_support diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp index 60989e2bd0..0a66a897a1 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp @@ -40,14 +40,16 @@ #include "qeglfskmsegldevice.h" #include "qeglfskmsegldevicescreen.h" #include "qeglfskmsegldeviceintegration.h" +#include "private/qeglfsintegration_p.h" #include "private/qeglfscursor_p.h" #include <QtCore/private/qcore_unix_p.h> QT_BEGIN_NAMESPACE -QEglFSKmsEglDevice::QEglFSKmsEglDevice(QEglFSKmsIntegration *integration, const QString &path) - : QEglFSKmsDevice(integration, path), +QEglFSKmsEglDevice::QEglFSKmsEglDevice(QEglFSKmsEglDeviceIntegration *devInt, QKmsScreenConfig *screenConfig, const QString &path) + : QEglFSKmsDevice(screenConfig, path), + m_devInt(devInt), m_globalCursor(nullptr) { } @@ -56,11 +58,9 @@ bool QEglFSKmsEglDevice::open() { Q_ASSERT(fd() == -1); - qCDebug(qLcEglfsKmsDebug, "Opening DRM device %s", qPrintable(devicePath())); - int fd = drmOpen(devicePath().toLocal8Bit().constData(), Q_NULLPTR); if (Q_UNLIKELY(fd < 0)) - qFatal("Could not open DRM device"); + qFatal("Could not open DRM (NV) device"); setFd(fd); @@ -69,29 +69,28 @@ bool QEglFSKmsEglDevice::open() void QEglFSKmsEglDevice::close() { - qCDebug(qLcEglfsKmsDebug, "Closing DRM device"); + // Note: screens are gone at this stage. if (qt_safe_close(fd()) == -1) - qErrnoWarning("Could not close DRM device"); + qErrnoWarning("Could not close DRM (NV) device"); setFd(-1); } EGLNativeDisplayType QEglFSKmsEglDevice::nativeDisplay() const { - return reinterpret_cast<EGLNativeDisplayType>(static_cast<QEglFSKmsEglDeviceIntegration *>(m_integration)->eglDevice()); + return reinterpret_cast<EGLNativeDisplayType>(m_devInt->eglDevice()); } -QEglFSKmsScreen *QEglFSKmsEglDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, - QEglFSKmsOutput output) +QPlatformScreen *QEglFSKmsEglDevice::createScreen(const QKmsOutput &output) { - QEglFSKmsScreen *screen = new QEglFSKmsEglDeviceScreen(integration, device, output); - - if (!m_globalCursor && !integration->separateScreens()) { + QEglFSKmsScreen *screen = new QEglFSKmsEglDeviceScreen(this, output); +#if QT_CONFIG(opengl) + if (!m_globalCursor && !screenConfig()->separateScreens()) { qCDebug(qLcEglfsKmsDebug, "Creating new global mouse cursor"); m_globalCursor = new QEglFSCursor(screen); } - +#endif return screen; } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h index 8c8f79f70c..8d469879ab 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h @@ -45,25 +45,25 @@ QT_BEGIN_NAMESPACE class QPlatformCursor; +class QEglFSKmsEglDeviceIntegration; class QEglFSKmsEglDevice: public QEglFSKmsDevice { public: - QEglFSKmsEglDevice(QEglFSKmsIntegration *integration, const QString &path); + QEglFSKmsEglDevice(QEglFSKmsEglDeviceIntegration *devInt, QKmsScreenConfig *screenConfig, const QString &path); - virtual bool open() Q_DECL_OVERRIDE; - virtual void close() Q_DECL_OVERRIDE; + bool open() override; + void close() override; - virtual EGLNativeDisplayType nativeDisplay() const Q_DECL_OVERRIDE; + void *nativeDisplay() const override; - virtual QEglFSKmsScreen *createScreen(QEglFSKmsIntegration *integration, - QEglFSKmsDevice *device, - QEglFSKmsOutput output) Q_DECL_OVERRIDE; + QPlatformScreen *createScreen(const QKmsOutput &output) override; QPlatformCursor *globalCursor() { return m_globalCursor; } void destroyGlobalCursor(); private: + QEglFSKmsEglDeviceIntegration *m_devInt; QPlatformCursor *m_globalCursor; }; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp index cf1de71831..43bdb77a18 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp @@ -50,8 +50,7 @@ QT_BEGIN_NAMESPACE QEglFSKmsEglDeviceIntegration::QEglFSKmsEglDeviceIntegration() - : QEglFSKmsIntegration() - , m_egl_device(EGL_NO_DEVICE_EXT) + : m_egl_device(EGL_NO_DEVICE_EXT) , m_funcs(Q_NULLPTR) { qCDebug(qLcEglfsKmsDebug, "New DRM/KMS on EGLDevice integration created"); @@ -101,30 +100,30 @@ bool QEglFSKmsEglDeviceIntegration::supportsPBuffers() const return true; } -class QEglJetsonTK1Window : public QEglFSWindow +class QEglFSKmsEglDeviceWindow : public QEglFSWindow { public: - QEglJetsonTK1Window(QWindow *w, const QEglFSKmsEglDeviceIntegration *integration) + QEglFSKmsEglDeviceWindow(QWindow *w, const QEglFSKmsEglDeviceIntegration *integration) : QEglFSWindow(w) , m_integration(integration) , m_egl_stream(EGL_NO_STREAM_KHR) { } - void invalidateSurface() Q_DECL_OVERRIDE; - void resetSurface() Q_DECL_OVERRIDE; + void invalidateSurface() override; + void resetSurface() override; const QEglFSKmsEglDeviceIntegration *m_integration; EGLStreamKHR m_egl_stream; EGLint m_latency; }; -void QEglJetsonTK1Window::invalidateSurface() +void QEglFSKmsEglDeviceWindow::invalidateSurface() { QEglFSWindow::invalidateSurface(); m_integration->m_funcs->destroy_stream(screen()->display(), m_egl_stream); } -void QEglJetsonTK1Window::resetSurface() +void QEglFSKmsEglDeviceWindow::resetSurface() { qCDebug(qLcEglfsKmsDebug, "Creating stream"); @@ -173,7 +172,7 @@ void QEglJetsonTK1Window::resetSurface() QEglFSKmsEglDeviceScreen *cur_screen = static_cast<QEglFSKmsEglDeviceScreen *>(screen()); Q_ASSERT(cur_screen); - QEglFSKmsOutput &output(cur_screen->output()); + QKmsOutput &output(cur_screen->output()); const uint32_t wantedId = !output.wants_plane ? output.crtc_id : output.plane_id; qCDebug(qLcEglfsKmsDebug, "Searching for id: %d", wantedId); @@ -235,7 +234,7 @@ void QEglJetsonTK1Window::resetSurface() QEglFSWindow *QEglFSKmsEglDeviceIntegration::createWindow(QWindow *window) const { - QEglJetsonTK1Window *eglWindow = new QEglJetsonTK1Window(window, this); + QEglFSKmsEglDeviceWindow *eglWindow = new QEglFSKmsEglDeviceWindow(window, this); m_funcs->initialize(eglWindow->screen()->display()); if (Q_UNLIKELY(!(m_funcs->has_egl_output_base && m_funcs->has_egl_output_drm && m_funcs->has_egl_stream && @@ -245,10 +244,8 @@ QEglFSWindow *QEglFSKmsEglDeviceIntegration::createWindow(QWindow *window) const return eglWindow; } -QEglFSKmsDevice *QEglFSKmsEglDeviceIntegration::createDevice(const QString &devicePath) +QKmsDevice *QEglFSKmsEglDeviceIntegration::createDevice() { - Q_UNUSED(devicePath) - if (Q_UNLIKELY(!query_egl_device())) qFatal("Could not set up EGL device!"); @@ -256,7 +253,7 @@ QEglFSKmsDevice *QEglFSKmsEglDeviceIntegration::createDevice(const QString &devi if (Q_UNLIKELY(!deviceName)) qFatal("Failed to query device name from EGLDevice"); - return new QEglFSKmsEglDevice(this, deviceName); + return new QEglFSKmsEglDevice(this, screenConfig(), deviceName); } bool QEglFSKmsEglDeviceIntegration::query_egl_device() @@ -283,7 +280,11 @@ bool QEglFSKmsEglDeviceIntegration::query_egl_device() QPlatformCursor *QEglFSKmsEglDeviceIntegration::createCursor(QPlatformScreen *screen) const { - return separateScreens() ? new QEglFSCursor(screen) : nullptr; +#if QT_CONFIG(opengl) + if (screenConfig()->separateScreens()) + return new QEglFSCursor(screen); +#endif + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h index cddfdbd5c6..62404cfcd1 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h @@ -55,27 +55,26 @@ class QEglFSKmsEglDeviceIntegration : public QEglFSKmsIntegration public: QEglFSKmsEglDeviceIntegration(); - EGLint surfaceType() const Q_DECL_OVERRIDE; - EGLDisplay createDisplay(EGLNativeDisplayType nativeDisplay) Q_DECL_OVERRIDE; - bool supportsSurfacelessContexts() const Q_DECL_OVERRIDE; - bool supportsPBuffers() const Q_DECL_OVERRIDE; - QEglFSWindow *createWindow(QWindow *window) const Q_DECL_OVERRIDE; + EGLint surfaceType() const override; + EGLDisplay createDisplay(EGLNativeDisplayType nativeDisplay) override; + bool supportsSurfacelessContexts() const override; + bool supportsPBuffers() const override; + QEglFSWindow *createWindow(QWindow *window) const override; EGLDeviceEXT eglDevice() const { return m_egl_device; } protected: - QEglFSKmsDevice *createDevice(const QString &devicePath) Q_DECL_OVERRIDE; - QPlatformCursor *createCursor(QPlatformScreen *screen) const Q_DECL_OVERRIDE; + QKmsDevice *createDevice() override; + QPlatformCursor *createCursor(QPlatformScreen *screen) const override; private: bool setup_kms(); bool query_egl_device(); EGLDeviceEXT m_egl_device; - - friend class QEglJetsonTK1Window; - // EGLStream infrastructure QEGLStreamConvenience *m_funcs; + + friend class QEglFSKmsEglDeviceWindow; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp index 42fec073f1..5763ab45cc 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp @@ -47,7 +47,7 @@ class QEglFSKmsEglDeviceIntegrationPlugin : public QEglFSDeviceIntegrationPlugin Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_kms_egldevice.json") public: - QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSKmsEglDeviceIntegration; } + QEglFSDeviceIntegration *create() override { return new QEglFSKmsEglDeviceIntegration; } }; QT_END_NAMESPACE 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 3935c99b9e..a27c89faab 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp @@ -40,11 +40,15 @@ #include "qeglfskmsegldevicescreen.h" #include "qeglfskmsegldevice.h" #include <QGuiApplication> +#include <QLoggingCategory> +#include <errno.h> QT_BEGIN_NAMESPACE -QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output) - : QEglFSKmsScreen(integration, device, output) +Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug) + +QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QKmsDevice *device, const QKmsOutput &output) + : QEglFSKmsScreen(device, output) { } @@ -52,7 +56,7 @@ QEglFSKmsEglDeviceScreen::~QEglFSKmsEglDeviceScreen() { const int remainingScreenCount = qGuiApp->screens().count(); qCDebug(qLcEglfsKmsDebug, "Screen dtor. Remaining screens: %d", remainingScreenCount); - if (!remainingScreenCount && !m_integration->separateScreens()) + if (!remainingScreenCount && !device()->screenConfig()->separateScreens()) static_cast<QEglFSKmsEglDevice *>(device())->destroyGlobalCursor(); } @@ -62,12 +66,15 @@ QPlatformCursor *QEglFSKmsEglDeviceScreen::cursor() const // in its ctor. With separateScreens just use that. Otherwise // there's a virtual desktop and the device has a global cursor // and the base class has no dedicated cursor at all. - return m_integration->separateScreens() ? QEglFSScreen::cursor() : static_cast<QEglFSKmsEglDevice *>(device())->globalCursor(); + // config->hwCursor() is ignored for now, just use the standard OpenGL cursor. + return device()->screenConfig()->separateScreens() + ? QEglFSScreen::cursor() + : static_cast<QEglFSKmsEglDevice *>(device())->globalCursor(); } void QEglFSKmsEglDeviceScreen::waitForFlip() { - QEglFSKmsOutput &op(output()); + QKmsOutput &op(output()); const int fd = device()->fd(); const uint32_t w = op.modes[op.mode].hdisplay; const uint32_t h = op.modes[op.mode].vdisplay; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h index c57f52c6b7..5efe35f8b3 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h @@ -47,14 +47,12 @@ QT_BEGIN_NAMESPACE class QEglFSKmsEglDeviceScreen : public QEglFSKmsScreen { public: - QEglFSKmsEglDeviceScreen(QEglFSKmsIntegration *integration, - QEglFSKmsDevice *device, - QEglFSKmsOutput output); + QEglFSKmsEglDeviceScreen(QKmsDevice *device, const QKmsOutput &output); ~QEglFSKmsEglDeviceScreen(); - QPlatformCursor *cursor() const Q_DECL_OVERRIDE; + QPlatformCursor *cursor() const override; - void waitForFlip() Q_DECL_OVERRIDE; + void waitForFlip() override; }; QT_END_NAMESPACE |