From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
To: "Xaver Hugl" <xaver.hugl@gmail.com>,
"Vidith Madhu" <vmadhu@nvidia.com>,
"Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>,
"Leo Li" <sunpeng.li@amd.com>,
"Harry Wentland" <harry.wentland@amd.com>,
"Fangzhi Zuo" <Jerry.Zuo@amd.com>,
"Daniel Stone" <daniels@collabora.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>, "Helge Deller" <deller@gmx.de>,
"Andrzej Hajda" <andrzej.hajda@intel.com>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Robert Foss" <rfoss@kernel.org>,
"Laurent Pinchart" <Laurent.pinchart@ideasonboard.com>,
"Jonas Karlman" <jonas@kwiboo.se>,
"Jernej Skrabec" <jernej.skrabec@gmail.com>,
"Luca Ceresoli" <luca.ceresoli@bootlin.com>,
"Sandy Huang" <hjc@rock-chips.com>,
"Heiko Stübner" <heiko@sntech.de>, "Andy Yan" <andyshrk@163.com>,
"Michel Dänzer" <michel.daenzer@mailbox.org>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-fbdev@vger.kernel.org, linux-rockchip@lists.infradead.org,
linux-arm-kernel@lists.infradead.org, kernel@collabora.com,
Derek Foreman <derek.foreman@collabora.com>,
wayland-devel@lists.freedesktop.org,
Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Subject: [PATCH v2 02/27] drm/connector: add vrr_display_mode connector property
Date: Thu, 05 Nov 2026 16:51:53 +0100 [thread overview]
Message-ID: <20261105-vrr-limiter-uapi-v2-2-55f4215be2c2@collabora.com> (raw)
In-Reply-To: <20261105-vrr-limiter-uapi-v2-0-55f4215be2c2@collabora.com>
It's common to want to keep a VRR-capable display in a specific VRR mode
regardless of whether a CRTC uses VRR presentation, to avoid screen
blanking during switching of the VRR mode. On the other hand, it's also
not always desired to keep a display in VRR mode even when nothing does
VRR presentation, for example in battery-powered systems.
To let userspace control this explicitly, instead of relying on implicit
driver policy, introduce a new connector KMS property: vrr_display_mode.
It defaults to "Game", which matches the behaviour of dGPU drivers,
wherein a VRR-capable display will always be in Game mode. However, it
also has an "Off" mode, with which userspace can explicitly request that
VRR be disabled on the display sink.
The associated connector state member uses an u8 rather than the enum
type in order to fit into the existing 2 bytes of padding there. Once
the kernel mandates compiler versions that have backported C23 features,
the enum can be given an explicit small backing type and the member can
be changed to use the enum type.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/gpu/drm/drm_atomic_uapi.c | 4 ++
drivers/gpu/drm/drm_connector.c | 77 +++++++++++++++++++++++++++++++++++++++
include/drm/drm_connector.h | 29 +++++++++++++++
3 files changed, 110 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 1eebcf6f5e05..127bdd77802b 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -969,6 +969,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
state->hdmi.broadcast_rgb = val;
} else if (property == connector->color_format_property) {
state->color_format = val;
+ } else if (property == connector->vrr_display_mode_property) {
+ state->vrr_display_mode = val;
} else if (connector->funcs->atomic_set_property) {
return connector->funcs->atomic_set_property(connector,
state, property, val);
@@ -1056,6 +1058,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
*val = state->hdmi.broadcast_rgb;
} else if (property == connector->color_format_property) {
*val = state->color_format;
+ } else if (property == connector->vrr_display_mode_property) {
+ *val = state->vrr_display_mode;
} else if (connector->funcs->atomic_get_property) {
return connector->funcs->atomic_get_property(connector,
state, property, val);
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 893716a9e489..65c14b6e47a6 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1434,6 +1434,12 @@ static const struct drm_prop_enum_list drm_tv_mode_enum_list[] = {
};
DRM_ENUM_NAME_FN(drm_get_tv_mode_name, drm_tv_mode_enum_list)
+static const struct drm_prop_enum_list drm_vrr_mode_enum_list[] = {
+ { VRR_DISPLAY_MODE_GAME, "Game" },
+ { VRR_DISPLAY_MODE_OFF, "Off" },
+};
+DRM_ENUM_NAME_FN(drm_get_vrr_mode_name, drm_vrr_mode_enum_list)
+
/**
* drm_get_tv_mode_from_name - Translates a TV mode name into its enum value
* @name: TV Mode name we want to convert
@@ -2560,6 +2566,14 @@ EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
*
* The driver may place further restrictions within these minimum
* and maximum bounds.
+ *
+ * "vrr_display_mode":
+ * Optional &drm_connector enum property that controls which VRR mode, if
+ * any, a display is in. Possible values::
+ *
+ * - Game - set display to game mode if display supports it,
+ * regardless of CRTC state
+ * - Off - set display to VRR disabled mode, regardless of CRTC state
*/
/**
@@ -2593,6 +2607,69 @@ int drm_connector_attach_vrr_capable_property(
}
EXPORT_SYMBOL(drm_connector_attach_vrr_capable_property);
+/**
+ * drm_connector_attach_vrr_display_mode_property - creates and attaches VRR
+ * display mode property
+ * @connector: pointer to the &struct drm_connector to attach the property to
+ * @supported_vrr_modes: bitmask of VRR modes the connector supports regardless
+ * of sink
+ *
+ * Creates and attaches the "vrr_display_mode" property to @connector. The
+ * property must not already exist on it. @supported_vrr_modes is a bitmask
+ * wherein BIT(VRR_DISPLAY_MODE_FOO) indicates VRR_DISPLAY_MODE_FOO is supported
+ * by the connector.
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int drm_connector_attach_vrr_display_mode_property(struct drm_connector *connector,
+ unsigned int supported_vrr_modes)
+{
+ struct drm_device *dev = connector->dev;
+ struct drm_prop_enum_list enum_list[VRR_DISPLAY_MODE_COUNT];
+ unsigned int num_enums = 0;
+ struct drm_property *prop;
+ int i;
+
+ if (supported_vrr_modes & ~(BIT(VRR_DISPLAY_MODE_COUNT) - 1)) {
+ drm_err(dev, "Unknown VRR modes provided on [CONNECTOR:%d:%s]\n",
+ connector->base.id, connector->name);
+ return -EINVAL;
+ }
+
+ if (connector->vrr_display_mode_property) {
+ drm_err(dev, "[CONNECTOR:%d:%s] already has a 'vrr_display_mode' property\n",
+ connector->base.id, connector->name);
+ return -EEXIST;
+ }
+
+ if (!(supported_vrr_modes & BIT(VRR_DISPLAY_MODE_GAME))) {
+ drm_err(dev, "Missing default VRR mode on [CONNECTOR:%d:%s]\n",
+ connector->base.id, connector->name);
+ return -EINVAL;
+ }
+
+ for (i = 0; i < VRR_DISPLAY_MODE_COUNT; i++) {
+ if (BIT(i) & supported_vrr_modes) {
+ enum_list[num_enums].name = drm_get_vrr_mode_name(i);
+ enum_list[num_enums].type = i;
+ num_enums++;
+ }
+ }
+
+ prop = drm_property_create_enum(dev, DRM_MODE_PROP_ENUM, "vrr_display_mode",
+ enum_list, num_enums);
+
+ if (!prop)
+ return -ENOMEM;
+
+ connector->vrr_display_mode_property = prop;
+ drm_object_attach_property(&connector->base, prop, VRR_DISPLAY_MODE_GAME);
+
+ return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_vrr_display_mode_property);
+
/**
* drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
* @connector: connector to attach scaling mode property on.
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 2ee7c59329aa..8699f35cafcb 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -809,6 +809,15 @@ enum drm_bus_flags {
DRM_BUS_FLAG_SHARP_SIGNALS = BIT(8),
};
+enum vrr_display_mode {
+ /** @VRR_DISPLAY_MODE_GAME: Set the display to VRR "Game" mode */
+ VRR_DISPLAY_MODE_GAME = 0,
+ /** @VRR_DISPLAY_MODE_OFF: Turn off VRR on the display */
+ VRR_DISPLAY_MODE_OFF,
+ /** @VRR_DISPLAY_MODE_COUNT: Sentinel, not a valid mode, keep last */
+ VRR_DISPLAY_MODE_COUNT
+};
+
/**
* struct drm_amd_vsdb_info - AMD-specific VSDB information
*
@@ -1352,6 +1361,12 @@ struct drm_connector_state {
*/
u8 max_bpc;
+ /**
+ * @vrr_display_mode: One of &enum vrr_display_mode to indicate the VRR
+ * type to use on a VRR-capable display.
+ */
+ u8 vrr_display_mode;
+
/**
* @privacy_screen_sw_state: See :ref:`Standard Connector
* Properties<standard_connector_properties>`
@@ -2454,6 +2469,17 @@ struct drm_connector {
*/
struct drm_property *vrr_capable_property;
+ /**
+ * @vrr_display_mode_property: Optional property for userspace to set
+ * a connected display to a specific VRR mode, regardless of the
+ * connected CRTC's VRR_ENABLED property. Drivers can create and attach
+ * the property to a connector by calling
+ * drm_connector_attach_vrr_display_mode_property(). Implementations can
+ * then read the set display mode (&enum vrr_display_mode) from
+ * &drm_connector_state.vrr_display_mode.
+ */
+ struct drm_property *vrr_display_mode_property;
+
/**
* @colorspace_property: Connector property to set the suitable
* colorspace supported by the sink.
@@ -2859,6 +2885,7 @@ const char *drm_get_dpms_name(int val);
const char *drm_get_dvi_i_subconnector_name(int val);
const char *drm_get_dvi_i_select_name(int val);
const char *drm_get_tv_mode_name(int val);
+const char *drm_get_vrr_mode_name(int val);
const char *drm_get_tv_subconnector_name(int val);
const char *drm_get_tv_select_name(int val);
const char *drm_get_dp_subconnector_name(int val);
@@ -2883,6 +2910,8 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
u32 scaling_mode_mask);
int drm_connector_attach_vrr_capable_property(
struct drm_connector *connector);
+int drm_connector_attach_vrr_display_mode_property(struct drm_connector *connector,
+ unsigned int supported_vrr_modes);
void drm_connector_attach_panel_type_property(struct drm_connector *connector);
int drm_connector_attach_broadcast_rgb_property(struct drm_connector *connector);
int drm_connector_attach_colorspace_property(struct drm_connector *connector);
--
2.56.0
next prev parent reply other threads:[~2026-11-05 15:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 15:51 [PATCH v2 00/27] VRR Target Rate Limiter KMS uAPI and Implementation Nicolas Frattaroli
2026-11-05 15:51 ` [PATCH v2 01/27] drm: Add VRR state Nicolas Frattaroli
2026-11-05 15:51 ` Nicolas Frattaroli [this message]
2026-11-05 15:51 ` [PATCH v2 03/27] video/hdmi: Add VTEM EMP packing Nicolas Frattaroli
2026-11-05 15:51 ` [PATCH v2 04/27] drm/bridge: Add VTEM EMP support Nicolas Frattaroli
2026-11-05 15:51 ` [PATCH v2 05/27] drm/connector: hdmi: Add VTEM EMP generation Nicolas Frattaroli
2026-11-05 15:51 ` [PATCH v2 06/27] drm/crtc-helper: Add VRR helper functions Nicolas Frattaroli
2026-11-05 15:51 ` [PATCH v2 07/27] drm/bridge: synopsys: Add VTEM EMP support Nicolas Frattaroli
2026-11-05 15:51 ` [PATCH v2 08/27] drm/connector: Add drm_display_info_is_vrr_capable Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 09/27] drm: Add VRR target frame rate properties Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 10/27] drm/connector: Add vrr_display_{min,max} connector properties Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 11/27] drm: Implement VRR rate limiting Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 12/27] drm/rockchip: dw_hdmi_qp: Add VRR support Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 13/27] drm/rockchip: Set mode_changed on vrr_enabled change Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 14/27] drm/rockchip: vop2: Enable VRR Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 15/27] drm/edid: Parse QMS flag from HDMI SCDS Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 16/27] drm/edid: Parse QMS TFR min/max flags " Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 17/27] drm/connector: Add "Media" VRR display mode for QMS Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 18/27] video/hdmi: Add support for QMS in VTEM EMP packing Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 19/27] drm/connector: hdmi: Add QMS to VTEM EMP generation Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 20/27] drm/connector: hdmi: Add QMS state validation and computation Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 21/27] drm/rockchip: dw_hdmi_qp: Add QMS support Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 22/27] drm/tests: hdmi: Add "Game Mode" VRR tests Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 23/27] drm/tests: hdmi: Add Fixed/Constrained rate " Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 24/27] drm/tests: hdmi: Add Quick Media Switching tests Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 25/27] drm/connector: Fix docs for cnmvrr and cinemavrr members Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 26/27] drm/debugfs: Expose HDMI VRR in vrr_range debugfs Nicolas Frattaroli
2026-11-05 15:52 ` [PATCH v2 27/27] drm/tests: hdmi: Add tests for vrr_display_{min,max} properties Nicolas Frattaroli
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=20261105-vrr-limiter-uapi-v2-2-55f4215be2c2@collabora.com \
--to=nicolas.frattaroli@collabora.com \
--cc=Jerry.Zuo@amd.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=andyshrk@163.com \
--cc=chaitanya.kumar.borah@intel.com \
--cc=daniels@collabora.com \
--cc=deller@gmx.de \
--cc=derek.foreman@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=heiko@sntech.de \
--cc=hjc@rock-chips.com \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=kernel@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=luca.ceresoli@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=michel.daenzer@mailbox.org \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=simona@ffwll.ch \
--cc=sunpeng.li@amd.com \
--cc=tzimmermann@suse.de \
--cc=vmadhu@nvidia.com \
--cc=wayland-devel@lists.freedesktop.org \
--cc=xaver.hugl@gmail.com \
/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
all inboxes | Powered by JetHome®