]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/amd/display: Add back code to allow for rounding error
authorAnthony Koo <Anthony.Koo@amd.com>
Thu, 5 Apr 2018 19:20:15 +0000 (15:20 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 27 Aug 2018 16:10:53 +0000 (11:10 -0500)
Signed-off-by: Anthony Koo <Anthony.Koo@amd.com>
Reviewed-by: Aric Cyr <Aric.Cyr@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/modules/freesync/freesync.c

index 4887c888bbe7f77fffe39231bb4705af6590a3ad..abd5c9374eb32d57b04d2bdad1af0299d14d3247 100644 (file)
@@ -896,6 +896,17 @@ bool mod_freesync_is_valid_range(struct mod_freesync *mod_freesync,
        unsigned long long nominal_field_rate_in_uhz =
                        mod_freesync_calc_nominal_field_rate(stream);
 
+       /* Allow for some rounding error of actual video timing by taking ceil.
+        * For example, 144 Hz mode timing may actually be 143.xxx Hz when
+        * calculated from pixel rate and vertical/horizontal totals, but
+        * this should be allowed instead of blocking FreeSync.
+        */
+       nominal_field_rate_in_uhz = div_u64(nominal_field_rate_in_uhz, 1000000);
+       min_refresh_cap_in_uhz /= 1000000;
+       max_refresh_cap_in_uhz /= 1000000;
+       min_refresh_request_in_uhz /= 1000000;
+       max_refresh_request_in_uhz /= 1000000;
+
        // Check nominal is within range
        if (nominal_field_rate_in_uhz > max_refresh_cap_in_uhz ||
                nominal_field_rate_in_uhz < min_refresh_cap_in_uhz)
@@ -921,7 +932,7 @@ bool mod_freesync_is_valid_range(struct mod_freesync *mod_freesync,
 
        // For variable range, check for at least 10 Hz range
        if ((max_refresh_request_in_uhz != min_refresh_request_in_uhz) &&
-               (max_refresh_request_in_uhz - min_refresh_request_in_uhz < 10000000))
+               (max_refresh_request_in_uhz - min_refresh_request_in_uhz < 10))
                return false;
 
        return true;