From patchwork Sat May 26 17:25:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 10429165 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 8F8D460249 for ; Sat, 26 May 2018 17:30:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E15628C9A for ; Sat, 26 May 2018 17:30:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EB5D28EB5; Sat, 26 May 2018 17:30:02 +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=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 0927728C9A for ; Sat, 26 May 2018 17:30:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD0236EB2B; Sat, 26 May 2018 17:26:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC2966E41D for ; Sat, 26 May 2018 17:26:06 +0000 (UTC) Received: from avalon.bb.dnainternet.fi (unknown [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 671601C7C; Sat, 26 May 2018 19:25:42 +0200 (CEST) From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 49/60] drm/omap: Create all planes before CRTCs Date: Sat, 26 May 2018 20:25:07 +0300 Message-Id: <20180526172518.18710-50-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180526172518.18710-1-laurent.pinchart@ideasonboard.com> References: <20180526172518.18710-1-laurent.pinchart@ideasonboard.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomi Valkeinen MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Creating all the planes in a single location instead of creating them per-CRTC with remaining planes then created in a second step simplifies the logic. Signed-off-by: Laurent Pinchart Reviewed-by: Sebastian Reichel --- drivers/gpu/drm/omapdrm/omap_drv.c | 45 ++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 0d4c3e2db058..99ed47a17ce3 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -271,14 +271,30 @@ static int omap_modeset_init(struct drm_device *dev) return -EINVAL; } - /* All planes can be put to any CRTC */ + /* Create all planes first. They can all be put to any CRTC. */ plane_crtc_mask = (1 << num_crtcs) - 1; + for (i = 0; i < num_ovls; i++) { + enum drm_plane_type type = i < priv->num_dssdevs + ? DRM_PLANE_TYPE_PRIMARY + : DRM_PLANE_TYPE_OVERLAY; + struct drm_plane *plane; + + if (WARN_ON(priv->num_planes >= ARRAY_SIZE(priv->planes))) + return -EINVAL; + + plane = omap_plane_init(dev, i, type, plane_crtc_mask); + if (IS_ERR(plane)) + return PTR_ERR(plane); + + priv->planes[priv->num_planes++] = plane; + } + + /* Create the CRTCs, encoders and connectors. */ for (i = 0; i < priv->num_dssdevs; i++) { struct omap_dss_device *dssdev = priv->dssdevs[i]; struct drm_connector *connector; struct drm_encoder *encoder; - struct drm_plane *plane; struct drm_crtc *crtc; encoder = omap_encoder_init(dev, dssdev); @@ -290,12 +306,7 @@ static int omap_modeset_init(struct drm_device *dev) if (!connector) return -ENOMEM; - plane = omap_plane_init(dev, i, DRM_PLANE_TYPE_PRIMARY, - plane_crtc_mask); - if (IS_ERR(plane)) - return PTR_ERR(plane); - - crtc = omap_crtc_init(dev, plane, dssdev); + crtc = omap_crtc_init(dev, priv->planes[i], dssdev); if (IS_ERR(crtc)) return PTR_ERR(crtc); @@ -303,28 +314,10 @@ static int omap_modeset_init(struct drm_device *dev) encoder->possible_crtcs = 1 << i; priv->crtcs[priv->num_crtcs++] = crtc; - priv->planes[priv->num_planes++] = plane; priv->encoders[priv->num_encoders++] = encoder; priv->connectors[priv->num_connectors++] = connector; } - /* - * Create normal planes for the remaining overlays: - */ - for (; i < num_ovls; i++) { - struct drm_plane *plane; - - if (WARN_ON(priv->num_planes >= ARRAY_SIZE(priv->planes))) - return -EINVAL; - - plane = omap_plane_init(dev, i, DRM_PLANE_TYPE_OVERLAY, - plane_crtc_mask); - if (IS_ERR(plane)) - return PTR_ERR(plane); - - priv->planes[priv->num_planes++] = plane; - } - DBG("registered %d planes, %d crtcs, %d encoders and %d connectors\n", priv->num_planes, priv->num_crtcs, priv->num_encoders, priv->num_connectors);