From patchwork Wed Jan 3 09:16:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 10141887 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C5B51601A1 for ; Wed, 3 Jan 2018 09:16:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB3E928F49 for ; Wed, 3 Jan 2018 09:16:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F29928F71; Wed, 3 Jan 2018 09:16:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A754228F49 for ; Wed, 3 Jan 2018 09:16:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2498C89381; Wed, 3 Jan 2018 09:16:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 75D5F89381 for ; Wed, 3 Jan 2018 09:16:35 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id w039Fx8G029801; Wed, 3 Jan 2018 03:15:59 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1514970959; bh=rfH/yUiXsmDisdRj0H757lFdyewYzGkYnWGxok3/H+c=; h=From:To:CC:Subject:Date; b=xOWgZEXR4PgYGWJHiCZQ+MzzFG52SfE+GHMNmYDqvvQRxX/LpVf8eGNI+xaBWlbWd SZln34VMJTqU2nNBKASaX9v8lTrtEvvyDTLjJPr2ppTxc6DgYIJb13Rjjq6Gu8L61r 8xYnxollxGYr+KheQnnLkM3zXTwgHvqrrTkUE8Og= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w039Fx7R026849; Wed, 3 Jan 2018 03:15:59 -0600 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Wed, 3 Jan 2018 03:15:59 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Wed, 3 Jan 2018 03:15:59 -0600 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w039FvxS015274; Wed, 3 Jan 2018 03:15:57 -0600 From: Peter Ujfalusi To: , Subject: [PATCH v2] drm/omap: plane zpos/zorder management improvements Date: Wed, 3 Jan 2018 11:16:04 +0200 Message-ID: <20180103091604.11099-1-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.15.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: jsarha@ti.com, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;