kwin/src/plugins/platforms/drm/drm_object_crtc.cpp
Vlad Zahorodnii 15f1b9792b Revert "platforms/drm: Introduce DrmPipeline"
This reverts commit 5a22deda3b.

We still need more work to finish the DrmPipeline. At the moment, there
are a few major issues, e.g. some outputs not turning on, output
transforms not working correctly, a crash when changing dpms mode.

Let's merge this change back once all major issues are fixed and after
more testing.
2021-04-20 11:34:04 +00:00

84 lines
1.9 KiB
C++

/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2016 Roman Gilg <subdiff@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "drm_object_crtc.h"
#include "drm_backend.h"
#include "drm_output.h"
#include "drm_buffer.h"
#include "drm_pointer.h"
#include "logging.h"
#include "drm_gpu.h"
namespace KWin
{
DrmCrtc::DrmCrtc(DrmGpu *gpu, uint32_t crtcId, int pipeIndex)
: DrmObject(gpu, crtcId)
, m_crtc(drmModeGetCrtc(gpu->fd(), crtcId))
, m_pipeIndex(pipeIndex)
{
}
bool DrmCrtc::init()
{
if (!m_crtc) {
return false;
}
qCDebug(KWIN_DRM) << "Init for CRTC:" << pipeIndex() << "id:" << id();
return initProps({
PropertyDefinition(QByteArrayLiteral("MODE_ID")),
PropertyDefinition(QByteArrayLiteral("ACTIVE")),
}, DRM_MODE_OBJECT_CRTC);
}
void DrmCrtc::flipBuffer()
{
m_currentBuffer = m_nextBuffer;
m_nextBuffer = nullptr;
delete m_blackBuffer;
m_blackBuffer = nullptr;
}
bool DrmCrtc::blank(DrmOutput *output)
{
if (gpu()->atomicModeSetting()) {
return false;
}
if (!m_blackBuffer) {
DrmDumbBuffer *blackBuffer = new DrmDumbBuffer(gpu(), output->pixelSize());
if (!blackBuffer->map()) {
delete blackBuffer;
return false;
}
blackBuffer->image()->fill(Qt::black);
m_blackBuffer = blackBuffer;
}
if (output->setModeLegacy(m_blackBuffer)) {
m_currentBuffer = nullptr;
m_nextBuffer = nullptr;
return true;
}
return false;
}
bool DrmCrtc::setGammaRamp(const GammaRamp &gamma)
{
uint16_t *red = const_cast<uint16_t *>(gamma.red());
uint16_t *green = const_cast<uint16_t *>(gamma.green());
uint16_t *blue = const_cast<uint16_t *>(gamma.blue());
const bool isError = drmModeCrtcSetGamma(gpu()->fd(), id(),
gamma.size(), red, green, blue);
return !isError;
}
}