[mutter] crtc-mode-xrandr: Take RR_DoubleScan and RR_Interlace flags into account
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] crtc-mode-xrandr: Take RR_DoubleScan and RR_Interlace flags into account
- Date: Sun, 2 Jan 2022 21:39:00 +0000 (UTC)
commit 60d7cd82ba7dcaff2f7b45226fe0782a8dbf24e6
Author: Robert Mader <robert mader collabora com>
Date: Thu Dec 30 21:29:25 2021 +0100
crtc-mode-xrandr: Take RR_DoubleScan and RR_Interlace flags into account
Otherwise we often advertise wrongly calculated modes.
Original patch from Jonas Ã…dahl and the xrandr project.
Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/275
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2190>
src/backends/x11/meta-gpu-xrandr.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/src/backends/x11/meta-gpu-xrandr.c b/src/backends/x11/meta-gpu-xrandr.c
index bc3292d368..6c84be6ce8 100644
--- a/src/backends/x11/meta-gpu-xrandr.c
+++ b/src/backends/x11/meta-gpu-xrandr.c
@@ -86,6 +86,24 @@ get_xmode_name (XRRModeInfo *xmode)
return g_strdup_printf ("%dx%d", width, height);
}
+static float
+calculate_xrandr_refresh_rate (XRRModeInfo *xmode)
+{
+ float h_total;
+ float v_total;
+
+ h_total = (float) xmode->hTotal;
+ v_total = (float) xmode->vTotal;
+
+ if (xmode->modeFlags & RR_DoubleScan)
+ v_total *= 2.0;
+
+ if (xmode->modeFlags & RR_Interlace)
+ v_total /= 2.0;
+
+ return xmode->dotClock / (h_total * v_total);
+}
+
static gboolean
meta_gpu_xrandr_read_current (MetaGpu *gpu,
GError **error)
@@ -148,8 +166,7 @@ meta_gpu_xrandr_read_current (MetaGpu *gpu,
crtc_mode_info = meta_crtc_mode_info_new ();
crtc_mode_info->width = xmode->width;
crtc_mode_info->height = xmode->height;
- crtc_mode_info->refresh_rate = (xmode->dotClock /
- ((float)xmode->hTotal * xmode->vTotal));
+ crtc_mode_info->refresh_rate = calculate_xrandr_refresh_rate (xmode);
crtc_mode_info->flags = xmode->modeFlags;
crtc_mode_name = get_xmode_name (xmode);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]