From 6d9d4c190ad8948c5c6f767508c00cf8008d14fb Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Wed, 22 Jun 2022 10:22:30 +0200 Subject: [PATCH] backends/drm: fix enabled+inactive check When dpms disabled outputs get set active, they require a modeset. If after that they are set inactive again without resetting the pipelines first, they no longer require a modeset but still have the pending properties that would enable a crtc - but without a framebuffer set. To prevent this, first test the current setup as it is, and only then see if the pipelines would work if enabled again. --- src/backends/drm/drm_gpu.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/backends/drm/drm_gpu.cpp b/src/backends/drm/drm_gpu.cpp index 8285c1735d..78cf8b05d5 100644 --- a/src/backends/drm/drm_gpu.cpp +++ b/src/backends/drm/drm_gpu.cpp @@ -432,22 +432,22 @@ bool DrmGpu::testPendingConfiguration() bool DrmGpu::testPipelines() { - // pipelines that are enabled but not active need to be activated for the test QVector inactivePipelines; - for (const auto &pipeline : qAsConst(m_pipelines)) { - if (!pipeline->active()) { - pipeline->setActive(true); - inactivePipelines << pipeline; - } - } + std::copy_if(m_pipelines.constBegin(), m_pipelines.constEnd(), std::back_inserter(inactivePipelines), [](const auto pipeline) { + return pipeline->enabled() && !pipeline->active(); + }); const auto unused = unusedObjects(); bool test = DrmPipeline::commitPipelines(m_pipelines, DrmPipeline::CommitMode::Test, unused); - // disable inactive pipelines again - for (const auto &pipeline : qAsConst(inactivePipelines)) { - pipeline->setActive(false); - } if (!inactivePipelines.isEmpty() && test) { + // ensure that pipelines that are set as enabled but currently inactive + // still work when they need to be set active again + for (const auto pipeline : qAsConst(inactivePipelines)) { + pipeline->setActive(true); + } test = DrmPipeline::commitPipelines(m_pipelines, DrmPipeline::CommitMode::Test, unused); + for (const auto pipeline : qAsConst(inactivePipelines)) { + pipeline->setActive(false); + } } return test; }