platforms/drm: directly check for required properties
Instead of crashing because a nullptr property gets accessed, use an explicit error message and ignore the offending object. This also acts as documentation
This commit is contained in:
parent
5a1b98d148
commit
0054d825c4
5 changed files with 41 additions and 28 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -175,13 +175,20 @@ public:
|
|||
virtual bool updateProperties();
|
||||
|
||||
protected:
|
||||
enum class Requirement {
|
||||
Required,
|
||||
Optional
|
||||
};
|
||||
struct PropertyDefinition
|
||||
{
|
||||
PropertyDefinition(const QByteArray &name, const QVector<QByteArray> &&enumNames = {})
|
||||
: name(name), enumNames(enumNames)
|
||||
PropertyDefinition(const QByteArray &name, Requirement requirement, const QVector<QByteArray> &&enumNames = {})
|
||||
: name(name)
|
||||
, requirement(requirement)
|
||||
, enumNames(enumNames)
|
||||
{
|
||||
}
|
||||
QByteArray name;
|
||||
Requirement requirement;
|
||||
QVector<QByteArray> enumNames;
|
||||
};
|
||||
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue