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

Eduard Permyakov epermyakov at codeweavers.com
Tue Sep 7 12:24:04 CDT 2021


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

diff --git a/dlls/winex11.drv/xinerama.c b/dlls/winex11.drv/xinerama.c
index 0e1e07669c2..b2afd309b6c 100644
--- a/dlls/winex11.drv/xinerama.c
+++ b/dlls/winex11.drv/xinerama.c
@@ -111,6 +111,76 @@ static int query_screens(void)
     return count;
 }
 
+static void get_virtual_edid( RECT monitor, unsigned char **edid, unsigned long *len )
+{
+    int i;
+    uint8_t accum = 0;
+    static const size_t desc_size = 128;
+    unsigned int width = monitor.right - monitor.left;
+    unsigned int height = monitor.bottom - monitor.top;
+    /*Sample EDID for an LCD Desktop IT Display, from VESA spec */
+    static const unsigned char default_edid[128] = {
+        /* Header */
+        0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+        /* Manufacturer's code name */
+        0x04, 0x43,
+        /* Product code */
+        0x06, 0xf2,
+        /* Serial Number */
+        0x01, 0x00, 0x00, 0x00,
+        /* Date of manufacture */
+        0x01, 0x11,
+        /* EDID version */
+        0x01, 0x04,
+        /* Standard characteristics */
+        0x0f, 0x2b, 0x20, 0x78, 0x2b, 0x9c, 0x68, 0xa0,
+        0x57, 0x4a, 0x9b, 0x26, 0x12, 0x48, 0x4c, 0xff,
+        0xff, 0x80, 0xa9, 0x59, 0xa9, 0x4f, 0xa9, 0x4a,
+        0xa9, 0x45, 0x81, 0x99, 0x81, 0x80, 0x61, 0x59,
+        0x45, 0x59,
+        /* First 18-byte data block (Preferred Timing Mode) */
+        0x48, 0x3f, 0x40, 0x30, 0x62, 0xb0, 0x32, 0x40,
+        0x40, 0xc0, 0x13, 0x00, 0xab, 0x40, 0x11, 0x00,
+        0x00, 0x1e,
+        /* Second 18-byte data block */
+        0x00, 0x00, 0x00, 0xfd, 0x00, 0x32, 0x5a, 0x1e,
+        0x6e, 0x17, 0x04, 0x11, 0x00, 0xc8, 0x90, 0x00,
+        0x50, 0x3c,
+        /* Third 18-byte data block */
+        0x00, 0x00, 0x00, 0xf7, 0x00, 0x0a, 0xf7, 0x0f,
+        0x03, 0x87, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00,
+        /* Fourth 18-byte data block */
+        0x00, 0x00, 0x00, 0xfc, 0x00, 0x41, 0x42, 0x43,
+        0x20, 0x4c, 0x43, 0x44, 0x32, 0x31, 0x0a, 0x20,
+        0x20, 0x20,
+        /* Extension flag */
+        0x00,
+    };
+
+    *edid = heap_calloc( desc_size, 1 );
+    if (!*edid)
+    {
+        *len = 0;
+        return;
+    }
+
+    memcpy( *edid, default_edid, sizeof(default_edid) );
+    *len = desc_size;
+
+    /* Set the native resolution in the Preferred Timing Mode descriptor */
+    (*edid)[0x38] = width & 0xff;
+    (*edid)[0x3a] = ((width >> 8) & 0xf) << 4;
+
+    (*edid)[0x3b] = height & 0xff;
+    (*edid)[0x3d] = ((height >> 8) & 0xf) << 4;
+
+    /* Set checksum */
+    for (i = 0; i < desc_size-1; i++)
+        accum += (*edid)[i];
+    (*edid)[desc_size - 1] = 256 - accum;
+}
+
 #else  /* SONAME_LIBXINERAMA */
 
 static inline int query_screens(void)
@@ -244,8 +314,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 +329,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++)
+        heap_free( monitors[i].edid );
     heap_free( monitors );
 }
 
-- 
2.25.1




More information about the wine-devel mailing list