From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7BE7C433FE for ; Fri, 14 Jan 2022 18:43:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D372110E1F8; Fri, 14 Jan 2022 18:43:40 +0000 (UTC) Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by gabe.freedesktop.org (Postfix) with ESMTPS id DC2EB11213A for ; Thu, 13 Jan 2022 09:44:43 +0000 (UTC) Received: by mail-pl1-x636.google.com with SMTP id c3so8846662pls.5 for ; Thu, 13 Jan 2022 01:44:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ky2zKVWv+mMhs4J7OH2O/XxqaVlLO/dXHhtpRUox9mg=; b=2ZH3pGHASkNoRRW3yTj2gs92BdyBRnbNK7EOWNRr2p217WskEpz3ZawJyYbGwRENS2 vMGX0y2vgckUQbJ9vbH13jk0cwh/3yJoWJLe/o/FSFsQZYR/fm/HI6Xl2v9Y0JVUt21K R6X6RLp8BjThthOhgV7LfRvovvIn2RAf28l/48+klHURA9SOlvp18Ptm60y1nJuIWes3 gTagPWQTaTNH8luH6KNm+Y/kA6LjMn3ZVm7KQjtO77ob8sjLultWHYwYVr8R1bs5yLsF 9GwUIkQt/vKTCQo95rk4F0FN9PoipNIROxY1Ozx+F6lvwYpEm+hU+L67Orip/Mwq9zMR zaow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ky2zKVWv+mMhs4J7OH2O/XxqaVlLO/dXHhtpRUox9mg=; b=N8k6u/e0ofdyM3L2PQDIiGvZRjkPuOws5LJG0Y0gBd++uzKyFYR5vzF3lNW/nBzb8f jhfILBVsUvrbkiZhsov2rZRNmt2p1P9zL5iKspq4KpTqHhALjnGWBanYfIVBdhZHi7wM TQMM7N7QwsLIN+nZsOP0jq/yTVr55jSi7Ycz9FpdUXre+qlPQsy+CTG7U1Wacz05Cm8j pKGbqSp441BX1vdN2vbSGjfUwi6B2kQCTI/9Bh0Kb6LGu2Hbr7xBQizpu8G2yV6NVe9G /C+42sin2BRInEiGpedjeSf4+Y9HfbhJGWeKGxJi9HhNvB6VxH4WRkgi8lK6NlFUgJ/E Cr5A== X-Gm-Message-State: AOAM530523O5aDFzK6FHjeoczPE3NWDbycUIyCJtxlXBFBUpCVu2Xwm1 6PQRU39lg4J4JX2jntZMtadRyw== X-Google-Smtp-Source: ABdhPJyGNIs5iSBJFPyNrKFb9TvMjCxg99lbnYZnpLQQPnfs6LZ/38Pz/SGsgrLp596XqfMheTyGNg== X-Received: by 2002:aa7:9094:0:b0:4bd:8f39:236e with SMTP id i20-20020aa79094000000b004bd8f39236emr3414645pfa.35.1642067083412; Thu, 13 Jan 2022 01:44:43 -0800 (PST) Received: from aqua.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id rm4sm2207154pjb.4.2022.01.13.01.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jan 2022 01:44:42 -0800 (PST) From: Tomohito Esaki To: dri-devel@lists.freedesktop.org Date: Thu, 13 Jan 2022 18:44:17 +0900 Message-Id: <20220113094419.12433-2-etom@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220113094419.12433-1-etom@igel.co.jp> References: <20220113094419.12433-1-etom@igel.co.jp> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 14 Jan 2022 18:43:39 +0000 Subject: [Nouveau] [RFC PATCH v2 1/3] drm: add support modifiers for drivers whose planes only support linear layout X-BeenThere: nouveau@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Nouveau development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , nouveau@lists.freedesktop.org, =?UTF-8?q?Michel=20D=C3=A4nzer?= , Daniel Stone , Lee Jones , Tomohito Esaki , Rob Clark , Evan Quan , amd-gfx@lists.freedesktop.org, Ben Skeggs , Petr Mladek , Sakari Ailus , Bas Nieuwenhuizen , Maarten Lankhorst , Abhinav Kumar , Dmitry Baryshkov , Takanari Hayama , Sean Paul , Maxime Ripard , Daniel Vetter , Andy Shevchenko , Mark Yacoub , Qingqing Zhuo , "Pan, Xinhui" , linux-kernel@vger.kernel.org, Simon Ser , Alex Deucher , Damian Hobson-Garcia , =?UTF-8?q?Christian=20K=C3=B6nig?= , Laurent Pinchart Errors-To: nouveau-bounces@lists.freedesktop.org Sender: "Nouveau" The LINEAR modifier is advertised as default if a driver doesn't specify modifiers. However, there are legacy drivers such as radeon that do not support modifiers but infer the actual layout of the underlying buffer. Therefore, a new flag not_support_fb_modifires is introduced for these legacy drivers. Allow_fb_modifiers will be replaced with this new flag. Signed-off-by: Tomohito Esaki --- drivers/gpu/drm/drm_plane.c | 15 ++++++++++++--- include/drm/drm_mode_config.h | 10 ++++++++++ include/drm/drm_plane.h | 3 +++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index deeec60a3315..5aa7e241971e 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -237,6 +237,10 @@ static int __drm_universal_plane_init(struct drm_device *dev, const char *name, va_list ap) { struct drm_mode_config *config = &dev->mode_config; + const uint64_t default_modifiers[] = { + DRM_FORMAT_MOD_LINEAR, + DRM_FORMAT_MOD_INVALID + }; unsigned int format_modifier_count = 0; int ret; @@ -277,6 +281,11 @@ static int __drm_universal_plane_init(struct drm_device *dev, while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID) format_modifier_count++; + } else { + if (!dev->mode_config.fb_modifiers_not_supported) { + format_modifiers = default_modifiers; + format_modifier_count = 1; + } } /* autoset the cap and check for consistency across all planes */ @@ -341,7 +350,7 @@ static int __drm_universal_plane_init(struct drm_device *dev, drm_object_attach_property(&plane->base, config->prop_src_h, 0); } - if (config->allow_fb_modifiers) + if (format_modifier_count) create_in_format_blob(dev, plane); return 0; @@ -368,8 +377,8 @@ static int __drm_universal_plane_init(struct drm_device *dev, * drm_universal_plane_init() to let the DRM managed resource infrastructure * take care of cleanup and deallocation. * - * Drivers supporting modifiers must set @format_modifiers on all their planes, - * even those that only support DRM_FORMAT_MOD_LINEAR. + * For drivers supporting modifiers, all planes will advertise + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set. * * Returns: * Zero on success, error code on failure. diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 48b7de80daf5..c56f298c55bd 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -920,6 +920,16 @@ struct drm_mode_config { */ bool allow_fb_modifiers; + /** + * @fb_modifiers_not_supported: + * + * This flag is for legacy drivers such as radeon that do not support + * modifiers but infer the actual layout of the underlying buffer. + * Generally, each drivers must support modifiers, this flag should not + * be set. + */ + bool fb_modifiers_not_supported; + /** * @normalize_zpos: * diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h index 0c1102dc4d88..cad641b1f797 100644 --- a/include/drm/drm_plane.h +++ b/include/drm/drm_plane.h @@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev, * * The @drm_plane_funcs.destroy hook must be NULL. * + * For drivers supporting modifiers, all planes will advertise + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set. + * * Returns: * Pointer to new plane, or ERR_PTR on failure. */ -- 2.25.1