Message ID | 20240202152837.7388-1-hamza.mahfooz@amd.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-50021-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp504917dyc; Fri, 2 Feb 2024 07:29:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPbTvpepKcrfiii12DgpNLyvva+yzj5MtZCZF3POCEDHO2ZBxbRggp9SZszlaJWGUkDVXW X-Received: by 2002:a05:6871:7a11:b0:210:d74e:9d0d with SMTP id pc17-20020a0568717a1100b00210d74e9d0dmr8721830oac.57.1706887786616; Fri, 02 Feb 2024 07:29:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUV37612z9hPhFocy15ZH49zYBQjRogoMm34vRBwjnWMbWrt1N6evutU5PpKjrPUUHl0tsSRyKynry4FQzGzwcnlbZQGg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bp37-20020a05622a1ba500b0042c0b72fb09si49480qtb.139.2024.02.02.07.29.46 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 07:29:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50021-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=m1jE29Dx; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-50021-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50021-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5698F1C22054 for <ouuuleilei@gmail.com>; Fri, 2 Feb 2024 15:29:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E80581474AC; Fri, 2 Feb 2024 15:29:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="m1jE29Dx" Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2083.outbound.protection.outlook.com [40.107.237.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B5C11468F0 for <linux-kernel@vger.kernel.org>; Fri, 2 Feb 2024 15:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706887753; cv=fail; b=J5qUlNGoTBsBrk4jj5QRLd3KzBuLpmJ0QqQd8G3HoyHLnMZ+p/FD4T0mbIHqx2MzWfiyKf5cM94ZLqgJzLfLP/aiBaxSjGn+FIxMGhzkIHBM/6NK0DuokzBB5coRYM79ehcOotvsC1A+kMMegIHsNWjj4W7sWnfGhDI4zRKNyBo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706887753; c=relaxed/simple; bh=iqugAU5W7XDUwANq4GvSVtPdFvrGMIsbGQkaVhr8uoo=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=rOIfZCOd+7Q0C46dmSZkDgx0CgA0IB6G969GnaKNwgir7AI7h8VE+BZsiix6JwsQhbCvY/W7Z6bsrW7dH3tES01wAajCrUjqWUw/yPD/wAdb5lya2EHYeOEe6YjeIQoj2CkfB+liRQeZ0qMj/1vyLWrbSmDMTASI1Jzpy0Gc6Uc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=m1jE29Dx; arc=fail smtp.client-ip=40.107.237.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e8nJvqO4b/nFYGYHcdynQ0g6IJXzs6t326AaJrHlGpEJkdS916jo5jQJsfbI1NPJC0VOdBllLxsUQSJm5U4XfgoFwAER6sse14oncISiheUlxTsNBictq6eEM8AJhNYmQBZ1ITkgQakEr/EYKwMqD7F4ny923NIxBb23TST1dzyDvyKjeayspFu4u/sTKtxUkUemFkrFCZxiX/FUCbbftVBHBKEq8uLlbk7/UULwB04LPJ5trK3gSe4F7zI6hGaDgbnscCzceY2SJ7X3pnimHeiZix/1+64vO2IOM+MuygyagyqpCE9Ehxj26HSrv7oXMy47fplDjAsplNJqsP2nOA== 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=UYWODiTtYOch6HfYrBMmvBJk+iOEDVwPN5IDcHkhyZo=; b=cu9ijXFFTJHzbZ0CtYSd6EcQ08NnWB9LJ/fz/a1ke56GDQnf7FwCxMzUH0m8wbJzzQoulwjQfHbC4ARfLUxdKMq6eQPay1AnL4HGhiQpzCtMBdzq4/taWLmHPl30PqClWZ7vS7aeauqxXfK+puQbWs/MMRStCfleJGt9OYbauoSX/iD7A+snhpAiMGuno5LK99ufPksn+ZQjlj3dKgAGDvpmB0GvL/TvNA3sOyrkHKGhBW6ufJVa5h2nVtlwMcKu2H6p9tkVeOx7gpcJcZDj6UCQoxclkikCXzwb6Qom3ROf9VI75jlNNfM2uATqocEMRnRem12q5bMUMApIGRLGQQ== 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=UYWODiTtYOch6HfYrBMmvBJk+iOEDVwPN5IDcHkhyZo=; b=m1jE29DxtW0xcEeuR3zjvD4w1z687ix9epiC95sSgHkVwppknnK2EQfXRtjr1sCDLzq1afd1UUUsfFtgVPeR/UfbWzUjCiOHSl+YxFl20/piHYmH/hQJ078bzBRClwzNbGwXPvtNIWfjZS7kRUmQQbVYtUWJ6I6GloTSlOeiQSg= Received: from SJ0PR05CA0057.namprd05.prod.outlook.com (2603:10b6:a03:33f::32) by IA1PR12MB6530.namprd12.prod.outlook.com (2603:10b6:208:3a5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.11; Fri, 2 Feb 2024 15:29:07 +0000 Received: from SJ5PEPF000001CD.namprd05.prod.outlook.com (2603:10b6:a03:33f:cafe::6c) by SJ0PR05CA0057.outlook.office365.com (2603:10b6:a03:33f::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.23 via Frontend Transport; Fri, 2 Feb 2024 15:29:06 +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 SJ5PEPF000001CD.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Fri, 2 Feb 2024 15:29:06 +0000 Received: from hamza-pc.localhost (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.34; Fri, 2 Feb 2024 09:29:04 -0600 From: Hamza Mahfooz <hamza.mahfooz@amd.com> To: <amd-gfx@lists.freedesktop.org> CC: Hamza Mahfooz <hamza.mahfooz@amd.com>, Mario Limonciello <mario.limonciello@amd.com>, Harry Wentland <harry.wentland@amd.com>, Leo Li <sunpeng.li@amd.com>, Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>, "Alex Deucher" <alexander.deucher@amd.com>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>, "Pan, Xinhui" <Xinhui.Pan@amd.com>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Alex Hung <alex.hung@amd.com>, Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>, Wayne Lin <wayne.lin@amd.com>, <dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH v2] drm/amd/display: add panel_power_savings sysfs entry to eDP connectors Date: Fri, 2 Feb 2024 10:28:35 -0500 Message-ID: <20240202152837.7388-1-hamza.mahfooz@amd.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: SJ5PEPF000001CD:EE_|IA1PR12MB6530:EE_ X-MS-Office365-Filtering-Correlation-Id: cd3d2c66-c5b6-4125-34da-08dc2403b1a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: giEeK6WV7aoaVlQdTY8uRCoqqFDWAb4ofjBxPbqKYh1PU8i4HDbp4PU8YlGzjLhsPH4Iy8UeGOZwn9wW4q2D1FIoIdMo37EdHqaCdEMF03HEKE2kxYj33imcQb7yCJx480bGXE/IFALPnjeYVNvVyodJLCLX1VL6IoudQ6nsTLeZWewqlJa0DcnN5At1loDBDebjV9e8UAU/iW0i03M+bDCrlk6EIATCbykfONTVdv2zXChKqlgFOfBIl4qWR1VIe+83efo4Ko12DkORsMcEwogJH54NWppqD1wHkqm7dwoO/uW52MPk5etlRUbpqBchWs2McRzAwR27sbCGZQAFq9iU5NKHEDAM+hpYJqEhHzXuix4kbTXog6dnsMyD3A7nojyHIXXQXrt8yC7s7d28SQMi5oO4U4Du43ujEhgKSZfU+NaQqJNQYolWt+U6MyzwgZF3PHuVIPOD8HHQdtB/9l4KRxtfnSUo+Wx58+RbYpo/NbHnjAJ4gOH7Oh603aPDsfAEu4XlnIda+uCtbYX99PS3GHVc1cB5UpL8R4MK3T//iti6zEWJ+75pjRvoCLZmelstBPCMxbwUN9T7l89/9SLHKD2wPH4gillAzUNhjzz15l0+eKR5tB0d3pbUU+F0471bCLK1wRQJ/FdQL0DPHfjQwVOxo419GMTtmzjVM994Ovs5jGV3KAFcLlSxiaLhL+L432wOyPLX8f/Ec0/k10S/P05VpdzBuX9rWfozycDrxGSNYwF0q2LEBY97an6mKldMzsZr9bf4taIgAr6F9Csus+T7b2/qsLJg+v0EkjknagUcbiRN/LJpmrUFqOdK 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)(4636009)(39860400002)(346002)(136003)(376002)(396003)(230922051799003)(1800799012)(82310400011)(186009)(64100799003)(451199024)(46966006)(40470700004)(36840700001)(5660300002)(4326008)(8936002)(8676002)(40480700001)(40460700003)(54906003)(6916009)(316002)(70206006)(2906002)(70586007)(44832011)(36756003)(26005)(47076005)(478600001)(1076003)(2616005)(6666004)(83380400001)(82740400003)(426003)(356005)(336012)(81166007)(16526019)(36860700001)(86362001)(41300700001)(16060500005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 15:29:06.2610 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd3d2c66-c5b6-4125-34da-08dc2403b1a8 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: SJ5PEPF000001CD.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6530 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789801567655577717 X-GMAIL-MSGID: 1789801567655577717 |
Series |
[v2] drm/amd/display: add panel_power_savings sysfs entry to eDP connectors
|
|
Commit Message
Hamza Mahfooz
Feb. 2, 2024, 3:28 p.m. UTC
We want programs besides the compositor to be able to enable or disable
panel power saving features. However, since they are currently only
configurable through DRM properties, that isn't possible. So, to remedy
that issue introduce a new "panel_power_savings" sysfs attribute.
Cc: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
---
v2: hide ABM_LEVEL_IMMEDIATE_DISABLE in the read case, force an atomic
commit when setting the value, call sysfs_remove_group() in
amdgpu_dm_connector_unregister() and add some documentation.
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 76 +++++++++++++++++++
1 file changed, 76 insertions(+)
Comments
On 2/2/2024 09:28, Hamza Mahfooz wrote: > We want programs besides the compositor to be able to enable or disable > panel power saving features. However, since they are currently only > configurable through DRM properties, that isn't possible. So, to remedy > that issue introduce a new "panel_power_savings" sysfs attribute. > > Cc: Mario Limonciello <mario.limonciello@amd.com> > Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Tested-by: Mario Limonciello <mario.limonciello@amd.com> > --- > v2: hide ABM_LEVEL_IMMEDIATE_DISABLE in the read case, force an atomic > commit when setting the value, call sysfs_remove_group() in > amdgpu_dm_connector_unregister() and add some documentation. > --- > .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 76 +++++++++++++++++++ > 1 file changed, 76 insertions(+) > > 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 8590c9f1dda6..3c62489d03dc 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > @@ -6436,10 +6436,79 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector, > return ret; > } > > +/** > + * DOC: panel power savings > + * > + * The display manager allows you to set your desired **panel power savings** > + * level (between 0-4, with 0 representing off), e.g. using the following:: > + * > + * # echo 3 > /sys/class/drm/card0-eDP-1/amdgpu/panel_power_savings > + * > + * Modifying this value can have implications on color accuracy, so tread > + * carefully. > + */ > + > +static ssize_t panel_power_savings_show(struct device *device, > + struct device_attribute *attr, > + char *buf) > +{ > + struct drm_connector *connector = dev_get_drvdata(device); > + struct drm_device *dev = connector->dev; > + 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; > + drm_modeset_unlock(&dev->mode_config.connection_mutex); > + > + return sysfs_emit(buf, "%u\n", val); > +} > + > +static ssize_t panel_power_savings_store(struct device *device, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct drm_connector *connector = dev_get_drvdata(device); > + struct drm_device *dev = connector->dev; > + long val; > + int ret; > + > + ret = kstrtol(buf, 0, &val); > + > + if (ret) > + return ret; > + > + if (val < 0 || val > 4) > + return -EINVAL; > + > + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); > + to_dm_connector_state(connector->state)->abm_level = val ?: > + ABM_LEVEL_IMMEDIATE_DISABLE; > + drm_modeset_unlock(&dev->mode_config.connection_mutex); > + > + drm_kms_helper_hotplug_event(dev); > + > + return count; > +} > + > +static DEVICE_ATTR_RW(panel_power_savings); > + > +static struct attribute *amdgpu_attrs[] = { > + &dev_attr_panel_power_savings.attr, > + NULL > +}; > + > +static const struct attribute_group amdgpu_group = { > + .name = "amdgpu", > + .attrs = amdgpu_attrs > +}; > + > static void amdgpu_dm_connector_unregister(struct drm_connector *connector) > { > struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); > > + sysfs_remove_group(&connector->kdev->kobj, &amdgpu_group); > drm_dp_aux_unregister(&amdgpu_dm_connector->dm_dp_aux.aux); > } > > @@ -6541,6 +6610,13 @@ amdgpu_dm_connector_late_register(struct drm_connector *connector) > to_amdgpu_dm_connector(connector); > int r; > > + if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { > + r = sysfs_create_group(&connector->kdev->kobj, > + &amdgpu_group); > + if (r) > + return r; > + } > + > amdgpu_dm_register_backlight_device(amdgpu_dm_connector); > > if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||
On 2024-02-02 11:20, Mario Limonciello wrote: > On 2/2/2024 09:28, Hamza Mahfooz wrote: >> We want programs besides the compositor to be able to enable or disable >> panel power saving features. However, since they are currently only >> configurable through DRM properties, that isn't possible. So, to remedy >> that issue introduce a new "panel_power_savings" sysfs attribute. >> I've been trying to avoid looking at this too closely, partly because I want ABM enablement by default, with control for users. But the more I think about this the more uncomfortable I get. The key for my discomfort is that we're going around the back of DRM master to set a DRM property. This is apt to create lots of weird behaviors, especially if compositors also decide to implement support for the abm_level property and then potentially fight PPD, or other users of this sysfs. I'm also not sure a new sysfs is a good candidate for drm-fixes. Harry >> Cc: Mario Limonciello <mario.limonciello@amd.com> >> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> > > Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> > Tested-by: Mario Limonciello <mario.limonciello@amd.com> > >> --- >> v2: hide ABM_LEVEL_IMMEDIATE_DISABLE in the read case, force an atomic >> commit when setting the value, call sysfs_remove_group() in >> amdgpu_dm_connector_unregister() and add some documentation. >> --- >> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 76 +++++++++++++++++++ >> 1 file changed, 76 insertions(+) >> >> 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 8590c9f1dda6..3c62489d03dc 100644 >> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c >> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c >> @@ -6436,10 +6436,79 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector, >> return ret; >> } >> +/** >> + * DOC: panel power savings >> + * >> + * The display manager allows you to set your desired **panel power savings** >> + * level (between 0-4, with 0 representing off), e.g. using the following:: >> + * >> + * # echo 3 > /sys/class/drm/card0-eDP-1/amdgpu/panel_power_savings >> + * >> + * Modifying this value can have implications on color accuracy, so tread >> + * carefully. >> + */ >> + >> +static ssize_t panel_power_savings_show(struct device *device, >> + struct device_attribute *attr, >> + char *buf) >> +{ >> + struct drm_connector *connector = dev_get_drvdata(device); >> + struct drm_device *dev = connector->dev; >> + 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; >> + drm_modeset_unlock(&dev->mode_config.connection_mutex); >> + >> + return sysfs_emit(buf, "%u\n", val); >> +} >> + >> +static ssize_t panel_power_savings_store(struct device *device, >> + struct device_attribute *attr, >> + const char *buf, size_t count) >> +{ >> + struct drm_connector *connector = dev_get_drvdata(device); >> + struct drm_device *dev = connector->dev; >> + long val; >> + int ret; >> + >> + ret = kstrtol(buf, 0, &val); >> + >> + if (ret) >> + return ret; >> + >> + if (val < 0 || val > 4) >> + return -EINVAL; >> + >> + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); >> + to_dm_connector_state(connector->state)->abm_level = val ?: >> + ABM_LEVEL_IMMEDIATE_DISABLE; >> + drm_modeset_unlock(&dev->mode_config.connection_mutex); >> + >> + drm_kms_helper_hotplug_event(dev); >> + >> + return count; >> +} >> + >> +static DEVICE_ATTR_RW(panel_power_savings); >> + >> +static struct attribute *amdgpu_attrs[] = { >> + &dev_attr_panel_power_savings.attr, >> + NULL >> +}; >> + >> +static const struct attribute_group amdgpu_group = { >> + .name = "amdgpu", >> + .attrs = amdgpu_attrs >> +}; >> + >> static void amdgpu_dm_connector_unregister(struct drm_connector *connector) >> { >> struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); >> + sysfs_remove_group(&connector->kdev->kobj, &amdgpu_group); >> drm_dp_aux_unregister(&amdgpu_dm_connector->dm_dp_aux.aux); >> } >> @@ -6541,6 +6610,13 @@ amdgpu_dm_connector_late_register(struct drm_connector *connector) >> to_amdgpu_dm_connector(connector); >> int r; >> + if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { >> + r = sysfs_create_group(&connector->kdev->kobj, >> + &amdgpu_group); >> + if (r) >> + return r; >> + } >> + >> amdgpu_dm_register_backlight_device(amdgpu_dm_connector); >> if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) || >
On 2/15/2024 11:54, Harry Wentland wrote: > On 2024-02-02 11:20, Mario Limonciello wrote: >> On 2/2/2024 09:28, Hamza Mahfooz wrote: >>> We want programs besides the compositor to be able to enable or disable >>> panel power saving features. However, since they are currently only >>> configurable through DRM properties, that isn't possible. So, to remedy >>> that issue introduce a new "panel_power_savings" sysfs attribute. >>> > > I've been trying to avoid looking at this too closely, partly because > I want ABM enablement by default, with control for users. But the > more I think about this the more uncomfortable I get. The key for my > discomfort is that we're going around the back of DRM master to set > a DRM property. This is apt to create lots of weird behaviors, > especially if compositors also decide to implement support for the > abm_level property and then potentially fight PPD, or other users > of this sysfs. I feel the problem is that specifically both DRM master and sysfs can simultaneously fight over the value for ABM. This isn't a totally new problem because previously the user and DRM master could fight over this (with the user setting it on command line and DRM master overriding that). That was fixed in a follow up patch though in that the DRM property isn't attached if a user sets the value on the command line. I feel the solution to these concerns is that we should make a knob that controls whether the DRM property is created or the sysfs file is created but not let them happen simultaneously. We already have amdgpu.abmlevel=-1 is the only time sysfs is created. I'd say we should drop the drm property in that case and add a case for amdgpu.abmlevel=-2 which will only make the drm property and not the sysfs value. With that done it turns into: -2 : DRM master is in control -1 : sysfs is in control. Software like PPD will tune it as needed. 0-4 : User is in control.
On Fri, 2 Feb 2024 10:28:35 -0500 Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: > We want programs besides the compositor to be able to enable or disable > panel power saving features. Could you also explain why, in the commit message, please? It is unexpected for arbitrary programs to be able to override the KMS client, and certainly new ways to do so should not be added without an excellent justification. Maybe debugfs would be more appropriate if the purpose is only testing rather than production environments? > However, since they are currently only > configurable through DRM properties, that isn't possible. So, to remedy > that issue introduce a new "panel_power_savings" sysfs attribute. When the DRM property was added, what was used as the userspace to prove its workings? Thanks, pq > > Cc: Mario Limonciello <mario.limonciello@amd.com> > Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> > --- > v2: hide ABM_LEVEL_IMMEDIATE_DISABLE in the read case, force an atomic > commit when setting the value, call sysfs_remove_group() in > amdgpu_dm_connector_unregister() and add some documentation. > --- > .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 76 +++++++++++++++++++ > 1 file changed, 76 insertions(+) > > 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 8590c9f1dda6..3c62489d03dc 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > @@ -6436,10 +6436,79 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector, > return ret; > } > > +/** > + * DOC: panel power savings > + * > + * The display manager allows you to set your desired **panel power savings** > + * level (between 0-4, with 0 representing off), e.g. using the following:: > + * > + * # echo 3 > /sys/class/drm/card0-eDP-1/amdgpu/panel_power_savings > + * > + * Modifying this value can have implications on color accuracy, so tread > + * carefully. > + */ > + > +static ssize_t panel_power_savings_show(struct device *device, > + struct device_attribute *attr, > + char *buf) > +{ > + struct drm_connector *connector = dev_get_drvdata(device); > + struct drm_device *dev = connector->dev; > + 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; > + drm_modeset_unlock(&dev->mode_config.connection_mutex); > + > + return sysfs_emit(buf, "%u\n", val); > +} > + > +static ssize_t panel_power_savings_store(struct device *device, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct drm_connector *connector = dev_get_drvdata(device); > + struct drm_device *dev = connector->dev; > + long val; > + int ret; > + > + ret = kstrtol(buf, 0, &val); > + > + if (ret) > + return ret; > + > + if (val < 0 || val > 4) > + return -EINVAL; > + > + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); > + to_dm_connector_state(connector->state)->abm_level = val ?: > + ABM_LEVEL_IMMEDIATE_DISABLE; > + drm_modeset_unlock(&dev->mode_config.connection_mutex); > + > + drm_kms_helper_hotplug_event(dev); > + > + return count; > +} > + > +static DEVICE_ATTR_RW(panel_power_savings); > + > +static struct attribute *amdgpu_attrs[] = { > + &dev_attr_panel_power_savings.attr, > + NULL > +}; > + > +static const struct attribute_group amdgpu_group = { > + .name = "amdgpu", > + .attrs = amdgpu_attrs > +}; > + > static void amdgpu_dm_connector_unregister(struct drm_connector *connector) > { > struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); > > + sysfs_remove_group(&connector->kdev->kobj, &amdgpu_group); > drm_dp_aux_unregister(&amdgpu_dm_connector->dm_dp_aux.aux); > } > > @@ -6541,6 +6610,13 @@ amdgpu_dm_connector_late_register(struct drm_connector *connector) > to_amdgpu_dm_connector(connector); > int r; > > + if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { > + r = sysfs_create_group(&connector->kdev->kobj, > + &amdgpu_group); > + if (r) > + return r; > + } > + > amdgpu_dm_register_backlight_device(amdgpu_dm_connector); > > if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||
On Thu, 15 Feb 2024, Mario Limonciello <mario.limonciello@amd.com> wrote: > I feel the solution to these concerns is that we should make a knob that > controls whether the DRM property is created or the sysfs file is > created but not let them happen simultaneously. *insert the eyeballs emoji here* I mean no matter what the problem is, this sounds like the solution is worse than the problem! BR, Jani.
Am 02.02.24 um 16:28 schrieb Hamza Mahfooz: > We want programs besides the compositor to be able to enable or disable > panel power saving features. Well I don't know the full background, but that is usually a no-go. > However, since they are currently only > configurable through DRM properties, that isn't possible. Maybe I'm repeating others, but I wanted to point it out explicitly: This is intentional and not that easily changeable. If it's a common DRM property, e.g. something standardized among all drivers, then amdgpu is not allowed to circumvent that. Regards, Christian. > So, to remedy > that issue introduce a new "panel_power_savings" sysfs attribute. > > Cc: Mario Limonciello <mario.limonciello@amd.com> > Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> > --- > v2: hide ABM_LEVEL_IMMEDIATE_DISABLE in the read case, force an atomic > commit when setting the value, call sysfs_remove_group() in > amdgpu_dm_connector_unregister() and add some documentation. > --- > .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 76 +++++++++++++++++++ > 1 file changed, 76 insertions(+) > > 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 8590c9f1dda6..3c62489d03dc 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > @@ -6436,10 +6436,79 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector, > return ret; > } > > +/** > + * DOC: panel power savings > + * > + * The display manager allows you to set your desired **panel power savings** > + * level (between 0-4, with 0 representing off), e.g. using the following:: > + * > + * # echo 3 > /sys/class/drm/card0-eDP-1/amdgpu/panel_power_savings > + * > + * Modifying this value can have implications on color accuracy, so tread > + * carefully. > + */ > + > +static ssize_t panel_power_savings_show(struct device *device, > + struct device_attribute *attr, > + char *buf) > +{ > + struct drm_connector *connector = dev_get_drvdata(device); > + struct drm_device *dev = connector->dev; > + 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; > + drm_modeset_unlock(&dev->mode_config.connection_mutex); > + > + return sysfs_emit(buf, "%u\n", val); > +} > + > +static ssize_t panel_power_savings_store(struct device *device, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct drm_connector *connector = dev_get_drvdata(device); > + struct drm_device *dev = connector->dev; > + long val; > + int ret; > + > + ret = kstrtol(buf, 0, &val); > + > + if (ret) > + return ret; > + > + if (val < 0 || val > 4) > + return -EINVAL; > + > + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); > + to_dm_connector_state(connector->state)->abm_level = val ?: > + ABM_LEVEL_IMMEDIATE_DISABLE; > + drm_modeset_unlock(&dev->mode_config.connection_mutex); > + > + drm_kms_helper_hotplug_event(dev); > + > + return count; > +} > + > +static DEVICE_ATTR_RW(panel_power_savings); > + > +static struct attribute *amdgpu_attrs[] = { > + &dev_attr_panel_power_savings.attr, > + NULL > +}; > + > +static const struct attribute_group amdgpu_group = { > + .name = "amdgpu", > + .attrs = amdgpu_attrs > +}; > + > static void amdgpu_dm_connector_unregister(struct drm_connector *connector) > { > struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); > > + sysfs_remove_group(&connector->kdev->kobj, &amdgpu_group); > drm_dp_aux_unregister(&amdgpu_dm_connector->dm_dp_aux.aux); > } > > @@ -6541,6 +6610,13 @@ amdgpu_dm_connector_late_register(struct drm_connector *connector) > to_amdgpu_dm_connector(connector); > int r; > > + if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { > + r = sysfs_create_group(&connector->kdev->kobj, > + &amdgpu_group); > + if (r) > + return r; > + } > + > amdgpu_dm_register_backlight_device(amdgpu_dm_connector); > > if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||
On 2/16/24 03:19, Pekka Paalanen wrote: > On Fri, 2 Feb 2024 10:28:35 -0500 > Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: > >> We want programs besides the compositor to be able to enable or disable >> panel power saving features. > > Could you also explain why, in the commit message, please? > > It is unexpected for arbitrary programs to be able to override the KMS > client, and certainly new ways to do so should not be added without an > excellent justification. > > Maybe debugfs would be more appropriate if the purpose is only testing > rather than production environments? > >> However, since they are currently only >> configurable through DRM properties, that isn't possible. So, to remedy >> that issue introduce a new "panel_power_savings" sysfs attribute. > > When the DRM property was added, what was used as the userspace to > prove its workings? To my knowledge, it is only used by IGT. Also, it is worth noting that it is a vendor specific property, so I doubt there are any compositors out there that felt motivated enough to use it in any capacity. > > > Thanks, > pq > >> >> Cc: Mario Limonciello <mario.limonciello@amd.com> >> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> >> --- >> v2: hide ABM_LEVEL_IMMEDIATE_DISABLE in the read case, force an atomic >> commit when setting the value, call sysfs_remove_group() in >> amdgpu_dm_connector_unregister() and add some documentation. >> --- >> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 76 +++++++++++++++++++ >> 1 file changed, 76 insertions(+) >> >> 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 8590c9f1dda6..3c62489d03dc 100644 >> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c >> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c >> @@ -6436,10 +6436,79 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector, >> return ret; >> } >> >> +/** >> + * DOC: panel power savings >> + * >> + * The display manager allows you to set your desired **panel power savings** >> + * level (between 0-4, with 0 representing off), e.g. using the following:: >> + * >> + * # echo 3 > /sys/class/drm/card0-eDP-1/amdgpu/panel_power_savings >> + * >> + * Modifying this value can have implications on color accuracy, so tread >> + * carefully. >> + */ >> + >> +static ssize_t panel_power_savings_show(struct device *device, >> + struct device_attribute *attr, >> + char *buf) >> +{ >> + struct drm_connector *connector = dev_get_drvdata(device); >> + struct drm_device *dev = connector->dev; >> + 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; >> + drm_modeset_unlock(&dev->mode_config.connection_mutex); >> + >> + return sysfs_emit(buf, "%u\n", val); >> +} >> + >> +static ssize_t panel_power_savings_store(struct device *device, >> + struct device_attribute *attr, >> + const char *buf, size_t count) >> +{ >> + struct drm_connector *connector = dev_get_drvdata(device); >> + struct drm_device *dev = connector->dev; >> + long val; >> + int ret; >> + >> + ret = kstrtol(buf, 0, &val); >> + >> + if (ret) >> + return ret; >> + >> + if (val < 0 || val > 4) >> + return -EINVAL; >> + >> + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); >> + to_dm_connector_state(connector->state)->abm_level = val ?: >> + ABM_LEVEL_IMMEDIATE_DISABLE; >> + drm_modeset_unlock(&dev->mode_config.connection_mutex); >> + >> + drm_kms_helper_hotplug_event(dev); >> + >> + return count; >> +} >> + >> +static DEVICE_ATTR_RW(panel_power_savings); >> + >> +static struct attribute *amdgpu_attrs[] = { >> + &dev_attr_panel_power_savings.attr, >> + NULL >> +}; >> + >> +static const struct attribute_group amdgpu_group = { >> + .name = "amdgpu", >> + .attrs = amdgpu_attrs >> +}; >> + >> static void amdgpu_dm_connector_unregister(struct drm_connector *connector) >> { >> struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); >> >> + sysfs_remove_group(&connector->kdev->kobj, &amdgpu_group); >> drm_dp_aux_unregister(&amdgpu_dm_connector->dm_dp_aux.aux); >> } >> >> @@ -6541,6 +6610,13 @@ amdgpu_dm_connector_late_register(struct drm_connector *connector) >> to_amdgpu_dm_connector(connector); >> int r; >> >> + if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { >> + r = sysfs_create_group(&connector->kdev->kobj, >> + &amdgpu_group); >> + if (r) >> + return r; >> + } >> + >> amdgpu_dm_register_backlight_device(amdgpu_dm_connector); >> >> if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) || >
On 2/16/24 03:19, Pekka Paalanen wrote: > On Fri, 2 Feb 2024 10:28:35 -0500 > Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: > >> We want programs besides the compositor to be able to enable or disable >> panel power saving features. > > Could you also explain why, in the commit message, please? > > It is unexpected for arbitrary programs to be able to override the KMS > client, and certainly new ways to do so should not be added without an > excellent justification. Also, to be completely honest with you, I'm not sure why it was initially exposed as a DRM prop, since it's a power management feature. Which is to say, that it doesn't really make sense to have the compositor control it. > > Maybe debugfs would be more appropriate if the purpose is only testing > rather than production environments? > >> However, since they are currently only >> configurable through DRM properties, that isn't possible. So, to remedy >> that issue introduce a new "panel_power_savings" sysfs attribute. > > When the DRM property was added, what was used as the userspace to > prove its workings? > > > Thanks, > pq > >> >> Cc: Mario Limonciello <mario.limonciello@amd.com> >> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> >> --- >> v2: hide ABM_LEVEL_IMMEDIATE_DISABLE in the read case, force an atomic >> commit when setting the value, call sysfs_remove_group() in >> amdgpu_dm_connector_unregister() and add some documentation. >> --- >> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 76 +++++++++++++++++++ >> 1 file changed, 76 insertions(+) >> >> 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 8590c9f1dda6..3c62489d03dc 100644 >> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c >> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c >> @@ -6436,10 +6436,79 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector, >> return ret; >> } >> >> +/** >> + * DOC: panel power savings >> + * >> + * The display manager allows you to set your desired **panel power savings** >> + * level (between 0-4, with 0 representing off), e.g. using the following:: >> + * >> + * # echo 3 > /sys/class/drm/card0-eDP-1/amdgpu/panel_power_savings >> + * >> + * Modifying this value can have implications on color accuracy, so tread >> + * carefully. >> + */ >> + >> +static ssize_t panel_power_savings_show(struct device *device, >> + struct device_attribute *attr, >> + char *buf) >> +{ >> + struct drm_connector *connector = dev_get_drvdata(device); >> + struct drm_device *dev = connector->dev; >> + 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; >> + drm_modeset_unlock(&dev->mode_config.connection_mutex); >> + >> + return sysfs_emit(buf, "%u\n", val); >> +} >> + >> +static ssize_t panel_power_savings_store(struct device *device, >> + struct device_attribute *attr, >> + const char *buf, size_t count) >> +{ >> + struct drm_connector *connector = dev_get_drvdata(device); >> + struct drm_device *dev = connector->dev; >> + long val; >> + int ret; >> + >> + ret = kstrtol(buf, 0, &val); >> + >> + if (ret) >> + return ret; >> + >> + if (val < 0 || val > 4) >> + return -EINVAL; >> + >> + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); >> + to_dm_connector_state(connector->state)->abm_level = val ?: >> + ABM_LEVEL_IMMEDIATE_DISABLE; >> + drm_modeset_unlock(&dev->mode_config.connection_mutex); >> + >> + drm_kms_helper_hotplug_event(dev); >> + >> + return count; >> +} >> + >> +static DEVICE_ATTR_RW(panel_power_savings); >> + >> +static struct attribute *amdgpu_attrs[] = { >> + &dev_attr_panel_power_savings.attr, >> + NULL >> +}; >> + >> +static const struct attribute_group amdgpu_group = { >> + .name = "amdgpu", >> + .attrs = amdgpu_attrs >> +}; >> + >> static void amdgpu_dm_connector_unregister(struct drm_connector *connector) >> { >> struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); >> >> + sysfs_remove_group(&connector->kdev->kobj, &amdgpu_group); >> drm_dp_aux_unregister(&amdgpu_dm_connector->dm_dp_aux.aux); >> } >> >> @@ -6541,6 +6610,13 @@ amdgpu_dm_connector_late_register(struct drm_connector *connector) >> to_amdgpu_dm_connector(connector); >> int r; >> >> + if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { >> + r = sysfs_create_group(&connector->kdev->kobj, >> + &amdgpu_group); >> + if (r) >> + return r; >> + } >> + >> amdgpu_dm_register_backlight_device(amdgpu_dm_connector); >> >> if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) || >
On 2024-02-16 03:19, Pekka Paalanen wrote: > On Fri, 2 Feb 2024 10:28:35 -0500 > Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: > >> We want programs besides the compositor to be able to enable or disable >> panel power saving features. > > Could you also explain why, in the commit message, please? > > It is unexpected for arbitrary programs to be able to override the KMS > client, and certainly new ways to do so should not be added without an > excellent justification. > > Maybe debugfs would be more appropriate if the purpose is only testing > rather than production environments? > >> However, since they are currently only >> configurable through DRM properties, that isn't possible. So, to remedy >> that issue introduce a new "panel_power_savings" sysfs attribute. > > When the DRM property was added, what was used as the userspace to > prove its workings? > I don't think there ever was a userspace implementation and doubt any exists today. Part of that is on me. In hindsight, the KMS prop should have never gone upstream. I suggest we drop the KMS prop entirely. As for the color accuracy topic, I think it is important that compositors can have full control over that if needed, while it's also important for HW vendors to optimize for power when absolute color accuracy is not needed. An average end-user writing code or working on their slides would rather have a longer battery life than a perfectly color-accurate display. We should probably think of a solution that can support both use-cases. Harry > > Thanks, > pq > >> >> Cc: Mario Limonciello <mario.limonciello@amd.com> >> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> >> --- >> v2: hide ABM_LEVEL_IMMEDIATE_DISABLE in the read case, force an atomic >> commit when setting the value, call sysfs_remove_group() in >> amdgpu_dm_connector_unregister() and add some documentation. >> --- >> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 76 +++++++++++++++++++ >> 1 file changed, 76 insertions(+) >> >> 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 8590c9f1dda6..3c62489d03dc 100644 >> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c >> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c >> @@ -6436,10 +6436,79 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector, >> return ret; >> } >> >> +/** >> + * DOC: panel power savings >> + * >> + * The display manager allows you to set your desired **panel power savings** >> + * level (between 0-4, with 0 representing off), e.g. using the following:: >> + * >> + * # echo 3 > /sys/class/drm/card0-eDP-1/amdgpu/panel_power_savings >> + * >> + * Modifying this value can have implications on color accuracy, so tread >> + * carefully. >> + */ >> + >> +static ssize_t panel_power_savings_show(struct device *device, >> + struct device_attribute *attr, >> + char *buf) >> +{ >> + struct drm_connector *connector = dev_get_drvdata(device); >> + struct drm_device *dev = connector->dev; >> + 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; >> + drm_modeset_unlock(&dev->mode_config.connection_mutex); >> + >> + return sysfs_emit(buf, "%u\n", val); >> +} >> + >> +static ssize_t panel_power_savings_store(struct device *device, >> + struct device_attribute *attr, >> + const char *buf, size_t count) >> +{ >> + struct drm_connector *connector = dev_get_drvdata(device); >> + struct drm_device *dev = connector->dev; >> + long val; >> + int ret; >> + >> + ret = kstrtol(buf, 0, &val); >> + >> + if (ret) >> + return ret; >> + >> + if (val < 0 || val > 4) >> + return -EINVAL; >> + >> + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); >> + to_dm_connector_state(connector->state)->abm_level = val ?: >> + ABM_LEVEL_IMMEDIATE_DISABLE; >> + drm_modeset_unlock(&dev->mode_config.connection_mutex); >> + >> + drm_kms_helper_hotplug_event(dev); >> + >> + return count; >> +} >> + >> +static DEVICE_ATTR_RW(panel_power_savings); >> + >> +static struct attribute *amdgpu_attrs[] = { >> + &dev_attr_panel_power_savings.attr, >> + NULL >> +}; >> + >> +static const struct attribute_group amdgpu_group = { >> + .name = "amdgpu", >> + .attrs = amdgpu_attrs >> +}; >> + >> static void amdgpu_dm_connector_unregister(struct drm_connector *connector) >> { >> struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); >> >> + sysfs_remove_group(&connector->kdev->kobj, &amdgpu_group); >> drm_dp_aux_unregister(&amdgpu_dm_connector->dm_dp_aux.aux); >> } >> >> @@ -6541,6 +6610,13 @@ amdgpu_dm_connector_late_register(struct drm_connector *connector) >> to_amdgpu_dm_connector(connector); >> int r; >> >> + if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { >> + r = sysfs_create_group(&connector->kdev->kobj, >> + &amdgpu_group); >> + if (r) >> + return r; >> + } >> + >> amdgpu_dm_register_backlight_device(amdgpu_dm_connector); >> >> if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) || >
On Fri, 16 Feb 2024 09:33:47 -0500 Harry Wentland <harry.wentland@amd.com> wrote: > On 2024-02-16 03:19, Pekka Paalanen wrote: > > On Fri, 2 Feb 2024 10:28:35 -0500 > > Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: > > > >> We want programs besides the compositor to be able to enable or disable > >> panel power saving features. > > > > Could you also explain why, in the commit message, please? > > > > It is unexpected for arbitrary programs to be able to override the KMS > > client, and certainly new ways to do so should not be added without an > > excellent justification. > > > > Maybe debugfs would be more appropriate if the purpose is only testing > > rather than production environments? > > > >> However, since they are currently only > >> configurable through DRM properties, that isn't possible. So, to remedy > >> that issue introduce a new "panel_power_savings" sysfs attribute. > > > > When the DRM property was added, what was used as the userspace to > > prove its workings? > > > > I don't think there ever was a userspace implementation and doubt any > exists today. Part of that is on me. In hindsight, the KMS prop should > have never gone upstream. > > I suggest we drop the KMS prop entirely. Sounds good. What about the sysfs thing? Should it be a debugfs thing instead, assuming the below question will be resolved? > As for the color accuracy topic, I think it is important that compositors > can have full control over that if needed, while it's also important > for HW vendors to optimize for power when absolute color accuracy is not > needed. An average end-user writing code or working on their slides > would rather have a longer battery life than a perfectly color-accurate > display. We should probably think of a solution that can support both > use-cases. I agree. Maybe this pondering should start from "how would it work from end user perspective"? "Automatically" is probably be most desirable answer. Some kind of desktop settings with options like "save power at the expense of image quality": - always - not if watching movies/gaming - on battery - on battery, unless I'm watching movies/gaming - never Or maybe there already is something like that, and it only needs to be plumbed through? Which would point towards KMS clients needing to control it, which means a generic KMS prop rather than vendor specific? Or should the desktop compositor be talking to some daemon instead of KMS for this? Maybe they already are? Thanks, pq
On 2024-02-16 10:42, Pekka Paalanen wrote: > On Fri, 16 Feb 2024 09:33:47 -0500 > Harry Wentland <harry.wentland@amd.com> wrote: > >> On 2024-02-16 03:19, Pekka Paalanen wrote: >>> On Fri, 2 Feb 2024 10:28:35 -0500 >>> Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: >>> >>>> We want programs besides the compositor to be able to enable or disable >>>> panel power saving features. >>> >>> Could you also explain why, in the commit message, please? >>> >>> It is unexpected for arbitrary programs to be able to override the KMS >>> client, and certainly new ways to do so should not be added without an >>> excellent justification. >>> >>> Maybe debugfs would be more appropriate if the purpose is only testing >>> rather than production environments? >>> >>>> However, since they are currently only >>>> configurable through DRM properties, that isn't possible. So, to remedy >>>> that issue introduce a new "panel_power_savings" sysfs attribute. >>> >>> When the DRM property was added, what was used as the userspace to >>> prove its workings? >>> >> >> I don't think there ever was a userspace implementation and doubt any >> exists today. Part of that is on me. In hindsight, the KMS prop should >> have never gone upstream. >> >> I suggest we drop the KMS prop entirely. > > Sounds good. What about the sysfs thing? Should it be a debugfs thing > instead, assuming the below question will be resolved? > It's intended to be used by the power profiles daemon (PPD). I don't think debugfs is the right choice. See https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/commit/41ed5d33a82b0ceb7b6d473551eb2aa62cade6bc >> As for the color accuracy topic, I think it is important that compositors >> can have full control over that if needed, while it's also important >> for HW vendors to optimize for power when absolute color accuracy is not >> needed. An average end-user writing code or working on their slides >> would rather have a longer battery life than a perfectly color-accurate >> display. We should probably think of a solution that can support both >> use-cases. > > I agree. Maybe this pondering should start from "how would it work from > end user perspective"? > > "Automatically" is probably be most desirable answer. Some kind of I agree > desktop settings with options like "save power at the expense of image > quality": > - always > - not if watching movies/gaming > - on battery > - on battery, unless I'm watching movies/gaming > - never > It's interesting that you split out movies/gaming, specifically. AMD's ABM algorithm seems to have considered movies in particular when evaluating the power/fidelity trade-off. I wouldn't think consumer media is very particular about a specific color fidelity (despite what HDR specs try to make you believe). Where color fidelity would matter to me is when I'd want to edit pictures or video. The "abm_level" property that we expose is really just that, a setting for the strength of the power-savings effect, with 0 being off and 4 being maximum strength and power saving, at the expense of fidelity. Mario's work is to let the PPD control it and set the ABM levels based on the selected power profile: 0 - Performance 1 - Balance 3 - Power And I believe we've looked at disabling ABM (setting it to 0) automatically if we know we're on AC power. > Or maybe there already is something like that, and it only needs to be > plumbed through? > > Which would point towards KMS clients needing to control it, which > means a generic KMS prop rather than vendor specific? > > Or should the desktop compositor be talking to some daemon instead of > KMS for this? Maybe they already are? > I think the intention is for the PPD to be that daemon. Mario can elaborate. Harry > > Thanks, > pq
On 2024-02-16 11:11, Harry Wentland wrote: > > > On 2024-02-16 10:42, Pekka Paalanen wrote: >> On Fri, 16 Feb 2024 09:33:47 -0500 >> Harry Wentland <harry.wentland@amd.com> wrote: >> >>> On 2024-02-16 03:19, Pekka Paalanen wrote: >>>> On Fri, 2 Feb 2024 10:28:35 -0500 >>>> Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: >>>> >>>>> We want programs besides the compositor to be able to enable or disable >>>>> panel power saving features. >>>> >>>> Could you also explain why, in the commit message, please? >>>> >>>> It is unexpected for arbitrary programs to be able to override the KMS >>>> client, and certainly new ways to do so should not be added without an >>>> excellent justification. >>>> >>>> Maybe debugfs would be more appropriate if the purpose is only testing >>>> rather than production environments? >>>> >>>>> However, since they are currently only >>>>> configurable through DRM properties, that isn't possible. So, to remedy >>>>> that issue introduce a new "panel_power_savings" sysfs attribute. >>>> >>>> When the DRM property was added, what was used as the userspace to >>>> prove its workings? >>>> >>> >>> I don't think there ever was a userspace implementation and doubt any >>> exists today. Part of that is on me. In hindsight, the KMS prop should >>> have never gone upstream. >>> >>> I suggest we drop the KMS prop entirely. >> >> Sounds good. What about the sysfs thing? Should it be a debugfs thing >> instead, assuming the below question will be resolved? >> > > > It's intended to be used by the power profiles daemon (PPD). I don't think > debugfs is the right choice. See > https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/commit/41ed5d33a82b0ceb7b6d473551eb2aa62cade6bc > >>> As for the color accuracy topic, I think it is important that compositors >>> can have full control over that if needed, while it's also important >>> for HW vendors to optimize for power when absolute color accuracy is not >>> needed. An average end-user writing code or working on their slides >>> would rather have a longer battery life than a perfectly color-accurate >>> display. We should probably think of a solution that can support both >>> use-cases. >> >> I agree. Maybe this pondering should start from "how would it work from >> end user perspective"? >> >> "Automatically" is probably be most desirable answer. Some kind of > > I agree > >> desktop settings with options like "save power at the expense of image >> quality": >> - always >> - not if watching movies/gaming >> - on battery >> - on battery, unless I'm watching movies/gaming >> - never >> > > It's interesting that you split out movies/gaming, specifically. AMD's > ABM algorithm seems to have considered movies in particular when > evaluating the power/fidelity trade-off. > > I wouldn't think consumer media is very particular about a specific > color fidelity (despite what HDR specs try to make you believe). Where > color fidelity would matter to me is when I'd want to edit pictures or > video. > > The "abm_level" property that we expose is really just that, a setting > for the strength of the power-savings effect, with 0 being off and 4 being > maximum strength and power saving, at the expense of fidelity. > > Mario's work is to let the PPD control it and set the ABM levels based on > the selected power profile: > 0 - Performance > 1 - Balance > 3 - Power > > And I believe we've looked at disabling ABM (setting it to 0) automatically > if we know we're on AC power. > >> Or maybe there already is something like that, and it only needs to be >> plumbed through? >> >> Which would point towards KMS clients needing to control it, which >> means a generic KMS prop rather than vendor specific? >> >> Or should the desktop compositor be talking to some daemon instead of >> KMS for this? Maybe they already are? >> > > I think the intention is for the PPD to be that daemon. Mario can elaborate. > Some more details and screenshots on how the PPD is expected to work and look: https://linuxconfig.org/how-to-manage-power-profiles-over-d-bus-with-power-profiles-daemon-on-linux Harry > Harry > >> >> Thanks, >> pq >
On 2/16/2024 10:13, Harry Wentland wrote: > > > On 2024-02-16 11:11, Harry Wentland wrote: >> >> >> On 2024-02-16 10:42, Pekka Paalanen wrote: >>> On Fri, 16 Feb 2024 09:33:47 -0500 >>> Harry Wentland <harry.wentland@amd.com> wrote: >>> >>>> On 2024-02-16 03:19, Pekka Paalanen wrote: >>>>> On Fri, 2 Feb 2024 10:28:35 -0500 >>>>> Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: >>>>> >>>>>> We want programs besides the compositor to be able to enable or disable >>>>>> panel power saving features. >>>>> >>>>> Could you also explain why, in the commit message, please? >>>>> >>>>> It is unexpected for arbitrary programs to be able to override the KMS >>>>> client, and certainly new ways to do so should not be added without an >>>>> excellent justification. >>>>> >>>>> Maybe debugfs would be more appropriate if the purpose is only testing >>>>> rather than production environments? >>>>> >>>>>> However, since they are currently only >>>>>> configurable through DRM properties, that isn't possible. So, to remedy >>>>>> that issue introduce a new "panel_power_savings" sysfs attribute. >>>>> >>>>> When the DRM property was added, what was used as the userspace to >>>>> prove its workings? >>>>> >>>> >>>> I don't think there ever was a userspace implementation and doubt any >>>> exists today. Part of that is on me. In hindsight, the KMS prop should >>>> have never gone upstream. >>>> >>>> I suggest we drop the KMS prop entirely. >>> >>> Sounds good. What about the sysfs thing? Should it be a debugfs thing >>> instead, assuming the below question will be resolved? >>> >> >> >> It's intended to be used by the power profiles daemon (PPD). I don't think >> debugfs is the right choice. See >> https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/commit/41ed5d33a82b0ceb7b6d473551eb2aa62cade6bc >> >>>> As for the color accuracy topic, I think it is important that compositors >>>> can have full control over that if needed, while it's also important >>>> for HW vendors to optimize for power when absolute color accuracy is not >>>> needed. An average end-user writing code or working on their slides >>>> would rather have a longer battery life than a perfectly color-accurate >>>> display. We should probably think of a solution that can support both >>>> use-cases. >>> >>> I agree. Maybe this pondering should start from "how would it work from >>> end user perspective"? >>> >>> "Automatically" is probably be most desirable answer. Some kind of >> >> I agree >> >>> desktop settings with options like "save power at the expense of image >>> quality": >>> - always >>> - not if watching movies/gaming >>> - on battery >>> - on battery, unless I'm watching movies/gaming >>> - never >>> >> >> It's interesting that you split out movies/gaming, specifically. AMD's >> ABM algorithm seems to have considered movies in particular when >> evaluating the power/fidelity trade-off. >> >> I wouldn't think consumer media is very particular about a specific >> color fidelity (despite what HDR specs try to make you believe). Where >> color fidelity would matter to me is when I'd want to edit pictures or >> video. >> >> The "abm_level" property that we expose is really just that, a setting >> for the strength of the power-savings effect, with 0 being off and 4 being >> maximum strength and power saving, at the expense of fidelity. >> >> Mario's work is to let the PPD control it and set the ABM levels based on >> the selected power profile: >> 0 - Performance >> 1 - Balance >> 3 - Power >> >> And I believe we've looked at disabling ABM (setting it to 0) automatically >> if we know we're on AC power. >> >>> Or maybe there already is something like that, and it only needs to be >>> plumbed through? >>> >>> Which would point towards KMS clients needing to control it, which >>> means a generic KMS prop rather than vendor specific? >>> >>> Or should the desktop compositor be talking to some daemon instead of >>> KMS for this? Maybe they already are? >>> >> >> I think the intention is for the PPD to be that daemon. Mario can elaborate. >> > > Some more details and screenshots on how the PPD is expected to work and look: > https://linuxconfig.org/how-to-manage-power-profiles-over-d-bus-with-power-profiles-daemon-on-linux Right, thanks! The most important point is that the user indicates intent from the GUI. The daemon orchestrates the various knobs to get that intent. It's intentionally very coarse - 3 power states. The policy of what to do for those states is managed by the daemon. In the case of ABM it will only apply the policy if the daemon detects the system is on battery.
On Fri, 16 Feb 2024 10:32:10 -0600 Mario Limonciello <mario.limonciello@amd.com> wrote: > On 2/16/2024 10:13, Harry Wentland wrote: > > > > > > On 2024-02-16 11:11, Harry Wentland wrote: > >> > >> > >> On 2024-02-16 10:42, Pekka Paalanen wrote: > >>> On Fri, 16 Feb 2024 09:33:47 -0500 > >>> Harry Wentland <harry.wentland@amd.com> wrote: > >>> > >>>> On 2024-02-16 03:19, Pekka Paalanen wrote: > >>>>> On Fri, 2 Feb 2024 10:28:35 -0500 > >>>>> Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: > >>>>> > >>>>>> We want programs besides the compositor to be able to enable or disable > >>>>>> panel power saving features. > >>>>> > >>>>> Could you also explain why, in the commit message, please? > >>>>> > >>>>> It is unexpected for arbitrary programs to be able to override the KMS > >>>>> client, and certainly new ways to do so should not be added without an > >>>>> excellent justification. > >>>>> > >>>>> Maybe debugfs would be more appropriate if the purpose is only testing > >>>>> rather than production environments? > >>>>> > >>>>>> However, since they are currently only > >>>>>> configurable through DRM properties, that isn't possible. So, to remedy > >>>>>> that issue introduce a new "panel_power_savings" sysfs attribute. > >>>>> > >>>>> When the DRM property was added, what was used as the userspace to > >>>>> prove its workings? > >>>>> > >>>> > >>>> I don't think there ever was a userspace implementation and doubt any > >>>> exists today. Part of that is on me. In hindsight, the KMS prop should > >>>> have never gone upstream. > >>>> > >>>> I suggest we drop the KMS prop entirely. > >>> > >>> Sounds good. What about the sysfs thing? Should it be a debugfs thing > >>> instead, assuming the below question will be resolved? > >>> > >> > >> > >> It's intended to be used by the power profiles daemon (PPD). I don't think > >> debugfs is the right choice. See > >> https://gitlab.freedesktop.org/upower/power-profiles-daemon/-/commit/41ed5d33a82b0ceb7b6d473551eb2aa62cade6bc > >> > >>>> As for the color accuracy topic, I think it is important that compositors > >>>> can have full control over that if needed, while it's also important > >>>> for HW vendors to optimize for power when absolute color accuracy is not > >>>> needed. An average end-user writing code or working on their slides > >>>> would rather have a longer battery life than a perfectly color-accurate > >>>> display. We should probably think of a solution that can support both > >>>> use-cases. > >>> > >>> I agree. Maybe this pondering should start from "how would it work from > >>> end user perspective"? > >>> > >>> "Automatically" is probably be most desirable answer. Some kind of > >> > >> I agree > >> > >>> desktop settings with options like "save power at the expense of image > >>> quality": > >>> - always > >>> - not if watching movies/gaming > >>> - on battery > >>> - on battery, unless I'm watching movies/gaming > >>> - never > >>> > >> > >> It's interesting that you split out movies/gaming, specifically. AMD's > >> ABM algorithm seems to have considered movies in particular when > >> evaluating the power/fidelity trade-off. > >> > >> I wouldn't think consumer media is very particular about a specific > >> color fidelity (despite what HDR specs try to make you believe). Where > >> color fidelity would matter to me is when I'd want to edit pictures or > >> video. > >> > >> The "abm_level" property that we expose is really just that, a setting > >> for the strength of the power-savings effect, with 0 being off and 4 being > >> maximum strength and power saving, at the expense of fidelity. > >> > >> Mario's work is to let the PPD control it and set the ABM levels based on > >> the selected power profile: > >> 0 - Performance > >> 1 - Balance > >> 3 - Power > >> > >> And I believe we've looked at disabling ABM (setting it to 0) automatically > >> if we know we're on AC power. > >> > >>> Or maybe there already is something like that, and it only needs to be > >>> plumbed through? > >>> > >>> Which would point towards KMS clients needing to control it, which > >>> means a generic KMS prop rather than vendor specific? > >>> > >>> Or should the desktop compositor be talking to some daemon instead of > >>> KMS for this? Maybe they already are? > >>> > >> > >> I think the intention is for the PPD to be that daemon. Mario can elaborate. > >> > > > > Some more details and screenshots on how the PPD is expected to work and look: > > https://linuxconfig.org/how-to-manage-power-profiles-over-d-bus-with-power-profiles-daemon-on-linux > > Right, thanks! > > The most important point is that the user indicates intent from the GUI. > The daemon orchestrates the various knobs to get that intent. > > It's intentionally very coarse - 3 power states. The policy of what to > do for those states is managed by the daemon. > > In the case of ABM it will only apply the policy if the daemon detects > the system is on battery. > Sounds like sysfs is the best option, and it should never have been a KMS property, indeed. Thanks, pq
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 8590c9f1dda6..3c62489d03dc 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -6436,10 +6436,79 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector, return ret; } +/** + * DOC: panel power savings + * + * The display manager allows you to set your desired **panel power savings** + * level (between 0-4, with 0 representing off), e.g. using the following:: + * + * # echo 3 > /sys/class/drm/card0-eDP-1/amdgpu/panel_power_savings + * + * Modifying this value can have implications on color accuracy, so tread + * carefully. + */ + +static ssize_t panel_power_savings_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct drm_connector *connector = dev_get_drvdata(device); + struct drm_device *dev = connector->dev; + 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; + drm_modeset_unlock(&dev->mode_config.connection_mutex); + + return sysfs_emit(buf, "%u\n", val); +} + +static ssize_t panel_power_savings_store(struct device *device, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct drm_connector *connector = dev_get_drvdata(device); + struct drm_device *dev = connector->dev; + long val; + int ret; + + ret = kstrtol(buf, 0, &val); + + if (ret) + return ret; + + if (val < 0 || val > 4) + return -EINVAL; + + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); + to_dm_connector_state(connector->state)->abm_level = val ?: + ABM_LEVEL_IMMEDIATE_DISABLE; + drm_modeset_unlock(&dev->mode_config.connection_mutex); + + drm_kms_helper_hotplug_event(dev); + + return count; +} + +static DEVICE_ATTR_RW(panel_power_savings); + +static struct attribute *amdgpu_attrs[] = { + &dev_attr_panel_power_savings.attr, + NULL +}; + +static const struct attribute_group amdgpu_group = { + .name = "amdgpu", + .attrs = amdgpu_attrs +}; + static void amdgpu_dm_connector_unregister(struct drm_connector *connector) { struct amdgpu_dm_connector *amdgpu_dm_connector = to_amdgpu_dm_connector(connector); + sysfs_remove_group(&connector->kdev->kobj, &amdgpu_group); drm_dp_aux_unregister(&amdgpu_dm_connector->dm_dp_aux.aux); } @@ -6541,6 +6610,13 @@ amdgpu_dm_connector_late_register(struct drm_connector *connector) to_amdgpu_dm_connector(connector); int r; + if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) { + r = sysfs_create_group(&connector->kdev->kobj, + &amdgpu_group); + if (r) + return r; + } + amdgpu_dm_register_backlight_device(amdgpu_dm_connector); if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||