File u_DPMS-Check-for-broken-DPMSGet.patch of Package xf86-video-vesa

From: Egbert Eich <eich@suse.de>
Date: Mon Jul 4 18:00:18 2016 +0200
Subject: [PATCH]DPMS: Check for broken DPMSGet()
Patch-mainline: to be upstreamed
Git-commit: 484aa9d156f213d08001b3c926ff1632cf3826c2
References: bsc#986974
Signed-off-by: Egbert Eich <eich@suse.com>

On some BIOSes DPMSGet may return an incorrect mode. Check by
attempting to read back the mode just set and compare it to
the value set.

Signed-off-by: Egbert Eich <eich@suse.de>
---
 src/vesa.c | 8 +++++++-
 src/vesa.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/vesa.c b/src/vesa.c
index 983a5f5..818d9a7 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -1698,10 +1698,16 @@ VESADisplayPowerManagementSet(ScrnInfoPtr pScrn, int mode,
         (val & (1 << mode)) == 0)
         return;
 
-    if (VBEDPMSGet(pVesa->pVbe, &val) == TRUE && val == mode)
+    if (!pVesa->brokenDPMSGet &&
+        VBEDPMSGet(pVesa->pVbe, &val) == TRUE &&
+        val == mode)
         return;
 #endif
     VBEDPMSSet(pVesa->pVbe, mode);
+#ifdef VBE_HAVE_DPMS_GET_CAPABILITIES
+    if (!pVesa->brokenDPMSGet && VBEDPMSGet(pVesa->pVbe, &val) && val != mode)
+        pVesa->brokenDPMSGet = TRUE;
+#endif
 }
 
 /***********************************************************************
diff --git a/src/vesa.h b/src/vesa.h
index bcc9e37..7c68724 100644
--- a/src/vesa.h
+++ b/src/vesa.h
@@ -119,6 +119,7 @@ typedef struct _VESARec
     void *shadow;
     ShadowUpdateProc update;
     ShadowWindowProc window;
+    Bool brokenDPMSGet;
 } VESARec, *VESAPtr;
openSUSE Build Service is sponsored by