xserver: Branch 'master' - 8 commits

Keith Packard keithp at kemper.freedesktop.org
Thu Dec 11 11:39:28 PST 2014


 glamor/glamor.h                                  |    2 
 glamor/glamor_egl.c                              |   12 +
 hw/xfree86/drivers/modesetting/Makefile.am       |    2 
 hw/xfree86/drivers/modesetting/driver.c          |   33 +--
 hw/xfree86/drivers/modesetting/drmmode_display.c |  247 ++++++++++-------------
 hw/xfree86/drivers/modesetting/drmmode_display.h |   26 +-
 hw/xfree86/drivers/modesetting/dumb_bo.c         |  134 ++++++++++++
 hw/xfree86/drivers/modesetting/dumb_bo.h         |   45 ++++
 8 files changed, 338 insertions(+), 163 deletions(-)

New commits:
commit 7b784df51bd6be38238d7101b1f5e320eb4aa5b8
Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue Dec 9 12:43:57 2014 -0800

    modesetting: Use GBM for buffer allocations if Glamor supports it.
    
    For performance, Glamor wants to render to tiled buffers, not linear
    ones.  Using GBM allows us to pick the 3D driver's preferred tiling
    modes.
    
    v2: Declare drmmode->gbm as void * if !GLAMOR_HAS_GBM.
    v3: Just use a forward declaration of struct gbm_device.
    
    Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
    Tested-by: Jason Ekstrand <jason.ekstrand at intel.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index dea709e..cad9000 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -877,7 +877,7 @@ CreateScreenResources(ScreenPtr pScreen)
     modesettingPtr ms = modesettingPTR(pScrn);
     PixmapPtr rootPixmap;
     Bool ret;
-    void *pixels;
+    void *pixels = NULL;
 
     pScreen->CreateScreenResources = ms->createScreenResources;
     ret = pScreen->CreateScreenResources(pScreen);
@@ -893,9 +893,12 @@ CreateScreenResources(ScreenPtr pScreen)
 
     if (!ms->drmmode.sw_cursor)
         drmmode_map_cursor_bos(pScrn, &ms->drmmode);
-    pixels = drmmode_map_front_bo(&ms->drmmode);
-    if (!pixels)
-        return FALSE;
+
+    if (!ms->drmmode.gbm) {
+        pixels = drmmode_map_front_bo(&ms->drmmode);
+        if (!pixels)
+            return FALSE;
+    }
 
     rootPixmap = pScreen->GetScreenPixmap(pScreen);
 
@@ -985,6 +988,11 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
     if (!SetMaster(pScrn))
         return FALSE;
 
+#ifdef GLAMOR_HAS_GBM
+    if (ms->drmmode.glamor)
+        ms->drmmode.gbm = glamor_egl_get_gbm_device(pScreen);
+#endif
+
     /* HW dependent - FIXME */
     pScrn->displayWidth = pScrn->virtualX;
     if (!drmmode_create_initial_bos(pScrn, &ms->drmmode))
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 29b8844..13a96dc 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -53,6 +53,9 @@
 #ifdef GLAMOR
 #define GLAMOR_FOR_XORG 1
 #include "glamor.h"
+#ifdef GLAMOR_HAS_GBM
+#include <gbm.h>
+#endif
 #endif
 
 static int
@@ -60,6 +63,13 @@ drmmode_bo_destroy(drmmode_ptr drmmode, drmmode_bo *bo)
 {
     int ret;
 
+#ifdef GLAMOR_HAS_GBM
+    if (bo->gbm) {
+        gbm_bo_destroy(bo->gbm);
+        bo->gbm = NULL;
+    }
+#endif
+
     if (bo->dumb) {
         ret = dumb_bo_destroy(drmmode->fd, bo->dumb);
         if (ret == 0)
@@ -72,12 +82,22 @@ drmmode_bo_destroy(drmmode_ptr drmmode, drmmode_bo *bo)
 static uint32_t
 drmmode_bo_get_pitch(drmmode_bo *bo)
 {
+#ifdef GLAMOR_HAS_GBM
+    if (bo->gbm)
+        return gbm_bo_get_stride(bo->gbm);
+#endif
+
     return bo->dumb->pitch;
 }
 
 uint32_t
 drmmode_bo_get_handle(drmmode_bo *bo)
 {
+#ifdef GLAMOR_HAS_GBM
+    if (bo->gbm)
+        return gbm_bo_get_handle(bo->gbm).u32;
+#endif
+
     return bo->dumb->handle;
 }
 
@@ -85,6 +105,15 @@ static Bool
 drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo,
                   unsigned width, unsigned height, unsigned bpp)
 {
+#ifdef GLAMOR_HAS_GBM
+    if (drmmode->glamor) {
+        bo->gbm = gbm_bo_create(drmmode->gbm, width, height,
+                                GBM_FORMAT_ARGB8888,
+                                GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);
+        return bo->gbm != NULL;
+    }
+#endif
+
     bo->dumb = dumb_bo_create(drmmode->fd, width, height, bpp);
     return bo->dumb != NULL;
 }
@@ -1110,10 +1139,22 @@ drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode)
 #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 (!glamor_egl_create_textured_pixmap_from_gbm_bo(screen_pixmap, gbm_bo)) {
+        xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed");
+        return FALSE;
+    }
+    glamor_set_screen_pixmap(screen_pixmap, NULL);
+#else
     if (!glamor_egl_create_textured_screen(screen,
                                            drmmode_bo_get_handle(&drmmode->front_bo),
                                            scrn->displayWidth *
@@ -1123,6 +1164,7 @@ drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode)
         return FALSE;
     }
 #endif
+#endif
 
     return TRUE;
 }
@@ -1142,7 +1184,7 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
     int i, pitch, old_width, old_height, old_pitch;
     int cpp = (scrn->bitsPerPixel + 7) / 8;
     PixmapPtr ppix = screen->GetScreenPixmap(screen);
-    void *new_pixels;
+    void *new_pixels = NULL;
 
     if (scrn->virtualX == width && scrn->virtualY == height)
         return TRUE;
@@ -1178,9 +1220,11 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
     if (ret)
         goto fail;
 
-    new_pixels = drmmode_map_front_bo(drmmode);
-    if (!new_pixels)
-        goto fail;
+    if (!drmmode->gbm) {
+        new_pixels = drmmode_map_front_bo(drmmode);
+        if (!new_pixels)
+            goto fail;
+    }
 
     if (drmmode->shadow_enable) {
         uint32_t size = scrn->displayWidth * scrn->virtualY *
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index 7c1ff05..6450811 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -34,8 +34,13 @@
 
 #include "dumb_bo.h"
 
+struct gbm_device;
+
 typedef struct {
     struct dumb_bo *dumb;
+#ifdef GLAMOR_HAS_GBM
+    struct gbm_bo *gbm;
+#endif
 } drmmode_bo;
 
 typedef struct {
@@ -46,6 +51,9 @@ typedef struct {
     drmModeFBPtr mode_fb;
     int cpp;
     ScrnInfoPtr scrn;
+
+    struct gbm_device *gbm;
+
 #ifdef CONFIG_UDEV_KMS
     struct udev_monitor *uevent_monitor;
     InputHandlerProc uevent_handler;
commit cfef64b0cabe7677c7584a72d7432c20343d9361
Author: Dave Airlie <airlied at redhat.com>
Date:   Tue Dec 9 12:28:38 2014 -0800

    glamor: Add an accessor for the GBM device.
    
    (Originally written by Dave Airlie; split into a separate patch by
    Kenneth Graunke.)
    
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
    Tested-by: Jason Ekstrand <jason.ekstrand at intel.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor.h b/glamor/glamor.h
index 95c4253..206158c 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -172,6 +172,8 @@ extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
 
 extern void glamor_egl_destroy_pixmap_image(PixmapPtr pixmap);
 
+extern _X_EXPORT void *glamor_egl_get_gbm_device(ScreenPtr screen);
+
 /* @glamor_supports_pixmap_import_export: Returns whether
  * glamor_fd_from_pixmap(), glamor_name_from_pixmap(), and
  * glamor_pixmap_from_fd() are supported.
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 898081a..113450c 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -174,6 +174,18 @@ glamor_create_texture_from_image(ScreenPtr screen,
     return TRUE;
 }
 
+void *
+glamor_egl_get_gbm_device(ScreenPtr screen)
+{
+#ifdef GLAMOR_HAS_GBM
+    struct glamor_egl_screen_private *glamor_egl =
+        glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
+    return glamor_egl->gbm;
+#else
+    return NULL;
+#endif
+}
+
 unsigned int
 glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
 {
commit 980535757d38db5c812c8afa32726d8cc36abfa4
Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue Dec 9 15:20:44 2014 -0800

    modesetting: Create a drmmode_bo wrapper; use it for front_bo.
    
    This code is going to be extended to support GBM BOs soon.  This small
    abstraction removes a lot of direct dumb_bo access, so we can add that
    support in one place, rather than putting conditionals at every
    pitch/handle/etc access.
    
    Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
    Tested-by: Jason Ekstrand <jason.ekstrand at intel.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index 61c8032..dea709e 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -861,7 +861,7 @@ msShadowWindow(ScreenPtr screen, CARD32 row, CARD32 offset, int mode,
     stride = (pScrn->displayWidth * pScrn->bitsPerPixel) / 8;
     *size = stride;
 
-    return ((uint8_t *) ms->drmmode.front_bo->ptr + row * stride + offset);
+    return ((uint8_t *) ms->drmmode.front_bo.dumb->ptr + row * stride + offset);
 }
 
 static void
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 277f60c..29b8844 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -55,6 +55,40 @@
 #include "glamor.h"
 #endif
 
+static int
+drmmode_bo_destroy(drmmode_ptr drmmode, drmmode_bo *bo)
+{
+    int ret;
+
+    if (bo->dumb) {
+        ret = dumb_bo_destroy(drmmode->fd, bo->dumb);
+        if (ret == 0)
+            bo->dumb = NULL;
+    }
+
+    return 0;
+}
+
+static uint32_t
+drmmode_bo_get_pitch(drmmode_bo *bo)
+{
+    return bo->dumb->pitch;
+}
+
+uint32_t
+drmmode_bo_get_handle(drmmode_bo *bo)
+{
+    return bo->dumb->handle;
+}
+
+static Bool
+drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo,
+                  unsigned width, unsigned height, unsigned bpp)
+{
+    bo->dumb = dumb_bo_create(drmmode->fd, width, height, bpp);
+    return bo->dumb != NULL;
+}
+
 Bool
 drmmode_SetSlaveBO(PixmapPtr ppix,
                    drmmode_ptr drmmode, int fd_handle, int pitch, int size)
@@ -213,8 +247,9 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
         ret = drmModeAddFB(drmmode->fd,
                            pScrn->virtualX, height,
                            pScrn->depth, pScrn->bitsPerPixel,
-                           drmmode->front_bo->pitch,
-                           drmmode->front_bo->handle, &drmmode->fb_id);
+                           drmmode_bo_get_pitch(&drmmode->front_bo),
+                           drmmode_bo_get_handle(&drmmode->front_bo),
+                           &drmmode->fb_id);
         if (ret < 0) {
             ErrorF("failed to add fb %d\n", ret);
             return FALSE;
@@ -1080,7 +1115,7 @@ drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode)
         return TRUE;
 
     if (!glamor_egl_create_textured_screen(screen,
-                                           drmmode->front_bo->handle,
+                                           drmmode_bo_get_handle(&drmmode->front_bo),
                                            scrn->displayWidth *
                                            scrn->bitsPerPixel / 8)) {
         xf86DrvMsg(scrn->scrnIndex, X_ERROR,
@@ -1100,7 +1135,7 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
     drmmode_crtc_private_ptr
         drmmode_crtc = xf86_config->crtc[0]->driver_private;
     drmmode_ptr drmmode = drmmode_crtc->drmmode;
-    struct dumb_bo *old_front = NULL;
+    drmmode_bo old_front;
     Bool ret;
     ScreenPtr screen = xf86ScrnToScreen(scrn);
     uint32_t old_fb_id;
@@ -1122,16 +1157,15 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 
     old_width = scrn->virtualX;
     old_height = scrn->virtualY;
-    old_pitch = drmmode->front_bo->pitch;
+    old_pitch = drmmode_bo_get_pitch(&drmmode->front_bo);
     old_fb_id = drmmode->fb_id;
     old_front = drmmode->front_bo;
 
-    drmmode->front_bo =
-        dumb_bo_create(drmmode->fd, width, height, scrn->bitsPerPixel);
-    if (!drmmode->front_bo)
+    if (!drmmode_create_bo(drmmode, &drmmode->front_bo,
+                           width, height, scrn->bitsPerPixel))
         goto fail;
 
-    pitch = drmmode->front_bo->pitch;
+    pitch = drmmode_bo_get_pitch(&drmmode->front_bo);
 
     scrn->virtualX = width;
     scrn->virtualY = height;
@@ -1139,7 +1173,8 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 
     ret = drmModeAddFB(drmmode->fd, width, height, scrn->depth,
                        scrn->bitsPerPixel, pitch,
-                       drmmode->front_bo->handle, &drmmode->fb_id);
+                       drmmode_bo_get_handle(&drmmode->front_bo),
+                       &drmmode->fb_id);
     if (ret)
         goto fail;
 
@@ -1174,14 +1209,13 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 
     if (old_fb_id) {
         drmModeRmFB(drmmode->fd, old_fb_id);
-        dumb_bo_destroy(drmmode->fd, old_front);
+        drmmode_bo_destroy(drmmode, &old_front);
     }
 
     return TRUE;
 
  fail:
-    if (drmmode->front_bo)
-        dumb_bo_destroy(drmmode->fd, drmmode->front_bo);
+    drmmode_bo_destroy(drmmode, &drmmode->front_bo);
     drmmode->front_bo = old_front;
     scrn->virtualX = old_width;
     scrn->virtualY = old_height;
@@ -1467,10 +1501,9 @@ drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
     width = pScrn->virtualX;
     height = pScrn->virtualY;
 
-    drmmode->front_bo = dumb_bo_create(drmmode->fd, width, height, bpp);
-    if (!drmmode->front_bo)
+    if (!drmmode_create_bo(drmmode, &drmmode->front_bo, width, height, bpp))
         return FALSE;
-    pScrn->displayWidth = drmmode->front_bo->pitch / cpp;
+    pScrn->displayWidth = drmmode_bo_get_pitch(&drmmode->front_bo) / cpp;
 
     width = ms->cursor_width;
     height = ms->cursor_height;
@@ -1490,14 +1523,14 @@ drmmode_map_front_bo(drmmode_ptr drmmode)
 {
     int ret;
 
-    if (drmmode->front_bo->ptr)
-        return drmmode->front_bo->ptr;
+    if (drmmode->front_bo.dumb->ptr)
+        return drmmode->front_bo.dumb->ptr;
 
-    ret = dumb_bo_map(drmmode->fd, drmmode->front_bo);
+    ret = dumb_bo_map(drmmode->fd, drmmode->front_bo.dumb);
     if (ret)
         return NULL;
 
-    return drmmode->front_bo->ptr;
+    return drmmode->front_bo.dumb->ptr;
 
 }
 
@@ -1544,8 +1577,7 @@ drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
         drmmode->fb_id = 0;
     }
 
-    dumb_bo_destroy(drmmode->fd, drmmode->front_bo);
-    drmmode->front_bo = NULL;
+    drmmode_bo_destroy(drmmode, &drmmode->front_bo);
 
     for (i = 0; i < xf86_config->num_crtc; i++) {
         xf86CrtcPtr crtc = xf86_config->crtc[i];
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index abb93ec..7c1ff05 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -35,6 +35,10 @@
 #include "dumb_bo.h"
 
 typedef struct {
+    struct dumb_bo *dumb;
+} drmmode_bo;
+
+typedef struct {
     int fd;
     unsigned fb_id;
     unsigned old_fb_id;
@@ -47,7 +51,7 @@ typedef struct {
     InputHandlerProc uevent_handler;
 #endif
     drmEventContext event_context;
-    struct dumb_bo *front_bo;
+    drmmode_bo front_bo;
     Bool sw_cursor;
 
     Bool glamor;
@@ -123,6 +127,7 @@ extern DevPrivateKeyRec msPixmapPrivateKeyRec;
 
 #define msGetPixmapPriv(drmmode, p) ((msPixmapPrivPtr)dixGetPrivateAddr(&(p)->devPrivates, &(drmmode)->pixmapPrivateKeyRec))
 
+uint32_t drmmode_bo_get_handle(drmmode_bo *bo);
 Bool drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode);
 void *drmmode_map_slave_bo(drmmode_ptr drmmode, msPixmapPrivPtr ppriv);
 Bool drmmode_SetSlaveBO(PixmapPtr ppix,
commit c6388964b079b3828c0b64951ff03008dda8f44a
Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue Dec 9 11:26:39 2014 -0800

    modesetting: Drop dumb_bo::map_count field and dead unmap code.
    
    The drm kernel API for dumb BOs apparently doesn't include an unmap
    ioctl, so we can't do much here.  It looks like this code was copied
    from libkms, which was also unfinished.
    
    We may as well delete the dead variable that simply gets incremented
    and never read.
    
    Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
    Tested-by: Jason Ekstrand <jason.ekstrand at intel.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/dumb_bo.c b/hw/xfree86/drivers/modesetting/dumb_bo.c
index 9a69aa2..58d420e 100644
--- a/hw/xfree86/drivers/modesetting/dumb_bo.c
+++ b/hw/xfree86/drivers/modesetting/dumb_bo.c
@@ -74,7 +74,6 @@ dumb_bo_map(int fd, struct dumb_bo *bo)
     void *map;
 
     if (bo->ptr) {
-        bo->map_count++;
         return 0;
     }
 
@@ -93,15 +92,6 @@ dumb_bo_map(int fd, struct dumb_bo *bo)
     return 0;
 }
 
-#if 0
-static int
-dumb_bo_unmap(int fd, struct dumb_bo *bo)
-{
-    bo->map_count--;
-    return 0;
-}
-#endif
-
 int
 dumb_bo_destroy(int fd, struct dumb_bo *bo)
 {
diff --git a/hw/xfree86/drivers/modesetting/dumb_bo.h b/hw/xfree86/drivers/modesetting/dumb_bo.h
index 1d401d4..9235e61 100644
--- a/hw/xfree86/drivers/modesetting/dumb_bo.h
+++ b/hw/xfree86/drivers/modesetting/dumb_bo.h
@@ -33,7 +33,6 @@ struct dumb_bo {
     uint32_t handle;
     uint32_t size;
     void *ptr;
-    int map_count;
     uint32_t pitch;
 };
 
commit 87cc0c0d317c5eac4fcf9bf4a7ad36454c05f6b8
Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue Dec 9 11:17:30 2014 -0800

    modesetting: Move dumb_bo into its own source files.
    
    Eventually, drmmode_display will be able to use GBM for handling
    buffers, and won't need dumb_bo.  Keeping the display related logic
    and buffer object abstraction in separate files seems a bit tidier.
    
    Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
    Tested-by: Jason Ekstrand <jason.ekstrand at intel.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/Makefile.am b/hw/xfree86/drivers/modesetting/Makefile.am
index 5b08600..921ca00 100644
--- a/hw/xfree86/drivers/modesetting/Makefile.am
+++ b/hw/xfree86/drivers/modesetting/Makefile.am
@@ -48,6 +48,8 @@ modesetting_drv_la_SOURCES = \
 	 driver.h \
 	 drmmode_display.c \
 	 drmmode_display.h \
+	 dumb_bo.c \
+	 dumb_bo.h \
 	 vblank.c \
 	 $(NULL)
 
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 6f6eaf3..277f60c 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -33,6 +33,7 @@
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <unistd.h>
+#include "dumb_bo.h"
 #include "xf86str.h"
 #include "X11/Xatom.h"
 #include "micmap.h"
@@ -54,114 +55,6 @@
 #include "glamor.h"
 #endif
 
-static struct dumb_bo *
-dumb_bo_create(int fd,
-               const unsigned width, const unsigned height, const unsigned bpp)
-{
-    struct drm_mode_create_dumb arg;
-    struct dumb_bo *bo;
-    int ret;
-
-    bo = calloc(1, sizeof(*bo));
-    if (!bo)
-        return NULL;
-
-    memset(&arg, 0, sizeof(arg));
-    arg.width = width;
-    arg.height = height;
-    arg.bpp = bpp;
-
-    ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
-    if (ret)
-        goto err_free;
-
-    bo->handle = arg.handle;
-    bo->size = arg.size;
-    bo->pitch = arg.pitch;
-
-    return bo;
- err_free:
-    free(bo);
-    return NULL;
-}
-
-static int
-dumb_bo_map(int fd, struct dumb_bo *bo)
-{
-    struct drm_mode_map_dumb arg;
-    int ret;
-    void *map;
-
-    if (bo->ptr) {
-        bo->map_count++;
-        return 0;
-    }
-
-    memset(&arg, 0, sizeof(arg));
-    arg.handle = bo->handle;
-
-    ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
-    if (ret)
-        return ret;
-
-    map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, arg.offset);
-    if (map == MAP_FAILED)
-        return -errno;
-
-    bo->ptr = map;
-    return 0;
-}
-
-#if 0
-static int
-dumb_bo_unmap(int fd, struct dumb_bo *bo)
-{
-    bo->map_count--;
-    return 0;
-}
-#endif
-
-int
-dumb_bo_destroy(int fd, struct dumb_bo *bo)
-{
-    struct drm_mode_destroy_dumb arg;
-    int ret;
-
-    if (bo->ptr) {
-        munmap(bo->ptr, bo->size);
-        bo->ptr = NULL;
-    }
-
-    memset(&arg, 0, sizeof(arg));
-    arg.handle = bo->handle;
-    ret = drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg);
-    if (ret)
-        return -errno;
-
-    free(bo);
-    return 0;
-}
-
-struct dumb_bo *
-dumb_get_bo_from_fd(int fd, int handle, int pitch, int size)
-{
-    struct dumb_bo *bo;
-    int ret;
-
-    bo = calloc(1, sizeof(*bo));
-    if (!bo)
-        return NULL;
-
-    ret = drmPrimeFDToHandle(fd, handle, &bo->handle);
-    if (ret) {
-        free(bo);
-        return NULL;
-    }
-    bo->pitch = pitch;
-    bo->size = size;
-    return bo;
-}
-
 Bool
 drmmode_SetSlaveBO(PixmapPtr ppix,
                    drmmode_ptr drmmode, int fd_handle, int pitch, int size)
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index a8df7ca..abb93ec 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -32,13 +32,7 @@
 #include "libudev.h"
 #endif
 
-struct dumb_bo {
-    uint32_t handle;
-    uint32_t size;
-    void *ptr;
-    int map_count;
-    uint32_t pitch;
-};
+#include "dumb_bo.h"
 
 typedef struct {
     int fd;
@@ -149,8 +143,6 @@ Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode,
                              int *depth, int *bpp);
-struct dumb_bo *dumb_get_bo_from_fd(int drm_fd, int fd, int pitch, int size);
-int dumb_bo_destroy(int fd, struct dumb_bo *bo);
 
 
 #ifndef DRM_CAP_DUMB_PREFERRED_DEPTH
diff --git a/hw/xfree86/drivers/modesetting/dumb_bo.c b/hw/xfree86/drivers/modesetting/dumb_bo.c
new file mode 100644
index 0000000..9a69aa2
--- /dev/null
+++ b/hw/xfree86/drivers/modesetting/dumb_bo.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Authors:
+ *    Dave Airlie <airlied at redhat.com>
+ *
+ */
+
+#include "dumb_bo.h"
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <xf86drm.h>
+
+struct dumb_bo *
+dumb_bo_create(int fd,
+               const unsigned width, const unsigned height, const unsigned bpp)
+{
+    struct drm_mode_create_dumb arg;
+    struct dumb_bo *bo;
+    int ret;
+
+    bo = calloc(1, sizeof(*bo));
+    if (!bo)
+        return NULL;
+
+    memset(&arg, 0, sizeof(arg));
+    arg.width = width;
+    arg.height = height;
+    arg.bpp = bpp;
+
+    ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
+    if (ret)
+        goto err_free;
+
+    bo->handle = arg.handle;
+    bo->size = arg.size;
+    bo->pitch = arg.pitch;
+
+    return bo;
+ err_free:
+    free(bo);
+    return NULL;
+}
+
+int
+dumb_bo_map(int fd, struct dumb_bo *bo)
+{
+    struct drm_mode_map_dumb arg;
+    int ret;
+    void *map;
+
+    if (bo->ptr) {
+        bo->map_count++;
+        return 0;
+    }
+
+    memset(&arg, 0, sizeof(arg));
+    arg.handle = bo->handle;
+
+    ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
+    if (ret)
+        return ret;
+
+    map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, arg.offset);
+    if (map == MAP_FAILED)
+        return -errno;
+
+    bo->ptr = map;
+    return 0;
+}
+
+#if 0
+static int
+dumb_bo_unmap(int fd, struct dumb_bo *bo)
+{
+    bo->map_count--;
+    return 0;
+}
+#endif
+
+int
+dumb_bo_destroy(int fd, struct dumb_bo *bo)
+{
+    struct drm_mode_destroy_dumb arg;
+    int ret;
+
+    if (bo->ptr) {
+        munmap(bo->ptr, bo->size);
+        bo->ptr = NULL;
+    }
+
+    memset(&arg, 0, sizeof(arg));
+    arg.handle = bo->handle;
+    ret = drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg);
+    if (ret)
+        return -errno;
+
+    free(bo);
+    return 0;
+}
+
+struct dumb_bo *
+dumb_get_bo_from_fd(int fd, int handle, int pitch, int size)
+{
+    struct dumb_bo *bo;
+    int ret;
+
+    bo = calloc(1, sizeof(*bo));
+    if (!bo)
+        return NULL;
+
+    ret = drmPrimeFDToHandle(fd, handle, &bo->handle);
+    if (ret) {
+        free(bo);
+        return NULL;
+    }
+    bo->pitch = pitch;
+    bo->size = size;
+    return bo;
+}
diff --git a/hw/xfree86/drivers/modesetting/dumb_bo.h b/hw/xfree86/drivers/modesetting/dumb_bo.h
new file mode 100644
index 0000000..1d401d4
--- /dev/null
+++ b/hw/xfree86/drivers/modesetting/dumb_bo.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2007 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Authors:
+ *     Dave Airlie <airlied at redhat.com>
+ *
+ */
+#ifndef DUMB_BO_H
+#define DUMB_BO_H
+
+#include <stdint.h>
+
+struct dumb_bo {
+    uint32_t handle;
+    uint32_t size;
+    void *ptr;
+    int map_count;
+    uint32_t pitch;
+};
+
+struct dumb_bo *dumb_bo_create(int fd, const unsigned width,
+                               const unsigned height, const unsigned bpp);
+int dumb_bo_map(int fd, struct dumb_bo *bo);
+int dumb_bo_destroy(int fd, struct dumb_bo *bo);
+struct dumb_bo *dumb_get_bo_from_fd(int fd, int handle, int pitch, int size);
+
+#endif
commit af4f94b08eb8e5961799a8a74a06449fd3fe8ad9
Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue Dec 9 15:18:39 2014 -0800

    modesetting: Create helper for glamor_egl_create_textured_screen call.
    
    This will need to change when we add GBM support; by pulling it into a
    helper function, we should only have to edit one place.
    
    Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
    Tested-by: Jason Ekstrand <jason.ekstrand at intel.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index 06b0f21..61c8032 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -886,18 +886,8 @@ CreateScreenResources(ScreenPtr pScreen)
     if (!drmmode_set_desired_modes(pScrn, &ms->drmmode))
         return FALSE;
 
-#ifdef GLAMOR
-    if (ms->drmmode.glamor) {
-        if (!glamor_egl_create_textured_screen(pScreen,
-                                               ms->drmmode.front_bo->handle,
-                                               pScrn->displayWidth *
-                                               pScrn->bitsPerPixel / 8)) {
-            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-                       "glamor_egl_create_textured_screen() failed\n");
-            return FALSE;
-        }
-    }
-#endif
+    if (!drmmode_glamor_handle_new_screen_pixmap(&ms->drmmode))
+        return FALSE;
 
     drmmode_uevent_init(pScrn, &ms->drmmode);
 
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index f88148d..6f6eaf3 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -1176,6 +1176,29 @@ drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
     }
 }
 
+Bool
+drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode)
+{
+#ifdef GLAMOR
+    ScrnInfoPtr scrn = drmmode->scrn;
+    ScreenPtr screen = xf86ScrnToScreen(drmmode->scrn);
+
+    if (!drmmode->glamor)
+        return TRUE;
+
+    if (!glamor_egl_create_textured_screen(screen,
+                                           drmmode->front_bo->handle,
+                                           scrn->displayWidth *
+                                           scrn->bitsPerPixel / 8)) {
+        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                   "glamor_egl_create_textured_screen() failed\n");
+        return FALSE;
+    }
+#endif
+
+    return TRUE;
+}
+
 static Bool
 drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 {
@@ -1243,18 +1266,8 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 
     screen->ModifyPixmapHeader(ppix, width, height, -1, -1, pitch, new_pixels);
 
-#ifdef GLAMOR
-    if (drmmode->glamor) {
-        if (!glamor_egl_create_textured_screen(screen,
-                                               drmmode->front_bo->handle,
-                                               scrn->displayWidth *
-                                               scrn->bitsPerPixel / 8)) {
-            xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-                       "glamor_egl_create_textured_screen() failed\n");
-            goto fail;
-        }
-    }
-#endif
+    if (!drmmode_glamor_handle_new_screen_pixmap(drmmode))
+        goto fail;
 
     for (i = 0; i < xf86_config->num_crtc; i++) {
         xf86CrtcPtr crtc = xf86_config->crtc[i];
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index 92e2816..a8df7ca 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -129,6 +129,7 @@ extern DevPrivateKeyRec msPixmapPrivateKeyRec;
 
 #define msGetPixmapPriv(drmmode, p) ((msPixmapPrivPtr)dixGetPrivateAddr(&(p)->devPrivates, &(drmmode)->pixmapPrivateKeyRec))
 
+Bool drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode);
 void *drmmode_map_slave_bo(drmmode_ptr drmmode, msPixmapPrivPtr ppriv);
 Bool drmmode_SetSlaveBO(PixmapPtr ppix,
                         drmmode_ptr drmmode,
commit b4324c6a2382dc96295bdb061316f699e4ffabb9
Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue Dec 9 14:38:39 2014 -0800

    modesetting: Move ModifyPixmapHeader calls out of if/else branches.
    
    Both branches called ModifyPixmapHeader with essentially the same
    parameters.  By using new_pixels in the shadowfb case, we can make
    them completely the same, and move them out a level, for simplicity.
    
    Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
    Tested-by: Jason Ekstrand <jason.ekstrand at intel.com>
    Reviewed-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 fddbaff..f88148d 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -1231,22 +1231,18 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
     if (!new_pixels)
         goto fail;
 
-    if (!drmmode->shadow_enable)
-        screen->ModifyPixmapHeader(ppix, width, height, -1, -1,
-                                   pitch, new_pixels);
-    else {
-        void *new_shadow;
+    if (drmmode->shadow_enable) {
         uint32_t size = scrn->displayWidth * scrn->virtualY *
             ((scrn->bitsPerPixel + 7) >> 3);
-        new_shadow = calloc(1, size);
-        if (new_shadow == NULL)
+        new_pixels = calloc(1, size);
+        if (new_pixels == NULL)
             goto fail;
         free(drmmode->shadow_fb);
-        drmmode->shadow_fb = new_shadow;
-        screen->ModifyPixmapHeader(ppix, width, height, -1, -1,
-                                   pitch, drmmode->shadow_fb);
+        drmmode->shadow_fb = new_pixels;
     }
 
+    screen->ModifyPixmapHeader(ppix, width, height, -1, -1, pitch, new_pixels);
+
 #ifdef GLAMOR
     if (drmmode->glamor) {
         if (!glamor_egl_create_textured_screen(screen,
commit 35e9924484ec7bafb749c88ed7f78e6a71f8dfb3
Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue Dec 9 13:01:09 2014 -0800

    modesetting: Stop using glamor_egl_create_textured_screen_ext().
    
    The _ext variant takes an additional pointer argument, which it now
    ignores, thanks to Keith's recent patches.
    
    Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
    Tested-by: Jason Ekstrand <jason.ekstrand at intel.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index d1284c6..06b0f21 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -888,13 +888,12 @@ CreateScreenResources(ScreenPtr pScreen)
 
 #ifdef GLAMOR
     if (ms->drmmode.glamor) {
-        if (!glamor_egl_create_textured_screen_ext(pScreen,
-                                                   ms->drmmode.front_bo->handle,
-                                                   pScrn->displayWidth *
-                                                   pScrn->bitsPerPixel / 8,
-                                                   NULL)) {
+        if (!glamor_egl_create_textured_screen(pScreen,
+                                               ms->drmmode.front_bo->handle,
+                                               pScrn->displayWidth *
+                                               pScrn->bitsPerPixel / 8)) {
             xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-                       "glamor_egl_create_textured_screen_ext() failed\n");
+                       "glamor_egl_create_textured_screen() failed\n");
             return FALSE;
         }
     }
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index d5b7d00..fddbaff 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -1249,13 +1249,12 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 
 #ifdef GLAMOR
     if (drmmode->glamor) {
-        if (!glamor_egl_create_textured_screen_ext(screen,
-                                                   drmmode->front_bo->handle,
-                                                   scrn->displayWidth *
-                                                   scrn->bitsPerPixel / 8,
-                                                   NULL)) {
+        if (!glamor_egl_create_textured_screen(screen,
+                                               drmmode->front_bo->handle,
+                                               scrn->displayWidth *
+                                               scrn->bitsPerPixel / 8)) {
             xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-                       "glamor_egl_create_textured_screen_ext() failed\n");
+                       "glamor_egl_create_textured_screen() failed\n");
             goto fail;
         }
     }


More information about the xorg-commit mailing list