~mmach/netext73/xorg-server

« back to all changes in this revision

Viewing changes to 993.patch

  • Committer: mmach
  • Date: 2022-12-14 09:34:30 UTC
  • Revision ID: netbit73@gmail.com-20221214093430-gn3afttx63yhs09u
21.1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From d3f13e2c3d04ab8b1f702222a82216c0f1ec8bb4 Mon Sep 17 00:00:00 2001
 
2
From: "Chia-Lin Kao (AceLan)" <acelan.kao@canonical.com>
 
3
Date: Tue, 8 Nov 2022 08:11:50 +0800
 
4
Subject: [PATCH] hw/xfree86: re-calculate the clock and refresh rate
 
5
MIME-Version: 1.0
 
6
Content-Type: text/plain; charset=UTF-8
 
7
Content-Transfer-Encoding: 8bit
 
8
 
 
9
xserver fails to generate useable resolutions with 90Hz framerate
 
10
panels(encounter the same issue with 3 different 2.5k resolution
 
11
panels). All the resolutions shown by xrandr lead to blank screen except
 
12
the one written in EDID.
 
13
Ville Syrjälä from Intel provides a method to calculate the preferred
 
14
clock and refresh rate from the existing resolution table and this
 
15
works for the issue.
 
16
 
 
17
v2. xf86ModeVRefresh might return 0, need to check it before use it.
 
18
 
 
19
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1388
 
20
Signed-off-by: Chia-Lin Kao (AceLan) <acelan.kao@canonical.com>
 
21
---
 
22
 hw/xfree86/common/xf86Mode.c                     |  2 ++
 
23
 hw/xfree86/drivers/modesetting/drmmode_display.c | 12 +++++++++++-
 
24
 include/displaymode.h                            |  1 +
 
25
 3 files changed, 14 insertions(+), 1 deletion(-)
 
26
 
 
27
diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c
 
28
index 16dd529e3..136cd15d0 100644
 
29
--- a/hw/xfree86/common/xf86Mode.c
 
30
+++ b/hw/xfree86/common/xf86Mode.c
 
31
@@ -230,6 +230,8 @@ xf86ModeStatusToString(ModeStatus status)
 
32
         return "monitor doesn't support reduced blanking";
 
33
     case MODE_BANDWIDTH:
 
34
         return "mode requires too much memory bandwidth";
 
35
+    case MODE_DUPLICATE:
 
36
+        return "the same mode has been added";
 
37
     case MODE_BAD:
 
38
         return "unknown reason";
 
39
     case MODE_ERROR:
 
40
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
 
41
index 65e8e6335..dc4e0f078 100644
 
42
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
 
43
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
 
44
@@ -2641,7 +2641,7 @@ static DisplayModePtr
 
45
 drmmode_output_add_gtf_modes(xf86OutputPtr output, DisplayModePtr Modes)
 
46
 {
 
47
     xf86MonPtr mon = output->MonInfo;
 
48
-    DisplayModePtr i, m, preferred = NULL;
 
49
+    DisplayModePtr i, j, m, preferred = NULL;
 
50
     int max_x = 0, max_y = 0;
 
51
     float max_vrefresh = 0.0;
 
52
 
 
53
@@ -2673,6 +2673,16 @@ drmmode_output_add_gtf_modes(xf86OutputPtr output, DisplayModePtr Modes)
 
54
             i->VDisplay >= preferred->VDisplay &&
 
55
             xf86ModeVRefresh(i) >= xf86ModeVRefresh(preferred))
 
56
             i->status = MODE_VSYNC;
 
57
+        if (xf86ModeVRefresh(i) > 0.0)
 
58
+            i->Clock = i->Clock * xf86ModeVRefresh(preferred) / xf86ModeVRefresh(i);
 
59
+        i->VRefresh = xf86ModeVRefresh(preferred);
 
60
+        for (j = m; j != i; j = j->next) {
 
61
+            if (!strcmp(i->name, j->name) &&
 
62
+                xf86ModeVRefresh(i) * (1 + SYNC_TOLERANCE) >= xf86ModeVRefresh(j) &&
 
63
+                xf86ModeVRefresh(i) * (1 - SYNC_TOLERANCE) <= xf86ModeVRefresh(j)) {
 
64
+                i->status = MODE_DUPLICATE;
 
65
+            }
 
66
+        }
 
67
     }
 
68
 
 
69
     xf86PruneInvalidModes(output->scrn, &m, FALSE);
 
70
diff --git a/include/displaymode.h b/include/displaymode.h
 
71
index ad01b87ec..561087717 100644
 
72
--- a/include/displaymode.h
 
73
+++ b/include/displaymode.h
 
74
@@ -47,6 +47,7 @@ typedef enum {
 
75
     MODE_ONE_SIZE,              /* only one resolution is supported */
 
76
     MODE_NO_REDUCED,            /* monitor doesn't accept reduced blanking */
 
77
     MODE_BANDWIDTH,             /* mode requires too much memory bandwidth */
 
78
+    MODE_DUPLICATE,             /* mode is duplicated */
 
79
     MODE_BAD = -2,              /* unspecified reason */
 
80
     MODE_ERROR = -1             /* error condition */
 
81
 } ModeStatus;
 
82
-- 
 
83
GitLab
 
84