summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2015-04-14 20:47:26 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2015-04-14 21:02:12 +0100
commit26fd6bec113194c471c5d9e1b414c0a1824c5a23 (patch)
tree4d905228f8aee550de2d921094d61407220bc1a9
parent4c277bc43d958b256d15f72aec884bb921f4ad0a (diff)
sna: Add common widescreen resolutions
Currently we add fake modes to cater for applications that want to change the screen size but limit themselves to only those that are available, and do not wish to either use RandR scaling or their own. For widescreen panels, these 4:3 aspect ratio modes require panel fitting and so are less than satisfory. Since we add fake modes, let's add a few common widescreen modes as well (choosing the right aspect ration for the panel). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=37858 References: https://bugs.freedesktop.org/show_bug.cgi?id=29890 References: https://bugs.freedesktop.org/show_bug.cgi?id=89996 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_display.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 9e6c8cc4..944bb535 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -3259,10 +3259,40 @@ static bool duplicate_mode(DisplayModePtr modes, DisplayModePtr m)
return false;
}
+static struct pixel_count {
+ int16_t width, height;
+} common_16_9[] = {
+ { 640, 360 },
+ { 720, 405 },
+ { 864, 486 },
+ { 960, 540 },
+ { 1024, 576 },
+ { 1280, 720 },
+ { 1366, 768 },
+ { 1600, 900 },
+ { 1920, 1080 },
+ { 2048, 1152 },
+ { 2560, 1440 },
+ { 2880, 1620 },
+ { 3200, 1800 },
+ { 3840, 2160 },
+ { 4096, 2304 },
+ { 5120, 2880 },
+ { 7680, 4320 },
+ { 15360, 8640 },
+}, common_16_10[] = {
+ { 1280, 800 },
+ { 1400, 900 },
+ { 1680, 1050 },
+ { 1920, 1200 },
+ { 2560, 1600 },
+};
+
static DisplayModePtr
default_modes(DisplayModePtr preferred)
{
DisplayModePtr modes;
+ int n;
#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,6,99,900,0)
modes = xf86GetDefaultModes();
@@ -3270,6 +3300,8 @@ default_modes(DisplayModePtr preferred)
modes = xf86GetDefaultModes(0, 0);
#endif
+ /* XXX O(n^2) mode list generation :( */
+
#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,4,99,901,0)
if (preferred) {
DisplayModePtr m;
@@ -3283,6 +3315,50 @@ default_modes(DisplayModePtr preferred)
modes = xf86ModesAdd(modes, m);
else
free(m);
+
+ if (preferred->VDisplay * 16 > preferred->HDisplay*9 - preferred->HDisplay/32 &&
+ preferred->VDisplay * 16 < preferred->HDisplay*9 + preferred->HDisplay/32) {
+ DBG(("Adding 16:9 modes -- %d < %d > %d\n",
+ preferred->HDisplay*9 - preferred->HDisplay/32,
+ preferred->VDisplay * 16,
+ preferred->HDisplay*9 + preferred->HDisplay/32));
+ for (n = 0; n < ARRAY_SIZE(common_16_9); n++) {
+ if (preferred->HDisplay >= common_16_9[n].width ||
+ preferred->VDisplay >= common_16_9[n].height)
+ break;
+
+ m = xf86GTFMode(common_16_9[n].width,
+ common_16_9[n].height,
+ xf86ModeVRefresh(preferred),
+ FALSE, FALSE);
+ if (!duplicate_mode(modes, m))
+ modes = xf86ModesAdd(modes, m);
+ else
+ free(m);
+ }
+ }
+
+ if (preferred->VDisplay * 16 > preferred->HDisplay*10 - preferred->HDisplay/32 &&
+ preferred->VDisplay * 16 < preferred->HDisplay*10 + preferred->HDisplay/32) {
+ DBG(("Adding 16:10 modes -- %d < %d > %d\n",
+ preferred->HDisplay*10 - preferred->HDisplay/32,
+ preferred->VDisplay * 16,
+ preferred->HDisplay*10 + preferred->HDisplay/32));
+ for (n = 0; n < ARRAY_SIZE(common_16_10); n++) {
+ if (preferred->HDisplay >= common_16_10[n].width ||
+ preferred->VDisplay >= common_16_10[n].height)
+ break;
+
+ m = xf86GTFMode(common_16_10[n].width,
+ common_16_10[n].height,
+ xf86ModeVRefresh(preferred),
+ FALSE, FALSE);
+ if (!duplicate_mode(modes, m))
+ modes = xf86ModesAdd(modes, m);
+ else
+ free(m);
+ }
+ }
}
#endif