From cd6296f35a8de3bb02251736bc427f7f8273224c Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 6 Oct 2014 09:17:46 +0100 Subject: [PATCH] randr/prime: Don't stop on the first pipe when disabling ReplaceScanoutPixmap As we define sizeFits based on whether a CRTC is active, and skip trying to redirect the scanout on a disable pipe, we then attempt to undo it later and fail because crtc->scanout_pixmap != DRI2_Pixmap and !sizeFits. Paper over this failure by skipping unredirected CRTC when disabling. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84653 Signed-off-by: Chris Wilson Cc: Dave Airlie --- randr/rrcrtc.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 69b3ecf..86d05b8 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -1667,23 +1667,24 @@ Bool RRReplaceScanoutPixmap(DrawablePtr pDrawable, PixmapPtr pPixmap, Bool enable) { rrScrPriv(pDrawable->pScreen); - int i; - Bool size_fits = FALSE; - Bool changed = FALSE; Bool ret = TRUE; + int i; for (i = 0; i < pScrPriv->numCrtcs; i++) { RRCrtcPtr crtc = pScrPriv->crtcs[i]; + Bool size_fits, changed; if (!crtc->mode && enable) continue; + if (!crtc->scanout_pixmap && !enable) + continue; changed = FALSE; - if (crtc->mode && crtc->x == pDrawable->x && - crtc->y == pDrawable->y && - crtc->mode->mode.width == pDrawable->width && - crtc->mode->mode.height == pDrawable->height) - size_fits = TRUE; + size_fits = (crtc->mode && + crtc->x == pDrawable->x && + crtc->y == pDrawable->y && + crtc->mode->mode.width == pDrawable->width && + crtc->mode->mode.height == pDrawable->height); /* is the pixmap already set? */ if (crtc->scanout_pixmap == pPixmap) { @@ -1692,23 +1693,25 @@ RRReplaceScanoutPixmap(DrawablePtr pDrawable, PixmapPtr pPixmap, Bool enable) /* set scanout to NULL */ crtc->scanout_pixmap = NULL; changed = TRUE; - } else { - /* if the size fits then we are already setup */ - if (size_fits) - return TRUE; + } else if (!size_fits) { /* if the size no longer fits then drop off */ crtc->scanout_pixmap = NULL; changed = TRUE; ret = FALSE; - } + } else { + /* if the size fits then we are already setup */ + } } else { - if (!size_fits) - return FALSE; - if (enable) { + if (!size_fits) { + ret = FALSE; + } else if (enable) { crtc->scanout_pixmap = pPixmap; pScrPriv->rrCrtcSetScanoutPixmap(crtc, pPixmap); changed = TRUE; - } + } else { + /* reject an attempt to disable someone else's scanout_pixmap */ + ret = FALSE; + } } if (changed && pScrPriv->rrCrtcSet) { @@ -1718,5 +1721,7 @@ RRReplaceScanoutPixmap(DrawablePtr pDrawable, PixmapPtr pPixmap, Bool enable) crtc->rotation, crtc->numOutputs, crtc->outputs); } } + + /* XXX unwind failure? */ return ret; } -- 1.9.1