From 99b6f6150d0422b224d62314dbc38a2816b1b26b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Fri, 3 Nov 2017 18:35:13 +0100 Subject: [PATCH] [platforms/drm] Determine the supported transformation on a plane Summary: The idea behind getting the supported transformations is to tell KScreen which transformations are actually supported and thus not even allow the user select a setting which is not supported. Reviewers: #kwin, #plasma, subdiff Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D8645 --- plugins/platforms/drm/drm_object.cpp | 2 +- plugins/platforms/drm/drm_object.h | 7 +++++++ plugins/platforms/drm/drm_object_plane.cpp | 24 ++++++++++++++++++++++ plugins/platforms/drm/drm_object_plane.h | 2 ++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/plugins/platforms/drm/drm_object.cpp b/plugins/platforms/drm/drm_object.cpp index 579b06b83f..79a473caa0 100644 --- a/plugins/platforms/drm/drm_object.cpp +++ b/plugins/platforms/drm/drm_object.cpp @@ -102,7 +102,7 @@ DrmObject::Property::~Property() = default; void DrmObject::Property::initEnumMap(drmModePropertyRes *prop) { - if (!(prop->flags & DRM_MODE_PROP_ENUM) || prop->count_enums < 1) { + if (!((prop->flags & DRM_MODE_PROP_ENUM) || (prop->flags & DRM_MODE_PROP_BITMASK)) || prop->count_enums < 1) { qCWarning(KWIN_DRM) << "Property '" << prop->name << "' ( id =" << m_propId << ") should be enum valued, but it is not."; return; diff --git a/plugins/platforms/drm/drm_object.h b/plugins/platforms/drm/drm_object.h index 6c46a6bcf7..49ab7207fb 100644 --- a/plugins/platforms/drm/drm_object.h +++ b/plugins/platforms/drm/drm_object.h @@ -61,6 +61,10 @@ public: return m_props[prop]->value(); } + bool propHasEnum(int prop, uint64_t value) const { + return m_props[prop]->hasEnum(value); + } + void setValue(int prop, uint64_t new_value) { Q_ASSERT(prop < m_props.size()); @@ -94,6 +98,9 @@ protected: uint64_t enumMap(int n) { return m_enumMap[n]; // TODO: test on index out of bounds? } + bool hasEnum(uint64_t value) const { + return m_enumMap.contains(value); + } uint32_t propId() { return m_propId; diff --git a/plugins/platforms/drm/drm_object_plane.cpp b/plugins/platforms/drm/drm_object_plane.cpp index 05ec849d30..6899769709 100644 --- a/plugins/platforms/drm/drm_object_plane.cpp +++ b/plugins/platforms/drm/drm_object_plane.cpp @@ -84,6 +84,15 @@ bool DrmPlane::initProps() QByteArrayLiteral("Overlay"), }; + const QVector rotationNames{ + QByteArrayLiteral("rotate-0"), + QByteArrayLiteral("rotate-90"), + QByteArrayLiteral("rotate-180"), + QByteArrayLiteral("rotate-270"), + QByteArrayLiteral("reflect-x"), + QByteArrayLiteral("reflect-y") + }; + drmModeObjectProperties *properties = drmModeObjectGetProperties(m_backend->fd(), m_id, DRM_MODE_OBJECT_PLANE); if (!properties){ qCWarning(KWIN_DRM) << "Failed to get properties for plane " << m_id ; @@ -94,6 +103,21 @@ bool DrmPlane::initProps() for (int j = 0; j < propCount; ++j) { if (j == int(PropertyIndex::Type)) { initProp(j, properties, typeNames); + } else if (j == int(PropertyIndex::Rotation)) { + initProp(j, properties, rotationNames); + m_supportedTransformations = Transformations(); + auto testTransform = [j, this] (uint64_t value, Transformation t) { + if (propHasEnum(j, value)) { + m_supportedTransformations |= t; + } + }; + testTransform(0, Transformation::Rotate0); + testTransform(1, Transformation::Rotate90); + testTransform(2, Transformation::Rotate180); + testTransform(3, Transformation::Rotate270); + testTransform(4, Transformation::ReflectX); + testTransform(5, Transformation::ReflectY); + qCDebug(KWIN_DRM) << "Supported Transformations: " << m_supportedTransformations << " on plane " << m_id; } else { initProp(j, properties); } diff --git a/plugins/platforms/drm/drm_object_plane.h b/plugins/platforms/drm/drm_object_plane.h index 46e468b6f0..18e74bfaa6 100644 --- a/plugins/platforms/drm/drm_object_plane.h +++ b/plugins/platforms/drm/drm_object_plane.h @@ -106,6 +106,8 @@ private: // TODO: when using overlay planes in the future: restrict possible screens / crtcs of planes uint32_t m_possibleCrtcs; + + Transformations m_supportedTransformations = Transformation::Rotate0; }; }