backends/drm: Pass DrmGpu to page flip handler through user data
The page flip handler can be simpler if it gets the gpu through user data. It also removes a usage of the Application singleton.
This commit is contained in:
parent
e179d9cea1
commit
82c1cf3de2
5 changed files with 7 additions and 22 deletions
|
@ -670,14 +670,6 @@ DrmGpu *DrmBackend::findGpu(dev_t deviceId) const
|
|||
return it == m_gpus.end() ? nullptr : it->get();
|
||||
}
|
||||
|
||||
DrmGpu *DrmBackend::findGpuByFd(int fd) const
|
||||
{
|
||||
auto it = std::find_if(m_gpus.begin(), m_gpus.end(), [fd](const auto &gpu) {
|
||||
return gpu->fd() == fd;
|
||||
});
|
||||
return it == m_gpus.end() ? nullptr : it->get();
|
||||
}
|
||||
|
||||
bool DrmBackend::applyOutputChanges(const OutputConfiguration &config)
|
||||
{
|
||||
QVector<DrmOutput *> toBeEnabled;
|
||||
|
|
|
@ -68,7 +68,6 @@ public:
|
|||
|
||||
DrmGpu *primaryGpu() const;
|
||||
DrmGpu *findGpu(dev_t deviceId) const;
|
||||
DrmGpu *findGpuByFd(int fd) const;
|
||||
|
||||
bool isActive() const;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "egl_gbm_backend.h"
|
||||
#include "gbm_dmabuf.h"
|
||||
#include "logging.h"
|
||||
#include "main.h"
|
||||
#include "renderloop_p.h"
|
||||
#include "session.h"
|
||||
#include "wayland/drmleasedevice_v1_interface.h"
|
||||
|
@ -527,16 +526,10 @@ static std::chrono::nanoseconds convertTimestamp(clockid_t sourceClock, clockid_
|
|||
|
||||
void DrmGpu::pageFlipHandler(int fd, unsigned int sequence, unsigned int sec, unsigned int usec, unsigned int crtc_id, void *user_data)
|
||||
{
|
||||
Q_UNUSED(fd)
|
||||
Q_UNUSED(sequence)
|
||||
Q_UNUSED(user_data)
|
||||
auto backend = dynamic_cast<DrmBackend *>(kwinApp()->platform());
|
||||
if (!backend) {
|
||||
return;
|
||||
}
|
||||
auto gpu = backend->findGpuByFd(fd);
|
||||
if (!gpu) {
|
||||
return;
|
||||
}
|
||||
|
||||
DrmGpu *gpu = static_cast<DrmGpu *>(user_data);
|
||||
|
||||
// The static_cast<> here are for a 32-bit environment where
|
||||
// sizeof(time_t) == sizeof(unsigned int) == 4 . Putting @p sec
|
||||
|
|
|
@ -145,12 +145,13 @@ DrmPipeline::Error DrmPipeline::commitPipelinesAtomic(const QVector<DrmPipeline
|
|||
} else {
|
||||
flags |= DRM_MODE_ATOMIC_NONBLOCK;
|
||||
}
|
||||
if (drmModeAtomicCommit(pipelines[0]->gpu()->fd(), req, (flags & (~DRM_MODE_PAGE_FLIP_EVENT)) | DRM_MODE_ATOMIC_TEST_ONLY, nullptr) != 0) {
|
||||
DrmGpu *gpu = pipelines[0]->gpu();
|
||||
if (drmModeAtomicCommit(gpu->fd(), req, (flags & (~DRM_MODE_PAGE_FLIP_EVENT)) | DRM_MODE_ATOMIC_TEST_ONLY, nullptr) != 0) {
|
||||
qCDebug(KWIN_DRM) << "Atomic test for" << mode << "failed!" << strerror(errno);
|
||||
failed();
|
||||
return errnoToError();
|
||||
}
|
||||
if (mode != CommitMode::Test && drmModeAtomicCommit(pipelines[0]->gpu()->fd(), req, flags, nullptr) != 0) {
|
||||
if (mode != CommitMode::Test && drmModeAtomicCommit(gpu->fd(), req, flags, gpu) != 0) {
|
||||
qCCritical(KWIN_DRM) << "Atomic commit failed! This should never happen!" << strerror(errno);
|
||||
failed();
|
||||
return errnoToError();
|
||||
|
|
|
@ -30,7 +30,7 @@ DrmPipeline::Error DrmPipeline::presentLegacy()
|
|||
}
|
||||
}
|
||||
const auto buffer = m_pending.layer->currentBuffer();
|
||||
if (drmModePageFlip(gpu()->fd(), m_pending.crtc->id(), buffer->framebufferId(), DRM_MODE_PAGE_FLIP_EVENT, nullptr) != 0) {
|
||||
if (drmModePageFlip(gpu()->fd(), m_pending.crtc->id(), buffer->framebufferId(), DRM_MODE_PAGE_FLIP_EVENT, gpu()) != 0) {
|
||||
qCWarning(KWIN_DRM) << "Page flip failed:" << strerror(errno);
|
||||
return errnoToError();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue