All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 0/5] A DRM API for adaptive sync and variable refresh rate support
@ 2018-11-08 14:43 Nicholas Kazlauskas
  2018-11-08 14:43 ` [PATCH v7 3/5] drm: Document variable refresh properties Nicholas Kazlauskas
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Nicholas Kazlauskas @ 2018-11-08 14:43 UTC (permalink / raw)
  To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: michel-otUistvHUpPR7s880joybQ, harry.wentland-5C7GfCeVMHo,
	Nicholas Kazlauskas

These patches are part of a proposed new interface for supporting variable refresh rate via DRM properties.

=== Changes from v6 ===

drm changes:

* Updated documentation typos, added more information about potential issues with luminance changes

=== Changes from v5 ===

drm changes:

* Updated documentation to define userspace expectations when variable refresh rate is enabled

amd changes:

* Added patch to fix vblank timestamp calculations when vpos > vtotal

=== Changes from v4 ===

amd changes:

* Removed unused FreeSync functions from amdgpu

=== Changes from v3 ===

drm changes:

* Docstring and formatting fixes

amd/display changes:

* Updated commit message and debug statements

=== Changes from v2 ===

The interface has changed substantially from the last revision and the cover letter has been updated accordingly.

drm changes:

* Most "variable_refresh" prefixes in code have been shortened to just "vrr". This was motivated after changes to the interface had function names close to 80 characters long. Comments from the mailing list were already shortening these in discussion as well.
* Documentation for "Variable Refresh" has been added to the KMS properties subsection for DRM driver developers.
* The drm_connector property "variable_refresh_capable" has been renamed to "vrr_capable".
* The drm_crtc property "variable_refresh" has been been renamed "vrr_enabled" to better reflect its usage.
* The drm_connector "variable_refresh_enabled" property has been removed. Managing this is now up to userspace when it sets "vrr_enabled".
* The "vrr_capable" property no longer has any state in drm_connector_state associated with it. The value can now be updated with the drm_connector_set_vrr_capable_property() function. This better matches the immutable flag on the property.
* The "variable_refresh_changed" flag has been removed from atomic helpers based on feedback from the mailing list and updated interface usage in the amd kernel driver.

amd/display changes:

* Updated interface usage based on the new properties
* Updated VRR infopacket handling based on new xf86-video-amdgpu usage

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

Adaptive sync is part of the DisplayPort specification 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. The user may experience "flickering" from differences in panel luminance at different refresh rates. Content that flips at an infrequent rate or demand is more likely to cause large changes in refresh rate that result in flickering.

Userland needs a way to let the driver know when the screen content is suitable for variable refresh rates.

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

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

The drm_connector has one new optional boolean property:

* bool vrr_capable - set by the driver if the hardware is capable of supporting variable refresh rates

The drm_crtc has one new default boolean property:

* bool vrr_enabled - set by userspace indicating that variable refresh rate should be enabled

== Overview for DRM driver developers ===

Driver developers can attach the "vrr_capable" property by calling drm_connector_attach_vrr_capable_property(). This should be done on connectors that could be capable of supporting variable refresh rates (such as DP or HDMI).

The "vrr_capable" can then be updated accordingly by calling drm_connector_set_vrr_capable_property().

The "vrr_enabled" property can be checked from the drm_crtc_state object.

=== Overview for Userland developers ==

The "vrr_enabled" property on the CRTC should be set to true when the CRTC is suitable for variable refresh rates.

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 (https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu)
* mesa (mesa-dev)

These patches enable adaptive variable refresh on X for AMD hardware. Support for variable refresh is disabled by default in xf86-video-amdgpu and will require additional user configuration.

The patches have been tested as working on upstream userland with the GNOME desktop environment under a single monitor setup. They also work on KDE in a single monitor setup with the compositor disabled.

The patches require that suitable applications flip via the Present extension to xf86-video-amdgpu for the entire Screen. Some compositors may interfere with this if they are unable to unredirect the window.

Full implementation details for these changes can be reviewed in their respective mailing lists and the xf86-video-amdgpu GitLab.

=== Previous discussions ===

These patches are based upon feedback from previous threads on the subject. These 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
https://lists.freedesktop.org/archives/dri-devel/2018-September/189404.htm
https://lists.freedesktop.org/archives/dri-devel/2018-September/190910.html
https://lists.freedesktop.org/archives/dri-devel/2018-October/192211.html
https://lists.freedesktop.org/archives/dri-devel/2018-October/192874.html

Nicholas Kazlauskas (5):
  drm: Add vrr_capable property to the drm connector
  drm: Add vrr_enabled property to drm CRTC
  drm: Document variable refresh properties
  drm/amdgpu: Correct get_crtc_scanoutpos behavior when vpos >= vtotal
  drm/amdgpu: Set FreeSync state using drm VRR properties

 Documentation/gpu/drm-kms.rst                 |   7 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |   7 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h      |   7 -
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 255 +++++++++---------
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   7 +-
 drivers/gpu/drm/drm_atomic_uapi.c             |   4 +
 drivers/gpu/drm/drm_connector.c               | 117 ++++++++
 drivers/gpu/drm/drm_crtc.c                    |   2 +
 drivers/gpu/drm/drm_mode_config.c             |   6 +
 include/drm/drm_connector.h                   |  15 ++
 include/drm/drm_crtc.h                        |   9 +
 include/drm/drm_mode_config.h                 |   5 +
 12 files changed, 309 insertions(+), 132 deletions(-)

-- 
2.19.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v7 1/5] drm: Add vrr_capable property to the drm connector
       [not found] ` <20181108144353.31363-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
@ 2018-11-08 14:43   ` Nicholas Kazlauskas
  2018-11-08 14:43   ` [PATCH v7 2/5] drm: Add vrr_enabled property to drm CRTC Nicholas Kazlauskas
  2018-11-08 14:43   ` [PATCH v7 4/5] drm/amdgpu: Correct get_crtc_scanoutpos behavior when vpos >= vtotal Nicholas Kazlauskas
  2 siblings, 0 replies; 15+ messages in thread
From: Nicholas Kazlauskas @ 2018-11-08 14:43 UTC (permalink / raw)
  To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: michel-otUistvHUpPR7s880joybQ, harry.wentland-5C7GfCeVMHo,
	Nicholas Kazlauskas

Modern display hardware is capable of supporting variable refresh rates.
This patch introduces the "vrr_capable" property on the connector to
allow userspace to query support for variable refresh rates.

Atomic drivers should attach this property to connectors that are
capable of driving variable refresh rates using
drm_connector_attach_vrr_capable_property().

The value should be updated based on driver and hardware capability
by using drm_connector_set_vrr_capable_property().

Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: Manasi Navare <manasi.d.navare@intel.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
---
 drivers/gpu/drm/drm_connector.c | 49 +++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h     | 15 ++++++++++
 2 files changed, 64 insertions(+)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 4943cef178be..49290060ab7b 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1255,6 +1255,37 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
 
+/**
+ * drm_connector_attach_vrr_capable_property - creates the
+ * vrr_capable property
+ * @connector: connector to create the vrr_capable property on.
+ *
+ * This is used by atomic drivers to add support for querying
+ * variable refresh rate capability for a connector.
+ *
+ * Returns:
+ * Zero on success, negative errono on failure.
+ */
+int drm_connector_attach_vrr_capable_property(
+	struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_property *prop;
+
+	if (!connector->vrr_capable_property) {
+		prop = drm_property_create_bool(dev, DRM_MODE_PROP_IMMUTABLE,
+			"vrr_capable");
+		if (!prop)
+			return -ENOMEM;
+
+		connector->vrr_capable_property = prop;
+		drm_object_attach_property(&connector->base, prop, 0);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_vrr_capable_property);
+
 /**
  * drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
  * @connector: connector to attach scaling mode property on.
@@ -1583,6 +1614,24 @@ void drm_connector_set_link_status_property(struct drm_connector *connector,
 }
 EXPORT_SYMBOL(drm_connector_set_link_status_property);
 
+/**
+ * drm_connector_set_vrr_capable_property - sets the variable refresh rate
+ * capable property for a connector
+ * @connector: drm connector
+ * @capable: True if the connector is variable refresh rate capable
+ *
+ * Should be used by atomic drivers to update the indicated support for
+ * variable refresh rate over a connector.
+ */
+void drm_connector_set_vrr_capable_property(
+		struct drm_connector *connector, bool capable)
+{
+	drm_object_property_set_value(&connector->base,
+				      connector->vrr_capable_property,
+				      capable);
+}
+EXPORT_SYMBOL(drm_connector_set_vrr_capable_property);
+
 /**
  * drm_connector_init_panel_orientation_property -
  *	initialize the connecters panel_orientation property
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 9ccad6b062f2..4e6befff153b 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -959,6 +959,17 @@ struct drm_connector {
 	 */
 	struct drm_property *scaling_mode_property;
 
+	/**
+	 * @vrr_capable_property: Optional property to help userspace
+	 * query hardware support for variable refresh rate on a connector.
+	 * connector. Drivers can add the property to a connector by
+	 * calling drm_connector_attach_vrr_capable_property().
+	 *
+	 * This should be updated only by calling
+	 * drm_connector_set_vrr_capable_property().
+	 */
+	struct drm_property *vrr_capable_property;
+
 	/**
 	 * @content_protection_property: DRM ENUM property for content
 	 * protection. See drm_connector_attach_content_protection_property().
@@ -1250,6 +1261,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_vrr_capable_property(
+		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);
@@ -1266,6 +1279,8 @@ int drm_connector_update_edid_property(struct drm_connector *connector,
 				       const struct edid *edid);
 void drm_connector_set_link_status_property(struct drm_connector *connector,
 					    uint64_t link_status);
+void drm_connector_set_vrr_capable_property(
+		struct drm_connector *connector, bool capable);
 int drm_connector_init_panel_orientation_property(
 	struct drm_connector *connector, int width, int height);
 
-- 
2.19.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v7 2/5] drm: Add vrr_enabled property to drm CRTC
       [not found] ` <20181108144353.31363-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
  2018-11-08 14:43   ` [PATCH v7 1/5] drm: Add vrr_capable property to the drm connector Nicholas Kazlauskas
@ 2018-11-08 14:43   ` Nicholas Kazlauskas
       [not found]     ` <20181108144353.31363-3-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
  2018-11-08 14:43   ` [PATCH v7 4/5] drm/amdgpu: Correct get_crtc_scanoutpos behavior when vpos >= vtotal Nicholas Kazlauskas
  2 siblings, 1 reply; 15+ messages in thread
From: Nicholas Kazlauskas @ 2018-11-08 14:43 UTC (permalink / raw)
  To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Manasi Navare, michel-otUistvHUpPR7s880joybQ,
	harry.wentland-5C7GfCeVMHo, Nicholas Kazlauskas

This patch introduces the 'vrr_enabled' CRTC property to allow
dynamic control over variable refresh rate support for a CRTC.

This property should be treated like a content hint to the driver -
if the hardware or driver is not capable of driving variable refresh
timings then this is not considered an error.

Capability for variable refresh rate support should be determined
by querying the vrr_capable drm connector property.

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

Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Cc: Manasi Navare <manasi.d.navare@intel.com>
---
 drivers/gpu/drm/drm_atomic_uapi.c | 4 ++++
 drivers/gpu/drm/drm_crtc.c        | 2 ++
 drivers/gpu/drm/drm_mode_config.c | 6 ++++++
 include/drm/drm_crtc.h            | 9 +++++++++
 include/drm/drm_mode_config.h     | 5 +++++
 5 files changed, 26 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index d5b7f315098c..eec396a57b88 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -433,6 +433,8 @@ static 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_vrr_enabled) {
+		state->vrr_enabled = val;
 	} else if (property == config->degamma_lut_property) {
 		ret = drm_atomic_replace_property_blob_from_id(dev,
 					&state->degamma_lut,
@@ -491,6 +493,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_vrr_enabled)
+		*val = state->vrr_enabled;
 	else if (property == config->degamma_lut_property)
 		*val = (state->degamma_lut) ? state->degamma_lut->base.id : 0;
 	else if (property == config->ctm_property)
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 268a182ae189..6f8ddfcfaba5 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -340,6 +340,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_vrr_enabled, 0);
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index ee80788f2c40..5670c67f28d4 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -310,6 +310,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,
+			"VRR_ENABLED");
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.prop_vrr_enabled = prop;
+
 	prop = drm_property_create(dev,
 			DRM_MODE_PROP_BLOB,
 			"DEGAMMA_LUT", 0);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index b21437bc95bf..39c3900aab3c 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -290,6 +290,15 @@ struct drm_crtc_state {
 	 */
 	u32 pageflip_flags;
 
+	/**
+	 * @vrr_enabled:
+	 *
+	 * Indicates if variable refresh rate should be enabled for the CRTC.
+	 * Support for the requested vrr state will depend on driver and
+	 * hardware capabiltiy - lacking support is not treated as failure.
+	 */
+	bool vrr_enabled;
+
 	/**
 	 * @event:
 	 *
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 928e4172a0bb..49f2fcfdb5fc 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -639,6 +639,11 @@ struct drm_mode_config {
 	 * connectors must be of and active must be set to disabled, too.
 	 */
 	struct drm_property *prop_mode_id;
+	/**
+	 * @prop_vrr_enabled: Default atomic CRTC property to indicate
+	 * whether variable refresh rate should be enabled on the CRTC.
+	 */
+	struct drm_property *prop_vrr_enabled;
 
 	/**
 	 * @dvi_i_subconnector_property: Optional DVI-I property to
-- 
2.19.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v7 3/5] drm: Document variable refresh properties
  2018-11-08 14:43 [PATCH v7 0/5] A DRM API for adaptive sync and variable refresh rate support Nicholas Kazlauskas
@ 2018-11-08 14:43 ` Nicholas Kazlauskas
       [not found]   ` <20181108144353.31363-4-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
       [not found] ` <20181108144353.31363-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
  2018-11-08 14:43 ` [PATCH v7 5/5] drm/amdgpu: Set FreeSync state using drm VRR properties Nicholas Kazlauskas
  2 siblings, 1 reply; 15+ messages in thread
From: Nicholas Kazlauskas @ 2018-11-08 14:43 UTC (permalink / raw)
  To: dri-devel, amd-gfx; +Cc: michel, Manasi Navare, Nicholas Kazlauskas

These include the drm_connector 'vrr_capable' and the drm_crtc
'vrr_enabled' properties.

Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Manasi Navare <manasi.d.navare@intel.com>
Cc: Pekka Paalanen <ppaalanen@gmail.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Michel Dänzer <michel@daenzer.net>
---
 Documentation/gpu/drm-kms.rst   |  7 ++++
 drivers/gpu/drm/drm_connector.c | 68 +++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)

diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.rst
index 4b1501b4835b..8da2a178cf85 100644
--- a/Documentation/gpu/drm-kms.rst
+++ b/Documentation/gpu/drm-kms.rst
@@ -575,6 +575,13 @@ Explicit Fencing Properties
 .. kernel-doc:: drivers/gpu/drm/drm_atomic_uapi.c
    :doc: explicit fencing properties
 
+
+Variable Refresh Properties
+---------------------------
+
+.. kernel-doc:: drivers/gpu/drm/drm_connector.c
+   :doc: Variable refresh properties
+
 Existing KMS Properties
 -----------------------
 
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 49290060ab7b..0e4287461997 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1255,6 +1255,74 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
 
+/**
+ * DOC: Variable refresh properties
+ *
+ * Variable refresh rate capable displays can dynamically adjust their
+ * refresh rate by extending the duration of their vertical front porch
+ * until page flip or timeout occurs. This can reduce or remove stuttering
+ * and latency in scenarios where the page flip does not align with the
+ * vblank interval.
+ *
+ * An example scenario would be an application flipping at a constant rate
+ * of 48Hz on a 60Hz display. The page flip will frequently miss the vblank
+ * interval and the same contents will be displayed twice. This can be
+ * observed as stuttering for content with motion.
+ *
+ * If variable refresh rate was active on a display that supported a
+ * variable refresh range from 35Hz to 60Hz no stuttering would be observable
+ * for the example scenario. The minimum supported variable refresh rate of
+ * 35Hz is below the page flip frequency and the vertical front porch can
+ * be extended until the page flip occurs. The vblank interval will be
+ * directly aligned to the page flip rate.
+ *
+ * Not all userspace content is suitable for use with variable refresh rate.
+ * Large and frequent changes in vertical front porch duration may worsen
+ * perceived stuttering for input sensitive applications.
+ *
+ * Panel brightness will also vary with vertical front porch duration. Some
+ * panels may have noticeable differences in brightness between the minimum
+ * vertical front porch duration and the maximum vertical front porch duration.
+ * Large and frequent changes in vertical front porch duration may produce
+ * observable flickering for such panels.
+ *
+ * Userspace control for variable refresh rate is supported via properties
+ * on the &drm_connector and &drm_crtc objects.
+ *
+ * "vrr_capable":
+ *	Optional &drm_connector boolean property that drivers should attach
+ *	with drm_connector_attach_vrr_capable_property() on connectors that
+ *	could support variable refresh rates. Drivers should update the
+ *	property value by calling drm_connector_set_vrr_capable_property().
+ *
+ *	Absence of the property should indicate absence of support.
+ *
+ * "vrr_enabled":
+ *	Default &drm_crtc boolean property that notifies the driver that the
+ *	content on the CRTC is suitable for variable refresh rate presentation.
+ *	The driver will take this property as a hint to enable variable
+ *	refresh rate support if the receiver supports it, ie. if the
+ *	"vrr_capable" property is true on the &drm_connector object. The
+ *	vertical front porch duration will be extended until page-flip or
+ *	timeout when enabled.
+ *
+ *	The minimum vertical front porch duration is defined as the vertical
+ *	front porch duration for the current mode.
+ *
+ *	The maximum vertical front porch duration is greater than or equal to
+ *	the minimum vertical front porch duration. The duration is derived
+ *	from the minimum supported variable refresh rate for the connector.
+ *
+ *	The driver may place further restrictions within these minimum
+ *	and maximum bounds.
+ *
+ *	The semantics for the vertical blank timestamp differ when
+ *	variable refresh rate is active. The vertical blank timestamp
+ *	is defined to be an estimate using the current mode's fixed
+ *	refresh rate timings. The semantics for the page-flip event
+ *	timestamp remain the same.
+ */
+
 /**
  * drm_connector_attach_vrr_capable_property - creates the
  * vrr_capable property
-- 
2.19.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v7 4/5] drm/amdgpu: Correct get_crtc_scanoutpos behavior when vpos >= vtotal
       [not found] ` <20181108144353.31363-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
  2018-11-08 14:43   ` [PATCH v7 1/5] drm: Add vrr_capable property to the drm connector Nicholas Kazlauskas
  2018-11-08 14:43   ` [PATCH v7 2/5] drm: Add vrr_enabled property to drm CRTC Nicholas Kazlauskas
@ 2018-11-08 14:43   ` Nicholas Kazlauskas
  2 siblings, 0 replies; 15+ messages in thread
From: Nicholas Kazlauskas @ 2018-11-08 14:43 UTC (permalink / raw)
  To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: michel-otUistvHUpPR7s880joybQ, harry.wentland-5C7GfCeVMHo,
	Nicholas Kazlauskas

When variable refresh rate is active the hardware counter can return
a position >= vtotal. This results in a vpos being returned from
amdgpu_display_get_crtc_scanoutpos that's a positive value. The
positive value indicates to the caller that the display is
currently in scanout when the display is actually still in vblank.

This is because the vfront porch duration is unknown with variable
refresh active and will end when either a page flip occurs or the
timeout specified by the driver/display is reached.

The behavior of the amdgpu_display_get_crtc_scanoutpos remains the
same when the position is below vtotal. When the position is above
vtotal the function will return a value that is effectively -vbl_end,
the size of the vback porch.

The only caller affected by this change is the DRM helper for
calculating vblank timestamps. This change corrects behavior for
calculating the page flip timestamp from being the previous timestamp
to the calculation to the next timestamp when position >= vtotal.

Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Cc: Michel Dänzer <michel@daenzer.net>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 6748cd7fc129..cb331319f225 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -850,7 +850,12 @@ int amdgpu_display_get_crtc_scanoutpos(struct drm_device *dev,
 	/* Inside "upper part" of vblank area? Apply corrective offset if so: */
 	if (in_vbl && (*vpos >= vbl_start)) {
 		vtotal = mode->crtc_vtotal;
-		*vpos = *vpos - vtotal;
+
+		/* With variable refresh rate displays the vpos can exceed
+		 * the vtotal value. Clamp to 0 to return -vbl_end instead
+		 * of guessing the remaining number of lines until scanout.
+		 */
+		*vpos = (*vpos < vtotal) ? (*vpos - vtotal) : 0;
 	}
 
 	/* Correct for shifted end of vbl at vbl_end. */
-- 
2.19.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v7 5/5] drm/amdgpu: Set FreeSync state using drm VRR properties
  2018-11-08 14:43 [PATCH v7 0/5] A DRM API for adaptive sync and variable refresh rate support Nicholas Kazlauskas
  2018-11-08 14:43 ` [PATCH v7 3/5] drm: Document variable refresh properties Nicholas Kazlauskas
       [not found] ` <20181108144353.31363-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
@ 2018-11-08 14:43 ` Nicholas Kazlauskas
  2 siblings, 0 replies; 15+ messages in thread
From: Nicholas Kazlauskas @ 2018-11-08 14:43 UTC (permalink / raw)
  To: dri-devel, amd-gfx; +Cc: michel, Nicholas Kazlauskas

Support for AMDGPU specific FreeSync properties and ioctls are dropped
from amdgpu_dm in favor of supporting drm variable refresh rate
properties.

The notify_freesync and set_freesync_property functions are dropped
from amdgpu_display_funcs.

The drm vrr_capable property is now attached to any DP/HDMI connector.
Its value is updated accordingly to the connector's FreeSync capabiltiy.

The freesync_enable logic and ioctl control has has been dropped in
favor of utilizing the vrr_enabled on the drm CRTC. This allows for more
fine grained atomic control over which CRTCs should support variable
refresh rate.

To handle state changes for vrr_enabled it was easiest to drop the
forced modeset on freesync_enabled change. This patch now performs the
required stream updates when planes are flipped.

This is done for a few reasons:

(1) VRR stream updates can be done in the fast update path

(2) amdgpu_dm_atomic_check would need to be hacked apart to check
    desired variable refresh state and capability before the CRTC
    disable pass.

(3) Performing VRR stream updates on-flip is needed for enabling BTR
    support.

VRR packets and timing adjustments are now tracked and compared to
previous values sent to the hardware.

Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h      |   7 -
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 255 +++++++++---------
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   7 +-
 3 files changed, 138 insertions(+), 131 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
index b9e9e8b02fb7..0cbe867ec375 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
@@ -295,13 +295,6 @@ struct amdgpu_display_funcs {
 			      uint16_t connector_object_id,
 			      struct amdgpu_hpd *hpd,
 			      struct amdgpu_router *router);
-	/* it is used to enter or exit into free sync mode */
-	int (*notify_freesync)(struct drm_device *dev, void *data,
-			       struct drm_file *filp);
-	/* it is used to allow enablement of freesync mode */
-	int (*set_freesync_property)(struct drm_connector *connector,
-				     struct drm_property *property,
-				     uint64_t val);
 
 
 };
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index b0df6dc9a775..53eb3d16f75c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1809,72 +1809,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_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;
-
-	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->freesync_enabled = 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 */
@@ -1888,7 +1822,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,
 
 };
 
@@ -2841,7 +2774,8 @@ dm_crtc_duplicate_state(struct drm_crtc *crtc)
 
 	state->adjust = cur->adjust;
 	state->vrr_infopacket = cur->vrr_infopacket;
-	state->freesync_enabled = cur->freesync_enabled;
+	state->vrr_supported = cur->vrr_supported;
+	state->freesync_config = cur->freesync_config;
 
 	/* TODO Duplicate dc_stream after objects are stream object is flattened */
 
@@ -3060,8 +2994,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;
 }
 
@@ -3807,6 +3739,11 @@ 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_connector_attach_vrr_capable_property(
+			&aconnector->base);
+	}
 }
 
 static int amdgpu_dm_i2c_xfer(struct i2c_adapter *i2c_adap,
@@ -4183,6 +4120,77 @@ static void prepare_flip_isr(struct amdgpu_crtc *acrtc)
 						 acrtc->crtc_id);
 }
 
+static void update_freesync_state_on_stream(
+	struct amdgpu_display_manager *dm,
+	struct dm_crtc_state *new_crtc_state,
+	struct dc_stream_state *new_stream)
+{
+	struct mod_vrr_params vrr = {0};
+	struct dc_info_packet vrr_infopacket = {0};
+	struct mod_freesync_config config = new_crtc_state->freesync_config;
+
+	if (!new_stream)
+		return;
+
+	/*
+	 * TODO: Determine why min/max totals and vrefresh can be 0 here.
+	 * For now it's sufficient to just guard against these conditions.
+	 */
+
+	if (!new_stream->timing.h_total || !new_stream->timing.v_total)
+		return;
+
+	if (new_crtc_state->vrr_supported &&
+	    config.min_refresh_in_uhz &&
+	    config.max_refresh_in_uhz) {
+		config.state = new_crtc_state->base.vrr_enabled ?
+			VRR_STATE_ACTIVE_VARIABLE :
+			VRR_STATE_INACTIVE;
+	} else {
+		config.state = VRR_STATE_UNSUPPORTED;
+	}
+
+	mod_freesync_build_vrr_params(dm->freesync_module,
+				      new_stream,
+				      &config, &vrr);
+
+	mod_freesync_build_vrr_infopacket(
+		dm->freesync_module,
+		new_stream,
+		&vrr,
+		packet_type_vrr,
+		transfer_func_unknown,
+		&vrr_infopacket);
+
+	new_crtc_state->freesync_timing_changed =
+		(memcmp(&new_crtc_state->adjust,
+			&vrr.adjust,
+			sizeof(vrr.adjust)) != 0);
+
+	new_crtc_state->freesync_vrr_info_changed =
+		(memcmp(&new_crtc_state->vrr_infopacket,
+			&vrr_infopacket,
+			sizeof(vrr_infopacket)) != 0);
+
+	new_crtc_state->adjust = vrr.adjust;
+	new_crtc_state->vrr_infopacket = vrr_infopacket;
+
+	new_stream->adjust = new_crtc_state->adjust;
+	new_stream->vrr_infopacket = vrr_infopacket;
+
+	if (new_crtc_state->freesync_vrr_info_changed)
+		DRM_DEBUG_KMS("VRR packet update: crtc=%u enabled=%d state=%d",
+			      new_crtc_state->base.crtc->base.id,
+			      (int)new_crtc_state->base.vrr_enabled,
+			      (int)vrr.state);
+
+	if (new_crtc_state->freesync_timing_changed)
+		DRM_DEBUG_KMS("VRR timing update: crtc=%u min=%u max=%u\n",
+			      new_crtc_state->base.crtc->base.id,
+			      vrr.adjust.v_total_min,
+			      vrr.adjust.v_total_max);
+}
+
 /*
  * Executes flip
  *
@@ -4204,6 +4212,7 @@ static void amdgpu_dm_do_flip(struct drm_crtc *crtc,
 	struct dc_flip_addrs addr = { {0} };
 	/* TODO eliminate or rename surface_update */
 	struct dc_surface_update surface_updates[1] = { {0} };
+	struct dc_stream_update stream_update = {0};
 	struct dm_crtc_state *acrtc_state = to_dm_crtc_state(crtc->state);
 	struct dc_stream_status *stream_status;
 
@@ -4276,11 +4285,26 @@ static void amdgpu_dm_do_flip(struct drm_crtc *crtc,
 	}
 	surface_updates->flip_addr = &addr;
 
+	if (acrtc_state->stream) {
+		update_freesync_state_on_stream(
+			&adev->dm,
+			acrtc_state,
+			acrtc_state->stream);
+
+		if (acrtc_state->freesync_timing_changed)
+			stream_update.adjust =
+				&acrtc_state->stream->adjust;
+
+		if (acrtc_state->freesync_vrr_info_changed)
+			stream_update.vrr_infopacket =
+				&acrtc_state->stream->vrr_infopacket;
+	}
+
 	dc_commit_updates_for_stream(adev->dm.dc,
 					     surface_updates,
 					     1,
 					     acrtc_state->stream,
-					     NULL,
+					     &stream_update,
 					     &surface_updates->surface,
 					     state);
 
@@ -4340,11 +4364,6 @@ 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 =
@@ -4480,9 +4499,6 @@ 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,
 							planes_count,
@@ -4686,9 +4702,6 @@ 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,
@@ -4912,20 +4925,18 @@ static int do_aquire_global_lock(struct drm_device *dev,
 	return ret < 0 ? ret : 0;
 }
 
-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)
+static void get_freesync_config_for_crtc(
+	struct dm_crtc_state *new_crtc_state,
+	struct dm_connector_state *new_con_state)
 {
 	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 ?
+	new_crtc_state->vrr_supported = new_con_state->freesync_capable;
+
+	if (new_con_state->freesync_capable) {
+		config.state = new_crtc_state->base.vrr_enabled ?
 				VRR_STATE_ACTIVE_VARIABLE :
 				VRR_STATE_INACTIVE;
 		config.min_refresh_in_uhz =
@@ -4935,19 +4946,18 @@ void set_freesync_on_stream(struct amdgpu_display_manager *dm,
 		config.vsif_supported = true;
 	}
 
-	mod_freesync_build_vrr_params(dm->freesync_module,
-				      new_stream,
-				      &config, &vrr);
+	new_crtc_state->freesync_config = config;
+}
 
-	mod_freesync_build_vrr_infopacket(dm->freesync_module,
-					  new_stream,
-					  &vrr,
-					  packet_type_fs1,
-					  NULL,
-					  &vrr_infopacket);
+static void reset_freesync_config_for_crtc(
+	struct dm_crtc_state *new_crtc_state)
+{
+	new_crtc_state->vrr_supported = false;
 
-	new_crtc_state->adjust = vrr.adjust;
-	new_crtc_state->vrr_infopacket = vrr_infopacket;
+	memset(&new_crtc_state->adjust, 0,
+	       sizeof(new_crtc_state->adjust));
+	memset(&new_crtc_state->vrr_infopacket, 0,
+	       sizeof(new_crtc_state->vrr_infopacket));
 }
 
 static int dm_update_crtcs_state(struct amdgpu_display_manager *dm,
@@ -5022,9 +5032,6 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm,
 				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;
@@ -5033,9 +5040,6 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm,
 			}
 		}
 
-		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;
 
@@ -5072,6 +5076,8 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm,
 			dc_stream_release(dm_old_crtc_state->stream);
 			dm_new_crtc_state->stream = NULL;
 
+			reset_freesync_config_for_crtc(dm_new_crtc_state);
+
 			*lock_and_validation_needed = true;
 
 		} else {/* Add stream for any updated/enabled CRTC */
@@ -5149,7 +5155,9 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm,
 			amdgpu_dm_set_ctm(dm_new_crtc_state);
 		}
 
-
+		/* Update Freesync settings. */
+		get_freesync_config_for_crtc(dm_new_crtc_state,
+					     dm_new_conn_state);
 	}
 
 	return ret;
@@ -5414,12 +5422,9 @@ 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 &&
-		    (dm_old_crtc_state->freesync_enabled == dm_new_crtc_state->freesync_enabled))
+		    !new_crtc_state->vrr_enabled)
 			continue;
 
 		if (!new_crtc_state->enable)
@@ -5571,14 +5576,15 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 	struct detailed_data_monitor_range *range;
 	struct amdgpu_dm_connector *amdgpu_dm_connector =
 			to_amdgpu_dm_connector(connector);
-	struct dm_connector_state *dm_con_state;
+	struct dm_connector_state *dm_con_state = NULL;
 
 	struct drm_device *dev = connector->dev;
 	struct amdgpu_device *adev = dev->dev_private;
+	bool freesync_capable = false;
 
 	if (!connector->state) {
 		DRM_ERROR("%s - Connector has no state", __func__);
-		return;
+		goto update;
 	}
 
 	if (!edid) {
@@ -5588,9 +5594,7 @@ 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;
-		return;
+		goto update;
 	}
 
 	dm_con_state = to_dm_connector_state(connector->state);
@@ -5598,10 +5602,10 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 	edid_check_required = false;
 	if (!amdgpu_dm_connector->dc_sink) {
 		DRM_ERROR("dc_sink NULL, could not add free_sync module.\n");
-		return;
+		goto update;
 	}
 	if (!adev->dm.freesync_module)
-		return;
+		goto update;
 	/*
 	 * if edid non zero restrict freesync only for dp and edp
 	 */
@@ -5613,7 +5617,6 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 						amdgpu_dm_connector);
 		}
 	}
-	dm_con_state->freesync_capable = false;
 	if (edid_check_required == true && (edid->version > 1 ||
 	   (edid->version == 1 && edid->revision > 1))) {
 		for (i = 0; i < 4; i++) {
@@ -5645,8 +5648,16 @@ 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;
+			freesync_capable = true;
 		}
 	}
+
+update:
+	if (dm_con_state)
+		dm_con_state->freesync_capable = freesync_capable;
+
+	if (connector->vrr_capable_property)
+		drm_connector_set_vrr_capable_property(connector,
+						       freesync_capable);
 }
 
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
index 978b34a5011c..a5aaf8b08968 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
@@ -185,7 +185,11 @@ struct dm_crtc_state {
 	int crc_skip_count;
 	bool crc_enabled;
 
-	bool freesync_enabled;
+	bool freesync_timing_changed;
+	bool freesync_vrr_info_changed;
+
+	bool vrr_supported;
+	struct mod_freesync_config freesync_config;
 	struct dc_crtc_timing_adjust adjust;
 	struct dc_info_packet vrr_infopacket;
 };
@@ -207,7 +211,6 @@ struct dm_connector_state {
 	uint8_t underscan_vborder;
 	uint8_t underscan_hborder;
 	bool underscan_enable;
-	bool freesync_enable;
 	bool freesync_capable;
 };
 
-- 
2.19.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v7 3/5] drm: Document variable refresh properties
       [not found]   ` <20181108144353.31363-4-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
@ 2018-11-12 16:12     ` Wentland, Harry
       [not found]       ` <77ad01c4-4306-e150-c143-f52593b4656f-5C7GfCeVMHo@public.gmane.org>
  2018-11-27  9:22       ` Daniel Vetter
  0 siblings, 2 replies; 15+ messages in thread
From: Wentland, Harry @ 2018-11-12 16:12 UTC (permalink / raw)
  To: Kazlauskas, Nicholas, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Manasi Navare, michel-otUistvHUpPR7s880joybQ, Pekka Paalanen,
	Ville Syrjälä

On 2018-11-08 9:43 a.m., Nicholas Kazlauskas wrote:
> These include the drm_connector 'vrr_capable' and the drm_crtc
> 'vrr_enabled' properties.
> 
> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
> Cc: Harry Wentland <harry.wentland@amd.com>
> Cc: Manasi Navare <manasi.d.navare@intel.com>
> Cc: Pekka Paalanen <ppaalanen@gmail.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Michel Dänzer <michel@daenzer.net>

Looks good. Whole series is
Reviewed-by: Harry Wentland <harry.wentland@amd.com>

How are we with the userspace patches? We should probably hold off pushing the kernel patches until the userspace work is all reviewed.

Harry

> ---
>  Documentation/gpu/drm-kms.rst   |  7 ++++
>  drivers/gpu/drm/drm_connector.c | 68 +++++++++++++++++++++++++++++++++
>  2 files changed, 75 insertions(+)
> 
> diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.rst
> index 4b1501b4835b..8da2a178cf85 100644
> --- a/Documentation/gpu/drm-kms.rst
> +++ b/Documentation/gpu/drm-kms.rst
> @@ -575,6 +575,13 @@ Explicit Fencing Properties
>  .. kernel-doc:: drivers/gpu/drm/drm_atomic_uapi.c
>     :doc: explicit fencing properties
>  
> +
> +Variable Refresh Properties
> +---------------------------
> +
> +.. kernel-doc:: drivers/gpu/drm/drm_connector.c
> +   :doc: Variable refresh properties
> +
>  Existing KMS Properties
>  -----------------------
>  
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 49290060ab7b..0e4287461997 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -1255,6 +1255,74 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
>  }
>  EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
>  
> +/**
> + * DOC: Variable refresh properties
> + *
> + * Variable refresh rate capable displays can dynamically adjust their
> + * refresh rate by extending the duration of their vertical front porch
> + * until page flip or timeout occurs. This can reduce or remove stuttering
> + * and latency in scenarios where the page flip does not align with the
> + * vblank interval.
> + *
> + * An example scenario would be an application flipping at a constant rate
> + * of 48Hz on a 60Hz display. The page flip will frequently miss the vblank
> + * interval and the same contents will be displayed twice. This can be
> + * observed as stuttering for content with motion.
> + *
> + * If variable refresh rate was active on a display that supported a
> + * variable refresh range from 35Hz to 60Hz no stuttering would be observable
> + * for the example scenario. The minimum supported variable refresh rate of
> + * 35Hz is below the page flip frequency and the vertical front porch can
> + * be extended until the page flip occurs. The vblank interval will be
> + * directly aligned to the page flip rate.
> + *
> + * Not all userspace content is suitable for use with variable refresh rate.
> + * Large and frequent changes in vertical front porch duration may worsen
> + * perceived stuttering for input sensitive applications.
> + *
> + * Panel brightness will also vary with vertical front porch duration. Some
> + * panels may have noticeable differences in brightness between the minimum
> + * vertical front porch duration and the maximum vertical front porch duration.
> + * Large and frequent changes in vertical front porch duration may produce
> + * observable flickering for such panels.
> + *
> + * Userspace control for variable refresh rate is supported via properties
> + * on the &drm_connector and &drm_crtc objects.
> + *
> + * "vrr_capable":
> + *	Optional &drm_connector boolean property that drivers should attach
> + *	with drm_connector_attach_vrr_capable_property() on connectors that
> + *	could support variable refresh rates. Drivers should update the
> + *	property value by calling drm_connector_set_vrr_capable_property().
> + *
> + *	Absence of the property should indicate absence of support.
> + *
> + * "vrr_enabled":
> + *	Default &drm_crtc boolean property that notifies the driver that the
> + *	content on the CRTC is suitable for variable refresh rate presentation.
> + *	The driver will take this property as a hint to enable variable
> + *	refresh rate support if the receiver supports it, ie. if the
> + *	"vrr_capable" property is true on the &drm_connector object. The
> + *	vertical front porch duration will be extended until page-flip or
> + *	timeout when enabled.
> + *
> + *	The minimum vertical front porch duration is defined as the vertical
> + *	front porch duration for the current mode.
> + *
> + *	The maximum vertical front porch duration is greater than or equal to
> + *	the minimum vertical front porch duration. The duration is derived
> + *	from the minimum supported variable refresh rate for the connector.
> + *
> + *	The driver may place further restrictions within these minimum
> + *	and maximum bounds.
> + *
> + *	The semantics for the vertical blank timestamp differ when
> + *	variable refresh rate is active. The vertical blank timestamp
> + *	is defined to be an estimate using the current mode's fixed
> + *	refresh rate timings. The semantics for the page-flip event
> + *	timestamp remain the same.
> + */
> +
>  /**
>   * drm_connector_attach_vrr_capable_property - creates the
>   * vrr_capable property
> 
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v7 3/5] drm: Document variable refresh properties
       [not found]       ` <77ad01c4-4306-e150-c143-f52593b4656f-5C7GfCeVMHo@public.gmane.org>
@ 2018-11-12 17:05         ` Kazlauskas, Nicholas
       [not found]           ` <58956653-ab01-55c8-abad-a6b8e270acd1-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Kazlauskas, Nicholas @ 2018-11-12 17:05 UTC (permalink / raw)
  To: Wentland, Harry, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Manasi Navare, michel-otUistvHUpPR7s880joybQ, Pekka Paalanen,
	Ville Syrjälä

On 11/12/18 11:12 AM, Wentland, Harry wrote:
> On 2018-11-08 9:43 a.m., Nicholas Kazlauskas wrote:
>> These include the drm_connector 'vrr_capable' and the drm_crtc
>> 'vrr_enabled' properties.
>>
>> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
>> Cc: Harry Wentland <harry.wentland@amd.com>
>> Cc: Manasi Navare <manasi.d.navare@intel.com>
>> Cc: Pekka Paalanen <ppaalanen@gmail.com>
>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> Cc: Michel Dänzer <michel@daenzer.net>
> 
> Looks good. Whole series is
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
> 
> How are we with the userspace patches? We should probably hold off pushing the kernel patches until the userspace work is all reviewed.
> 
> Harry

Thanks for the review.

The xf86-video-amdgpu patches have been reviewed and the mesa patches 
have been partially reviewed.

Nicholas Kazlauskas

> 
>> ---
>>   Documentation/gpu/drm-kms.rst   |  7 ++++
>>   drivers/gpu/drm/drm_connector.c | 68 +++++++++++++++++++++++++++++++++
>>   2 files changed, 75 insertions(+)
>>
>> diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.rst
>> index 4b1501b4835b..8da2a178cf85 100644
>> --- a/Documentation/gpu/drm-kms.rst
>> +++ b/Documentation/gpu/drm-kms.rst
>> @@ -575,6 +575,13 @@ Explicit Fencing Properties
>>   .. kernel-doc:: drivers/gpu/drm/drm_atomic_uapi.c
>>      :doc: explicit fencing properties
>>   
>> +
>> +Variable Refresh Properties
>> +---------------------------
>> +
>> +.. kernel-doc:: drivers/gpu/drm/drm_connector.c
>> +   :doc: Variable refresh properties
>> +
>>   Existing KMS Properties
>>   -----------------------
>>   
>> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
>> index 49290060ab7b..0e4287461997 100644
>> --- a/drivers/gpu/drm/drm_connector.c
>> +++ b/drivers/gpu/drm/drm_connector.c
>> @@ -1255,6 +1255,74 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
>>   }
>>   EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
>>   
>> +/**
>> + * DOC: Variable refresh properties
>> + *
>> + * Variable refresh rate capable displays can dynamically adjust their
>> + * refresh rate by extending the duration of their vertical front porch
>> + * until page flip or timeout occurs. This can reduce or remove stuttering
>> + * and latency in scenarios where the page flip does not align with the
>> + * vblank interval.
>> + *
>> + * An example scenario would be an application flipping at a constant rate
>> + * of 48Hz on a 60Hz display. The page flip will frequently miss the vblank
>> + * interval and the same contents will be displayed twice. This can be
>> + * observed as stuttering for content with motion.
>> + *
>> + * If variable refresh rate was active on a display that supported a
>> + * variable refresh range from 35Hz to 60Hz no stuttering would be observable
>> + * for the example scenario. The minimum supported variable refresh rate of
>> + * 35Hz is below the page flip frequency and the vertical front porch can
>> + * be extended until the page flip occurs. The vblank interval will be
>> + * directly aligned to the page flip rate.
>> + *
>> + * Not all userspace content is suitable for use with variable refresh rate.
>> + * Large and frequent changes in vertical front porch duration may worsen
>> + * perceived stuttering for input sensitive applications.
>> + *
>> + * Panel brightness will also vary with vertical front porch duration. Some
>> + * panels may have noticeable differences in brightness between the minimum
>> + * vertical front porch duration and the maximum vertical front porch duration.
>> + * Large and frequent changes in vertical front porch duration may produce
>> + * observable flickering for such panels.
>> + *
>> + * Userspace control for variable refresh rate is supported via properties
>> + * on the &drm_connector and &drm_crtc objects.
>> + *
>> + * "vrr_capable":
>> + *	Optional &drm_connector boolean property that drivers should attach
>> + *	with drm_connector_attach_vrr_capable_property() on connectors that
>> + *	could support variable refresh rates. Drivers should update the
>> + *	property value by calling drm_connector_set_vrr_capable_property().
>> + *
>> + *	Absence of the property should indicate absence of support.
>> + *
>> + * "vrr_enabled":
>> + *	Default &drm_crtc boolean property that notifies the driver that the
>> + *	content on the CRTC is suitable for variable refresh rate presentation.
>> + *	The driver will take this property as a hint to enable variable
>> + *	refresh rate support if the receiver supports it, ie. if the
>> + *	"vrr_capable" property is true on the &drm_connector object. The
>> + *	vertical front porch duration will be extended until page-flip or
>> + *	timeout when enabled.
>> + *
>> + *	The minimum vertical front porch duration is defined as the vertical
>> + *	front porch duration for the current mode.
>> + *
>> + *	The maximum vertical front porch duration is greater than or equal to
>> + *	the minimum vertical front porch duration. The duration is derived
>> + *	from the minimum supported variable refresh rate for the connector.
>> + *
>> + *	The driver may place further restrictions within these minimum
>> + *	and maximum bounds.
>> + *
>> + *	The semantics for the vertical blank timestamp differ when
>> + *	variable refresh rate is active. The vertical blank timestamp
>> + *	is defined to be an estimate using the current mode's fixed
>> + *	refresh rate timings. The semantics for the page-flip event
>> + *	timestamp remain the same.
>> + */
>> +
>>   /**
>>    * drm_connector_attach_vrr_capable_property - creates the
>>    * vrr_capable property
>>

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v7 3/5] drm: Document variable refresh properties
       [not found]           ` <58956653-ab01-55c8-abad-a6b8e270acd1-5C7GfCeVMHo@public.gmane.org>
@ 2018-11-26 21:49             ` Wentland, Harry
       [not found]               ` <a3cc6477-37bc-40c5-8042-997a64d166e5-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Wentland, Harry @ 2018-11-26 21:49 UTC (permalink / raw)
  To: Kazlauskas, Nicholas, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Manasi Navare, michel-otUistvHUpPR7s880joybQ, Pekka Paalanen,
	Ville Syrjälä

On 2018-11-12 12:05 p.m., Kazlauskas, Nicholas wrote:
> On 11/12/18 11:12 AM, Wentland, Harry wrote:
>> On 2018-11-08 9:43 a.m., Nicholas Kazlauskas wrote:
>>> These include the drm_connector 'vrr_capable' and the drm_crtc
>>> 'vrr_enabled' properties.
>>>
>>> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
>>> Cc: Harry Wentland <harry.wentland@amd.com>
>>> Cc: Manasi Navare <manasi.d.navare@intel.com>
>>> Cc: Pekka Paalanen <ppaalanen@gmail.com>
>>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> Cc: Michel Dänzer <michel@daenzer.net>
>>
>> Looks good. Whole series is
>> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>>
>> How are we with the userspace patches? We should probably hold off pushing the kernel patches until the userspace work is all reviewed.
>>
>> Harry
> 
> Thanks for the review.
> 
> The xf86-video-amdgpu patches have been reviewed and the mesa patches 
> have been partially reviewed.
> 

Alex, Michel,

how do we merge changes like this that provide a kernel API that goes together with userspace changes?

I imagine we'd want to get the kernel changes in first, and then merge the xf86-video-amdgpu and mesa changes. Please correct me if I'm wrong. Any objections to getting this merged via the usual amd-stg?

Thanks,
Harry


> Nicholas Kazlauskas
> 
>>
>>> ---
>>>   Documentation/gpu/drm-kms.rst   |  7 ++++
>>>   drivers/gpu/drm/drm_connector.c | 68 +++++++++++++++++++++++++++++++++
>>>   2 files changed, 75 insertions(+)
>>>
>>> diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.rst
>>> index 4b1501b4835b..8da2a178cf85 100644
>>> --- a/Documentation/gpu/drm-kms.rst
>>> +++ b/Documentation/gpu/drm-kms.rst
>>> @@ -575,6 +575,13 @@ Explicit Fencing Properties
>>>   .. kernel-doc:: drivers/gpu/drm/drm_atomic_uapi.c
>>>      :doc: explicit fencing properties
>>>   
>>> +
>>> +Variable Refresh Properties
>>> +---------------------------
>>> +
>>> +.. kernel-doc:: drivers/gpu/drm/drm_connector.c
>>> +   :doc: Variable refresh properties
>>> +
>>>   Existing KMS Properties
>>>   -----------------------
>>>   
>>> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
>>> index 49290060ab7b..0e4287461997 100644
>>> --- a/drivers/gpu/drm/drm_connector.c
>>> +++ b/drivers/gpu/drm/drm_connector.c
>>> @@ -1255,6 +1255,74 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
>>>   }
>>>   EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
>>>   
>>> +/**
>>> + * DOC: Variable refresh properties
>>> + *
>>> + * Variable refresh rate capable displays can dynamically adjust their
>>> + * refresh rate by extending the duration of their vertical front porch
>>> + * until page flip or timeout occurs. This can reduce or remove stuttering
>>> + * and latency in scenarios where the page flip does not align with the
>>> + * vblank interval.
>>> + *
>>> + * An example scenario would be an application flipping at a constant rate
>>> + * of 48Hz on a 60Hz display. The page flip will frequently miss the vblank
>>> + * interval and the same contents will be displayed twice. This can be
>>> + * observed as stuttering for content with motion.
>>> + *
>>> + * If variable refresh rate was active on a display that supported a
>>> + * variable refresh range from 35Hz to 60Hz no stuttering would be observable
>>> + * for the example scenario. The minimum supported variable refresh rate of
>>> + * 35Hz is below the page flip frequency and the vertical front porch can
>>> + * be extended until the page flip occurs. The vblank interval will be
>>> + * directly aligned to the page flip rate.
>>> + *
>>> + * Not all userspace content is suitable for use with variable refresh rate.
>>> + * Large and frequent changes in vertical front porch duration may worsen
>>> + * perceived stuttering for input sensitive applications.
>>> + *
>>> + * Panel brightness will also vary with vertical front porch duration. Some
>>> + * panels may have noticeable differences in brightness between the minimum
>>> + * vertical front porch duration and the maximum vertical front porch duration.
>>> + * Large and frequent changes in vertical front porch duration may produce
>>> + * observable flickering for such panels.
>>> + *
>>> + * Userspace control for variable refresh rate is supported via properties
>>> + * on the &drm_connector and &drm_crtc objects.
>>> + *
>>> + * "vrr_capable":
>>> + *	Optional &drm_connector boolean property that drivers should attach
>>> + *	with drm_connector_attach_vrr_capable_property() on connectors that
>>> + *	could support variable refresh rates. Drivers should update the
>>> + *	property value by calling drm_connector_set_vrr_capable_property().
>>> + *
>>> + *	Absence of the property should indicate absence of support.
>>> + *
>>> + * "vrr_enabled":
>>> + *	Default &drm_crtc boolean property that notifies the driver that the
>>> + *	content on the CRTC is suitable for variable refresh rate presentation.
>>> + *	The driver will take this property as a hint to enable variable
>>> + *	refresh rate support if the receiver supports it, ie. if the
>>> + *	"vrr_capable" property is true on the &drm_connector object. The
>>> + *	vertical front porch duration will be extended until page-flip or
>>> + *	timeout when enabled.
>>> + *
>>> + *	The minimum vertical front porch duration is defined as the vertical
>>> + *	front porch duration for the current mode.
>>> + *
>>> + *	The maximum vertical front porch duration is greater than or equal to
>>> + *	the minimum vertical front porch duration. The duration is derived
>>> + *	from the minimum supported variable refresh rate for the connector.
>>> + *
>>> + *	The driver may place further restrictions within these minimum
>>> + *	and maximum bounds.
>>> + *
>>> + *	The semantics for the vertical blank timestamp differ when
>>> + *	variable refresh rate is active. The vertical blank timestamp
>>> + *	is defined to be an estimate using the current mode's fixed
>>> + *	refresh rate timings. The semantics for the page-flip event
>>> + *	timestamp remain the same.
>>> + */
>>> +
>>>   /**
>>>    * drm_connector_attach_vrr_capable_property - creates the
>>>    * vrr_capable property
>>>
> 
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v7 3/5] drm: Document variable refresh properties
       [not found]               ` <a3cc6477-37bc-40c5-8042-997a64d166e5-5C7GfCeVMHo@public.gmane.org>
@ 2018-11-27  8:52                 ` Michel Dänzer
  0 siblings, 0 replies; 15+ messages in thread
From: Michel Dänzer @ 2018-11-27  8:52 UTC (permalink / raw)
  To: Wentland, Harry, Kazlauskas, Nicholas
  Cc: Manasi Navare, Ville Syrjälä,
	Pekka Paalanen, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 2018-11-26 10:49 p.m., Wentland, Harry wrote:
> On 2018-11-12 12:05 p.m., Kazlauskas, Nicholas wrote:
>> On 11/12/18 11:12 AM, Wentland, Harry wrote:
>>> On 2018-11-08 9:43 a.m., Nicholas Kazlauskas wrote:
>>>> These include the drm_connector 'vrr_capable' and the drm_crtc
>>>> 'vrr_enabled' properties.
>>>>
>>>> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
>>>> Cc: Harry Wentland <harry.wentland@amd.com>
>>>> Cc: Manasi Navare <manasi.d.navare@intel.com>
>>>> Cc: Pekka Paalanen <ppaalanen@gmail.com>
>>>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>> Cc: Michel Dänzer <michel@daenzer.net>
>>>
>>> Looks good. Whole series is
>>> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>>>
>>> How are we with the userspace patches? We should probably hold off pushing the kernel patches until the userspace work is all reviewed.
>>>
>>> Harry
>>
>> Thanks for the review.
>>
>> The xf86-video-amdgpu patches have been reviewed and the mesa patches 
>> have been partially reviewed.
> 
> Alex, Michel,
> 
> how do we merge changes like this that provide a kernel API that goes
> together with userspace changes?
> 
> I imagine we'd want to get the kernel changes in first, and then merge
> the xf86-video-amdgpu and mesa changes.

Yeah, that's how it's usually done.


> Any objections to getting this merged via the usual amd-stg?

None from me.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v7 3/5] drm: Document variable refresh properties
  2018-11-12 16:12     ` Wentland, Harry
       [not found]       ` <77ad01c4-4306-e150-c143-f52593b4656f-5C7GfCeVMHo@public.gmane.org>
@ 2018-11-27  9:22       ` Daniel Vetter
       [not found]         ` <20181127092258.GA4266-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
  1 sibling, 1 reply; 15+ messages in thread
From: Daniel Vetter @ 2018-11-27  9:22 UTC (permalink / raw)
  To: Wentland, Harry
  Cc: Manasi Navare, michel, amd-gfx, Kazlauskas, Nicholas, dri-devel

On Mon, Nov 12, 2018 at 04:12:10PM +0000, Wentland, Harry wrote:
> On 2018-11-08 9:43 a.m., Nicholas Kazlauskas wrote:
> > These include the drm_connector 'vrr_capable' and the drm_crtc
> > 'vrr_enabled' properties.
> > 
> > Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
> > Cc: Harry Wentland <harry.wentland@amd.com>
> > Cc: Manasi Navare <manasi.d.navare@intel.com>
> > Cc: Pekka Paalanen <ppaalanen@gmail.com>
> > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > Cc: Michel Dänzer <michel@daenzer.net>
> 
> Looks good. Whole series is
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
> 
> How are we with the userspace patches? We should probably hold off
> pushing the kernel patches until the userspace work is all reviewed.

Do some igts exist for this too? Especially for tricky pieces of uapi
having a non-vendor reference code somewhere would be good, aside from
testing and all that.
-Daniel

> 
> Harry
> 
> > ---
> >  Documentation/gpu/drm-kms.rst   |  7 ++++
> >  drivers/gpu/drm/drm_connector.c | 68 +++++++++++++++++++++++++++++++++
> >  2 files changed, 75 insertions(+)
> > 
> > diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.rst
> > index 4b1501b4835b..8da2a178cf85 100644
> > --- a/Documentation/gpu/drm-kms.rst
> > +++ b/Documentation/gpu/drm-kms.rst
> > @@ -575,6 +575,13 @@ Explicit Fencing Properties
> >  .. kernel-doc:: drivers/gpu/drm/drm_atomic_uapi.c
> >     :doc: explicit fencing properties
> >  
> > +
> > +Variable Refresh Properties
> > +---------------------------
> > +
> > +.. kernel-doc:: drivers/gpu/drm/drm_connector.c
> > +   :doc: Variable refresh properties
> > +
> >  Existing KMS Properties
> >  -----------------------
> >  
> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> > index 49290060ab7b..0e4287461997 100644
> > --- a/drivers/gpu/drm/drm_connector.c
> > +++ b/drivers/gpu/drm/drm_connector.c
> > @@ -1255,6 +1255,74 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
> >  }
> >  EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
> >  
> > +/**
> > + * DOC: Variable refresh properties
> > + *
> > + * Variable refresh rate capable displays can dynamically adjust their
> > + * refresh rate by extending the duration of their vertical front porch
> > + * until page flip or timeout occurs. This can reduce or remove stuttering
> > + * and latency in scenarios where the page flip does not align with the
> > + * vblank interval.
> > + *
> > + * An example scenario would be an application flipping at a constant rate
> > + * of 48Hz on a 60Hz display. The page flip will frequently miss the vblank
> > + * interval and the same contents will be displayed twice. This can be
> > + * observed as stuttering for content with motion.
> > + *
> > + * If variable refresh rate was active on a display that supported a
> > + * variable refresh range from 35Hz to 60Hz no stuttering would be observable
> > + * for the example scenario. The minimum supported variable refresh rate of
> > + * 35Hz is below the page flip frequency and the vertical front porch can
> > + * be extended until the page flip occurs. The vblank interval will be
> > + * directly aligned to the page flip rate.
> > + *
> > + * Not all userspace content is suitable for use with variable refresh rate.
> > + * Large and frequent changes in vertical front porch duration may worsen
> > + * perceived stuttering for input sensitive applications.
> > + *
> > + * Panel brightness will also vary with vertical front porch duration. Some
> > + * panels may have noticeable differences in brightness between the minimum
> > + * vertical front porch duration and the maximum vertical front porch duration.
> > + * Large and frequent changes in vertical front porch duration may produce
> > + * observable flickering for such panels.
> > + *
> > + * Userspace control for variable refresh rate is supported via properties
> > + * on the &drm_connector and &drm_crtc objects.
> > + *
> > + * "vrr_capable":
> > + *	Optional &drm_connector boolean property that drivers should attach
> > + *	with drm_connector_attach_vrr_capable_property() on connectors that
> > + *	could support variable refresh rates. Drivers should update the
> > + *	property value by calling drm_connector_set_vrr_capable_property().
> > + *
> > + *	Absence of the property should indicate absence of support.
> > + *
> > + * "vrr_enabled":
> > + *	Default &drm_crtc boolean property that notifies the driver that the
> > + *	content on the CRTC is suitable for variable refresh rate presentation.
> > + *	The driver will take this property as a hint to enable variable
> > + *	refresh rate support if the receiver supports it, ie. if the
> > + *	"vrr_capable" property is true on the &drm_connector object. The
> > + *	vertical front porch duration will be extended until page-flip or
> > + *	timeout when enabled.
> > + *
> > + *	The minimum vertical front porch duration is defined as the vertical
> > + *	front porch duration for the current mode.
> > + *
> > + *	The maximum vertical front porch duration is greater than or equal to
> > + *	the minimum vertical front porch duration. The duration is derived
> > + *	from the minimum supported variable refresh rate for the connector.
> > + *
> > + *	The driver may place further restrictions within these minimum
> > + *	and maximum bounds.
> > + *
> > + *	The semantics for the vertical blank timestamp differ when
> > + *	variable refresh rate is active. The vertical blank timestamp
> > + *	is defined to be an estimate using the current mode's fixed
> > + *	refresh rate timings. The semantics for the page-flip event
> > + *	timestamp remain the same.
> > + */
> > +
> >  /**
> >   * drm_connector_attach_vrr_capable_property - creates the
> >   * vrr_capable property
> > 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v7 3/5] drm: Document variable refresh properties
       [not found]         ` <20181127092258.GA4266-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
@ 2018-11-27 14:43           ` Wentland, Harry
  0 siblings, 0 replies; 15+ messages in thread
From: Wentland, Harry @ 2018-11-27 14:43 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Manasi Navare, michel-otUistvHUpPR7s880joybQ,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Kazlauskas, Nicholas,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 2018-11-27 4:22 a.m., Daniel Vetter wrote:
> On Mon, Nov 12, 2018 at 04:12:10PM +0000, Wentland, Harry wrote:
>> On 2018-11-08 9:43 a.m., Nicholas Kazlauskas wrote:
>>> These include the drm_connector 'vrr_capable' and the drm_crtc
>>> 'vrr_enabled' properties.
>>>
>>> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
>>> Cc: Harry Wentland <harry.wentland@amd.com>
>>> Cc: Manasi Navare <manasi.d.navare@intel.com>
>>> Cc: Pekka Paalanen <ppaalanen@gmail.com>
>>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> Cc: Michel Dänzer <michel@daenzer.net>
>>
>> Looks good. Whole series is
>> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>>
>> How are we with the userspace patches? We should probably hold off
>> pushing the kernel patches until the userspace work is all reviewed.
> 
> Do some igts exist for this too? Especially for tricky pieces of uapi
> having a non-vendor reference code somewhere would be good, aside from
> testing and all that.

Not yet, unfortunately, although it's on our list of things to do.

Harry

> -Daniel
> 
>>
>> Harry
>>
>>> ---
>>>  Documentation/gpu/drm-kms.rst   |  7 ++++
>>>  drivers/gpu/drm/drm_connector.c | 68 +++++++++++++++++++++++++++++++++
>>>  2 files changed, 75 insertions(+)
>>>
>>> diff --git a/Documentation/gpu/drm-kms.rst b/Documentation/gpu/drm-kms.rst
>>> index 4b1501b4835b..8da2a178cf85 100644
>>> --- a/Documentation/gpu/drm-kms.rst
>>> +++ b/Documentation/gpu/drm-kms.rst
>>> @@ -575,6 +575,13 @@ Explicit Fencing Properties
>>>  .. kernel-doc:: drivers/gpu/drm/drm_atomic_uapi.c
>>>     :doc: explicit fencing properties
>>>  
>>> +
>>> +Variable Refresh Properties
>>> +---------------------------
>>> +
>>> +.. kernel-doc:: drivers/gpu/drm/drm_connector.c
>>> +   :doc: Variable refresh properties
>>> +
>>>  Existing KMS Properties
>>>  -----------------------
>>>  
>>> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
>>> index 49290060ab7b..0e4287461997 100644
>>> --- a/drivers/gpu/drm/drm_connector.c
>>> +++ b/drivers/gpu/drm/drm_connector.c
>>> @@ -1255,6 +1255,74 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
>>>  }
>>>  EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
>>>  
>>> +/**
>>> + * DOC: Variable refresh properties
>>> + *
>>> + * Variable refresh rate capable displays can dynamically adjust their
>>> + * refresh rate by extending the duration of their vertical front porch
>>> + * until page flip or timeout occurs. This can reduce or remove stuttering
>>> + * and latency in scenarios where the page flip does not align with the
>>> + * vblank interval.
>>> + *
>>> + * An example scenario would be an application flipping at a constant rate
>>> + * of 48Hz on a 60Hz display. The page flip will frequently miss the vblank
>>> + * interval and the same contents will be displayed twice. This can be
>>> + * observed as stuttering for content with motion.
>>> + *
>>> + * If variable refresh rate was active on a display that supported a
>>> + * variable refresh range from 35Hz to 60Hz no stuttering would be observable
>>> + * for the example scenario. The minimum supported variable refresh rate of
>>> + * 35Hz is below the page flip frequency and the vertical front porch can
>>> + * be extended until the page flip occurs. The vblank interval will be
>>> + * directly aligned to the page flip rate.
>>> + *
>>> + * Not all userspace content is suitable for use with variable refresh rate.
>>> + * Large and frequent changes in vertical front porch duration may worsen
>>> + * perceived stuttering for input sensitive applications.
>>> + *
>>> + * Panel brightness will also vary with vertical front porch duration. Some
>>> + * panels may have noticeable differences in brightness between the minimum
>>> + * vertical front porch duration and the maximum vertical front porch duration.
>>> + * Large and frequent changes in vertical front porch duration may produce
>>> + * observable flickering for such panels.
>>> + *
>>> + * Userspace control for variable refresh rate is supported via properties
>>> + * on the &drm_connector and &drm_crtc objects.
>>> + *
>>> + * "vrr_capable":
>>> + *	Optional &drm_connector boolean property that drivers should attach
>>> + *	with drm_connector_attach_vrr_capable_property() on connectors that
>>> + *	could support variable refresh rates. Drivers should update the
>>> + *	property value by calling drm_connector_set_vrr_capable_property().
>>> + *
>>> + *	Absence of the property should indicate absence of support.
>>> + *
>>> + * "vrr_enabled":
>>> + *	Default &drm_crtc boolean property that notifies the driver that the
>>> + *	content on the CRTC is suitable for variable refresh rate presentation.
>>> + *	The driver will take this property as a hint to enable variable
>>> + *	refresh rate support if the receiver supports it, ie. if the
>>> + *	"vrr_capable" property is true on the &drm_connector object. The
>>> + *	vertical front porch duration will be extended until page-flip or
>>> + *	timeout when enabled.
>>> + *
>>> + *	The minimum vertical front porch duration is defined as the vertical
>>> + *	front porch duration for the current mode.
>>> + *
>>> + *	The maximum vertical front porch duration is greater than or equal to
>>> + *	the minimum vertical front porch duration. The duration is derived
>>> + *	from the minimum supported variable refresh rate for the connector.
>>> + *
>>> + *	The driver may place further restrictions within these minimum
>>> + *	and maximum bounds.
>>> + *
>>> + *	The semantics for the vertical blank timestamp differ when
>>> + *	variable refresh rate is active. The vertical blank timestamp
>>> + *	is defined to be an estimate using the current mode's fixed
>>> + *	refresh rate timings. The semantics for the page-flip event
>>> + *	timestamp remain the same.
>>> + */
>>> +
>>>  /**
>>>   * drm_connector_attach_vrr_capable_property - creates the
>>>   * vrr_capable property
>>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v7 2/5] drm: Add vrr_enabled property to drm CRTC
       [not found]     ` <20181108144353.31363-3-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
@ 2019-01-30 10:42       ` Daniel Vetter
       [not found]         ` <CAKMK7uHjOvivvK1_5yFV3miR=xQx7NHta11_etBSkGfr+Aor-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Daniel Vetter @ 2019-01-30 10:42 UTC (permalink / raw)
  To: Nicholas Kazlauskas
  Cc: Manasi Navare, Michel Dänzer, amd-gfx list, dri-devel

On Thu, Nov 8, 2018 at 3:44 PM Nicholas Kazlauskas
<nicholas.kazlauskas@amd.com> wrote:
>
> This patch introduces the 'vrr_enabled' CRTC property to allow
> dynamic control over variable refresh rate support for a CRTC.
>
> This property should be treated like a content hint to the driver -
> if the hardware or driver is not capable of driving variable refresh
> timings then this is not considered an error.
>
> Capability for variable refresh rate support should be determined
> by querying the vrr_capable drm connector property.
>
> It is worth noting that while the property is intended for atomic use
> it isn't filtered from legacy userspace queries. This allows for Xorg
> userspace drivers to implement support.
>
> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
> Cc: Manasi Navare <manasi.d.navare@intel.com>
> ---
>  drivers/gpu/drm/drm_atomic_uapi.c | 4 ++++
>  drivers/gpu/drm/drm_crtc.c        | 2 ++
>  drivers/gpu/drm/drm_mode_config.c | 6 ++++++
>  include/drm/drm_crtc.h            | 9 +++++++++
>  include/drm/drm_mode_config.h     | 5 +++++
>  5 files changed, 26 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index d5b7f315098c..eec396a57b88 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -433,6 +433,8 @@ static 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_vrr_enabled) {
> +               state->vrr_enabled = val;
>         } else if (property == config->degamma_lut_property) {
>                 ret = drm_atomic_replace_property_blob_from_id(dev,
>                                         &state->degamma_lut,
> @@ -491,6 +493,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_vrr_enabled)
> +               *val = state->vrr_enabled;
>         else if (property == config->degamma_lut_property)
>                 *val = (state->degamma_lut) ? state->degamma_lut->base.id : 0;
>         else if (property == config->ctm_property)
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 268a182ae189..6f8ddfcfaba5 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -340,6 +340,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_vrr_enabled, 0);
>         }
>
>         return 0;
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index ee80788f2c40..5670c67f28d4 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -310,6 +310,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,
> +                       "VRR_ENABLED");

VRR_ENABLED doesn't match vrr_enabled in the docs. But the connector
one seems to indeed be lowercase. And casing matters for properties

Can you pls figure out who's right here and fix this confusion up?

Thanks, Daniel

> +       if (!prop)
> +               return -ENOMEM;
> +       dev->mode_config.prop_vrr_enabled = prop;
> +
>         prop = drm_property_create(dev,
>                         DRM_MODE_PROP_BLOB,
>                         "DEGAMMA_LUT", 0);
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index b21437bc95bf..39c3900aab3c 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -290,6 +290,15 @@ struct drm_crtc_state {
>          */
>         u32 pageflip_flags;
>
> +       /**
> +        * @vrr_enabled:
> +        *
> +        * Indicates if variable refresh rate should be enabled for the CRTC.
> +        * Support for the requested vrr state will depend on driver and
> +        * hardware capabiltiy - lacking support is not treated as failure.
> +        */
> +       bool vrr_enabled;
> +
>         /**
>          * @event:
>          *
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index 928e4172a0bb..49f2fcfdb5fc 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -639,6 +639,11 @@ struct drm_mode_config {
>          * connectors must be of and active must be set to disabled, too.
>          */
>         struct drm_property *prop_mode_id;
> +       /**
> +        * @prop_vrr_enabled: Default atomic CRTC property to indicate
> +        * whether variable refresh rate should be enabled on the CRTC.
> +        */
> +       struct drm_property *prop_vrr_enabled;
>
>         /**
>          * @dvi_i_subconnector_property: Optional DVI-I property to
> --
> 2.19.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel



-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v7 2/5] drm: Add vrr_enabled property to drm CRTC
       [not found]         ` <CAKMK7uHjOvivvK1_5yFV3miR=xQx7NHta11_etBSkGfr+Aor-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2019-01-30 11:02           ` Daniel Vetter
       [not found]             ` <CAKMK7uFcZWMbs98H3ks6yYMmjM7TVtaW4B4TVXMX8wSJMZbvVA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Daniel Vetter @ 2019-01-30 11:02 UTC (permalink / raw)
  To: Nicholas Kazlauskas
  Cc: Manasi Navare, Michel Dänzer, amd-gfx list, dri-devel

On Wed, Jan 30, 2019 at 11:42 AM Daniel Vetter <daniel@ffwll.ch> wrote:
>
> On Thu, Nov 8, 2018 at 3:44 PM Nicholas Kazlauskas
> <nicholas.kazlauskas@amd.com> wrote:
> >
> > This patch introduces the 'vrr_enabled' CRTC property to allow
> > dynamic control over variable refresh rate support for a CRTC.
> >
> > This property should be treated like a content hint to the driver -
> > if the hardware or driver is not capable of driving variable refresh
> > timings then this is not considered an error.
> >
> > Capability for variable refresh rate support should be determined
> > by querying the vrr_capable drm connector property.
> >
> > It is worth noting that while the property is intended for atomic use
> > it isn't filtered from legacy userspace queries. This allows for Xorg
> > userspace drivers to implement support.
> >
> > Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
> > Reviewed-by: Harry Wentland <harry.wentland@amd.com>
> > Cc: Manasi Navare <manasi.d.navare@intel.com>
> > ---
> >  drivers/gpu/drm/drm_atomic_uapi.c | 4 ++++
> >  drivers/gpu/drm/drm_crtc.c        | 2 ++
> >  drivers/gpu/drm/drm_mode_config.c | 6 ++++++
> >  include/drm/drm_crtc.h            | 9 +++++++++
> >  include/drm/drm_mode_config.h     | 5 +++++
> >  5 files changed, 26 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> > index d5b7f315098c..eec396a57b88 100644
> > --- a/drivers/gpu/drm/drm_atomic_uapi.c
> > +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> > @@ -433,6 +433,8 @@ static 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_vrr_enabled) {
> > +               state->vrr_enabled = val;
> >         } else if (property == config->degamma_lut_property) {
> >                 ret = drm_atomic_replace_property_blob_from_id(dev,
> >                                         &state->degamma_lut,
> > @@ -491,6 +493,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_vrr_enabled)
> > +               *val = state->vrr_enabled;
> >         else if (property == config->degamma_lut_property)
> >                 *val = (state->degamma_lut) ? state->degamma_lut->base.id : 0;
> >         else if (property == config->ctm_property)
> > diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> > index 268a182ae189..6f8ddfcfaba5 100644
> > --- a/drivers/gpu/drm/drm_crtc.c
> > +++ b/drivers/gpu/drm/drm_crtc.c
> > @@ -340,6 +340,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_vrr_enabled, 0);
> >         }
> >
> >         return 0;
> > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > index ee80788f2c40..5670c67f28d4 100644
> > --- a/drivers/gpu/drm/drm_mode_config.c
> > +++ b/drivers/gpu/drm/drm_mode_config.c
> > @@ -310,6 +310,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,
> > +                       "VRR_ENABLED");
>
> VRR_ENABLED doesn't match vrr_enabled in the docs. But the connector
> one seems to indeed be lowercase. And casing matters for properties
>
> Can you pls figure out who's right here and fix this confusion up?

I checked the igt quickly, patch is typed, will send out today or so.
-Daniel

>
> Thanks, Daniel
>
> > +       if (!prop)
> > +               return -ENOMEM;
> > +       dev->mode_config.prop_vrr_enabled = prop;
> > +
> >         prop = drm_property_create(dev,
> >                         DRM_MODE_PROP_BLOB,
> >                         "DEGAMMA_LUT", 0);
> > diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> > index b21437bc95bf..39c3900aab3c 100644
> > --- a/include/drm/drm_crtc.h
> > +++ b/include/drm/drm_crtc.h
> > @@ -290,6 +290,15 @@ struct drm_crtc_state {
> >          */
> >         u32 pageflip_flags;
> >
> > +       /**
> > +        * @vrr_enabled:
> > +        *
> > +        * Indicates if variable refresh rate should be enabled for the CRTC.
> > +        * Support for the requested vrr state will depend on driver and
> > +        * hardware capabiltiy - lacking support is not treated as failure.
> > +        */
> > +       bool vrr_enabled;
> > +
> >         /**
> >          * @event:
> >          *
> > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > index 928e4172a0bb..49f2fcfdb5fc 100644
> > --- a/include/drm/drm_mode_config.h
> > +++ b/include/drm/drm_mode_config.h
> > @@ -639,6 +639,11 @@ struct drm_mode_config {
> >          * connectors must be of and active must be set to disabled, too.
> >          */
> >         struct drm_property *prop_mode_id;
> > +       /**
> > +        * @prop_vrr_enabled: Default atomic CRTC property to indicate
> > +        * whether variable refresh rate should be enabled on the CRTC.
> > +        */
> > +       struct drm_property *prop_vrr_enabled;
> >
> >         /**
> >          * @dvi_i_subconnector_property: Optional DVI-I property to
> > --
> > 2.19.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch



-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v7 2/5] drm: Add vrr_enabled property to drm CRTC
       [not found]             ` <CAKMK7uFcZWMbs98H3ks6yYMmjM7TVtaW4B4TVXMX8wSJMZbvVA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2019-01-30 13:37               ` Kazlauskas, Nicholas
  0 siblings, 0 replies; 15+ messages in thread
From: Kazlauskas, Nicholas @ 2019-01-30 13:37 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Manasi Navare, Michel Dänzer, amd-gfx list, dri-devel

On 1/30/19 6:02 AM, Daniel Vetter wrote:
> On Wed, Jan 30, 2019 at 11:42 AM Daniel Vetter <daniel@ffwll.ch> wrote:
>>
>> On Thu, Nov 8, 2018 at 3:44 PM Nicholas Kazlauskas
>> <nicholas.kazlauskas@amd.com> wrote:
>>>
>>> This patch introduces the 'vrr_enabled' CRTC property to allow
>>> dynamic control over variable refresh rate support for a CRTC.
>>>
>>> This property should be treated like a content hint to the driver -
>>> if the hardware or driver is not capable of driving variable refresh
>>> timings then this is not considered an error.
>>>
>>> Capability for variable refresh rate support should be determined
>>> by querying the vrr_capable drm connector property.
>>>
>>> It is worth noting that while the property is intended for atomic use
>>> it isn't filtered from legacy userspace queries. This allows for Xorg
>>> userspace drivers to implement support.
>>>
>>> Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
>>> Reviewed-by: Harry Wentland <harry.wentland@amd.com>
>>> Cc: Manasi Navare <manasi.d.navare@intel.com>
>>> ---
>>>   drivers/gpu/drm/drm_atomic_uapi.c | 4 ++++
>>>   drivers/gpu/drm/drm_crtc.c        | 2 ++
>>>   drivers/gpu/drm/drm_mode_config.c | 6 ++++++
>>>   include/drm/drm_crtc.h            | 9 +++++++++
>>>   include/drm/drm_mode_config.h     | 5 +++++
>>>   5 files changed, 26 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
>>> index d5b7f315098c..eec396a57b88 100644
>>> --- a/drivers/gpu/drm/drm_atomic_uapi.c
>>> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
>>> @@ -433,6 +433,8 @@ static 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_vrr_enabled) {
>>> +               state->vrr_enabled = val;
>>>          } else if (property == config->degamma_lut_property) {
>>>                  ret = drm_atomic_replace_property_blob_from_id(dev,
>>>                                          &state->degamma_lut,
>>> @@ -491,6 +493,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_vrr_enabled)
>>> +               *val = state->vrr_enabled;
>>>          else if (property == config->degamma_lut_property)
>>>                  *val = (state->degamma_lut) ? state->degamma_lut->base.id : 0;
>>>          else if (property == config->ctm_property)
>>> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
>>> index 268a182ae189..6f8ddfcfaba5 100644
>>> --- a/drivers/gpu/drm/drm_crtc.c
>>> +++ b/drivers/gpu/drm/drm_crtc.c
>>> @@ -340,6 +340,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_vrr_enabled, 0);
>>>          }
>>>
>>>          return 0;
>>> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
>>> index ee80788f2c40..5670c67f28d4 100644
>>> --- a/drivers/gpu/drm/drm_mode_config.c
>>> +++ b/drivers/gpu/drm/drm_mode_config.c
>>> @@ -310,6 +310,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,
>>> +                       "VRR_ENABLED");
>>
>> VRR_ENABLED doesn't match vrr_enabled in the docs. But the connector
>> one seems to indeed be lowercase. And casing matters for properties
>>
>> Can you pls figure out who's right here and fix this confusion up?
> 
> I checked the igt quickly, patch is typed, will send out today or so.
> -Daniel

Yeah, it should be "VRR_ENABLED" in the docs (like the other CRTC 
default properties, eg. explicit fencing "IN_FENCE_FD” and "OUT_FENCE_PTR".

It looks a bit weird next to "vrr_capable" but it makes sense in the 
usage context for CRTC vs connector at least.

This should be fixed in the docs and it sounds like you have a patch so 
I'll drop my R-B when it's up.

Thanks!

Nicholas Kazlauskas

> 
>>
>> Thanks, Daniel
>>
>>> +       if (!prop)
>>> +               return -ENOMEM;
>>> +       dev->mode_config.prop_vrr_enabled = prop;
>>> +
>>>          prop = drm_property_create(dev,
>>>                          DRM_MODE_PROP_BLOB,
>>>                          "DEGAMMA_LUT", 0);
>>> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
>>> index b21437bc95bf..39c3900aab3c 100644
>>> --- a/include/drm/drm_crtc.h
>>> +++ b/include/drm/drm_crtc.h
>>> @@ -290,6 +290,15 @@ struct drm_crtc_state {
>>>           */
>>>          u32 pageflip_flags;
>>>
>>> +       /**
>>> +        * @vrr_enabled:
>>> +        *
>>> +        * Indicates if variable refresh rate should be enabled for the CRTC.
>>> +        * Support for the requested vrr state will depend on driver and
>>> +        * hardware capabiltiy - lacking support is not treated as failure.
>>> +        */
>>> +       bool vrr_enabled;
>>> +
>>>          /**
>>>           * @event:
>>>           *
>>> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
>>> index 928e4172a0bb..49f2fcfdb5fc 100644
>>> --- a/include/drm/drm_mode_config.h
>>> +++ b/include/drm/drm_mode_config.h
>>> @@ -639,6 +639,11 @@ struct drm_mode_config {
>>>           * connectors must be of and active must be set to disabled, too.
>>>           */
>>>          struct drm_property *prop_mode_id;
>>> +       /**
>>> +        * @prop_vrr_enabled: Default atomic CRTC property to indicate
>>> +        * whether variable refresh rate should be enabled on the CRTC.
>>> +        */
>>> +       struct drm_property *prop_vrr_enabled;
>>>
>>>          /**
>>>           * @dvi_i_subconnector_property: Optional DVI-I property to
>>> --
>>> 2.19.1
>>>
>>> _______________________________________________
>>> dri-devel mailing list
>>> dri-devel@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
>>
>>
>> --
>> Daniel Vetter
>> Software Engineer, Intel Corporation
>> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
> 
> 
> 

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-01-30 13:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-08 14:43 [PATCH v7 0/5] A DRM API for adaptive sync and variable refresh rate support Nicholas Kazlauskas
2018-11-08 14:43 ` [PATCH v7 3/5] drm: Document variable refresh properties Nicholas Kazlauskas
     [not found]   ` <20181108144353.31363-4-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
2018-11-12 16:12     ` Wentland, Harry
     [not found]       ` <77ad01c4-4306-e150-c143-f52593b4656f-5C7GfCeVMHo@public.gmane.org>
2018-11-12 17:05         ` Kazlauskas, Nicholas
     [not found]           ` <58956653-ab01-55c8-abad-a6b8e270acd1-5C7GfCeVMHo@public.gmane.org>
2018-11-26 21:49             ` Wentland, Harry
     [not found]               ` <a3cc6477-37bc-40c5-8042-997a64d166e5-5C7GfCeVMHo@public.gmane.org>
2018-11-27  8:52                 ` Michel Dänzer
2018-11-27  9:22       ` Daniel Vetter
     [not found]         ` <20181127092258.GA4266-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-11-27 14:43           ` Wentland, Harry
     [not found] ` <20181108144353.31363-1-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
2018-11-08 14:43   ` [PATCH v7 1/5] drm: Add vrr_capable property to the drm connector Nicholas Kazlauskas
2018-11-08 14:43   ` [PATCH v7 2/5] drm: Add vrr_enabled property to drm CRTC Nicholas Kazlauskas
     [not found]     ` <20181108144353.31363-3-nicholas.kazlauskas-5C7GfCeVMHo@public.gmane.org>
2019-01-30 10:42       ` Daniel Vetter
     [not found]         ` <CAKMK7uHjOvivvK1_5yFV3miR=xQx7NHta11_etBSkGfr+Aor-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-01-30 11:02           ` Daniel Vetter
     [not found]             ` <CAKMK7uFcZWMbs98H3ks6yYMmjM7TVtaW4B4TVXMX8wSJMZbvVA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-01-30 13:37               ` Kazlauskas, Nicholas
2018-11-08 14:43   ` [PATCH v7 4/5] drm/amdgpu: Correct get_crtc_scanoutpos behavior when vpos >= vtotal Nicholas Kazlauskas
2018-11-08 14:43 ` [PATCH v7 5/5] drm/amdgpu: Set FreeSync state using drm VRR properties Nicholas Kazlauskas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.