From patchwork Wed Dec 13 15:33:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 121785 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5620715qgn; Wed, 13 Dec 2017 07:33:49 -0800 (PST) X-Google-Smtp-Source: ACJfBosagP27fsKuTJOJ0PFUC7xpGCnM1/MiCN5J7EyxDvwjyV7K5j/nGabqPoQZJaPsESPhsjjD X-Received: by 10.159.245.144 with SMTP id a16mr6319454pls.302.1513179229447; Wed, 13 Dec 2017 07:33:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513179229; cv=none; d=google.com; s=arc-20160816; b=bn6Uxb1E6vuvrdNRLUnmcFTZM4ok3PQTuABhFV0UXPWiEJQwcYfJHQq+us2Hf1eExH wD2/2UZrvHpxi4/2GPXbJ/ZL0XMIwSIltT2I+oLGBCE31dhJBuoZ2nk2dhRbfe06r1nn w2ZmOEXiH+nOCfoD8RvtmCYkUVx9ucGhN0Qsp06Pr08VIiouAlFwdFEzHo6pmZUFziL4 xSOhS2YTNwBjm80WHG8uk6LhgRTYFGWy8OQ4MOeJ50/tCS86YY7WS/ohua5FuWiucJsl aYQZ9p/ZgZ4smAEIzaFIdDSL2AQZl48NNnmUEIPgKPQjzrKTMAaBMKCoZXguv2WyFC+u CWbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=wlG30iLueiyDtJH7QN6/gjKY43hR8B1TMlZcPNUuzdc=; b=lvWyvhdy4HBkLQ4u3ONncWzz6FMu+JPe5ptKA+1CQZa5O4EX5GzjmqW8+7EBjL2YZv hfYl1JHOy/aydaMw0+M1xTaO0AR9gXUDaW89Tg9K8NUvACQmTdfUijkf5SsH6PWCmQAk aOU/+SbTnvm3how+CFcaoygOLt6m1e+ZGBsHCFdGDyaBN970kagJ85FiDCn1/JQIZbLe ApQq5USdGjXwzUi6yiUkwgRsPihBypGkXq24Qep6pyrViYSmDhQ4CQEjai2ZVYuEjdWD GYzG/4/ziJM6XJqV5YrH2nI67iGJ3RoxObk/02AxrzqdlIp6Hga00tgF7Sx+MZIv+/K2 0RdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si1578813pfg.369.2017.12.13.07.33.49; Wed, 13 Dec 2017 07:33:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753498AbdLMPdq (ORCPT + 12 others); Wed, 13 Dec 2017 10:33:46 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:37723 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753434AbdLMPdl (ORCPT ); Wed, 13 Dec 2017 10:33:41 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id CBCBF20964; 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 9F31F20503; Wed, 13 Dec 2017 16:33:39 +0100 (CET) From: Maxime Ripard To: Daniel Vetter , David Airlie , Chen-Yu Tsai , Maxime Ripard Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Thomas Petazzoni , thomas@vitsch.nl Subject: [PATCH 6/8] drm/sun4i: sun4i_layer: Wire in the frontend Date: Wed, 13 Dec 2017 16:33:30 +0100 Message-Id: <0cd2570c9cbe20d094cee0e8e9918c3a0f6af2fa.1513178989.git-series.maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we have a driver, we can make use of it. This is done by adding a flag to our custom plane state that will trigger whether we should use the frontend on that particular plane or not. The rest is just plumbing to set up the backend to not perform the DMA but receive its data from the frontend. Note that we're still not making any use of the frontend itself, as no one is setting the flag yet. Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_backend.c | 53 ++++++++++++++++++++++++++++- drivers/gpu/drm/sun4i/sun4i_backend.h | 3 ++- drivers/gpu/drm/sun4i/sun4i_layer.c | 27 ++++++++++++-- drivers/gpu/drm/sun4i/sun4i_layer.h | 1 +- 4 files changed, 81 insertions(+), 3 deletions(-) -- git-series 0.9.1 Reviewed-by: Neil Armstrong diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c index e83e1fe43823..f1d19767c55d 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.c +++ b/drivers/gpu/drm/sun4i/sun4i_backend.c @@ -26,6 +26,7 @@ #include "sun4i_backend.h" #include "sun4i_drv.h" +#include "sun4i_frontend.h" #include "sun4i_layer.h" #include "sunxi_engine.h" @@ -203,6 +204,30 @@ int sun4i_backend_update_layer_formats(struct sun4i_backend *backend, return 0; } +int sun4i_backend_update_layer_frontend(struct sun4i_backend *backend, + int layer, uint32_t fmt) +{ + u32 val; + int ret; + + ret = sun4i_backend_drm_format_to_layer(NULL, fmt, &val); + if (ret) { + DRM_DEBUG_DRIVER("Invalid format\n"); + return ret; + } + + regmap_update_bits(backend->engine.regs, + SUN4I_BACKEND_ATTCTL_REG0(layer), + SUN4I_BACKEND_ATTCTL_REG0_LAY_VDOEN, + SUN4I_BACKEND_ATTCTL_REG0_LAY_VDOEN); + + regmap_update_bits(backend->engine.regs, + SUN4I_BACKEND_ATTCTL_REG1(layer), + SUN4I_BACKEND_ATTCTL_REG1_LAY_FBFMT, val); + + return 0; +} + int sun4i_backend_update_layer_buffer(struct sun4i_backend *backend, int layer, struct drm_plane *plane) { @@ -330,6 +355,34 @@ static int sun4i_backend_of_get_id(struct device_node *node) return ret; } +static struct sun4i_frontend *sun4i_backend_find_frontend(struct sun4i_drv *drv, + struct device_node *node) +{ + struct device_node *port, *ep, *remote; + struct sun4i_frontend *frontend; + + port = of_graph_get_port_by_id(node, 0); + if (!port) + return ERR_PTR(-EINVAL); + + for_each_available_child_of_node(port, ep) { + remote = of_graph_get_remote_port_parent(ep); + if (!remote) + continue; + + /* does this node match any registered engines? */ + list_for_each_entry(frontend, &drv->frontend_list, list) { + if (remote == frontend->node) { + of_node_put(remote); + of_node_put(port); + return frontend; + } + } + } + + return ERR_PTR(-EINVAL); +} + static const struct sunxi_engine_ops sun4i_backend_engine_ops = { .commit = sun4i_backend_commit, .layers_init = sun4i_layers_init, diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.h b/drivers/gpu/drm/sun4i/sun4i_backend.h index ba1410fd5410..636a51521e77 100644 --- a/drivers/gpu/drm/sun4i/sun4i_backend.h +++ b/drivers/gpu/drm/sun4i/sun4i_backend.h @@ -72,6 +72,7 @@ #define SUN4I_BACKEND_ATTCTL_REG0_LAY_PIPESEL(x) ((x) << 15) #define SUN4I_BACKEND_ATTCTL_REG0_LAY_PRISEL_MASK GENMASK(11, 10) #define SUN4I_BACKEND_ATTCTL_REG0_LAY_PRISEL(x) ((x) << 10) +#define SUN4I_BACKEND_ATTCTL_REG0_LAY_VDOEN BIT(1) #define SUN4I_BACKEND_ATTCTL_REG1(l) (0x8a0 + (0x4 * (l))) #define SUN4I_BACKEND_ATTCTL_REG1_LAY_HSCAFCT GENMASK(15, 14) @@ -171,5 +172,7 @@ int sun4i_backend_update_layer_formats(struct sun4i_backend *backend, int layer, struct drm_plane *plane); int sun4i_backend_update_layer_buffer(struct sun4i_backend *backend, int layer, struct drm_plane *plane); +int sun4i_backend_update_layer_frontend(struct sun4i_backend *backend, + int layer, uint32_t in_fmt); #endif /* _SUN4I_BACKEND_H_ */ diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c index c3afcf888906..3b58667a06dc 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.c +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c @@ -15,6 +15,7 @@ #include #include "sun4i_backend.h" +#include "sun4i_frontend.h" #include "sun4i_layer.h" #include "sunxi_engine.h" @@ -70,21 +71,41 @@ static void sun4i_backend_layer_destroy_state(struct drm_plane *plane, static void sun4i_backend_layer_atomic_disable(struct drm_plane *plane, struct drm_plane_state *old_state) { + struct sun4i_layer_state *layer_state = state_to_sun4i_layer_state(old_state); struct sun4i_layer *layer = plane_to_sun4i_layer(plane); struct sun4i_backend *backend = layer->backend; + struct sun4i_frontend *frontend = backend->frontend; sun4i_backend_layer_enable(backend, layer->id, false); + + if (layer_state->uses_frontend) + sun4i_frontend_exit(frontend); } static void sun4i_backend_layer_atomic_update(struct drm_plane *plane, struct drm_plane_state *old_state) { + struct sun4i_layer_state *layer_state = state_to_sun4i_layer_state(plane->state); struct sun4i_layer *layer = plane_to_sun4i_layer(plane); struct sun4i_backend *backend = layer->backend; + struct sun4i_frontend *frontend = backend->frontend; + + if (layer_state->uses_frontend) { + sun4i_frontend_init(frontend); + sun4i_frontend_update_coord(frontend, plane); + sun4i_frontend_update_buffer(frontend, plane); + sun4i_frontend_update_formats(frontend, plane, + DRM_FORMAT_ARGB8888); + sun4i_backend_update_layer_frontend(backend, layer->id, + DRM_FORMAT_ARGB8888); + sun4i_backend_update_layer_coord(backend, layer->id, plane); + sun4i_frontend_enable(frontend); + } else { + sun4i_backend_update_layer_coord(backend, layer->id, plane); + sun4i_backend_update_layer_formats(backend, layer->id, plane); + sun4i_backend_update_layer_buffer(backend, layer->id, plane); + } - sun4i_backend_update_layer_coord(backend, layer->id, plane); - sun4i_backend_update_layer_formats(backend, layer->id, plane); - sun4i_backend_update_layer_buffer(backend, layer->id, plane); sun4i_backend_layer_enable(backend, layer->id, true); } diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.h b/drivers/gpu/drm/sun4i/sun4i_layer.h index d2c19348d1b0..75b4868ba87c 100644 --- a/drivers/gpu/drm/sun4i/sun4i_layer.h +++ b/drivers/gpu/drm/sun4i/sun4i_layer.h @@ -24,6 +24,7 @@ struct sun4i_layer { struct sun4i_layer_state { struct drm_plane_state state; + bool uses_frontend; }; static inline struct sun4i_layer *