From patchwork Wed Dec 20 15:46:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10127193 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 348FE603B5 for ; Thu, 21 Dec 2017 09:02:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22F27298EB for ; Thu, 21 Dec 2017 09:02:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17E3B29B3F; Thu, 21 Dec 2017 09:02:51 +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 8B89E298EB for ; Thu, 21 Dec 2017 09:02:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0AAA86E5E4; Thu, 21 Dec 2017 09:00:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x244.google.com (mail-lf0-x244.google.com [IPv6:2a00:1450:4010:c07::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id D6E376E42B for ; Wed, 20 Dec 2017 15:50:14 +0000 (UTC) Received: by mail-lf0-x244.google.com with SMTP id m20so11455228lfi.6 for ; Wed, 20 Dec 2017 07:50:14 -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 :in-reply-to:references; bh=opOZF48hlCMkPHrh6WBxyWozmyM276LvGVo+P0smqwU=; b=rXPcYUjkOS08yHM6iipG2+NoC3BLSOXC+jW0GmBPkI31XBYqcUQJEuGvOEiDSrLWiJ WWfJATLFtte7AtJjFWem4SCYrma1VBISP91SWuqiXEbKYFHaXwRT+vb9bYAyLwaXsWZc t0NaeykdFScXm7E/bCTYF2Xh6AmpyL7j6jbECxK9UzhMw7euetzra1imst/NrRUvIZhD Xe5v9jbZ6h0jcetyOKPvmaiNGPPPvTpy9qgpZUlYZ+XwNmiTBaQNYDt+Lff4x//tEql4 Y2hwU4DN49t0xZ94hQd5NrSgwOeNfbc8xxVIkGKcQFYhQflZtcXSGryECdQ0+HgcJ+h1 BW7g== 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:in-reply-to:references; bh=opOZF48hlCMkPHrh6WBxyWozmyM276LvGVo+P0smqwU=; b=l9rTRMMZTBbUs8ebsSmxoh6vozRiervw+e8afzWyFghqfSjkWJRVLTjunHLYOJpBDJ yMqa1UonlHOnvtNlBBnkeJNXwOIDGoG4mZh5jm5rIwC0/90LnLaK1DQZw38D6xr8bGHM 6G2n7taSu05ICnbC/tlNp8/qPVGZ2t4OGD7JWH+XfBdHOmFh03Z8zgPfCVO9FmtXsv/c /wekPOoZzPf13ZTCouW+cixP+NxieloiinzefbU5xeN27x0qObK6s4F/s/xca3z0ncJN 0bu6wM4qiM7sp6ZWlY+IFDnE5uSrLDQqpiry5DViFZCtfcKpdcycu592uJD/AD9xGEmM PC3w== X-Gm-Message-State: AKGB3mL0NN+h6CQwU2ztiwRb7vZ9AVSgFj7Pn6cYmakHU1mrt0OAhr2Q YB/rwAwPR8sCFZQ/+ByOqus= X-Google-Smtp-Source: ACJfBouf1Srp53VeCv4yC2vRL1XRGle833q6OEQjF8Dnw655HB82uIhIf+YD+khwi5tU6lnfKHYAtg== X-Received: by 10.25.123.19 with SMTP id w19mr4841784lfc.78.1513785012948; Wed, 20 Dec 2017 07:50:12 -0800 (PST) Received: from localhost.localdomain (ppp109-252-55-194.pppoe.spdop.ru. [109.252.55.194]) by smtp.gmail.com with ESMTPSA id m18sm3685762lje.21.2017.12.20.07.50.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Dec 2017 07:50:12 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding Subject: [PATCH v3 2/5] drm/tegra: Restore opaque and drop alpha formats on Tegra20/30 Date: Wed, 20 Dec 2017 18:46:11 +0300 Message-Id: <0476e28d70b47ec599fb65d1cfa457276629de27.1513783738.git.digetx@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: References: In-Reply-To: References: X-Mailman-Approved-At: Thu, 21 Dec 2017 08:59:57 +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 Commit 7772fdaef939 ("drm/tegra: Support ARGB and ABGR formats") broke DRM's MODE_ADDFB IOCTL on Tegra20/30, because IOCTL uses XRGB format if requested FB depth is 24bpp. As a result, Xorg doesn't work anymore with both modesetting and opentegra drivers. On older Tegra's each plane has a blending configuration which should be used to enable / disable alpha blending and right now the blending configs are hardcoded to disabled alpha blending. In order to support alpha formats properly, planes blending configuration must be adjusted, until then the alpha formats are equal to non-alpha. Fixes: 7772fdaef939 ("drm/tegra: Support ARGB and ABGR formats") Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/dc.c | 29 ++++++++++++++++++----------- drivers/gpu/drm/tegra/dc.h | 1 + drivers/gpu/drm/tegra/fb.c | 13 ------------- drivers/gpu/drm/tegra/hub.c | 3 ++- drivers/gpu/drm/tegra/plane.c | 22 +++++++++++++++++----- drivers/gpu/drm/tegra/plane.h | 2 +- 6 files changed, 39 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index 5299185cea2f..460510366bb8 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -299,12 +299,12 @@ static void tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index, } static const u32 tegra20_primary_formats[] = { - DRM_FORMAT_ARGB4444, - DRM_FORMAT_ARGB1555, DRM_FORMAT_RGB565, - DRM_FORMAT_RGBA5551, - DRM_FORMAT_ABGR8888, - DRM_FORMAT_ARGB8888, + /* non-native formats */ + DRM_FORMAT_XRGB1555, + DRM_FORMAT_RGBX5551, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_XBGR8888, }; static const u32 tegra114_primary_formats[] = { @@ -369,7 +369,8 @@ static int tegra_plane_atomic_check(struct drm_plane *plane, err = tegra_plane_format(state->fb->format->format, &plane_state->format, - &plane_state->swap); + &plane_state->swap, + dc->soc->supports_opaque_formats); if (err < 0) return err; @@ -692,12 +693,12 @@ static struct drm_plane *tegra_dc_cursor_plane_create(struct drm_device *drm, } static const u32 tegra20_overlay_formats[] = { - DRM_FORMAT_ARGB4444, - DRM_FORMAT_ARGB1555, DRM_FORMAT_RGB565, - DRM_FORMAT_RGBA5551, - DRM_FORMAT_ABGR8888, - DRM_FORMAT_ARGB8888, + /* non-native formats */ + DRM_FORMAT_XRGB1555, + DRM_FORMAT_RGBX5551, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_XBGR8888, /* planar formats */ DRM_FORMAT_UYVY, DRM_FORMAT_YUYV, @@ -1854,6 +1855,7 @@ static const struct tegra_dc_soc_info tegra20_dc_soc_info = { .primary_formats = tegra20_primary_formats, .num_overlay_formats = ARRAY_SIZE(tegra20_overlay_formats), .overlay_formats = tegra20_overlay_formats, + .supports_opaque_formats = false, }; static const struct tegra_dc_soc_info tegra30_dc_soc_info = { @@ -1869,6 +1871,7 @@ static const struct tegra_dc_soc_info tegra30_dc_soc_info = { .primary_formats = tegra20_primary_formats, .num_overlay_formats = ARRAY_SIZE(tegra20_overlay_formats), .overlay_formats = tegra20_overlay_formats, + .supports_opaque_formats = false, }; static const struct tegra_dc_soc_info tegra114_dc_soc_info = { @@ -1884,6 +1887,7 @@ static const struct tegra_dc_soc_info tegra114_dc_soc_info = { .primary_formats = tegra114_primary_formats, .num_overlay_formats = ARRAY_SIZE(tegra114_overlay_formats), .overlay_formats = tegra114_overlay_formats, + .supports_opaque_formats = true, }; static const struct tegra_dc_soc_info tegra124_dc_soc_info = { @@ -1899,6 +1903,7 @@ static const struct tegra_dc_soc_info tegra124_dc_soc_info = { .primary_formats = tegra114_primary_formats, .num_overlay_formats = ARRAY_SIZE(tegra124_overlay_formats), .overlay_formats = tegra114_overlay_formats, + .supports_opaque_formats = true, }; static const struct tegra_dc_soc_info tegra210_dc_soc_info = { @@ -1914,6 +1919,7 @@ static const struct tegra_dc_soc_info tegra210_dc_soc_info = { .primary_formats = tegra114_primary_formats, .num_overlay_formats = ARRAY_SIZE(tegra114_overlay_formats), .overlay_formats = tegra114_overlay_formats, + .supports_opaque_formats = true, }; static const struct tegra_windowgroup_soc tegra186_dc_wgrps[] = { @@ -1961,6 +1967,7 @@ static const struct tegra_dc_soc_info tegra186_dc_soc_info = { .has_nvdisplay = true, .wgrps = tegra186_dc_wgrps, .num_wgrps = ARRAY_SIZE(tegra186_dc_wgrps), + .supports_opaque_formats = true, }; static const struct of_device_id tegra_dc_of_match[] = { diff --git a/drivers/gpu/drm/tegra/dc.h b/drivers/gpu/drm/tegra/dc.h index 8098f49c0d96..3a66a1127ee7 100644 --- a/drivers/gpu/drm/tegra/dc.h +++ b/drivers/gpu/drm/tegra/dc.h @@ -65,6 +65,7 @@ struct tegra_dc_soc_info { unsigned int num_primary_formats; const u32 *overlay_formats; unsigned int num_overlay_formats; + bool supports_opaque_formats; }; struct tegra_dc { diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c index 5f6289c4e56a..bd8c9da1ed0d 100644 --- a/drivers/gpu/drm/tegra/fb.c +++ b/drivers/gpu/drm/tegra/fb.c @@ -253,19 +253,6 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper, cmd.height = sizes->surface_height; cmd.pitches[0] = round_up(sizes->surface_width * bytes_per_pixel, tegra->pitch_align); - - /* - * Early generations of Tegra (Tegra20 and Tegra30) do not support any - * of the X* or *X formats, only their A* or *A equivalents. Force the - * legacy framebuffer format to include an alpha component so that the - * framebuffer emulation can be supported on all generations. - */ - if (sizes->surface_bpp == 32 && sizes->surface_depth == 24) - sizes->surface_depth = 32; - - if (sizes->surface_bpp == 16 && sizes->surface_depth == 15) - sizes->surface_depth = 16; - cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp, sizes->surface_depth); diff --git a/drivers/gpu/drm/tegra/hub.c b/drivers/gpu/drm/tegra/hub.c index f4911feda9ff..03298a1e87cc 100644 --- a/drivers/gpu/drm/tegra/hub.c +++ b/drivers/gpu/drm/tegra/hub.c @@ -332,7 +332,8 @@ static int tegra_shared_plane_atomic_check(struct drm_plane *plane, err = tegra_plane_format(state->fb->format->format, &plane_state->format, - &plane_state->swap); + &plane_state->swap, + true); if (err < 0) return err; diff --git a/drivers/gpu/drm/tegra/plane.c b/drivers/gpu/drm/tegra/plane.c index 326700cd0d80..345ec37c7481 100644 --- a/drivers/gpu/drm/tegra/plane.c +++ b/drivers/gpu/drm/tegra/plane.c @@ -103,7 +103,7 @@ int tegra_plane_state_add(struct tegra_plane *plane, return 0; } -int tegra_plane_format(u32 fourcc, u32 *format, u32 *swap) +int tegra_plane_format(u32 fourcc, u32 *format, u32 *swap, bool opaque_fmt) { /* assume no swapping of fetched data */ if (swap) @@ -147,11 +147,17 @@ int tegra_plane_format(u32 fourcc, u32 *format, u32 *swap) break; case DRM_FORMAT_XRGB1555: - *format = WIN_COLOR_DEPTH_B5G5R5X1; + if (opaque_fmt) + *format = WIN_COLOR_DEPTH_B5G5R5X1; + else + *format = WIN_COLOR_DEPTH_B5G5R5A; break; case DRM_FORMAT_RGBX5551: - *format = WIN_COLOR_DEPTH_X1B5G5R5; + if (opaque_fmt) + *format = WIN_COLOR_DEPTH_X1B5G5R5; + else + *format = WIN_COLOR_DEPTH_AB5G5R5; break; case DRM_FORMAT_XBGR1555: @@ -175,11 +181,17 @@ int tegra_plane_format(u32 fourcc, u32 *format, u32 *swap) break; case DRM_FORMAT_XRGB8888: - *format = WIN_COLOR_DEPTH_B8G8R8X8; + if (opaque_fmt) + *format = WIN_COLOR_DEPTH_B8G8R8X8; + else + *format = WIN_COLOR_DEPTH_B8G8R8A8; break; case DRM_FORMAT_XBGR8888: - *format = WIN_COLOR_DEPTH_R8G8B8X8; + if (opaque_fmt) + *format = WIN_COLOR_DEPTH_R8G8B8X8; + else + *format = WIN_COLOR_DEPTH_R8G8B8A8; break; case DRM_FORMAT_UYVY: diff --git a/drivers/gpu/drm/tegra/plane.h b/drivers/gpu/drm/tegra/plane.h index fc7566f630fa..27145d64ad90 100644 --- a/drivers/gpu/drm/tegra/plane.h +++ b/drivers/gpu/drm/tegra/plane.h @@ -55,7 +55,7 @@ extern const struct drm_plane_funcs tegra_plane_funcs; int tegra_plane_state_add(struct tegra_plane *plane, struct drm_plane_state *state); -int tegra_plane_format(u32 fourcc, u32 *format, u32 *swap); +int tegra_plane_format(u32 fourcc, u32 *format, u32 *swap, bool opaque_fmt); bool tegra_plane_format_is_yuv(unsigned int format, bool *planar); #endif /* TEGRA_PLANE_H */