From patchwork Sun Dec 17 17:25:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10118439 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 6340460390 for ; Mon, 18 Dec 2017 08:38:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 509C028903 for ; Mon, 18 Dec 2017 08:38:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45616288C5; Mon, 18 Dec 2017 08:38:10 +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 BC043288C5 for ; Mon, 18 Dec 2017 08:38:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 907EF89BF5; 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-x244.google.com (mail-lf0-x244.google.com [IPv6:2a00:1450:4010:c07::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC5F189C6A for ; Sun, 17 Dec 2017 17:28:01 +0000 (UTC) Received: by mail-lf0-x244.google.com with SMTP id r143so15328992lfe.13 for ; Sun, 17 Dec 2017 09:28:01 -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=A0orc9JihH1MdWAGHzGx1OepRtWbHrgsJkpXPT8beRE=; b=pjS+WyYFaYRLlI1I4np0Mc7N/RgxJDG0Ma3iXWbDVEZsX0e85S0iMRY56XDVwCwA0g qWVTybn1dnV0BeSQyWUcDfbkPwpuy3SfNtz0BqNsltQrWJ6IHNJBsV3ZReumT62BQmEI iTx5QtB/w0eVBciCnpo6anR8NeFL3cqoNz+Hz+FYNDeZgjfSpT9FFYdtvcYwCT0ml/1t z+jjVx7f8ol73drE9oA5t1o8u3mWJTmPS5aJ0IZci3p0V3VDKN7ZfVjxtkVKTIewbyYI /IyZij0EyFeoCYXbtd5Rq5Ttw2ZzZMNZsvcNfMYEPHxKVBd2BRqo8kd+O8gw2CcPzO22 1bsQ== 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=A0orc9JihH1MdWAGHzGx1OepRtWbHrgsJkpXPT8beRE=; b=P1QaztIYmRzXSCUUvmhpBB2bDCuVsx+oceacl0SbdcAaxcmrs6zObpWH8SUo2+25VJ jKp/IrE07bR0JA3bC7JvyasbZN0f298qxmv8IBsDKyrvAzDatTDOy5AA5rfMxwp9utjU ERUIYIZFUMKT+Qj+DZJnj0J8tdvyPMMDbwvIgsn6HEgJOJul8En+0ut19902VejrX954 FbSxyT5sjRvxwY6Hi2Wkgj80stbXgZDWPeE5Rsv8XrnOfqmiWBw2ECNQ/JHyP0pWOKFR ndvaTMYvnXHebl5Ghy7PlF2GAax7yio07xGuNCCul1ivSINaEQnvALBb9Y+tY1/k3tXY fCsg== X-Gm-Message-State: AKGB3mL0lqao+yIjiIsSVTr5mALkhBprno1poV0fnpMxU4UKpiWXwdEf 3ygo5bvyYPxXW3Wjw0TZ7Pfk0sJQ X-Google-Smtp-Source: ACJfBotBW98iRXuJT982fe9YRzwwm51PfMbPf+JDSO0EXKpUxiE8fDF3l/eDa5ipIVRMLRkCUA2IPw== X-Received: by 10.46.117.28 with SMTP id q28mr9342263ljc.14.1513531680380; Sun, 17 Dec 2017 09:28:00 -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.27.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Dec 2017 09:27:59 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding Subject: [PATCH v1] drm/tegra: Restore opaque formats on Tegra20/30 Date: Sun, 17 Dec 2017 20:25:44 +0300 Message-Id: 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 Commit 7772fdaef939 ("drm/tegra: Support ARGB and ABGR formats") broke DRM's MODE_ADDFB IOCTL on Tegra20/30, because it uses XRGBA format if requested FB depth is 24bpp. As a result, Xorg doesn't work anymore with both modesetting and opentegra drivers. On all 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 with alpha blending being disabled. 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 | 19 ++++++++++++++++++- 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(+), 21 deletions(-) diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index be84c36ad81f..7e58143f4145 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -305,6 +305,11 @@ static const u32 tegra20_primary_formats[] = { 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 +374,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; @@ -698,6 +704,11 @@ static const u32 tegra20_overlay_formats[] = { 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, @@ -1848,6 +1859,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 = { @@ -1863,6 +1875,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 = { @@ -1878,6 +1891,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 = { @@ -1893,6 +1907,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 = { @@ -1908,6 +1923,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[] = { @@ -1955,6 +1971,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 cccd44711d68..68c31fd7fd91 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 */