From patchwork Wed Dec 13 15:33:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 121789 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5621207qgn; Wed, 13 Dec 2017 07:34:13 -0800 (PST) X-Google-Smtp-Source: ACJfBoupaqGXtLFC3hLNm3bs8P/PxYwm8BxBaztkxDOEBqDpLK/FtQUwrERxYB+YKt1vJsNX4DvB X-Received: by 10.98.104.194 with SMTP id d185mr6388725pfc.155.1513179253899; Wed, 13 Dec 2017 07:34:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513179253; cv=none; d=google.com; s=arc-20160816; b=iDqdxfIF58bIqj7d2FNr0u7R0yNJe7uXSQaTCRAIukmVKFt9xS0JyIE4rBb5GgrByR 8jT3HyEWGefA+18LUNQiY/qxKxHAd7d2CE/3pVqP3w4Pul1JZTon/mG41uMNd3HYpw7P VtWBgImhXfmQuo+12vnUr8QxM4cDzrOcUBqG0LxXmewnp2WYYZB+go1+t826MfUOECpB A4y8Bl1tQgl3GyPycm9RtpeZQE4/7icbiekZDTmDABd17OiskEHB4yJatJrKaBb8AZHu Brj/YO6BsbiF7WFTZBL+G3bxT4EIZmnK3VGxEvfbiQ2v8mV/jj7af3+Yv1ZrKFoMiz2j 40GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:references:in-reply-to :message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=TEbiUimMtUKj24SBbpqnxSQFb4hltBR/35oA0hrdRnc=; b=Zdv5sQCbHvXIvA10ccxMhkC1TaK22JOW85wuVg/3unZVV0AbKtsEIPqJD18UxwmLTE BfPcr8iulPsAmE/cDMdta53AML7p5M4SGNjQg9kAbYqjyCTjPKoD1Xpr4trsy3vpQyG1 IHIuZTbpnzbjWK8NH7+yExHoZ5q+urB6yTq3cNdPcdsr6wjxm2ulvWbg49zgr4j8k80T hTNaQEl28w2D1IOx5jXgR+YTv+VWgHl//cAZpkY1nuI4DQ3Rkvuao/vmXthio4ntuxZA k1x/BAzmlKO9DUKVxMsOodNPzMP5K9ijArdhkJZpXNv8tPHoXpCzn7cQkonQnII2nBOK gCJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id e62si1597841pfa.154.2017.12.13.07.34.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 07:34:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 638AB6E514; Wed, 13 Dec 2017 15:33:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D6346E510 for ; Wed, 13 Dec 2017 15:33:39 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 2971620850; Wed, 13 Dec 2017 16:33:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id F2BC120732; Wed, 13 Dec 2017 16:33:37 +0100 (CET) From: Maxime Ripard To: Daniel Vetter , David Airlie , Chen-Yu Tsai , Maxime Ripard Subject: [PATCH 1/8] drm/sun4i: backend: Move line stride setup to buffer setup function Date: Wed, 13 Dec 2017 16:33:25 +0100 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, thomas@vitsch.nl 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" Setup the line stride in the buffer setup function, since it's tied to the buffer itself, and is not needed when we do not set the buffer in the backend. This is for example the case when using the frontend and then routing its output to the backend. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_backend.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index 847eecbe4d14..c99d1a7e815a 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -141,7 +141,6 @@ int sun4i_backend_update_layer_coord(struct sun4i_backend *backend, int layer, struct drm_plane *plane) { struct drm_plane_state *state = plane->state; - struct drm_framebuffer *fb = state->fb; DRM_DEBUG_DRIVER("Updating layer %d\n", layer); @@ -153,12 +152,6 @@ int sun4i_backend_update_layer_coord(struct sun4i_backend *backend, state->crtc_h)); } - /* Set the line width */ - DRM_DEBUG_DRIVER("Layer line width: %d bits\n", fb->pitches[0] * 8); - regmap_write(backend->engine.regs, - SUN4I_BACKEND_LAYLINEWIDTH_REG(layer), - fb->pitches[0] * 8); - /* Set height and width */ DRM_DEBUG_DRIVER("Layer size W: %u H: %u\n", state->crtc_w, state->crtc_h); @@ -218,6 +211,13 @@ int sun4i_backend_update_layer_buffer(struct sun4i_backend *backend, u32 lo_paddr, hi_paddr; dma_addr_t paddr; + /* Set the line width */ + DRM_DEBUG_DRIVER("Layer line width: %d bits\n", fb->pitches[0] * 8); + regmap_write(backend->engine.regs, + SUN4I_BACKEND_LAYLINEWIDTH_REG(layer), + fb->pitches[0] * 8); + + /* Get the start of the displayed memory */ paddr = drm_fb_cma_get_gem_addr(fb, state, 0); DRM_DEBUG_DRIVER("Setting buffer address to %pad\n", &paddr); From patchwork Wed Dec 13 15:33:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 121784 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5620619qgn; Wed, 13 Dec 2017 07:33:45 -0800 (PST) X-Google-Smtp-Source: ACJfBotP10ohthO1YcXao1/sV+OwexEpPC4Et9762cZmgdpFtO4+A0OPGrGA5iIDF9tyc2vSUdgk X-Received: by 10.99.170.77 with SMTP id x13mr5745068pgo.117.1513179225330; Wed, 13 Dec 2017 07:33:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513179225; cv=none; d=google.com; s=arc-20160816; b=qPpckaob7xT9zhGd5sda80jdBMm7K3B95qJhA+1PZMEt8OD7VQgma78lO8IudxqNMM 8J4+OCu1L+W8i1i+ouwA72oGFuINHsyQ5WMbyD2jRDY9xHWW0phZEZavEBvEgxLaqp3l hC7fY5iZmnyJJGHD5JcrU6uPuTukaDBSueTC3DbWbnl58udpLXgj7VGwPaKoxHvWSRXU MMDsOG1+ElL1HVmAySkV2n+C175PfcFfZDXY7u/Z+jN8kMJILkHvpclTJTCqLOlRN/PV AjiVmllAo/a3mY+8ZuwrqAVF/PtBzBCmsNj9VJpyYUvKtRGA/YdW1URcCpYcVlePOJO/ 0B4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:references:in-reply-to :message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=eeyP8AT2UU4NsismrWv0hUJzP/QzCEe81vYe+icIDQQ=; b=lbv0ETRA9WX+xV6G+GRaboorswe+HEtQj3x56KFm7+a2etwuRHcltAKgztRohBOAKq 75bg5euVjkF2vTlrX8GC5sleyL9JXjKC0oxwX4x+2DFu+1sqaSWMfJDmenu0Mv/T35nu bH3S0P6A6T89hym5SEHN3WBUOlL67u1qlDoG0z2LJF1uC27GBHSc5Sq6f/qx/kNYh0KB 6fhueDPt8Iasd6sbUA2km3DVfJJecGB/HFPZk2INNKBPo8Hpsmb4cOBPAxIhiYov7GM6 aKSeKc454HFsQprG8xrGE9Ny9osWsA/rBU1EcjJU2bAqhGHrFroKYPoZ3rHrCDVeepW2 1QnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id q1si1503943plr.363.2017.12.13.07.33.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 07:33:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A1DB56E513; Wed, 13 Dec 2017 15:33:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id AD56F6E50D for ; Wed, 13 Dec 2017 15:33:39 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 770E320810; Wed, 13 Dec 2017 16:33:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 4E2C020503; Wed, 13 Dec 2017 16:33:38 +0100 (CET) From: Maxime Ripard To: Daniel Vetter , David Airlie , Chen-Yu Tsai , Maxime Ripard Subject: [PATCH 2/8] drm/sun4i: backend: Allow a NULL plane pointer to retrieve the format Date: Wed, 13 Dec 2017 16:33:26 +0100 Message-Id: <6a1686760e61baa9f21fd2f12e56a8de92eb1714.1513178989.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, thomas@vitsch.nl 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" The function converting the DRM format to its equivalent in the backend registers was assuming that we were having a plane. However, we might want to use that function when setting up a plane using the frontend, in which case we will not have a plane associated to the backend's layer. Yet, we still need to setup the format to the one output by the frontend. Test for NULL plane pointers before referencing them, so that we can work around it. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index c99d1a7e815a..f971d3fb5ee4 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -93,7 +93,7 @@ void sun4i_backend_layer_enable(struct sun4i_backend *backend, static int sun4i_backend_drm_format_to_layer(struct drm_plane *plane, u32 format, u32 *mode) { - if ((plane->type == DRM_PLANE_TYPE_PRIMARY) && + if (plane && (plane->type == DRM_PLANE_TYPE_PRIMARY) && (format == DRM_FORMAT_ARGB8888)) format = DRM_FORMAT_XRGB8888; From patchwork Wed Dec 13 15:33:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 121791 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5621265qgn; Wed, 13 Dec 2017 07:34:17 -0800 (PST) X-Google-Smtp-Source: ACJfBouO/wUutqDaOguRmk24snhMYtwcvKJqj2zpKdtQuB6DL34WSaMLFbJXDqygBJBoeA92QvEH X-Received: by 10.84.129.46 with SMTP id 43mr6436637plb.1.1513179256978; Wed, 13 Dec 2017 07:34:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513179256; cv=none; d=google.com; s=arc-20160816; b=gFZ/1WXllrc14Zyg+rP4ewGDBD94/yynU2np9ZUm6tBma9d7+LSv3mTahbVaZsahsi w/EBUdISO4eLGo2uTUvZNK806cI2bo75kFNGKX9SjzhrCFBZ73X6uuQKvuz5h5WE+4A9 TPpm4TbUm2WvbFTFuVdt/qV8NmyoVAYtS272TX+fzcL6UN4iQrCjGumHMDbJbzFn9BYM TK0KhjW3pWBf26A1LOUPpX17xyvQD1N8HQEUwnCMFL8az7pOrTbjctB7httMsVIOBKfc zfNxcP70EmEMgtNO4TkHzYnFaxKHU3pjcjT1R9Qedc94kD/1dhpVAPplFVwvl42B9s+x aFEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:references:in-reply-to :message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=tlSqlsQDjaKi2ts7Jjc3VUAzcGodlh1KARXfp9BvP8o=; b=el6U/Ni7DDHHfq07UJwzylZ+oYzRNB52di+38DlkqgmHQtzDoxW0aiiMmYpEEGT6ZI mbPnFGIA/dHsmyD/R/61hA0yyaOZXjkOLXekQA5hH8f4d3cUnsf1EqPt63k2dxpT8cSZ c1PfmIeMRFyCYDOOV9Z9YRGCwlKYQ1vdWXqbF/X40I592BZZDOrGxQ3juXhTrKV+mY8u kLeoVsjD61v7nGl4XIE8ciE+6A5yUs1F9MYe5xxKvbT3Ztg611nnDAzzG4iztOB8Frg9 dzVfXm+LsYWwQD4R4GhoTDWZ6/JgvLkUACfVpz6wpOQkeOGT3/6l3Mpl1Vq2DzdSr1JR zn1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id r10si1433843pgp.66.2017.12.13.07.34.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 07:34:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B56EE6E51D; Wed, 13 Dec 2017 15:33:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id 00D936E50D for ; Wed, 13 Dec 2017 15:33:40 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id C1F882092C; Wed, 13 Dec 2017 16:33:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 9BBB120503; Wed, 13 Dec 2017 16:33:38 +0100 (CET) From: Maxime Ripard To: Daniel Vetter , David Airlie , Chen-Yu Tsai , Maxime Ripard Subject: [PATCH 3/8] drm/sun4i: sun4i_layer: Add a custom plane state Date: Wed, 13 Dec 2017 16:33:27 +0100 Message-Id: <8ecbf0bda89d11539dbf9357f0fe77561ebdd4c3.1513178989.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, thomas@vitsch.nl 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" We will need to store some additional data in the future to the state. Create a custom plane state that will embed those data, in order to store the pipe or whether or not that plane should use the frontend. Signed-off-by: Maxime Ripard Reviewed-by: Neil Armstrong --- drivers/gpu/drm/sun4i/sun4i_layer.c | 48 ++++++++++++++++++++++++++++-- drivers/gpu/drm/sun4i/sun4i_layer.h | 10 ++++++- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c index 7bddf12548d3..c3afcf888906 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.c +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c @@ -25,6 +25,48 @@ struct sun4i_plane_desc { uint32_t nformats; }; +static void sun4i_backend_layer_reset(struct drm_plane *plane) +{ + struct sun4i_layer_state *state; + + if (plane->state) { + state = state_to_sun4i_layer_state(plane->state); + + __drm_atomic_helper_plane_destroy_state(&state->state); + kfree(state); + plane->state = NULL; + } + + state = kzalloc(sizeof(*state), GFP_KERNEL); + if (state) { + plane->state = &state->state; + plane->state->plane = plane; + } +} + +static struct drm_plane_state * +sun4i_backend_layer_duplicate_state(struct drm_plane *plane) +{ + struct sun4i_layer_state *copy; + + copy = kzalloc(sizeof(*copy), GFP_KERNEL); + if (!copy) + return NULL; + + __drm_atomic_helper_plane_duplicate_state(plane, ©->state); + + return ©->state; +} + +static void sun4i_backend_layer_destroy_state(struct drm_plane *plane, + struct drm_plane_state *state) +{ + struct sun4i_layer_state *s_state = state_to_sun4i_layer_state(state); + + __drm_atomic_helper_plane_destroy_state(state); + kfree(s_state); +} + static void sun4i_backend_layer_atomic_disable(struct drm_plane *plane, struct drm_plane_state *old_state) { @@ -52,11 +94,11 @@ static const struct drm_plane_helper_funcs sun4i_backend_layer_helper_funcs = { }; static const struct drm_plane_funcs sun4i_backend_layer_funcs = { - .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, - .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state, + .atomic_destroy_state = sun4i_backend_layer_destroy_state, + .atomic_duplicate_state = sun4i_backend_layer_duplicate_state, .destroy = drm_plane_cleanup, .disable_plane = drm_atomic_helper_disable_plane, - .reset = drm_atomic_helper_plane_reset, + .reset = sun4i_backend_layer_reset, .update_plane = drm_atomic_helper_update_plane, }; diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.h b/drivers/gpu/drm/sun4i/sun4i_layer.h index 4e84f438b346..d2c19348d1b0 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.h +++ b/drivers/gpu/drm/sun4i/sun4i_layer.h @@ -22,12 +22,22 @@ struct sun4i_layer { int id; }; +struct sun4i_layer_state { + struct drm_plane_state state; +}; + static inline struct sun4i_layer * plane_to_sun4i_layer(struct drm_plane *plane) { return container_of(plane, struct sun4i_layer, plane); } +static inline struct sun4i_layer_state * +state_to_sun4i_layer_state(struct drm_plane_state *state) +{ + return container_of(state, struct sun4i_layer_state, state); +} + struct drm_plane **sun4i_layers_init(struct drm_device *drm, struct sunxi_engine *engine); From patchwork Wed Dec 13 15:33:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 121790 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5621215qgn; Wed, 13 Dec 2017 07:34:14 -0800 (PST) X-Google-Smtp-Source: ACJfBoszoKYdxa6IYjVFQoe8Hc/T1qlRoHMb0rMZMiio2n0LtrypPptDmNFaZNlBUfHRJh4KG2b0 X-Received: by 10.98.195.26 with SMTP id v26mr6375146pfg.209.1513179254658; Wed, 13 Dec 2017 07:34:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513179254; cv=none; d=google.com; s=arc-20160816; b=njRN3lVClhoNm3Suv1EZUoJLrXkKOQW55ZibBomZwHQYNbt31lsc2MMXvOtbRNP1IQ 0AKhkmKaIPRKV7PuW2RdfnSoAPyshN1xDOILsluweYoIaJFiqtF4LA2NbBqXBygB7BVQ 0oEGNRXw7rT3lSDNknWvlhlOvjwVRp/0HHKfems8wQHlRB8IQ7K3ykQpHa9yUNyvJE33 gAoFUzodAC9zvZ4zY23yI7T2CecrNUOEP2OFe80cIsTGMPoEuVK8b/i2dodZLF7WO5eq UK+vHIY8beqYzqnt3WY3+0C53oaeahy4/qusRobVBVLXKATonvRmce8wEOpKXqFPo5Tg KcxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:references:in-reply-to :message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=Me9nt49WZZh8LIYDrUw4xsd9wL8nCNpD+1heFGnBBHw=; b=sDt4qp2uvofvxGa7nsuS3veoNy0JYY1HQnx94a8dWTguyYkzMZ+0HUm1S0HS7fi9pS 10oMNeCnE/VCNFgq3M4IVSYNe3cvqshLqoWWzLfccGM41hNS9f/htlbk986aElcro9jE 5PFv38nVByJlUpVyC6xAhOYv+vUfVqNW6u9jvAL7boks87+IS7HTTvMrmT5gAJ0hX9Mt o5b5r5chlzQSiAJcBcbw5mk5rY+YPrlAFbB9hqDUPYW0sj/7NvrlJmPqgigKTstWSUnZ dd6yAjXrGnmcTBIlBRYuRFJVJxX4Woehkdj6r379X6QPrdh0HdSKmjyOjqnoM61XzYAo HEFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id f23si1411992pgv.509.2017.12.13.07.34.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 07:34:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B5416E532; Wed, 13 Dec 2017 15:33:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by gabe.freedesktop.org (Postfix) with ESMTP id 4EE406E513 for ; Wed, 13 Dec 2017 15:33:40 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 1F37C2094D; Wed, 13 Dec 2017 16:33:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id EA2BE20503; Wed, 13 Dec 2017 16:33:38 +0100 (CET) From: Maxime Ripard To: Daniel Vetter , David Airlie , Chen-Yu Tsai , Maxime Ripard Subject: [PATCH 4/8] drm/sun4i: crtc: Add a custom crtc atomic_check Date: Wed, 13 Dec 2017 16:33:28 +0100 Message-Id: X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Cc: linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, thomas@vitsch.nl 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" We have some restrictions on what the planes and CRTC can provide that are tied to only one generation of display engines. For example, on the first generation, we can only have one YUV plane or one plane that uses the frontend output. Let's allow our engines to provide an atomic_check callback to validate the current configuration. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_crtc.c | 14 ++++++++++++++ drivers/gpu/drm/sun4i/sunxi_engine.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c b/drivers/gpu/drm/sun4i/sun4i_crtc.c index 5decae0069d0..2a565325714f 100644 --- a/drivers/gpu/drm/sun4i/sun4i_crtc.c +++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c @@ -46,6 +46,19 @@ static struct drm_encoder *sun4i_crtc_get_encoder(struct drm_crtc *crtc) return NULL; } +static int sun4i_crtc_atomic_check(struct drm_crtc *crtc, + struct drm_crtc_state *state) +{ + struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc); + struct sunxi_engine *engine = scrtc->engine; + int ret = 0; + + if (engine && engine->ops && engine->ops->atomic_check) + ret = engine->ops->atomic_check(engine, state); + + return ret; +} + static void sun4i_crtc_atomic_begin(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { @@ -125,6 +138,7 @@ static void sun4i_crtc_mode_set_nofb(struct drm_crtc *crtc) } static const struct drm_crtc_helper_funcs sun4i_crtc_helper_funcs = { + .atomic_check = sun4i_crtc_atomic_check, .atomic_begin = sun4i_crtc_atomic_begin, .atomic_flush = sun4i_crtc_atomic_flush, .atomic_enable = sun4i_crtc_atomic_enable, diff --git a/drivers/gpu/drm/sun4i/sunxi_engine.h b/drivers/gpu/drm/sun4i/sunxi_engine.h index 4cb70ae65c79..42655230aeba 100644 --- a/drivers/gpu/drm/sun4i/sunxi_engine.h +++ b/drivers/gpu/drm/sun4i/sunxi_engine.h @@ -16,6 +16,8 @@ struct drm_device; struct sunxi_engine; struct sunxi_engine_ops { + int (*atomic_check)(struct sunxi_engine *engine, + struct drm_crtc_state *state); void (*commit)(struct sunxi_engine *engine); struct drm_plane **(*layers_init)(struct drm_device *drm, struct sunxi_engine *engine);