diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c index 16dd529e3..136cd15d0 100644 --- a/hw/xfree86/common/xf86Mode.c +++ b/hw/xfree86/common/xf86Mode.c @@ -230,6 +230,8 @@ xf86ModeStatusToString(ModeStatus status) return "monitor doesn't support reduced blanking"; case MODE_BANDWIDTH: return "mode requires too much memory bandwidth"; + case MODE_DUPLICATE: + return "the same mode has been added"; case MODE_BAD: return "unknown reason"; case MODE_ERROR: diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index 623961ff6..1c1d79f30 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -2843,7 +2843,7 @@ static DisplayModePtr drmmode_output_add_gtf_modes(xf86OutputPtr output, DisplayModePtr Modes) { xf86MonPtr mon = output->MonInfo; - DisplayModePtr i, m, preferred = NULL; + DisplayModePtr i, j, m, preferred = NULL; int max_x = 0, max_y = 0; float max_vrefresh = 0.0; @@ -2875,6 +2875,17 @@ drmmode_output_add_gtf_modes(xf86OutputPtr output, DisplayModePtr Modes) i->VDisplay >= preferred->VDisplay && xf86ModeVRefresh(i) >= xf86ModeVRefresh(preferred)) i->status = MODE_VSYNC; + if (preferred && xf86ModeVRefresh(i) > 0.0) { + i->Clock = i->Clock * xf86ModeVRefresh(preferred) / xf86ModeVRefresh(i); + i->VRefresh = xf86ModeVRefresh(preferred); + } + for (j = m; j != i; j = j->next) { + if (!strcmp(i->name, j->name) && + xf86ModeVRefresh(i) * (1 + SYNC_TOLERANCE) >= xf86ModeVRefresh(j) && + xf86ModeVRefresh(i) * (1 - SYNC_TOLERANCE) <= xf86ModeVRefresh(j)) { + i->status = MODE_DUPLICATE; + } + } } xf86PruneInvalidModes(output->scrn, &m, FALSE); diff --git a/include/displaymode.h b/include/displaymode.h index ad01b87ec..561087717 100644 --- a/include/displaymode.h +++ b/include/displaymode.h @@ -47,6 +47,7 @@ typedef enum { MODE_ONE_SIZE, /* only one resolution is supported */ MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */ MODE_BANDWIDTH, /* mode requires too much memory bandwidth */ + MODE_DUPLICATE, /* mode is duplicated */ MODE_BAD = -2, /* unspecified reason */ MODE_ERROR = -1 /* error condition */ } ModeStatus;