From patchwork Sun Dec 17 17:25:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10118437 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 B43A660390 for ; Mon, 18 Dec 2017 08:38:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1EF0288C5 for ; Mon, 18 Dec 2017 08:38:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96D4828915; Mon, 18 Dec 2017 08:38:08 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 2B1C0288C5 for ; Mon, 18 Dec 2017 08:38:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 76D5989AD2; Mon, 18 Dec 2017 08:38:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2DC1F89C6A for ; Sun, 17 Dec 2017 17:28:02 +0000 (UTC) Received: by mail-lf0-x242.google.com with SMTP id o26so1101907lfc.10 for ; Sun, 17 Dec 2017 09:28:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lJ09Xa7Q847KZXVG91sSyaRSHFRB8WpdQw1PLK8eFR0=; b=Za3TP8CnYlLEcjP+dIs7fBbgW5mTD5E3R4+esPxauHO56qMbEH3DROQtMliZecuXG7 FRjS6Mf4cjMGrw35Y0oToe4QwIewdlr44OYpTa/8x4TchaVrmRL9Zo+g3C+9DN83vjm+ H+f6sJJepLK5orCg3nqDRuZI4HMISRl1SuIAXaycTTuB98D5iBFowyVd8eYa6SQYuynJ axzuQNkOR4H2RpbPR5L/yYRhn0CQXka4yi5L6zBOATbR4IUuKkGdufgkzcgopMUKrPWo Q9nY6bnhb5apdJJh8KBTZO7Vi/kcxrOS/d3zYPWdk6Jgv9m6zWah4dp9jT/ilwcUBeoz BlQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lJ09Xa7Q847KZXVG91sSyaRSHFRB8WpdQw1PLK8eFR0=; b=hiR5FuQfkjLVRGZBcSL1zV6iodnYUm3A9ydDo+KIKGJytiaGRI/5Y7SSsNnJU+5TwH cKtdN0vsV/dYy1FnyA71rD2JljN2wLDlyFI/EJmxGZ+aeV9PCobGAZo9jleSMzFNAS0V RaukyO8DdBtaT/ex/6KtvgYL0t/QIlYaA2TY+lGZVqJtILGYtJoOntAsHo2LnR7Jdtiq X9f/nOkNb2daGUSHsc0JnCulxpsmk/If/ev+GW1aPYXyDjZPNo2XHt+gwTX9KUBka+R5 5nWNzkViYM9GPQilywcGQWs6T75iexNY6Y3h6RWWxfp1yOAIDamB4apg0Kyd0ZUIkFmB HlbA== X-Gm-Message-State: AKGB3mLmAeI8fPA3LvfWtez0IimjjjNj7HcAAJFOin/OzKXeN2tZYX5W 6P3hTFLstiU/hWeJC6GiBCA= X-Google-Smtp-Source: ACJfBourylb9ujgzvwm5xISKq0IoFydmaikPWGJfFdl7iI04WlHsWNPobkObfFB2k7kZvLmPcb2tIw== X-Received: by 10.46.20.83 with SMTP id 19mr10033467lju.23.1513531681349; Sun, 17 Dec 2017 09:28:01 -0800 (PST) Received: from localhost.localdomain (ppp109-252-55-194.pppoe.spdop.ru. [109.252.55.194]) by smtp.gmail.com with ESMTPSA id t85sm2244926ljb.91.2017.12.17.09.28.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Dec 2017 09:28:00 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding Subject: [PATCH v1] drm/tegra: Trade overlay plane for cursor on older Tegra's Date: Sun, 17 Dec 2017 20:25:45 +0300 Message-Id: <73fc5a5b95e6829e895dbd4ed97462451d0c0338.1513530923.git.digetx@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <8a87083279bb793dd21a0c621bcd002a851495e5.1513530934.git.digetx@gmail.com> References: <8a87083279bb793dd21a0c621bcd002a851495e5.1513530934.git.digetx@gmail.com> X-Mailman-Approved-At: Mon, 18 Dec 2017 08:38:01 +0000 Cc: linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.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 Older Tegra's do not support RGBA format for the cursor, but instead overlay plane could be used for it. Since there is no much use for the overlays on a regular desktop and HW-accelerated cursor is much nicer than the jerky SW cursor, let's trade one overlay plane for the cursor. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/dc.c | 52 +++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index 7e58143f4145..3282aa911351 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -125,9 +125,10 @@ static inline u32 compute_initial_dda(unsigned int in) return dfixed_frac(inf); } -static void tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index, +static void tegra_dc_setup_window(struct tegra_dc *dc, struct drm_plane *plane, const struct tegra_dc_window *window) { + struct tegra_plane *p = to_tegra_plane(plane); unsigned h_offset, v_offset, h_size, v_size, h_dda, v_dda, bpp; unsigned long value, flags; bool yuv, planar; @@ -144,7 +145,7 @@ static void tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index, spin_lock_irqsave(&dc->lock, flags); - value = WINDOW_A_SELECT << index; + value = WINDOW_A_SELECT << p->index; tegra_dc_writel(dc, value, DC_CMD_DISPLAY_WINDOW_HEADER); tegra_dc_writel(dc, window->format, DC_WIN_COLOR_DEPTH); @@ -275,23 +276,29 @@ static void tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index, tegra_dc_writel(dc, 0xffff00, DC_WIN_BLEND_NOKEY); tegra_dc_writel(dc, 0xffff00, DC_WIN_BLEND_1WIN); - switch (index) { + switch (p->index) { case 0: tegra_dc_writel(dc, 0x000000, DC_WIN_BLEND_2WIN_X); - tegra_dc_writel(dc, 0x000000, DC_WIN_BLEND_2WIN_Y); + tegra_dc_writel(dc, 0x000008, DC_WIN_BLEND_2WIN_Y); tegra_dc_writel(dc, 0x000000, DC_WIN_BLEND_3WIN_XY); break; case 1: tegra_dc_writel(dc, 0xffff00, DC_WIN_BLEND_2WIN_X); tegra_dc_writel(dc, 0x000000, DC_WIN_BLEND_2WIN_Y); - tegra_dc_writel(dc, 0x000000, DC_WIN_BLEND_3WIN_XY); + tegra_dc_writel(dc, 0x000008, DC_WIN_BLEND_3WIN_XY); break; case 2: - tegra_dc_writel(dc, 0xffff00, DC_WIN_BLEND_2WIN_X); - tegra_dc_writel(dc, 0xffff00, DC_WIN_BLEND_2WIN_Y); - tegra_dc_writel(dc, 0xffff00, DC_WIN_BLEND_3WIN_XY); + if (plane->type == DRM_PLANE_TYPE_CURSOR) { + tegra_dc_writel(dc, 0xffff04, DC_WIN_BLEND_2WIN_X); + tegra_dc_writel(dc, 0xffff04, DC_WIN_BLEND_2WIN_Y); + tegra_dc_writel(dc, 0xffff04, DC_WIN_BLEND_3WIN_XY); + } else { + tegra_dc_writel(dc, 0xffff00, DC_WIN_BLEND_2WIN_X); + tegra_dc_writel(dc, 0xffff00, DC_WIN_BLEND_2WIN_Y); + tegra_dc_writel(dc, 0xffff00, DC_WIN_BLEND_3WIN_XY); + } break; } @@ -438,7 +445,6 @@ static void tegra_plane_atomic_update(struct drm_plane *plane, struct tegra_plane_state *state = to_tegra_plane_state(plane->state); struct tegra_dc *dc = to_tegra_dc(plane->state->crtc); struct drm_framebuffer *fb = plane->state->fb; - struct tegra_plane *p = to_tegra_plane(plane); struct tegra_dc_window window; unsigned int i; @@ -480,7 +486,7 @@ static void tegra_plane_atomic_update(struct drm_plane *plane, window.stride[i] = fb->pitches[i]; } - tegra_dc_setup_window(dc, p->index, &window); + tegra_dc_setup_window(dc, plane, &window); } static const struct drm_plane_helper_funcs tegra_plane_helper_funcs = { @@ -775,9 +781,11 @@ static const u32 tegra124_overlay_formats[] = { static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm, struct tegra_dc *dc, - unsigned int index) + unsigned int index, + bool cursor) { struct tegra_plane *plane; + enum drm_plane_type type; unsigned int num_formats; const u32 *formats; int err; @@ -793,11 +801,14 @@ static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm, num_formats = dc->soc->num_overlay_formats; formats = dc->soc->overlay_formats; + type = DRM_PLANE_TYPE_OVERLAY; + + if (cursor) + type = DRM_PLANE_TYPE_CURSOR; err = drm_universal_plane_init(drm, &plane->base, 1 << dc->pipe, &tegra_plane_funcs, formats, - num_formats, NULL, - DRM_PLANE_TYPE_OVERLAY, NULL); + num_formats, NULL, type, NULL); if (err < 0) { kfree(plane); return ERR_PTR(err); @@ -846,14 +857,18 @@ static struct drm_plane *tegra_dc_add_planes(struct drm_device *drm, struct tegra_dc *dc) { struct drm_plane *plane, *primary; + unsigned int planes_num = 2; unsigned int i; primary = tegra_primary_plane_create(drm, dc); if (IS_ERR(primary)) return primary; - for (i = 0; i < 2; i++) { - plane = tegra_dc_overlay_plane_create(drm, dc, 1 + i); + if (!dc->soc->supports_cursor) + planes_num--; + + for (i = 0; i < planes_num; i++) { + plane = tegra_dc_overlay_plane_create(drm, dc, 1 + i, false); if (IS_ERR(plane)) { /* XXX tegra_plane_destroy() */ drm_plane_cleanup(primary); @@ -1770,6 +1785,13 @@ static int tegra_dc_init(struct host1x_client *client) err = PTR_ERR(cursor); goto cleanup; } + } else { + /* trade overlay for RGBA cursor plane on older Tegra's */ + cursor = tegra_dc_overlay_plane_create(drm, dc, 2, true); + if (IS_ERR(cursor)) { + err = PTR_ERR(cursor); + goto cleanup; + } } err = drm_crtc_init_with_planes(drm, &dc->base, primary, cursor,