From patchwork Thu Feb 23 08:05:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 9589217 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 3F88D6042D for ; Fri, 24 Feb 2017 00:37:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AEA728752 for ; Fri, 24 Feb 2017 00:37:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F379328774; Fri, 24 Feb 2017 00:37:11 +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.2 required=2.0 tests=BAYES_00, 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 A13A828752 for ; Fri, 24 Feb 2017 00:37:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 514E26EB62; Fri, 24 Feb 2017 00:37:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from wens.csie.org (mirror2.csie.ntu.edu.tw [140.112.30.76]) by gabe.freedesktop.org (Postfix) with ESMTPS id B08726E994 for ; Thu, 23 Feb 2017 08:05:53 +0000 (UTC) Received: by wens.csie.org (Postfix, from userid 1000) id 5AA355FD2E; Thu, 23 Feb 2017 16:05:48 +0800 (CST) From: Chen-Yu Tsai To: Maxime Ripard , David Airlie Subject: [PATCH 06/11] drm/sun4i: Drop primary layer pointer from sun4i_drv Date: Thu, 23 Feb 2017 16:05:38 +0800 Message-Id: <20170223080543.6659-7-wens@csie.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170223080543.6659-1-wens@csie.org> References: <20170223080543.6659-1-wens@csie.org> X-Mailman-Approved-At: Fri, 24 Feb 2017 00:37:07 +0000 Cc: linux-arm-kernel@lists.infradead.org, Chen-Yu Tsai , linux-sunxi@googlegroups.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The current layer init code keeps a pointer to the primary plane layer in sun4i_drv. When we eventually support multiple display pipelines, this would force us to keep track of primary planes for all crtcs. And these pointers only get used at bind time. Instead, have the crtc init code iterate through the returned layers to find the primary and cursor layers. And drop the pointer from the sun4i_drv structure. Signed-off-by: Chen-Yu Tsai --- drivers/gpu/drm/sun4i/sun4i_crtc.c | 25 +++++++++++++++++++++---- drivers/gpu/drm/sun4i/sun4i_drv.h | 1 - drivers/gpu/drm/sun4i/sun4i_layer.c | 3 --- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c b/drivers/gpu/drm/sun4i/sun4i_crtc.c index 1d01667fa45d..cb1a901bc389 100644 --- a/drivers/gpu/drm/sun4i/sun4i_crtc.c +++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c @@ -119,7 +119,8 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm) { struct sun4i_drv *drv = drm->dev_private; struct sun4i_crtc *scrtc; - int ret; + struct drm_plane *primary = NULL, *cursor = NULL; + int ret, i; scrtc = devm_kzalloc(drm->dev, sizeof(*scrtc), GFP_KERNEL); if (!scrtc) @@ -130,12 +131,28 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm) scrtc->layers = sun4i_layers_init(drm); if (IS_ERR(scrtc->layers)) { dev_err(drm->dev, "Couldn't create the planes\n"); - return ERR_CAST(scrtc->layers); + return NULL; + } + + /* find primary and cursor planes for drm_crtc_init_with_planes */ + for (i = 0; scrtc->layers[i]; i++) { + struct sun4i_layer *layer = scrtc->layers[i]; + + switch (layer->plane.type) { + case DRM_PLANE_TYPE_PRIMARY: + primary = &layer->plane; + break; + case DRM_PLANE_TYPE_CURSOR: + cursor = &layer->plane; + break; + default: + break; + } } ret = drm_crtc_init_with_planes(drm, &scrtc->crtc, - drv->primary, - NULL, + primary, + cursor, &sun4i_crtc_funcs, NULL); if (ret) { diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.h b/drivers/gpu/drm/sun4i/sun4i_drv.h index 7a3345b7b6d1..5df50126ff52 100644 --- a/drivers/gpu/drm/sun4i/sun4i_drv.h +++ b/drivers/gpu/drm/sun4i/sun4i_drv.h @@ -20,7 +20,6 @@ struct sun4i_drv { struct sun4i_backend *backend; struct sun4i_tcon *tcon; - struct drm_plane *primary; struct drm_fbdev_cma *fbdev; }; diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c index 0b703fb02656..9c0baee25fae 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.c +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c @@ -127,9 +127,6 @@ static struct sun4i_layer *sun4i_layer_init_one(struct drm_device *drm, &sun4i_backend_layer_helper_funcs); layer->drv = drv; - if (plane->type == DRM_PLANE_TYPE_PRIMARY) - drv->primary = &layer->plane; - return layer; }