Use the plane index as default zpos for all planes. Even if the application is not setting zpos/zorder explicitly we will have unique zpos for each plane. Enforce that all planes must have unique zpos by refusing atomic update for planes with already used zpos. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@xxxxxx> --- Hi, changes since v1: - Dropped the zpos normalization related patches - New patch based on the discussion, see commit message. Regards, Peter drivers/gpu/drm/omapdrm/omap_plane.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 15e5d5d325c6..6aeda3cc2f8b 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -33,6 +33,7 @@ struct omap_plane { struct drm_plane base; enum omap_plane_id id; + int idx; const char *name; }; @@ -99,8 +100,7 @@ static void omap_plane_atomic_disable(struct drm_plane *plane, struct omap_plane *omap_plane = to_omap_plane(plane); plane->state->rotation = DRM_MODE_ROTATE_0; - plane->state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY - ? 0 : omap_plane->id; + plane->state->zpos = omap_plane->idx; priv->dispc_ops->ovl_enable(omap_plane->id, false); } @@ -109,15 +109,17 @@ static int omap_plane_atomic_check(struct drm_plane *plane, struct drm_plane_state *state) { struct drm_crtc_state *crtc_state; + struct drm_crtc *crtc = state->crtc; + struct drm_plane *p; if (!state->fb) return 0; /* crtc should only be NULL when disabling (i.e., !state->fb) */ - if (WARN_ON(!state->crtc)) + if (WARN_ON(!crtc)) return 0; - crtc_state = drm_atomic_get_existing_crtc_state(state->state, state->crtc); + crtc_state = drm_atomic_get_existing_crtc_state(state->state, crtc); /* we should have a crtc state if the plane is attached to a crtc */ if (WARN_ON(!crtc_state)) return 0; @@ -125,6 +127,16 @@ static int omap_plane_atomic_check(struct drm_plane *plane, if (!crtc_state->enable) return 0; + drm_for_each_plane_mask(p, crtc->dev, crtc->state->plane_mask) { + if (plane->base.id == p->base.id) + continue; + + if (p->state->zpos == state->zpos) { + DBG("zpos must be unique (zpos: %u)", state->zpos); + return -EINVAL; + } + } + if (state->crtc_x < 0 || state->crtc_y < 0) return -EINVAL; @@ -196,8 +208,7 @@ static void omap_plane_reset(struct drm_plane *plane) * Set the zpos default depending on whether we are a primary or overlay * plane. */ - plane->state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY - ? 0 : omap_plane->id; + plane->state->zpos = omap_plane->idx; } static int omap_plane_atomic_set_property(struct drm_plane *plane, @@ -284,6 +295,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, for (nformats = 0; formats[nformats]; ++nformats) ; omap_plane->id = id; + omap_plane->idx = idx; omap_plane->name = plane_id_to_name[id]; plane = &omap_plane->base; @@ -297,7 +309,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev, drm_plane_helper_add(plane, &omap_plane_helper_funcs); omap_plane_install_properties(plane, &plane->base); - drm_plane_create_zpos_property(plane, 0, 0, num_planes - 1); + drm_plane_create_zpos_property(plane, idx, 0, num_planes - 1); return plane; -- Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel