Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1573395pxb; Sat, 29 Jan 2022 09:57:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUU/01oVgrzNU6TmJgPmmgb/zqyCzJt96MYGUVPyN5u2Q+FEjRuOtzNEnBeSO+c6R7Ydd6 X-Received: by 2002:a17:907:2485:: with SMTP id zg5mr9339797ejb.406.1643479037133; Sat, 29 Jan 2022 09:57:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643479037; cv=none; d=google.com; s=arc-20160816; b=UajuggPCR6xu0k2zJK7dTBezgLBd6ZaqyQI0F+D8URp8p13jz20l1qTBkR/KwzbHGK 7mTiv59vFKHh/tU0jjZHbrvtFAyhsqXWUAknQAN9VG7FlqGKpi7qStlFdj1taapbSXKR jWDvFCL69V24ZMUVgOTFzQti+sb/pE040kS/wIwel4laPhsekQx5I+s9SZuimZC7ug5V se3XDOXQNO/kLvf/8ssKQqwfyQcN+ZCjlEdk3eNPw8t6hN6+4Ptp0Lj7YN5NKrt1ht3w XDBWYsvDIBr0V/6RtoRe6oFhNHqNx+e02FPuor/S2AmrJFiiZAnbGbMtfv1TNGNq/+Ea ms9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9EzdZpZS4Z4IcY2FEqLzAsgmSU4/ecufEMUgyzjH9DI=; b=kz4ZPr7lbifrj5IPdh2OcByal3C7XjtLVYJLfp9pBZOwYIMDcByUnNt110rZ8ij2Ao PybN6QZbZdLQena9lLGHovXz52c23sXJmc2ppM66jEmF5q2mH34mXBN6Yuer+PgbGwSx vvc7BPgP8XH4Fd0R7k+LTXridXtR8ZDMcTs9TwGWG3JmQjRo8ZJOzPIhSu//zF8QziY8 ecOdhw4nAylICKx/eyTTdd4g38oxaVdw/xUBlvPlMZkhWo1YDCw6MgtqObv1lDzcogic zT0qHBff6jlmIRfBdmRCqDEMRE9p8ReokbcUu3PVyW/mbigBkxpotRYTDbtkOHrXWLxw EPbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@igel-co-jp.20210112.gappssmtp.com header.s=20210112 header.b=f1KfTjyj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n26si2717928edr.287.2022.01.29.09.56.51; Sat, 29 Jan 2022 09:57:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@igel-co-jp.20210112.gappssmtp.com header.s=20210112 header.b=f1KfTjyj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346313AbiA1GJM (ORCPT + 99 others); Fri, 28 Jan 2022 01:09:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346299AbiA1GJL (ORCPT ); Fri, 28 Jan 2022 01:09:11 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13183C061714 for ; Thu, 27 Jan 2022 22:09:11 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id r59so5555644pjg.4 for ; Thu, 27 Jan 2022 22:09:11 -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=9EzdZpZS4Z4IcY2FEqLzAsgmSU4/ecufEMUgyzjH9DI=; b=f1KfTjyjde3MGlrud7czWaI2aS8ME1vzCb9QYQASOs88grRoMJPZr8I6OowNxoI3Q0 N0YHyEDdHTP4AhLbcN9Uz1/qx3nr0/Ho4uzOYIUORaOR2GinK04vXj6uFPzibJYTXvzK KjJrr07KiH2Ir+a5x6ERoNy472hxzqef3fnImX3KStMfJQNnnSo5YzQLoNB3S3RTD275 WqFALl/KbnfIO9C2f9Q47r94tp1zlcFLzbUkW8dfH/My9yxzDRIOd2P7q/voBqtXRKL2 VQJ+tm8zYZNljyZFwlpFFl7CPHkxp3BAac7n7TE7dVLlCmwIB+ojG/haE9wV1aqUo8VR A+1A== 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=9EzdZpZS4Z4IcY2FEqLzAsgmSU4/ecufEMUgyzjH9DI=; b=mFK7m1/2ZgCFEFESIznVyK8hBT3+14coCrcumYGRlGsyRyG8yFgNRoNJdB2UISclqt mT8v9y2v2ogQ5vuaGpLhP+idRvtBueWu8SgVGyxEdLpF7KADWOpH+azYemvikFI6StA5 RInUYAazhyPFzzJA12vxCKYle6mdNmvgPPVvBmWgTirTGX9iJ5rh86GBDlmpB8iY1nO4 leQk/YYqNJrpRdj1Vx3CZ48pAiUuY94jtZNoNr6D00iwkBrKn5p3/l8tMnW5rCWegZts oZUIO5KpQs9fkBIGJ8tmD5w1zeRlvPqHpVxlWBioo/06aYD4yyq9knipK+qhoeFZA/e/ FBjw== X-Gm-Message-State: AOAM532NP4ZD90TvrkzUkzZ9BGGIhLUYoLJbThkHuVRABGHTgRiod6Aa JNMVHJz9xfmSa+/5jxO9l9Ibuw== X-Received: by 2002:a17:903:2446:: with SMTP id l6mr7240246pls.48.1643350150500; Thu, 27 Jan 2022 22:09:10 -0800 (PST) Received: from aqua.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id h5sm7743182pfi.111.2022.01.27.22.09.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 22:09:10 -0800 (PST) From: Tomohito Esaki To: dri-devel@lists.freedesktop.org Cc: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Ben Skeggs , =?UTF-8?q?Michel=20D=C3=A4nzer?= , Simon Ser , Qingqing Zhuo , Bas Nieuwenhuizen , Mark Yacoub , Sean Paul , Evan Quan , Andy Shevchenko , Petr Mladek , Sakari Ailus , Lee Jones , Abhinav Kumar , Dmitry Baryshkov , Rob Clark , amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, Daniel Stone , Laurent Pinchart , Tomohito Esaki , Damian Hobson-Garcia , Takanari Hayama Subject: [RFC PATCH v6 2/3] drm: add support modifiers for drivers whose planes only support linear layout Date: Fri, 28 Jan 2022 15:08:35 +0900 Message-Id: <20220128060836.11216-3-etom@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220128060836.11216-1-etom@igel.co.jp> References: <20220128060836.11216-1-etom@igel.co.jp> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The LINEAR modifier is advertised as default if a driver doesn't specify modifiers. v2: - rebase to the latest master branch (5.16.0+) + "drm/plane: Make format_mod_supported truly optional" patch [1] [1] https://patchwork.freedesktop.org/patch/467940/?series=98255&rev=3 v3: - change the order as follows: 1. add fb_modifiers_not_supported flag 2. add default modifiers 3. remove allow_fb_modifiers flag v5: - change default_modifiers array from non-static to static - remove terminator in default_modifiers array - use ARRAY_SIZE to get the format_modifier_count - update sanity check in plane init func to use the fb_modifiers_not_supported - modify kernel docs Signed-off-by: Tomohito Esaki Reviewed-by: Andy Shevchenko Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/drm_plane.c | 23 +++++++++++++---------- include/drm/drm_plane.h | 3 +++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index deeec60a3315..bf0daa8d9bbd 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -237,6 +237,9 @@ static int __drm_universal_plane_init(struct drm_device *dev, const char *name, va_list ap) { struct drm_mode_config *config = &dev->mode_config; + static const uint64_t default_modifiers[] = { + DRM_FORMAT_MOD_LINEAR, + }; unsigned int format_modifier_count = 0; int ret; @@ -277,16 +280,16 @@ 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 = ARRAY_SIZE(default_modifiers); + } } /* autoset the cap and check for consistency across all planes */ - if (format_modifier_count) { - drm_WARN_ON(dev, !config->allow_fb_modifiers && - !list_empty(&config->plane_list)); - config->allow_fb_modifiers = true; - } else { - drm_WARN_ON(dev, config->allow_fb_modifiers); - } + drm_WARN_ON(dev, config->fb_modifiers_not_supported && + format_modifier_count); plane->modifier_count = format_modifier_count; plane->modifiers = kmalloc_array(format_modifier_count, @@ -341,7 +344,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 +371,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. + * Drivers that only support the DRM_FORMAT_MOD_LINEAR modifier support may set + * @format_modifiers to NULL. The plane will advertise the linear modifier. * * Returns: * Zero on success, error code on failure. diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h index 0c1102dc4d88..a0390b6ad3b4 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. * + * Drivers that only support the DRM_FORMAT_MOD_LINEAR modifier support may set + * @format_modifiers to NULL. The plane will advertise the linear modifier. + * * Returns: * Pointer to new plane, or ERR_PTR on failure. */ -- 2.25.1