dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: tomi.valkeinen@ti.com, laurent.pinchart@ideasonboard.com
Cc: jsarha@ti.com, dri-devel@lists.freedesktop.org
Subject: [PATCH v2] drm/omap: plane zpos/zorder management improvements
Date: Wed, 3 Jan 2018 11:16:04 +0200	[thread overview]
Message-ID: <20180103091604.11099-1-peter.ujfalusi@ti.com> (raw)

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@ti.com>
---
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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

             reply	other threads:[~2018-01-03  9:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-03  9:16 Peter Ujfalusi [this message]
2018-01-04 10:17 ` [PATCH v2] drm/omap: plane zpos/zorder management improvements Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180103091604.11099-1-peter.ujfalusi@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jsarha@ti.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).