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

backends/drm: don't expose DrmPipeline state as a public member

While having all state be public is great for avoiding the boilerplate that
comes with setters and getters, it also exposes more state than necessary
to the rest of the backend and makes it more error-prone if more than one
part of the state needs to be changed at the same time.
parent f7452fb4
Pipeline #168594 passed with stage
in 12 minutes and 57 seconds
......@@ -276,7 +276,7 @@ bool DrmGpu::updateOutputs()
qCDebug(KWIN_DRM, "New %soutput on GPU %s: %s", conn->isNonDesktop() ? "non-desktop " : "", qPrintable(m_devNode), qPrintable(conn->modelName()));
m_pipelines << conn->pipeline();
if (conn->isNonDesktop()) {
conn->pipeline()->pending.active = false;
conn->pipeline()->setActive(false);
conn->pipeline()->applyPendingChanges();
auto leaseOutput = new DrmLeaseOutput(conn->pipeline(), m_leaseDevice);
m_leaseOutputs << leaseOutput;
......@@ -315,16 +315,16 @@ bool DrmGpu::updateOutputs()
}
for (const auto &pipeline : qAsConst(m_pipelines)) {
if (!pipeline->pending.layer) {
pipeline->pending.layer = m_platform->renderBackend()->createDrmPipelineLayer(pipeline);
if (!pipeline->layer()) {
pipeline->setLayer(m_platform->renderBackend()->createDrmPipelineLayer(pipeline));
pipeline->applyPendingChanges();
}
}
if (testPendingConfiguration()) {
for (const auto &pipeline : qAsConst(m_pipelines)) {
pipeline->applyPendingChanges();
if (pipeline->output() && !pipeline->pending.crtc) {
pipeline->pending.enabled = false;
if (pipeline->output() && !pipeline->crtc()) {
pipeline->setEnable(false);
pipeline->output()->setEnabled(false);
}
}
......@@ -335,7 +335,7 @@ bool DrmGpu::updateOutputs()
}
for (const auto &output : qAsConst(addedOutputs)) {
output->setEnabled(false);
output->pipeline()->pending.enabled = false;
output->pipeline()->setEnable(false);
output->pipeline()->applyPendingChanges();
}
}
......@@ -353,15 +353,15 @@ bool DrmGpu::checkCrtcAssignment(QVector<DrmConnector *> connectors, const QVect
// remaining connectors can't be powered
for (const auto &conn : qAsConst(connectors)) {
qCWarning(KWIN_DRM) << "disabling connector" << conn->modelName() << "without a crtc";
conn->pipeline()->pending.crtc = nullptr;
conn->pipeline()->setCrtc(nullptr);
}
return testPipelines();
}
auto connector = connectors.takeFirst();
auto pipeline = connector->pipeline();
if (!pipeline->pending.enabled) {
if (!pipeline->enabled()) {
// disabled pipelines don't need CRTCs
pipeline->pending.crtc = nullptr;
pipeline->setCrtc(nullptr);
return checkCrtcAssignment(connectors, crtcs);
}
DrmCrtc *currentCrtc = nullptr;
......@@ -375,7 +375,7 @@ bool DrmGpu::checkCrtcAssignment(QVector<DrmConnector *> connectors, const QVect
currentCrtc = *it;
auto crtcsLeft = crtcs;
crtcsLeft.removeOne(currentCrtc);
pipeline->pending.crtc = currentCrtc;
pipeline->setCrtc(currentCrtc);
if (checkCrtcAssignment(connectors, crtcsLeft)) {
return true;
}
......@@ -385,7 +385,7 @@ bool DrmGpu::checkCrtcAssignment(QVector<DrmConnector *> connectors, const QVect
if (connector->isCrtcSupported(crtc) && crtc != currentCrtc) {
auto crtcsLeft = crtcs;
crtcsLeft.removeOne(crtc);
pipeline->pending.crtc = crtc;
pipeline->setCrtc(crtc);
if (checkCrtcAssignment(connectors, crtcsLeft)) {
return true;
}
......@@ -407,7 +407,7 @@ bool DrmGpu::testPendingConfiguration()
for (const auto &output : qAsConst(m_leaseOutputs)) {
if (output->lease()) {
connectors.removeOne(output->pipeline()->connector());
crtcs.removeOne(output->pipeline()->pending.crtc);
crtcs.removeOne(output->pipeline()->crtc());
}
}
if (m_atomicModeSetting) {
......@@ -422,8 +422,8 @@ bool DrmGpu::testPendingConfiguration()
// try again without hw rotation
bool hwRotationUsed = false;
for (const auto &pipeline : qAsConst(m_pipelines)) {
hwRotationUsed |= (pipeline->pending.bufferOrientation != DrmPlane::Transformations(DrmPlane::Transformation::Rotate0));
pipeline->pending.bufferOrientation = DrmPlane::Transformation::Rotate0;
hwRotationUsed |= (pipeline->bufferOrientation() != DrmPlane::Transformations(DrmPlane::Transformation::Rotate0));
pipeline->setBufferOrientation(DrmPlane::Transformation::Rotate0);
}
return hwRotationUsed ? checkCrtcAssignment(connectors, crtcs) : false;
}
......@@ -434,8 +434,8 @@ bool DrmGpu::testPipelines()
// pipelines that are enabled but not active need to be activated for the test
QVector<DrmPipeline *> inactivePipelines;
for (const auto &pipeline : qAsConst(m_pipelines)) {
if (!pipeline->pending.active) {
pipeline->pending.active = true;
if (!pipeline->active()) {
pipeline->setActive(true);
inactivePipelines << pipeline;
}
}
......@@ -443,7 +443,7 @@ bool DrmGpu::testPipelines()
bool test = DrmPipeline::commitPipelines(m_pipelines, DrmPipeline::CommitMode::Test, unused);
// disable inactive pipelines again
for (const auto &pipeline : qAsConst(inactivePipelines)) {
pipeline->pending.active = false;
pipeline->setActive(false);
}
if (!inactivePipelines.isEmpty() && test) {
test = DrmPipeline::commitPipelines(m_pipelines, DrmPipeline::CommitMode::Test, unused);
......@@ -566,7 +566,7 @@ void DrmGpu::removeOutput(DrmOutput *output)
qCDebug(KWIN_DRM) << "Removing output" << output;
m_drmOutputs.removeOne(output);
m_pipelines.removeOne(output->pipeline());
output->pipeline()->pending.layer.reset();
output->pipeline()->setLayer(nullptr);
m_outputs.removeOne(output);
Q_EMIT outputRemoved(output);
delete output;
......@@ -665,7 +665,7 @@ void DrmGpu::removeLeaseOutput(DrmLeaseOutput *output)
qCDebug(KWIN_DRM) << "Removing leased output" << output;
m_leaseOutputs.removeOne(output);
m_pipelines.removeOne(output->pipeline());
output->pipeline()->pending.layer.reset();
output->pipeline()->setLayer(nullptr);
delete output;
}
......@@ -738,7 +738,7 @@ bool DrmGpu::maybeModeset()
}
}
bool presentPendingForAll = std::all_of(pipelines.constBegin(), pipelines.constEnd(), [](const auto &pipeline) {
return pipeline->modesetPresentPending() || !pipeline->pending.active;
return pipeline->modesetPresentPending() || !pipeline->active();
});
if (!presentPendingForAll) {
// commit only once all pipelines are ready for presentation
......@@ -766,10 +766,10 @@ QVector<DrmObject *> DrmGpu::unusedObjects() const
QVector<DrmObject *> ret = m_allObjects;
for (const auto &pipeline : m_pipelines) {
ret.removeOne(pipeline->connector());
if (pipeline->pending.crtc) {
ret.removeOne(pipeline->pending.crtc);
ret.removeOne(pipeline->pending.crtc->primaryPlane());
ret.removeOne(pipeline->pending.crtc->cursorPlane());
if (pipeline->crtc()) {
ret.removeOne(pipeline->crtc());
ret.removeOne(pipeline->crtc()->primaryPlane());
ret.removeOne(pipeline->crtc()->cursorPlane());
}
}
return ret;
......@@ -783,7 +783,7 @@ QSize DrmGpu::cursorSize() const
void DrmGpu::recreateSurfaces()
{
for (const auto &pipeline : qAsConst(m_pipelines)) {
pipeline->pending.layer = m_platform->renderBackend()->createDrmPipelineLayer(pipeline);
pipeline->setLayer(m_platform->renderBackend()->createDrmPipelineLayer(pipeline));
pipeline->applyPendingChanges();
}
for (const auto &output : qAsConst(m_outputs)) {
......
......@@ -41,15 +41,15 @@ DrmLeaseOutput::~DrmLeaseOutput()
bool DrmLeaseOutput::addLeaseObjects(QVector<uint32_t> &objectList)
{
if (!m_pipeline->pending.crtc) {
if (!m_pipeline->crtc()) {
qCWarning(KWIN_DRM) << "Can't lease connector: No suitable crtc available";
return false;
}
qCDebug(KWIN_DRM) << "adding connector" << m_pipeline->connector()->id() << "to lease";
objectList << m_pipeline->connector()->id();
objectList << m_pipeline->pending.crtc->id();
if (m_pipeline->pending.crtc->primaryPlane()) {
objectList << m_pipeline->pending.crtc->primaryPlane()->id();
objectList << m_pipeline->crtc()->id();
if (m_pipeline->crtc()->primaryPlane()) {
objectList << m_pipeline->crtc()->primaryPlane()->id();
}
return true;
}
......
......@@ -347,8 +347,8 @@ bool DrmConnector::updateProperties()
return false;
} else {
generateCommonModes();
if (!m_pipeline->pending.mode) {
m_pipeline->pending.mode = m_modes.constFirst();
if (!m_pipeline->mode()) {
m_pipeline->setMode(m_modes.constFirst());
m_pipeline->applyPendingChanges();
}
if (m_pipeline->output()) {
......
......@@ -47,7 +47,7 @@ DrmOutput::DrmOutput(DrmPipeline *pipeline)
{
m_pipeline->setOutput(this);
const auto conn = m_pipeline->connector();
m_renderLoop->setRefreshRate(m_pipeline->pending.mode->refreshRate());
m_renderLoop->setRefreshRate(m_pipeline->mode()->refreshRate());
Capabilities capabilities = Capability::Dpms;
if (conn->hasOverscan()) {
......@@ -79,7 +79,7 @@ DrmOutput::DrmOutput(DrmPipeline *pipeline)
});
const QList<QSharedPointer<OutputMode>> modes = getModes();
QSharedPointer<OutputMode> currentMode = m_pipeline->pending.mode;
QSharedPointer<OutputMode> currentMode = m_pipeline->mode();
if (!currentMode) {
currentMode = modes.constFirst();
}
......@@ -119,7 +119,7 @@ void DrmOutput::updateCursor()
m_setCursorSuccessful = false;
return;
}
if (!m_pipeline->pending.crtc) {
if (!m_pipeline->crtc()) {
return;
}
const Cursor *cursor = Cursors::self()->currentCursor();
......@@ -136,7 +136,7 @@ void DrmOutput::updateCursor()
m_pipeline->setCursor(nullptr);
return;
}
const auto plane = m_pipeline->pending.crtc->cursorPlane();
const auto plane = m_pipeline->crtc()->cursorPlane();
if (!m_cursor || (plane && !plane->formats().value(m_cursor->drmFormat()).contains(DRM_FORMAT_MOD_LINEAR))) {
if (plane && (!plane->formats().contains(DRM_FORMAT_ARGB8888) || !plane->formats().value(DRM_FORMAT_ARGB8888).contains(DRM_FORMAT_MOD_LINEAR))) {
m_pipeline->setCursor(nullptr);
......@@ -173,7 +173,7 @@ void DrmOutput::updateCursor()
void DrmOutput::moveCursor()
{
if (!m_setCursorSuccessful || !m_pipeline->pending.crtc) {
if (!m_setCursorSuccessful || !m_pipeline->crtc()) {
return;
}
Cursor *cursor = Cursors::self()->currentCursor();
......@@ -231,7 +231,7 @@ bool DrmOutput::setDrmDpmsMode(DpmsMode mode)
setDpmsModeInternal(mode);
return true;
}
m_pipeline->pending.active = active;
m_pipeline->setActive(active);
if (DrmPipeline::commitPipelines({m_pipeline}, active ? DrmPipeline::CommitMode::Test : DrmPipeline::CommitMode::CommitModeset)) {
m_pipeline->applyPendingChanges();
setDpmsModeInternal(mode);
......@@ -285,14 +285,14 @@ void DrmOutput::updateModes()
{
const QList<QSharedPointer<OutputMode>> modes = getModes();
if (m_pipeline->pending.crtc) {
const auto currentMode = m_pipeline->connector()->findMode(m_pipeline->pending.crtc->queryCurrentMode());
if (currentMode != m_pipeline->pending.mode) {
if (m_pipeline->crtc()) {
const auto currentMode = m_pipeline->connector()->findMode(m_pipeline->crtc()->queryCurrentMode());
if (currentMode != m_pipeline->mode()) {
// DrmConnector::findCurrentMode might fail
m_pipeline->pending.mode = currentMode ? currentMode : m_pipeline->connector()->modes().constFirst();
m_pipeline->setMode(currentMode ? currentMode : m_pipeline->connector()->modes().constFirst());
if (m_gpu->testPendingConfiguration()) {
m_pipeline->applyPendingChanges();
m_renderLoop->setRefreshRate(m_pipeline->pending.mode->refreshRate());
m_renderLoop->setRefreshRate(m_pipeline->mode()->refreshRate());
} else {
qCWarning(KWIN_DRM) << "Setting changed mode failed!";
m_pipeline->revertPendingChanges();
......@@ -300,7 +300,7 @@ void DrmOutput::updateModes()
}
}
QSharedPointer<OutputMode> currentMode = m_pipeline->pending.mode;
QSharedPointer<OutputMode> currentMode = m_pipeline->mode();
if (!currentMode) {
currentMode = modes.constFirst();
}
......@@ -311,8 +311,8 @@ void DrmOutput::updateModes()
bool DrmOutput::present()
{
RenderLoopPrivate *renderLoopPrivate = RenderLoopPrivate::get(m_renderLoop);
if (m_pipeline->pending.syncMode != renderLoopPrivate->presentMode) {
m_pipeline->pending.syncMode = renderLoopPrivate->presentMode;
if (m_pipeline->syncMode() != renderLoopPrivate->presentMode) {
m_pipeline->setSyncMode(renderLoopPrivate->presentMode);
if (DrmPipeline::commitPipelines({m_pipeline}, DrmPipeline::CommitMode::Test)) {
m_pipeline->applyPendingChanges();
} else {
......@@ -321,7 +321,7 @@ bool DrmOutput::present()
}
bool modeset = gpu()->needsModeset();
if (modeset ? m_pipeline->maybeModeset() : m_pipeline->present()) {
Q_EMIT outputChange(m_pipeline->pending.layer->currentDamage());
Q_EMIT outputChange(m_pipeline->layer()->currentDamage());
return true;
} else if (!modeset) {
qCWarning(KWIN_DRM) << "Presentation failed!" << strerror(errno);
......@@ -346,7 +346,7 @@ bool DrmOutput::queueChanges(const OutputConfiguration &config)
static int envOnlySoftwareRotations = qEnvironmentVariableIntValue("KWIN_DRM_SW_ROTATIONS_ONLY", &valid) == 1 || !valid;
const auto props = config.constChangeSet(this);
m_pipeline->pending.active = props->enabled;
m_pipeline->setActive(props->enabled);
const auto modelist = m_connector->modes();
const auto it = std::find_if(modelist.begin(), modelist.end(), [&props](const auto &mode) {
return mode->size() == props->modeSize && mode->refreshRate() == props->refreshRate;
......@@ -355,14 +355,14 @@ bool DrmOutput::queueChanges(const OutputConfiguration &config)
qCWarning(KWIN_DRM).nospace() << "Could not find mode " << props->modeSize << "@" << props->refreshRate << " for output " << this;
return false;
}
m_pipeline->pending.mode = *it;
m_pipeline->pending.overscan = props->overscan;
m_pipeline->pending.rgbRange = props->rgbRange;
m_pipeline->pending.renderOrientation = outputToPlaneTransform(props->transform);
m_pipeline->setMode(*it);
m_pipeline->setOverscan(props->overscan);
m_pipeline->setRgbRange(props->rgbRange);
m_pipeline->setRenderOrientation(outputToPlaneTransform(props->transform));
if (!envOnlySoftwareRotations && m_gpu->atomicModeSetting()) {
m_pipeline->pending.bufferOrientation = m_pipeline->pending.renderOrientation;
m_pipeline->setBufferOrientation(m_pipeline->renderOrientation());
}
m_pipeline->pending.enabled = props->enabled;
m_pipeline->setEnable(props->enabled);
return true;
}
......@@ -375,7 +375,7 @@ void DrmOutput::applyQueuedChanges(const OutputConfiguration &config)
m_pipeline->applyPendingChanges();
auto props = config.constChangeSet(this);
setEnabled(props->enabled && m_pipeline->pending.crtc);
setEnabled(props->enabled && m_pipeline->crtc());
if (!isEnabled() && m_pipeline->needsModeset()) {
m_gpu->maybeModeset();
}
......@@ -383,11 +383,11 @@ void DrmOutput::applyQueuedChanges(const OutputConfiguration &config)
setScale(props->scale);
setTransformInternal(props->transform);
const auto &mode = m_pipeline->pending.mode;
const auto mode = m_pipeline->mode();
setCurrentModeInternal(mode);
m_renderLoop->setRefreshRate(mode->refreshRate());
setOverscanInternal(m_pipeline->pending.overscan);
setRgbRangeInternal(m_pipeline->pending.rgbRange);
setOverscanInternal(m_pipeline->overscan());
setRgbRangeInternal(m_pipeline->rgbRange());
setVrrPolicy(props->vrrPolicy);
m_renderLoop->scheduleRepaint();
......@@ -406,12 +406,12 @@ bool DrmOutput::usesSoftwareCursor() const
DrmOutputLayer *DrmOutput::outputLayer() const
{
return m_pipeline->pending.layer.data();
return m_pipeline->layer();
}
void DrmOutput::setColorTransformation(const QSharedPointer<ColorTransformation> &transformation)
{
m_pipeline->pending.colorTransformation = transformation;
m_pipeline->setColorTransformation(transformation);
if (DrmPipeline::commitPipelines({m_pipeline}, DrmPipeline::CommitMode::Test)) {
m_pipeline->applyPendingChanges();
m_renderLoop->scheduleRepaint();
......
......@@ -60,11 +60,11 @@ bool DrmPipeline::testScanout()
bool DrmPipeline::present()
{
Q_ASSERT(pending.crtc);
Q_ASSERT(m_pending.crtc);
if (gpu()->atomicModeSetting()) {
return commitPipelines({this}, CommitMode::Commit);
} else {
if (pending.layer->hasDirectScanoutBuffer()) {
if (m_pending.layer->hasDirectScanoutBuffer()) {
// already presented
return true;
}
......@@ -113,7 +113,7 @@ bool DrmPipeline::commitPipelinesAtomic(const QVector<DrmPipeline *> &pipelines,
return false;
};
for (const auto &pipeline : pipelines) {
if (pipeline->activePending() && !pipeline->pending.layer->checkTestBuffer()) {
if (pipeline->activePending() && !pipeline->m_pending.layer->checkTestBuffer()) {
qCWarning(KWIN_DRM) << "Checking test buffer failed for" << mode;
return failed();
}
......@@ -173,35 +173,35 @@ bool DrmPipeline::populateAtomicValues(drmModeAtomicReq *req, uint32_t &flags)
if (activePending()) {
flags |= DRM_MODE_PAGE_FLIP_EVENT;
}
if (pending.crtc) {
pending.crtc->setPending(DrmCrtc::PropertyIndex::VrrEnabled, pending.syncMode == RenderLoopPrivate::SyncMode::Adaptive);
const auto currentTransformation = pending.gamma ? pending.gamma->lut().transformation() : nullptr;
if (pending.colorTransformation != currentTransformation) {
pending.gamma = QSharedPointer<DrmGammaRamp>::create(pending.crtc, pending.colorTransformation);
if (m_pending.crtc) {
m_pending.crtc->setPending(DrmCrtc::PropertyIndex::VrrEnabled, m_pending.syncMode == RenderLoopPrivate::SyncMode::Adaptive);
const auto currentTransformation = m_pending.gamma ? m_pending.gamma->lut().transformation() : nullptr;
if (m_pending.colorTransformation != currentTransformation) {
m_pending.gamma = QSharedPointer<DrmGammaRamp>::create(m_pending.crtc, m_pending.colorTransformation);
}
pending.crtc->setPending(DrmCrtc::PropertyIndex::Gamma_LUT, pending.gamma ? pending.gamma->blobId() : 0);
const auto modeSize = pending.mode->size();
const auto buffer = pending.layer->currentBuffer().data();
pending.crtc->primaryPlane()->set(QPoint(0, 0), buffer ? buffer->size() : bufferSize(), QPoint(0, 0), modeSize);
pending.crtc->primaryPlane()->setBuffer(activePending() ? buffer : nullptr);
if (pending.crtc->cursorPlane()) {
pending.crtc->cursorPlane()->set(QPoint(0, 0), gpu()->cursorSize(), pending.cursorPos, gpu()->cursorSize());
pending.crtc->cursorPlane()->setBuffer(activePending() ? pending.cursorBo.get() : nullptr);
pending.crtc->cursorPlane()->setPending(DrmPlane::PropertyIndex::CrtcId, (activePending() && pending.cursorBo) ? pending.crtc->id() : 0);
m_pending.crtc->setPending(DrmCrtc::PropertyIndex::Gamma_LUT, m_pending.gamma ? m_pending.gamma->blobId() : 0);
const auto modeSize = m_pending.mode->size();
const auto buffer = m_pending.layer->currentBuffer().data();
m_pending.crtc->primaryPlane()->set(QPoint(0, 0), buffer ? buffer->size() : bufferSize(), QPoint(0, 0), modeSize);
m_pending.crtc->primaryPlane()->setBuffer(activePending() ? buffer : nullptr);
if (m_pending.crtc->cursorPlane()) {
m_pending.crtc->cursorPlane()->set(QPoint(0, 0), gpu()->cursorSize(), m_pending.cursorPos, gpu()->cursorSize());
m_pending.crtc->cursorPlane()->setBuffer(activePending() ? m_pending.cursorBo.get() : nullptr);
m_pending.crtc->cursorPlane()->setPending(DrmPlane::PropertyIndex::CrtcId, (activePending() && m_pending.cursorBo) ? m_pending.crtc->id() : 0);
}
}
if (!m_connector->atomicPopulate(req)) {
return false;
}
if (pending.crtc) {
if (!pending.crtc->atomicPopulate(req)) {
if (m_pending.crtc) {
if (!m_pending.crtc->atomicPopulate(req)) {
return false;
}
if (!pending.crtc->primaryPlane()->atomicPopulate(req)) {
if (!m_pending.crtc->primaryPlane()->atomicPopulate(req)) {
return false;
}
if (pending.crtc->cursorPlane() && !pending.crtc->cursorPlane()->atomicPopulate(req)) {
if (m_pending.crtc->cursorPlane() && !m_pending.crtc->cursorPlane()->atomicPopulate(req)) {
return false;
}
}
......@@ -210,49 +210,49 @@ bool DrmPipeline::populateAtomicValues(drmModeAtomicReq *req, uint32_t &flags)
void DrmPipeline::prepareAtomicModeset()
{
if (!pending.crtc) {
if (!m_pending.crtc) {
m_connector->setPending(DrmConnector::PropertyIndex::CrtcId, 0);
return;
}
m_connector->setPending(DrmConnector::PropertyIndex::CrtcId, activePending() ? pending.crtc->id() : 0);
m_connector->setPending(DrmConnector::PropertyIndex::CrtcId, activePending() ? m_pending.crtc->id() : 0);
if (const auto &prop = m_connector->getProp(DrmConnector::PropertyIndex::Broadcast_RGB)) {
prop->setEnum(pending.rgbRange);
prop->setEnum(m_pending.rgbRange);
}
if (const auto &prop = m_connector->getProp(DrmConnector::PropertyIndex::LinkStatus)) {
prop->setEnum(DrmConnector::LinkStatus::Good);
}
if (const auto overscan = m_connector->getProp(DrmConnector::PropertyIndex::Overscan)) {
overscan->setPending(pending.overscan);
overscan->setPending(m_pending.overscan);
} else if (const auto underscan = m_connector->getProp(DrmConnector::PropertyIndex::Underscan)) {
const uint32_t hborder = calculateUnderscan();
underscan->setEnum(pending.overscan != 0 ? DrmConnector::UnderscanOptions::On : DrmConnector::UnderscanOptions::Off);
m_connector->getProp(DrmConnector::PropertyIndex::Underscan_vborder)->setPending(pending.overscan);
underscan->setEnum(m_pending.overscan != 0 ? DrmConnector::UnderscanOptions::On : DrmConnector::UnderscanOptions::Off);
m_connector->getProp(DrmConnector::PropertyIndex::Underscan_vborder)->setPending(m_pending.overscan);
m_connector->getProp(DrmConnector::PropertyIndex::Underscan_hborder)->setPending(hborder);
}
if (const auto bpc = m_connector->getProp(DrmConnector::PropertyIndex::MaxBpc)) {
bpc->setPending(bpc->maxValue());
}
pending.crtc->setPending(DrmCrtc::PropertyIndex::Active, activePending());
pending.crtc->setPending(DrmCrtc::PropertyIndex::ModeId, activePending() ? pending.mode->blobId() : 0);
m_pending.crtc->setPending(DrmCrtc::PropertyIndex::Active, activePending());
m_pending.crtc->setPending(DrmCrtc::PropertyIndex::ModeId, activePending() ? m_pending.mode->blobId() : 0);
pending.crtc->primaryPlane()->setPending(DrmPlane::PropertyIndex::CrtcId, activePending() ? pending.crtc->id() : 0);
pending.crtc->primaryPlane()->setTransformation(pending.bufferOrientation);
if (pending.crtc->cursorPlane()) {
pending.crtc->cursorPlane()->setTransformation(DrmPlane::Transformation::Rotate0);
m_pending.crtc->primaryPlane()->setPending(DrmPlane::PropertyIndex::CrtcId, activePending() ? m_pending.crtc->id() : 0);
m_pending.crtc->primaryPlane()->setTransformation(m_pending.bufferOrientation);
if (m_pending.crtc->cursorPlane()) {
m_pending.crtc->cursorPlane()->setTransformation(DrmPlane::Transformation::Rotate0);
}
}
uint32_t DrmPipeline::calculateUnderscan()
{
const auto size = pending.mode->size();
const auto size = m_pending.mode->size();
const float aspectRatio = size.width() / static_cast<float>(size.height());
uint32_t hborder = pending.overscan * aspectRatio;
uint32_t hborder = m_pending.overscan * aspectRatio;
if (hborder > 128) {
// overscan only goes from 0-100 so we cut off the 101-128 value range of underscan_vborder
hborder = 128;
pending.overscan = 128 / aspectRatio;
m_pending.overscan = 128 / aspectRatio;
}
return hborder;
}
......@@ -260,11 +260,11 @@ uint32_t DrmPipeline::calculateUnderscan()
void DrmPipeline::atomicCommitFailed()
{
m_connector->rollbackPending();
if (pending.crtc) {
pending.crtc->rollbackPending();
pending.crtc->primaryPlane()->rollbackPending();
if (pending.crtc->cursorPlane()) {
pending.crtc->cursorPlane()->rollbackPending();
if (m_pending.crtc) {
m_pending.crtc->rollbackPending();
m_pending.crtc->primaryPlane()->rollbackPending();
if (m_pending.crtc->cursorPlane()) {
m_pending.crtc->cursorPlane()->rollbackPending();
}
}
}
......@@ -272,11 +272,11 @@ void DrmPipeline::atomicCommitFailed()
void DrmPipeline::atomicCommitSuccessful(CommitMode mode)
{
m_connector->commitPending();
if (pending.crtc) {
pending.crtc->commitPending();
pending.crtc->primaryPlane()->commitPending();
if (pending.crtc->cursorPlane()) {
pending.crtc->cursorPlane()->commitPending();
if (m_pending.crtc) {
m_pending.crtc->commitPending();
m_pending.crtc->primaryPlane()->commitPending();
if (m_pending.crtc->cursorPlane()) {
m_pending.crtc->cursorPlane()->commitPending();
}
}
if (mode != CommitMode::Test) {
......@@ -284,16 +284,16 @@ void DrmPipeline::atomicCommitSuccessful(CommitMode mode)
m_pageflipPending = true;
}
m_connector->commit();
if (pending.crtc) {
pending.crtc->commit();
pending.crtc->primaryPlane()->setNext(pending.layer->currentBuffer());
pending.crtc->primaryPlane()->commit();
if (pending.crtc->cursorPlane()) {
pending.crtc->cursorPlane()->setNext(pending.cursorBo);
pending.crtc->cursorPlane()->commit();
if (m_pending.crtc) {
m_pending.crtc->commit();
m_pending.crtc->primaryPlane()->setNext(m_pending.layer->currentBuffer());
m_pending.crtc->primaryPlane()->commit();
if (m_pending.crtc->cursorPlane()) {
m_pending.crtc->cursorPlane()->setNext(m_pending.cursorBo);
m_pending.crtc->cursorPlane()->commit();
}
}
m_current = pending;
m_current = m_pending;
if (mode == CommitMode::CommitModeset && activePending()) {
pageFlipped(std::chrono::steady_clock::now().time_since_epoch());
}
......@@ -302,67 +302,67 @@ void DrmPipeline::atomicCommitSuccessful(CommitMode mode)
bool DrmPipeline::setCursor(const QSharedPointer<DrmDumbBuffer> &buffer, const QPoint &hotspot)
{
if (pending.cursorBo == buffer && pending.cursorHotspot == hotspot) {
if (m_pending.cursorBo == buffer && m_pending.cursorHotspot == hotspot) {
return true;
}
bool result;
const bool visibleBefore = isCursorVisible();
pending.cursorBo = buffer;
pending.cursorHotspot = hotspot;
m_pending.cursorBo = buffer;
m_pending.cursorHotspot = hotspot;
// explicitly check for the cursor plane and not for AMS, as we might not always have one
if (pending.crtc->cursorPlane()) {
if (m_pending.crtc->cursorPlane()) {
result = commitPipelines({this}, CommitMode::Test);
} else {