From patchwork Fri Dec 1 06:05:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 10086335 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 C02486037E for ; Fri, 1 Dec 2017 06:29:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A567F2A509 for ; Fri, 1 Dec 2017 06:29:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9859D2A50C; Fri, 1 Dec 2017 06:29:15 +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,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 42BB92A509 for ; Fri, 1 Dec 2017 06:29:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=v+RzLyYsTAJ8daa0VOW38EFoP347LI/YxljdULeircI=; b=HeC2FqMTm0PQXzEfxEydKWsQ3F KpgT5kXqlmg465aOPIY+zw3HO4mzjGv4aECCXmgcF0VscZU1P/lwttbPd3fgW5E68Y60tVRZGarUa KSQE+BiETqL/kkxP7+VwyDUiC35a9jOxET0yG4len73ySMMjMqDJeZ2nT+ZI6w615cUuQIJq0ni5P TXkhCclAqxVi9/Qq9aKj1xzXSphVRkh+yTuvetOtr6M8SVpyKYluKPzya0JpYLFAA9mkz1jMXKeea kKxmAPQhzBOSLcoLYHMA8LuQic19NINeYQYf5OkeywnmXA5usy1WlowyUXNcHMX25nu6ekyPOXZ4S FXJ3Etbw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eKeox-0004xo-Nm; Fri, 01 Dec 2017 06:29:11 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eKeU7-0004yJ-2p for linux-arm-kernel@bombadil.infradead.org; Fri, 01 Dec 2017 06:07:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CEir8HT0hqwZYUhMq93o91j9Ja2drRIScWUrDKRRedw=; b=CTZ3p1/DXoqcLJOTkWE+SAKvP usdwpwFY6cOVKZoQKH32sp1yj8ZpfwphPSvEBlrdbxogKKIh0sPnWvr0BlNJU0DUzDYY43BIkwTcC lXYncImAKnI6wMhI9M57J6ppOYO8FYupfoNW9+38AdwgiTgsc6tkaeS/xqhaUGnpt34SFanBKwqBN wNHvPddJCVaM6yNgF3MXeLv3iPpC6jk0NNMGSb22wO54TmUDvsDFdh6YzPBQYOFPRuw2cjBnId0Kg c4EQTTsPlmAyQJ48H28EOgYxzr8xc2wr4McleZ1c0UdeeSwi65ufuTxwH8QSloRa4MEoAwC0yROM/ UWAyY0ljQ==; Received: from mailoutvs2.siol.net ([213.250.19.135] helo=mail.siol.net) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eKeU3-0005cQ-Qh for linux-arm-kernel@lists.infradead.org; Fri, 01 Dec 2017 06:07:36 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTP id DBF60520790; Fri, 1 Dec 2017 07:06:50 +0100 (CET) X-Virus-Scanned: amavisd-new at psrvmta09.zcs-production.pri Received: from mail.siol.net ([127.0.0.1]) by localhost (psrvmta09.zcs-production.pri [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id w8k03aV_Ibzj; Fri, 1 Dec 2017 07:06:50 +0100 (CET) Received: from mail.siol.net (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTPS id 51C7C52071B; Fri, 1 Dec 2017 07:06:50 +0100 (CET) Received: from localhost.localdomain (cpe-86-58-68-135.ftth.triera.net [86.58.68.135]) (Authenticated sender: 031275009) by mail.siol.net (Postfix) with ESMTPSA id DA277520729; Fri, 1 Dec 2017 07:06:47 +0100 (CET) From: Jernej Skrabec To: maxime.ripard@free-electrons.com Subject: [PATCH v2 16/27] drm/sun4i: Add multi plane support to DE2 driver Date: Fri, 1 Dec 2017 07:05:39 +0100 Message-Id: <20171201060550.10392-17-jernej.skrabec@siol.net> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171201060550.10392-1-jernej.skrabec@siol.net> References: <20171201060550.10392-1-jernej.skrabec@siol.net> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: airlied@linux.ie, linux-sunxi@googlegroups.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, wens@csie.org, linux-arm-kernel@lists.infradead.org, icenowy@aosc.io MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Support for multiple UI planes can now be easily enabled just by adding more planes with different index. For now, add immutable zpos property. Signed-off-by: Jernej Skrabec --- drivers/gpu/drm/sun4i/sun8i_layer.c | 38 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_layer.c b/drivers/gpu/drm/sun4i/sun8i_layer.c index 1eced63f365d..65d6eb7d5cbf 100644 --- a/drivers/gpu/drm/sun4i/sun8i_layer.c +++ b/drivers/gpu/drm/sun4i/sun8i_layer.c @@ -22,12 +22,6 @@ #include "sun8i_layer.h" #include "sun8i_mixer.h" -struct sun8i_plane_desc { - enum drm_plane_type type; - const uint32_t *formats; - uint32_t nformats; -}; - static int sun8i_mixer_layer_atomic_check(struct drm_plane *plane, struct drm_plane_state *state) { @@ -106,35 +100,38 @@ static const uint32_t sun8i_mixer_layer_formats[] = { DRM_FORMAT_XRGB8888, }; -static const struct sun8i_plane_desc sun8i_mixer_planes[] = { - { - .type = DRM_PLANE_TYPE_PRIMARY, - .formats = sun8i_mixer_layer_formats, - .nformats = ARRAY_SIZE(sun8i_mixer_layer_formats), - }, -}; - static struct sun8i_layer *sun8i_layer_init_one(struct drm_device *drm, struct sun8i_mixer *mixer, - const struct sun8i_plane_desc *plane) + int index) { struct sun8i_layer *layer; + enum drm_plane_type type; int ret; layer = devm_kzalloc(drm->dev, sizeof(*layer), GFP_KERNEL); if (!layer) return ERR_PTR(-ENOMEM); + type = index == 0 ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY; + /* possible crtcs are set later */ ret = drm_universal_plane_init(drm, &layer->plane, 0, &sun8i_mixer_layer_funcs, - plane->formats, plane->nformats, - NULL, plane->type, NULL); + sun8i_mixer_layer_formats, + ARRAY_SIZE(sun8i_mixer_layer_formats), + NULL, type, NULL); if (ret) { dev_err(drm->dev, "Couldn't initialize layer\n"); return ERR_PTR(ret); } + /* fixed zpos for now */ + ret = drm_plane_create_zpos_immutable_property(&layer->plane, index); + if (ret) { + dev_err(drm->dev, "Couldn't add zpos property\n"); + return ERR_PTR(ret); + } + drm_plane_helper_add(&layer->plane, &sun8i_mixer_layer_helper_funcs); layer->mixer = mixer; @@ -149,16 +146,15 @@ struct drm_plane **sun8i_layers_init(struct drm_device *drm, struct sun8i_mixer *mixer = engine_to_sun8i_mixer(engine); int i; - planes = devm_kcalloc(drm->dev, ARRAY_SIZE(sun8i_mixer_planes) + 1, + planes = devm_kcalloc(drm->dev, mixer->cfg->ui_num + 1, sizeof(*planes), GFP_KERNEL); if (!planes) return ERR_PTR(-ENOMEM); - for (i = 0; i < ARRAY_SIZE(sun8i_mixer_planes); i++) { - const struct sun8i_plane_desc *plane = &sun8i_mixer_planes[i]; + for (i = 0; i < mixer->cfg->ui_num; i++) { struct sun8i_layer *layer; - layer = sun8i_layer_init_one(drm, mixer, plane); + layer = sun8i_layer_init_one(drm, mixer, i); if (IS_ERR(layer)) { dev_err(drm->dev, "Couldn't initialize %s plane\n", i ? "overlay" : "primary");