[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-video-intel: Changes to 'upstream-unstable'



Rebased ref, commits from common ancestor:
commit f04552cdbcb110c876816dfda577803e6c92fb6a
Author: Eric Anholt <eric@anholt.net>
Date:   Mon Mar 2 11:18:27 2009 -0800

    Bump version to 2.6.3.

diff --git a/configure.ac b/configure.ac
index 13d7468..be4a25f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-video-intel],
-        2.6.2,
+        2.6.3,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-video-intel)
 

commit c0d91bd3ffea329058b63e648d2eae05edd9ad8a
Author: Eric Anholt <eric@anholt.net>
Date:   Mon Mar 2 11:17:27 2009 -0800

    Only allocate pixmaps aligned for tiling when requested by DRI2 GetBuffers.
    
    This saves massive quantities of memory on pre-965 since the DRI2 tiling
    enable caused the minimum size of any pixmap to be 1MB.
    (cherry picked from commit 5bfd73cd31ba197a62f549cdbad1a1270b571027)

diff --git a/src/i830.h b/src/i830.h
index 6a5b7ed..55b1681 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -1095,4 +1095,15 @@ extern const int I830CopyROP[16];
 #define QUIRK_IGNORE_CRT		0x00000080
 extern void i830_fixup_devices(ScrnInfoPtr);
 
+/**
+ * Hints to CreatePixmap to tell the driver how the pixmap is going to be
+ * used.
+ *
+ * Compare to CREATE_PIXMAP_USAGE_* in the server.
+ */
+enum {
+    INTEL_CREATE_PIXMAP_TILING_X = 0x10000000,
+    INTEL_CREATE_PIXMAP_TILING_Y,
+};
+
 #endif /* _I830_H_ */
diff --git a/src/i830_dri.c b/src/i830_dri.c
index 0b15656..bc8d646 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1862,36 +1862,33 @@ I830DRI2CreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
 	    pPixmap = pDepthPixmap;
 	    pPixmap->refcnt++;
 	} else {
-	    uint32_t tiling = I915_TILING_NONE;
+	    unsigned int hint = 0;
 
-	    pPixmap = (*pScreen->CreatePixmap)(pScreen,
-					       pDraw->width,
-					       pDraw->height,
-					       pDraw->depth, 0);
 	    switch (attachments[i]) {
 	    case DRI2BufferDepth:
 		if (SUPPORTS_YTILING(pI830))
-		    tiling = I915_TILING_Y;
+		    hint = INTEL_CREATE_PIXMAP_TILING_Y;
 		else
-		    tiling = I915_TILING_X;
+		    hint = INTEL_CREATE_PIXMAP_TILING_X;
 		break;
 	    case DRI2BufferFakeFrontLeft:
 	    case DRI2BufferFakeFrontRight:
 	    case DRI2BufferBackLeft:
 	    case DRI2BufferBackRight:
-		    tiling = I915_TILING_X;
+		    hint = INTEL_CREATE_PIXMAP_TILING_X;
 		break;
 	    }
 
 	    if (!pI830->tiling ||
 		(!IS_I965G(pI830) && !pI830->kernel_exec_fencing))
-		tiling = I915_TILING_NONE;
+		hint = 0;
+
+	    pPixmap = (*pScreen->CreatePixmap)(pScreen,
+					       pDraw->width,
+					       pDraw->height,
+					       pDraw->depth,
+					       hint);
 
-	    if (tiling != I915_TILING_NONE) {
-		bo = i830_get_pixmap_bo(pPixmap);
-		drm_intel_bo_set_tiling(bo, &tiling,
-					intel_get_pixmap_pitch(pPixmap));
-	    }
 	}
 
 	if (attachments[i] == DRI2BufferDepth)
diff --git a/src/i830_exa.c b/src/i830_exa.c
index e61f661..85d884f 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -883,29 +883,38 @@ i830_uxa_create_pixmap (ScreenPtr screen, int w, int h, int depth, unsigned usag
     if (w && h)
     {
 	unsigned int size;
+	uint32_t tiling = I915_TILING_NONE;
 
 	stride = ROUND_TO((w * pixmap->drawable.bitsPerPixel + 7) / 8,
 			  i830->accel_pixmap_pitch_alignment);
 
-	/* Use the I915_FENCE_TILING_X even if it may end up being TILING_Y,
-	 * as it just results in larger alignment.  Really, we need to use the
-	 * usage hint to tell what the pixmap's going to be.
-	 */
-	stride = i830_get_fence_pitch(i830, stride, I915_TILING_X);
-	/* Round the object up to the size of the fence it will live in
-	 * if necessary.  We could potentially make the kernel allocate
-	 * a larger aperture space and just bind the subset of pages in,
-	 * but this is easier and also keeps us out of trouble (as much)
-	 * with drm_intel_bufmgr_check_aperture().
-	 */
-	size = i830_get_fence_size(i830, stride * h);
+	if (usage == INTEL_CREATE_PIXMAP_TILING_X)
+	    tiling = I915_TILING_X;
+	else if (usage == INTEL_CREATE_PIXMAP_TILING_Y)
+	    tiling = I915_TILING_Y;
+
+	if (tiling == I915_TILING_NONE) {
+	    size = stride * h;
+	} else {
+	    stride = i830_get_fence_pitch(i830, stride, tiling);
+	    /* Round the object up to the size of the fence it will live in
+	     * if necessary.  We could potentially make the kernel allocate
+	     * a larger aperture space and just bind the subset of pages in,
+	     * but this is easier and also keeps us out of trouble (as much)
+	     * with drm_intel_bufmgr_check_aperture().
+	     */
+	    size = i830_get_fence_size(i830, stride * h);
+	}
 
 	bo = drm_intel_bo_alloc_for_render(i830->bufmgr, "pixmap", size, 0);
 	if (!bo) {
 	    fbDestroyPixmap (pixmap);
 	    return NullPixmap;
 	}
-	
+
+	if (tiling != I915_TILING_NONE)
+	    drm_intel_bo_set_tiling(bo, &tiling, stride);
+
 	screen->ModifyPixmapHeader (pixmap, w, h, 0, 0, stride, NULL);
     
 	i830_uxa_set_pixmap_bo (pixmap, bo);

commit 5441be42649e4f969ac16c323de2fb5ed93b271a
Author: Eric Anholt <eric@anholt.net>
Date:   Tue Feb 24 20:54:05 2009 -0800

    Disable fb resizing for DRI1-only server so that DRI1 can initialize.
    (cherry picked from commit 70e0261208654c6c875ad462da2734c6aa9eeb96)

diff --git a/src/i830_driver.c b/src/i830_driver.c
index 5a31e82..fbe5934 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1694,6 +1694,10 @@ I830AccelMethodInit(ScrnInfoPtr pScrn)
     pI830->can_resize = FALSE;
     if (pI830->accel == ACCEL_UXA && pI830->directRenderingType != DRI_XF86DRI)
 	pI830->can_resize = TRUE;
+#if !defined(DRI2) && defined(XF86DRI)
+    /* Disable resizing so that DRI1 can initialize and give us GEM support. */
+    pI830->can_resize = FALSE;
+#endif
 
     xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 	       "Resizable framebuffer: %s (%d %d)\n",

commit 93ae6c7f8cadb60d479e626ddd2a67d7cb2cc4c0
Author: Eric Anholt <eric@anholt.net>
Date:   Tue Feb 24 13:59:17 2009 -0800

    Bump version to 2.6.2 for release.

diff --git a/configure.ac b/configure.ac
index 4d40427..13d7468 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-video-intel],
-        2.6.1,
+        2.6.2,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-video-intel)
 

commit 626a54870fd3c5038c7bdae5d9085fe98f73885b
Author: Eric Anholt <eric@anholt.net>
Date:   Tue Feb 24 14:05:15 2009 -0800

    Fix distcheck from drmmode_display.h deletion.
    (cherry picked from commit 9d8e5c21a1688b915bf39261d4c3b0bf2906daef)

diff --git a/src/Makefile.am b/src/Makefile.am
index 3fb30ff..cbe9fb1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -136,8 +136,7 @@ intel_drv_la_SOURCES = \
 	 i830_render.c \
 	 i915_render.c \
 	 i965_render.c \
-	 drmmode_display.c \
-	 drmmode_display.h
+	 drmmode_display.c
 
 INTEL_G4A =				\
 	packed_yuv_sf.g4a		\

commit aa6997ecd5383ee94c8ac9cfca4a1b58820e098c
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Tue Feb 24 13:58:20 2009 -0500

    Update kms to work with drmModeModeInfo API update.
    (cherry picked from commit a6b31f38ebf470c61de0e10b0ce2af0d7ee1684b)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index f0e4f1e..8128004 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -61,7 +61,7 @@ typedef struct {
 
 static void
 drmmode_ConvertFromKMode(ScrnInfoPtr scrn,
-			 struct drm_mode_modeinfo *kmode,
+			 drmModeModeInfoPtr kmode,
 			 DisplayModePtr	mode)
 {
 	memset(mode, 0, sizeof(DisplayModeRec));
@@ -93,7 +93,7 @@ drmmode_ConvertFromKMode(ScrnInfoPtr scrn,
 
 static void
 drmmode_ConvertToKMode(ScrnInfoPtr scrn,
-		       struct drm_mode_modeinfo *kmode,
+		       drmModeModeInfoPtr kmode,
 		       DisplayModePtr mode)
 {
 	memset(kmode, 0, sizeof(*kmode));
@@ -141,7 +141,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 	int ret = TRUE;
 	int i;
 	int fb_id;
-	struct drm_mode_modeinfo kmode;
+	drmModeModeInfo kmode;
 	unsigned int pitch = pScrn->displayWidth * pI830->cpp;
 
 	if (drmmode->fb_id == 0) {

commit 97b3ab47c6eec98baf7566e7290c6030934ad956
Author: Eric Anholt <eric@anholt.net>
Date:   Sat Feb 21 20:36:58 2009 -0800

    Don't do AdjustFrame in KMS mode.
    
    This was hit by xv86vm's SwitchMode path, and for that the CRTC offsets
    get set at mode setting time anyway.
    (cherry picked from commit 53108994616d9751ac3a29fd61eb269cfaeab967)

diff --git a/src/i830_driver.c b/src/i830_driver.c
index cd00a71..5a31e82 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -3535,6 +3535,9 @@ i830AdjustFrame(int scrnIndex, int x, int y, int flags)
    DPRINTF(PFX, "i830AdjustFrame: y = %d (+ %d), x = %d (+ %d)\n",
 	   x, pI830->xoffset, y, pI830->yoffset);
 
+   if (pI830->use_drm_mode)
+      return;
+
    if (crtc && crtc->enabled)
    {
       /* Sync the engine before adjust frame */

commit f3f21a0e45060aa7b333e026938325af133b014c
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Mon Feb 23 15:16:51 2009 -0500

    KMS: Fix bug that prevented EDID data from getting propagated.
    (cherry picked from commit 73bc7f113969834d00cd92be8374dbadc62f96a9)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 0ae7d34..f0e4f1e 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -460,7 +460,8 @@ drmmode_output_get_modes(xf86OutputPtr output)
 		if (!props || !(props->flags & DRM_MODE_PROP_BLOB))
 			continue;
 
-		if (!strcmp(props->name, "EDID") && drmmode_output->edid_blob) {
+		if (!strcmp(props->name, "EDID") &&
+		    drmmode_output->edid_blob == NULL) {
 			drmModeFreePropertyBlob(drmmode_output->edid_blob);
 			drmmode_output->edid_blob =
 				drmModeGetPropertyBlob(drmmode->fd,

commit 3baf4cf7deedf2e0df13bf07cd0f329cfc7911f5
Author: Helge Bahmann <helge.bahmann@secunet.com>
Date:   Sat Feb 21 10:10:04 2009 -0800

    Move disable_render_standby to EnterVT instead of startup.
    
    Otherwise, with a pre-2.6.28 older kernel the disable would be lost at
    resume time and cause hangs.
    
    Bug #20214
    (cherry picked from commit 81c652e9a666a7459bcc5217c8a5ec518b6e00da)

diff --git a/src/i830_driver.c b/src/i830_driver.c
index ac4257e..cd00a71 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -3351,9 +3351,6 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 	   return FALSE;
    }
 
-   if (!pI830->use_drm_mode)
-       i830_disable_render_standby(pScrn);
-
    DPRINTF(PFX, "assert( if(!I830EnterVT(scrnIndex, 0)) )\n");
 
    if (pI830->accel <= ACCEL_XAA) {
@@ -3685,6 +3682,9 @@ I830EnterVT(int scrnIndex, int flags)
 
    pI830->leaving = FALSE;
 
+   if (!pI830->use_drm_mode)
+       i830_disable_render_standby(pScrn);
+
 #ifdef XF86DRI
    if (pI830->memory_manager && !pI830->use_drm_mode) {
       int ret;

commit 6314b9178a252292a79e21a64d47d740e23df28d
Author: Eric Anholt <eric@anholt.net>
Date:   Wed Feb 18 13:32:44 2009 -0800

    uxa: Ask for BOs ready for rendering for pixmaps.
    
    The assumption is that we're almost always accelerating our drawing to
    new pixmaps (fill, copy, etc.).
    (cherry picked from commit 0621ba12a3b694720e67a49b25ca52f0e09b3802)

diff --git a/configure.ac b/configure.ac
index 2958a0a..4d40427 100644
--- a/configure.ac
+++ b/configure.ac
@@ -209,7 +209,7 @@ if test "x$GCC" = "xyes"; then
 	-Wnested-externs -fno-strict-aliasing"
 fi
 
-PKG_CHECK_MODULES(DRM, [libdrm >= 2.4.0])
+PKG_CHECK_MODULES(DRM, [libdrm >= 2.4.5])
 AM_CONDITIONAL(DRI, test x$DRI = xyes)
 if test "$DRI" = yes; then
         PKG_CHECK_MODULES(DRI, [xf86driproto glproto])
diff --git a/src/i830_exa.c b/src/i830_exa.c
index 28be786..e61f661 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -900,7 +900,7 @@ i830_uxa_create_pixmap (ScreenPtr screen, int w, int h, int depth, unsigned usag
 	 */
 	size = i830_get_fence_size(i830, stride * h);
 
-	bo = dri_bo_alloc (i830->bufmgr, "pixmap", size, 0);
+	bo = drm_intel_bo_alloc_for_render(i830->bufmgr, "pixmap", size, 0);
 	if (!bo) {
 	    fbDestroyPixmap (pixmap);
 	    return NullPixmap;

commit 36f3136933653ea80e72fcd3ce3c6c8fe2bf150a
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Fri Feb 20 15:34:29 2009 -0500

    KMS: Hook up rotated shadow buffers.
    (cherry picked from commit 5018d0f16cb8b44c743b5b37d194fe806d955568)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 66d6014..0ae7d34 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -48,7 +48,7 @@ typedef struct {
     drmModeCrtcPtr mode_crtc;
     dri_bo *cursor;
     dri_bo *rotate_bo;
-    int rotate_fb_id;
+    uint32_t rotate_fb_id;
 } drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
 
 typedef struct {
@@ -277,17 +277,19 @@ drmmode_show_cursor (xf86CrtcPtr crtc)
 static void *
 drmmode_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
 {
+	ScrnInfoPtr pScrn = crtc->scrn;
+	I830Ptr pI830 = I830PTR(pScrn);
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 	drmmode_ptr drmmode = drmmode_crtc->drmmode;
-	int size;
+	int size, ret;
 	unsigned long rotate_pitch;
 
-	rotate_pitch = crtc->scrn->displayWidth * drmmode->cpp;
+	width = i830_pad_drawable_width(width, drmmode->cpp);
+	rotate_pitch = width * drmmode->cpp;
 	size = rotate_pitch * height;
 
-#if 0
 	drmmode_crtc->rotate_bo =
-		dri_bo_alloc(drmmode->bufmgr, "rotate", size, 4096);
+		drm_intel_bo_alloc(pI830->bufmgr, "rotate", size, 4096);
 
 	if (!drmmode_crtc->rotate_bo) {
 		xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR,
@@ -295,18 +297,19 @@ drmmode_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
 		return NULL;
 	}
 
-	dri_bo_map(drmmode_crtc->rotate_bo, 1);
+	drm_intel_gem_bo_map_gtt(drmmode_crtc->rotate_bo);
 
 	ret = drmModeAddFB(drmmode->fd, width, height, crtc->scrn->depth,
 			   crtc->scrn->bitsPerPixel, rotate_pitch,
 			   drmmode_crtc->rotate_bo->handle,
 			   &drmmode_crtc->rotate_fb_id);
-	if (ret)
+	if (ret) {
 		ErrorF("failed to add rotate fb\n");
+		drm_intel_bo_unreference(drmmode_crtc->rotate_bo);
+		return NULL;
+	}
 
 	return drmmode_crtc->rotate_bo->virtual;
-#endif
-	return NULL;
 }
 
 static PixmapPtr
@@ -321,8 +324,8 @@ drmmode_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 	if (!data)
 		data = drmmode_crtc_shadow_allocate (crtc, width, height);
 
-	rotate_pitch = pScrn->displayWidth * drmmode->cpp;
-
+	rotate_pitch =
+		i830_pad_drawable_width(width, drmmode->cpp) * drmmode->cpp;
 	rotate_pixmap = GetScratchPixmapHeader(pScrn->pScreen,
 					       width, height,
 					       pScrn->depth,
@@ -334,27 +337,32 @@ drmmode_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 			   "Couldn't allocate shadow pixmap for rotated CRTC\n");
 	}
-	return rotate_pixmap;
 
+	if (drmmode_crtc->rotate_bo)
+		i830_set_pixmap_bo(rotate_pixmap, drmmode_crtc->rotate_bo);
+
+	return rotate_pixmap;
 }
 
 static void
 drmmode_crtc_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)
 		FreeScratchPixmapHeader(rotate_pixmap);
 
-#if 0
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
 	if (data) {
-		/* Be sure to sync acceleration before the memory gets unbound. */
+		/* Be sure to sync acceleration before the memory gets
+		 * unbound. */
 		drmModeRmFB(drmmode->fd, drmmode_crtc->rotate_fb_id);
 		drmmode_crtc->rotate_fb_id = 0;
+		drm_intel_bo_unmap(drmmode_crtc->rotate_bo);
 		dri_bo_unreference(drmmode_crtc->rotate_bo);
 		drmmode_crtc->rotate_bo = NULL;
 	}
-#endif
 }
 
 static void
@@ -376,17 +384,10 @@ static const xf86CrtcFuncsRec drmmode_crtc_funcs = {
 	.show_cursor = drmmode_show_cursor,
 	.hide_cursor = drmmode_hide_cursor,
 	.load_cursor_argb = drmmode_load_cursor_argb,
-
 	.shadow_create = drmmode_crtc_shadow_create,
 	.shadow_allocate = drmmode_crtc_shadow_allocate,
 	.shadow_destroy = drmmode_crtc_shadow_destroy,
 	.gamma_set = drmmode_crtc_gamma_set,
-#if 0
-	.shadow_create = i830_crtc_shadow_create,
-	.shadow_allocate = i830_crtc_shadow_allocate,
-	.shadow_destroy = i830_crtc_shadow_destroy,
-	.set_cursor_colors = i830_crtc_set_cursor_colors,
-#endif
 	.destroy = NULL, /* XXX */
 };
 
@@ -637,7 +638,8 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
 	scrn->virtualX = width;
 	scrn->virtualY = height;
 	scrn->displayWidth = pitch;
-	pI830->front_buffer = i830_allocate_framebuffer(scrn, pI830, &mem_box, FALSE);
+	pI830->front_buffer =
+		i830_allocate_framebuffer(scrn, pI830, &mem_box, FALSE);
 	if (!pI830->front_buffer)
 		goto fail;
 

commit 49093943d09a149e09639000da1ab18e2596c7c8
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Fri Feb 20 11:08:51 2009 -0500

    Access the Xv buffer through the GTT for the non-KMS case.
    (cherry picked from commit beca598bc2848093b710bd47828d622205d273df)

diff --git a/src/i830_video.c b/src/i830_video.c
index e542897..c9a0181 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -1271,7 +1271,8 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 		   int srcPitch,
 		   int dstPitch, int top, int left, int h, int w)
 {
-    unsigned char *src, *dst;
+    I830Ptr pI830 = I830PTR(pScrn);
+    unsigned char *src, *dst, *dst_base;
     int i,j;
     unsigned char *s;
 
@@ -1283,11 +1284,18 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 
     src = buf + (top * srcPitch) + (left << 1);
 
-    drm_intel_bo_map(pPriv->buf, TRUE);
+    if (pPriv->textured) {
+	drm_intel_bo_map(pPriv->buf, TRUE);
+	dst_base = pPriv->buf->virtual;
+    } else {
+	drm_intel_gem_bo_start_gtt_access(pPriv->buf, TRUE);
+	dst_base = pI830->FbBase;
+    }
+
     if (pPriv->currentBuf == 0)
-	dst = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf0offset;
+	dst = dst_base + pPriv->YBuf0offset;
     else
-	dst = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf1offset;
+	dst = dst_base + pPriv->YBuf1offset;
 
     switch (pPriv->rotation) {
     case RR_Rotate_0:
@@ -1360,7 +1368,9 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 	}
 	break;
     }
-    drm_intel_bo_unmap(pPriv->buf);
+
+    if (pPriv->textured)
+	drm_intel_bo_unmap(pPriv->buf);
 }
 
 static void
@@ -1369,8 +1379,9 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 		   int srcPitch2, int dstPitch, int srcH, int top, int left,
 		   int h, int w, int id)
 {
+    I830Ptr pI830 = I830PTR(pScrn);
     int i, j = 0;
-    unsigned char *src1, *src2, *src3, *dst1, *dst2, *dst3;
+    unsigned char *src1, *src2, *src3, *dst_base, *dst1, *dst2, *dst3;
     unsigned char *s;
     int dstPitch2 = dstPitch << 1;
 
@@ -1387,11 +1398,19 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
     ErrorF("src1 is %p, offset is %ld\n", src1,
 	   (unsigned long)src1 - (unsigned long)buf);
 #endif
-    drm_intel_bo_map(pPriv->buf, TRUE);
+
+    if (pPriv->textured) {
+	drm_intel_bo_map(pPriv->buf, TRUE);
+	dst_base = pPriv->buf->virtual;
+    } else {
+	drm_intel_gem_bo_start_gtt_access(pPriv->buf, TRUE);
+	dst_base = pI830->FbBase + pPriv->buf->offset;
+    }
+
     if (pPriv->currentBuf == 0)
-	dst1 = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf0offset;
+	dst1 = dst_base + pPriv->YBuf0offset;
     else
-	dst1 = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf1offset;
+	dst1 = dst_base + pPriv->YBuf1offset;
 
     switch (pPriv->rotation) {
     case RR_Rotate_0:
@@ -1441,14 +1460,14 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 #endif
     if (pPriv->currentBuf == 0) {
 	if (id == FOURCC_I420)
-	    dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf0offset;
+	    dst2 = dst_base + pPriv->UBuf0offset;
 	else
-	    dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf0offset;
+	    dst2 = dst_base + pPriv->VBuf0offset;
     } else {
 	if (id == FOURCC_I420)
-	    dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf1offset;
+	    dst2 = dst_base + pPriv->UBuf1offset;
 	else
-	    dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf1offset;
+	    dst2 = dst_base + pPriv->VBuf1offset;
     }
 
     switch (pPriv->rotation) {
@@ -1500,14 +1519,14 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 #endif
     if (pPriv->currentBuf == 0) {
 	if (id == FOURCC_I420)
-	    dst3 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf0offset;
+	    dst3 = dst_base + pPriv->VBuf0offset;
 	else
-	    dst3 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf0offset;
+	    dst3 = dst_base + pPriv->UBuf0offset;
     } else {
 	if (id == FOURCC_I420)
-	    dst3 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf1offset;
+	    dst3 = dst_base + pPriv->VBuf1offset;
 	else
-	    dst3 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf1offset;
+	    dst3 = dst_base + pPriv->UBuf1offset;
     }
 
     switch (pPriv->rotation) {
@@ -1549,7 +1568,9 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 	}
 	break;
     }
-    drm_intel_bo_unmap(pPriv->buf);
+
+    if (pPriv->textured)
+	drm_intel_bo_unmap(pPriv->buf);
 }
 
 typedef struct {
@@ -2410,10 +2431,10 @@ I830PutImage(ScrnInfoPtr pScrn,
 	destId = FOURCC_YV12;
     } else {
 #endif
-	if (!pPriv->textured)
-	    pPriv->YBuf0offset = pPriv->buf->offset;
-	else
+	if (pPriv->textured)
 	    pPriv->YBuf0offset = 0;
+	else
+	    pPriv->YBuf0offset = pPriv->buf->offset;
 
 	if (pPriv->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
 	    pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * width);

commit 3937756ae4cae78b6c6c72714ac8898f155844f6
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Thu Feb 19 16:41:49 2009 -0500

    Fix i915 textured video to work with the i830_memory -> bo change.
    
    Forgot to update i915_video.c in 872aadc7102bd5131e1582ede081e22672911ba2.
    (cherry picked from commit e97e2571703e3d6188bf18f211b793fc50383f9c)

diff --git a/src/i915_video.c b/src/i915_video.c
index b903b5e..81a0f87 100644
--- a/src/i915_video.c
+++ b/src/i915_video.c
@@ -161,7 +161,8 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
 
       OUT_BATCH(_3DSTATE_MAP_STATE | 3);
       OUT_BATCH(0x00000001);	/* texture map #1 */
-      OUT_BATCH(pPriv->YBuf0offset);
+      OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->YBuf0offset);
+
       ms3 = MAPSURF_422 | MS3_USE_FENCE_REGS;
       switch (id) {
       case FOURCC_YUY2:
@@ -269,7 +270,7 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
       OUT_BATCH(_3DSTATE_MAP_STATE | 9);
       OUT_BATCH(0x00000007);
 
-      OUT_BATCH(pPriv->YBuf0offset);
+      OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->YBuf0offset);
       ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
       ms3 |= (height - 1) << MS3_HEIGHT_SHIFT;
       ms3 |= (width - 1) << MS3_WIDTH_SHIFT;
@@ -282,14 +283,14 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
       else
 	  OUT_BATCH(((video_pitch * 2 / 4) - 1) << MS4_PITCH_SHIFT);
 
-      OUT_BATCH(pPriv->UBuf0offset);
+      OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->UBuf0offset);
       ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
       ms3 |= (height / 2 - 1) << MS3_HEIGHT_SHIFT;
       ms3 |= (width / 2 - 1) << MS3_WIDTH_SHIFT;
       OUT_BATCH(ms3);
       OUT_BATCH(((video_pitch / 4) - 1) << MS4_PITCH_SHIFT);
 
-      OUT_BATCH(pPriv->VBuf0offset);
+      OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->VBuf0offset);
       ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
       ms3 |= (height / 2 - 1) << MS3_HEIGHT_SHIFT;
       ms3 |= (width / 2 - 1) << MS3_WIDTH_SHIFT;

commit 2587a3e1d07acde3199592a81198716f4eb4221d
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Thu Feb 19 16:40:19 2009 -0500

    Dont allocate overlay registers in KMS mode.
    (cherry picked from commit 96da26b6813a8c1da8a43036c375aa0d2bb70f16)

diff --git a/src/i830_driver.c b/src/i830_driver.c
index 8b246ed..ac4257e 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -3291,12 +3291,6 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 		    "needs 2D acceleration.\n");
 	 pI830->XvEnabled = FALSE;
       }
-      if (!OVERLAY_NOEXIST(pI830) && pI830->overlay_regs == NULL) {
-	  xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-		     "Disabling Xv because the overlay register buffer "
-		      "allocation failed.\n");
-	 pI830->XvEnabled = FALSE;
-      }
    }
 #endif
 
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 05e9157..706b947 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -1476,7 +1476,7 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn)
     /* Allocate overlay register space and optional XAA linear allocator
      * space.  The second head in zaphod mode will share the space.
      */
-    if (I830IsPrimary(pScrn))
+    if (I830IsPrimary(pScrn) && !pI830->use_drm_mode)
 	i830_allocate_overlay(pScrn);
 #endif
 
diff --git a/src/i830_video.c b/src/i830_video.c
index be2d28e..e542897 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -648,8 +648,13 @@ I830InitVideo(ScreenPtr pScreen)
     }
 #endif
 
-    if (num_adaptors)
+    if (num_adaptors) {
 	xf86XVScreenInit(pScreen, adaptors, num_adaptors);
+    } else {
+	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+		   "Disabling Xv because no adaptors could be initialized.\n");
+	pI830->XvEnabled = FALSE;
+    }
 
 #ifdef INTEL_XVMC
     if (xvmc_status)

commit be56ce2c4cdeabaf655c53ca177ec35b8536bd9b
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Wed Feb 18 17:26:06 2009 -0500

    Make Xv used a buffer object instead of i830_memory.
    
    We still pin the buffer object in case of overlay, but for textured video
    we're now no longer using i830_memory for Xv anymore.
    (cherry picked from commit 872aadc7102bd5131e1582ede081e22672911ba2)

diff --git a/src/i830_driver.c b/src/i830_driver.c
index c51ae81..8b246ed 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -3488,7 +3488,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 	       pI830->XvMCEnabled ? "en" : "dis");
 #endif
    /* Init video */
-   if (pI830->XvEnabled && !pI830->use_drm_mode)
+   if (pI830->XvEnabled)
       I830InitVideo(pScreen);
 #endif
 
diff --git a/src/i830_video.c b/src/i830_video.c
index 8a3718d..be2d28e 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -620,7 +620,7 @@ I830InitVideo(ScreenPtr pScreen)
 
     /* Set up overlay video if we can do it at this depth. */
     if (!OVERLAY_NOEXIST(pI830) && pScrn->bitsPerPixel != 8 &&
-	    pI830->overlay_regs != NULL)
+	!pI830->use_drm_mode && pI830->overlay_regs != NULL)
     {
 	overlayAdaptor = I830SetupImageVideoOverlay(pScreen);
 	if (overlayAdaptor != NULL) {
@@ -1073,10 +1073,9 @@ I830StopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
 	    if (pI830->entityPrivate)
 		pI830->entityPrivate->XvInUse = -1;
 	}
-	/* Sync before freeing the buffer, because the pages will be unbound.
-	 */
-	I830Sync(pScrn);
-	i830_free_memory(pScrn, pPriv->buf);
+	if (!pPriv->textured)
+	    drm_intel_bo_unpin(pPriv->buf);
+	drm_intel_bo_unreference(pPriv->buf);
 	pPriv->buf = NULL;
 	pPriv->videoStatus = 0;
     } else {
@@ -1267,7 +1266,6 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 		   int srcPitch,
 		   int dstPitch, int top, int left, int h, int w)
 {
-    I830Ptr pI830 = I830PTR(pScrn);
     unsigned char *src, *dst;
     int i,j;
     unsigned char *s;
@@ -1280,10 +1278,11 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 
     src = buf + (top * srcPitch) + (left << 1);
 
+    drm_intel_bo_map(pPriv->buf, TRUE);
     if (pPriv->currentBuf == 0)
-	dst = pI830->FbBase + pPriv->YBuf0offset;
+	dst = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf0offset;
     else
-	dst = pI830->FbBase + pPriv->YBuf1offset;
+	dst = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf1offset;
 
     switch (pPriv->rotation) {
     case RR_Rotate_0:
@@ -1356,6 +1355,7 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 	}
 	break;
     }
+    drm_intel_bo_unmap(pPriv->buf);
 }
 
 static void
@@ -1364,7 +1364,6 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 		   int srcPitch2, int dstPitch, int srcH, int top, int left,
 		   int h, int w, int id)
 {
-    I830Ptr pI830 = I830PTR(pScrn);
     int i, j = 0;
     unsigned char *src1, *src2, *src3, *dst1, *dst2, *dst3;
     unsigned char *s;
@@ -1383,10 +1382,11 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
     ErrorF("src1 is %p, offset is %ld\n", src1,
 	   (unsigned long)src1 - (unsigned long)buf);
 #endif
+    drm_intel_bo_map(pPriv->buf, TRUE);
     if (pPriv->currentBuf == 0)
-	dst1 = pI830->FbBase + pPriv->YBuf0offset;
+	dst1 = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf0offset;
     else
-	dst1 = pI830->FbBase + pPriv->YBuf1offset;
+	dst1 = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf1offset;
 
     switch (pPriv->rotation) {
     case RR_Rotate_0:
@@ -1436,14 +1436,14 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 #endif
     if (pPriv->currentBuf == 0) {
 	if (id == FOURCC_I420)
-	    dst2 = pI830->FbBase + pPriv->UBuf0offset;
+	    dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf0offset;
 	else
-	    dst2 = pI830->FbBase + pPriv->VBuf0offset;
+	    dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf0offset;
     } else {
 	if (id == FOURCC_I420)
-	    dst2 = pI830->FbBase + pPriv->UBuf1offset;
+	    dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf1offset;
 	else
-	    dst2 = pI830->FbBase + pPriv->VBuf1offset;
+	    dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf1offset;
     }
 
     switch (pPriv->rotation) {
@@ -1495,14 +1495,14 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 #endif
     if (pPriv->currentBuf == 0) {
 	if (id == FOURCC_I420)
-	    dst3 = pI830->FbBase + pPriv->VBuf0offset;
+	    dst3 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf0offset;
 	else
-	    dst3 = pI830->FbBase + pPriv->UBuf0offset;
+	    dst3 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf0offset;
     } else {
 	if (id == FOURCC_I420)
-	    dst3 = pI830->FbBase + pPriv->VBuf1offset;
+	    dst3 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf1offset;
 	else
-	    dst3 = pI830->FbBase + pPriv->UBuf1offset;
+	    dst3 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf1offset;
     }
 
     switch (pPriv->rotation) {
@@ -1544,6 +1544,7 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 	}
 	break;
     }
+    drm_intel_bo_unmap(pPriv->buf);
 }
 
 typedef struct {
@@ -2374,29 +2375,27 @@ I830PutImage(ScrnInfoPtr pScrn,
     if (pPriv->doubleBuffer)
 	alloc_size *= 2;
 
-    if (pPriv->buf) {
-	/* Wait for any previous acceleration to the buffer to have completed.
-	 * When we start using BOs for rendering, we won't have to worry
-	 * because mapping or freeing will take care of it automatically.
-	 */
-	I830Sync(pScrn);
-    }
-
     /* Free the current buffer if we're going to have to reallocate */
     if (pPriv->buf && pPriv->buf->size < alloc_size) {
-	i830_free_memory(pScrn, pPriv->buf);
+	if (!pPriv->textured)
+	    drm_intel_bo_unpin(pPriv->buf);
+	drm_intel_bo_unreference(pPriv->buf);
 	pPriv->buf = NULL;
     }
 
     if (pPriv->buf == NULL) {
-	pPriv->buf = i830_allocate_memory(pScrn, "xv buffer",
-					  alloc_size, 0, 16,
-					  0, TILE_NONE);
+	pPriv->buf = drm_intel_bo_alloc(pI830->bufmgr,
+					"xv buffer", alloc_size, 4096);
+	if (pPriv->buf == NULL)
+	    return BadAlloc;
+	if (!pPriv->textured && drm_intel_bo_pin(pPriv->buf, 4096) != 0) {
+	    drm_intel_bo_unreference(pPriv->buf);
+	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		       "Failed to pin xv buffer\n");
+	    return BadAlloc;
+	}
     }
 
-    if (pPriv->buf == NULL)
-	return BadAlloc;
-
     /* fixup pointers */
 #ifdef INTEL_XVMC
     if (id == FOURCC_XVMC && IS_I915(pI830)) {
@@ -2406,7 +2405,11 @@ I830PutImage(ScrnInfoPtr pScrn,
 	destId = FOURCC_YV12;
     } else {
 #endif
-	pPriv->YBuf0offset = pPriv->buf->offset;
+	if (!pPriv->textured)
+	    pPriv->YBuf0offset = pPriv->buf->offset;
+	else
+	    pPriv->YBuf0offset = 0;
+
 	if (pPriv->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
 	    pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * width);
 	    pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * width / 2);
@@ -2663,11 +2666,9 @@ I830VideoBlockHandler(int i, pointer blockData, pointer pTimeout,
 	    }
 	} else {				/* FREE_TIMER */
 	    if (pPriv->freeTime < now) {
-		/* Sync before freeing the buffer, because the pages will be
-		 * unbound.


Reply to: