Skip to contentSkip to conversation

drm/dp: Add function to parse EDID descriptors for adaptive sync limits

PATCH Superseded Manasi Navare 5 participants 16 messages Jan 8, 2020 – Mar 2, 2020

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/dp: Add function to parse EDID descriptors for adaptive sync limits

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +51 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
 
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;
+
+	for (i = 0; i < 4; i++) {
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);
 #endif /* __DRM_EDID_H__ */
Signature · 6 lines
2.19.1

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

Ville, could you take a look at this patch?
I have tested this on the VRR monitor here and it does parse
the detailed monitor range correctly to expose the min and max vfreq. Also I got rid of storing the pixel clock in the info->adaptive_sync_limits struct since thats just themax dotclock and not related to adaptive sync limits really.

Harry, could you take a look at this patch as well? This can be used inside amdgpu in several ways, it will automatically populate the drm_display_info during get_edid_modes or this function can be called explicitly in amdgpu_dm_update_freesync_caps() so I would leave the usage of this to you and Nicholas depending on what works better in your driver.

Regards
Manasi

Quoted 154 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +51 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
 
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;
+
+	for (i = 0; i < 4; i++) {
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);
 #endif /* __DRM_EDID_H__ */
Signature · 1 line
2.19.1

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

#2 lore raw
In reply to Manasi Navare
Quoted 29 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +0 -0
index 99769d6c9f84..52781a0e708b 100644

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4889

Quoted 10 lines
drivers/gpu/drm/drm_edid.c +7 -0
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
 
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;

Needlessly wide scope for everything above.

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4900

Quoted 11 lines
drivers/gpu/drm/drm_edid.c +11 -0
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;

if (!version_greater(...))

	return;

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4902

Quoted 2 lines
drivers/gpu/drm/drm_edid.c +2 -0
+
+	for (i = 0; i < 4; i++) {

This should probably use for_each_detailed_block()

Quoted 101 lines
drivers/gpu/drm/drm_edid.c +31 -0
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);
 #endif /* __DRM_EDID_H__ */
Signature · 1 line
2.19.1
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
Quoted 33 lines · Ville Syrjälä
Quoted 32 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +0 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
 
Quoted 9 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4889

Quoted 7 lines
drivers/gpu/drm/drm_edid.c +7 -0
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;

Needlessly wide scope for everything above.

Okay will move inside the for_each loop ?

Quoted 14 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4900

Quoted 12 lines
drivers/gpu/drm/drm_edid.c +11 -0
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;

if (!version_greater(...))

Quoted 1 line
	return;

You mean simplify the condition or use define a function version_greater() to check this condition?

Quoted 6 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4902

Quoted 3 lines
drivers/gpu/drm/drm_edid.c +2 -0
+
+	for (i = 0; i < 4; i++) {

This should probably use for_each_detailed_block()

Ok yes will use for_each_detailed_block

Manasi

Quoted 87 lines
Quoted 87 lines
drivers/gpu/drm/drm_edid.c +31 -0
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 
Quoted 18 lines
Quoted 14 lines
include/drm/drm_connector.h +0 -0
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);
 #endif /* __DRM_EDID_H__ */
Signature · 1 line
2.19.1
Signature · 2 lines
Ville Syrjälä
Intel

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

#4 lore raw

Hi Ville,

So the two major changes you would like to see here are:

use version_greate(edid) function
and make use of :
drm_for_each_detailed_block() instead of the for loop. But this function does not parse the monitor range yet so you are suggesting modifying that dmr helper function as well?

Manasi

Quoted 182 lines · Manasi Navare
Quoted 33 lines · Ville Syrjälä
Quoted 32 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +0 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
 
Quoted 9 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4889

Quoted 7 lines
drivers/gpu/drm/drm_edid.c +7 -0
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;

Needlessly wide scope for everything above.

Okay will move inside the for_each loop ?

Quoted 14 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4900

Quoted 12 lines
drivers/gpu/drm/drm_edid.c +11 -0
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;

if (!version_greater(...))

Quoted 1 line
	return;

You mean simplify the condition or use define a function version_greater() to check this condition?

Quoted 6 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4902

Quoted 3 lines
drivers/gpu/drm/drm_edid.c +2 -0
+
+	for (i = 0; i < 4; i++) {

This should probably use for_each_detailed_block()

Ok yes will use for_each_detailed_block

Manasi

Quoted 87 lines
Quoted 87 lines
drivers/gpu/drm/drm_edid.c +31 -0
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 
Quoted 18 lines
Quoted 14 lines
include/drm/drm_connector.h +0 -0
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);
 #endif /* __DRM_EDID_H__ */
Signature · 1 line
2.19.1
Signature · 2 lines
Ville Syrjälä
Intel
Quoted 4 lines

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

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

#5 lore raw
Quoted 9 lines · Manasi Navare

Hi Ville,

So the two major changes you would like to see here are:

use version_greate(edid) function
and make use of :
drm_for_each_detailed_block() instead of the for loop. But this function does not parse the monitor range yet so you are suggesting modifying that dmr helper function as well?

That functions is just the thing that iterates the descriptors, so can't figure out what you're asking.

Quoted 190 lines

Manasi

Quoted 186 lines · Manasi Navare
Quoted 33 lines · Ville Syrjälä
Quoted 32 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +0 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
 
Quoted 9 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4889

Quoted 7 lines
drivers/gpu/drm/drm_edid.c +7 -0
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;

Needlessly wide scope for everything above.

Okay will move inside the for_each loop ?

Quoted 14 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4900

Quoted 12 lines
drivers/gpu/drm/drm_edid.c +11 -0
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;

if (!version_greater(...))

Quoted 1 line
	return;

You mean simplify the condition or use define a function version_greater() to check this condition?

Quoted 6 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4902

Quoted 3 lines
drivers/gpu/drm/drm_edid.c +2 -0
+
+	for (i = 0; i < 4; i++) {

This should probably use for_each_detailed_block()

Ok yes will use for_each_detailed_block

Manasi

Quoted 87 lines
Quoted 87 lines
drivers/gpu/drm/drm_edid.c +31 -0
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 
Quoted 18 lines
Quoted 14 lines
include/drm/drm_connector.h +0 -0
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);
 #endif /* __DRM_EDID_H__ */
Signature · 1 line
2.19.1
Signature · 2 lines
Ville Syrjälä
Intel

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

Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw
Quoted 5 lines · Ville Syrjälä
Quoted 4 lines · Manasi Navare

Hi Ville,

So the two major changes you would like to see here are:

Quoted 8 lines
Quoted 5 lines

use version_greate(edid) function
and make use of :
drm_for_each_detailed_block() instead of the for loop. But this function does not parse the monitor range yet so you are suggesting modifying that dmr helper function as well?

That functions is just the thing that iterates the descriptors, so can't figure out what you're asking.

My question was on your review comment below where you asked me to use for_each_detailed_block(), were you referring to using the existing drm_for_each_detailed_block or just defining a new iterator for looping through 4 detailed blocks to get the monitor range?

Manasi

Quoted 187 lines
Quoted 187 lines

Manasi

Quoted 182 lines · Manasi Navare
Quoted 33 lines · Ville Syrjälä
Quoted 32 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +0 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
 
Quoted 9 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4889

Quoted 7 lines
drivers/gpu/drm/drm_edid.c +7 -0
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;

Needlessly wide scope for everything above.

Okay will move inside the for_each loop ?

Quoted 14 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4900

Quoted 12 lines
drivers/gpu/drm/drm_edid.c +11 -0
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;

if (!version_greater(...))

Quoted 1 line
	return;

You mean simplify the condition or use define a function version_greater() to check this condition?

Quoted 6 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4902

Quoted 3 lines
drivers/gpu/drm/drm_edid.c +2 -0
+
+	for (i = 0; i < 4; i++) {

This should probably use for_each_detailed_block()

Ok yes will use for_each_detailed_block

Manasi

Quoted 105 lines
Quoted 101 lines
drivers/gpu/drm/drm_edid.c +31 -0
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);
 #endif /* __DRM_EDID_H__ */
Signature · 1 line
2.19.1
Signature · 2 lines
Ville Syrjälä
Intel
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

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

Signature · 2 lines
Ville Syrjälä
Intel

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

#7 lore raw
In reply to Ville Syrjälä
Quoted 33 lines · Ville Syrjälä
Quoted 32 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +0 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
 
Quoted 9 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4889

Quoted 7 lines
drivers/gpu/drm/drm_edid.c +7 -0
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;

Needlessly wide scope for everything above.

Ok will add this inside the for loop

Quoted 14 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4900

Quoted 12 lines
drivers/gpu/drm/drm_edid.c +11 -0
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;

if (!version_greater(...))

Quoted 6 lines
	return;

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4902

Quoted 2 lines
drivers/gpu/drm/drm_edid.c +2 -0
+
+	for (i = 0; i < 4; i++) {

This should probably use for_each_detailed_block()

Can you elaborate, I dont understand what you mean by using for_each_detailed_block()

Manasi

Quoted 88 lines
Quoted 88 lines
drivers/gpu/drm/drm_edid.c +31 -0
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 
Quoted 18 lines
Quoted 14 lines
include/drm/drm_connector.h +0 -0
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);
 #endif /* __DRM_EDID_H__ */
Signature · 1 line
2.19.1
Signature · 2 lines
Ville Syrjälä
Intel

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

#8 lore raw
Quoted 62 lines · Manasi Navare
Quoted 33 lines · Ville Syrjälä
Quoted 32 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +0 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
 
Quoted 9 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4889

Quoted 7 lines
drivers/gpu/drm/drm_edid.c +7 -0
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;

Needlessly wide scope for everything above.

Ok will add this inside the for loop

Quoted 16 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4900

Quoted 12 lines
drivers/gpu/drm/drm_edid.c +11 -0
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;

if (!version_greater(...))

	return;
Quoted 8 lines
Quoted 4 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4902

Quoted 2 lines
drivers/gpu/drm/drm_edid.c +2 -0
+
+	for (i = 0; i < 4; i++) {

This should probably use for_each_detailed_block()

Can you elaborate, I dont understand what you mean by using for_each_detailed_block()

Manasi

Does that mean:
I need to define drm_edid_get_vrr_range() where i call drm_for_each_detailed_block((u8 * )edid, get_vrr_range, &vrr_min, &vrr_max) but i need to access range = &data->data.range; where
data = &timing->data.other_data; inside get_vrr_range() how can I access range?

Manasi

Quoted 107 lines
Quoted 89 lines
Quoted 89 lines
drivers/gpu/drm/drm_edid.c +31 -0
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 
Quoted 18 lines
Quoted 14 lines
include/drm/drm_connector.h +0 -0
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);
 #endif /* __DRM_EDID_H__ */
Signature · 1 line
2.19.1
Signature · 2 lines
Ville Syrjälä
Intel
Quoted 4 lines

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

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

#9 lore raw
Quoted 16 lines · Manasi Navare
Quoted 15 lines · Manasi Navare
Quoted 14 lines · Ville Syrjälä
Quoted 13 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>

Hi Manasi, sorry for the delayed response on this one!

Few comments inline below:

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
---
  drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
  include/drm/drm_connector.h | 22 ++++++++++++++++
  include/drm/drm_edid.h      |  2 ++
  3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +0 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
  	}
  }
 
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4884

Quoted 2 lines
drivers/gpu/drm/drm_edid.c +2 -0
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)

Agree with other feedback here on making this static. We can move over amdgpu to just check the DRM reported caps after.

Quoted 11 lines
Quoted 11 lines
Quoted 7 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4889

Quoted 5 lines
drivers/gpu/drm/drm_edid.c +5 -0
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;

Needlessly wide scope for everything above.

Ok will add this inside the for loop

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4897

Quoted 8 lines
drivers/gpu/drm/drm_edid.c +8 -0
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;

This probably doesn't need to be blocked here, this is just parsing the EDID.

Quoted 14 lines
Quoted 14 lines
Quoted 11 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4900

Quoted 3 lines
drivers/gpu/drm/drm_edid.c +3 -0
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;

if (!version_greater(...))

	return;

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4902

Quoted 2 lines
drivers/gpu/drm/drm_edid.c +2 -0
+
+	for (i = 0; i < 4; i++) {

This should probably use for_each_detailed_block()

Can you elaborate, I dont understand what you mean by using for_each_detailed_block()

Quoted 7 lines
Quoted 1 line

Manasi

Does that mean:
I need to define drm_edid_get_vrr_range() where i call drm_for_each_detailed_block((u8 * )edid, get_vrr_range, &vrr_min, &vrr_max) but i need to access range = &data->data.range; where
data = &timing->data.other_data; inside get_vrr_range() how can I access range?

Manasi

Wouldn't it look like:

drm_for_each_detailed_block((u8 *)edid, get_adaptive_sync_range, &info->adaptive_sync);

Or something along those lines?

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
drivers/gpu/drm/drm_edid.c +19 -0
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4929

Quoted 8 lines
drivers/gpu/drm/drm_edid.c +8 -0
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);

Can drop this EXPORT since this is all in drm_edid.c.

Quoted 60 lines
Quoted 60 lines
Quoted 60 lines
Quoted 60 lines
drivers/gpu/drm/drm_edid.c +4 -0
+
  /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
   * all of the values which would have been set from EDID
   */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
  	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
  	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
  }
 
  u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
  	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
  	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
  	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
  	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
  };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
  /*
   * This is a consolidated colorimetry list supported by HDMI and
   * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
  	 * @non_desktop: Non desktop display (HMD).
  	 */
  	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
  };
 
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

include/drm/drm_edid.h void drm_edid_get_monitor_name(struct edid *edid, char *name, · line 507

Quoted 11 lines
include/drm/drm_connector.h +0 -0
  int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
  struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
  					   int hsize, int vsize, int fresh,
  					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);

Can drop this one as well.

Regards,
Nicholas Kazlauskas

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
include/drm/drm_edid.h +0 -0
  #endif /* __DRM_EDID_H__ */
Signature · 1 line
2.19.1
Signature · 2 lines
Ville Syrjälä
Intel
Quoted 9 lines
Quoted 4 lines

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

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

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

#10 lore raw
Quoted 89 lines · Nicholas
Quoted 16 lines · Manasi Navare
Quoted 15 lines · Manasi Navare
Quoted 14 lines · Ville Syrjälä
Quoted 13 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>

Hi Manasi, sorry for the delayed response on this one!

Few comments inline below:

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4883

Quoted 9 lines
drivers/gpu/drm/drm_edid.c +2 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)

Agree with other feedback here on making this static. We can move over amdgpu to just check the DRM reported caps after.

Quoted 11 lines
Quoted 11 lines
Quoted 7 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4889

Quoted 5 lines
drivers/gpu/drm/drm_edid.c +5 -0
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;

Needlessly wide scope for everything above.

Ok will add this inside the for loop

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4897

Quoted 8 lines
drivers/gpu/drm/drm_edid.c +8 -0
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;

This probably doesn't need to be blocked here, this is just parsing the EDID.

Quoted 20 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4900

Quoted 3 lines
drivers/gpu/drm/drm_edid.c +3 -0
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;

if (!version_greater(...))

	return;
Quoted 8 lines
Quoted 4 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4901

Quoted 2 lines
drivers/gpu/drm/drm_edid.c +2 -0
+
+	for (i = 0; i < 4; i++) {

This should probably use for_each_detailed_block()

Can you elaborate, I dont understand what you mean by using for_each_detailed_block()

Manasi

Does that mean:
I need to define drm_edid_get_vrr_range() where i call drm_for_each_detailed_block((u8 * )edid, get_vrr_range, &vrr_min, &vrr_max) but i need to access range = &data->data.range; where
data = &timing->data.other_data; inside get_vrr_range() how can I access range?

Quoted 6 lines
Quoted 1 line

Manasi

Wouldn't it look like:

drm_for_each_detailed_block((u8 *)edid, get_adaptive_sync_range, &info->adaptive_sync);

Yes but am still not sure how to access timing, data and range from the passed argumnet of edid, once that is clear then yes I can just fill info->adaptive sync directly inside the function.

Manasi

Quoted 103 lines

Or something along those lines?

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
drivers/gpu/drm/drm_edid.c +18 -0
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
 
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4929

Quoted 8 lines
drivers/gpu/drm/drm_edid.c +8 -0
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);

Can drop this EXPORT since this is all in drm_edid.c.

Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
Quoted 56 lines
drivers/gpu/drm/drm_edid.c +4 -0
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +0 -0
index f0b03d401c27..b9a230aa3e69 100644
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

include/drm/drm_edid.h void drm_edid_get_monitor_name(struct edid *edid, char *name, · line 507

Quoted 8 lines
include/drm/drm_edid.h +2 -0
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);

Can drop this one as well.

Quoted 20 lines

Regards,
Nicholas Kazlauskas

Quoted 16 lines
Quoted 11 lines
Quoted 7 lines
Quoted 3 lines
include/drm/drm_edid.h +0 -0
 #endif /* __DRM_EDID_H__ */
Signature · 1 line
2.19.1
Signature · 2 lines
Ville Syrjälä
Intel

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

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

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

#11 lore raw
In reply to Manasi Navare
Quoted 69 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +37 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
 
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;
+
+	for (i = 0; i < 4; i++) {
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4929

Quoted 10 lines
drivers/gpu/drm/drm_edid.c +10 -0
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);

Why the export? Rather, why is this not static?

BR,
Jani.

Quoted 72 lines
drivers/gpu/drm/drm_edid.c +4 -0
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);
 #endif /* __DRM_EDID_H__ */
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw
Quoted 74 lines · Jani Nikula
Quoted 73 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +41 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
 
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;
+
+	for (i = 0; i < 4; i++) {
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
Quoted 9 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4929

Quoted 6 lines
drivers/gpu/drm/drm_edid.c +6 -0
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);

Why the export? Rather, why is this not static?

I could make it static but since the way AMDGPU code is written right now they would be calling this function explicitly to populate the vmin and vmax in their local structs but I can make it static and with some minor refactoring they should be able to use thsi infor directly from drm_display_info

Manasi

Quoted 63 lines

BR,
Jani.

Quoted 60 lines
drivers/gpu/drm/drm_edid.c +4 -0
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 
Quoted 15 lines
Quoted 12 lines
include/drm/drm_connector.h +0 -0
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);
 #endif /* __DRM_EDID_H__ */
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center

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

#13 lore raw

Fixing Nick's email.

Quoted 85 lines · Manasi Navare
Quoted 74 lines · Jani Nikula
Quoted 73 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +41 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
 
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;
+
+	for (i = 0; i < 4; i++) {
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
Quoted 9 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4929

Quoted 6 lines
drivers/gpu/drm/drm_edid.c +6 -0
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);

Why the export? Rather, why is this not static?

Quoted 5 lines

I could make it static but since the way AMDGPU code is written right now they would be calling this function explicitly to populate the vmin and vmax in their local structs but I can make it static and with some minor refactoring they should be able to use thsi infor directly from drm_display_info

Calling this through drm_add_edid_modes should be sufficient for us. We'll just need to move amdgpu_dm_update_freesync_caps to our get_modes function.

Dropping the export here seems to be the right thing to do.

Harry

Quoted 80 lines

Manasi

Quoted 63 lines

BR,
Jani.

Quoted 60 lines
drivers/gpu/drm/drm_edid.c +4 -0
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 
Quoted 15 lines
Quoted 12 lines
include/drm/drm_connector.h +0 -0
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);
 #endif /* __DRM_EDID_H__ */
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Quoted 5 lines

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

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

#14 lore raw
Quoted 16 lines · Harry Wentland

Fixing Nick's email.

Quoted 4 lines · Manasi Navare
Quoted 3 lines · Jani Nikula
Quoted 1 line · Manasi Navare

+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);

Quoted 8 lines
Quoted 2 lines

Why the export? Rather, why is this not static?

I could make it static but since the way AMDGPU code is written right now they would be calling this function explicitly to populate the vmin and vmax in their local structs but I can make it static and with some minor refactoring they should be able to use thsi infor directly from drm_display_info

Quoted 5 lines

Calling this through drm_add_edid_modes should be sufficient for us. We'll just need to move amdgpu_dm_update_freesync_caps to our get_modes function.

Dropping the export here seems to be the right thing to do.

Thanks; this should help unify the behaviour across drivers.

BR,
Jani.

Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#15 lore raw
In reply to Harry Wentland
Quoted 94 lines · Harry Wentland

Fixing Nick's email.

Quoted 85 lines · Manasi Navare
Quoted 74 lines · Jani Nikula
Quoted 73 lines · Manasi Navare

Adaptive Sync is a VESA feature so add a DRM core helper to parse the EDID's detailed descritors to obtain the adaptive sync monitor range. Store this info as part fo drm_display_info so it can be used across all drivers.
This part of the code is stripped out of amdgpu's function amdgpu_dm_update_freesync_caps() to make it generic and be used across all DRM drivers

v2:
* Change vmin and vmax to use u8 (Ville)
* Dont store pixel clock since that is just a max dotclock and not related to VRR mode (Manasi)

Cc Ville Syrjälä <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Clinton A Taylor <[email protected]>
Cc Nicholas Kazlauskas <[email protected]>
---
 drivers/gpu/drm/drm_edid.c  | 51 +++++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h | 22 ++++++++++++++++
 include/drm/drm_edid.h      |  2 ++
 3 files changed, 75 insertions(+)
drivers/gpu/drm/drm_edid.c +41 -0
index 99769d6c9f84..52781a0e708b 100644
@@ -4880,6 +4880,54 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
 	}
 }
 
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid)
+{
+	struct drm_display_info *info = &connector->display_info;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;
+	int i;
+
+	/*
+	 * Restrict Adaptive Sync only for dp and edp
+	 */
+	if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort &&
+	    connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return;
+
+	if (edid->version <= 1 && !(edid->version == 1 && edid->revision > 1))
+		return;
+
+	for (i = 0; i < 4; i++) {
+		timing  = &edid->detailed_timings[i];
+		data    = &timing->data.other_data;
+		range   = &data->data.range;
+		/*
+		 * Check if monitor has continuous frequency mode
+		 */
+		if (data->type != EDID_DETAIL_MONITOR_RANGE)
+			continue;
+		/*
+		 * Check for flag range limits only. If flag == 1 then
+		 * no additional timing information provided.
+		 * Default GTF, GTF Secondary curve and CVT are not
+		 * supported
+		 */
+		if (range->flags != 1)
+			continue;
+
+		info->adaptive_sync.min_vfreq = range->min_vfreq;
+		info->adaptive_sync.max_vfreq = range->max_vfreq;
+
+		DRM_DEBUG_KMS("Adaptive Sync refresh rate range is %d Hz - %d Hz\n",
Quoted 9 lines

drivers/gpu/drm/drm_edid.c static void drm_parse_cea_ext(struct drm_connector *connector, · line 4929

Quoted 6 lines
drivers/gpu/drm/drm_edid.c +6 -0
+			      info->adaptive_sync.min_vfreq,
+			      info->adaptive_sync.max_vfreq);
+		break;
+	}
+}
+EXPORT_SYMBOL(drm_get_adaptive_sync_limits);

Why the export? Rather, why is this not static?

Quoted 5 lines

I could make it static but since the way AMDGPU code is written right now they would be calling this function explicitly to populate the vmin and vmax in their local structs but I can make it static and with some minor refactoring they should be able to use thsi infor directly from drm_display_info

Quoted 3 lines

Calling this through drm_add_edid_modes should be sufficient for us. We'll just need to move amdgpu_dm_update_freesync_caps to our get_modes function.

Thanks Harry, Would you or Nick make these changes as follow up changes after this patch lands? Since it might be easier for you to figure out where to accomodate the changes in amdgpu.

Manasi

Quoted 90 lines

Dropping the export here seems to be the right thing to do.

Harry

Quoted 85 lines

Manasi

Quoted 63 lines

BR,
Jani.

Quoted 60 lines
drivers/gpu/drm/drm_edid.c +4 -0
+
 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
  * all of the values which would have been set from EDID
  */
@@ -4901,6 +4949,7 @@ drm_reset_display_info(struct drm_connector *connector)
 	memset(&info->hdmi, 0, sizeof(info->hdmi));
 
 	info->non_desktop = 0;
+	memset(&info->adaptive_sync, 0, sizeof(info->adaptive_sync));
 }
 
 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
@@ -4916,6 +4965,8 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 	info->non_desktop = !!(quirks & EDID_QUIRK_NON_DESKTOP);
 
+	drm_get_adaptive_sync_limits(connector, edid);
+
 	DRM_DEBUG_KMS("non_desktop set to %d\n", info->non_desktop);
 
 	if (edid->revision < 3)
include/drm/drm_connector.h +22 -0
index 221910948b37..77df404a2e01 100644
@@ -254,6 +254,23 @@ enum drm_panel_orientation {
 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
 };
 
+/**
+ * struct drm_adaptive_sync_info - Panel's Adaptive Sync capabilities for
+ * &drm_display_info
+ *
+ * This struct is used to store a Panel's Adaptive Sync capabilities
+ * as parsed from EDID's detailed monitor range descriptor block.
+ *
+ * @min_vfreq: This is the min supported refresh rate in Hz from
+ *             EDID's detailed monitor range.
+ * @max_vfreq: This is the max supported refresh rate in Hz from
+ *             EDID's detailed monitor range
+ */
+struct drm_adaptive_sync_info {
+	u8 min_vfreq;
+	u8 max_vfreq;
+};
+
 /*
  * This is a consolidated colorimetry list supported by HDMI and
  * DP protocol standard. The respective connectors will register
@@ -465,6 +482,11 @@ struct drm_display_info {
 	 * @non_desktop: Non desktop display (HMD).
 	 */
 	bool non_desktop;
+
+	/**
+	 * @adaptive_sync: Adaptive Sync capabilities of the DP/eDP sink
+	 */
+	struct drm_adaptive_sync_info adaptive_sync;
 };
 
Quoted 15 lines
Quoted 12 lines
include/drm/drm_connector.h +0 -0
 int drm_display_info_set_bus_formats(struct drm_display_info *info,
include/drm/drm_edid.h +2 -0
index f0b03d401c27..b9a230aa3e69 100644
@@ -503,4 +503,6 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name,
 struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 					   int hsize, int vsize, int fresh,
 					   bool rb);
+void drm_get_adaptive_sync_limits(struct drm_connector *connector,
+				  const struct edid *edid);
 #endif /* __DRM_EDID_H__ */
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center

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

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