Commit d3c3d8c2 authored by Xaver Hugl's avatar Xaver Hugl
Browse files

Properly clean up DrmGpu

CCBUG: 433145
(cherry picked from commit 79ccfadd)
parent 72d3f30e
......@@ -57,8 +57,6 @@
#define DRM_CAP_CURSOR_HEIGHT 0x9
#endif
#define KWIN_DRM_EVENT_CONTEXT_VERSION 2
namespace KWin
{
......@@ -287,31 +285,17 @@ void DrmBackend::openDrm()
}
drmModeFreeResources(resources);
m_active = true;
QSocketNotifier *notifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
connect(notifier, &QSocketNotifier::activated, this,
[fd] {
if (!LogindIntegration::self()->isActiveSession()) {
return;
}
drmEventContext e;
memset(&e, 0, sizeof e);
e.version = KWIN_DRM_EVENT_CONTEXT_VERSION;
e.page_flip_handler = pageFlipHandler;
drmHandleEvent(fd, &e);
}
);
DrmGpu *gpu = new DrmGpu(this, devNode, fd, device->sysNum());
connect(gpu, &DrmGpu::outputAdded, this, &DrmBackend::addOutput);
connect(gpu, &DrmGpu::outputRemoved, this, &DrmBackend::removeOutput);
if (gpu->useEglStreams()) {
// TODO this needs to be removed once EglStreamBackend supports multi-gpu operation
if (gpu_index == 0) {
m_gpus.append(gpu);
if (!gpu->useEglStreams() || gpu_index == 0) {
m_gpus.append(gpu);
m_active = true;
connect(gpu, &DrmGpu::outputAdded, this, &DrmBackend::addOutput);
connect(gpu, &DrmGpu::outputRemoved, this, &DrmBackend::removeOutput);
if (gpu->useEglStreams()) {
break;
}
} else {
m_gpus.append(gpu);
delete gpu;
}
}
......
......@@ -15,6 +15,7 @@
#include "drm_object_crtc.h"
#include "abstract_egl_backend.h"
#include "logging.h"
#include "logind.h"
#if HAVE_GBM
#include "egl_gbm_backend.h"
......@@ -29,6 +30,8 @@
#include <xf86drmMode.h>
#include <libdrm/drm_mode.h>
#define KWIN_DRM_EVENT_CONTEXT_VERSION 2
namespace KWin
{
......@@ -60,6 +63,20 @@ DrmGpu::DrmGpu(DrmBackend *backend, QByteArray devNode, int fd, int drmId) : m_b
m_useEglStreams = strstr(version->name, "nvidia-drm");
m_deleteBufferAfterPageFlip = !m_useEglStreams;
m_socketNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
connect(m_socketNotifier, &QSocketNotifier::activated, this,
[fd] {
if (!LogindIntegration::self()->isActiveSession()) {
return;
}
drmEventContext e;
memset(&e, 0, sizeof e);
e.version = KWIN_DRM_EVENT_CONTEXT_VERSION;
e.page_flip_handler = DrmBackend::pageFlipHandler;
drmHandleEvent(fd, &e);
}
);
}
DrmGpu::~DrmGpu()
......@@ -73,7 +90,8 @@ DrmGpu::~DrmGpu()
qDeleteAll(m_crtcs);
qDeleteAll(m_connectors);
qDeleteAll(m_planes);
close(m_fd);
delete m_socketNotifier;
LogindIntegration::self()->releaseDevice(m_fd);
}
clockid_t DrmGpu::presentationClock() const
......
......@@ -12,6 +12,7 @@
#include <qobject.h>
#include <QVector>
#include <QSocketNotifier>
#include <epoxy/egl.h>
......@@ -135,6 +136,7 @@ private:
gbm_device* m_gbmDevice;
EGLDisplay m_eglDisplay = EGL_NO_DISPLAY;
clockid_t m_presentationClock;
QSocketNotifier *m_socketNotifier = nullptr;
// all available planes: primarys, cursors and overlays
QVector<DrmPlane*> m_planes;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment