aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/modes/xf86Modes.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86/modes/xf86Modes.c')
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Modes.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/xorg-server/hw/xfree86/modes/xf86Modes.c b/xorg-server/hw/xfree86/modes/xf86Modes.c
index d105b48ab..75aedaa99 100644
--- a/xorg-server/hw/xfree86/modes/xf86Modes.c
+++ b/xorg-server/hw/xfree86/modes/xf86Modes.c
@@ -136,10 +136,12 @@ xf86ModeBandwidth(DisplayModePtr mode, int depth)
void
xf86SetModeDefaultName(DisplayModePtr mode)
{
- if (mode->name != NULL)
- xfree(mode->name);
+ Bool interlaced = !!(mode->Flags & V_INTERLACE);
- mode->name = XNFprintf("%dx%d", mode->HDisplay, mode->VDisplay);
+ xfree(mode->name);
+
+ mode->name = XNFprintf("%dx%d%s", mode->HDisplay, mode->VDisplay,
+ interlaced ? "i" : "");
}
/*
@@ -689,3 +691,37 @@ xf86GetDefaultModes (void)
}
return head;
}
+
+/*
+ * Walk a mode list and prune out duplicates. Will preserve the preferred
+ * mode of an otherwise-duplicate pair.
+ *
+ * Probably best to call this on lists that are all of a single class
+ * (driver, default, user, etc.), otherwise, which mode gets deleted is
+ * not especially well defined.
+ *
+ * Returns the new list.
+ */
+
+DisplayModePtr
+xf86PruneDuplicateModes(DisplayModePtr modes)
+{
+ DisplayModePtr m, n, o;
+
+top:
+ for (m = modes; m; m = m->next) {
+ for (n = m->next; n; n = o) {
+ o = n->next;
+ if (xf86ModesEqual(m, n)) {
+ if (n->type & M_T_PREFERRED) {
+ xf86DeleteMode(&modes, m);
+ goto top;
+ }
+ else
+ xf86DeleteMode(&modes, n);
+ }
+ }
+ }
+
+ return modes;
+}