[PATCH] modesetting: Add common 16by9 and 16by10 resolutions to mode list

Michael Cronenworth mike at cchtml.com
Tue Aug 22 18:20:52 UTC 2017


Related: https://bugzilla.redhat.com/show_bug.cgi?id=1339930

Signed-off-by: Michael Cronenworth <mike at cchtml.com>
---
 hw/xfree86/drivers/modesetting/drmmode_display.c | 78 +++++++++++++++++++++++-
 1 file changed, 76 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index fec7ac276..7e5f0565e 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -50,6 +50,35 @@
 
 #include "driver.h"
 
+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 Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height);
 static PixmapPtr drmmode_create_pixmap_header(ScreenPtr pScreen, int width, int height,
                                               int depth, int bitsPerPixel, int devKind,
@@ -1267,7 +1296,10 @@ drmmode_output_add_gtf_modes(xf86OutputPtr output, DisplayModePtr Modes)
 {
     xf86MonPtr mon = output->MonInfo;
     DisplayModePtr i, m, preferred = NULL;
-    int max_x = 0, max_y = 0;
+    drmmode_output_private_ptr drmmode_output = output->driver_private;
+    drmmode_ptr drmmode = drmmode_output->drmmode;
+    ScrnInfoPtr pScrn = drmmode->scrn;
+    int max_x = 0, max_y = 0, n;
     float max_vrefresh = 0.0;
 
     if (mon && GTF_SUPPORTED(mon->features.msc))
@@ -1302,7 +1334,49 @@ drmmode_output_add_gtf_modes(xf86OutputPtr output, DisplayModePtr Modes)
 
     xf86PruneInvalidModes(output->scrn, &m, FALSE);
 
-    return xf86ModesAdd(Modes, m);
+    Modes = xf86ModesAdd(Modes, m);
+
+    if (preferred->VDisplay * 16 > preferred->HDisplay*9 - preferred->HDisplay/32 &&
+        preferred->VDisplay * 16 < preferred->HDisplay*9 + preferred->HDisplay/32) {
+        xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, MS_LOGLEVEL_DEBUG,
+                       "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);
+            Modes = xf86ModesAdd(Modes, m);
+        }
+    }
+
+    if (preferred->VDisplay * 16 > preferred->HDisplay*10 - preferred->HDisplay/32 &&
+        preferred->VDisplay * 16 < preferred->HDisplay*10 + preferred->HDisplay/32) {
+        xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, MS_LOGLEVEL_DEBUG,
+                       "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);
+            Modes = xf86ModesAdd(Modes, m);
+        }
+    }
+
+    return Modes;
 }
 
 static DisplayModePtr
-- 
2.13.5



More information about the xorg-devel mailing list