drm_atomic: do not set immutable properties

On some platforms the ZPOS property might exist, but be immutable.
This is at least the case on Intel Sandy Bridge since Linux kernel
5.5.0. Trying to set an immutable property will cause.
drmModeAtomicCommit to fail with -EINVAL.

On other platforms we might want to set ZPOS to tweak the layering of
planes.

To reconcile these two, simply have drm_object_set_property check if a
property is immutable before attempting to add it to the atomic
commit, instead returning an error code (which is, as previously,
ignored in the case of ZPOS as we don't strictly need it)
This commit is contained in:
Anton Kindestam 2020-02-02 16:27:54 +01:00 committed by Jan Ekström
parent f304a79935
commit 19e5155147
1 changed files with 6 additions and 1 deletions

View File

@ -94,6 +94,11 @@ int drm_object_set_property(drmModeAtomicReq *request, struct drm_object *object
{ {
for (int i = 0; i < object->props->count_props; i++) { for (int i = 0; i < object->props->count_props; i++) {
if (strcasecmp(name, object->props_info[i]->name) == 0) { if (strcasecmp(name, object->props_info[i]->name) == 0) {
if (object->props_info[i]->flags & DRM_MODE_PROP_IMMUTABLE) {
/* Do not try to set immutable values, as this might cause the
* atomic commit operation to fail. */
return -EINVAL;
}
return drmModeAtomicAddProperty(request, object->id, return drmModeAtomicAddProperty(request, object->id,
object->props_info[i]->prop_id, value); object->props_info[i]->prop_id, value);
} }
@ -362,7 +367,7 @@ static bool drm_atomic_restore_plane_state(drmModeAtomicReq *request,
ret = false; ret = false;
if (0 > drm_object_set_property(request, plane, "CRTC_H", plane_state->crtc_h)) if (0 > drm_object_set_property(request, plane, "CRTC_H", plane_state->crtc_h))
ret = false; ret = false;
// ZPOS might not exist, so ignore whether or not this succeeds // ZPOS might not exist, or be immutable, so ignore whether or not this succeeds
drm_object_set_property(request, plane, "ZPOS", plane_state->zpos); drm_object_set_property(request, plane, "ZPOS", plane_state->zpos);
return ret; return ret;