backend-drm: Add zpos DRM-property
authorMarius Vlad <marius.vlad@collabora.com>
Thu, 29 Aug 2019 17:42:00 +0000 (20:42 +0300)
committerDaniel Stone <daniels@collabora.com>
Mon, 11 Nov 2019 16:51:48 +0000 (16:51 +0000)
Functional no change, as nobody makes use of it. Only apply the zpos
value if the zpos property is mutable (that is, zpos_max and zpos_min
are not the same).

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
libweston/backend-drm/drm-internal.h
libweston/backend-drm/drm.c
libweston/backend-drm/kms.c
libweston/backend-drm/state-helpers.c

index 29b68e38c2127f4a5e648036aa09b6c4aad02485..2bd5b3479abd8076a8a14d15690723f9671c9fc0 100644 (file)
 #define GBM_BO_USE_LINEAR (1 << 4)
 #endif
 
+#ifndef DRM_PLANE_ZPOS_INVALID_PLANE
+#define DRM_PLANE_ZPOS_INVALID_PLANE   0xffffffffffffffffULL
+#endif
+
 /**
  * A small wrapper to print information into the 'drm-backend' debug scope.
  *
@@ -169,6 +173,7 @@ enum wdrm_plane_property {
        WDRM_PLANE_IN_FORMATS,
        WDRM_PLANE_IN_FENCE_FD,
        WDRM_PLANE_FB_DAMAGE_CLIPS,
+       WDRM_PLANE_ZPOS,
        WDRM_PLANE__COUNT
 };
 
@@ -385,6 +390,8 @@ struct drm_plane_state {
        int32_t dest_x, dest_y;
        uint32_t dest_w, dest_h;
 
+       uint64_t zpos;
+
        bool complete;
 
        /* We don't own the fd, so we shouldn't close it */
@@ -426,6 +433,9 @@ struct drm_plane {
        /* The last state submitted to the kernel for this plane. */
        struct drm_plane_state *state_cur;
 
+       uint64_t zpos_min;
+       uint64_t zpos_max;
+
        struct wl_list link;
 
        struct {
index 878d71ec3d6f797f813bafdc0a7d58d3899cb1ca..dd579e3ca824ee73a87a5dda063c6da0ba8a63ff 100644 (file)
@@ -680,6 +680,7 @@ drm_plane_create(struct drm_backend *b, const drmModePlane *kplane,
 {
        struct drm_plane *plane;
        drmModeObjectProperties *props;
+       uint64_t *zpos_range_values;
        uint32_t num_formats = (kplane) ? kplane->count_formats : 1;
 
        plane = zalloc(sizeof(*plane) +
@@ -711,6 +712,18 @@ drm_plane_create(struct drm_backend *b, const drmModePlane *kplane,
                                               props,
                                               WDRM_PLANE_TYPE__COUNT);
 
+               zpos_range_values =
+                       drm_property_get_range_values(&plane->props[WDRM_PLANE_ZPOS], 
+                                                     props);
+
+               if (zpos_range_values) {
+                       plane->zpos_min = zpos_range_values[0];
+                       plane->zpos_max = zpos_range_values[1];
+               } else {
+                       plane->zpos_min = DRM_PLANE_ZPOS_INVALID_PLANE;
+                       plane->zpos_max = DRM_PLANE_ZPOS_INVALID_PLANE;
+               }
+
                if (drm_plane_populate_formats(plane, kplane, props) < 0) {
                        drmModeFreeObjectProperties(props);
                        goto err;
@@ -724,6 +737,8 @@ drm_plane_create(struct drm_backend *b, const drmModePlane *kplane,
                plane->count_formats = 1;
                plane->formats[0].format = format;
                plane->type = type;
+               plane->zpos_max = DRM_PLANE_ZPOS_INVALID_PLANE;
+               plane->zpos_min = DRM_PLANE_ZPOS_INVALID_PLANE;
        }
 
        if (plane->type == WDRM_PLANE_TYPE__COUNT)
index 4cb242d3adfe7481223dbf7c4dc64d594629eed3..5468afb36a095f12e5e9f7325b6f805bc5941af1 100644 (file)
@@ -77,6 +77,7 @@ const struct drm_property_info plane_props[] = {
        [WDRM_PLANE_IN_FORMATS] = { .name = "IN_FORMATS" },
        [WDRM_PLANE_IN_FENCE_FD] = { .name = "IN_FENCE_FD" },
        [WDRM_PLANE_FB_DAMAGE_CLIPS] = { .name = "FB_DAMAGE_CLIPS" },
+       [WDRM_PLANE_ZPOS] = { .name = "zpos" },
 };
 
 struct drm_property_enum_info dpms_state_enums[] = {
@@ -1050,6 +1051,13 @@ drm_output_apply_state_atomic(struct drm_output_state *state,
                                              plane_state->in_fence_fd);
                }
 
+               /* do note, that 'invented' zpos values are set as immutable */
+               if (plane_state->zpos != DRM_PLANE_ZPOS_INVALID_PLANE &&
+                   plane_state->plane->zpos_min != plane_state->plane->zpos_max)
+                       ret |= plane_add_prop(req, plane,
+                                             WDRM_PLANE_ZPOS,
+                                             plane_state->zpos);
+
                if (ret != 0) {
                        weston_log("couldn't set plane state\n");
                        return ret;
index 3956960c8e11f4ebc07dd3d56975c9b1358337af..79b800e77d5ec87a5f3c645f75da26bfc1676855 100644 (file)
@@ -48,6 +48,7 @@ drm_plane_state_alloc(struct drm_output_state *state_output,
        state->output_state = state_output;
        state->plane = plane;
        state->in_fence_fd = -1;
+       state->zpos = DRM_PLANE_ZPOS_INVALID_PLANE;
        pixman_region32_init(&state->damage);
 
        /* Here we only add the plane state to the desired link, and not
@@ -80,6 +81,7 @@ drm_plane_state_free(struct drm_plane_state *state, bool force)
        wl_list_init(&state->link);
        state->output_state = NULL;
        state->in_fence_fd = -1;
+       state->zpos = DRM_PLANE_ZPOS_INVALID_PLANE;
        pixman_region32_fini(&state->damage);
 
        if (force || state != state->plane->state_cur) {