[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-xorg-devel
Subject:    [PATCH 11/11] modesetting: Suspend and resume flipping with DPMS
From:       Alex Goins <agoins () nvidia ! com>
Date:       2015-11-26 2:39:35
Message-ID: e8a07653a75b26369cf93886434cdead0000d8da.1448493820.git.agoins () nvidia ! com
[Download RAW message or body]

DPMS would prevent page flip / vblank events from being raised, freezing
the screen until PRIME flipping was reinitialized. To handle DPMS cleanly,
suspend PRIME page flipping when DPMS mode is not on, and resume it when
DPMS mode is on.

Signed-off-by: Alex Goins <agoins@nvidia.com>
---
 hw/xfree86/drivers/modesetting/drmmode_display.c | 39 +++++++++++++++++++-----
 hw/xfree86/drivers/modesetting/drmmode_display.h |  1 +
 2 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c \
b/hw/xfree86/drivers/modesetting/drmmode_display.c index 9c85b75..8916c5f 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -319,20 +319,35 @@ drmmode_SharedPixmapFlip(PixmapPtr frontTarget, PixmapPtr \
backTarget,  static Bool
 drmmode_InitSharedPixmapFlipping(xf86CrtcPtr crtc, drmmode_ptr drmmode)
 {
+    Bool ret;
     drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
     if (!drmmode_crtc->enable_flipping)
         return FALSE;
 
-    return drmmode_SharedPixmapFlip(crtc->randr_crtc->scanout_pixmap_back,
-                                    crtc->randr_crtc->scanout_pixmap,
-                                    crtc, drmmode, TRUE);
+    if (drmmode_crtc->flipping_active)
+        return TRUE;
+
+    ret = drmmode_SharedPixmapFlip(crtc->randr_crtc->scanout_pixmap_back,
+                                   crtc->randr_crtc->scanout_pixmap,
+                                   crtc, drmmode, TRUE);
+
+    if (ret)
+        drmmode_crtc->flipping_active = TRUE;
+
+    return ret;
 }
 
 static void
 drmmode_FiniSharedPixmapFlipping(xf86CrtcPtr crtc, drmmode_ptr drmmode)
 {
     uint32_t seq;
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+    if (!drmmode_crtc->flipping_active)
+        return;
+
+    drmmode_crtc->flipping_active = FALSE;
 
     /* Abort page flip event handler on scanout_pixmap */
     seq = msGetPixmapPriv(drmmode, crtc->randr_crtc->scanout_pixmap)->flipSeq;
@@ -1242,12 +1257,22 @@ drmmode_output_dpms(xf86OutputPtr output, int mode)
     drmModeConnectorSetProperty(drmmode->fd, koutput->connector_id,
                                 drmmode_output->dpms_enum_id, mode);
 
-    if (mode == DPMSModeOn && crtc) {
+    if (crtc) {
         drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-        if (drmmode_crtc->need_modeset)
-            drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
-                                   crtc->x, crtc->y);
+
+        if (mode == DPMSModeOn) {
+            if (drmmode_crtc->need_modeset)
+                drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
+                                       crtc->x, crtc->y);
+
+            if (drmmode_crtc->enable_flipping)
+                drmmode_InitSharedPixmapFlipping(crtc, drmmode_crtc->drmmode);
+        } else {
+            if (drmmode_crtc->enable_flipping)
+                drmmode_FiniSharedPixmapFlipping(crtc, drmmode_crtc->drmmode);
+        }
     }
+
     return;
 }
 
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h \
b/hw/xfree86/drivers/modesetting/drmmode_display.h index b0f6084..9f23937 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -117,6 +117,7 @@ typedef struct {
     Bool need_modeset;
 
     Bool enable_flipping;
+    Bool flipping_active;
 } drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
 
 typedef struct {
-- 
1.9.1

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic