From patchwork Wed May 22 22:05:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13671134 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 B3EA2C25B7C for ; Wed, 22 May 2024 22:06:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 80AB910EF93; Wed, 22 May 2024 22:06:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="OALqkieN"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2074.outbound.protection.outlook.com [40.107.220.74]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5BFB910E3B8; Wed, 22 May 2024 22:05:59 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bso1TAE3uAaVX6Btjs92MJCe08QU14iklWaa7q+Sm0QeSPkqgUegMivZetzrUKNCWlrO6vCdHeWxcVm1D8EhOsoM+dAatKxMujEPxAHeXe2DIhhXH/4Tli1D8fmwhAtmt15XFa+HEuTqBwkgrTJimj2iVsvSMPhOvzlenZp8wVajlSgalmcweBZv9p15B/NUcs1DPyr9Gep1o6n0tB0pu1IEcqqgxPuS5ivAB7lnfhBfwGo/G4+z3bPfVflrNeQfJbDZkIatzEiZUG+7eI3ntvxCyDCVqEG6lnPgPf0CE6iPViJZ1kvJD3U7E2d2Hv80dvOdF3RgjgtzYqhgtbkh7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/Nf9tSBk3Y0t2tBanFLxTyexGIIoDStIS53kzjq38UA=; b=OY1tF+J/DUx2q4NT6Bv85kGk8Z0dHY/3VIAhYgueG5kIKGLawH5QmdTEMW1iP2H7PiBU9ZCaBODnzxgTdKwg1xNkJWcNCLvCsb7OeFcCNKu3A8NCkEW8RYJhIAPXrGRNz8eVRAoboCai+LdSEEz/A16eNfHOm43R0sBSc2kuVyTQMIhNK6jgT3L7s2nMrb/oj22d9sbxqbwV58pGGYIkDR71wKqZIKL8WtxHJU52Vj45jpb9L8yZa6jydzPa1P1jqZ4lyC7nKNMyc/bDQSptoZmrjBhvjg98Syo4egFvDgxFEAhNRN9LeyRKKLN3dIjKnWgdV4U7s1EQIz5XKj7viw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/Nf9tSBk3Y0t2tBanFLxTyexGIIoDStIS53kzjq38UA=; b=OALqkieNL/4A1pe/1e0IXjdvsp/BuGqvePXf2c2TqSyAZQbyMASLBCRw+j0krxiWONMP7D3fWHORE2sXgKcKw5wfTsdOTU0HOxVyfzpofytoRI7zBjcfW5y86VxfxYr++XBcvxXJW9fDM+AAdqDXedQRBofQhmZn8L5Y8fS6470= Received: from PH7P220CA0047.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::6) by CH2PR12MB4200.namprd12.prod.outlook.com (2603:10b6:610:ac::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36; Wed, 22 May 2024 22:05:54 +0000 Received: from MWH0EPF000A6731.namprd04.prod.outlook.com (2603:10b6:510:32b:cafe::36) by PH7P220CA0047.outlook.office365.com (2603:10b6:510:32b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20 via Frontend Transport; Wed, 22 May 2024 22:05:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A6731.mail.protection.outlook.com (10.167.249.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Wed, 22 May 2024 22:05:53 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 22 May 2024 17:05:51 -0500 From: Mario Limonciello To: , Simon Ser CC: Harry Wentland , Xaver Hugl , , Leo Li , Sean Paul , Mario Limonciello Subject: [PATCH v2 1/2] drm: Introduce 'power saving policy' drm property Date: Wed, 22 May 2024 17:05:30 -0500 Message-ID: <20240522220531.32728-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522220531.32728-1-mario.limonciello@amd.com> References: <20240522220531.32728-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6731:EE_|CH2PR12MB4200:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d11c14b-424c-4cf5-c208-08dc7aab5975 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|1800799015|376005|82310400017|36860700004; X-Microsoft-Antispam-Message-Info: omi0JkuEGgcV1REVFZMSJoyBUvQrMc+e4y2IRLlxtaOd1cJAmFlkbaTQn/bhEhz5RLK6s55/8aZwsoXvC7qVYPRBaiVoKh7PgDRQv5fMTKfFTReyEgP9givNE/vCiZ/kyJGmspRXExyNMgPkD5JkpAmAZ7QSSMMIV7l60tRaus6XUmOjGnZ8KbNU06Gymj34CnL3Ehls+1NX6RTrgoMZ6uRijxrgrGNTm88cKs0ZsCT0A4+2qIQeMq1zkg+HrrT1rZ/yqEMrcVYxoH9NgobpLHNVEth6KTDdaXcIl938qI2iYcj34s0WjCopFCLmfMUxMZuYnB88zDtrpoh2Gn6QhsNSKa+S6ISqVES0FScQEj3kP/vWRDX/qnwbVhm6Y3L9Xqhhmbuw+PsiV5qoR4tjPmqSv7K1Da/CWPYLB2hYgPuPzi7oPepw9D/NvxGmeSVfjV37L2ooU1IMfoscHowCsvaq9eOSzpbF4ZJ80eMu14Wi5hAflfG7tuKhrkaXLlEcivKEKR6OpBovDj47ZejC/Py1roz066+w+wU9w4pI0PgwdEM0tkH9p9GaU6BF42u21XP9IS+U+FhVtc1Lz0SdZbBVrdg53tvadLU6k40MjSF/FR9+8zo71DAqrMaJTA1ywbJnzeMpdL8Q7iuCXqq9nVktI8CK3PTPtsLFHqfIfZ5yI7ld7WQidFisQRLteAnxhZenbKWWcWox3w2JulrJFkM5RTBiNbn0XvngbfbuVHc6HmVJq/zzFv3MfMHoh54Nu6wW3/0JbVt8uDMfI0RTnfiFZdTL1D5EjR/GHB3tu4/KWI+68EZT89f8TztzrWXC7ciJzs4IfySIlGI5cTQ9lAgttfL8osNQnSGFVIjqcDC3r7NIokywAFVOrUnsHGEBUBA1wCPAZuQaOzwQ85v6zYViVDuUpTFVTGQqLFlFJb1VNpvaHWBl0m0aVZ2lxOsDjOfVYEQ0xpA7WXAY/PmPmqJzM7yQCyQ3vJEzk40n2C/fKpu3FK9K3jgqSPvO7Iz6QQ9ZpixO3cMbVkow0ElpqepKQAxi6FLTwqG6+9wfvTpqEWj+zRDyx62FvQLhQn1lN0ZBvCeSSa43syzFAdvT/egvbFHC6OCXMXYlrh2Ich0B36O/6R+mZMEYoSyb2aZ8mgeapKLw1Wby8QX+EOY61U6fatXuIJ3hyyYfu79OavhuKz2qSjNfy4/Tbn5hdPJF4nDQxQrXVuDbjWtqNYWPkvF1f1asPPkCLJKPMIaxiySnMFTTkqiC3F1WboEK5g2oFOoKaeW4341ApAKWL4iMaozFzHh1zwuPDV52a9df6oaGktOYGsNfoL5h1wwiMmJUeeaevzkyopwizH4y8kCjGQfnybuIj/Q5ie3rlJK6NE25vP9j/8ASy2g7kAh8HVer X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(1800799015)(376005)(82310400017)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2024 22:05:53.7091 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1d11c14b-424c-4cf5-c208-08dc7aab5975 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6731.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4200 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The `power saving policy` DRM property is an optional property that can be added to a connector by a driver. This property is for compositors to indicate intent of policy of whether a driver can use power saving features that may compromise the experience intended by the compositor. Signed-off-by: Mario Limonciello Acked-by: Leo Li --- drivers/gpu/drm/drm_connector.c | 46 +++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 2 ++ include/drm/drm_mode_config.h | 5 ++++ include/uapi/drm/drm_mode.h | 7 +++++ 4 files changed, 60 insertions(+) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 4d2df7f64dc5..088a5874c7a4 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -961,6 +961,11 @@ static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] = { { DRM_MODE_SCALE_ASPECT, "Full aspect" }, }; +static const struct drm_prop_enum_list drm_power_saving_policy_enum_list[] = { + { __builtin_ffs(DRM_MODE_REQUIRE_COLOR_ACCURACY) - 1, "Require color accuracy" }, + { __builtin_ffs(DRM_MODE_REQUIRE_LOW_LATENCY) - 1, "Require low latency" }, +}; + static const struct drm_prop_enum_list drm_aspect_ratio_enum_list[] = { { DRM_MODE_PICTURE_ASPECT_NONE, "Automatic" }, { DRM_MODE_PICTURE_ASPECT_4_3, "4:3" }, @@ -1499,6 +1504,16 @@ static const u32 dp_colorspaces = * * Drivers can set up these properties by calling * drm_mode_create_tv_margin_properties(). + * power saving policy: + * This property is used to set the power saving policy for the connector. + * This property is populated with a bitmask of optional requirements set + * by the drm master for the drm driver to respect: + * - "Require color accuracy": Disable power saving features that will + * affect color fidelity. + * For example: Hardware assisted backlight modulation. + * - "Require low latency": Disable power saving features that will + * affect latency. + * For example: Panel self refresh (PSR) */ int drm_connector_create_standard_properties(struct drm_device *dev) @@ -1963,6 +1978,37 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev) } EXPORT_SYMBOL(drm_mode_create_scaling_mode_property); +/** + * drm_mode_create_power_saving_policy_property - create power saving policy property + * @dev: DRM device + * @supported_policies: bitmask of supported power saving policies + * + * Called by a driver the first time it's needed, must be attached to desired + * connectors. + * + * Returns: %0 + */ +int drm_mode_create_power_saving_policy_property(struct drm_device *dev, + uint64_t supported_policies) +{ + struct drm_property *power_saving; + + if (dev->mode_config.power_saving_policy) + return 0; + WARN_ON((supported_policies & DRM_MODE_POWER_SAVING_POLICY_ALL) == 0); + + power_saving = + drm_property_create_bitmask(dev, 0, "power saving policy", + drm_power_saving_policy_enum_list, + ARRAY_SIZE(drm_power_saving_policy_enum_list), + supported_policies); + + dev->mode_config.power_saving_policy = power_saving; + + return 0; +} +EXPORT_SYMBOL(drm_mode_create_power_saving_policy_property); + /** * DOC: Variable refresh properties * diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index fe88d7fc6b8f..b0ec2ec48de7 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -2025,6 +2025,8 @@ int drm_mode_create_dp_colorspace_property(struct drm_connector *connector, u32 supported_colorspaces); int drm_mode_create_content_type_property(struct drm_device *dev); int drm_mode_create_suggested_offset_properties(struct drm_device *dev); +int drm_mode_create_power_saving_policy_property(struct drm_device *dev, + uint64_t supported_policies); int drm_connector_set_path_property(struct drm_connector *connector, const char *path); diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 973119a9176b..32077e701e2f 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -954,6 +954,11 @@ struct drm_mode_config { */ struct drm_atomic_state *suspend_state; + /** + * @power_saving_policy: bitmask for power saving policy requests. + */ + struct drm_property *power_saving_policy; + const struct drm_mode_config_helper_funcs *helper_private; }; diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 7040e7ea80c7..c2c86623552c 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -152,6 +152,13 @@ extern "C" { #define DRM_MODE_SCALE_CENTER 2 /* Centered, no scaling */ #define DRM_MODE_SCALE_ASPECT 3 /* Full screen, preserve aspect */ +/* power saving policy options */ +#define DRM_MODE_REQUIRE_COLOR_ACCURACY BIT(0) /* Compositor requires color accuracy */ +#define DRM_MODE_REQUIRE_LOW_LATENCY BIT(1) /* Compositor requires low latency */ + +#define DRM_MODE_POWER_SAVING_POLICY_ALL (DRM_MODE_REQUIRE_COLOR_ACCURACY |\ + DRM_MODE_REQUIRE_LOW_LATENCY) + /* Dithering mode options */ #define DRM_MODE_DITHERING_OFF 0 #define DRM_MODE_DITHERING_ON 1 From patchwork Wed May 22 22:05:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13671133 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 A30E9C25B7C for ; Wed, 22 May 2024 22:06:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4EE4410EC1A; Wed, 22 May 2024 22:06:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="c52Zf0IF"; dkim-atps=neutral Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2085.outbound.protection.outlook.com [40.107.96.85]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6EEFD10EC1A; Wed, 22 May 2024 22:06:00 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LevrCwe29hnKmK405ykNUUUkmjDetZ4TF1Vu34JyWyxtSuW+02Luc65xYbyf1igcQGWSJZIf0aFheQwIKyP2RchMpDmmkLIe2iaWI/eqM1jnIwZMn4gS6/mLPw2dp00woPby6y1NT/CFazbntE3KTqNHHV5iORDbUKZv+ljUsc41JMsqLQXwp5CbD51aXTMCAgu7o3msD2N3rSduLVk0CDkyDZjuSln9aWsxucOF6lFArNmZCIqOnqcF3/YzF6v4RxSoUylKsWjE1xgl6tUpYJ5FzRz/d8OeZ0a7gfmZ/swUxEg/g8TBJ9qDdmLiPDWWwLaScAYl6UfIBGDSzzLZXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YQDATGlcKoK1MbJii9dTWt/cKbD7zWps+qg3FXvEQ8E=; b=PRGMdJjMj9rO05XqcxRIbFPYWBfrT5T2vAqojHFPSwlDKYzUkLDhtpRD48X9NDxDJY/EfhPJEptMfRHXAFslyzx4jOexs7OtaatYkr2LHhZtxcY3D9+XuHZCXXo3M744AisXOlY1vp5/tJlhn1sLH86lbZwSos2gCjNNhnKpbHXaPaez0F+U6/kcak+eIpMzqvneqIOChSIkGPALvc6jqCK2yEaj5+qNgA5yEnMDf8DXN9MdHLpqxmOS8GixgeDDxQ61w4hZk8w+zHRAZja45x6kJ7T6qwDWNkDnn3p9pQv/+DPOgefKoHTincq2xD5g8fZZes3RzB3pfP6NTp7fyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YQDATGlcKoK1MbJii9dTWt/cKbD7zWps+qg3FXvEQ8E=; b=c52Zf0IF21JV8sPp5VHxfnakILG9MGsG36qmHvtntn1ndXDhb+3eNjMf+m6Z5Tg8YayibX3LJbH9HbAGz+PAg7RRhTtazqJJ+BG1jJUJAejf42f25zYJlZ3xTWielXK7E3gxDO37/ul6KALXCwBpfNI1t1JdXxbsyDfY6eYlPAw= Received: from PH7P220CA0046.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::10) by IA0PR12MB7649.namprd12.prod.outlook.com (2603:10b6:208:437::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36; Wed, 22 May 2024 22:05:55 +0000 Received: from MWH0EPF000A6731.namprd04.prod.outlook.com (2603:10b6:510:32b:cafe::f5) by PH7P220CA0046.outlook.office365.com (2603:10b6:510:32b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.19 via Frontend Transport; Wed, 22 May 2024 22:05:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A6731.mail.protection.outlook.com (10.167.249.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Wed, 22 May 2024 22:05:55 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 22 May 2024 17:05:52 -0500 From: Mario Limonciello To: , Simon Ser CC: Harry Wentland , Xaver Hugl , , Leo Li , Sean Paul , Mario Limonciello Subject: [PATCH v2 2/2] drm/amd: Add power_saving_policy drm property to eDP connectors Date: Wed, 22 May 2024 17:05:31 -0500 Message-ID: <20240522220531.32728-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522220531.32728-1-mario.limonciello@amd.com> References: <20240522220531.32728-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6731:EE_|IA0PR12MB7649:EE_ X-MS-Office365-Filtering-Correlation-Id: 4dabfb93-d598-4223-0759-08dc7aab5a3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|82310400017|376005|1800799015|36860700004; X-Microsoft-Antispam-Message-Info: SgDpZHqtvhy3R5N19UTopCEPYpvOCRuaLbweYvQxRpHhzLSkLNk0+lO1GGIiOP9reWp5a6gYFOocgKPdK+WK/1sHWU7xlVznccjSLKZpEp8ODV9Y/QgCrThYNQxUQQ9bsR2VlOmkY9OKkhFbiVXo8Y53+z/Bf1ZpxS2Dk8rUo4yojT/7+AdADc/e8Rjuh4/7LzJpiiOW2+4/teqgVJKNjHg8/svIY/jN0xiJTitH9CrJGF6h4/htBgAZGz+D83Ojn/NPM9AJ8vbN+ZalmdEVUtOSHVd2OtorJcLTxD+oDeMAdMNTJQAfEzxQE+VPp8XOQphYvBnTYlKL03QxBwPUIpa+ETreuWqsLMF1scEAy3aCmgV1tSQLOUFJjwf7aUPifXDrOHbfIDbmzb6gpQxIciqD+tfc/d2REa0J+R6+3ZhfOZR7F3KBu7spwr+rjbQLEAWghivfuUBAkzBlAOYme4hViWkQwJUvqi42yxKmIemyTAB71niB13cWJTZZLZyFIrztSU4gmidnkHaVRkL4hWHIeWm9a2hHd8I0zSGuV+oxr2eudzhetioGKukIA4e8Y6Aryu9ZtvJdRlQPvDVkiWSToANH+LP8bWUXmObJCYmT+RKEr0F0hGDp3kWbHO/3NKAvpEdB+Cb/EfK57RYzJAUUDdaZGWYMZUmsNk6t5h30eWpCFPSwJuz+x56BY4MMlxB2nUv4RYduenipUDof/gG0AFmymEMzBLBTM9yWdex7AJ4f8AkqboZMpdLYOBaEkMnDn8j2JfhXFg5/SY7CO7lVvmJ7DuVFpIWUtQUisjGtCoQ52r+hj34XEZV3x/a+LQREXV0KV+emN5nrLREgoXGoehOkeL5W7chqG2VvmNXNmEzQAF0EAdCiikAo/Zl8pTv3m/wJayg2MFaixBR1/zLiYY/n0mMhzG5Aail2g2zjE8OEML6aIo5kN5WgA28eYzlZ1nxtZELmcZAs5VO/reMR/mpowiMv63c/amYxA+BGzwvv3dsoEt/ACqadDav1u4atkxH9XCsK1iDtM8NjWxy/Uau2tOSHNl5BUFWxeAztmiWYNZsmHEuSADKmQxs/5SP7xi76xrTyLNF5CizBVYNvB9RC3lSpnFcCAcnWhnJZSy97JX3Ie63DIRe3s5epmq+c1D7dHZonWZlF5LcZzHUIC/xCyvEVt/vamNJYPehTi9EUFJS0JhNkQNTHBNAvGbRZW+/Ev56raJxo70kjMHtocdZpmU1Mjkpz1ZVgh/cQ0JNUEZhahrKCPU5xii5Ekf82EwMNycuHvvFYezcYq1sQufp8GpvLqYO/priYQVA6HWhI0VbaVIZ7YjRPMjcTgtMfeOSxM5eWaWhYaoIaZ5cog0zRpVelxZCAuyc9BHM= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(82310400017)(376005)(1800799015)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2024 22:05:55.0216 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4dabfb93-d598-4223-0759-08dc7aab5a3e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6731.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7649 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When the `power_saving_policy` property is set to bit mask "Require color accuracy" ABM should be disabled immediately and any requests by sysfs to update will return an -EBUSY error. When the `power_saving_policy` property is set to bit mask "Require low latency" PSR should be disabled. When the property is restored to an empty bit mask the previous value of ABM and pSR will be restored. Signed-off-by: Mario Limonciello --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 ++ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 51 +++++++++++++++++-- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 2 + 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 3ecc7ef95172..cfb5220cf182 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c @@ -1350,6 +1350,10 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev) "dither", amdgpu_dither_enum_list, sz); + if (adev->dc_enabled) + drm_mode_create_power_saving_policy_property(adev_to_drm(adev), + DRM_MODE_POWER_SAVING_POLICY_ALL); + return 0; } diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 01b0a331e4a6..a480e86892de 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -6421,6 +6421,13 @@ int amdgpu_dm_connector_atomic_set_property(struct drm_connector *connector, } else if (property == adev->mode_info.underscan_property) { dm_new_state->underscan_enable = val; ret = 0; + } else if (property == dev->mode_config.power_saving_policy) { + dm_new_state->abm_forbidden = val & DRM_MODE_REQUIRE_COLOR_ACCURACY; + dm_new_state->abm_level = (dm_new_state->abm_forbidden || !amdgpu_dm_abm_level) ? + ABM_LEVEL_IMMEDIATE_DISABLE : + amdgpu_dm_abm_level; + dm_new_state->psr_forbidden = val & DRM_MODE_REQUIRE_LOW_LATENCY; + ret = 0; } return ret; @@ -6463,6 +6470,13 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector, } else if (property == adev->mode_info.underscan_property) { *val = dm_state->underscan_enable; ret = 0; + } else if (property == dev->mode_config.power_saving_policy) { + *val = 0; + if (dm_state->psr_forbidden) + *val |= DRM_MODE_REQUIRE_LOW_LATENCY; + if (dm_state->abm_forbidden) + *val |= DRM_MODE_REQUIRE_COLOR_ACCURACY; + ret = 0; } return ret; @@ -6489,9 +6503,12 @@ static ssize_t panel_power_savings_show(struct device *device, u8 val; drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); - val = to_dm_connector_state(connector->state)->abm_level == - ABM_LEVEL_IMMEDIATE_DISABLE ? 0 : - to_dm_connector_state(connector->state)->abm_level; + if (to_dm_connector_state(connector->state)->abm_forbidden) + val = 0; + else + val = to_dm_connector_state(connector->state)->abm_level == + ABM_LEVEL_IMMEDIATE_DISABLE ? 0 : + to_dm_connector_state(connector->state)->abm_level; drm_modeset_unlock(&dev->mode_config.connection_mutex); return sysfs_emit(buf, "%u\n", val); @@ -6515,10 +6532,16 @@ static ssize_t panel_power_savings_store(struct device *device, return -EINVAL; drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); - to_dm_connector_state(connector->state)->abm_level = val ?: - ABM_LEVEL_IMMEDIATE_DISABLE; + if (to_dm_connector_state(connector->state)->abm_forbidden) + ret = -EBUSY; + else + to_dm_connector_state(connector->state)->abm_level = val ?: + ABM_LEVEL_IMMEDIATE_DISABLE; drm_modeset_unlock(&dev->mode_config.connection_mutex); + if (ret) + return ret; + drm_kms_helper_hotplug_event(dev); return count; @@ -7689,6 +7712,13 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm, aconnector->base.state->max_bpc = 16; aconnector->base.state->max_requested_bpc = aconnector->base.state->max_bpc; + if (connector_type == DRM_MODE_CONNECTOR_eDP && + (dc_is_dmcu_initialized(adev->dm.dc) || + adev->dm.dc->ctx->dmub_srv)) { + drm_object_attach_property(&aconnector->base.base, + dm->ddev->mode_config.power_saving_policy, 0); + } + if (connector_type == DRM_MODE_CONNECTOR_HDMIA) { /* Content Type is currently only implemented for HDMI. */ drm_connector_attach_content_type_property(&aconnector->base); @@ -9344,6 +9374,11 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) stream_update.hdr_static_metadata = &hdr_packet; } + if (dm_old_con_state->psr_forbidden && !dm_new_con_state->psr_forbidden) + amdgpu_dm_psr_disable(dm_new_crtc_state->stream); + else if (!dm_old_con_state->psr_forbidden && dm_new_con_state->psr_forbidden) + amdgpu_dm_psr_enable(dm_new_crtc_state->stream); + status = dc_stream_get_status(dm_new_crtc_state->stream); if (WARN_ON(!status)) @@ -10019,6 +10054,12 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm, update_stream_scaling_settings( &new_crtc_state->mode, dm_new_conn_state, dm_new_crtc_state->stream); + + if (dm_old_conn_state->psr_forbidden && !dm_new_conn_state->psr_forbidden) + amdgpu_dm_psr_disable(dm_new_crtc_state->stream); + else if (!dm_old_conn_state->psr_forbidden && dm_new_conn_state->psr_forbidden) + amdgpu_dm_psr_enable(dm_new_crtc_state->stream); + /* ABM settings */ dm_new_crtc_state->abm_level = dm_new_conn_state->abm_level; diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h index 09519b7abf67..b246e82f5b0d 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h @@ -873,6 +873,8 @@ struct dm_connector_state { bool underscan_enable; bool freesync_capable; bool update_hdcp; + bool abm_forbidden; + bool psr_forbidden; uint8_t abm_level; int vcpi_slots; uint64_t pbn;