modes: Fix duplicate detection, and do it more consistently
Signed-off-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
ba2d39dd54
commit
7c0803f555
|
@ -1377,34 +1377,6 @@ xf86InitialPanning (ScrnInfoPtr scrn)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX walk the monitor mode list and prune out duplicates that
|
||||
* are inserted by xf86DDCMonitorSet. In an ideal world, that
|
||||
* function would do this work by itself.
|
||||
*/
|
||||
|
||||
static void
|
||||
xf86PruneDuplicateMonitorModes (MonPtr Monitor)
|
||||
{
|
||||
DisplayModePtr master, clone, next;
|
||||
|
||||
for (master = Monitor->Modes;
|
||||
master && master != Monitor->Last;
|
||||
master = master->next)
|
||||
{
|
||||
for (clone = master->next; clone && clone != Monitor->Modes; clone = next)
|
||||
{
|
||||
next = clone->next;
|
||||
if (xf86ModesEqual (master, clone))
|
||||
{
|
||||
if (Monitor->Last == clone)
|
||||
Monitor->Last = clone->prev;
|
||||
xf86DeleteMode (&Monitor->Modes, clone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Return - 0 + if a should be earlier, same or later than b in list
|
||||
*/
|
||||
static int
|
||||
|
@ -1575,9 +1547,6 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
|
|||
maxY = config->maxHeight;
|
||||
}
|
||||
|
||||
/* Elide duplicate modes before defaulting code uses them */
|
||||
xf86PruneDuplicateMonitorModes (scrn->monitor);
|
||||
|
||||
/* Probe the list of modes for each output. */
|
||||
for (o = 0; o < config->num_output; o++)
|
||||
{
|
||||
|
|
|
@ -1082,6 +1082,8 @@ xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC)
|
|||
if (quirks & DDC_QUIRK_PREFER_LARGE_75)
|
||||
xf86DDCSetPreferredRefresh(scrnIndex, Modes, 75);
|
||||
|
||||
Modes = xf86PruneDuplicateModes(Modes);
|
||||
|
||||
return Modes;
|
||||
}
|
||||
|
||||
|
|
|
@ -691,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;
|
||||
}
|
||||
|
|
|
@ -95,6 +95,9 @@ extern _X_EXPORT void
|
|||
xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList,
|
||||
Bool verbose);
|
||||
|
||||
extern _X_EXPORT DisplayModePtr
|
||||
xf86PruneDuplicateModes(DisplayModePtr modes);
|
||||
|
||||
extern _X_EXPORT void
|
||||
xf86ValidateModesFlags(ScrnInfoPtr pScrn, DisplayModePtr modeList,
|
||||
int flags);
|
||||
|
|
Loading…
Reference in New Issue