Skip to contentSkip to conversation

A DRM API for adaptive sync and variable refresh rate support

PATCH New Nicholas Kazlauskas 10 participants 23 messages Sep 11, 2018 – Sep 12, 2018 5 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover A DRM API for adaptive sync and variable refresh rate support

=== Adaptive sync and variable refresh rate ===

Adaptive sync is part of the DisplayPort spec and allows for graphics adapters to drive displays with varying frame timings.

Variable refresh rate (VRR) is essentially the same, but defined for HDMI.

=== Use cases for variable refresh rate ===

Variable frame (flip) timings don't align well with fixed refresh rate displays. This results in stuttering, tearing and/or input lag. By adjusting the display refresh rate dynamically these issues can be reduced or eliminated.

However, not all content is suitable for dynamic refresh adaptation. Content that is flipped infrequently or at random intervals tends to fair poorly. Multiple clients trying to flip under the same screen can similarly interfere with prediction.

Userland needs a way to let the driver know when the content on the screen is suitable for variable refresh rate and if the user wishes to have the feature enabled.

=== DRM API to support variable refresh rates ===

This patch introduces a new API via atomic properties on the DRM connector and CRTC.

The connector has two new optional properties:

* bool variable_refresh_capable - set by the driver if the hardware is capable of supporting variable refresh tech

* bool variable_refresh_enabled - set by the user to enable variable refresh adjustment over the connector

The CRTC has one additional default property:

* bool variable_refresh - a content hint to the driver specifying that the CRTC contents are suitable for variable refresh adjustment

== Overview for DRM driver developers ===

Driver developers can attach the optional connector properties via drm_connector_attach_variable_refresh_properties on connectors that support variable refresh (typically DP or HDMI).

The variable_refresh_capable property should be managed as the output on the connector changes. The property is read only from userspace.

The variable_refresh_enabled property is intended to be a property controlled by userland as a global on/off switch for variable refresh technology. It should be checked before enabling variable refresh rate.

=== Overview for Userland developers ==

The variable_refresh property on the CRTC should be set to true when the CRTCs are suitable for variable refresh rate. In practice this is probably an application like a game - a single window that covers the whole CRTC surface and is the only client issuing flips.

To demonstrate the suitability of the API for variable refresh and dynamic adaptation there are additional patches using this API that implement adaptive variable refresh across kernel and userland projects:

- DRM (dri-devel)
- amdgpu DRM kernel driver (amd-gfx)
- xf86-video-amdgpu (amd-gfx)
- mesa (mesa-dev)

These patches enable adaptive variable refresh on X for AMD hardware provided that the user sets the variable_refresh_enabled property to true on supported connectors (ie. using xrandr --set-prop).

They have been tested on upstream userland under GNOME/KDE desktop environments under single and multi-monitor setups for a number of GL applications. Most games and benchmarks should work as expected provided that the compositor correctly unredirects the application's surface. KDE seems to have the best support for this with an explicit option to disable tearing support.

Full implementation details for these changes can be reviewed in their respective mailing lists.

=== Previous discussions ===

These patches are based upon feedback from patches and feedback from two previous threads on the subject which are linked below for reference:

https://lists.freedesktop.org/archives/amd-gfx/2018-April/021047.html
https://lists.freedesktop.org/archives/dri-devel/2017-October/155207.html

Nicholas Kazlauskas

Anthony Koo (1):
drm/amd/display: Refactor FreeSync module

Harry Wentland (3):
drm/amdgpu: fill in amdgpu_dm_remove_sink_from_freesync_module drm/amdgpu/display: add freesync drm properties drm/amdgpu: add freesync ioctl

Nicholas Kazlauskas (5):
drm: Add variable refresh rate properties to DRM connector
drm: Add variable refresh property to DRM CRTC drm/amd/display: Replace FreeSync props with DRM VRR props drm/amd/display: Drop FreeSync ioctl notification support drm/amdgpu: Drop unneeded freesync properties from amdpgu

 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |    3 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |   16 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c       |    3 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  240 +--
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   17 +-
 .../display/amdgpu_dm/amdgpu_dm_mst_types.c   |   10 +-
 drivers/gpu/drm/amd/display/dc/core/dc.c      |   60 +-
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  |    3 +
 .../gpu/drm/amd/display/dc/core/dc_resource.c |  110 +-
 drivers/gpu/drm/amd/display/dc/dc_hw_types.h  |    6 -
 drivers/gpu/drm/amd/display/dc/dc_stream.h    |   29 +-
 drivers/gpu/drm/amd/display/dc/dc_types.h     |   22 +-
 .../display/dc/dce110/dce110_hw_sequencer.c   |   34 +-
 .../amd/display/dc/dcn10/dcn10_hw_sequencer.c |   27 +-
 .../drm/amd/display/include/set_mode_types.h  |   12 -
 .../amd/display/modules/freesync/freesync.c   | 1837 ++++++-----------
 .../amd/display/modules/inc/mod_freesync.h    |  144 +-
 drivers/gpu/drm/drm_atomic.c                  |   15 +
 drivers/gpu/drm/drm_atomic_helper.c           |    1 +
 drivers/gpu/drm/drm_connector.c               |   35 +
 drivers/gpu/drm/drm_crtc.c                    |    2 +
 drivers/gpu/drm/drm_mode_config.c             |    6 +
 include/drm/drm_connector.h                   |   27 +
 include/drm/drm_crtc.h                        |   13 +
 include/drm/drm_mode_config.h                 |    8 +
 include/uapi/drm/amdgpu_drm.h                 |   16 +
 26 files changed, 1026 insertions(+), 1670 deletions(-)
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 20180911161333.5334-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 1/9 drm: Add variable refresh rate properties to DRM connector

Modern monitor hardware is capable of supporting variable refresh rates and adaptive sync technologies. The properties for querying and controlling these features should be exposed on the DRM connector.

This patch introduces two new properties for variable refresh rate support:

- variable_refresh_capable
- variable_refresh_enabled

These are optional properties that can be added to a DRM connector dynamically by using drm_connector_attach_variable_refresh_properties.

DRM drivers should set variable_refresh_capable as applicable for their hardware. The property variable_refresh_enabled as a userspace controlled option.

Change-Id I5f60f8b57534e1d3dacda4c64c6c9106b42f4439
---
 drivers/gpu/drm/drm_atomic.c    |  9 +++++++++
 drivers/gpu/drm/drm_connector.c | 35 +++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h     | 27 +++++++++++++++++++++++++
 3 files changed, 71 insertions(+)
drivers/gpu/drm/drm_atomic.c +9 -0
index d0478abc01bd..2f89ab0fac87 100644
@@ -1403,6 +1403,11 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 		state->content_type = val;
 	} else if (property == connector->scaling_mode_property) {
 		state->scaling_mode = val;
+	} else if (property == connector->variable_refresh_capable_property) {
+		DRM_DEBUG_KMS("only drivers can set variable_refresh_capable\n");
+		return -EINVAL;
+	} else if (property == connector->variable_refresh_enabled_property) {
+		state->variable_refresh_enabled = val;
 	} else if (property == connector->content_protection_property) {
 		if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
 			DRM_DEBUG_KMS("only drivers can set CP Enabled\n");
@@ -1508,6 +1513,10 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
 		*val = state->content_type;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
+	} else if (property == connector->variable_refresh_capable_property) {
+		*val = state->variable_refresh_capable;
+	} else if (property == connector->variable_refresh_enabled_property) {
+		*val = state->variable_refresh_enabled;
 	} else if (property == connector->content_protection_property) {
 		*val = state->content_protection;
 	} else if (property == config->writeback_fb_id_property) {
drivers/gpu/drm/drm_connector.c +35 -0
index 6011d769d50b..37fb33fa77b9 100644
@@ -1250,6 +1250,41 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
 
+/**
+ * drm_connector_attach_variable_refresh_properties - creates and attaches
+ * properties for connectors that support adaptive refresh
+ * @connector: connector to create adaptive refresh properties on
+ */
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (!connector->variable_refresh_capable_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_capable");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_capable_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	if (!connector->variable_refresh_enabled_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_enabled");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_enabled_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_variable_refresh_properties);
+
 /**
  * drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
  * @connector: connector to attach scaling mode property on.
include/drm/drm_connector.h +27 -0
index 97ea41dc678f..105a127e9191 100644
@@ -448,6 +448,18 @@ struct drm_connector_state {
 	 */
 	unsigned int content_protection;
 
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is supported on the device.
+	 */
+	bool variable_refresh_capable;
+
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is enabled.
+	 */
+	bool variable_refresh_enabled;
+
 	/**
 	 * @writeback_job: Writeback job for writeback connectors
 	 *
@@ -909,6 +921,19 @@ struct drm_connector {
 	 */
 	struct drm_property *scaling_mode_property;
 
+	/**
+	 * @variable_refresh_capable_property: Optional property for
+	 * querying hardware support for variable refresh.
+	 */
+	struct drm_property *variable_refresh_capable_property;
+
+	/**
+	 * @variable_refresh_enabled_property: Optional property for
+	 * enabling or disabling support for variable refresh
+	 * on the connector.
+	 */
+	struct drm_property *variable_refresh_enabled_property;
+
 	/**
 	 * @content_protection_property: DRM ENUM property for content
 	 * protection. See drm_connector_attach_content_protection_property().
@@ -1182,6 +1207,8 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev);
 int drm_connector_attach_content_type_property(struct drm_connector *dev);
 int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
 					       u32 scaling_mode_mask);
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector);
 int drm_connector_attach_content_protection_property(
 		struct drm_connector *connector);
 int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

Re: [PATCH 1/9] drm: Add variable refresh rate properties to DRM connector

Quoted 30 lines · Nicholas Kazlauskas

Modern monitor hardware is capable of supporting variable refresh rates and adaptive sync technologies. The properties for querying and controlling these features should be exposed on the DRM connector.

This patch introduces two new properties for variable refresh rate support:

- variable_refresh_capable
- variable_refresh_enabled

These are optional properties that can be added to a DRM connector dynamically by using drm_connector_attach_variable_refresh_properties.

DRM drivers should set variable_refresh_capable as applicable for their hardware. The property variable_refresh_enabled as a userspace controlled option.

Change-Id I5f60f8b57534e1d3dacda4c64c6c9106b42f4439
---
 drivers/gpu/drm/drm_atomic.c    |  9 +++++++++
 drivers/gpu/drm/drm_connector.c | 35 +++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h     | 27 +++++++++++++++++++++++++
 3 files changed, 71 insertions(+)
drivers/gpu/drm/drm_atomic.c +0 -0
index d0478abc01bd..2f89ab0fac87 100644

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1408

Quoted 6 lines
drivers/gpu/drm/drm_atomic.c +3 -0
@@ -1403,6 +1403,11 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 		state->content_type = val;
 	} else if (property == connector->scaling_mode_property) {
 		state->scaling_mode = val;
+	} else if (property == connector->variable_refresh_capable_property) {
+		DRM_DEBUG_KMS("only drivers can set variable_refresh_capable\n");
+		return -EINVAL;

Why is that needed? Why not just avoid exposing the vrr_enabled prop when it's not supported?

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1410

Quoted 2 lines
drivers/gpu/drm/drm_atomic.c +2 -0
+	} else if (property == connector->variable_refresh_enabled_property) {
+		state->variable_refresh_enabled = val;

So one thing I already asked long ago is whether there would a point in exposing some kind of min/max refresh rate range control. Never really got an answer. Was somehting like that considered and rejected?

Quoted 114 lines
drivers/gpu/drm/drm_atomic.c +4 -0
 	} else if (property == connector->content_protection_property) {
 		if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
 			DRM_DEBUG_KMS("only drivers can set CP Enabled\n");
@@ -1508,6 +1513,10 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
 		*val = state->content_type;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
+	} else if (property == connector->variable_refresh_capable_property) {
+		*val = state->variable_refresh_capable;
+	} else if (property == connector->variable_refresh_enabled_property) {
+		*val = state->variable_refresh_enabled;
 	} else if (property == connector->content_protection_property) {
 		*val = state->content_protection;
 	} else if (property == config->writeback_fb_id_property) {
drivers/gpu/drm/drm_connector.c +35 -0
index 6011d769d50b..37fb33fa77b9 100644
@@ -1250,6 +1250,41 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
 
+/**
+ * drm_connector_attach_variable_refresh_properties - creates and attaches
+ * properties for connectors that support adaptive refresh
+ * @connector: connector to create adaptive refresh properties on
+ */
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (!connector->variable_refresh_capable_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_capable");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_capable_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	if (!connector->variable_refresh_enabled_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_enabled");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_enabled_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_variable_refresh_properties);
+
 /**
  * drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
  * @connector: connector to attach scaling mode property on.
include/drm/drm_connector.h +27 -0
index 97ea41dc678f..105a127e9191 100644
@@ -448,6 +448,18 @@ struct drm_connector_state {
 	 */
 	unsigned int content_protection;
 
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is supported on the device.
+	 */
+	bool variable_refresh_capable;
+
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is enabled.
+	 */
+	bool variable_refresh_enabled;
+
 	/**
 	 * @writeback_job: Writeback job for writeback connectors
 	 *
@@ -909,6 +921,19 @@ struct drm_connector {
 	 */
 	struct drm_property *scaling_mode_property;
 
+	/**
+	 * @variable_refresh_capable_property: Optional property for
+	 * querying hardware support for variable refresh.
+	 */
+	struct drm_property *variable_refresh_capable_property;
+
+	/**
+	 * @variable_refresh_enabled_property: Optional property for
+	 * enabling or disabling support for variable refresh
+	 * on the connector.
+	 */
+	struct drm_property *variable_refresh_enabled_property;
+
 	/**
 	 * @content_protection_property: DRM ENUM property for content
 	 * protection. See drm_connector_attach_content_protection_property().
@@ -1182,6 +1207,8 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev);
 int drm_connector_attach_content_type_property(struct drm_connector *dev);
 int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
 					       u32 scaling_mode_mask);
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector);
 int drm_connector_attach_content_protection_property(
 		struct drm_connector *connector);
 int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
Signature · 1 line
2.17.1
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

Re: [PATCH 1/9] drm: Add variable refresh rate properties to DRM connector

Quoted 26 lines · Ville Syrjälä
Quoted 25 lines · Nicholas Kazlauskas

Modern monitor hardware is capable of supporting variable refresh rates and adaptive sync technologies. The properties for querying and controlling these features should be exposed on the DRM connector.

This patch introduces two new properties for variable refresh rate support:

- variable_refresh_capable
- variable_refresh_enabled

These are optional properties that can be added to a DRM connector dynamically by using drm_connector_attach_variable_refresh_properties.

DRM drivers should set variable_refresh_capable as applicable for their hardware. The property variable_refresh_enabled as a userspace controlled option.

Change-Id I5f60f8b57534e1d3dacda4c64c6c9106b42f4439
---
 drivers/gpu/drm/drm_atomic.c    |  9 +++++++++
 drivers/gpu/drm/drm_connector.c | 35 +++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h     | 27 +++++++++++++++++++++++++
 3 files changed, 71 insertions(+)
Quoted 14 lines

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1408

Quoted 11 lines
drivers/gpu/drm/drm_atomic.c +3 -0
index d0478abc01bd..2f89ab0fac87 100644
@@ -1403,6 +1403,11 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 		state->content_type = val;
 	} else if (property == connector->scaling_mode_property) {
 		state->scaling_mode = val;
+	} else if (property == connector->variable_refresh_capable_property) {
+		DRM_DEBUG_KMS("only drivers can set variable_refresh_capable\n");
+		return -EINVAL;

Why is that needed? Why not just avoid exposing the vrr_enabled prop when it's not supported?

Ah, I guess you want to change the value after plugging in a new display. Yeah, if we don't want userspace to have to parse the EDID I guess we need this. But in that case it should be marked immutable, and then you don't need any of this atomic state related code for it.

Quoted 126 lines

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1410

Quoted 3 lines
drivers/gpu/drm/drm_atomic.c +2 -0
+	} else if (property == connector->variable_refresh_enabled_property) {
+		state->variable_refresh_enabled = val;

So one thing I already asked long ago is whether there would a point in exposing some kind of min/max refresh rate range control. Never really got an answer. Was somehting like that considered and rejected?

Quoted 114 lines
drivers/gpu/drm/drm_atomic.c +4 -0
 	} else if (property == connector->content_protection_property) {
 		if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
 			DRM_DEBUG_KMS("only drivers can set CP Enabled\n");
@@ -1508,6 +1513,10 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
 		*val = state->content_type;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
+	} else if (property == connector->variable_refresh_capable_property) {
+		*val = state->variable_refresh_capable;
+	} else if (property == connector->variable_refresh_enabled_property) {
+		*val = state->variable_refresh_enabled;
 	} else if (property == connector->content_protection_property) {
 		*val = state->content_protection;
 	} else if (property == config->writeback_fb_id_property) {
drivers/gpu/drm/drm_connector.c +35 -0
index 6011d769d50b..37fb33fa77b9 100644
@@ -1250,6 +1250,41 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
 
+/**
+ * drm_connector_attach_variable_refresh_properties - creates and attaches
+ * properties for connectors that support adaptive refresh
+ * @connector: connector to create adaptive refresh properties on
+ */
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (!connector->variable_refresh_capable_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_capable");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_capable_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	if (!connector->variable_refresh_enabled_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_enabled");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_enabled_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_variable_refresh_properties);
+
 /**
  * drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
  * @connector: connector to attach scaling mode property on.
include/drm/drm_connector.h +27 -0
index 97ea41dc678f..105a127e9191 100644
@@ -448,6 +448,18 @@ struct drm_connector_state {
 	 */
 	unsigned int content_protection;
 
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is supported on the device.
+	 */
+	bool variable_refresh_capable;
+
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is enabled.
+	 */
+	bool variable_refresh_enabled;
+
 	/**
 	 * @writeback_job: Writeback job for writeback connectors
 	 *
@@ -909,6 +921,19 @@ struct drm_connector {
 	 */
 	struct drm_property *scaling_mode_property;
 
+	/**
+	 * @variable_refresh_capable_property: Optional property for
+	 * querying hardware support for variable refresh.
+	 */
+	struct drm_property *variable_refresh_capable_property;
+
+	/**
+	 * @variable_refresh_enabled_property: Optional property for
+	 * enabling or disabling support for variable refresh
+	 * on the connector.
+	 */
+	struct drm_property *variable_refresh_enabled_property;
+
 	/**
 	 * @content_protection_property: DRM ENUM property for content
 	 * protection. See drm_connector_attach_content_protection_property().
@@ -1182,6 +1207,8 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev);
 int drm_connector_attach_content_type_property(struct drm_connector *dev);
 int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
 					       u32 scaling_mode_mask);
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector);
 int drm_connector_attach_content_protection_property(
 		struct drm_connector *connector);
 int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
Signature · 1 line
2.17.1
Signature · 2 lines
Ville Syrjälä
Intel
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#6 lore raw

Re: [PATCH 1/9] drm: Add variable refresh rate properties to DRM connector

Quoted 42 lines · Ville Syrjälä
Quoted 26 lines · Ville Syrjälä
Quoted 25 lines · Nicholas Kazlauskas

Modern monitor hardware is capable of supporting variable refresh rates and adaptive sync technologies. The properties for querying and controlling these features should be exposed on the DRM connector.

This patch introduces two new properties for variable refresh rate support:

- variable_refresh_capable
- variable_refresh_enabled

These are optional properties that can be added to a DRM connector dynamically by using drm_connector_attach_variable_refresh_properties.

DRM drivers should set variable_refresh_capable as applicable for their hardware. The property variable_refresh_enabled as a userspace controlled option.

Change-Id I5f60f8b57534e1d3dacda4c64c6c9106b42f4439
---
  drivers/gpu/drm/drm_atomic.c    |  9 +++++++++
  drivers/gpu/drm/drm_connector.c | 35 +++++++++++++++++++++++++++++++++
  include/drm/drm_connector.h     | 27 +++++++++++++++++++++++++
  3 files changed, 71 insertions(+)
Quoted 14 lines

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1408

Quoted 11 lines
drivers/gpu/drm/drm_atomic.c +3 -0
index d0478abc01bd..2f89ab0fac87 100644
@@ -1403,6 +1403,11 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
  		state->content_type = val;
  	} else if (property == connector->scaling_mode_property) {
  		state->scaling_mode = val;
+	} else if (property == connector->variable_refresh_capable_property) {
+		DRM_DEBUG_KMS("only drivers can set variable_refresh_capable\n");
+		return -EINVAL;

Why is that needed? Why not just avoid exposing the vrr_enabled prop when it's not supported?

Quoted 4 lines

Ah, I guess you want to change the value after plugging in a new display. Yeah, if we don't want userspace to have to parse the EDID I guess we need this. But in that case it should be marked immutable, and then you don't need any of this atomic state related code for it.

Yeah, it's for hotplugging that it works this way. The reason it's not marked as immutable is mostly convention - the existing driver write-only properties (with userspace queries) do the same thing.

The immutable property flag is only used for non-connector properties. During testing I also noticed that something likes to cache the initial default value for these immutable flagged properties for userspace queries - so when you call xrandr you only end up seeing the default value and not the current.

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1410

Quoted 4 lines
drivers/gpu/drm/drm_atomic.c +2 -0
+	} else if (property == connector->variable_refresh_enabled_property) {
+		state->variable_refresh_enabled = val;

So one thing I already asked long ago is whether there would a point in exposing some kind of min/max refresh rate range control. Never really got an answer. Was somehting like that considered and rejected?

For the initial patchset it seemed best to keep things simple and target the dynamic adaptation usecase with on/off toggle.

The driver having access to the full range can enable additional functionality that can improve the user experience - a good example is low framerate compensation.

Adding the properties to support setting the min/max could be done on top of this, however. Driver behavior would likely need to be defined for atomic check. The driver needs to verify with the monitor that the ranges are valid at some point - whether it silently fails or returns an error is an example of something to consider here.

Do you have a specific usecase in mind that needs min/max exposed to userspace?

Quoted 111 lines
Quoted 111 lines
Quoted 111 lines
drivers/gpu/drm/drm_atomic.c +4 -0
  	} else if (property == connector->content_protection_property) {
  		if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
  			DRM_DEBUG_KMS("only drivers can set CP Enabled\n");
@@ -1508,6 +1513,10 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
  		*val = state->content_type;
  	} else if (property == connector->scaling_mode_property) {
  		*val = state->scaling_mode;
+	} else if (property == connector->variable_refresh_capable_property) {
+		*val = state->variable_refresh_capable;
+	} else if (property == connector->variable_refresh_enabled_property) {
+		*val = state->variable_refresh_enabled;
  	} else if (property == connector->content_protection_property) {
  		*val = state->content_protection;
  	} else if (property == config->writeback_fb_id_property) {
drivers/gpu/drm/drm_connector.c +35 -0
index 6011d769d50b..37fb33fa77b9 100644
@@ -1250,6 +1250,41 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
  }
  EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
 
+/**
+ * drm_connector_attach_variable_refresh_properties - creates and attaches
+ * properties for connectors that support adaptive refresh
+ * @connector: connector to create adaptive refresh properties on
+ */
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (!connector->variable_refresh_capable_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_capable");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_capable_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	if (!connector->variable_refresh_enabled_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_enabled");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_enabled_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_variable_refresh_properties);
+
  /**
   * drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
   * @connector: connector to attach scaling mode property on.
include/drm/drm_connector.h +27 -0
index 97ea41dc678f..105a127e9191 100644
@@ -448,6 +448,18 @@ struct drm_connector_state {
  	 */
  	unsigned int content_protection;
 
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is supported on the device.
+	 */
+	bool variable_refresh_capable;
+
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is enabled.
+	 */
+	bool variable_refresh_enabled;
+
  	/**
  	 * @writeback_job: Writeback job for writeback connectors
  	 *
@@ -909,6 +921,19 @@ struct drm_connector {
  	 */
  	struct drm_property *scaling_mode_property;
 
+	/**
+	 * @variable_refresh_capable_property: Optional property for
+	 * querying hardware support for variable refresh.
+	 */
+	struct drm_property *variable_refresh_capable_property;
+
+	/**
+	 * @variable_refresh_enabled_property: Optional property for
+	 * enabling or disabling support for variable refresh
+	 * on the connector.
+	 */
+	struct drm_property *variable_refresh_enabled_property;
+
  	/**
  	 * @content_protection_property: DRM ENUM property for content
  	 * protection. See drm_connector_attach_content_protection_property().
@@ -1182,6 +1207,8 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev);
  int drm_connector_attach_content_type_property(struct drm_connector *dev);
  int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
  					       u32 scaling_mode_mask);
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector);
  int drm_connector_attach_content_protection_property(
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
include/drm/drm_connector.h +0 -0
  		struct drm_connector *connector);
  int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
Signature · 1 line
2.17.1
Signature · 2 lines
Ville Syrjälä
Intel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): b7b0cff8-3d90-d3e1-0080-e422c1bcac83-5C7GfCeVMHo@public.gmane.org

#8 lore raw

Re: [PATCH 1/9] drm: Add variable refresh rate properties to DRM connector

Quoted 48 lines · Nicholas
Quoted 42 lines · Ville Syrjälä
Quoted 26 lines · Ville Syrjälä
Quoted 25 lines · Nicholas Kazlauskas

Modern monitor hardware is capable of supporting variable refresh rates and adaptive sync technologies. The properties for querying and controlling these features should be exposed on the DRM connector.

This patch introduces two new properties for variable refresh rate support:

- variable_refresh_capable
- variable_refresh_enabled

These are optional properties that can be added to a DRM connector dynamically by using drm_connector_attach_variable_refresh_properties.

DRM drivers should set variable_refresh_capable as applicable for their hardware. The property variable_refresh_enabled as a userspace controlled option.

Change-Id I5f60f8b57534e1d3dacda4c64c6c9106b42f4439
---
  drivers/gpu/drm/drm_atomic.c    |  9 +++++++++
  drivers/gpu/drm/drm_connector.c | 35 +++++++++++++++++++++++++++++++++
  include/drm/drm_connector.h     | 27 +++++++++++++++++++++++++
  3 files changed, 71 insertions(+)
Quoted 14 lines

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1408

Quoted 11 lines
drivers/gpu/drm/drm_atomic.c +3 -0
index d0478abc01bd..2f89ab0fac87 100644
@@ -1403,6 +1403,11 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
  		state->content_type = val;
  	} else if (property == connector->scaling_mode_property) {
  		state->scaling_mode = val;
+	} else if (property == connector->variable_refresh_capable_property) {
+		DRM_DEBUG_KMS("only drivers can set variable_refresh_capable\n");
+		return -EINVAL;

Why is that needed? Why not just avoid exposing the vrr_enabled prop when it's not supported?

Quoted 4 lines

Ah, I guess you want to change the value after plugging in a new display. Yeah, if we don't want userspace to have to parse the EDID I guess we need this. But in that case it should be marked immutable, and then you don't need any of this atomic state related code for it.

Quoted 5 lines

Yeah, it's for hotplugging that it works this way. The reason it's not marked as immutable is mostly convention - the existing driver write-only properties (with userspace queries) do the same thing.

The immutable property flag is only used for non-connector properties.

There are plenty of immutable connector properties: EDID, TILE, non-desktop, etc. I'm pretty sure there are more immutable connector properties than there are immutable properties on other types of objects. And considering immutable connector properties existed before other types of objects even had any properties I'd say it's well established by now :)

Quoted 4 lines

During testing I also noticed that something likes to cache the initial default value for these immutable flagged properties for userspace queries - so when you call xrandr you only end up seeing the default value and not the current.

'xrandr --current' is supposed to not probe hard for new stuff. Without the --current it may or may not result in a full probe depending on the implementation in the ddx and or the kms driver. A full probe should definitely happen after a hotplug. If it's not happening then there is a bug somewhere.

Quoted 17 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1410

Quoted 5 lines
drivers/gpu/drm/drm_atomic.c +2 -0
+	} else if (property == connector->variable_refresh_enabled_property) {
+		state->variable_refresh_enabled = val;

So one thing I already asked long ago is whether there would a point in exposing some kind of min/max refresh rate range control. Never really got an answer. Was somehting like that considered and rejected?

For the initial patchset it seemed best to keep things simple and target the dynamic adaptation usecase with on/off toggle.

The driver having access to the full range can enable additional functionality that can improve the user experience - a good example is low framerate compensation.

Quoted 8 lines

Adding the properties to support setting the min/max could be done on top of this, however. Driver behavior would likely need to be defined for atomic check. The driver needs to verify with the monitor that the ranges are valid at some point - whether it silently fails or returns an error is an example of something to consider here.

Do you have a specific usecase in mind that needs min/max exposed to userspace?

Not really. Some vague ideas about video playback and such, and maybe just for power saving. It was just an idea that occurred to me when thinking about this stuff. Although I suppose the compositor could always throttle the flip rate using other means. And in tne end it comes down to a policy question of how the compositor would decide what the allowed range is.

Quoted 121 lines
Quoted 121 lines
Quoted 120 lines
Quoted 116 lines
drivers/gpu/drm/drm_atomic.c +4 -0
  	} else if (property == connector->content_protection_property) {
  		if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
  			DRM_DEBUG_KMS("only drivers can set CP Enabled\n");
@@ -1508,6 +1513,10 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
  		*val = state->content_type;
  	} else if (property == connector->scaling_mode_property) {
  		*val = state->scaling_mode;
+	} else if (property == connector->variable_refresh_capable_property) {
+		*val = state->variable_refresh_capable;
+	} else if (property == connector->variable_refresh_enabled_property) {
+		*val = state->variable_refresh_enabled;
  	} else if (property == connector->content_protection_property) {
  		*val = state->content_protection;
  	} else if (property == config->writeback_fb_id_property) {
drivers/gpu/drm/drm_connector.c +35 -0
index 6011d769d50b..37fb33fa77b9 100644
@@ -1250,6 +1250,41 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
  }
  EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
 
+/**
+ * drm_connector_attach_variable_refresh_properties - creates and attaches
+ * properties for connectors that support adaptive refresh
+ * @connector: connector to create adaptive refresh properties on
+ */
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (!connector->variable_refresh_capable_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_capable");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_capable_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	if (!connector->variable_refresh_enabled_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_enabled");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_enabled_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_variable_refresh_properties);
+
  /**
   * drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
   * @connector: connector to attach scaling mode property on.
include/drm/drm_connector.h +27 -0
index 97ea41dc678f..105a127e9191 100644
@@ -448,6 +448,18 @@ struct drm_connector_state {
  	 */
  	unsigned int content_protection;
 
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is supported on the device.
+	 */
+	bool variable_refresh_capable;
+
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is enabled.
+	 */
+	bool variable_refresh_enabled;
+
  	/**
  	 * @writeback_job: Writeback job for writeback connectors
  	 *
@@ -909,6 +921,19 @@ struct drm_connector {
  	 */
  	struct drm_property *scaling_mode_property;
 
+	/**
+	 * @variable_refresh_capable_property: Optional property for
+	 * querying hardware support for variable refresh.
+	 */
+	struct drm_property *variable_refresh_capable_property;
+
+	/**
+	 * @variable_refresh_enabled_property: Optional property for
+	 * enabling or disabling support for variable refresh
+	 * on the connector.
+	 */
+	struct drm_property *variable_refresh_enabled_property;
+
  	/**
  	 * @content_protection_property: DRM ENUM property for content
  	 * protection. See drm_connector_attach_content_protection_property().
@@ -1182,6 +1207,8 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev);
  int drm_connector_attach_content_type_property(struct drm_connector *dev);
  int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
  					       u32 scaling_mode_mask);
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector);
  int drm_connector_attach_content_protection_property(
  		struct drm_connector *connector);
  int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
Signature · 1 line
2.17.1
Signature · 2 lines
Ville Syrjälä
Intel
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

Re: [PATCH 1/9] drm: Add variable refresh rate properties to DRM connector

Quoted 53 lines · Ville Syrjälä
Quoted 52 lines · Nicholas
Quoted 42 lines · Ville Syrjälä
Quoted 26 lines · Ville Syrjälä
Quoted 25 lines · Nicholas Kazlauskas

Modern monitor hardware is capable of supporting variable refresh rates and adaptive sync technologies. The properties for querying and controlling these features should be exposed on the DRM connector.

This patch introduces two new properties for variable refresh rate support:

- variable_refresh_capable
- variable_refresh_enabled

These are optional properties that can be added to a DRM connector dynamically by using drm_connector_attach_variable_refresh_properties.

DRM drivers should set variable_refresh_capable as applicable for their hardware. The property variable_refresh_enabled as a userspace controlled option.

Change-Id I5f60f8b57534e1d3dacda4c64c6c9106b42f4439
---
   drivers/gpu/drm/drm_atomic.c    |  9 +++++++++
   drivers/gpu/drm/drm_connector.c | 35 +++++++++++++++++++++++++++++++++
   include/drm/drm_connector.h     | 27 +++++++++++++++++++++++++
   3 files changed, 71 insertions(+)
Quoted 14 lines

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1408

Quoted 11 lines
drivers/gpu/drm/drm_atomic.c +3 -0
index d0478abc01bd..2f89ab0fac87 100644
@@ -1403,6 +1403,11 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
   		state->content_type = val;
   	} else if (property == connector->scaling_mode_property) {
   		state->scaling_mode = val;
+	} else if (property == connector->variable_refresh_capable_property) {
+		DRM_DEBUG_KMS("only drivers can set variable_refresh_capable\n");
+		return -EINVAL;

Why is that needed? Why not just avoid exposing the vrr_enabled prop when it's not supported?

Quoted 4 lines

Ah, I guess you want to change the value after plugging in a new display. Yeah, if we don't want userspace to have to parse the EDID I guess we need this. But in that case it should be marked immutable, and then you don't need any of this atomic state related code for it.

Yeah, it's for hotplugging that it works this way. The reason it's not marked as immutable is mostly convention - the existing driver write-only properties (with userspace queries) do the same thing.

Quoted 8 lines
Quoted 1 line

The immutable property flag is only used for non-connector properties.

There are plenty of immutable connector properties: EDID, TILE, non-desktop, etc. I'm pretty sure there are more immutable connector properties than there are immutable properties on other types of objects. And considering immutable connector properties existed before other types of objects even had any properties I'd say it's well established by now :)

I went back and checked and I guess you were right and most connector properties have this on them. Not sure what part of the code I was thinking back on.

Quoted 10 lines
Quoted 5 lines

During testing I also noticed that something likes to cache the initial default value for these immutable flagged properties for userspace queries - so when you call xrandr you only end up seeing the default value and not the current >

'xrandr --current' is supposed to not probe hard for new stuff. Without the --current it may or may not result in a full probe depending on the implementation in the ddx and or the kms driver. A full probe should definitely happen after a hotplug. If it's not happening then there is a bug somewhere.

This might be a bug then since I don't use the --current flag (and it exhibits the same issue with it). I just tested this again with the DRM_MODE_PROP_IMMUTABLE flag set and it shows up as 0 for monitors that support it (even though it's set in kernelspace to 1).

Quoted 27 lines
Quoted 18 lines
Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1410

Quoted 6 lines
drivers/gpu/drm/drm_atomic.c +2 -0
+	} else if (property == connector->variable_refresh_enabled_property) {
+		state->variable_refresh_enabled = val;

So one thing I already asked long ago is whether there would a point in exposing some kind of min/max refresh rate range control. Never really got an answer. Was somehting like that considered and rejected?

For the initial patchset it seemed best to keep things simple and target the dynamic adaptation usecase with on/off toggle.

The driver having access to the full range can enable additional functionality that can improve the user experience - a good example is low framerate compensation.

Quoted 8 lines

Adding the properties to support setting the min/max could be done on top of this, however. Driver behavior would likely need to be defined for atomic check. The driver needs to verify with the monitor that the ranges are valid at some point - whether it silently fails or returns an error is an example of something to consider here.

Do you have a specific usecase in mind that needs min/max exposed to userspace?

Quoted 129 lines

Not really. Some vague ideas about video playback and such, and maybe just for power saving. It was just an idea that occurred to me when thinking about this stuff. Although I suppose the compositor could always throttle the flip rate using other means. And in tne end it comes down to a policy question of how the compositor would decide what the allowed range is.

Quoted 121 lines
Quoted 121 lines
Quoted 120 lines
Quoted 116 lines
drivers/gpu/drm/drm_atomic.c +4 -0
   	} else if (property == connector->content_protection_property) {
   		if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
   			DRM_DEBUG_KMS("only drivers can set CP Enabled\n");
@@ -1508,6 +1513,10 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
   		*val = state->content_type;
   	} else if (property == connector->scaling_mode_property) {
   		*val = state->scaling_mode;
+	} else if (property == connector->variable_refresh_capable_property) {
+		*val = state->variable_refresh_capable;
+	} else if (property == connector->variable_refresh_enabled_property) {
+		*val = state->variable_refresh_enabled;
   	} else if (property == connector->content_protection_property) {
   		*val = state->content_protection;
   	} else if (property == config->writeback_fb_id_property) {
drivers/gpu/drm/drm_connector.c +35 -0
index 6011d769d50b..37fb33fa77b9 100644
@@ -1250,6 +1250,41 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
   }
   EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
 
+/**
+ * drm_connector_attach_variable_refresh_properties - creates and attaches
+ * properties for connectors that support adaptive refresh
+ * @connector: connector to create adaptive refresh properties on
+ */
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (!connector->variable_refresh_capable_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_capable");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_capable_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	if (!connector->variable_refresh_enabled_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_enabled");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_enabled_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_variable_refresh_properties);
+
   /**
    * drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
    * @connector: connector to attach scaling mode property on.
include/drm/drm_connector.h +27 -0
index 97ea41dc678f..105a127e9191 100644
@@ -448,6 +448,18 @@ struct drm_connector_state {
   	 */
   	unsigned int content_protection;
 
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is supported on the device.
+	 */
+	bool variable_refresh_capable;
+
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is enabled.
+	 */
+	bool variable_refresh_enabled;
+
   	/**
   	 * @writeback_job: Writeback job for writeback connectors
   	 *
@@ -909,6 +921,19 @@ struct drm_connector {
   	 */
   	struct drm_property *scaling_mode_property;
 
+	/**
+	 * @variable_refresh_capable_property: Optional property for
+	 * querying hardware support for variable refresh.
+	 */
+	struct drm_property *variable_refresh_capable_property;
+
+	/**
+	 * @variable_refresh_enabled_property: Optional property for
+	 * enabling or disabling support for variable refresh
+	 * on the connector.
+	 */
+	struct drm_property *variable_refresh_enabled_property;
+
   	/**
   	 * @content_protection_property: DRM ENUM property for content
   	 * protection. See drm_connector_attach_content_protection_property().
@@ -1182,6 +1207,8 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev);
   int drm_connector_attach_content_type_property(struct drm_connector *dev);
   int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
   					       u32 scaling_mode_mask);
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector);
   int drm_connector_attach_content_protection_property(
   		struct drm_connector *connector);
   int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
Signature · 1 line
2.17.1
Signature · 2 lines
Ville Syrjälä
Intel

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#11 lore raw

Re: [PATCH 1/9] drm: Add variable refresh rate properties to DRM connector

In reply to a message not in the archive
Quoted 99 lines · Ville Syrjälä
Quoted 48 lines · Nicholas
Quoted 42 lines · Ville Syrjälä
Quoted 26 lines · Ville Syrjälä
Quoted 25 lines · Nicholas Kazlauskas

Modern monitor hardware is capable of supporting variable refresh rates and adaptive sync technologies. The properties for querying and controlling these features should be exposed on the DRM connector.

This patch introduces two new properties for variable refresh rate support:

- variable_refresh_capable
- variable_refresh_enabled

These are optional properties that can be added to a DRM connector dynamically by using drm_connector_attach_variable_refresh_properties.

DRM drivers should set variable_refresh_capable as applicable for their hardware. The property variable_refresh_enabled as a userspace controlled option.

Change-Id I5f60f8b57534e1d3dacda4c64c6c9106b42f4439
---
  drivers/gpu/drm/drm_atomic.c    |  9 +++++++++
  drivers/gpu/drm/drm_connector.c | 35 +++++++++++++++++++++++++++++++++
  include/drm/drm_connector.h     | 27 +++++++++++++++++++++++++
  3 files changed, 71 insertions(+)
Quoted 14 lines

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1408

Quoted 11 lines
drivers/gpu/drm/drm_atomic.c +3 -0
index d0478abc01bd..2f89ab0fac87 100644
@@ -1403,6 +1403,11 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
  		state->content_type = val;
  	} else if (property == connector->scaling_mode_property) {
  		state->scaling_mode = val;
+	} else if (property == connector->variable_refresh_capable_property) {
+		DRM_DEBUG_KMS("only drivers can set variable_refresh_capable\n");
+		return -EINVAL;

Why is that needed? Why not just avoid exposing the vrr_enabled prop when it's not supported?

Quoted 4 lines

Ah, I guess you want to change the value after plugging in a new display. Yeah, if we don't want userspace to have to parse the EDID I guess we need this. But in that case it should be marked immutable, and then you don't need any of this atomic state related code for it.

Quoted 5 lines

Yeah, it's for hotplugging that it works this way. The reason it's not marked as immutable is mostly convention - the existing driver write-only properties (with userspace queries) do the same thing.

The immutable property flag is only used for non-connector properties.

There are plenty of immutable connector properties: EDID, TILE, non-desktop, etc. I'm pretty sure there are more immutable connector properties than there are immutable properties on other types of objects. And considering immutable connector properties existed before other types of objects even had any properties I'd say it's well established by now :)

Quoted 4 lines

During testing I also noticed that something likes to cache the initial default value for these immutable flagged properties for userspace queries - so when you call xrandr you only end up seeing the default value and not the current.

'xrandr --current' is supposed to not probe hard for new stuff. Without the --current it may or may not result in a full probe depending on the implementation in the ddx and or the kms driver. A full probe should definitely happen after a hotplug. If it's not happening then there is a bug somewhere.

Quoted 17 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1410

Quoted 5 lines
drivers/gpu/drm/drm_atomic.c +2 -0
+	} else if (property == connector->variable_refresh_enabled_property) {
+		state->variable_refresh_enabled = val;

So one thing I already asked long ago is whether there would a point in exposing some kind of min/max refresh rate range control. Never really got an answer. Was somehting like that considered and rejected?

For the initial patchset it seemed best to keep things simple and target the dynamic adaptation usecase with on/off toggle.

The driver having access to the full range can enable additional functionality that can improve the user experience - a good example is low framerate compensation.

Quoted 8 lines

Adding the properties to support setting the min/max could be done on top of this, however. Driver behavior would likely need to be defined for atomic check. The driver needs to verify with the monitor that the ranges are valid at some point - whether it silently fails or returns an error is an example of something to consider here.

Do you have a specific usecase in mind that needs min/max exposed to userspace?

Quoted 7 lines

Not really. Some vague ideas about video playback and such, and maybe just for power saving. It was just an idea that occurred to me when thinking about this stuff. Although I suppose the compositor could always throttle the flip rate using other means. And in tne end it comes down to a policy question of how the compositor would decide what the allowed range is.

Responding here to both your and Manasi's questions.

What good would exposing vmin/vmax do?

The gaming case is very well served by the properties Nicholas is introducing and the video playback case would be best served with something like a target_present_time or target_frame_duration. Exposing vmin/vmax might unnecessarily tie userland to DP/HDMI spec details and complicate an already complex problem.

Harry

Quoted 113 lines
Quoted 113 lines
Quoted 113 lines
Quoted 113 lines
Quoted 113 lines
drivers/gpu/drm/drm_atomic.c +4 -0
  	} else if (property == connector->content_protection_property) {
  		if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
  			DRM_DEBUG_KMS("only drivers can set CP Enabled\n");
@@ -1508,6 +1513,10 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
  		*val = state->content_type;
  	} else if (property == connector->scaling_mode_property) {
  		*val = state->scaling_mode;
+	} else if (property == connector->variable_refresh_capable_property) {
+		*val = state->variable_refresh_capable;
+	} else if (property == connector->variable_refresh_enabled_property) {
+		*val = state->variable_refresh_enabled;
  	} else if (property == connector->content_protection_property) {
  		*val = state->content_protection;
  	} else if (property == config->writeback_fb_id_property) {
drivers/gpu/drm/drm_connector.c +35 -0
index 6011d769d50b..37fb33fa77b9 100644
@@ -1250,6 +1250,41 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
  }
  EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
 
+/**
+ * drm_connector_attach_variable_refresh_properties - creates and attaches
+ * properties for connectors that support adaptive refresh
+ * @connector: connector to create adaptive refresh properties on
+ */
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (!connector->variable_refresh_capable_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_capable");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_capable_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	if (!connector->variable_refresh_enabled_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_enabled");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_enabled_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_variable_refresh_properties);
+
  /**
   * drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
   * @connector: connector to attach scaling mode property on.
include/drm/drm_connector.h +27 -0
index 97ea41dc678f..105a127e9191 100644
@@ -448,6 +448,18 @@ struct drm_connector_state {
  	 */
  	unsigned int content_protection;
 
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is supported on the device.
+	 */
+	bool variable_refresh_capable;
+
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is enabled.
+	 */
+	bool variable_refresh_enabled;
+
  	/**
  	 * @writeback_job: Writeback job for writeback connectors
  	 *
@@ -909,6 +921,19 @@ struct drm_connector {
  	 */
  	struct drm_property *scaling_mode_property;
 
+	/**
+	 * @variable_refresh_capable_property: Optional property for
+	 * querying hardware support for variable refresh.
+	 */
+	struct drm_property *variable_refresh_capable_property;
+
+	/**
+	 * @variable_refresh_enabled_property: Optional property for
+	 * enabling or disabling support for variable refresh
+	 * on the connector.
+	 */
+	struct drm_property *variable_refresh_enabled_property;
+
  	/**
  	 * @content_protection_property: DRM ENUM property for content
  	 * protection. See drm_connector_attach_content_protection_property().
@@ -1182,6 +1207,8 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev);
  int drm_connector_attach_content_type_property(struct drm_connector *dev);
  int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
  					       u32 scaling_mode_mask);
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector);
  int drm_connector_attach_content_protection_property(
  		struct drm_connector *connector);
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
include/drm/drm_connector.h +0 -0
  int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
Signature · 1 line
2.17.1
Signature · 2 lines
Ville Syrjälä
Intel

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#12 lore raw

Re: [PATCH 1/9] drm: Add variable refresh rate properties to DRM connector

In reply to Kazlauskas, Nicholas
Quoted 52 lines · Nicholas
Quoted 42 lines · Ville Syrjälä
Quoted 26 lines · Ville Syrjälä
Quoted 25 lines · Nicholas Kazlauskas

Modern monitor hardware is capable of supporting variable refresh rates and adaptive sync technologies. The properties for querying and controlling these features should be exposed on the DRM connector.

This patch introduces two new properties for variable refresh rate support:

- variable_refresh_capable
- variable_refresh_enabled

These are optional properties that can be added to a DRM connector dynamically by using drm_connector_attach_variable_refresh_properties.

DRM drivers should set variable_refresh_capable as applicable for their hardware. The property variable_refresh_enabled as a userspace controlled option.

Change-Id I5f60f8b57534e1d3dacda4c64c6c9106b42f4439
---
  drivers/gpu/drm/drm_atomic.c    |  9 +++++++++
  drivers/gpu/drm/drm_connector.c | 35 +++++++++++++++++++++++++++++++++
  include/drm/drm_connector.h     | 27 +++++++++++++++++++++++++
  3 files changed, 71 insertions(+)
Quoted 14 lines

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1408

Quoted 11 lines
drivers/gpu/drm/drm_atomic.c +3 -0
index d0478abc01bd..2f89ab0fac87 100644
@@ -1403,6 +1403,11 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
  		state->content_type = val;
  	} else if (property == connector->scaling_mode_property) {
  		state->scaling_mode = val;
+	} else if (property == connector->variable_refresh_capable_property) {
+		DRM_DEBUG_KMS("only drivers can set variable_refresh_capable\n");
+		return -EINVAL;

Why is that needed? Why not just avoid exposing the vrr_enabled prop when it's not supported?

Quoted 4 lines

Ah, I guess you want to change the value after plugging in a new display. Yeah, if we don't want userspace to have to parse the EDID I guess we need this. But in that case it should be marked immutable, and then you don't need any of this atomic state related code for it.

Yeah, it's for hotplugging that it works this way. The reason it's not marked as immutable is mostly convention - the existing driver write-only properties (with userspace queries) do the same thing.

Quoted 5 lines

The immutable property flag is only used for non-connector properties. During testing I also noticed that something likes to cache the initial default value for these immutable flagged properties for userspace queries - so when you call xrandr you only end up seeing the default value and not the current.

Immutable is used for the edid property. So exactly what you want here - static data that only depends upon the plugged in monitor, which userspace isn't allowed to change.

Yeah immutable is mislabelled, it just means "userspace can't change it". It's not actually for immutable stuff. The docs should explain this somewhere, if not, pls type a patch to fix this.
-Daniel

Quoted 144 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1410

Quoted 5 lines
drivers/gpu/drm/drm_atomic.c +2 -0
+	} else if (property == connector->variable_refresh_enabled_property) {
+		state->variable_refresh_enabled = val;

So one thing I already asked long ago is whether there would a point in exposing some kind of min/max refresh rate range control. Never really got an answer. Was somehting like that considered and rejected?

For the initial patchset it seemed best to keep things simple and target the dynamic adaptation usecase with on/off toggle.

The driver having access to the full range can enable additional functionality that can improve the user experience - a good example is low framerate compensation.

Adding the properties to support setting the min/max could be done on top of this, however. Driver behavior would likely need to be defined for atomic check. The driver needs to verify with the monitor that the ranges are valid at some point - whether it silently fails or returns an error is an example of something to consider here.

Do you have a specific usecase in mind that needs min/max exposed to userspace?

Quoted 117 lines
Quoted 116 lines
Quoted 112 lines
drivers/gpu/drm/drm_atomic.c +4 -0
  	} else if (property == connector->content_protection_property) {
  		if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
  			DRM_DEBUG_KMS("only drivers can set CP Enabled\n");
@@ -1508,6 +1513,10 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
  		*val = state->content_type;
  	} else if (property == connector->scaling_mode_property) {
  		*val = state->scaling_mode;
+	} else if (property == connector->variable_refresh_capable_property) {
+		*val = state->variable_refresh_capable;
+	} else if (property == connector->variable_refresh_enabled_property) {
+		*val = state->variable_refresh_enabled;
  	} else if (property == connector->content_protection_property) {
  		*val = state->content_protection;
  	} else if (property == config->writeback_fb_id_property) {
drivers/gpu/drm/drm_connector.c +35 -0
index 6011d769d50b..37fb33fa77b9 100644
@@ -1250,6 +1250,41 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
  }
  EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
+/**
+ * drm_connector_attach_variable_refresh_properties - creates and attaches
+ * properties for connectors that support adaptive refresh
+ * @connector: connector to create adaptive refresh properties on
+ */
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (!connector->variable_refresh_capable_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_capable");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_capable_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	if (!connector->variable_refresh_enabled_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_enabled");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_enabled_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_variable_refresh_properties);
+
  /**
   * drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
   * @connector: connector to attach scaling mode property on.
include/drm/drm_connector.h +27 -0
index 97ea41dc678f..105a127e9191 100644
@@ -448,6 +448,18 @@ struct drm_connector_state {
  	 */
  	unsigned int content_protection;
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is supported on the device.
+	 */
+	bool variable_refresh_capable;
+
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is enabled.
+	 */
+	bool variable_refresh_enabled;
+
  	/**
  	 * @writeback_job: Writeback job for writeback connectors
  	 *
@@ -909,6 +921,19 @@ struct drm_connector {
  	 */
  	struct drm_property *scaling_mode_property;
+	/**
+	 * @variable_refresh_capable_property: Optional property for
+	 * querying hardware support for variable refresh.
+	 */
+	struct drm_property *variable_refresh_capable_property;
+
+	/**
+	 * @variable_refresh_enabled_property: Optional property for
+	 * enabling or disabling support for variable refresh
+	 * on the connector.
+	 */
+	struct drm_property *variable_refresh_enabled_property;
+
  	/**
  	 * @content_protection_property: DRM ENUM property for content
  	 * protection. See drm_connector_attach_content_protection_property().
@@ -1182,6 +1207,8 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev);
  int drm_connector_attach_content_type_property(struct drm_connector *dev);
  int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
  					       u32 scaling_mode_mask);
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector);
  int drm_connector_attach_content_protection_property(
  		struct drm_connector *connector);
  int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
Signature · 1 line
2.17.1
Signature · 2 lines
Ville Syrjälä
Intel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw

Re: [PATCH 1/9] drm: Add variable refresh rate properties to DRM connector

In reply to Ville Syrjälä
Quoted 41 lines · Ville Syrjälä
Quoted 30 lines · Nicholas Kazlauskas

Modern monitor hardware is capable of supporting variable refresh rates and adaptive sync technologies. The properties for querying and controlling these features should be exposed on the DRM connector.

This patch introduces two new properties for variable refresh rate support:

- variable_refresh_capable
- variable_refresh_enabled

These are optional properties that can be added to a DRM connector dynamically by using drm_connector_attach_variable_refresh_properties.

DRM drivers should set variable_refresh_capable as applicable for their hardware. The property variable_refresh_enabled as a userspace controlled option.

Change-Id I5f60f8b57534e1d3dacda4c64c6c9106b42f4439
---
 drivers/gpu/drm/drm_atomic.c    |  9 +++++++++
 drivers/gpu/drm/drm_connector.c | 35 +++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h     | 27 +++++++++++++++++++++++++
 3 files changed, 71 insertions(+)
drivers/gpu/drm/drm_atomic.c +0 -0
index d0478abc01bd..2f89ab0fac87 100644

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1408

Quoted 6 lines
drivers/gpu/drm/drm_atomic.c +3 -0
@@ -1403,6 +1403,11 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 		state->content_type = val;
 	} else if (property == connector->scaling_mode_property) {
 		state->scaling_mode = val;
+	} else if (property == connector->variable_refresh_capable_property) {
+		DRM_DEBUG_KMS("only drivers can set variable_refresh_capable\n");
+		return -EINVAL;

Why is that needed? Why not just avoid exposing the vrr_enabled prop when it's not supported?

Quoted 7 lines

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1410

Quoted 2 lines
drivers/gpu/drm/drm_atomic.c +2 -0
+	} else if (property == connector->variable_refresh_enabled_property) {
+		state->variable_refresh_enabled = val;

So one thing I already asked long ago is whether there would a point in exposing some kind of min/max refresh rate range control. Never really got an answer. Was somehting like that considered and rejected?

Yes I think we will need the min/max refresh rate to be exposed from the driver. Since the driver will parse the edid and monitor range descriptor information and will know the min/max variable refresh values and it needs
to expose that to the userspace along with the variable_refresh_capable property.

Manasi

Quoted 106 lines
Quoted 106 lines
drivers/gpu/drm/drm_atomic.c +4 -0
 	} else if (property == connector->content_protection_property) {
 		if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
 			DRM_DEBUG_KMS("only drivers can set CP Enabled\n");
@@ -1508,6 +1513,10 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
 		*val = state->content_type;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
+	} else if (property == connector->variable_refresh_capable_property) {
+		*val = state->variable_refresh_capable;
+	} else if (property == connector->variable_refresh_enabled_property) {
+		*val = state->variable_refresh_enabled;
 	} else if (property == connector->content_protection_property) {
 		*val = state->content_protection;
 	} else if (property == config->writeback_fb_id_property) {
drivers/gpu/drm/drm_connector.c +35 -0
index 6011d769d50b..37fb33fa77b9 100644
@@ -1250,6 +1250,41 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
 
+/**
+ * drm_connector_attach_variable_refresh_properties - creates and attaches
+ * properties for connectors that support adaptive refresh
+ * @connector: connector to create adaptive refresh properties on
+ */
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (!connector->variable_refresh_capable_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_capable");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_capable_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	if (!connector->variable_refresh_enabled_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_enabled");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_enabled_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_variable_refresh_properties);
+
 /**
  * drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
  * @connector: connector to attach scaling mode property on.
include/drm/drm_connector.h +25 -0
index 97ea41dc678f..105a127e9191 100644
@@ -448,6 +448,18 @@ struct drm_connector_state {
 	 */
 	unsigned int content_protection;
 
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is supported on the device.
+	 */
+	bool variable_refresh_capable;
+
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is enabled.
+	 */
+	bool variable_refresh_enabled;
+
 	/**
 	 * @writeback_job: Writeback job for writeback connectors
 	 *
@@ -909,6 +921,19 @@ struct drm_connector {
 	 */
 	struct drm_property *scaling_mode_property;
 
+	/**
+	 * @variable_refresh_capable_property: Optional property for
+	 * querying hardware support for variable refresh.
+	 */
+	struct drm_property *variable_refresh_capable_property;
+
+	/**
+	 * @variable_refresh_enabled_property: Optional property for
+	 * enabling or disabling support for variable refresh
+	 * on the connector.
+	 */
+	struct drm_property *variable_refresh_enabled_property;
+
 	/**
 	 * @content_protection_property: DRM ENUM property for content
 	 * protection. See drm_connector_attach_content_protection_property().
@@ -1182,6 +1207,8 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev);
 int drm_connector_attach_content_type_property(struct drm_connector *dev);
 int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
Quoted 12 lines
Quoted 8 lines
include/drm/drm_connector.h +2 -0
 					       u32 scaling_mode_mask);
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector);
 int drm_connector_attach_content_protection_property(
 		struct drm_connector *connector);
 int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
Signature · 1 line
2.17.1
Signature · 2 lines
Ville Syrjälä
Intel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#14 lore raw

Re: [PATCH 1/9] drm: Add variable refresh rate properties to DRM connector

In reply to Nicholas Kazlauskas

Thanks for the patch, I have meant to send these patches out sitting in my internal tree but never got to it.
Find my comments below:

Quoted 30 lines · Nicholas Kazlauskas

Modern monitor hardware is capable of supporting variable refresh rates and adaptive sync technologies. The properties for querying and controlling these features should be exposed on the DRM connector.

This patch introduces two new properties for variable refresh rate support:

- variable_refresh_capable
- variable_refresh_enabled

These are optional properties that can be added to a DRM connector dynamically by using drm_connector_attach_variable_refresh_properties.

DRM drivers should set variable_refresh_capable as applicable for their hardware. The property variable_refresh_enabled as a userspace controlled option.

Change-Id I5f60f8b57534e1d3dacda4c64c6c9106b42f4439
---
 drivers/gpu/drm/drm_atomic.c    |  9 +++++++++
 drivers/gpu/drm/drm_connector.c | 35 +++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h     | 27 +++++++++++++++++++++++++
 3 files changed, 71 insertions(+)
drivers/gpu/drm/drm_atomic.c +0 -0
index d0478abc01bd..2f89ab0fac87 100644

drivers/gpu/drm/drm_atomic.c static int drm_atomic_connector_set_property(struct drm_connector *connector, · line 1407

Quoted 5 lines
drivers/gpu/drm/drm_atomic.c +2 -0
@@ -1403,6 +1403,11 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
 		state->content_type = val;
 	} else if (property == connector->scaling_mode_property) {
 		state->scaling_mode = val;
+	} else if (property == connector->variable_refresh_capable_property) {
+		DRM_DEBUG_KMS("only drivers can set variable_refresh_capable\n");

No need for this debug message here if its defined as an immutable prop

Quoted 28 lines
drivers/gpu/drm/drm_atomic.c +7 -0
+		return -EINVAL;
+	} else if (property == connector->variable_refresh_enabled_property) {
+		state->variable_refresh_enabled = val;
 	} else if (property == connector->content_protection_property) {
 		if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
 			DRM_DEBUG_KMS("only drivers can set CP Enabled\n");
@@ -1508,6 +1513,10 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
 		*val = state->content_type;
 	} else if (property == connector->scaling_mode_property) {
 		*val = state->scaling_mode;
+	} else if (property == connector->variable_refresh_capable_property) {
+		*val = state->variable_refresh_capable;
+	} else if (property == connector->variable_refresh_enabled_property) {
+		*val = state->variable_refresh_enabled;
 	} else if (property == connector->content_protection_property) {
 		*val = state->content_protection;
 	} else if (property == config->writeback_fb_id_property) {
drivers/gpu/drm/drm_connector.c +3 -0
index 6011d769d50b..37fb33fa77b9 100644
@@ -1250,6 +1250,41 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
 
+/**
+ * drm_connector_attach_variable_refresh_properties - creates and attaches
+ * properties for connectors that support adaptive refresh

drivers/gpu/drm/drm_connector.c int drm_mode_create_scaling_mode_property(struct drm_device *dev) · line 1265

Quoted 10 lines
drivers/gpu/drm/drm_connector.c +10 -0
+ * @connector: connector to create adaptive refresh properties on
+ */
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (!connector->variable_refresh_capable_property) {
+		prop = drm_property_create_bool(dev, 0,

You can create this property as a DRM_MODE_PROP_IMMUTABLE property here which would indicate that it cannot be changed by the userspace and avoid the check later.

Manasi

Quoted 84 lines
drivers/gpu/drm/drm_connector.c +22 -0
+			"variable_refresh_capable");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_capable_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	if (!connector->variable_refresh_enabled_property) {
+		prop = drm_property_create_bool(dev, 0,
+			"variable_refresh_enabled");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->variable_refresh_enabled_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_variable_refresh_properties);
+
 /**
  * drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
  * @connector: connector to attach scaling mode property on.
include/drm/drm_connector.h +27 -0
index 97ea41dc678f..105a127e9191 100644
@@ -448,6 +448,18 @@ struct drm_connector_state {
 	 */
 	unsigned int content_protection;
 
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is supported on the device.
+	 */
+	bool variable_refresh_capable;
+
+	/**
+	 * @variable_refresh_enabled: Connector property used to check
+	 * if variable refresh is enabled.
+	 */
+	bool variable_refresh_enabled;
+
 	/**
 	 * @writeback_job: Writeback job for writeback connectors
 	 *
@@ -909,6 +921,19 @@ struct drm_connector {
 	 */
 	struct drm_property *scaling_mode_property;
 
+	/**
+	 * @variable_refresh_capable_property: Optional property for
+	 * querying hardware support for variable refresh.
+	 */
+	struct drm_property *variable_refresh_capable_property;
+
+	/**
+	 * @variable_refresh_enabled_property: Optional property for
+	 * enabling or disabling support for variable refresh
+	 * on the connector.
+	 */
+	struct drm_property *variable_refresh_enabled_property;
+
 	/**
 	 * @content_protection_property: DRM ENUM property for content
 	 * protection. See drm_connector_attach_content_protection_property().
@@ -1182,6 +1207,8 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev);
 int drm_connector_attach_content_type_property(struct drm_connector *dev);
 int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
 					       u32 scaling_mode_mask);
+int drm_connector_attach_variable_refresh_properties(
+	struct drm_connector *connector);
 int drm_connector_attach_content_protection_property(
 		struct drm_connector *connector);
 int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#15 lore raw

PATCH 2/9 drm: Add variable refresh property to DRM CRTC

In reply to a message not in the archive

Variable refresh rate algorithms have typically been enabled only when the display is covered by a single source of content.

This patch introduces a new default CRTC property that helps hint to the driver when the CRTC composition is suitable for variable refresh rate algorithms. Userspace can set this property dynamically as the composition changes.

Whether the variable refresh rate algorithms are active will still depend on the CRTC being suitable and the connector being capable and enabled by the user for variable refresh rate support.

It is worth noting that while the property is atomic it isn't filtered from legacy userspace queries. This allows for Xorg userspace drivers to implement support in non-atomic setups.

Change-Id I5a5044f48fc68fcdbcfaa5141e83b44747d7116b
---
 drivers/gpu/drm/drm_atomic.c        |  6 ++++++
 drivers/gpu/drm/drm_atomic_helper.c |  1 +
 drivers/gpu/drm/drm_crtc.c          |  2 ++
 drivers/gpu/drm/drm_mode_config.c   |  6 ++++++
 include/drm/drm_crtc.h              | 13 +++++++++++++
 include/drm/drm_mode_config.h       |  8 ++++++++
 6 files changed, 36 insertions(+)
drivers/gpu/drm/drm_atomic.c +6 -0
index 2f89ab0fac87..46c50c1f267b 100644
@@ -553,6 +553,10 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
 		ret = drm_atomic_set_mode_prop_for_crtc(state, mode);
 		drm_property_blob_put(mode);
 		return ret;
+	} else if (property == config->prop_variable_refresh) {
+		if (state->variable_refresh != val)
+			state->variable_refresh_changed = true;
+		state->variable_refresh = val;
 	} else if (property == config->degamma_lut_property) {
 		ret = drm_atomic_replace_property_blob_from_id(dev,
 					&state->degamma_lut,
@@ -627,6 +631,8 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
 		*val = state->active;
 	else if (property == config->prop_mode_id)
 		*val = (state->mode_blob) ? state->mode_blob->base.id : 0;
+	else if (property == config->prop_variable_refresh)
+		*val = state->variable_refresh;
 	else if (property == config->degamma_lut_property)
 		*val = (state->degamma_lut) ? state->degamma_lut->base.id : 0;
 	else if (property == config->ctm_property)
drivers/gpu/drm/drm_atomic_helper.c +1 -0
index 2c23a48482da..dd01ab041eff 100644
@@ -3472,6 +3472,7 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
 	state->planes_changed = false;
 	state->connectors_changed = false;
 	state->color_mgmt_changed = false;
+	state->variable_refresh_changed = false;
 	state->zpos_changed = false;
 	state->commit = NULL;
 	state->event = NULL;
drivers/gpu/drm/drm_crtc.c +2 -0
index bae43938c8f6..f18b60ce7599 100644
@@ -337,6 +337,8 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,
 		drm_object_attach_property(&crtc->base, config->prop_mode_id, 0);
 		drm_object_attach_property(&crtc->base,
 					   config->prop_out_fence_ptr, 0);
+		drm_object_attach_property(&crtc->base,
+					   config->prop_variable_refresh, 0);
 	}
 
 	return 0;
drivers/gpu/drm/drm_mode_config.c +6 -0
index 21e353bd3948..5847ac1e88c1 100644
@@ -311,6 +311,12 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.prop_mode_id = prop;
 
+	prop = drm_property_create_bool(dev, 0,
+			"VARIABLE_REFRESH");
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.prop_variable_refresh = prop;
+
 	prop = drm_property_create(dev,
 			DRM_MODE_PROP_BLOB,
 			"DEGAMMA_LUT", 0);
include/drm/drm_crtc.h +13 -0
index b21437bc95bf..32b77f18ce6d 100644
@@ -168,6 +168,12 @@ struct drm_crtc_state {
 	 * drivers to steer the atomic commit control flow.
 	 */
 	bool color_mgmt_changed : 1;
+	/**
+	 * @variable_refresh_changed: Variable refresh support has changed
+	 * on the CRTC. Used by the atomic helpers and drivers to steer the
+	 * atomic commit control flow.
+	 */
+	bool variable_refresh_changed : 1;
 
 	/**
 	 * @no_vblank:
@@ -290,6 +296,13 @@ struct drm_crtc_state {
 	 */
 	u32 pageflip_flags;
 
+	/**
+	 * @variable_refresh:
+	 *
+	 * Indicates whether the CRTC is suitable for variable refresh rate.
+	 */
+	bool variable_refresh;
+
 	/**
 	 * @event:
 	 *
include/drm/drm_mode_config.h +8 -0
index a0b202e1d69a..9039dee49c83 100644
@@ -639,6 +639,14 @@ struct drm_mode_config {
 	 * connectors must be of and active must be set to disabled, too.
 	 */
 	struct drm_property *prop_mode_id;
+	/**
+	 * @prop_variable_refresh: Default atomic CRTC property to indicate
+	 * whether the CRTC is suitable for variable refresh rate support.
+	 *
+	 * This is only an indication of support, not whether variable
+	 * refresh is active on the CRTC.
+	 */
+	struct drm_property *prop_variable_refresh;
 
 	/**
 	 * @dvi_i_subconnector_property: Optional DVI-I property to
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#16 lore raw

PATCH 3/9 drm/amdgpu: fill in amdgpu_dm_remove_sink_from_freesync_module

In reply to a message not in the archive

From: Harry Wentland <[email protected]>

Add code to tear down freesync modules when disabled.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 40 ++++++++++++++-----
 1 file changed, 29 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +29 -11
index af6adffba788..9dad505d132f 100644
@@ -5230,19 +5230,37 @@ void amdgpu_dm_add_sink_to_freesync_module(struct drm_connector *connector,
 			dm_con_state->freesync_capable = true;
 		}
 	}
-
-	/*
-	 * TODO figure out how to notify user-mode or DRM of freesync caps
-	 * once we figure out how to deal with freesync in an upstreamable
-	 * fashion
-	 */
-
 }
 
 void amdgpu_dm_remove_sink_from_freesync_module(struct drm_connector *connector)
 {
-	/*
-	 * TODO fill in once we figure out how to deal with freesync in
-	 * an upstreamable fashion
-	 */
+	struct amdgpu_dm_connector *amdgpu_dm_connector =
+			to_amdgpu_dm_connector(connector);
+	struct dm_connector_state *dm_con_state;
+	struct drm_device *dev = connector->dev;
+	struct amdgpu_device *adev = dev->dev_private;
+
+	if (!amdgpu_dm_connector->dc_sink || !adev->dm.freesync_module) {
+		DRM_ERROR("dc_sink NULL or no free_sync module.\n");
+		return;
+	}
+
+	if (!connector->state) {
+		DRM_ERROR("%s - Connector has no state", __func__);
+		return;
+	}
+
+	dm_con_state = to_dm_connector_state(connector->state);
+
+	amdgpu_dm_connector->min_vfreq = 0;
+	amdgpu_dm_connector->max_vfreq = 0;
+	amdgpu_dm_connector->pixel_clock_mhz = 0;
+
+	memset(&amdgpu_dm_connector->caps, 0, sizeof(amdgpu_dm_connector->caps));
+
+	dm_con_state->freesync_capable = false;
+
+	dm_con_state->user_enable.enable_for_gaming = false;
+	dm_con_state->user_enable.enable_for_static = false;
+	dm_con_state->user_enable.enable_for_video = false;
 }
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#17 lore raw

PATCH 5/9 drm/amdgpu/display: add freesync drm properties

In reply to a message not in the archive

From: Harry Wentland <[email protected]>

Add connector properties for controlling freesync.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   | 13 +++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h      |  4 ++++
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 +++++++++++++++++++
 3 files changed, 36 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +13 -0
index 6748cd7fc129..642b47c5f4b8 100644
@@ -626,6 +626,19 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
 					 "dither",
 					 amdgpu_dither_enum_list, sz);
 
+	if (amdgpu_device_has_dc_support(adev)) {
+		adev->mode_info.freesync_property =
+			drm_property_create_bool(adev->ddev, 0, "freesync");
+		if (!adev->mode_info.freesync_property)
+			return -ENOMEM;
+		adev->mode_info.freesync_capable_property =
+			drm_property_create_bool(adev->ddev,
+						 0,
+						 "freesync_capable");
+		if (!adev->mode_info.freesync_capable_property)
+			return -ENOMEM;
+	}
+
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +4 -0
index b9e9e8b02fb7..f91a9bdcd63c 100644
@@ -339,6 +339,10 @@ struct amdgpu_mode_info {
 	struct drm_property *audio_property;
 	/* FMT dithering */
 	struct drm_property *dither_property;
+	/* it is used to allow enablement of freesync mode */
+	struct drm_property *freesync_property;
+	/* it is used to know about display capability of freesync mode */
+	struct drm_property *freesync_capable_property;
 	/* hardcoded DFP edid from BIOS */
 	struct edid *bios_hardcoded_edid;
 	int bios_hardcoded_edid_size;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +19 -0
index d599fbfa895b..8be3028850b6 100644
@@ -2718,6 +2718,12 @@ 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 == adev->mode_info.freesync_property) {
+		dm_new_state->freesync_enable = val;
+		ret = 0;
+	} else if (property == adev->mode_info.freesync_capable_property) {
+		dm_new_state->freesync_capable = val;
+		ret = 0;
 	}
 
 	return ret;
@@ -2760,6 +2766,12 @@ 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 == adev->mode_info.freesync_property) {
+		*val = dm_state->freesync_enable;
+		ret = 0;
+	} else if (property == adev->mode_info.freesync_capable_property) {
+		*val = dm_state->freesync_capable;
+		ret = 0;
 	}
 	return ret;
 }
@@ -3584,6 +3596,13 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
 				adev->mode_info.underscan_vborder_property,
 				0);
 
+	if (connector_type == DRM_MODE_CONNECTOR_HDMIA ||
+	    connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
+		drm_object_attach_property(&aconnector->base.base,
+				adev->mode_info.freesync_property, 0);
+		drm_object_attach_property(&aconnector->base.base,
+				adev->mode_info.freesync_capable_property, 0);
+	}
 }
 
 static int amdgpu_dm_i2c_xfer(struct i2c_adapter *i2c_adap,
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#18 lore raw

PATCH 6/9 drm/amdgpu: add freesync ioctl

In reply to a message not in the archive

From: Harry Wentland <[email protected]>

Add the ioctl to enable/disable freesync.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h              |  3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c      | 15 +++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c          |  3 ++-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c    |  4 ++++
 include/uapi/drm/amdgpu_drm.h                    | 16 ++++++++++++++++
 5 files changed, 40 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
index 447c4c7a36d6..95af917007f7 100644
@@ -1193,6 +1193,9 @@ int amdgpu_cs_wait_fences_ioctl(struct drm_device *dev, void *data,
 int amdgpu_gem_metadata_ioctl(struct drm_device *dev, void *data,
 				struct drm_file *filp);
 
+int amdgpu_display_freesync_ioctl(struct drm_device *dev, void *data,
+				  struct drm_file *filp);
+
 /* VRAM scratch page for HDP bug, default vram page */
 struct amdgpu_vram_scratch {
 	struct amdgpu_bo		*robj;
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +15 -0
index 642b47c5f4b8..7d6a36bca9dd 100644
@@ -894,3 +894,18 @@ int amdgpu_display_crtc_idx_to_irq_type(struct amdgpu_device *adev, int crtc)
 		return AMDGPU_CRTC_IRQ_NONE;
 	}
 }
+
+int amdgpu_display_freesync_ioctl(struct drm_device *dev, void *data,
+				  struct drm_file *filp)
+{
+	int ret = -EPERM;
+	struct amdgpu_device *adev = dev->dev_private;
+
+	if (adev->mode_info.funcs->notify_freesync)
+		ret = adev->mode_info.funcs->notify_freesync(dev,data,filp);
+	else
+		DRM_DEBUG("amdgpu no notify_freesync ioctl\n");
+
+	return ret;
+}
+
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -1
index bd98cc5fb97b..5b26e0447221 100644
@@ -1099,7 +1099,8 @@ const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
 	DRM_IOCTL_DEF_DRV(AMDGPU_GEM_METADATA, amdgpu_gem_metadata_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(AMDGPU_GEM_VA, amdgpu_gem_va_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
-	DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, DRM_AUTH|DRM_RENDER_ALLOW)
+	DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
+	DRM_IOCTL_DEF_DRV(AMDGPU_FREESYNC, amdgpu_display_freesync_ioctl, DRM_MASTER)
 };
 const int amdgpu_max_kms_ioctl = ARRAY_SIZE(amdgpu_ioctls_kms);
 
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -0
index 8be3028850b6..56598ed53123 100644
@@ -1584,6 +1584,7 @@ static void dm_bandwidth_update(struct amdgpu_device *adev)
 static int amdgpu_notify_freesync(struct drm_device *dev, void *data,
 				struct drm_file *filp)
 {
+	struct drm_amdgpu_freesync *args = data;
 	struct drm_atomic_state *state;
 	struct drm_modeset_acquire_ctx ctx;
 	struct drm_crtc *crtc;
@@ -1593,6 +1594,9 @@ static int amdgpu_notify_freesync(struct drm_device *dev, void *data,
 	uint8_t i;
 	bool enable = false;
 
+	if (args->op == AMDGPU_FREESYNC_FULLSCREEN_ENTER)
+		enable = true;
+
 	drm_modeset_acquire_init(&ctx, 0);
 
 	state = drm_atomic_state_alloc(dev);
include/uapi/drm/amdgpu_drm.h +16 -0
index 1ceec56de015..94444eeba55b 100644
@@ -54,6 +54,8 @@ extern "C" {
 #define DRM_AMDGPU_VM			0x13
 #define DRM_AMDGPU_FENCE_TO_HANDLE	0x14
 #define DRM_AMDGPU_SCHED		0x15
+/* not upstream */
+#define DRM_AMDGPU_FREESYNC	        0x5d
 
 #define DRM_IOCTL_AMDGPU_GEM_CREATE	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
 #define DRM_IOCTL_AMDGPU_GEM_MMAP	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
@@ -71,6 +73,7 @@ extern "C" {
 #define DRM_IOCTL_AMDGPU_VM		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)
 #define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
 #define DRM_IOCTL_AMDGPU_SCHED		DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)
+#define DRM_IOCTL_AMDGPU_FREESYNC	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FREESYNC, struct drm_amdgpu_freesync)
 
 /**
  * DOC: memory domains
@@ -987,6 +990,19 @@ struct drm_amdgpu_info_vce_clock_table {
 #define AMDGPU_FAMILY_AI			141 /* Vega10 */
 #define AMDGPU_FAMILY_RV			142 /* Raven */
 
+/*
+ * Definition of free sync enter and exit signals
+ * We may have more options in the future
+ */
+#define AMDGPU_FREESYNC_FULLSCREEN_ENTER		1
+#define AMDGPU_FREESYNC_FULLSCREEN_EXIT 		2
+
+struct drm_amdgpu_freesync {
+	__u32 op;			/* AMDGPU_FREESYNC_FULLSCREEN_ENTER or */
+				        /* AMDGPU_FREESYNC_FULLSCREEN_ENTER */
+	__u32 spare[7];
+};
+
 #if defined(__cplusplus)
 }
 #endif
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer
#19 lore raw

Re: [PATCH 6/9] drm/amdgpu: add freesync ioctl

Am 11.09.2018 um 18:13 schrieb Nicholas Kazlauskas:

Quoted 3 lines

From: Harry Wentland <[email protected]>

Add the ioctl to enable/disable freesync.

Why do we still need this now that we have the DRM CRTC properties?

Christian.

Quoted 115 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h              |  3 +++
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c      | 15 +++++++++++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c          |  3 ++-
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c    |  4 ++++
  include/uapi/drm/amdgpu_drm.h                    | 16 ++++++++++++++++
  5 files changed, 40 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
index 447c4c7a36d6..95af917007f7 100644
@@ -1193,6 +1193,9 @@ int amdgpu_cs_wait_fences_ioctl(struct drm_device *dev, void *data,
  int amdgpu_gem_metadata_ioctl(struct drm_device *dev, void *data,
  				struct drm_file *filp);
 
+int amdgpu_display_freesync_ioctl(struct drm_device *dev, void *data,
+				  struct drm_file *filp);
+
  /* VRAM scratch page for HDP bug, default vram page */
  struct amdgpu_vram_scratch {
  	struct amdgpu_bo		*robj;
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +15 -0
index 642b47c5f4b8..7d6a36bca9dd 100644
@@ -894,3 +894,18 @@ int amdgpu_display_crtc_idx_to_irq_type(struct amdgpu_device *adev, int crtc)
  		return AMDGPU_CRTC_IRQ_NONE;
  	}
  }
+
+int amdgpu_display_freesync_ioctl(struct drm_device *dev, void *data,
+				  struct drm_file *filp)
+{
+	int ret = -EPERM;
+	struct amdgpu_device *adev = dev->dev_private;
+
+	if (adev->mode_info.funcs->notify_freesync)
+		ret = adev->mode_info.funcs->notify_freesync(dev,data,filp);
+	else
+		DRM_DEBUG("amdgpu no notify_freesync ioctl\n");
+
+	return ret;
+}
+
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -1
index bd98cc5fb97b..5b26e0447221 100644
@@ -1099,7 +1099,8 @@ const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
  	DRM_IOCTL_DEF_DRV(AMDGPU_GEM_METADATA, amdgpu_gem_metadata_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  	DRM_IOCTL_DEF_DRV(AMDGPU_GEM_VA, amdgpu_gem_va_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
  	DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
-	DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, DRM_AUTH|DRM_RENDER_ALLOW)
+	DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
+	DRM_IOCTL_DEF_DRV(AMDGPU_FREESYNC, amdgpu_display_freesync_ioctl, DRM_MASTER)
  };
  const int amdgpu_max_kms_ioctl = ARRAY_SIZE(amdgpu_ioctls_kms);
 
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -0
index 8be3028850b6..56598ed53123 100644
@@ -1584,6 +1584,7 @@ static void dm_bandwidth_update(struct amdgpu_device *adev)
  static int amdgpu_notify_freesync(struct drm_device *dev, void *data,
  				struct drm_file *filp)
  {
+	struct drm_amdgpu_freesync *args = data;
  	struct drm_atomic_state *state;
  	struct drm_modeset_acquire_ctx ctx;
  	struct drm_crtc *crtc;
@@ -1593,6 +1594,9 @@ static int amdgpu_notify_freesync(struct drm_device *dev, void *data,
  	uint8_t i;
  	bool enable = false;
 
+	if (args->op == AMDGPU_FREESYNC_FULLSCREEN_ENTER)
+		enable = true;
+
  	drm_modeset_acquire_init(&ctx, 0);
 
  	state = drm_atomic_state_alloc(dev);
include/uapi/drm/amdgpu_drm.h +9 -0
index 1ceec56de015..94444eeba55b 100644
@@ -54,6 +54,8 @@ extern "C" {
  #define DRM_AMDGPU_VM			0x13
  #define DRM_AMDGPU_FENCE_TO_HANDLE	0x14
  #define DRM_AMDGPU_SCHED		0x15
+/* not upstream */
+#define DRM_AMDGPU_FREESYNC	        0x5d
 
  #define DRM_IOCTL_AMDGPU_GEM_CREATE	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
  #define DRM_IOCTL_AMDGPU_GEM_MMAP	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
@@ -71,6 +73,7 @@ extern "C" {
  #define DRM_IOCTL_AMDGPU_VM		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)
  #define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
  #define DRM_IOCTL_AMDGPU_SCHED		DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)
+#define DRM_IOCTL_AMDGPU_FREESYNC	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FREESYNC, struct drm_amdgpu_freesync)
 
  /**
   * DOC: memory domains
@@ -987,6 +990,19 @@ struct drm_amdgpu_info_vce_clock_table {
  #define AMDGPU_FAMILY_AI			141 /* Vega10 */
  #define AMDGPU_FAMILY_RV			142 /* Raven */
 
+/*
+ * Definition of free sync enter and exit signals
+ * We may have more options in the future
+ */
+#define AMDGPU_FREESYNC_FULLSCREEN_ENTER		1
+#define AMDGPU_FREESYNC_FULLSCREEN_EXIT 		2

include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_info_vce_clock_table { · line 1008

Quoted 10 lines
include/uapi/drm/amdgpu_drm.h +7 -0
+
+struct drm_amdgpu_freesync {
+	__u32 op;			/* AMDGPU_FREESYNC_FULLSCREEN_ENTER or */
+				        /* AMDGPU_FREESYNC_FULLSCREEN_ENTER */
+	__u32 spare[7];
+};
+
  #if defined(__cplusplus)
  }
  #endif

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#20 lore raw

Re: [PATCH 6/9] drm/amdgpu: add freesync ioctl

Quoted 6 lines · Christian König

Am 11.09.2018 um 18:13 schrieb Nicholas Kazlauskas:

Quoted 3 lines

From: Harry Wentland <[email protected]>

Add the ioctl to enable/disable freesync.

Why do we still need this now that we have the DRM CRTC properties?

These patches were already merged into amd-staging-drm-next so we felt it was best to just base the existing ones off of this work to keep things consistent.

The later patches in the series remove most of it but it looks like some of ioctl stuff itself was missed in amdgpu. It could probably use another patch on top of this to finish cleaning it up.

Quoted 121 lines

Christian.

Quoted 118 lines

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h              |  3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_display.c      | 15 +++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c          |  3 ++- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c    |  4 ++++ include/uapi/drm/amdgpu_drm.h                    | 16 ++++++++++++++++

  5 files changed, 40 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
index 447c4c7a36d6..95af917007f7 100644
@@ -1193,6 +1193,9 @@ int amdgpu_cs_wait_fences_ioctl(struct 
 drm_device *dev, void *data,
   int amdgpu_gem_metadata_ioctl(struct drm_device *dev, void *data,
                   struct drm_file *filp);
+int amdgpu_display_freesync_ioctl(struct drm_device *dev, void *data,
+                  struct drm_file *filp);
+
   /* VRAM scratch page for HDP bug, default vram page */
   struct amdgpu_vram_scratch {
       struct amdgpu_bo        *robj;
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -0
index 642b47c5f4b8..7d6a36bca9dd 100644
@@ -894,3 +894,18 @@ int amdgpu_display_crtc_idx_to_irq_type(struct 
 amdgpu_device *adev, int crtc)
           return AMDGPU_CRTC_IRQ_NONE;
       }

  }

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +15 -0
+
+int amdgpu_display_freesync_ioctl(struct drm_device *dev, void *data,
+                  struct drm_file *filp)
+{
+    int ret = -EPERM;
+    struct amdgpu_device *adev = dev->dev_private;
+
+    if (adev->mode_info.funcs->notify_freesync)
+        ret = adev->mode_info.funcs->notify_freesync(dev,data,filp);
+    else
+        DRM_DEBUG("amdgpu no notify_freesync ioctl\n");
+
+    return ret;
+}
+
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +2 -1
index bd98cc5fb97b..5b26e0447221 100644
@@ -1099,7 +1099,8 @@ const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
       DRM_IOCTL_DEF_DRV(AMDGPU_GEM_METADATA, amdgpu_gem_metadata_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
       DRM_IOCTL_DEF_DRV(AMDGPU_GEM_VA, amdgpu_gem_va_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
       DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
-    DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, 
 DRM_AUTH|DRM_RENDER_ALLOW)
+    DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, 
 DRM_AUTH|DRM_RENDER_ALLOW),
+    DRM_IOCTL_DEF_DRV(AMDGPU_FREESYNC, amdgpu_display_freesync_ioctl, 
 DRM_MASTER)

  };
  const int amdgpu_max_kms_ioctl = ARRAY_SIZE(amdgpu_ioctls_kms);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 8be3028850b6..56598ed53123 100644
@@ -1584,6 +1584,7 @@ static void dm_bandwidth_update(struct 
 amdgpu_device *adev)
   static int amdgpu_notify_freesync(struct drm_device *dev, void *data,
                   struct drm_file *filp)
   {
+    struct drm_amdgpu_freesync *args = data;
       struct drm_atomic_state *state;
       struct drm_modeset_acquire_ctx ctx;

      struct drm_crtc *crtc;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -0
@@ -1593,6 +1594,9 @@ static int amdgpu_notify_freesync(struct 
 drm_device *dev, void *data,
       uint8_t i;
       bool enable = false;
+    if (args->op == AMDGPU_FREESYNC_FULLSCREEN_ENTER)
+        enable = true;
+
       drm_modeset_acquire_init(&ctx, 0);
       state = drm_atomic_state_alloc(dev);
include/uapi/drm/amdgpu_drm.h +11 -0
index 1ceec56de015..94444eeba55b 100644
@@ -54,6 +54,8 @@ extern "C" {
   #define DRM_AMDGPU_VM            0x13
   #define DRM_AMDGPU_FENCE_TO_HANDLE    0x14
   #define DRM_AMDGPU_SCHED        0x15
+/* not upstream */
+#define DRM_AMDGPU_FREESYNC            0x5d
   #define DRM_IOCTL_AMDGPU_GEM_CREATE    DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
   #define DRM_IOCTL_AMDGPU_GEM_MMAP    DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
@@ -71,6 +73,7 @@ extern "C" {
   #define DRM_IOCTL_AMDGPU_VM        DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)
   #define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
   #define DRM_IOCTL_AMDGPU_SCHED        DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_SCHED, union drm_amdgpu_sched)
+#define DRM_IOCTL_AMDGPU_FREESYNC    DRM_IOWR(DRM_COMMAND_BASE + 
 DRM_AMDGPU_FREESYNC, struct drm_amdgpu_freesync)
   /**
    * DOC: memory domains
@@ -987,6 +990,19 @@ struct drm_amdgpu_info_vce_clock_table {
   #define AMDGPU_FAMILY_AI            141 /* Vega10 */
   #define AMDGPU_FAMILY_RV            142 /* Raven */
+/*
+ * Definition of free sync enter and exit signals
+ * We may have more options in the future
+ */
+#define AMDGPU_FREESYNC_FULLSCREEN_ENTER        1
+#define AMDGPU_FREESYNC_FULLSCREEN_EXIT         2
+
+struct drm_amdgpu_freesync {
Quoted 9 lines

include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_info_vce_clock_table { · line 1008

Quoted 8 lines
include/uapi/drm/amdgpu_drm.h +5 -0
+    __u32 op;            /* AMDGPU_FREESYNC_FULLSCREEN_ENTER or */
+                        /* AMDGPU_FREESYNC_FULLSCREEN_ENTER */
+    __u32 spare[7];
+};
+
   #if defined(__cplusplus)
   }
   #endif

Nicholas Kazlauskas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#21 lore raw

Re: [PATCH 6/9] drm/amdgpu: add freesync ioctl

Quoted 9 lines · Nicholas
Quoted 6 lines · Christian König

Am 11.09.2018 um 18:13 schrieb Nicholas Kazlauskas:

Quoted 3 lines

From: Harry Wentland <[email protected]>

Add the ioctl to enable/disable freesync.

Why do we still need this now that we have the DRM CRTC properties?

Quoted 7 lines

These patches were already merged into amd-staging-drm-next so we felt it was best to just base the existing ones off of this work to keep things consistent.

The later patches in the series remove most of it but it looks like some of ioctl stuff itself was missed in amdgpu. It could probably use another patch on top of this to finish cleaning it up.

You might want to just revert the relevant commits in amd-staging-drm-next as the starting point for this patch set so that what we eventually upstream is clean. Better yet, base it on this branch:
https://cgit.freedesktop.org/~agd5f/linux/log/?h=drm-next-4.20-wip
Which is basically amd-staging-drm-next without all the non-upstream stuff.

Alex

Quoted 145 lines
Quoted 135 lines

Christian.

Quoted 131 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h              |  3 +++
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c      | 15 +++++++++++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c          |  3 ++-
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c    |  4 ++++
  include/uapi/drm/amdgpu_drm.h                    | 16 ++++++++++++++++
  5 files changed, 40 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
index 447c4c7a36d6..95af917007f7 100644
@@ -1193,6 +1193,9 @@ int amdgpu_cs_wait_fences_ioctl(struct
 drm_device *dev, void *data,
  int amdgpu_gem_metadata_ioctl(struct drm_device *dev, void *data,
                  struct drm_file *filp);
+int amdgpu_display_freesync_ioctl(struct drm_device *dev, void *data,
+                  struct drm_file *filp);
+
  /* VRAM scratch page for HDP bug, default vram page */
  struct amdgpu_vram_scratch {
      struct amdgpu_bo        *robj;
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +15 -0
index 642b47c5f4b8..7d6a36bca9dd 100644
@@ -894,3 +894,18 @@ int amdgpu_display_crtc_idx_to_irq_type(struct
 amdgpu_device *adev, int crtc)
          return AMDGPU_CRTC_IRQ_NONE;
      }
  }
+
+int amdgpu_display_freesync_ioctl(struct drm_device *dev, void *data,
+                  struct drm_file *filp)
+{
+    int ret = -EPERM;
+    struct amdgpu_device *adev = dev->dev_private;
+
+    if (adev->mode_info.funcs->notify_freesync)
+        ret = adev->mode_info.funcs->notify_freesync(dev,data,filp);
+    else
+        DRM_DEBUG("amdgpu no notify_freesync ioctl\n");
+
+    return ret;
+}
+
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -1
index bd98cc5fb97b..5b26e0447221 100644
@@ -1099,7 +1099,8 @@ const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
      DRM_IOCTL_DEF_DRV(AMDGPU_GEM_METADATA,
 amdgpu_gem_metadata_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
      DRM_IOCTL_DEF_DRV(AMDGPU_GEM_VA, amdgpu_gem_va_ioctl,
 DRM_AUTH|DRM_RENDER_ALLOW),
      DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl,
 DRM_AUTH|DRM_RENDER_ALLOW),
-    DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl,

DRM_AUTH|DRM_RENDER_ALLOW)
+ DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl,
DRM_AUTH|DRM_RENDER_ALLOW),
+ DRM_IOCTL_DEF_DRV(AMDGPU_FREESYNC, amdgpu_display_freesync_ioctl,
DRM_MASTER)
};
const int amdgpu_max_kms_ioctl = ARRAY_SIZE(amdgpu_ioctls_kms);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 8be3028850b6..56598ed53123 100644
@@ -1584,6 +1584,7 @@ static void dm_bandwidth_update(struct
 amdgpu_device *adev)
  static int amdgpu_notify_freesync(struct drm_device *dev, void *data,
                  struct drm_file *filp)
  {
+    struct drm_amdgpu_freesync *args = data;
      struct drm_atomic_state *state;
      struct drm_modeset_acquire_ctx ctx;
      struct drm_crtc *crtc;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -0
@@ -1593,6 +1594,9 @@ static int amdgpu_notify_freesync(struct
 drm_device *dev, void *data,
      uint8_t i;
      bool enable = false;
+    if (args->op == AMDGPU_FREESYNC_FULLSCREEN_ENTER)
+        enable = true;
+
      drm_modeset_acquire_init(&ctx, 0);
      state = drm_atomic_state_alloc(dev);
include/uapi/drm/amdgpu_drm.h +2 -0
index 1ceec56de015..94444eeba55b 100644
@@ -54,6 +54,8 @@ extern "C" {
  #define DRM_AMDGPU_VM            0x13
  #define DRM_AMDGPU_FENCE_TO_HANDLE    0x14
  #define DRM_AMDGPU_SCHED        0x15
+/* not upstream */
+#define DRM_AMDGPU_FREESYNC            0x5d
  #define DRM_IOCTL_AMDGPU_GEM_CREATE    DRM_IOWR(DRM_COMMAND_BASE +
 DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
  #define DRM_IOCTL_AMDGPU_GEM_MMAP    DRM_IOWR(DRM_COMMAND_BASE +

DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)

include/uapi/drm/amdgpu_drm.h +1 -0
@@ -71,6 +73,7 @@ extern "C" {
  #define DRM_IOCTL_AMDGPU_VM        DRM_IOWR(DRM_COMMAND_BASE +
 DRM_AMDGPU_VM, union drm_amdgpu_vm)
  #define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE +
 DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
  #define DRM_IOCTL_AMDGPU_SCHED        DRM_IOW(DRM_COMMAND_BASE +
 DRM_AMDGPU_SCHED, union drm_amdgpu_sched)
+#define DRM_IOCTL_AMDGPU_FREESYNC    DRM_IOWR(DRM_COMMAND_BASE +

DRM_AMDGPU_FREESYNC, struct drm_amdgpu_freesync)
/**
* DOC: memory domains

include/uapi/drm/amdgpu_drm.h +8 -0
@@ -987,6 +990,19 @@ struct drm_amdgpu_info_vce_clock_table {
  #define AMDGPU_FAMILY_AI            141 /* Vega10 */
  #define AMDGPU_FAMILY_RV            142 /* Raven */
+/*
+ * Definition of free sync enter and exit signals
+ * We may have more options in the future
+ */
+#define AMDGPU_FREESYNC_FULLSCREEN_ENTER        1
+#define AMDGPU_FREESYNC_FULLSCREEN_EXIT         2
+
+struct drm_amdgpu_freesync {
Quoted 9 lines

include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_info_vce_clock_table { · line 1008

Quoted 8 lines
include/uapi/drm/amdgpu_drm.h +5 -0
+    __u32 op;            /* AMDGPU_FREESYNC_FULLSCREEN_ENTER or */
+                        /* AMDGPU_FREESYNC_FULLSCREEN_ENTER */
+    __u32 spare[7];
+};
+
  #if defined(__cplusplus)
  }
  #endif
Quoted 5 lines

Nicholas Kazlauskas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): CADnq5_PrTj_HaV-gpD5y6B+p7O=R+WxxWA9ytAKBYMQUW-GE7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#23 lore raw

Re: [PATCH 6/9] drm/amdgpu: add freesync ioctl

Am 11.09.2018 um 21:17 schrieb Alex Deucher:

Quoted 15 lines
Quoted 5 lines · Nicholas
Quoted 4 lines · Christian König

Am 11.09.2018 um 18:13 schrieb Nicholas Kazlauskas:

Quoted 3 lines

From: Harry Wentland <[email protected]>

Add the ioctl to enable/disable freesync.

Quoted 8 lines
Quoted 1 line

Why do we still need this now that we have the DRM CRTC properties?

These patches were already merged into amd-staging-drm-next so we felt it was best to just base the existing ones off of this work to keep things consistent.

The later patches in the series remove most of it but it looks like some of ioctl stuff itself was missed in amdgpu. It could probably use another patch on top of this to finish cleaning it up.

Quoted 6 lines

You might want to just revert the relevant commits in amd-staging-drm-next as the starting point for this patch set so that what we eventually upstream is clean. Better yet, base it on this branch:
https://cgit.freedesktop.org/~agd5f/linux/log/?h=drm-next-4.20-wip
Which is basically amd-staging-drm-next without all the non-upstream stuff.

Yes, completely agree.

For review it is certainly better to have a clean history based on some upstream branch, especially when you add common stuff like in this patchset.

Regards,
Christian.

Quoted 148 lines

Alex

Quoted 137 lines
Quoted 137 lines

Christian.

Quoted 135 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu.h              |  3 +++
   drivers/gpu/drm/amd/amdgpu/amdgpu_display.c      | 15 +++++++++++++++
   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c          |  3 ++-
   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c    |  4 ++++
   include/uapi/drm/amdgpu_drm.h                    | 16 ++++++++++++++++
   5 files changed, 40 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
index 447c4c7a36d6..95af917007f7 100644
@@ -1193,6 +1193,9 @@ int amdgpu_cs_wait_fences_ioctl(struct
 drm_device *dev, void *data,
   int amdgpu_gem_metadata_ioctl(struct drm_device *dev, void *data,
                   struct drm_file *filp);
+int amdgpu_display_freesync_ioctl(struct drm_device *dev, void *data,
+                  struct drm_file *filp);
+
   /* VRAM scratch page for HDP bug, default vram page */
   struct amdgpu_vram_scratch {
       struct amdgpu_bo        *robj;
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +15 -0
index 642b47c5f4b8..7d6a36bca9dd 100644
@@ -894,3 +894,18 @@ int amdgpu_display_crtc_idx_to_irq_type(struct
 amdgpu_device *adev, int crtc)
           return AMDGPU_CRTC_IRQ_NONE;
       }
   }
+
+int amdgpu_display_freesync_ioctl(struct drm_device *dev, void *data,
+                  struct drm_file *filp)
+{
+    int ret = -EPERM;
+    struct amdgpu_device *adev = dev->dev_private;
+
+    if (adev->mode_info.funcs->notify_freesync)
+        ret = adev->mode_info.funcs->notify_freesync(dev,data,filp);
+    else
+        DRM_DEBUG("amdgpu no notify_freesync ioctl\n");
+
+    return ret;
+}
+
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -1
index bd98cc5fb97b..5b26e0447221 100644
@@ -1099,7 +1099,8 @@ const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
       DRM_IOCTL_DEF_DRV(AMDGPU_GEM_METADATA,
 amdgpu_gem_metadata_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
       DRM_IOCTL_DEF_DRV(AMDGPU_GEM_VA, amdgpu_gem_va_ioctl,
 DRM_AUTH|DRM_RENDER_ALLOW),
       DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl,
 DRM_AUTH|DRM_RENDER_ALLOW),
-    DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl,

DRM_AUTH|DRM_RENDER_ALLOW)
+ DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl,
DRM_AUTH|DRM_RENDER_ALLOW),
+ DRM_IOCTL_DEF_DRV(AMDGPU_FREESYNC, amdgpu_display_freesync_ioctl,
DRM_MASTER)

   };
   const int amdgpu_max_kms_ioctl = ARRAY_SIZE(amdgpu_ioctls_kms);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 8be3028850b6..56598ed53123 100644
@@ -1584,6 +1584,7 @@ static void dm_bandwidth_update(struct
 amdgpu_device *adev)
   static int amdgpu_notify_freesync(struct drm_device *dev, void *data,
                   struct drm_file *filp)
   {
+    struct drm_amdgpu_freesync *args = data;
       struct drm_atomic_state *state;
       struct drm_modeset_acquire_ctx ctx;
       struct drm_crtc *crtc;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -0
@@ -1593,6 +1594,9 @@ static int amdgpu_notify_freesync(struct
 drm_device *dev, void *data,
       uint8_t i;
       bool enable = false;
+    if (args->op == AMDGPU_FREESYNC_FULLSCREEN_ENTER)
+        enable = true;
+
       drm_modeset_acquire_init(&ctx, 0);
       state = drm_atomic_state_alloc(dev);
include/uapi/drm/amdgpu_drm.h +2 -0
index 1ceec56de015..94444eeba55b 100644
@@ -54,6 +54,8 @@ extern "C" {
   #define DRM_AMDGPU_VM            0x13
   #define DRM_AMDGPU_FENCE_TO_HANDLE    0x14
   #define DRM_AMDGPU_SCHED        0x15
+/* not upstream */
+#define DRM_AMDGPU_FREESYNC            0x5d
   #define DRM_IOCTL_AMDGPU_GEM_CREATE    DRM_IOWR(DRM_COMMAND_BASE +
 DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
   #define DRM_IOCTL_AMDGPU_GEM_MMAP    DRM_IOWR(DRM_COMMAND_BASE +

DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)

include/uapi/drm/amdgpu_drm.h +1 -0
@@ -71,6 +73,7 @@ extern "C" {
   #define DRM_IOCTL_AMDGPU_VM        DRM_IOWR(DRM_COMMAND_BASE +
 DRM_AMDGPU_VM, union drm_amdgpu_vm)
   #define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE +
 DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
   #define DRM_IOCTL_AMDGPU_SCHED        DRM_IOW(DRM_COMMAND_BASE +
 DRM_AMDGPU_SCHED, union drm_amdgpu_sched)
+#define DRM_IOCTL_AMDGPU_FREESYNC    DRM_IOWR(DRM_COMMAND_BASE +

DRM_AMDGPU_FREESYNC, struct drm_amdgpu_freesync)
/**
* DOC: memory domains

include/uapi/drm/amdgpu_drm.h +13 -0
@@ -987,6 +990,19 @@ struct drm_amdgpu_info_vce_clock_table {
   #define AMDGPU_FAMILY_AI            141 /* Vega10 */
   #define AMDGPU_FAMILY_RV            142 /* Raven */
+/*
+ * Definition of free sync enter and exit signals
+ * We may have more options in the future
+ */
+#define AMDGPU_FREESYNC_FULLSCREEN_ENTER        1
+#define AMDGPU_FREESYNC_FULLSCREEN_EXIT         2
+
+struct drm_amdgpu_freesync {
+    __u32 op;            /* AMDGPU_FREESYNC_FULLSCREEN_ENTER or */
+                        /* AMDGPU_FREESYNC_FULLSCREEN_ENTER */
+    __u32 spare[7];
+};
+
Quoted 8 lines
Quoted 3 lines

include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_info_vce_clock_table { · line 1008

Quoted 3 lines
include/uapi/drm/amdgpu_drm.h +0 -0
   #if defined(__cplusplus)
   }
   #endif

Nicholas Kazlauskas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#24 lore raw

PATCH 8/9 drm/amd/display: Drop FreeSync ioctl notification support

In reply to a message not in the archive

This is no longer needed with the addition of the DRM properties.

The base driver correctly checks that notify_freesync is non-null before calling so there shouldn't be any null pointer dereferences as a result of this.

Change-Id If0833b201c81303ca4062393e873faf3ef7c143b
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 71 -------------------
 1 file changed, 71 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -71
index d28bab0f4657..c9de8f555c6a 100644
@@ -1581,76 +1581,6 @@ static void dm_bandwidth_update(struct amdgpu_device *adev)
 	/* TODO: implement later */
 }
 
-static int amdgpu_notify_freesync(struct drm_device *dev, void *data,
-				struct drm_file *filp)
-{
-	struct drm_amdgpu_freesync *args = data;
-	struct drm_atomic_state *state;
-	struct drm_modeset_acquire_ctx ctx;
-	struct drm_crtc *crtc;
-	struct drm_connector *connector;
-	struct drm_connector_state *old_con_state, *new_con_state;
-	int ret = 0;
-	uint8_t i;
-	bool enable = false;
-
-	if (args->op == AMDGPU_FREESYNC_FULLSCREEN_ENTER)
-		enable = true;
-
-	drm_modeset_acquire_init(&ctx, 0);
-
-	state = drm_atomic_state_alloc(dev);
-	if (!state) {
-		ret = -ENOMEM;
-		goto out;
-	}
-	state->acquire_ctx = &ctx;
-
-retry:
-	drm_for_each_crtc(crtc, dev) {
-		ret = drm_atomic_add_affected_connectors(state, crtc);
-		if (ret)
-			goto fail;
-
-		/* TODO rework amdgpu_dm_commit_planes so we don't need this */
-		ret = drm_atomic_add_affected_planes(state, crtc);
-		if (ret)
-			goto fail;
-	}
-
-	for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) {
-		struct dm_connector_state *dm_new_con_state = to_dm_connector_state(new_con_state);
-		struct drm_crtc_state *new_crtc_state;
-		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(dm_new_con_state->base.crtc);
-		struct dm_crtc_state *dm_new_crtc_state;
-
-		if (!acrtc) {
-			ASSERT(0);
-			continue;
-		}
-
-		new_crtc_state = drm_atomic_get_new_crtc_state(state, &acrtc->base);
-		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
-
-		dm_new_crtc_state->base.variable_refresh = enable;
-	}
-
-	ret = drm_atomic_commit(state);
-
-fail:
-	if (ret == -EDEADLK) {
-		drm_atomic_state_clear(state);
-		drm_modeset_backoff(&ctx);
-		goto retry;
-	}
-
-	drm_atomic_state_put(state);
-
-out:
-	drm_modeset_drop_locks(&ctx);
-	drm_modeset_acquire_fini(&ctx);
-	return ret;
-}
 
 static const struct amdgpu_display_funcs dm_display_funcs = {
 	.bandwidth_update = dm_bandwidth_update, /* called unconditionally */
@@ -1664,7 +1594,6 @@ static const struct amdgpu_display_funcs dm_display_funcs = {
 		dm_crtc_get_scanoutpos,/* called unconditionally */
 	.add_encoder = NULL, /* VBIOS parsing. DAL does it. */
 	.add_connector = NULL, /* VBIOS parsing. DAL does it. */
-	.notify_freesync = amdgpu_notify_freesync,
 
 };
 
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#25 lore raw

PATCH 4/9 drm/amd/display: Refactor FreeSync module

In reply to Nicholas Kazlauskas

From: Anthony Koo <[email protected]>

Remove dependency on internal sink map and instead use existing stream and plane state

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  288 +--
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   18 +-
 .../display/amdgpu_dm/amdgpu_dm_mst_types.c   |   10 +-
 drivers/gpu/drm/amd/display/dc/core/dc.c      |   60 +-
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  |    3 +
 .../gpu/drm/amd/display/dc/core/dc_resource.c |  110 +-
 drivers/gpu/drm/amd/display/dc/dc_hw_types.h  |    6 -
 drivers/gpu/drm/amd/display/dc/dc_stream.h    |   29 +-
 drivers/gpu/drm/amd/display/dc/dc_types.h     |   22 +-
 .../display/dc/dce110/dce110_hw_sequencer.c   |   34 +-
 .../amd/display/dc/dcn10/dcn10_hw_sequencer.c |   27 +-
 .../drm/amd/display/include/set_mode_types.h  |   12 -
 .../amd/display/modules/freesync/freesync.c   | 1837 ++++++-----------
 .../amd/display/modules/inc/mod_freesync.h    |  144 +-
 14 files changed, 930 insertions(+), 1670 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +152 -136
index 9dad505d132f..d599fbfa895b 100644
@@ -839,8 +839,7 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
 
 		if (sink) {
 			if (aconnector->dc_sink) {
-				amdgpu_dm_remove_sink_from_freesync_module(
-								connector);
+				amdgpu_dm_update_freesync_caps(connector, NULL);
 				/* retain and release bellow are used for
 				 * bump up refcount for sink because the link don't point
 				 * to it anymore after disconnect so on next crtc to connector
@@ -850,10 +849,10 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
 					dc_sink_release(aconnector->dc_sink);
 			}
 			aconnector->dc_sink = sink;
-			amdgpu_dm_add_sink_to_freesync_module(
-						connector, aconnector->edid);
+			amdgpu_dm_update_freesync_caps(connector,
+					aconnector->edid);
 		} else {
-			amdgpu_dm_remove_sink_from_freesync_module(connector);
+			amdgpu_dm_update_freesync_caps(connector, NULL);
 			if (!aconnector->dc_sink)
 				aconnector->dc_sink = aconnector->dc_em_sink;
 			else if (aconnector->dc_sink != aconnector->dc_em_sink)
@@ -890,8 +889,7 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
 		/* TODO: check if we still need the S3 mode update workaround.
 		 * If yes, put it here. */
 		if (aconnector->dc_sink)
-			amdgpu_dm_remove_sink_from_freesync_module(
-							connector);
+			amdgpu_dm_update_freesync_caps(connector, NULL);
 
 		aconnector->dc_sink = sink;
 		if (sink->dc_edid.length == 0) {
@@ -907,11 +905,11 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
 			drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,
 					    aconnector->edid);
 		}
-		amdgpu_dm_add_sink_to_freesync_module(connector, aconnector->edid);
+		amdgpu_dm_update_freesync_caps(connector, aconnector->edid);
 
 	} else {
 		drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux);
-		amdgpu_dm_remove_sink_from_freesync_module(connector);
+		amdgpu_dm_update_freesync_caps(connector, NULL);
 		drm_connector_update_edid_property(connector, NULL);
 		aconnector->num_modes = 0;
 		aconnector->dc_sink = NULL;
@@ -1586,26 +1584,68 @@ static void dm_bandwidth_update(struct amdgpu_device *adev)
 static int amdgpu_notify_freesync(struct drm_device *dev, void *data,
 				struct drm_file *filp)
 {
-	struct mod_freesync_params freesync_params;
-	uint8_t num_streams;
+	struct drm_atomic_state *state;
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_crtc *crtc;
+	struct drm_connector *connector;
+	struct drm_connector_state *old_con_state, *new_con_state;
+	int ret = 0;
 	uint8_t i;
+	bool enable = false;
 
-	struct amdgpu_device *adev = dev->dev_private;
-	int r = 0;
+	drm_modeset_acquire_init(&ctx, 0);
+
+	state = drm_atomic_state_alloc(dev);
+	if (!state) {
+		ret = -ENOMEM;
+		goto out;
+	}
+	state->acquire_ctx = &ctx;
+
+retry:
+	drm_for_each_crtc(crtc, dev) {
+		ret = drm_atomic_add_affected_connectors(state, crtc);
+		if (ret)
+			goto fail;
+
+		/* TODO rework amdgpu_dm_commit_planes so we don't need this */
+		ret = drm_atomic_add_affected_planes(state, crtc);
+		if (ret)
+			goto fail;
+	}
 
-	/* Get freesync enable flag from DRM */
+	for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) {
+		struct dm_connector_state *dm_new_con_state = to_dm_connector_state(new_con_state);
+		struct drm_crtc_state *new_crtc_state;
+		struct amdgpu_crtc *acrtc = to_amdgpu_crtc(dm_new_con_state->base.crtc);
+		struct dm_crtc_state *dm_new_crtc_state;
 
-	num_streams = dc_get_current_stream_count(adev->dm.dc);
+		if (!acrtc) {
+			ASSERT(0);
+			continue;
+		}
 
-	for (i = 0; i < num_streams; i++) {
-		struct dc_stream_state *stream;
-		stream = dc_get_stream_at_index(adev->dm.dc, i);
+		new_crtc_state = drm_atomic_get_new_crtc_state(state, &acrtc->base);
+		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
 
-		mod_freesync_update_state(adev->dm.freesync_module,
-					  &stream, 1, &freesync_params);
+		dm_new_crtc_state->freesync_enabled = enable;
 	}
 
-	return r;
+	ret = drm_atomic_commit(state);
+
+fail:
+	if (ret == -EDEADLK) {
+		drm_atomic_state_clear(state);
+		drm_modeset_backoff(&ctx);
+		goto retry;
+	}
+
+	drm_atomic_state_put(state);
+
+out:
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
+	return ret;
 }
 
 static const struct amdgpu_display_funcs dm_display_funcs = {
@@ -2565,6 +2605,10 @@ dm_crtc_duplicate_state(struct drm_crtc *crtc)
 		dc_stream_retain(state->stream);
 	}
 
+	state->adjust = cur->adjust;
+	state->vrr_infopacket = cur->vrr_infopacket;
+	state->freesync_enabled = cur->freesync_enabled;
+
 	/* TODO Duplicate dc_stream after objects are stream object is flattened */
 
 	return &state->base;
@@ -2774,13 +2818,15 @@ amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector)
 	struct dm_connector_state *new_state =
 			kmemdup(state, sizeof(*state), GFP_KERNEL);
 
-	if (new_state) {
-		__drm_atomic_helper_connector_duplicate_state(connector,
-							      &new_state->base);
-		return &new_state->base;
-	}
+	if (!new_state)
+		return NULL;
 
-	return NULL;
+	__drm_atomic_helper_connector_duplicate_state(connector, &new_state->base);
+
+	new_state->freesync_capable = state->freesync_capable;
+	new_state->freesync_enable = state->freesync_enable;
+
+	return &new_state->base;
 }
 
 static const struct drm_connector_funcs amdgpu_dm_connector_funcs = {
@@ -3787,8 +3833,6 @@ static void remove_stream(struct amdgpu_device *adev,
 			  struct dc_stream_state *stream)
 {
 	/* this is the update mode case */
-	if (adev->dm.freesync_module)
-		mod_freesync_remove_stream(adev->dm.freesync_module, stream);
 
 	acrtc->otg_inst = -1;
 	acrtc->enabled = false;
@@ -4056,6 +4100,11 @@ static bool commit_planes_to_stream(
 	stream_update->dst = dc_stream->dst;
 	stream_update->out_transfer_func = dc_stream->out_transfer_func;
 
+	if (dm_new_crtc_state->freesync_enabled != dm_old_crtc_state->freesync_enabled) {
+		stream_update->vrr_infopacket = &dc_stream->vrr_infopacket;
+		stream_update->adjust = &dc_stream->adjust;
+	}
+
 	for (i = 0; i < new_plane_count; i++) {
 		updates[i].surface = plane_states[i];
 		updates[i].gamma =
@@ -4191,6 +4240,8 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
 			spin_unlock_irqrestore(&pcrtc->dev->event_lock, flags);
 		}
 
+		dc_stream_attach->adjust = acrtc_state->adjust;
+		dc_stream_attach->vrr_infopacket = acrtc_state->vrr_infopacket;
 
 		if (false == commit_planes_to_stream(dm->dc,
 							plane_states_constructed,
@@ -4340,62 +4391,6 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 		}
 	} /* for_each_crtc_in_state() */
 
-	/*
-	 * Add streams after required streams from new and replaced streams
-	 * are removed from freesync module
-	 */
-	if (adev->dm.freesync_module) {
-		for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state,
-					      new_crtc_state, i) {
-			struct amdgpu_dm_connector *aconnector = NULL;
-			struct dm_connector_state *dm_new_con_state = NULL;
-			struct amdgpu_crtc *acrtc = NULL;
-			bool modeset_needed;
-
-			dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
-			dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
-			modeset_needed = modeset_required(
-					new_crtc_state,
-					dm_new_crtc_state->stream,
-					dm_old_crtc_state->stream);
-			/* We add stream to freesync if:
-			 * 1. Said stream is not null, and
-			 * 2. A modeset is requested. This means that the
-			 *    stream was removed previously, and needs to be
-			 *    replaced.
-			 */
-			if (dm_new_crtc_state->stream == NULL ||
-					!modeset_needed)
-				continue;
-
-			acrtc = to_amdgpu_crtc(crtc);
-
-			aconnector =
-				amdgpu_dm_find_first_crtc_matching_connector(
-					state, crtc);
-			if (!aconnector) {
-				DRM_DEBUG_DRIVER("Atomic commit: Failed to "
-						 "find connector for acrtc "
-						 "id:%d skipping freesync "
-						 "init\n",
-						 acrtc->crtc_id);
-				continue;
-			}
-
-			mod_freesync_add_stream(adev->dm.freesync_module,
-						dm_new_crtc_state->stream,
-						&aconnector->caps);
-			new_con_state = drm_atomic_get_new_connector_state(
-					state, &aconnector->base);
-			dm_new_con_state = to_dm_connector_state(new_con_state);
-
-			mod_freesync_set_user_enable(adev->dm.freesync_module,
-						     &dm_new_crtc_state->stream,
-						     1,
-						     &dm_new_con_state->user_enable);
-		}
-	}
-
 	if (dm_state->context) {
 		dm_enable_per_frame_crtc_master_sync(dm_state->context);
 		WARN_ON(!dc_commit_state(dm->dc, dm_state->context));
@@ -4449,6 +4444,9 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 		WARN_ON(!status);
 		WARN_ON(!status->plane_count);
 
+		dm_new_crtc_state->stream->adjust = dm_new_crtc_state->adjust;
+		dm_new_crtc_state->stream->vrr_infopacket = dm_new_crtc_state->vrr_infopacket;
+
 		/*TODO How it works with MPO ?*/
 		if (!commit_planes_to_stream(
 				dm->dc,
@@ -4481,11 +4479,6 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
 		if (dm_new_crtc_state->stream == NULL || !modeset_needed)
 			continue;
 
-		if (adev->dm.freesync_module)
-			mod_freesync_notify_mode_change(
-				adev->dm.freesync_module,
-				&dm_new_crtc_state->stream, 1);
-
 		manage_dm_interrupts(adev, acrtc, true);
 	}
 
@@ -4668,7 +4661,42 @@ static int do_aquire_global_lock(struct drm_device *dev,
 	return ret < 0 ? ret : 0;
 }
 
-static int dm_update_crtcs_state(struct dc *dc,
+void set_freesync_on_stream(struct amdgpu_display_manager *dm,
+			    struct dm_crtc_state *new_crtc_state,
+			    struct dm_connector_state *new_con_state,
+			    struct dc_stream_state *new_stream)
+{
+	struct mod_freesync_config config = {0};
+	struct mod_vrr_params vrr = {0};
+	struct dc_info_packet vrr_infopacket = {0};
+	struct amdgpu_dm_connector *aconnector =
+			to_amdgpu_dm_connector(new_con_state->base.connector);
+
+	if (new_con_state->freesync_capable &&
+	    new_con_state->freesync_enable) {
+		config.state = new_crtc_state->freesync_enabled ?
+				VRR_STATE_ACTIVE_VARIABLE :
+				VRR_STATE_INACTIVE;
+		config.min_refresh_in_uhz =
+				aconnector->min_vfreq * 1000000;
+		config.max_refresh_in_uhz =
+				aconnector->max_vfreq * 1000000;
+	}
+
+	mod_freesync_build_vrr_params(dm->freesync_module,
+				      new_stream,
+				      &config, &vrr);
+
+	mod_freesync_build_vrr_infopacket(dm->freesync_module,
+					  new_stream,
+					  &vrr,
+					  &vrr_infopacket);
+
+	new_crtc_state->adjust = vrr.adjust;
+	new_crtc_state->vrr_infopacket = vrr_infopacket;
+}
+
+static int dm_update_crtcs_state(struct amdgpu_display_manager *dm,
 				 struct drm_atomic_state *state,
 				 bool enable,
 				 bool *lock_and_validation_needed)
@@ -4738,6 +4766,9 @@ static int dm_update_crtcs_state(struct dc *dc,
 				break;
 			}
 
+			set_freesync_on_stream(dm, dm_new_crtc_state,
+					       dm_new_conn_state, new_stream);
+
 			if (dc_is_stream_unchanged(new_stream, dm_old_crtc_state->stream) &&
 			    dc_is_stream_scaling_unchanged(new_stream, dm_old_crtc_state->stream)) {
 				new_crtc_state->mode_changed = false;
@@ -4746,6 +4777,9 @@ static int dm_update_crtcs_state(struct dc *dc,
 			}
 		}
 
+		if (dm_old_crtc_state->freesync_enabled != dm_new_crtc_state->freesync_enabled)
+			new_crtc_state->mode_changed = true;
+
 		if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
 			goto next_crtc;
 
@@ -4772,7 +4806,7 @@ static int dm_update_crtcs_state(struct dc *dc,
 
 			/* i.e. reset mode */
 			if (dc_remove_stream_from_ctx(
-					dc,
+					dm->dc,
 					dm_state->context,
 					dm_old_crtc_state->stream) != DC_OK) {
 				ret = -EINVAL;
@@ -4809,7 +4843,7 @@ static int dm_update_crtcs_state(struct dc *dc,
 							crtc->base.id);
 
 				if (dc_add_stream_to_ctx(
-						dc,
+						dm->dc,
 						dm_state->context,
 						dm_new_crtc_state->stream) != DC_OK) {
 					ret = -EINVAL;
@@ -4858,6 +4892,8 @@ static int dm_update_crtcs_state(struct dc *dc,
 				goto fail;
 			amdgpu_dm_set_ctm(dm_new_crtc_state);
 		}
+
+
 	}
 
 	return ret;
@@ -5025,8 +5061,12 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 		goto fail;
 
 	for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+		struct dm_crtc_state *dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
+		struct dm_crtc_state *dm_old_crtc_state  = to_dm_crtc_state(old_crtc_state);
+
 		if (!drm_atomic_crtc_needs_modeset(new_crtc_state) &&
-		    !new_crtc_state->color_mgmt_changed)
+		    !new_crtc_state->color_mgmt_changed &&
+		    (dm_old_crtc_state->freesync_enabled == dm_new_crtc_state->freesync_enabled))
 			continue;
 
 		if (!new_crtc_state->enable)
@@ -5052,13 +5092,13 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 	}
 
 	/* Disable all crtcs which require disable */
-	ret = dm_update_crtcs_state(dc, state, false, &lock_and_validation_needed);
+	ret = dm_update_crtcs_state(&adev->dm, state, false, &lock_and_validation_needed);
 	if (ret) {
 		goto fail;
 	}
 
 	/* Enable all crtcs which require enable */
-	ret = dm_update_crtcs_state(dc, state, true, &lock_and_validation_needed);
+	ret = dm_update_crtcs_state(&adev->dm, state, true, &lock_and_validation_needed);
 	if (ret) {
 		goto fail;
 	}
@@ -5151,8 +5191,8 @@ static bool is_dp_capable_without_timing_msa(struct dc *dc,
 
 	return capable;
 }
-void amdgpu_dm_add_sink_to_freesync_module(struct drm_connector *connector,
-					   struct edid *edid)
+void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
+					struct edid *edid)
 {
 	int i;
 	bool edid_check_required;
@@ -5171,6 +5211,18 @@ void amdgpu_dm_add_sink_to_freesync_module(struct drm_connector *connector,
 		return;
 	}
 
+	if (!edid) {
+		dm_con_state = to_dm_connector_state(connector->state);
+
+		amdgpu_dm_connector->min_vfreq = 0;
+		amdgpu_dm_connector->max_vfreq = 0;
+		amdgpu_dm_connector->pixel_clock_mhz = 0;
+
+		dm_con_state->freesync_capable = false;
+		dm_con_state->freesync_enable = false;
+		return;
+	}
+
 	dm_con_state = to_dm_connector_state(connector->state);
 
 	edid_check_required = false;
@@ -5221,46 +5273,10 @@ void amdgpu_dm_add_sink_to_freesync_module(struct drm_connector *connector,
 		}
 
 		if (amdgpu_dm_connector->max_vfreq -
-				amdgpu_dm_connector->min_vfreq > 10) {
-			amdgpu_dm_connector->caps.supported = true;
-			amdgpu_dm_connector->caps.min_refresh_in_micro_hz =
-					amdgpu_dm_connector->min_vfreq * 1000000;
-			amdgpu_dm_connector->caps.max_refresh_in_micro_hz =
-					amdgpu_dm_connector->max_vfreq * 1000000;
+		    amdgpu_dm_connector->min_vfreq > 10) {
+
 			dm_con_state->freesync_capable = true;
 		}
 	}
 }
 
-void amdgpu_dm_remove_sink_from_freesync_module(struct drm_connector *connector)
-{
-	struct amdgpu_dm_connector *amdgpu_dm_connector =
-			to_amdgpu_dm_connector(connector);
-	struct dm_connector_state *dm_con_state;
-	struct drm_device *dev = connector->dev;
-	struct amdgpu_device *adev = dev->dev_private;
-
-	if (!amdgpu_dm_connector->dc_sink || !adev->dm.freesync_module) {
-		DRM_ERROR("dc_sink NULL or no free_sync module.\n");
-		return;
-	}
-
-	if (!connector->state) {
-		DRM_ERROR("%s - Connector has no state", __func__);
-		return;
-	}
-
-	dm_con_state = to_dm_connector_state(connector->state);
-
-	amdgpu_dm_connector->min_vfreq = 0;
-	amdgpu_dm_connector->max_vfreq = 0;
-	amdgpu_dm_connector->pixel_clock_mhz = 0;
-
-	memset(&amdgpu_dm_connector->caps, 0, sizeof(amdgpu_dm_connector->caps));
-
-	dm_con_state->freesync_capable = false;
-
-	dm_con_state->user_enable.enable_for_gaming = false;
-	dm_con_state->user_enable.enable_for_static = false;
-	dm_con_state->user_enable.enable_for_video = false;
-}
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +8 -10
index 54056d180003..85cfa2cbd8ec 100644
@@ -167,9 +167,6 @@ struct amdgpu_dm_connector {
 	int max_vfreq ;
 	int pixel_clock_mhz;
 
-	/*freesync caps*/
-	struct mod_freesync_caps caps;
-
 	struct mutex hpd_lock;
 
 	bool fake_enable;
@@ -197,9 +194,13 @@ struct dm_crtc_state {
 
 	int crc_skip_count;
 	bool crc_enabled;
+
+	bool freesync_enabled;
+	struct dc_crtc_timing_adjust adjust;
+	struct dc_info_packet vrr_infopacket;
 };
 
-#define to_dm_crtc_state(x)    container_of(x, struct dm_crtc_state, base)
+#define to_dm_crtc_state(x) container_of(x, struct dm_crtc_state, base)
 
 struct dm_atomic_state {
 	struct drm_atomic_state base;
@@ -216,7 +217,7 @@ struct dm_connector_state {
 	uint8_t underscan_vborder;
 	uint8_t underscan_hborder;
 	bool underscan_enable;
-	struct mod_freesync_user_enable user_enable;
+	bool freesync_enable;
 	bool freesync_capable;
 };
 
@@ -250,11 +251,8 @@ enum drm_mode_status amdgpu_dm_connector_mode_valid(struct drm_connector *connec
 void dm_restore_drm_connector_state(struct drm_device *dev,
 				    struct drm_connector *connector);
 
-void amdgpu_dm_add_sink_to_freesync_module(struct drm_connector *connector,
-					   struct edid *edid);
-
-void
-amdgpu_dm_remove_sink_from_freesync_module(struct drm_connector *connector);
+void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
+					struct edid *edid);
 
 /* amdgpu_dm_crc.c */
 #ifdef CONFIG_DEBUG_FS
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +6 -4
index 18a3a6e5ffa0..03601d717fed 100644
@@ -234,8 +234,9 @@ void dm_dp_mst_dc_sink_create(struct drm_connector *connector)
 	dc_sink->priv = aconnector;
 	aconnector->dc_sink = dc_sink;
 
-	amdgpu_dm_add_sink_to_freesync_module(
-			connector, aconnector->edid);
+	if (aconnector->dc_sink)
+		amdgpu_dm_update_freesync_caps(
+				connector, aconnector->edid);
 }
 
 static int dm_dp_mst_get_modes(struct drm_connector *connector)
@@ -275,8 +276,9 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
 		aconnector->dc_sink = dc_sink;
 
 		if (aconnector->dc_sink)
-			amdgpu_dm_add_sink_to_freesync_module(
+			amdgpu_dm_update_freesync_caps(
 					connector, aconnector->edid);
+
 	}
 
 	drm_connector_update_edid_property(
@@ -439,7 +441,7 @@ static void dm_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
 
 	aconnector->port = NULL;
 	if (aconnector->dc_sink) {
-		amdgpu_dm_remove_sink_from_freesync_module(connector);
+		amdgpu_dm_update_freesync_caps(connector, NULL);
 		dc_link_remove_remote_sink(aconnector->dc_link, aconnector->dc_sink);
 		dc_sink_release(aconnector->dc_sink);
 		aconnector->dc_sink = NULL;
drivers/gpu/drm/amd/display/dc/core/dc.c +43 -17

112 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +3 -0
index a7553b6d59c2..d91df5ef0cb3 100644
@@ -2389,6 +2389,9 @@ static bool retrieve_link_cap(struct dc_link *link)
 
 	dp_wa_power_up_0010FA(link, dpcd_data, sizeof(dpcd_data));
 
+	down_strm_port_count.raw = dpcd_data[DP_DOWN_STREAM_PORT_COUNT -
+				 DP_DPCD_REV];
+
 	link->dpcd_caps.allow_invalid_MSA_timing_param =
 		down_strm_port_count.bits.IGNORE_MSA_TIMING_PARAM;
 
drivers/gpu/drm/amd/display/dc/core/dc_resource.c +2 -108

121 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/dc_hw_types.h +0 -6
index b789cb2b354b..57f57cf0fe2a 100644
@@ -708,12 +708,6 @@ struct crtc_trigger_info {
 	enum trigger_delay delay;
 };
 
-enum vrr_state {
-	VRR_STATE_OFF = 0,
-	VRR_STATE_VARIABLE,
-	VRR_STATE_FIXED,
-};
-
 struct dc_crtc_timing_adjust {
 	uint32_t v_total_min;
 	uint32_t v_total_max;
drivers/gpu/drm/amd/display/dc/dc_stream.h +14 -15
index cbfe418006cb..67101a525e3d 100644
@@ -45,19 +45,25 @@ struct dc_stream_status {
 	struct dc_link *link;
 };
 
+// TODO: References to this needs to be removed..
+struct freesync_context {
+	bool dummy;
+};
+
 struct dc_stream_state {
 	struct dc_sink *sink;
 	struct dc_crtc_timing timing;
-	struct dc_crtc_timing_adjust timing_adjust;
-	struct vrr_params vrr_params;
+	struct dc_crtc_timing_adjust adjust;
+	struct dc_info_packet vrr_infopacket;
 
 	struct rect src; /* composition area */
 	struct rect dst; /* stream addressable area */
 
-	struct audio_info audio_info;
-
+	// TODO: References to this needs to be removed..
 	struct freesync_context freesync_ctx;
 
+	struct audio_info audio_info;
+
 	struct dc_info_packet hdr_static_metadata;
 	PHYSICAL_ADDRESS_LOC dmdata_address;
 	bool   use_dynamic_meta;
@@ -120,6 +126,8 @@ struct dc_stream_update {
 	unsigned int *abm_level;
 
 	unsigned long long *periodic_fn_vsync_delta;
+	struct dc_crtc_timing_adjust *adjust;
+	struct dc_info_packet *vrr_infopacket;
 };
 
 bool dc_is_stream_unchanged(
@@ -258,10 +266,8 @@ bool dc_stream_set_cursor_position(
 
 
 bool dc_stream_adjust_vmin_vmax(struct dc *dc,
-				struct dc_stream_state **stream,
-				int num_streams,
-				int vmin,
-				int vmax);
+				struct dc_stream_state *stream,
+				struct dc_crtc_timing_adjust *adjust);
 
 bool dc_stream_get_crtc_position(struct dc *dc,
 				 struct dc_stream_state **stream,
@@ -288,13 +294,6 @@ void dc_stream_set_static_screen_events(struct dc *dc,
 void dc_stream_set_dither_option(struct dc_stream_state *stream,
 				 enum dc_dither_option option);
 
-
-bool dc_stream_adjust_vmin_vmax(struct dc *dc,
-				struct dc_stream_state **stream,
-				int num_streams,
-				int vmin,
-				int vmax);
-
 bool dc_stream_get_crtc_position(struct dc *dc,
 				 struct dc_stream_state **stream,
 				 int num_streams,
drivers/gpu/drm/amd/display/dc/dc_types.h +5 -17
index 8c6eb78b0c3b..58a6ef80a60e 100644
@@ -513,13 +513,11 @@ struct audio_info {
 	struct audio_mode modes[DC_MAX_AUDIO_DESC_COUNT];
 };
 
-struct vrr_params {
-	enum vrr_state state;
-	uint32_t window_min;
-	uint32_t window_max;
-	uint32_t inserted_frame_duration_in_us;
-	uint32_t frames_to_insert;
-	uint32_t frame_counter;
+enum dc_infoframe_type {
+	DC_HDMI_INFOFRAME_TYPE_VENDOR = 0x81,
+	DC_HDMI_INFOFRAME_TYPE_AVI = 0x82,
+	DC_HDMI_INFOFRAME_TYPE_SPD = 0x83,
+	DC_HDMI_INFOFRAME_TYPE_AUDIO = 0x84,
 };
 
 struct dc_info_packet {
@@ -539,16 +537,6 @@ struct dc_plane_flip_time {
 	unsigned int prev_update_time_in_us;
 };
 
-// Will combine with vrr_params at some point.
-struct freesync_context {
-	bool supported;
-	bool enabled;
-	bool active;
-
-	unsigned int min_refresh_in_micro_hz;
-	unsigned int nominal_refresh_in_micro_hz;
-};
-
 struct psr_config {
 	unsigned char psr_version;
 	unsigned int psr_rfb_setup_time;
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +26 -8
index 14384d9675a8..48885a1252b5 100644
@@ -1286,6 +1286,8 @@ static enum dc_status dce110_enable_stream_timing(
 	struct pipe_ctx *pipe_ctx_old = &dc->current_state->res_ctx.
 			pipe_ctx[pipe_ctx->pipe_idx];
 	struct tg_color black_color = {0};
+	struct drr_params params = {0};
+	unsigned int event_triggers = 0;
 
 	if (!pipe_ctx_old->stream) {
 
@@ -1315,9 +1317,19 @@ static enum dc_status dce110_enable_stream_timing(
 				&stream->timing,
 				true);
 
-		pipe_ctx->stream_res.tg->funcs->set_static_screen_control(
-				pipe_ctx->stream_res.tg,
-				0x182);
+		params.vertical_total_min = stream->adjust.v_total_min;
+		params.vertical_total_max = stream->adjust.v_total_max;
+		if (pipe_ctx->stream_res.tg->funcs->set_drr)
+			pipe_ctx->stream_res.tg->funcs->set_drr(
+				pipe_ctx->stream_res.tg, &params);
+
+		// DRR should set trigger event to monitor surface update event
+		if (stream->adjust.v_total_min != 0 &&
+				stream->adjust.v_total_max != 0)
+			event_triggers = 0x80;
+		if (pipe_ctx->stream_res.tg->funcs->set_static_screen_control)
+			pipe_ctx->stream_res.tg->funcs->set_static_screen_control(
+				pipe_ctx->stream_res.tg, event_triggers);
 	}
 
 	if (!pipe_ctx_old->stream) {
@@ -1328,8 +1340,6 @@ static enum dc_status dce110_enable_stream_timing(
 		}
 	}
 
-
-
 	return DC_OK;
 }
 
@@ -1719,16 +1729,24 @@ static void set_drr(struct pipe_ctx **pipe_ctx,
 {
 	int i = 0;
 	struct drr_params params = {0};
+	// DRR should set trigger event to monitor surface update event
+	unsigned int event_triggers = 0x80;
 
 	params.vertical_total_max = vmax;
 	params.vertical_total_min = vmin;
 
 	/* TODO: If multiple pipes are to be supported, you need
-	 * some GSL stuff
+	 * some GSL stuff. Static screen triggers may be programmed differently
+	 * as well.
 	 */
-
 	for (i = 0; i < num_pipes; i++) {
-		pipe_ctx[i]->stream_res.tg->funcs->set_drr(pipe_ctx[i]->stream_res.tg, &params);
+		pipe_ctx[i]->stream_res.tg->funcs->set_drr(
+			pipe_ctx[i]->stream_res.tg, &params);
+
+		if (vmax != 0 && vmin != 0)
+			pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control(
+					pipe_ctx[i]->stream_res.tg,
+					event_triggers);
 	}
 }
 
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +25 -2
index cfcc54f2ce65..05014e0c8805 100644
@@ -628,6 +628,8 @@ static enum dc_status dcn10_enable_stream_timing(
 	struct dc_stream_state *stream = pipe_ctx->stream;
 	enum dc_color_space color_space;
 	struct tg_color black_color = {0};
+	struct drr_params params = {0};
+	unsigned int event_triggers = 0;
 
 	/* by upper caller loop, pipe0 is parent pipe and be called first.
 	 * back end is set up by for pipe0. Other children pipe share back end
@@ -695,6 +697,19 @@ static enum dc_status dcn10_enable_stream_timing(
 		return DC_ERROR_UNEXPECTED;
 	}
 
+	params.vertical_total_min = stream->adjust.v_total_min;
+	params.vertical_total_max = stream->adjust.v_total_max;
+	if (pipe_ctx->stream_res.tg->funcs->set_drr)
+		pipe_ctx->stream_res.tg->funcs->set_drr(
+			pipe_ctx->stream_res.tg, &params);
+
+	// DRR should set trigger event to monitor surface update event
+	if (stream->adjust.v_total_min != 0 && stream->adjust.v_total_max != 0)
+		event_triggers = 0x80;
+	if (pipe_ctx->stream_res.tg->funcs->set_static_screen_control)
+		pipe_ctx->stream_res.tg->funcs->set_static_screen_control(
+				pipe_ctx->stream_res.tg, event_triggers);
+
 	/* TODO program crtc source select for non-virtual signal*/
 	/* TODO program FMT */
 	/* TODO setup link_enc */
@@ -2388,15 +2403,23 @@ static void set_drr(struct pipe_ctx **pipe_ctx,
 {
 	int i = 0;
 	struct drr_params params = {0};
+	// DRR should set trigger event to monitor surface update event
+	unsigned int event_triggers = 0x80;
 
 	params.vertical_total_max = vmax;
 	params.vertical_total_min = vmin;
 
 	/* TODO: If multiple pipes are to be supported, you need
-	 * some GSL stuff
+	 * some GSL stuff. Static screen triggers may be programmed differently
+	 * as well.
 	 */
 	for (i = 0; i < num_pipes; i++) {
-		pipe_ctx[i]->stream_res.tg->funcs->set_drr(pipe_ctx[i]->stream_res.tg, &params);
+		pipe_ctx[i]->stream_res.tg->funcs->set_drr(
+			pipe_ctx[i]->stream_res.tg, &params);
+		if (vmax != 0 && vmin != 0)
+			pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control(
+					pipe_ctx[i]->stream_res.tg,
+					event_triggers);
 	}
 }
 
drivers/gpu/drm/amd/display/include/set_mode_types.h +0 -12
index fee2b6ffcfc1..2b836e582c08 100644
@@ -90,18 +90,6 @@ union hdmi_info_packet {
 	struct info_packet_raw_data packet_raw_data;
 };
 
-struct info_packet {
-	enum info_frame_flag flags;
-	union hdmi_info_packet info_packet_hdmi;
-};
-
-struct info_frame {
-	struct info_packet avi_info_packet;
-	struct info_packet gamut_packet;
-	struct info_packet vendor_info_packet;
-	struct info_packet spd_info_packet;
-};
-
 #pragma pack(pop)
 
 #endif /* __DAL_SET_MODE_TYPES_H__ */
drivers/gpu/drm/amd/display/modules/freesync/freesync.c +581 -1256

1,989 lines not on this page · raw message

drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h +65 -79

144 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Part of the diff is not shown here. View the raw message.

#26 lore raw

PATCH 7/9 drm/amd/display: Replace FreeSync props with DRM VRR props

In reply to Nicholas Kazlauskas

DRM has built-in support for variable refresh properties on the connector and CRTC. Make use of these instead of the amdpgu specific freesync properties.

The connector properties freesync and freesync_capable are replaced with variable_refresh_enabled and variable_refresh_capable.

The CRTC property freesync_enable is replaced with the variable_refresh property.

The old FreeSync properties are no longer accessible from userspace and the DRM properties should be instead for enabling/disabling variable refresh support.

Change-Id I7c8117c09282a938c87292402af39d22e4eb823b
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 50 +++++++------------
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  3 --
 2 files changed, 18 insertions(+), 35 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +18 -32
index 56598ed53123..d28bab0f4657 100644
@@ -1632,7 +1632,7 @@ static int amdgpu_notify_freesync(struct drm_device *dev, void *data,
 		new_crtc_state = drm_atomic_get_new_crtc_state(state, &acrtc->base);
 		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
 
-		dm_new_crtc_state->freesync_enabled = enable;
+		dm_new_crtc_state->base.variable_refresh = enable;
 	}
 
 	ret = drm_atomic_commit(state);
@@ -2541,7 +2541,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
 
 	update_stream_signal(stream);
 
-	if (dm_state && dm_state->freesync_capable)
+	if (dm_state && dm_state->base.variable_refresh_capable)
 		stream->ignore_msa_timing_param = true;
 finish:
 	if (sink && sink->sink_signal == SIGNAL_TYPE_VIRTUAL)
@@ -2611,7 +2611,6 @@ dm_crtc_duplicate_state(struct drm_crtc *crtc)
 
 	state->adjust = cur->adjust;
 	state->vrr_infopacket = cur->vrr_infopacket;
-	state->freesync_enabled = cur->freesync_enabled;
 
 	/* TODO Duplicate dc_stream after objects are stream object is flattened */
 
@@ -2722,12 +2721,6 @@ 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 == adev->mode_info.freesync_property) {
-		dm_new_state->freesync_enable = val;
-		ret = 0;
-	} else if (property == adev->mode_info.freesync_capable_property) {
-		dm_new_state->freesync_capable = val;
-		ret = 0;
 	}
 
 	return ret;
@@ -2770,12 +2763,6 @@ 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 == adev->mode_info.freesync_property) {
-		*val = dm_state->freesync_enable;
-		ret = 0;
-	} else if (property == adev->mode_info.freesync_capable_property) {
-		*val = dm_state->freesync_capable;
-		ret = 0;
 	}
 	return ret;
 }
@@ -2839,9 +2826,6 @@ amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector)
 
 	__drm_atomic_helper_connector_duplicate_state(connector, &new_state->base);
 
-	new_state->freesync_capable = state->freesync_capable;
-	new_state->freesync_enable = state->freesync_enable;
-
 	return &new_state->base;
 }
 
@@ -3602,10 +3586,8 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
 
 	if (connector_type == DRM_MODE_CONNECTOR_HDMIA ||
 	    connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
-		drm_object_attach_property(&aconnector->base.base,
-				adev->mode_info.freesync_property, 0);
-		drm_object_attach_property(&aconnector->base.base,
-				adev->mode_info.freesync_capable_property, 0);
+		drm_connector_attach_variable_refresh_properties(
+			&aconnector->base);
 	}
 }
 
@@ -4123,7 +4105,8 @@ static bool commit_planes_to_stream(
 	stream_update->dst = dc_stream->dst;
 	stream_update->out_transfer_func = dc_stream->out_transfer_func;
 
-	if (dm_new_crtc_state->freesync_enabled != dm_old_crtc_state->freesync_enabled) {
+	if (dm_new_crtc_state->base.variable_refresh !=
+	    dm_old_crtc_state->base.variable_refresh) {
 		stream_update->vrr_infopacket = &dc_stream->vrr_infopacket;
 		stream_update->adjust = &dc_stream->adjust;
 	}
@@ -4695,9 +4678,9 @@ void set_freesync_on_stream(struct amdgpu_display_manager *dm,
 	struct amdgpu_dm_connector *aconnector =
 			to_amdgpu_dm_connector(new_con_state->base.connector);
 
-	if (new_con_state->freesync_capable &&
-	    new_con_state->freesync_enable) {
-		config.state = new_crtc_state->freesync_enabled ?
+	if (new_con_state->base.variable_refresh_capable &&
+		new_con_state->base.variable_refresh_enabled) {
+		config.state = new_crtc_state->base.variable_refresh ?
 				VRR_STATE_ACTIVE_VARIABLE :
 				VRR_STATE_INACTIVE;
 		config.min_refresh_in_uhz =
@@ -4800,7 +4783,8 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm,
 			}
 		}
 
-		if (dm_old_crtc_state->freesync_enabled != dm_new_crtc_state->freesync_enabled)
+		if (dm_old_crtc_state->base.variable_refresh !=
+		    dm_new_crtc_state->base.variable_refresh)
 			new_crtc_state->mode_changed = true;
 
 		if (!drm_atomic_crtc_needs_modeset(new_crtc_state))
@@ -5089,7 +5073,8 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 
 		if (!drm_atomic_crtc_needs_modeset(new_crtc_state) &&
 		    !new_crtc_state->color_mgmt_changed &&
-		    (dm_old_crtc_state->freesync_enabled == dm_new_crtc_state->freesync_enabled))
+		    (dm_old_crtc_state->base.variable_refresh ==
+		     dm_new_crtc_state->base.variable_refresh))
 			continue;
 
 		if (!new_crtc_state->enable)
@@ -5241,8 +5226,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 		amdgpu_dm_connector->max_vfreq = 0;
 		amdgpu_dm_connector->pixel_clock_mhz = 0;
 
-		dm_con_state->freesync_capable = false;
-		dm_con_state->freesync_enable = false;
+		dm_con_state->base.variable_refresh_capable = false;
+
 		return;
 	}
 
@@ -5266,7 +5251,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 						amdgpu_dm_connector);
 		}
 	}
-	dm_con_state->freesync_capable = false;
+	dm_con_state->base.variable_refresh_capable = false;
+
 	if (edid_check_required == true && (edid->version > 1 ||
 	   (edid->version == 1 && edid->revision > 1))) {
 		for (i = 0; i < 4; i++) {
@@ -5298,7 +5284,7 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 		if (amdgpu_dm_connector->max_vfreq -
 		    amdgpu_dm_connector->min_vfreq > 10) {
 
-			dm_con_state->freesync_capable = true;
+			dm_con_state->base.variable_refresh_capable = true;
 		}
 	}
 }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +0 -3
index 85cfa2cbd8ec..451b06859379 100644
@@ -195,7 +195,6 @@ struct dm_crtc_state {
 	int crc_skip_count;
 	bool crc_enabled;
 
-	bool freesync_enabled;
 	struct dc_crtc_timing_adjust adjust;
 	struct dc_info_packet vrr_infopacket;
 };
@@ -217,8 +216,6 @@ struct dm_connector_state {
 	uint8_t underscan_vborder;
 	uint8_t underscan_hborder;
 	bool underscan_enable;
-	bool freesync_enable;
-	bool freesync_capable;
 };
 
 #define to_dm_connector_state(x)\
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#27 lore raw

PATCH 9/9 drm/amdgpu: Drop unneeded freesync properties from amdpgu

In reply to Nicholas Kazlauskas

With the introduction of new properties in DRM these amdgpu driver specific ones are no longer necessary.

Change-Id Idc88f2e3e036aacc8fe726b15db03d900e509e7c
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 12 ------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h    |  4 ----
 2 files changed, 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -12
index 7d6a36bca9dd..4f2928e91f9c 100644
@@ -626,18 +626,6 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
 					 "dither",
 					 amdgpu_dither_enum_list, sz);
 
-	if (amdgpu_device_has_dc_support(adev)) {
-		adev->mode_info.freesync_property =
-			drm_property_create_bool(adev->ddev, 0, "freesync");
-		if (!adev->mode_info.freesync_property)
-			return -ENOMEM;
-		adev->mode_info.freesync_capable_property =
-			drm_property_create_bool(adev->ddev,
-						 0,
-						 "freesync_capable");
-		if (!adev->mode_info.freesync_capable_property)
-			return -ENOMEM;
-	}
 
 	return 0;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +0 -4
index f91a9bdcd63c..b9e9e8b02fb7 100644
@@ -339,10 +339,6 @@ struct amdgpu_mode_info {
 	struct drm_property *audio_property;
 	/* FMT dithering */
 	struct drm_property *dither_property;
-	/* it is used to allow enablement of freesync mode */
-	struct drm_property *freesync_property;
-	/* it is used to know about display capability of freesync mode */
-	struct drm_property *freesync_capable_property;
 	/* hardcoded DFP edid from BIOS */
 	struct edid *bios_hardcoded_edid;
 	int bios_hardcoded_edid_size;
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel