[mutter] output-kms: Change SYNC_TOLERANCE from 1% to 0.001Hz



commit b5169f256712ddd0d13e44111cef6534d2834592
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Wed Jun 15 18:17:23 2022 +0800

    output-kms: Change SYNC_TOLERANCE from 1% to 0.001Hz
    
    1% of 60Hz is 0.6Hz so it was losing the usual two decimal places
    precision you would expect as a minimum. Now we use three to be sure.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2465>

 src/backends/native/meta-output-kms.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/backends/native/meta-output-kms.c b/src/backends/native/meta-output-kms.c
index 108567cb1f..5e572e27b2 100644
--- a/src/backends/native/meta-output-kms.c
+++ b/src/backends/native/meta-output-kms.c
@@ -38,7 +38,7 @@
 #include "backends/native/meta-crtc-kms.h"
 #include "backends/native/meta-crtc-mode-kms.h"
 
-#define SYNC_TOLERANCE 0.01    /* 1 percent */
+#define SYNC_TOLERANCE_HZ 0.001
 
 struct _MetaOutputKms
 {
@@ -204,7 +204,7 @@ add_common_modes (MetaOutputInfo *output_info,
     }
 
   max_refresh_rate = MAX (max_refresh_rate, 60.0);
-  max_refresh_rate *= (1 + SYNC_TOLERANCE);
+  max_refresh_rate += SYNC_TOLERANCE_HZ;
 
   kms_device = meta_gpu_kms_get_kms_device (gpu_kms);
 
@@ -240,8 +240,8 @@ add_common_modes (MetaOutputInfo *output_info,
 
           if (drm_mode->hdisplay == crtc_mode_info->width &&
               drm_mode->vdisplay == crtc_mode_info->height &&
-              fabs (1 - (refresh_rate / crtc_mode_info->refresh_rate)) <
-              SYNC_TOLERANCE)
+              (fabs (refresh_rate - crtc_mode_info->refresh_rate) <
+               SYNC_TOLERANCE_HZ))
             {
               is_duplicate = TRUE;
               break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]