[PATCH v2 3/3] winex11.drv: Add EDID to the xinerama monitor devices.

Eduard Permyakov epermyakov at codeweavers.com
Fri Sep 3 07:31:01 CDT 2021


Signed-off-by: Eduard Permyakov <epermyakov at codeweavers.com>
---
 dlls/winex11.drv/xinerama.c | 40 +++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/dlls/winex11.drv/xinerama.c b/dlls/winex11.drv/xinerama.c
index 0e1e07669c2..bac3770355e 100644
--- a/dlls/winex11.drv/xinerama.c
+++ b/dlls/winex11.drv/xinerama.c
@@ -111,6 +111,40 @@ static int query_screens(void)
     return count;
 }
 
+static void get_virtual_edid(RECT monitor, unsigned char **edid, unsigned long *len)
+{
+    static const size_t desc_size = 128;
+    unsigned int width = monitor.right - monitor.left;
+    unsigned int height = monitor.bottom - monitor.top;
+    unsigned int width_mm, height_mm;
+    unsigned char *ret;
+
+    *edid = NULL;
+    *len = 0;
+
+    ret = calloc( desc_size, 1 );
+    if (!ret)
+        return;
+
+    /* Set the native resolution in the Preferred Timing Mode descriptor */
+    ret[0x38] = width & 0xff;
+    ret[0x3A] = ((width >> 8) & 0xf) << 4;
+
+    ret[0x3B] = height & 0xff;
+    ret[0x3D] = ((height >> 8) & 0xf) << 4;
+
+    /* Set the monitor size (mm) in the Preferred Timing Mode descriptor */
+    height_mm = 200;
+    width_mm = height_mm / ((float)height) * width;
+
+    ret[0x42] = width_mm & 0xff;
+    ret[0x43] = height_mm & 0xff;
+    ret[0x44] = (((width_mm >> 8) & 0xf) << 4) | ((height_mm >> 8) & 0xf);
+
+    *edid = ret;
+    *len = desc_size;
+}
+
 #else  /* SONAME_LIBXINERAMA */
 
 static inline int query_screens(void)
@@ -244,8 +278,7 @@ static BOOL xinerama_get_monitors( ULONG_PTR adapter_id, struct x11drv_monitor *
             monitor[index].rc_work = monitors[i].rcWork;
             /* Xinerama only reports monitors already attached */
             monitor[index].state_flags = DISPLAY_DEVICE_ATTACHED;
-            monitor[index].edid_len = 0;
-            monitor[index].edid = NULL;
+            get_virtual_edid( monitors[i].rcMonitor, &monitor[index].edid, &monitor[index].edid_len );
             if (!IsRectEmpty( &monitors[i].rcMonitor ))
                 monitor[index].state_flags |= DISPLAY_DEVICE_ACTIVE;
 
@@ -260,6 +293,9 @@ static BOOL xinerama_get_monitors( ULONG_PTR adapter_id, struct x11drv_monitor *
 
 static void xinerama_free_monitors( struct x11drv_monitor *monitors, int count )
 {
+    int i;
+    for (i = 0; i < count; i++)
+        free(monitors[i].edid);
     heap_free( monitors );
 }
 
-- 
2.25.1




More information about the wine-devel mailing list