[Why]
VRRmax=0 is a valid value and means that the upper bound is guared by
the selected video mode.

[How]
In this context, saved vrr max is the max possible refresh rate ever.
Try getting upper VRR bound from AMD vsdbif it exists or rely on the
limitations of BRR in VTEM info frames.

I found through testing, that TVs seem to reject VTEM when BRR is set
to over 1023 Hz. Use this as the last resort VRRmax. 1023 is the max
value for a 10-bit field as well.

v2:
- Update max BRR value to 1023

Signed-off-by: Tomasz Pakuła <[email protected]>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 23 +++++++++++++++----
 .../amd/display/modules/inc/mod_info_packet.h |  2 ++
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 6fb23d59fcc9..2200161da71b 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -13232,14 +13232,27 @@ static void monitor_range_from_vsdb(struct 
drm_display_info *display,
 }
 
 /**
- * Get VRR range from HDMI VRR info in EDID.
+ * Get VRR range from HDMI VRR info in EDID. If VRRmax == 0,
+ * try getting upper bound from AMD vsdb.
  *
  * @conn: drm_connector with HDMI VRR info
+ * @vsdb: AMD vsdb from CAE
  */
-static void monitor_range_from_hdmi(struct drm_display_info *display)
+static void monitor_range_from_hdmi(struct drm_display_info *display,
+                                   const struct amdgpu_hdmi_vsdb_info *vsdb)
 {
+       u16 vrr_max = display->hdmi.vrr_cap.vrr_max;
+
+       /* Try getting upper vrr bound from AMD vsdb */
+       if (vrr_max == 0)
+               vrr_max = vsdb->max_refresh_rate_hz;
+
+       /* Use max possible BRR value as a last resort */
+       if (vrr_max == 0)
+               vrr_max = VTEM_BRR_MAX;
+
        display->monitor_range.min_vfreq = display->hdmi.vrr_cap.vrr_min;
-       display->monitor_range.max_vfreq = display->hdmi.vrr_cap.vrr_max;
+       display->monitor_range.max_vfreq = vrr_max;
 }
 
 /*
@@ -13374,8 +13387,8 @@ void amdgpu_dm_update_freesync_caps(struct 
drm_connector *connector,
        /* DP -> HDMI PCON */
        } else if (pcon_allowed) {
                /* Prefer HDMI VRR */
-               if (hdmi_vrr.supported && hdmi_vrr.vrr_max > 0)
-                       monitor_range_from_hdmi(&connector->display_info);
+               if (hdmi_vrr.supported)
+                       monitor_range_from_hdmi(&connector->display_info, 
&vsdb_info);
                else if (vsdb_info.freesync_supported) {
                        amdgpu_dm_connector->vsdb_info = vsdb_info;
                        monitor_range_from_vsdb(&connector->display_info, 
&vsdb_info);
diff --git a/drivers/gpu/drm/amd/display/modules/inc/mod_info_packet.h 
b/drivers/gpu/drm/amd/display/modules/inc/mod_info_packet.h
index 5de8a6918e6a..306eb7355c25 100644
--- a/drivers/gpu/drm/amd/display/modules/inc/mod_info_packet.h
+++ b/drivers/gpu/drm/amd/display/modules/inc/mod_info_packet.h
@@ -33,6 +33,8 @@ struct dc_stream_state;
 struct dc_info_packet;
 struct mod_vrr_params;
 
+#define VTEM_BRR_MAX 1023
+
 void set_vsc_packet_colorimetry_data(
                const struct dc_stream_state *stream,
                struct dc_info_packet *info_packet,
-- 
2.52.0

Reply via email to