[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
This commit is contained in:
Martin Flöser 2017-11-03 18:35:13 +01:00
parent 59f7ed9c78
commit 99b6f6150d
4 changed files with 34 additions and 1 deletions

View file

@ -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;

View file

@ -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;

View file

@ -84,6 +84,15 @@ bool DrmPlane::initProps()
QByteArrayLiteral("Overlay"),
};
const QVector<QByteArray> 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);
}

View file

@ -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;
};
}