platforms/drm: add a method for setting legacy properties
This commit is contained in:
parent
e88f2501bf
commit
15da95149d
3 changed files with 22 additions and 15 deletions
|
@ -164,7 +164,7 @@ bool DrmObject::updateProperties()
|
|||
m_props[propIndex]->setCurrent(properties->prop_values[drmPropIndex]);
|
||||
}
|
||||
} else {
|
||||
m_props[propIndex] = new Property(m_gpu, prop.data(), properties->prop_values[drmPropIndex], def.enumNames, blob);
|
||||
m_props[propIndex] = new Property(this, prop.data(), properties->prop_values[drmPropIndex], def.enumNames, blob);
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
|
@ -187,7 +187,7 @@ bool DrmObject::updateProperties()
|
|||
* Definitions for DrmObject::Property
|
||||
*/
|
||||
|
||||
DrmObject::Property::Property(DrmGpu *gpu, drmModePropertyRes *prop, uint64_t val, const QVector<QByteArray> &enumNames, drmModePropertyBlobRes *blob)
|
||||
DrmObject::Property::Property(DrmObject *obj, drmModePropertyRes *prop, uint64_t val, const QVector<QByteArray> &enumNames, drmModePropertyBlobRes *blob)
|
||||
: m_propId(prop->prop_id)
|
||||
, m_propName(prop->name)
|
||||
, m_pending(val)
|
||||
|
@ -197,7 +197,7 @@ DrmObject::Property::Property(DrmGpu *gpu, drmModePropertyRes *prop, uint64_t va
|
|||
, m_current(val)
|
||||
, m_currentBlob(blob)
|
||||
, m_immutable(prop->flags & DRM_MODE_PROP_IMMUTABLE)
|
||||
, m_gpu(gpu)
|
||||
, m_obj(obj)
|
||||
{
|
||||
if (!enumNames.isEmpty()) {
|
||||
m_enumNames = enumNames;
|
||||
|
@ -227,17 +227,17 @@ bool DrmObject::Property::setPendingBlob(void *blob, size_t length)
|
|||
}
|
||||
uint32_t id = 0;
|
||||
if (blob != nullptr) {
|
||||
if (drmModeCreatePropertyBlob(m_gpu->fd(), blob, length, &id) != 0) {
|
||||
if (drmModeCreatePropertyBlob(m_obj->m_gpu->fd(), blob, length, &id) != 0) {
|
||||
qCWarning(KWIN_DRM) << "Creating property blob failed!" << strerror(errno);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (m_pending && m_pending != m_current && m_pending != m_next) {
|
||||
drmModeDestroyPropertyBlob(m_gpu->fd(), m_pending);
|
||||
drmModeDestroyPropertyBlob(m_obj->m_gpu->fd(), m_pending);
|
||||
drmModeFreePropertyBlob(m_pendingBlob);
|
||||
}
|
||||
m_pending = id;
|
||||
m_pendingBlob = drmModeGetPropertyBlob(m_gpu->fd(), m_pending);
|
||||
m_pendingBlob = drmModeGetPropertyBlob(m_obj->m_gpu->fd(), m_pending);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -274,15 +274,15 @@ void DrmObject::Property::setCurrentBlob(drmModePropertyBlobRes *blob)
|
|||
if (!blob && m_next == m_current) {
|
||||
// same as above, for the "next" blob
|
||||
uint32_t id = 0;
|
||||
if (drmModeCreatePropertyBlob(m_gpu->fd(), m_currentBlob->data, m_currentBlob->length, &id) != 0) {
|
||||
if (drmModeCreatePropertyBlob(m_obj->m_gpu->fd(), m_currentBlob->data, m_currentBlob->length, &id) != 0) {
|
||||
qCWarning(KWIN_DRM) << "Creating property blob failed!" << strerror(errno);
|
||||
}
|
||||
m_next = id;
|
||||
m_nextBlob = drmModeGetPropertyBlob(m_gpu->fd(), id);
|
||||
m_nextBlob = drmModeGetPropertyBlob(m_obj->m_gpu->fd(), id);
|
||||
}
|
||||
uint32_t blobId = blob ? blob->id : 0;
|
||||
if (m_current && m_current != m_pending && m_current != m_next && m_current != blobId) {
|
||||
drmModeDestroyPropertyBlob(m_gpu->fd(), m_current);
|
||||
drmModeDestroyPropertyBlob(m_obj->m_gpu->fd(), m_current);
|
||||
drmModeFreePropertyBlob(m_currentBlob);
|
||||
}
|
||||
m_currentBlob = blob;
|
||||
|
@ -313,7 +313,7 @@ void DrmObject::Property::commitPending()
|
|||
}
|
||||
if (m_pendingBlob || m_nextBlob) {
|
||||
if (m_next && m_next != m_current) {
|
||||
drmModeDestroyPropertyBlob(m_gpu->fd(), m_next);
|
||||
drmModeDestroyPropertyBlob(m_obj->m_gpu->fd(), m_next);
|
||||
drmModeFreePropertyBlob(m_nextBlob);
|
||||
}
|
||||
m_next = m_pending;
|
||||
|
@ -330,7 +330,7 @@ void DrmObject::Property::rollbackPending()
|
|||
}
|
||||
if (m_pendingBlob || m_nextBlob) {
|
||||
if (m_pending && m_pending != m_current) {
|
||||
drmModeDestroyPropertyBlob(m_gpu->fd(), m_pending);
|
||||
drmModeDestroyPropertyBlob(m_obj->m_gpu->fd(), m_pending);
|
||||
drmModeFreePropertyBlob(m_pendingBlob);
|
||||
}
|
||||
m_pending = m_next;
|
||||
|
@ -345,6 +345,11 @@ bool DrmObject::Property::needsCommit() const
|
|||
return m_pending != m_current;
|
||||
}
|
||||
|
||||
bool DrmObject::Property::setPropertyLegacy(uint64_t value)
|
||||
{
|
||||
return drmModeObjectSetProperty(m_obj->m_gpu->fd(), m_obj->id(), m_obj->m_objectType, m_propId, value) == 0;
|
||||
}
|
||||
|
||||
void DrmObject::Property::initEnumMap(drmModePropertyRes *prop)
|
||||
{
|
||||
if ( ( !(prop->flags & DRM_MODE_PROP_ENUM) && !(prop->flags & DRM_MODE_PROP_BITMASK) )
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
class Property
|
||||
{
|
||||
public:
|
||||
Property(DrmGpu *gpu, drmModePropertyRes *prop, uint64_t val, const QVector<QByteArray> &enumNames, drmModePropertyBlobRes *blob);
|
||||
Property(DrmObject *obj, drmModePropertyRes *prop, uint64_t val, const QVector<QByteArray> &enumNames, drmModePropertyBlobRes *blob);
|
||||
virtual ~Property();
|
||||
|
||||
void initEnumMap(drmModePropertyRes *prop);
|
||||
|
@ -140,6 +140,8 @@ public:
|
|||
void rollbackPending();
|
||||
bool needsCommit() const;
|
||||
|
||||
bool setPropertyLegacy(uint64_t value);
|
||||
|
||||
private:
|
||||
uint32_t m_propId = 0;
|
||||
QByteArray m_propName;
|
||||
|
@ -160,7 +162,7 @@ public:
|
|||
QVector<QByteArray> m_enumNames;
|
||||
const bool m_immutable;
|
||||
bool m_legacy = false;
|
||||
const DrmGpu *m_gpu;
|
||||
const DrmObject *m_obj;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -366,7 +366,7 @@ bool DrmPipeline::setActive(bool active)
|
|||
if (!dpmsProp) {
|
||||
qCWarning(KWIN_DRM) << "Setting active failed: dpms property missing!";
|
||||
} else {
|
||||
success = drmModeConnectorSetProperty(m_gpu->fd(), m_connector->id(), dpmsProp->propId(), active ? DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF) == 0;
|
||||
success = dpmsProp->setPropertyLegacy(active ? DRM_MODE_DPMS_ON : DRM_MODE_DPMS_OFF);
|
||||
}
|
||||
}
|
||||
if (!success) {
|
||||
|
@ -446,7 +446,7 @@ bool DrmPipeline::setSyncMode(RenderLoopPrivate::SyncMode syncMode)
|
|||
vrrProp->setPending(vrr);
|
||||
return test();
|
||||
} else {
|
||||
return drmModeObjectSetProperty(m_gpu->fd(), m_crtc->id(), DRM_MODE_OBJECT_CRTC, vrrProp->propId(), vrr) == 0;
|
||||
return vrrProp->setPropertyLegacy(vrr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue