From 96b625f7d7b9725532b852f601d1f81934f92358 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Sun, 12 Mar 2023 21:04:42 +0100 Subject: [PATCH] backends/drm: fail commits if nonexistent properties would be set --- src/backends/drm/drm_pipeline.cpp | 19 +++++++++++++------ src/backends/drm/drm_pipeline.h | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/backends/drm/drm_pipeline.cpp b/src/backends/drm/drm_pipeline.cpp index 03e8c96a1d..d25ea583d1 100644 --- a/src/backends/drm/drm_pipeline.cpp +++ b/src/backends/drm/drm_pipeline.cpp @@ -120,7 +120,10 @@ DrmPipeline::Error DrmPipeline::commitPipelinesAtomic(const QVectorprepareAtomicPresentation(); + if (!pipeline->prepareAtomicPresentation()) { + failed(); + return Error::InvalidArguments; + } if (mode == CommitMode::TestAllowModeset || mode == CommitMode::CommitModeset) { pipeline->prepareAtomicModeset(); } @@ -231,19 +234,22 @@ static QRect centerBuffer(const QSize &bufferSize, const QSize &modeSize) } } -void DrmPipeline::prepareAtomicPresentation() +bool DrmPipeline::prepareAtomicPresentation() { if (const auto contentType = m_connector->getProp(DrmConnector::PropertyIndex::ContentType)) { contentType->setEnum(m_pending.contentType); } m_pending.crtc->setPending(DrmCrtc::PropertyIndex::VrrEnabled, m_pending.syncMode == RenderLoopPrivate::SyncMode::Adaptive || m_pending.syncMode == RenderLoopPrivate::SyncMode::AdaptiveAsync); - // use LUT if available, CTM if not if (const auto gamma = m_pending.crtc->getProp(DrmCrtc::PropertyIndex::Gamma_LUT)) { gamma->setPending(m_pending.gamma ? m_pending.gamma->blobId() : 0); - m_pending.crtc->setPending(DrmCrtc::PropertyIndex::CTM, 0); - } else { - m_pending.crtc->setPending(DrmCrtc::PropertyIndex::CTM, m_pending.ctm ? m_pending.ctm->blobId() : 0); + } else if (m_pending.gamma) { + return false; + } + if (const auto ctm = m_pending.crtc->getProp(DrmCrtc::PropertyIndex::CTM)) { + ctm->setPending(m_pending.ctm ? m_pending.ctm->blobId() : 0); + } else if (m_pending.ctm) { + return false; } const auto fb = m_pending.layer->currentBuffer().get(); @@ -256,6 +262,7 @@ void DrmPipeline::prepareAtomicPresentation() m_pending.crtc->cursorPlane()->setBuffer(layer->isVisible() ? layer->currentBuffer().get() : nullptr); m_pending.crtc->cursorPlane()->setPending(DrmPlane::PropertyIndex::CrtcId, layer->isVisible() ? m_pending.crtc->id() : 0); } + return true; } void DrmPipeline::prepareAtomicDisable() diff --git a/src/backends/drm/drm_pipeline.h b/src/backends/drm/drm_pipeline.h index c3c83ff3ae..027059c723 100644 --- a/src/backends/drm/drm_pipeline.h +++ b/src/backends/drm/drm_pipeline.h @@ -172,7 +172,7 @@ private: void atomicCommitSuccessful(); void atomicModesetSuccessful(); void prepareAtomicModeset(); - void prepareAtomicPresentation(); + bool prepareAtomicPresentation(); void prepareAtomicDisable(); static Error commitPipelinesAtomic(const QVector &pipelines, CommitMode mode, const QVector &unusedObjects);