From e83e75018301d7b8e574054af5db33f4f74934eb Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Tue, 29 Oct 2019 17:29:37 +0200 Subject: [PATCH] backend-drm: Hard-code zpos values if HW doesn't exposes them This is based on the assumption that overlays are in between cursor and primary plane and it is required to be able to assign views to planes, even if the driver doesn't not expose such property. As we hard-code them as immutable the commit part would not need any further modifications. Signed-off-by: Marius Vlad Suggested-by: Daniel Stone --- libweston/backend-drm/drm.c | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index dd579e3c..33ccbeb3 100644 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -68,6 +68,61 @@ static const char default_seat[] = "seat0"; +static void +drm_backend_create_faked_zpos(struct drm_backend *b) +{ + struct drm_plane *plane; + uint64_t zpos = 0ULL; + uint64_t zpos_min_primary; + uint64_t zpos_min_overlay; + uint64_t zpos_min_cursor; + + zpos_min_primary = zpos; + wl_list_for_each(plane, &b->plane_list, link) { + /* if the property is there, bail out sooner */ + if (plane->props[WDRM_PLANE_ZPOS].prop_id != 0) + return; + + if (plane->type != WDRM_PLANE_TYPE_PRIMARY) + continue; + zpos++; + } + + zpos_min_overlay = zpos; + wl_list_for_each(plane, &b->plane_list, link) { + if (plane->type != WDRM_PLANE_TYPE_OVERLAY) + continue; + zpos++; + } + + zpos_min_cursor = zpos; + wl_list_for_each(plane, &b->plane_list, link) { + if (plane->type != WDRM_PLANE_TYPE_CURSOR) + continue; + zpos++; + } + + drm_debug(b, "[drm-backend] zpos property not found. " + "Using invented immutable zpos values:\n"); + /* assume that invented zpos values are immutable */ + wl_list_for_each(plane, &b->plane_list, link) { + if (plane->type == WDRM_PLANE_TYPE_PRIMARY) { + plane->zpos_min = zpos_min_primary; + plane->zpos_max = zpos_min_primary; + } else if (plane->type == WDRM_PLANE_TYPE_OVERLAY) { + plane->zpos_min = zpos_min_overlay; + plane->zpos_max = zpos_min_overlay; + } else if (plane->type == WDRM_PLANE_TYPE_CURSOR) { + plane->zpos_min = zpos_min_cursor; + plane->zpos_max = zpos_min_cursor; + } + drm_debug(b, "\t[plane] %s plane %d, zpos_min %"PRIu64", " + "zpos_max %"PRIu64"\n", + drm_output_get_plane_type_name(plane), + plane->plane_id, plane->zpos_min, plane->zpos_max); + } +} + static void wl_array_remove_uint32(struct wl_array *array, uint32_t elm) { @@ -2856,6 +2911,9 @@ drm_backend_create(struct weston_compositor *compositor, goto err_udev_input; } + /* 'compute' faked zpos values in case HW doesn't expose any */ + drm_backend_create_faked_zpos(b); + /* A this point we have some idea of whether or not we have a working * cursor plane. */ if (!b->cursors_are_broken)