diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2015-03-12 13:50:39 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2015-03-12 13:50:39 +0000 |
commit | 341654dc276d254aa23593efdb8e4c27a9ca1f77 (patch) | |
tree | 472802dd08b353fa2833ac6b7f39829dde66bf46 /src | |
parent | 71318389bedc87d3a2ea386343c371e5caed2880 (diff) |
sna: Compute half resolution modes
Sitting here with a 3200x1600 panel but no 1600x900 intermediate mode,
and I am too lazy to add it by hand.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/sna/sna_display.c | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index f648d626..5e800eca 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -3100,14 +3100,49 @@ done: } } +static bool duplicate_mode(DisplayModePtr modes, DisplayModePtr m) +{ + if (m == NULL) + return false; + + while (modes) { + if (xf86ModesEqual(modes, m)) + return true; + + modes = modes->next; + } + + return false; +} + static DisplayModePtr -default_modes(void) +default_modes(DisplayModePtr preferred) { + DisplayModePtr modes; + #if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,6,99,900,0) - return xf86GetDefaultModes(); + modes = xf86GetDefaultModes(); #else - return xf86GetDefaultModes(0, 0); + modes = xf86GetDefaultModes(0, 0); +#endif + +#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,4,99,901,0) + if (preferred) { + DisplayModePtr m; + + /* Add a half-resolution mode useful for large panels */ + m = xf86GTFMode(preferred->HDisplay/2, + preferred->VDisplay/2, + xf86ModeVRefresh(preferred), + FALSE, FALSE); + if (!duplicate_mode(modes, m)) + modes = xf86ModesAdd(modes, m); + else + free(m); + } #endif + + return modes; } static DisplayModePtr @@ -3132,7 +3167,7 @@ sna_output_add_default_modes(xf86OutputPtr output, DisplayModePtr modes) max_vrefresh = max(max_vrefresh, 60.0); max_vrefresh *= (1 + SYNC_TOLERANCE); - m = default_modes(); + m = default_modes(preferred); xf86ValidateModesSize(output->scrn, m, max_x, max_y, 0); for (i = m; i; i = i->next) { |