diff --git a/src/plugins/platforms/drm/drm_object.cpp b/src/plugins/platforms/drm/drm_object.cpp index 78939e15b3..e918e42561 100644 --- a/src/plugins/platforms/drm/drm_object.cpp +++ b/src/plugins/platforms/drm/drm_object.cpp @@ -174,6 +174,12 @@ bool DrmObject::updateProperties() deleteProp(propIndex); } } + for (int i = 0; i < m_propertyDefinitions.count(); i++) { + if (m_gpu->atomicModeSetting() && m_propertyDefinitions[i].requirement == Requirement::Required && !m_props[i]) { + qCWarning(KWIN_DRM, "Required property %s for object %d not found!", qPrintable(m_propertyDefinitions[i].name), m_id); + return false; + } + } return true; } diff --git a/src/plugins/platforms/drm/drm_object.h b/src/plugins/platforms/drm/drm_object.h index 9f3f379422..a77ad336b8 100644 --- a/src/plugins/platforms/drm/drm_object.h +++ b/src/plugins/platforms/drm/drm_object.h @@ -175,13 +175,20 @@ public: virtual bool updateProperties(); protected: + enum class Requirement { + Required, + Optional + }; struct PropertyDefinition { - PropertyDefinition(const QByteArray &name, const QVector &&enumNames = {}) - : name(name), enumNames(enumNames) + PropertyDefinition(const QByteArray &name, Requirement requirement, const QVector &&enumNames = {}) + : name(name) + , requirement(requirement) + , enumNames(enumNames) { } QByteArray name; + Requirement requirement; QVector enumNames; }; diff --git a/src/plugins/platforms/drm/drm_object_connector.cpp b/src/plugins/platforms/drm/drm_object_connector.cpp index 949914fa44..54d6b0ebd4 100644 --- a/src/plugins/platforms/drm/drm_object_connector.cpp +++ b/src/plugins/platforms/drm/drm_object_connector.cpp @@ -23,19 +23,19 @@ namespace KWin DrmConnector::DrmConnector(DrmGpu *gpu, uint32_t connectorId) : DrmObject(gpu, connectorId, { - PropertyDefinition(QByteArrayLiteral("CRTC_ID")), - PropertyDefinition(QByteArrayLiteral("non-desktop")), - PropertyDefinition(QByteArrayLiteral("DPMS")), - PropertyDefinition(QByteArrayLiteral("EDID")), - PropertyDefinition(QByteArrayLiteral("overscan")), - PropertyDefinition(QByteArrayLiteral("vrr_capable")), - PropertyDefinition(QByteArrayLiteral("underscan"), { + PropertyDefinition(QByteArrayLiteral("CRTC_ID"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("non-desktop"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("DPMS"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("EDID"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("overscan"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("vrr_capable"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("underscan"), Requirement::Optional, { QByteArrayLiteral("off"), QByteArrayLiteral("on"), QByteArrayLiteral("auto") }), - PropertyDefinition(QByteArrayLiteral("underscan vborder")), - PropertyDefinition(QByteArrayLiteral("underscan hborder")), + PropertyDefinition(QByteArrayLiteral("underscan vborder"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("underscan hborder"), Requirement::Optional), }, DRM_MODE_OBJECT_CONNECTOR) , m_conn(drmModeGetConnector(gpu->fd(), connectorId)) { diff --git a/src/plugins/platforms/drm/drm_object_crtc.cpp b/src/plugins/platforms/drm/drm_object_crtc.cpp index f810c04455..64ce864989 100644 --- a/src/plugins/platforms/drm/drm_object_crtc.cpp +++ b/src/plugins/platforms/drm/drm_object_crtc.cpp @@ -19,10 +19,10 @@ namespace KWin DrmCrtc::DrmCrtc(DrmGpu *gpu, uint32_t crtcId, int pipeIndex) : DrmObject(gpu, crtcId, { - PropertyDefinition(QByteArrayLiteral("MODE_ID")), - PropertyDefinition(QByteArrayLiteral("ACTIVE")), - PropertyDefinition(QByteArrayLiteral("VRR_ENABLED")), - PropertyDefinition(QByteArrayLiteral("GAMMA_LUT")), + PropertyDefinition(QByteArrayLiteral("MODE_ID"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("ACTIVE"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("VRR_ENABLED"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("GAMMA_LUT"), Requirement::Optional), }, DRM_MODE_OBJECT_CRTC) , m_crtc(drmModeGetCrtc(gpu->fd(), crtcId)) , m_pipeIndex(pipeIndex) diff --git a/src/plugins/platforms/drm/drm_object_plane.cpp b/src/plugins/platforms/drm/drm_object_plane.cpp index c2962e2e67..e5f3763690 100644 --- a/src/plugins/platforms/drm/drm_object_plane.cpp +++ b/src/plugins/platforms/drm/drm_object_plane.cpp @@ -20,28 +20,28 @@ namespace KWin DrmPlane::DrmPlane(DrmGpu *gpu, uint32_t planeId) : DrmObject(gpu, planeId, { - PropertyDefinition(QByteArrayLiteral("type"), { + PropertyDefinition(QByteArrayLiteral("type"), Requirement::Required, { QByteArrayLiteral("Overlay"), QByteArrayLiteral("Primary"), QByteArrayLiteral("Cursor")}), - PropertyDefinition(QByteArrayLiteral("SRC_X")), - PropertyDefinition(QByteArrayLiteral("SRC_Y")), - PropertyDefinition(QByteArrayLiteral("SRC_W")), - PropertyDefinition(QByteArrayLiteral("SRC_H")), - PropertyDefinition(QByteArrayLiteral("CRTC_X")), - PropertyDefinition(QByteArrayLiteral("CRTC_Y")), - PropertyDefinition(QByteArrayLiteral("CRTC_W")), - PropertyDefinition(QByteArrayLiteral("CRTC_H")), - PropertyDefinition(QByteArrayLiteral("FB_ID")), - PropertyDefinition(QByteArrayLiteral("CRTC_ID")), - PropertyDefinition(QByteArrayLiteral("rotation"), { + PropertyDefinition(QByteArrayLiteral("SRC_X"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("SRC_Y"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("SRC_W"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("SRC_H"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("CRTC_X"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("CRTC_Y"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("CRTC_W"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("CRTC_H"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("FB_ID"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("CRTC_ID"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("rotation"), Requirement::Optional, { QByteArrayLiteral("rotate-0"), QByteArrayLiteral("rotate-90"), QByteArrayLiteral("rotate-180"), QByteArrayLiteral("rotate-270"), QByteArrayLiteral("reflect-x"), QByteArrayLiteral("reflect-y")}), - PropertyDefinition(QByteArrayLiteral("IN_FORMATS")), + PropertyDefinition(QByteArrayLiteral("IN_FORMATS"), Requirement::Optional), }, DRM_MODE_OBJECT_PLANE) { }