backends/drm: fail commits if nonexistent properties would be set

This commit is contained in:
Xaver Hugl 2023-03-12 21:04:42 +01:00 committed by Vlad Zahorodnii
parent fa814d0b68
commit 96b625f7d7
2 changed files with 14 additions and 7 deletions

View file

@ -120,7 +120,10 @@ DrmPipeline::Error DrmPipeline::commitPipelinesAtomic(const QVector<DrmPipeline
failed(); failed();
return Error::TestBufferFailed; return Error::TestBufferFailed;
} }
pipeline->prepareAtomicPresentation(); if (!pipeline->prepareAtomicPresentation()) {
failed();
return Error::InvalidArguments;
}
if (mode == CommitMode::TestAllowModeset || mode == CommitMode::CommitModeset) { if (mode == CommitMode::TestAllowModeset || mode == CommitMode::CommitModeset) {
pipeline->prepareAtomicModeset(); 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)) { if (const auto contentType = m_connector->getProp(DrmConnector::PropertyIndex::ContentType)) {
contentType->setEnum(m_pending.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); 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)) { if (const auto gamma = m_pending.crtc->getProp(DrmCrtc::PropertyIndex::Gamma_LUT)) {
gamma->setPending(m_pending.gamma ? m_pending.gamma->blobId() : 0); gamma->setPending(m_pending.gamma ? m_pending.gamma->blobId() : 0);
m_pending.crtc->setPending(DrmCrtc::PropertyIndex::CTM, 0); } else if (m_pending.gamma) {
} else { return false;
m_pending.crtc->setPending(DrmCrtc::PropertyIndex::CTM, m_pending.ctm ? m_pending.ctm->blobId() : 0); }
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(); 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()->setBuffer(layer->isVisible() ? layer->currentBuffer().get() : nullptr);
m_pending.crtc->cursorPlane()->setPending(DrmPlane::PropertyIndex::CrtcId, layer->isVisible() ? m_pending.crtc->id() : 0); m_pending.crtc->cursorPlane()->setPending(DrmPlane::PropertyIndex::CrtcId, layer->isVisible() ? m_pending.crtc->id() : 0);
} }
return true;
} }
void DrmPipeline::prepareAtomicDisable() void DrmPipeline::prepareAtomicDisable()

View file

@ -172,7 +172,7 @@ private:
void atomicCommitSuccessful(); void atomicCommitSuccessful();
void atomicModesetSuccessful(); void atomicModesetSuccessful();
void prepareAtomicModeset(); void prepareAtomicModeset();
void prepareAtomicPresentation(); bool prepareAtomicPresentation();
void prepareAtomicDisable(); void prepareAtomicDisable();
static Error commitPipelinesAtomic(const QVector<DrmPipeline *> &pipelines, CommitMode mode, const QVector<DrmObject *> &unusedObjects); static Error commitPipelinesAtomic(const QVector<DrmPipeline *> &pipelines, CommitMode mode, const QVector<DrmObject *> &unusedObjects);