From 1c3256287c1edf7ffdd10e0a3ad57f129d02a4ce Mon Sep 17 00:00:00 2001 From: vaxerski Date: Wed, 21 Aug 2024 12:17:50 +0200 Subject: [PATCH] drm: verify output format in commit --- src/backend/drm/DRM.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/backend/drm/DRM.cpp b/src/backend/drm/DRM.cpp index 20e9165..f23b53f 100644 --- a/src/backend/drm/DRM.cpp +++ b/src/backend/drm/DRM.cpp @@ -1398,6 +1398,27 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) { } } + if (STATE.drmFormat == DRM_FORMAT_INVALID) { + backend->backend->log(AQ_LOG_ERROR, "drm: No format for output"); + return false; + } + + if (COMMITTED & COutputState::eOutputStateProperties::AQ_OUTPUT_STATE_FORMAT) { + // verify the format is valid for the primary plane + bool ok = false; + for (auto& f : getRenderFormats()) { + if (f.drmFormat == STATE.drmFormat) { + ok = true; + break; + } + } + + if (!ok) { + backend->backend->log(AQ_LOG_ERROR, "drm: Selected format is not supported by the primary KMS plane"); + return false; + } + } + if (STATE.adaptiveSync && !connector->canDoVrr) { backend->backend->log(AQ_LOG_ERROR, "drm: No Adaptive sync support for output"); return false;