From: Simon Ser <contact@emersion.fr>
To: dri-devel@lists.freedesktop.org, wayland-devel@lists.freedesktop.org
Subject: [PATCH] drm/atomic: add quirks for blind save/restore
Date: Thu, 17 Nov 2022 07:54:40 +0000 [thread overview]
Message-ID: <20221117075433.222968-1-contact@emersion.fr> (raw)
Two quirks to make blind atomic save/restore [1] work correctly:
- Mark the DPMS property as immutable for atomic clients, since
atomic clients cannot change it.
- Allow user-space to set content protection to "enabled", interpret
it as "desired".
[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3794
Signed-off-by: Simon Ser <contact@emersion.fr>
---
I don't have the motivation to write IGT tests for this.
drivers/gpu/drm/drm_atomic_uapi.c | 5 +++--
drivers/gpu/drm/drm_property.c | 7 +++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index c06d0639d552..95363aac7f69 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -741,8 +741,9 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
state->scaling_mode = val;
} else if (property == config->content_protection_property) {
if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
- drm_dbg_kms(dev, "only drivers can set CP Enabled\n");
- return -EINVAL;
+ /* Degrade ENABLED to DESIRED so that blind atomic
+ * save/restore works as intended. */
+ val = DRM_MODE_CONTENT_PROTECTION_DESIRED;
}
state->content_protection = val;
} else if (property == config->hdcp_content_type_property) {
diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c
index dfec479830e4..dde42986f8cb 100644
--- a/drivers/gpu/drm/drm_property.c
+++ b/drivers/gpu/drm/drm_property.c
@@ -474,7 +474,14 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
return -ENOENT;
strscpy_pad(out_resp->name, property->name, DRM_PROP_NAME_LEN);
+
out_resp->flags = property->flags;
+ if (file_priv->atomic && property == dev->mode_config.dpms_property) {
+ /* Quirk: indicate that the legacy DPMS property is not
+ * writable from atomic user-space, so that blind atomic
+ * save/restore works as intended. */
+ out_resp->flags |= DRM_MODE_PROP_IMMUTABLE;
+ }
value_count = property->num_values;
values_ptr = u64_to_user_ptr(out_resp->values_ptr);
--
2.38.1
next reply other threads:[~2022-11-17 7:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 7:54 Simon Ser [this message]
2022-11-17 8:35 ` [PATCH] drm/atomic: add quirks for blind save/restore Pekka Paalanen
2022-11-17 15:28 ` Daniel Vetter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221117075433.222968-1-contact@emersion.fr \
--to=contact@emersion.fr \
--cc=dri-devel@lists.freedesktop.org \
--cc=wayland-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox