xf86-video-intel: Branch 'modesetting-gem' - 4 commits - src/drmmode_display.c src/i830_batchbuffer.h src/i830_driver.c src/i830_exa.c src/i830.h src/i965_render.c

Jesse Barnes jbarnes at kemper.freedesktop.org
Thu Aug 14 15:48:34 PDT 2008


 src/drmmode_display.c  |   11 ++++-------
 src/i830.h             |    5 ++++-
 src/i830_batchbuffer.h |    6 +++---
 src/i830_driver.c      |   14 +++++++++++++-
 src/i830_exa.c         |   24 ++++++++++++++++++------
 src/i965_render.c      |   22 ++++++++++++++++------
 6 files changed, 58 insertions(+), 24 deletions(-)

New commits:
commit c1687f9ca9ce7b52043272e877e070c810e6599f
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Thu Aug 14 15:48:02 2008 -0700

    Map/unmap render state only when bo is available
    
    Otherwise just use the GTT address.

diff --git a/src/i965_render.c b/src/i965_render.c
index bd693ca..a4334c6 100644
--- a/src/i965_render.c
+++ b/src/i965_render.c
@@ -1441,6 +1441,7 @@ gen4_render_state_init(ScrnInfoPtr pScrn)
 {
     I830Ptr pI830 = I830PTR(pScrn);
     struct gen4_render_state *render_state;
+    int ret;
 
     if (pI830->gen4_render_state == NULL)
 	pI830->gen4_render_state = calloc(sizeof(*render_state), 1);
@@ -1449,12 +1450,19 @@ gen4_render_state_init(ScrnInfoPtr pScrn)
 
     render_state->card_state_offset = pI830->gen4_render_state_mem->offset;
 
-    if (dri_bo_map(pI830->gen4_render_state_mem->bo, 1)) {
-	xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Failed to map gen4 state\n");
-	return;
+    if (pI830->gen4_render_state_mem->bo) {
+	ret = dri_bo_map(pI830->gen4_render_state_mem->bo, 1);
+	if (ret) {
+	    xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+		       "Failed to map gen4 state\n");
+	    return;
+	}
+	render_state->card_state = pI830->gen4_render_state_mem->bo->virtual;
+    } else {
+	render_state->card_state = (gen4_state_t *)
+	    (pI830->FbBase + render_state->card_state_offset);
     }
 
-    render_state->card_state = pI830->gen4_render_state_mem->bo->virtual;
     gen4_state_init(render_state);
 }
 
@@ -1466,8 +1474,10 @@ gen4_render_state_cleanup(ScrnInfoPtr pScrn)
 {
     I830Ptr pI830 = I830PTR(pScrn);
 
-    dri_bo_unmap(pI830->gen4_render_state_mem->bo);
-    dri_bo_unreference(pI830->gen4_render_state_mem->bo);
+    if (pI830->gen4_render_state_mem->bo) {
+	dri_bo_unmap(pI830->gen4_render_state_mem->bo);
+	dri_bo_unreference(pI830->gen4_render_state_mem->bo);
+    }
     pI830->gen4_render_state->card_state = NULL;
 }
 
commit 380c80712f78b3673b64ea07746a8e25e15fba8e
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Thu Aug 14 15:39:57 2008 -0700

    Fixup AccelMethod kernel mode setting code
    
    Allow UXA or EXA in the kernel mode setting case, defaulting to EXA.

diff --git a/src/i830_driver.c b/src/i830_driver.c
index 3ad811e..289f8b8 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1648,6 +1648,19 @@ I830DrmModeInit(ScrnInfoPtr pScrn)
 #ifdef XF86DRM_MODE
     I830Ptr pI830 = I830PTR(pScrn);
     char *bus_id;
+    char *s;
+
+    /* Default to EXA but allow override */
+    pI830->accel = ACCEL_EXA;
+
+    if ((s = (char *)xf86GetOptValString(pI830->Options, OPTION_ACCELMETHOD))) {
+	if (!xf86NameCmp(s, "EXA"))
+	    pI830->accel = ACCEL_EXA;
+	else if (!xf86NameCmp(s, "UXA"))
+	    pI830->accel = ACCEL_UXA;
+	else
+	    pI830->accel = ACCEL_EXA;
+    }
 
     bus_id = DRICreatePCIBusID(pI830->PciInfo);
     if (drmmode_pre_init(pScrn, &pI830->drmmode, bus_id, "i915",
@@ -1664,7 +1677,6 @@ I830DrmModeInit(ScrnInfoPtr pScrn)
     pI830->drmSubFD = pI830->drmmode.fd;
     xfree(bus_id);
 
-    pI830->accel = ACCEL_EXA;
     pI830->directRenderingDisabled = FALSE;
     pI830->allocate_classic_textures = FALSE;
 
commit 4475dfb541c988ad19b177e60f31f333e2fb3355
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Thu Aug 14 15:38:07 2008 -0700

    Use pwrite for cursor updates
    
    Don't open code map/memcpy/unmap, let libdrm do that for us if necessary.

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index a65e948..5154b42 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -216,16 +216,13 @@ drmmode_load_cursor_argb (xf86CrtcPtr crtc, CARD32 *image)
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 	ScrnInfoPtr pScrn = crtc->scrn;
 	I830Ptr pI830 = I830PTR(pScrn);
-	void *ptr;
+	int ret;
 
 	/* cursor should be mapped already */
-	if (dri_bo_map(pI830->cursor_mem->bo, 1))
+	ret = dri_bo_subdata(pI830->cursor_mem->bo, 0, 64*64*4, image);
+	if (ret)
 		xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR,
-			   "failed to map cursor");
-
-	ptr = pI830->cursor_mem->bo->virtual;
-
-	memcpy (ptr, image, 64 * 64 * 4);
+			   "failed to set cursor: %s", strerror(-ret));
 
 	return;
 }
commit cb217d4bfd941d0fa9ceae3e483dd1ca1d768e86
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Wed Aug 13 16:55:39 2008 -0700

    Make EXA & UXA share bo getting function
    
    Needed for proper acceleration & batch buffer handling.

diff --git a/src/i830.h b/src/i830.h
index 3ae9e89..612c6a9 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -92,11 +92,14 @@ unsigned long long I830TexOffsetStart(PixmapPtr pPix);
 #ifdef I830_USE_UXA
 #include "uxa.h"
 Bool i830_uxa_init(ScreenPtr pScreen);
-dri_bo *i830_uxa_get_pixmap_bo (PixmapPtr pixmap);
 void i830_uxa_create_screen_resources(ScreenPtr pScreen);
 void i830_uxa_block_handler (ScreenPtr pScreen);
 #endif
 
+#if defined(I830_USE_UXA) || defined(I830_USE_EXA)
+dri_bo *i830_get_pixmap_bo (PixmapPtr pixmap);
+#endif
+
 #ifdef I830_USE_XAA
 Bool I830XAAInit(ScreenPtr pScreen);
 #endif
diff --git a/src/i830_batchbuffer.h b/src/i830_batchbuffer.h
index 4c1198d..2a23cae 100644
--- a/src/i830_batchbuffer.h
+++ b/src/i830_batchbuffer.h
@@ -78,13 +78,13 @@ intel_batch_emit_reloc_pixmap(I830Ptr pI830, PixmapPtr pPixmap,
 			      uint32_t read_domains, uint32_t write_domain,
 			      uint32_t delta)
 {
-#if I830_USE_UXA
-    dri_bo *bo = i830_uxa_get_pixmap_bo(pPixmap);
+#if I830_USE_UXA || I830_USE_EXA
+    dri_bo *bo = i830_get_pixmap_bo(pPixmap);
 #endif
     uint32_t offset;
     assert(pI830->batch_ptr != NULL);
     assert(intel_batch_space(pI830) >= 4);
-#if I830_USE_UXA
+#if I830_USE_UXA || I830_USE_EXA
     if (bo) {
 	intel_batch_emit_reloc(pI830, bo, read_domains, write_domain, delta);
 	return;
diff --git a/src/i830_exa.c b/src/i830_exa.c
index 504bfc1..e59ceaa 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -735,15 +735,27 @@ i830_uxa_set_pixmap_bo (PixmapPtr pixmap, dri_bo *bo)
 }
 
 dri_bo *
-i830_uxa_get_pixmap_bo (PixmapPtr pixmap)
+i830_get_pixmap_bo(PixmapPtr pixmap)
 {
-    return dixLookupPrivate(&pixmap->devPrivates, uxa_pixmap_key);
+    ScreenPtr screen = pixmap->drawable.pScreen;
+    ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+    I830Ptr i830 = I830PTR(scrn);
+
+    if (i830->accel == ACCEL_UXA) {
+	return dixLookupPrivate(&pixmap->devPrivates, uxa_pixmap_key);
+    } else if (i830->accel == ACCEL_EXA) {
+	struct i830_exa_pixmap_priv *driver_priv =
+	    exaGetPixmapDriverPrivate(pixmap);
+	return driver_priv ? driver_priv->bo : NULL;
+    }
+
+    return NULL;
 }
 
 static Bool
 i830_uxa_prepare_access (PixmapPtr pixmap, uxa_access_t access)
 {
-    dri_bo *bo = i830_uxa_get_pixmap_bo (pixmap);
+    dri_bo *bo = i830_get_pixmap_bo (pixmap);
 
     if (bo) {
 	ScreenPtr screen = pixmap->drawable.pScreen;
@@ -765,7 +777,7 @@ i830_uxa_prepare_access (PixmapPtr pixmap, uxa_access_t access)
 static void
 i830_uxa_finish_access (PixmapPtr pixmap)
 {
-    dri_bo *bo = i830_uxa_get_pixmap_bo (pixmap);
+    dri_bo *bo = i830_get_pixmap_bo (pixmap);
 
     if (bo) {
 	ScreenPtr screen = pixmap->drawable.pScreen;
@@ -794,7 +806,7 @@ i830_uxa_block_handler (ScreenPtr screen)
 static Bool
 i830_uxa_pixmap_is_offscreen(PixmapPtr pixmap)
 {
-    return i830_uxa_get_pixmap_bo (pixmap) != NULL;
+    return i830_get_pixmap_bo (pixmap) != NULL;
 }
 
 static PixmapPtr
@@ -835,7 +847,7 @@ static Bool
 i830_uxa_destroy_pixmap (PixmapPtr pixmap)
 {
     if (pixmap->refcnt == 1) {
-	dri_bo  *bo = i830_uxa_get_pixmap_bo (pixmap);
+	dri_bo  *bo = i830_get_pixmap_bo (pixmap);
     
 	if (bo)
 	    dri_bo_unreference (bo);


More information about the xorg-commit mailing list