xserver: Branch 'master' - 4 commits

Keith Packard keithp at kemper.freedesktop.org
Fri Jan 23 10:50:33 PST 2015


 hw/xfree86/drivers/modesetting/drmmode_display.c |  196 ++++++++++++++++++++---
 hw/xfree86/drivers/modesetting/drmmode_display.h |    4 
 hw/xfree86/drivers/modesetting/vblank.c          |    9 -
 3 files changed, 175 insertions(+), 34 deletions(-)

New commits:
commit fef2f6357b40b238ae01c4c80b0d29b17b839686
Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Tue Jan 13 15:08:38 2015 -0800

    modesetting: Return the crtc for a drawable even if it's rotated
    
    All of our checks for what crtc we are on take rotation into account so we
    select the correct crtc.  The only problem is that we weren't returning it
    we were rotated.  This caused X to think DRI3 apps were not on any crtc and
    limit them to 1 FPS.
    
    Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c
index 711f6ed..a342662 100644
--- a/hw/xfree86/drivers/modesetting/vblank.c
+++ b/hw/xfree86/drivers/modesetting/vblank.c
@@ -147,20 +147,13 @@ ms_dri2_crtc_covering_drawable(DrawablePtr pDraw)
     ScreenPtr pScreen = pDraw->pScreen;
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     BoxRec box, crtcbox;
-    xf86CrtcPtr crtc;
 
     box.x1 = pDraw->x;
     box.y1 = pDraw->y;
     box.x2 = box.x1 + pDraw->width;
     box.y2 = box.y1 + pDraw->height;
 
-    crtc = ms_covering_crtc(pScrn, &box, NULL, &crtcbox);
-
-    /* Make sure the CRTC is valid and this is the real front buffer */
-    if (crtc != NULL && !crtc->rotatedData)
-        return crtc;
-
-    return NULL;
+    return ms_covering_crtc(pScrn, &box, NULL, &crtcbox);
 }
 
 static Bool
commit 3dcd591fa9b71a3dce58d612ca5970209d8386eb
Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Tue Jan 13 15:08:37 2015 -0800

    modesetting: Add support for using RandR shadow buffers
    
    This replaces the stubs for shadow buffer creation/allocation with actual
    functions and adds a shadow_destroy function.  With this, we actually get
    shadow buffers and RandR now works properly.  Most of this is copied from
    the xf86-video-intel driver and modified for modesetting.
    
    v2 Jason Ekstrand <jason.ekstrand at intel.com>:
     - Fix build with --disable-glamor
     - Set the pixel data pointer in the pixmap header for dumb shadow bo's
     - Call drmmode_create_bo with the right bpp
    
    v2 Jason Ekstrand <jason.ekstrand at intel.com>:
     - Make shadow buffers per-crtc and leave shadow_enable alone
    
    Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index ee7087b..1ea799b 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -540,13 +540,122 @@ drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
 static void *
 drmmode_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
 {
-    return NULL;
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
+    int ret;
+
+    if (!drmmode_create_bo(drmmode, &drmmode_crtc->rotate_bo,
+                           width, height, crtc->scrn->bitsPerPixel)) {
+        xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR,
+               "Couldn't allocate shadow memory for rotated CRTC\n");
+        return NULL;
+    }
+
+    ret = drmModeAddFB(drmmode->fd, width, height, crtc->scrn->depth,
+                       crtc->scrn->bitsPerPixel,
+                       drmmode_bo_get_pitch(&drmmode_crtc->rotate_bo),
+                       drmmode_bo_get_handle(&drmmode_crtc->rotate_bo),
+                       &drmmode_crtc->rotate_fb_id);
+
+    if (ret) {
+        ErrorF("failed to add rotate fb\n");
+        drmmode_bo_destroy(drmmode, &drmmode_crtc->rotate_bo);
+        return NULL;
+    }
+
+#ifdef GLAMOR_HAS_GBM
+    if (drmmode->gbm)
+        return drmmode_crtc->rotate_bo.gbm;
+#endif
+    return drmmode_crtc->rotate_bo.dumb;
 }
 
 static PixmapPtr
+drmmode_create_pixmap_header(ScreenPtr pScreen, int width, int height,
+                             int depth, int bitsPerPixel, int devKind,
+                             void *pPixData)
+{
+    PixmapPtr pixmap;
+
+    /* width and height of 0 means don't allocate any pixmap data */
+    pixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, depth, 0);
+
+    if (pixmap) {
+        if ((*pScreen->ModifyPixmapHeader)(pixmap, width, height, depth,
+                                           bitsPerPixel, devKind, pPixData))
+            return pixmap;
+        (*pScreen->DestroyPixmap)(pixmap);
+    }
+    return NullPixmap;
+}
+
+static Bool
+drmmode_set_pixmap_bo(drmmode_ptr drmmode, PixmapPtr pixmap, drmmode_bo *bo);
+
+static PixmapPtr
 drmmode_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 {
-    return NULL;
+    ScrnInfoPtr scrn = crtc->scrn;
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
+    uint32_t rotate_pitch;
+    PixmapPtr rotate_pixmap;
+    void *pPixData = NULL;
+
+    if (!data) {
+        data = drmmode_shadow_allocate(crtc, width, height);
+        if (!data) {
+            xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                       "Couldn't allocate shadow pixmap for rotated CRTC\n");
+            return NULL;
+        }
+    }
+
+    if (!drmmode_bo_has_bo(&drmmode_crtc->rotate_bo)) {
+        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                   "Couldn't allocate shadow pixmap for rotated CRTC\n");
+        return NULL;
+    }
+
+    pPixData = drmmode_bo_map(drmmode, &drmmode_crtc->rotate_bo);
+    rotate_pitch = drmmode_bo_get_pitch(&drmmode_crtc->rotate_bo),
+
+    rotate_pixmap = drmmode_create_pixmap_header(scrn->pScreen,
+                                                 width, height,
+                                                 scrn->depth,
+                                                 scrn->bitsPerPixel,
+                                                 rotate_pitch,
+                                                 pPixData);
+
+    if (rotate_pixmap == NULL) {
+        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                   "Couldn't allocate shadow pixmap for rotated CRTC\n");
+        return NULL;
+    }
+
+    drmmode_set_pixmap_bo(drmmode, rotate_pixmap, &drmmode_crtc->rotate_bo);
+
+    return rotate_pixmap;
+}
+
+static void
+drmmode_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
+{
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
+
+    if (rotate_pixmap) {
+        drmmode_set_pixmap_bo(drmmode, rotate_pixmap, NULL);
+        rotate_pixmap->drawable.pScreen->DestroyPixmap(rotate_pixmap);
+    }
+
+    if (data) {
+        drmModeRmFB(drmmode->fd, drmmode_crtc->rotate_fb_id);
+        drmmode_crtc->rotate_fb_id = 0;
+
+        drmmode_bo_destroy(drmmode, &drmmode_crtc->rotate_bo);
+        memset(&drmmode_crtc->rotate_bo, 0, sizeof drmmode_crtc->rotate_bo);
+    }
 }
 
 static const xf86CrtcFuncsRec drmmode_crtc_funcs = {
@@ -563,6 +672,7 @@ static const xf86CrtcFuncsRec drmmode_crtc_funcs = {
     .set_scanout_pixmap = drmmode_set_scanout_pixmap,
     .shadow_allocate = drmmode_shadow_allocate,
     .shadow_create = drmmode_shadow_create,
+    .shadow_destroy = drmmode_shadow_destroy,
 };
 
 static uint32_t
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index 66d0ca2..3a8959a 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -89,10 +89,12 @@ typedef struct {
     int dpms_mode;
     struct dumb_bo *cursor_bo;
     Bool cursor_up;
-    unsigned rotate_fb_id;
     uint16_t lut_r[256], lut_g[256], lut_b[256];
     DamagePtr slave_damage;
 
+    drmmode_bo rotate_bo;
+    unsigned rotate_fb_id;
+
     /**
      * @{ MSC (vblank count) handling for the PRESENT extension.
      *
commit 7c656bfcae1d68aeffd5e202b3c1569885f5d13d
Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Tue Jan 13 15:08:36 2015 -0800

    modesetting: Add drmmode_bo_has_bo and drmmode_bo_map helper function
    
    Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index ea59ffe..ee7087b 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -82,6 +82,17 @@ drmmode_bo_get_pitch(drmmode_bo *bo)
     return bo->dumb->pitch;
 }
 
+static Bool
+drmmode_bo_has_bo(drmmode_bo *bo)
+{
+#ifdef GLAMOR_HAS_GBM
+    if (bo->gbm)
+        return TRUE;
+#endif
+
+    return bo->dumb != NULL;
+}
+
 uint32_t
 drmmode_bo_get_handle(drmmode_bo *bo)
 {
@@ -93,6 +104,26 @@ drmmode_bo_get_handle(drmmode_bo *bo)
     return bo->dumb->handle;
 }
 
+static void *
+drmmode_bo_map(drmmode_ptr drmmode, drmmode_bo *bo)
+{
+    int ret;
+
+#ifdef GLAMOR_HAS_GBM
+    if (bo->gbm)
+        return NULL;
+#endif
+
+    if (bo->dumb->ptr)
+        return bo->dumb->ptr;
+
+    ret = dumb_bo_map(drmmode->fd, bo->dumb);
+    if (ret)
+        return NULL;
+
+    return bo->dumb->ptr;
+}
+
 static Bool
 drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo,
                   unsigned width, unsigned height, unsigned bpp)
@@ -1570,17 +1601,7 @@ drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 void *
 drmmode_map_front_bo(drmmode_ptr drmmode)
 {
-    int ret;
-
-    if (drmmode->front_bo.dumb->ptr)
-        return drmmode->front_bo.dumb->ptr;
-
-    ret = dumb_bo_map(drmmode->fd, drmmode->front_bo.dumb);
-    if (ret)
-        return NULL;
-
-    return drmmode->front_bo.dumb->ptr;
-
+    return drmmode_bo_map(drmmode, &drmmode->front_bo);
 }
 
 void *
commit b4703a5a6e529b78810db8d8782317f0b4e2f265
Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Tue Jan 13 15:08:35 2015 -0800

    modesetting: Refactor drmmode_glamor_new_screen_pixmap
    
    The original drmmode_glamor_new_screen_pixmap function was specific to the
    primary screen pixmap.  This commit pulls the guts out into a new, more
    general, drmmode_set_pixmap_bo function for setting a buffer on a pixmap.
    The new function also properly tears down the glamor bits if the buffer
    being set is NULL.  The drmmode_glamor_new_screen_pixmap function is now
    just a 3-line wrapper around drmmode_set_pixmap_bo.
    
    v2 Jason Ekstrand <jason.ekstrand at intel.com>:
     - Re-arranged code in drmmode_set_pixmap_bo and
       drmmode_glamor_handle_new_screen_pixmap so that glamor_set_screen_pixmap
       only gets called for the screen pixmap
     - Guard the call to glamor_set_screen_pixmapa with a drmmode->glamor check
    
    Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 824500b..ea59ffe 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -1123,34 +1123,32 @@ drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
     }
 }
 
-Bool
-drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode)
+static Bool
+drmmode_set_pixmap_bo(drmmode_ptr drmmode, PixmapPtr pixmap, drmmode_bo *bo)
 {
 #ifdef GLAMOR
     ScrnInfoPtr scrn = drmmode->scrn;
-    ScreenPtr screen = xf86ScrnToScreen(drmmode->scrn);
-    PixmapPtr screen_pixmap;
-    void *gbm_bo;
 
     if (!drmmode->glamor)
         return TRUE;
 
-#ifdef GLAMOR_HAS_GBM
-    gbm_bo = drmmode->front_bo.gbm;
-    screen_pixmap = screen->GetScreenPixmap(screen);
+    if (bo == NULL) {
+        glamor_egl_destroy_textured_pixmap(pixmap);
+        return TRUE;
+    }
 
-    if (!glamor_egl_create_textured_pixmap_from_gbm_bo(screen_pixmap, gbm_bo)) {
+#ifdef GLAMOR_HAS_GBM
+    if (!glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap, bo->gbm)) {
         xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed");
         return FALSE;
     }
-    glamor_set_screen_pixmap(screen_pixmap, NULL);
 #else
-    if (!glamor_egl_create_textured_screen(screen,
+    if (!glamor_egl_create_textured_pixmap(pixmap,
                                            drmmode_bo_get_handle(&drmmode->front_bo),
                                            scrn->displayWidth *
                                            scrn->bitsPerPixel / 8)) {
         xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-                   "glamor_egl_create_textured_screen() failed\n");
+                   "glamor_egl_create_textured_pixmap() failed\n");
         return FALSE;
     }
 #endif
@@ -1159,6 +1157,23 @@ drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode)
     return TRUE;
 }
 
+Bool
+drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode)
+{
+    ScreenPtr screen = xf86ScrnToScreen(drmmode->scrn);
+    PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
+
+    if (!drmmode_set_pixmap_bo(drmmode, screen_pixmap, &drmmode->front_bo))
+        return FALSE;
+
+#ifdef GLAMOR
+    if (drmmode->glamor)
+        glamor_set_screen_pixmap(screen_pixmap, NULL);
+#endif
+
+    return TRUE;
+}
+
 static Bool
 drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 {


More information about the xorg-commit mailing list