[Intel-gfx] [PATCH 02/14] Start purging XF86DRI. Woo!

Eric Anholt eric at anholt.net
Wed Apr 22 01:13:24 CEST 2009


This includes disabling XVMC which is DRI1-only currently.
---
 configure.ac       |    8 +-
 src/i830.h         |   55 --
 src/i830_accel.c   |   43 --
 src/i830_display.c |   77 +---
 src/i830_dri.c     | 1438 ----------------------------------------------------
 src/i830_driver.c  |  191 +-------
 src/i830_exa.c     |   20 -
 src/i830_memory.c  |  245 +---------
 src/i830_xaa.c     |   34 +-
 9 files changed, 24 insertions(+), 2087 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8dd04d5..18fe983 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,10 +70,10 @@ AC_ARG_ENABLE(video-debug, AC_HELP_STRING([--enable-video-debug],
               [VIDEO_DEBUG="$enableval"],
               [VIDEO_DEBUG=no])
 
-AC_ARG_ENABLE(xvmc, AC_HELP_STRING([--disable-xvmc],
-                                  [Disable XvMC support [[default=auto]]]),
-              [XVMC="$enableval"],
-              [XVMC=auto])
+dnl AC_ARG_ENABLE(xvmc, AC_HELP_STRING([--disable-xvmc],
+dnl                                   [Disable XvMC support [[default=auto]]]),
+dnl               [XVMC="$enableval"],
+dnl               [XVMC=auto])
 
 # Checks for extensions
 XORG_DRIVER_CHECK_EXT(XINERAMA, xineramaproto)
diff --git a/src/i830.h b/src/i830.h
index de119ca..9ca8a5f 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -65,21 +65,18 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <pciaccess.h>
 #endif
 
-#ifdef XF86DRI
 #include "xf86drm.h"
 #include "sarea.h"
 #define _XF86DRI_SERVER_
 #include "dri.h"
 #include "GL/glxint.h"
 #include "i830_dri.h"
-#endif
 #include "intel_bufmgr.h"
 #include "i915_drm.h"
 
 #ifdef I830_USE_EXA
 #include "exa.h"
 Bool I830EXAInit(ScreenPtr pScreen);
-unsigned long long I830TexOffsetStart(PixmapPtr pPix);
 #endif
 
 #ifdef I830_USE_UXA
@@ -106,18 +103,6 @@ typedef struct _I830OutputRec I830OutputRec, *I830OutputPtr;
 #include "i830_sdvo.h"
 #include "i2c_vid.h"
 
-/*
- * The mode handling is based upon the VESA driver written by
- * Paulo C├ęsar Pereira de Andrade <pcpa at conectiva.com.br>.
- */
-
-#ifdef XF86DRI
-#define I830_MM_MINPAGES 512
-#define I830_MM_MAXSIZE  (32*1024)
-#define I830_KERNEL_MM  (1 << 0) /* Initialize the kernel memory manager*/
-#define I830_KERNEL_TEX (1 << 1) /* Allocate texture memory pool */
-#endif
-
 #ifdef XvMCExtension
 #ifdef ENABLE_XVMC
 #define INTEL_XVMC 1
@@ -361,7 +346,6 @@ typedef enum accel_method {
 enum dri_type {
     DRI_DISABLED,
     DRI_NONE,
-    DRI_XF86DRI,
     DRI_DRI2
 };
 
@@ -444,22 +428,10 @@ typedef struct _I830Rec {
 
    i830_memory *power_context;
 
-#ifdef XF86DRI
-   i830_memory *back_buffer;
-   i830_memory *depth_buffer;
-   i830_memory *textures;		/**< Compatibility texture memory */
    i830_memory *memory_manager;		/**< DRI memory manager aperture */
-   i830_memory *hw_status;		/* for G33 hw status page alloc */
-
-   int TexGranularity;
-   int drmMinor;
-   Bool allocate_classic_textures;
 
    Bool can_resize;
 
-   Bool want_vblank_interrupts;
-#endif
-
    Bool need_mi_flush;
 
    Bool tiling;
@@ -574,18 +546,9 @@ typedef struct _I830Rec {
 
    enum dri_type directRenderingType;	/* DRI enabled this generation. */
 
-#ifdef XF86DRI
    Bool directRenderingOpen;
-   int LockHeld;
-   DRIInfoPtr pDRIInfo;
    int drmSubFD;
-   int numVisualConfigs;
-   __GLXvisualConfig *pVisualConfigs;
-   I830ConfigPrivPtr pVisualConfigsPriv;
-   drm_handle_t buffer_map;
-   drm_handle_t ring_map;
    char deviceName[64];
-#endif
 
    /* Broken-out options. */
    OptionInfoPtr Options;
@@ -778,26 +741,8 @@ i830_pipe_a_require_activate (ScrnInfoPtr scrn);
 void
 i830_pipe_a_require_deactivate (ScrnInfoPtr scrn);
 
-#ifdef XF86DRI
-extern Bool I830Allocate3DMemory(ScrnInfoPtr pScrn, const int flags);
-extern void I830SetupMemoryTiling(ScrnInfoPtr pScrn);
-extern Bool I830DRIScreenInit(ScreenPtr pScreen);
-extern Bool I830DRIDoMappings(ScreenPtr pScreen);
-extern Bool I830DRIResume(ScreenPtr pScreen);
-extern void I830DRICloseScreen(ScreenPtr pScreen);
-extern Bool I830DRIFinishScreenInit(ScreenPtr pScreen);
-extern void I830DRIUnlock(ScrnInfoPtr pScrn);
-extern Bool I830DRILock(ScrnInfoPtr pScrn);
-extern Bool I830DRISetVBlankInterrupt (ScrnInfoPtr pScrn, Bool on);
-extern Bool i830_update_dri_buffers(ScrnInfoPtr pScrn);
-extern Bool I830DRISetHWS(ScrnInfoPtr pScrn);
-extern Bool I830DRIInstIrqHandler(ScrnInfoPtr pScrn);
-#endif
-
-#ifdef DRI2
 Bool I830DRI2ScreenInit(ScreenPtr pScreen);
 void I830DRI2CloseScreen(ScreenPtr pScreen);
-#endif
 
 #ifdef XF86DRM_MODE
 extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, int fd, int cpp);
diff --git a/src/i830_accel.c b/src/i830_accel.c
index 67f264c..61de2b5 100644
--- a/src/i830_accel.c
+++ b/src/i830_accel.c
@@ -137,12 +137,6 @@ I830WaitLpRing(ScrnInfoPtr pScrn, int n, int timeout_millis)
 	 else
 	     i830_dump_error_state(pScrn);
 	 ErrorF("space: %d wanted %d\n", ring->space, n);
-#ifdef XF86DRI
-	 if (pI830->directRenderingType == DRI_XF86DRI) {
-	    DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
-	    DRICloseScreen(screenInfo.screens[pScrn->scrnIndex]);
-	 }
-#endif
 #ifdef I830_USE_XAA
 	 pI830->AccelInfoRec = NULL;	/* Stops recursive behavior */
 #endif
@@ -180,14 +174,6 @@ I830Sync(ScrnInfoPtr pScrn)
    if (pI830->accel == ACCEL_NONE)
        return;
 
-#ifdef XF86DRI
-   /* VT switching tries to do this.
-    */
-   if (!pI830->LockHeld && pI830->directRenderingType == DRI_XF86DRI) {
-      return;
-   }
-#endif
-
    I830EmitFlush(pScrn);
 
    intel_batch_flush(pScrn, TRUE);
@@ -241,35 +227,6 @@ I830EmitFlush(ScrnInfoPtr pScrn)
    }
 }
 
-Bool
-I830SelectBuffer(ScrnInfoPtr pScrn, int buffer)
-{
-   I830Ptr pI830 = I830PTR(pScrn);
-
-   switch (buffer) {
-#ifdef XF86DRI
-   case I830_SELECT_BACK:
-      pI830->bufferOffset = pI830->back_buffer->offset;
-      if (pI830->back_buffer->tiling == TILE_YMAJOR)
-	 return FALSE;
-      break;
-   case I830_SELECT_DEPTH:
-      pI830->bufferOffset = pI830->depth_buffer->offset;
-      if (pI830->depth_buffer->tiling == TILE_YMAJOR)
-	 return FALSE;
-      break;
-#endif
-   default:
-   case I830_SELECT_FRONT:
-      pI830->bufferOffset = pScrn->fbOffset;
-      break;
-   }
-
-   if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
-      ErrorF("I830SelectBuffer %d --> offset %x\n",
-	     buffer, pI830->bufferOffset);
-   return TRUE;
-}
 
 #if (ALWAYS_SYNC || ALWAYS_FLUSH)
 void
diff --git a/src/i830_display.c b/src/i830_display.c
index 847dc22..c8e94ff 100644
--- a/src/i830_display.c
+++ b/src/i830_display.c
@@ -698,7 +698,6 @@ i830PipeSetBase(xf86CrtcPtr crtc, int x, int y)
     ScrnInfoPtr pScrn = crtc->scrn;
     I830Ptr pI830 = I830PTR(pScrn);
     I830CrtcPrivatePtr	intel_crtc = crtc->driver_private;
-    int pipe = intel_crtc->pipe;
     int plane = intel_crtc->plane;
     unsigned long Start, Offset, Stride;
     int dspbase = (plane == 0 ? DSPABASE : DSPBBASE);
@@ -737,30 +736,6 @@ i830PipeSetBase(xf86CrtcPtr crtc, int x, int y)
 	OUTREG(dspbase, Start + Offset);
 	POSTING_READ(dspbase);
     }
-
-#ifdef XF86DRI
-    if (pI830->directRenderingType == DRI_XF86DRI) {
-	drmI830Sarea *sPriv = (drmI830Sarea *) DRIGetSAREAPrivate(pScrn->pScreen);
-
-	if (!sPriv)
-	    return;
-
-	switch (pipe) {
-	case 0:
-	    sPriv->pipeA_x = x;
-	    sPriv->pipeA_y = y;
-	    break;
-	case 1:
-	    sPriv->pipeB_x = x;
-	    sPriv->pipeB_y = y;
-	    break;
-	default:
-	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		       "Can't update pipe %d in SAREA\n", pipe);
-	    break;
-	}
-    }
-#endif
 }
 
 /*
@@ -1062,7 +1037,7 @@ i830_use_fb_compression(xf86CrtcPtr crtc)
     return TRUE;
 }
 
-#if defined(DRM_IOCTL_MODESET_CTL) && (defined(XF86DRI) || defined(DRI2))
+#if defined(DRM_IOCTL_MODESET_CTL)
 static void i830_modeset_ctl(xf86CrtcPtr crtc, int pre)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
@@ -1094,7 +1069,7 @@ static void i830_modeset_ctl(xf86CrtcPtr crtc, int dpms_state)
 {
     return;
 }
-#endif /* DRM_IOCTL_MODESET_CTL && (XF86DRI || DRI2) */
+#endif /* DRM_IOCTL_MODESET_CTL */
 
 static void
 i830_disable_vga_plane (xf86CrtcPtr crtc)
@@ -1286,54 +1261,20 @@ i830_crtc_dpms(xf86CrtcPtr crtc, int mode)
     }
 
     intel_crtc->dpms_mode = mode;
-
-#ifdef XF86DRI
-    if (pI830->directRenderingType == DRI_XF86DRI) {
-	drmI830Sarea *sPriv = (drmI830Sarea *) DRIGetSAREAPrivate(pScrn->pScreen);
-	Bool enabled = crtc->enabled && mode != DPMSModeOff;
-
-	I830DRISetVBlankInterrupt (pScrn, TRUE);
-
-	if (!sPriv)
-	    return;
-
-	switch (pipe) {
-	case 0:
-	    sPriv->pipeA_w = enabled ? crtc->mode.HDisplay : 0;
-	    sPriv->pipeA_h = enabled ? crtc->mode.VDisplay : 0;
-	    break;
-	case 1:
-	    sPriv->pipeB_w = enabled ? crtc->mode.HDisplay : 0;
-	    sPriv->pipeB_h = enabled ? crtc->mode.VDisplay : 0;
-	    break;
-	default:
-	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		       "Can't update pipe %d in SAREA\n", pipe);
-	    break;
-	}
-    }
-#endif
 }
 
 static Bool
 i830_crtc_lock (xf86CrtcPtr crtc)
 {
-   /* Sync the engine before mode switch */
-   i830WaitSync(crtc->scrn);
+    /* Sync the engine before mode switch */
+    i830WaitSync(crtc->scrn);
 
-#ifdef XF86DRI
-    return I830DRILock(crtc->scrn);
-#else
     return FALSE;
-#endif
 }
 
 static void
 i830_crtc_unlock (xf86CrtcPtr crtc)
 {
-#ifdef XF86DRI
-    I830DRIUnlock (crtc->scrn);
-#endif
 }
 
 static void
@@ -1368,11 +1309,6 @@ i830_crtc_commit (xf86CrtcPtr crtc)
     /* Reenable FB compression if possible */
     if (i830_use_fb_compression(crtc))
 	i830_enable_fb_compression(crtc);
-
-#ifdef XF86DRI
-    /* Tell DRI1 the news about new output config */
-    i830_update_dri_buffers(crtc->scrn);
-#endif
 }
 
 void
@@ -1919,10 +1855,7 @@ i830_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode,
     OUTREG(dspcntr_reg, dspcntr);
     /* Flush the plane changes */
     i830PipeSetBase(crtc, x, y);
-#ifdef XF86DRI
-   I830DRISetVBlankInterrupt (pScrn, TRUE);
-#endif
-    
+
     i830WaitForVblank(pScrn);
 }
 
diff --git a/src/i830_dri.c b/src/i830_dri.c
index cbb0db8..7a41fae 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -89,1443 +89,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "i915_drm.h"
 
-#include "dristruct.h"
-
-#ifdef DRI2
 #include "dri2.h"
-#endif
-
-static Bool I830InitVisualConfigs(ScreenPtr pScreen);
-static Bool I830CreateContext(ScreenPtr pScreen, VisualPtr visual,
-			      drm_context_t hwContext, void *pVisualConfigPriv,
-			      DRIContextType contextStore);
-static void I830DestroyContext(ScreenPtr pScreen, drm_context_t hwContext,
-			       DRIContextType contextStore);
-static void I830DRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
-			       DRIContextType readContextType,
-			       void *readContextStore,
-			       DRIContextType writeContextType,
-			       void *writeContextStore);
-static void I830DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index);
-static void I830DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
-			       RegionPtr prgnSrc, CARD32 index);
-
-static void I830DRITransitionTo2d(ScreenPtr pScreen);
-static void I830DRITransitionTo3d(ScreenPtr pScreen);
-
-#if (DRIINFO_MAJOR_VERSION > 5 || \
-     (DRIINFO_MAJOR_VERSION == 5 && DRIINFO_MINOR_VERSION >= 4))
-#define DRI_DRIVER_FRAMEBUFFER_MAP 1
-#else
-#define DRI_DRIVER_FRAMEBUFFER_MAP 0
-#endif
-
-extern void GlxSetVisualConfigs(int nconfigs,
-				__GLXvisualConfig * configs,
-				void **configprivs);
-
-static Bool
-I830CleanupDma(ScrnInfoPtr pScrn)
-{
-   I830Ptr pI830 = I830PTR(pScrn);
-   drmI830Init info;
-
-   memset(&info, 0, sizeof(drmI830Init));
-   info.func = I830_CLEANUP_DMA;
-
-   if (drmCommandWrite(pI830->drmSubFD, DRM_I830_INIT,
-		       &info, sizeof(drmI830Init))) {
-      xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I830 Dma Cleanup Failed\n");
-      return FALSE;
-   }
-
-   return TRUE;
-}
-
-static Bool
-I830InitDma(ScrnInfoPtr pScrn)
-{
-   I830Ptr pI830 = I830PTR(pScrn);
-   I830RingBuffer *ring = &pI830->ring;
-   I830DRIPtr pI830DRI = (I830DRIPtr) pI830->pDRIInfo->devPrivate;
-   drmI830Init info;
-
-   memset(&info, 0, sizeof(drmI830Init));
-   info.func = I830_INIT_DMA;
-
-   /* Initialize fields that are used in the absence of GEM */
-   if (!pI830->memory_manager && !pI830->use_drm_mode) {
-       info.ring_start = ring->mem->offset + pI830->LinearAddr;
-       info.ring_end = ring->mem->end + pI830->LinearAddr;
-       info.ring_size = ring->mem->size;
-
-       /* Not used as of the middle of GEM development. */
-       info.mmio_offset = (unsigned int)pI830DRI->regs;
-
-       /* Not used as of before GEM development */
-       info.front_offset = pI830->front_buffer->offset;
-       info.back_offset = pI830->back_buffer->offset;
-       info.depth_offset = pI830->depth_buffer->offset;
-       info.pitch = pScrn->displayWidth;
-       info.back_pitch = pScrn->displayWidth;
-       info.depth_pitch = pScrn->displayWidth;
-       info.w = pScrn->virtualX;
-       info.h = pScrn->virtualY;
-   }
-
-
-   info.sarea_priv_offset = sizeof(XF86DRISAREARec);
-
-   /* This should probably have been moved alongside offset/pitch in the sarea.
-    */
-   info.cpp = pI830->cpp;
-
-   if (drmCommandWrite(pI830->drmSubFD, DRM_I830_INIT,
-		       &info, sizeof(drmI830Init))) {
-      xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		 "I830 Dma Initialization Failed\n");
-      return FALSE;
-   }
-
-   return TRUE;
-}
-
-static Bool
-I830ResumeDma(ScrnInfoPtr pScrn)
-{
-   I830Ptr pI830 = I830PTR(pScrn);
-   drmI830Init info;
-
-   memset(&info, 0, sizeof(drmI830Init));
-   info.func = I830_RESUME_DMA;
-
-   if (drmCommandWrite(pI830->drmSubFD, DRM_I830_INIT,
-		       &info, sizeof(drmI830Init))) {
-      xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I830 Dma Resume Failed\n");
-      return FALSE;
-   }
-
-   return TRUE;
-}
-
-static Bool
-I830SetParam(ScrnInfoPtr pScrn, int param, int value)
-{
-   I830Ptr pI830 = I830PTR(pScrn);
-   drmI830SetParam sp;
-
-   memset(&sp, 0, sizeof(sp));
-   sp.param = param;
-   sp.value = value;
-
-   if (drmCommandWrite(pI830->drmSubFD, DRM_I830_SETPARAM, &sp, sizeof(sp))) {
-      xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I830 SetParam Failed\n");
-      return FALSE;
-   }
-
-   return TRUE;
-}
-
-Bool
-I830DRISetHWS(ScrnInfoPtr pScrn)
-{
-    I830Ptr pI830 = I830PTR(pScrn);
-    drmI830HWS hws;
-
-    hws.addr = pI830->hw_status->offset;
-
-    if (drmCommandWrite(pI830->drmSubFD, DRM_I830_HWS_PAGE_ADDR,
-		&hws, sizeof(drmI830HWS))) {
-	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		"hw status page initialization Failed\n");
-	return FALSE;
-    }
-    return TRUE;
-}
-
-static Bool
-I830InitVisualConfigs(ScreenPtr pScreen)
-{
-   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-   I830Ptr pI830 = I830PTR(pScrn);
-   int numConfigs = 0;
-   __GLXvisualConfig *pConfigs = NULL;
-   I830ConfigPrivPtr pI830Configs = NULL;
-   I830ConfigPrivPtr *pI830ConfigPtrs = NULL;
-   int accum, stencil, db, depth;
-   int i;
-
-   switch (pScrn->bitsPerPixel) {
-   case 8:
-   case 24:
-      break;
-
-   case 16:
-      numConfigs = 8;
-
-      pConfigs =
-	    (__GLXvisualConfig *) xcalloc(sizeof(__GLXvisualConfig),
-					  numConfigs);
-      if (!pConfigs)
-	 return FALSE;
-
-      pI830Configs =
-	    (I830ConfigPrivPtr) xcalloc(sizeof(I830ConfigPrivRec),
-					numConfigs);
-      if (!pI830Configs) {
-	 xfree(pConfigs);
-	 return FALSE;
-      }
-
-      pI830ConfigPtrs =
-	    (I830ConfigPrivPtr *) xcalloc(sizeof(I830ConfigPrivPtr),
-					  numConfigs);
-      if (!pI830ConfigPtrs) {
-	 xfree(pConfigs);
-	 xfree(pI830Configs);
-	 return FALSE;
-      }
-
-      for (i = 0; i < numConfigs; i++)
-	 pI830ConfigPtrs[i] = &pI830Configs[i];
-
-      i = 0;
-      depth = 1;
-      for (accum = 0; accum <= 1; accum++) {
-	 for (stencil = 0; stencil <= 1; stencil++) {
-	    for (db = 1; db >= 0; db--) {
-	       pConfigs[i].vid = -1;
-	       pConfigs[i].class = -1;
-	       pConfigs[i].rgba = TRUE;
-	       pConfigs[i].redSize = 5;
-	       pConfigs[i].greenSize = 6;
-	       pConfigs[i].blueSize = 5;
-	       pConfigs[i].alphaSize = 0;
-	       pConfigs[i].redMask = 0x0000F800;
-	       pConfigs[i].greenMask = 0x000007E0;
-	       pConfigs[i].blueMask = 0x0000001F;
-	       pConfigs[i].alphaMask = 0;
-	       if (accum) {
-		  pConfigs[i].accumRedSize = 16;
-		  pConfigs[i].accumGreenSize = 16;
-		  pConfigs[i].accumBlueSize = 16;
-		  pConfigs[i].accumAlphaSize = 0;
-	       } else {
-		  pConfigs[i].accumRedSize = 0;
-		  pConfigs[i].accumGreenSize = 0;
-		  pConfigs[i].accumBlueSize = 0;
-		  pConfigs[i].accumAlphaSize = 0;
-	       }
-	       pConfigs[i].doubleBuffer = db ? TRUE : FALSE;
-	       pConfigs[i].stereo = FALSE;
-	       pConfigs[i].bufferSize = 16;
-	       if (depth)
-		  pConfigs[i].depthSize = 16;
-	       else
-		  pConfigs[i].depthSize = 0;
-	       if (stencil)
-		  pConfigs[i].stencilSize = 8;
-	       else
-		  pConfigs[i].stencilSize = 0;
-	       pConfigs[i].auxBuffers = 0;
-	       pConfigs[i].level = 0;
-	       if (stencil || accum)
-		  pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
-	       else
-		  pConfigs[i].visualRating = GLX_NONE_EXT;
-	       pConfigs[i].transparentPixel = GLX_NONE_EXT;
-	       pConfigs[i].transparentRed = 0;
-	       pConfigs[i].transparentGreen = 0;
-	       pConfigs[i].transparentBlue = 0;
-	       pConfigs[i].transparentAlpha = 0;
-	       pConfigs[i].transparentIndex = 0;
-	       i++;
-	    }
-	 }
-      }
-      assert(i == numConfigs);
-      break;
-
-   case 32:
-      numConfigs = 8;
-
-      pConfigs = (__GLXvisualConfig *) xcalloc(sizeof(__GLXvisualConfig),
-					       numConfigs);
-      if (!pConfigs) {
-	 return FALSE;
-      }
-
-      pI830Configs = (I830ConfigPrivPtr) xcalloc(sizeof(I830ConfigPrivRec),
-						 numConfigs);
-      if (!pI830Configs) {
-	 xfree(pConfigs);
-	 return FALSE;
-      }
-
-      pI830ConfigPtrs = (I830ConfigPrivPtr *)
-	    xcalloc(sizeof(I830ConfigPrivPtr), numConfigs);
-      if (!pI830ConfigPtrs) {
-	 xfree(pConfigs);
-	 xfree(pI830Configs);
-	 return FALSE;
-      }
-
-      for (i = 0; i < numConfigs; i++) {
-	 pI830ConfigPtrs[i] = &pI830Configs[i];
-      }
-
-      i = 0;
-      for (accum = 0; accum <= 1; accum++) {
-	 for (depth = 1; depth >= 0; depth--) {	/* and stencil */
-	    for (db = 1; db >= 0; db--) {
-	       pConfigs[i].vid = -1;
-	       pConfigs[i].class = -1;
-	       pConfigs[i].rgba = TRUE;
-	       pConfigs[i].redSize = 8;
-	       pConfigs[i].greenSize = 8;
-	       pConfigs[i].blueSize = 8;
-	       pConfigs[i].alphaSize = 8;
-	       pConfigs[i].redMask = 0x00FF0000;
-	       pConfigs[i].greenMask = 0x0000FF00;
-	       pConfigs[i].blueMask = 0x000000FF;
-	       pConfigs[i].alphaMask = 0xFF000000;
-	       if (accum) {
-		  pConfigs[i].accumRedSize = 16;
-		  pConfigs[i].accumGreenSize = 16;
-		  pConfigs[i].accumBlueSize = 16;
-		  pConfigs[i].accumAlphaSize = 16;
-	       } else {
-		  pConfigs[i].accumRedSize = 0;
-		  pConfigs[i].accumGreenSize = 0;
-		  pConfigs[i].accumBlueSize = 0;
-		  pConfigs[i].accumAlphaSize = 0;
-	       }
-	       if (db) {
-		  pConfigs[i].doubleBuffer = TRUE;
-	       } else {
-		  pConfigs[i].doubleBuffer = FALSE;
-	       }
-	       pConfigs[i].stereo = FALSE;
-	       pConfigs[i].bufferSize = 32;
-	       if (depth) {
-		  pConfigs[i].depthSize = 24;
-		  pConfigs[i].stencilSize = 8;
-	       } else {
-		  pConfigs[i].depthSize = 0;
-		  pConfigs[i].stencilSize = 0;
-	       }
-	       pConfigs[i].auxBuffers = 0;
-	       pConfigs[i].level = 0;
-	       if (accum) {
-		  pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
-	       } else {
-		  pConfigs[i].visualRating = GLX_NONE_EXT;
-	       }
-	       pConfigs[i].transparentPixel = GLX_NONE_EXT;
-	       pConfigs[i].transparentRed = 0;
-	       pConfigs[i].transparentGreen = 0;
-	       pConfigs[i].transparentBlue = 0;
-	       pConfigs[i].transparentAlpha = 0;
-	       pConfigs[i].transparentIndex = 0;
-	       i++;
-	    }
-	 }
-      }
-      if (i != numConfigs) {
-	 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		    "[drm] Incorrect initialization of visuals\n");
-	 return FALSE;
-      }
-      break;
-
-   }
-   pI830->numVisualConfigs = numConfigs;
-   pI830->pVisualConfigs = pConfigs;
-   pI830->pVisualConfigsPriv = pI830Configs;
-   GlxSetVisualConfigs(numConfigs, pConfigs, (void **)pI830ConfigPtrs);
-   return TRUE;
-}
-
-static Bool
-I830CheckDRIAvailable(ScrnInfoPtr pScrn)
-{
-   /* Hardware 3D rendering only implemented for 16bpp and 32 bpp */
-   if (((pScrn->bitsPerPixel / 8) != 2 && pScrn->depth != 16) &&
-       (pScrn->bitsPerPixel / 8) != 4) {
-      xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		 "[drm] Direct rendering only supported in 16 and 32 bpp modes\n");
-      return FALSE;
-   }
-
-   /* Check that the GLX, DRI, and DRM modules have been loaded by testing
-    * for known symbols in each module. */
-   if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) {
-      xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		 "[dri] %s failed: glx not loaded\n", __FUNCTION__);
-      return FALSE;
-   }
-   if (!xf86LoaderCheckSymbol("DRIScreenInit")) {
-      xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		 "[dri] %s failed: dri not loaded\n", __FUNCTION__);
-      return FALSE;
-   }
-   if (!xf86LoaderCheckSymbol("drmAvailable")) {
-      xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		 "[dri] %s failed: libdrm not loaded\n", __FUNCTION__);
-      return FALSE;
-   }
-   if (!xf86LoaderCheckSymbol("DRIQueryVersion")) {
-      xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		 "[dri] %s failed (libdri.a too old)\n", __FUNCTION__);
-      return FALSE;
-   }
-
-   /* Check the DRI version */
-   {
-      int major, minor, patch;
-
-      DRIQueryVersion(&major, &minor, &patch);
-      if (major != DRIINFO_MAJOR_VERSION || minor < DRIINFO_MINOR_VERSION ||
-	  major < 5) {
-	 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		    "[dri] %s failed because of a version mismatch.\n"
-		    "[dri] libDRI version is %d.%d.%d but version %d.%d.x is needed.\n"
-		    "[dri] Disabling DRI.\n",
-		    "I830CheckDRIAvailable", major, minor, patch,
-		     DRIINFO_MAJOR_VERSION, DRIINFO_MINOR_VERSION);
-	 return FALSE;
-      }
-   }
-
-   return TRUE;
-}
-
-Bool
-I830DRIScreenInit(ScreenPtr pScreen)
-{
-   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-   I830Ptr pI830 = I830PTR(pScrn);
-   DRIInfoPtr pDRIInfo;
-   I830DRIPtr pI830DRI;
-
-   DPRINTF(PFX, "I830DRIScreenInit\n");
-
-   if (!I830CheckDRIAvailable(pScrn))
-      return FALSE;
-
-   pDRIInfo = DRICreateInfoRec();
-   if (!pDRIInfo) {
-      xf86DrvMsg(pScreen->myNum, X_ERROR,
-		 "[dri] DRICreateInfoRec failed. Disabling DRI.\n");
-      return FALSE;
-   }
-
-   pI830->pDRIInfo = pDRIInfo;
-   pI830->LockHeld = 0;
-
-   pDRIInfo->drmDriverName = "i915";
-   if (IS_I965G(pI830))
-      pDRIInfo->clientDriverName = "i965";
-   else
-      pDRIInfo->clientDriverName = "i915";
-
-   if (xf86LoaderCheckSymbol("DRICreatePCIBusID")) {
-      pDRIInfo->busIdString = DRICreatePCIBusID(pI830->PciInfo);
-   } else {
-      pDRIInfo->busIdString = xalloc(64);
-      sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d",
-#if XSERVER_LIBPCIACCESS
-	      ((pI830->PciInfo->domain << 8) | pI830->PciInfo->bus),
-	      pI830->PciInfo->dev, pI830->PciInfo->func
-#else
-	      ((pciConfigPtr) pI830->PciInfo->thisCard)->busnum,
-	      ((pciConfigPtr) pI830->PciInfo->thisCard)->devnum,
-	      ((pciConfigPtr) pI830->PciInfo->thisCard)->funcnum
-#endif
-	      );
-   }
-   pDRIInfo->ddxDriverMajorVersion = I830_MAJOR_VERSION;
-   pDRIInfo->ddxDriverMinorVersion = I830_MINOR_VERSION;
-   pDRIInfo->ddxDriverPatchVersion = I830_PATCHLEVEL;
-   pDRIInfo->ddxDrawableTableEntry = I830_MAX_DRAWABLES;
-
-   if (SAREA_MAX_DRAWABLES < I830_MAX_DRAWABLES)
-      pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES;
-   else
-      pDRIInfo->maxDrawableTableEntry = I830_MAX_DRAWABLES;
-
-   if (sizeof(XF86DRISAREARec) + sizeof(drmI830Sarea) > SAREA_MAX) {
-      xf86DrvMsg(pScreen->myNum, X_ERROR,
-		 "[dri] Data does not fit in SAREA\n");
-      return FALSE;
-   }
-   /* This is a hack for now.  We have to have more than a 4k page here
-    * because of the size of the state.  However, the state should be
-    * in a per-context mapping.  This will be added in the Mesa 3.5 port
-    * of the I830 driver.
-    */
-   pDRIInfo->SAREASize = SAREA_MAX;
-
-   if (!(pI830DRI = (I830DRIPtr) xcalloc(sizeof(I830DRIRec), 1))) {
-      DRIDestroyInfoRec(pI830->pDRIInfo);
-      pI830->pDRIInfo = NULL;
-      return FALSE;
-   }
-   pDRIInfo->devPrivate = pI830DRI;
-   pDRIInfo->devPrivateSize = sizeof(I830DRIRec);
-   pDRIInfo->contextSize = sizeof(I830DRIContextRec);
-
-   pDRIInfo->CreateContext = I830CreateContext;
-   pDRIInfo->DestroyContext = I830DestroyContext;
-   pDRIInfo->SwapContext = I830DRISwapContext;
-   pDRIInfo->InitBuffers = I830DRIInitBuffers;
-   pDRIInfo->MoveBuffers = I830DRIMoveBuffers;
-   pDRIInfo->bufferRequests = DRI_ALL_WINDOWS;
-
-#if DRIINFO_MAJOR_VERSION > 5 || \
-    (DRIINFO_MAJOR_VERSION == 5 && DRIINFO_MINOR_VERSION >= 3)
-      if (pI830->accel == ACCEL_EXA)
-	 pDRIInfo->texOffsetStart = I830TexOffsetStart;
-#endif
-
-#if DRI_DRIVER_FRAMEBUFFER_MAP
-   /* DRI version is high enough that we can get the DRI code to not
-    * try to manage the framebuffer.
-    */
-   pDRIInfo->frameBufferPhysicalAddress = 0;
-   pDRIInfo->frameBufferSize = 0;
-   pDRIInfo->frameBufferStride = 0;
-   pDRIInfo->dontMapFrameBuffer = TRUE;
-#else
-   /* Supply a dummy mapping info required by DRI setup.
-    */
-   pDRIInfo->frameBufferPhysicalAddress = (char *) pI830->LinearAddr;
-   pDRIInfo->frameBufferSize = GTT_PAGE_SIZE;
-   pDRIInfo->frameBufferStride = 1;
-#endif
-
-   pDRIInfo->TransitionTo2d = I830DRITransitionTo2d;
-   pDRIInfo->TransitionTo3d = I830DRITransitionTo3d;
-
-   /* do driver-independent DRI screen initialization here */
-   if (!DRIScreenInit(pScreen, pDRIInfo, &pI830->drmSubFD)) {
-      xf86DrvMsg(pScreen->myNum, X_ERROR,
-		 "[dri] DRIScreenInit failed. Disabling DRI.\n");
-      xfree(pDRIInfo->devPrivate);
-      pDRIInfo->devPrivate = NULL;
-      DRIDestroyInfoRec(pI830->pDRIInfo);
-      pI830->pDRIInfo = NULL;
-      return FALSE;
-   }
-
-   /* Now, nuke dri.c's dummy frontbuffer map setup if we did that. */
-   if (pDRIInfo->frameBufferSize != 0) {
-       int tmp;
-       drm_handle_t fb_handle;
-       void *ptmp;
-
-       /* With the compat method, it will continue to report
-	* the wrong map out of GetDeviceInfo, which will break AIGLX.
-	*/
-       DRIGetDeviceInfo(pScreen, &fb_handle, &tmp, &tmp, &tmp, &tmp, &ptmp);
-       drmRmMap(pI830->drmSubFD, fb_handle);
-
-       xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-		  "Removed DRI frontbuffer mapping in compatibility mode.\n");
-       xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-		  "DRIGetDeviceInfo will report incorrect frontbuffer "
-		  "handle.\n");
-   }
-
-   /* Check the i915 DRM versioning */
-   {
-      drmVersionPtr version;
-
-      /* Check the DRM lib version.
-       * drmGetLibVersion was not supported in version 1.0, so check for
-       * symbol first to avoid possible crash or hang.
-       */
-      if (xf86LoaderCheckSymbol("drmGetLibVersion")) {
-	 version = drmGetLibVersion(pI830->drmSubFD);
-      } else
-      {
-	 /* drmlib version 1.0.0 didn't have the drmGetLibVersion
-	  * entry point.  Fake it by allocating a version record
-	  * via drmGetVersion and changing it to version 1.0.0
-	  */
-	 version = drmGetVersion(pI830->drmSubFD);
-	 version->version_major = 1;
-	 version->version_minor = 0;
-	 version->version_patchlevel = 0;
-      }
-
-#define REQ_MAJ 1
-#define REQ_MIN 1
-      if (version) {
-	 if (version->version_major != REQ_MAJ ||
-	     version->version_minor < REQ_MIN) {
-	    /* incompatible drm library version */
-	    xf86DrvMsg(pScreen->myNum, X_ERROR,
-		       "[dri] I830DRIScreenInit failed because of a version mismatch.\n"
-		       "[dri] libdrm.a module version is %d.%d.%d but version %d.%d.x is needed.\n"
-		       "[dri] Disabling DRI.\n",
-		       version->version_major,
-		       version->version_minor, version->version_patchlevel,
-		       REQ_MAJ, REQ_MIN);
-	    drmFreeVersion(version);
-	    I830DRICloseScreen(pScreen);
-	    return FALSE;
-	 }
-	 drmFreeVersion(version);
-      }
-
-      /* Check the i915 DRM version */
-      version = drmGetVersion(pI830->drmSubFD);
-      if (version) {
-	 if (version->version_major != 1 || version->version_minor < 3) {
-	    /* incompatible drm version */
-	    xf86DrvMsg(pScreen->myNum, X_ERROR,
-		       "[dri] %s failed because of a version mismatch.\n"
-		       "[dri] i915 kernel module version is %d.%d.%d but version 1.3 or greater is needed.\n"
-		       "[dri] Disabling DRI.\n",
-		       "I830DRIScreenInit",
-		       version->version_major,
-		       version->version_minor, version->version_patchlevel);
-	    I830DRICloseScreen(pScreen);
-	    drmFreeVersion(version);
-	    return FALSE;
-	 }
-	 /* Check whether the kernel module attached to the device isn't the
-	  * one we expected (meaning it's the old i830 module).
-	  */
-	 if (strncmp(version->name, pDRIInfo->drmDriverName,
-		     strlen(pDRIInfo->drmDriverName)))
-	 {
-	    xf86DrvMsg(pScreen->myNum, X_WARNING,
-		       "Detected i830 kernel module.  The i915 kernel module "
-		       "is required for DRI.  Aborting.\n");
-	    I830DRICloseScreen(pScreen);
-	    drmFreeVersion(version);
-	    return FALSE;
-	 }
-	 pI830->drmMinor = version->version_minor;
-	 drmFreeVersion(version);
-      }
-   }
-
-   return TRUE;
-}
-
-static void
-I830InitTextureHeap(ScrnInfoPtr pScrn)
-{
-   I830Ptr pI830 = I830PTR(pScrn);
-   drmI830MemInitHeap drmHeap;
-
-   if (pI830->textures == NULL)
-       return;
-
-   /* Start up the simple memory manager for agp space */
-   drmHeap.region = I830_MEM_REGION_AGP;
-   drmHeap.start  = 0;
-   drmHeap.size   = pI830->textures->size;
-
-   if (drmCommandWrite(pI830->drmSubFD, DRM_I830_INIT_HEAP,
-			  &drmHeap, sizeof(drmHeap))) {
-      xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		    "[drm] Failed to initialized agp heap manager\n");
-   } else {
-      xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-		    "[drm] Initialized kernel agp heap manager, %ld\n",
-		    pI830->textures->size);
-
-      I830SetParam(pScrn, I830_SETPARAM_TEX_LRU_LOG_GRANULARITY, 
-		   pI830->TexGranularity);
-   }
-}
-
-/*
- * Map registers & ring buffer
- */
-static Bool
-I830DRIMapHW(ScreenPtr pScreen)
-{
-   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-   I830Ptr pI830 = I830PTR(pScrn);
-   DRIInfoPtr pDRIInfo = pI830->pDRIInfo;
-   I830DRIPtr pI830DRI = pDRIInfo->devPrivate;
-
-   /* Kernel deals with direct hw access in this case */
-   if (pI830->use_drm_mode)
-       return TRUE;
-
-   DPRINTF(PFX, "I830DRIMapHW\n");
-   pI830DRI->regsSize = I830_REG_SIZE;
-   if (drmAddMap(pI830->drmSubFD, (drm_handle_t)pI830->MMIOAddr,
-		 pI830DRI->regsSize, DRM_REGISTERS, 0,
-		 (drmAddress) &pI830DRI->regs) < 0) {
-      xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAddMap(regs) failed\n");
-      DRICloseScreen(pScreen);
-      return FALSE;
-   }
-   xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Registers = 0x%08x\n",
-	      (int)pI830DRI->regs);
-
-   if (!pI830->memory_manager) {
-       if (drmAddMap(pI830->drmSubFD,
-		     (drm_handle_t)pI830->ring.mem->offset +
-		     pI830->LinearAddr,
-		     pI830->ring.mem->size, DRM_AGP, 0,
-		     (drmAddress) &pI830->ring_map) < 0) {
-	   xf86DrvMsg(pScreen->myNum, X_ERROR,
-		      "[drm] drmAddMap(ring_map) failed. Disabling DRI\n");
-	   DRICloseScreen(pScreen);
-	   return FALSE;
-       }
-       xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] ring buffer = 0x%08x\n",
-		  (int)pI830->ring_map);
-   }
-
-   return TRUE;
-}
-
-/**
- * Sets up mappings for static, lifetime-fixed allocations, and inital SAREA
- * setup.
- */
-Bool
-I830DRIDoMappings(ScreenPtr pScreen)
-{
-   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-   I830Ptr pI830 = I830PTR(pScrn);
-   DRIInfoPtr pDRIInfo = pI830->pDRIInfo;
-   I830DRIPtr pI830DRI = pDRIInfo->devPrivate;
-   drmI830Sarea *sarea = (drmI830Sarea *) DRIGetSAREAPrivate(pScreen);
-
-   if (!I830DRIMapHW(pScreen)) {
-       DRICloseScreen(pScreen);
-       return FALSE;
-   }
-
-   if (!I830InitDma(pScrn)) {
-      DRICloseScreen(pScreen);
-      return FALSE;
-   }
-
-   if (pI830->memory_manager == NULL)
-       intel_bufmgr_fake_set_last_dispatch(pI830->bufmgr,
-					   (volatile unsigned int *)
-					   &sarea->last_dispatch);
-
-   /* init to zero to be safe */
-   sarea->front_handle = 0;
-   sarea->back_handle = 0;
-   sarea->depth_handle = 0;
-   sarea->tex_handle = 0;
-
-   /* Assign pScreen */
-   pScrn->pScreen = pScreen;
-
-   /* Need to initialize pScreen now to let RandR know. */
-   pScrn->pScreen->width = pScrn->virtualX;
-   pScrn->pScreen->height = pScrn->virtualY;
-
-   /* If we are using the kernel memory manager, we have to delay SAREA and
-    * mapping setup until our buffers are pinned at EnterVT, losing the
-    * opportunity to fail cleanly early on.
-    */
-   if (pI830->memory_manager == NULL) {
-      if (!i830_update_dri_buffers(pScrn)) {
-	 /* screen mappings probably failed */
-	 xf86DrvMsg(pScreen->myNum, X_ERROR,
-		    "[drm] drmAddMap(screen mappings) failed. "
-		    "Disabling DRI\n");
-	 DRICloseScreen(pScreen);
-	 return FALSE;
-      }
-   }
-
-   if (pI830->allocate_classic_textures)
-      I830InitTextureHeap(pScrn);
-
-   if (DEVICE_ID(pI830->PciInfo) != PCI_CHIP_845_G &&
-       DEVICE_ID(pI830->PciInfo) != PCI_CHIP_I830_M) {
-      I830SetParam(pScrn, I830_SETPARAM_USE_MI_BATCHBUFFER_START, 1 );
-   }
-
-   pI830DRI = (I830DRIPtr) pI830->pDRIInfo->devPrivate;
-   pI830DRI->deviceID = DEVICE_ID(pI830->PciInfo);
-   pI830DRI->width = pScrn->virtualX;
-   pI830DRI->height = pScrn->virtualY;
-   pI830DRI->mem = pScrn->videoRam * 1024;
-   pI830DRI->cpp = pI830->cpp;
-
-   pI830DRI->bitsPerPixel = pScrn->bitsPerPixel;
-
-   pI830DRI->sarea_priv_offset = sizeof(XF86DRISAREARec);
-
-   if (!(I830InitVisualConfigs(pScreen))) {
-      xf86DrvMsg(pScreen->myNum, X_ERROR,
-		 "[dri] I830InitVisualConfigs failed. Disabling DRI\n");
-      DRICloseScreen(pScreen);
-      return FALSE;
-   }
-
-   xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] visual configs initialized\n");
-   pI830->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT;
-
-   return TRUE;
-}
-
-Bool
-I830DRIInstIrqHandler(ScrnInfoPtr pScrn)
-{
-   I830Ptr pI830 = I830PTR(pScrn);
-   I830DRIPtr pI830DRI = (I830DRIPtr) pI830->pDRIInfo->devPrivate;
-
-   pI830DRI->irq = drmGetInterruptFromBusID(pI830->drmSubFD,
-#if XSERVER_LIBPCIACCESS
-					       ((pI830->PciInfo->domain << 8) |
-						pI830->PciInfo->bus),
-					       pI830->PciInfo->dev,
-					       pI830->PciInfo->func
-#else
-					       ((pciConfigPtr) pI830->
-						PciInfo->thisCard)->busnum,
-					       ((pciConfigPtr) pI830->
-						PciInfo->thisCard)->devnum,
-					       ((pciConfigPtr) pI830->
-						PciInfo->thisCard)->funcnum
-#endif
-					       );
-
-   if (drmCtlInstHandler(pI830->drmSubFD, pI830DRI->irq)) {
-       xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-	       "[drm] failure adding irq handler\n");
-       pI830DRI->irq = 0;
-       return FALSE;
-   } else
-       xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-	       "[drm] dma control initialized, using IRQ %d\n",
-	       pI830DRI->irq);
-
-   return TRUE;
-}
-
-Bool
-I830DRIResume(ScreenPtr pScreen)
-{
-   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-   I830Ptr pI830 = I830PTR(pScrn);
-
-   DPRINTF(PFX, "I830DRIResume\n");
-
-   I830ResumeDma(pScrn);
-
-   if (!pI830->memory_manager)
-       I830DRIInstIrqHandler(pScrn);
-
-   return TRUE;
-}
-
-void
-I830DRICloseScreen(ScreenPtr pScreen)
-{
-   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-   I830Ptr pI830 = I830PTR(pScrn);
-   I830DRIPtr pI830DRI = (I830DRIPtr) pI830->pDRIInfo->devPrivate;
-
-   DPRINTF(PFX, "I830DRICloseScreen\n");
-
-   if (!pI830->memory_manager && pI830DRI->irq) {
-       drmCtlUninstHandler(pI830->drmSubFD);
-       pI830DRI->irq = 0;
-   }
-
-   I830CleanupDma(pScrn);
-
-   DRICloseScreen(pScreen);
-
-   if (pI830->pDRIInfo) {
-      if (pI830->pDRIInfo->devPrivate) {
-	 xfree(pI830->pDRIInfo->devPrivate);
-	 pI830->pDRIInfo->devPrivate = NULL;
-      }
-      DRIDestroyInfoRec(pI830->pDRIInfo);
-      pI830->pDRIInfo = NULL;
-   }
-   if (pI830->pVisualConfigs)
-      xfree(pI830->pVisualConfigs);
-   if (pI830->pVisualConfigsPriv)
-      xfree(pI830->pVisualConfigsPriv);
-   pI830->directRenderingType = DRI_NONE;
-}
-
-static Bool
-I830CreateContext(ScreenPtr pScreen, VisualPtr visual,
-		  drm_context_t hwContext, void *pVisualConfigPriv,
-		  DRIContextType contextStore)
-{
-   return TRUE;
-}
-
-static void
-I830DestroyContext(ScreenPtr pScreen, drm_context_t hwContext,
-		   DRIContextType contextStore)
-{
-}
-
-Bool
-I830DRIFinishScreenInit(ScreenPtr pScreen)
-{
-   DPRINTF(PFX, "I830DRIFinishScreenInit\n");
-
-   if (!DRIFinishScreenInit(pScreen))
-      return FALSE;
-
-   /* move irq initialize later in EnterVT, as then we
-    * would finish binding possible hw status page, which
-    * requires irq ctrl ioctl not be called that early.
-    */
-   return TRUE;
-}
-
-static void
-I830DRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
-		   DRIContextType oldContextType, void *oldContext,
-		   DRIContextType newContextType, void *newContext)
-{
-   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-   I830Ptr pI830 = I830PTR(pScrn);
-
-   if (syncType == DRI_3D_SYNC &&
-       oldContextType == DRI_2D_CONTEXT && newContextType == DRI_2D_CONTEXT) {
-
-      if (I810_DEBUG & DEBUG_VERBOSE_DRI)
-	 ErrorF("i830DRISwapContext (in)\n");
-
-      pI830->last_3d = LAST_3D_OTHER;
-
-      if (!pScrn->vtSema)
-     	 return;
-      pI830->LockHeld = 1;
-      if (!pI830->memory_manager)
-	  i830_refresh_ring(pScrn);
-
-   } else if (syncType == DRI_2D_SYNC &&
-	      oldContextType == DRI_NO_CONTEXT &&
-	      newContextType == DRI_2D_CONTEXT) {
-      if (I810_DEBUG & DEBUG_VERBOSE_DRI)
-	 ErrorF("i830DRISwapContext (out)\n");
-
-      if (!pScrn->vtSema)
-     	 return;
-      pI830->LockHeld = 0;
-   } else if (I810_DEBUG & DEBUG_VERBOSE_DRI)
-      ErrorF("i830DRISwapContext (other)\n");
-}
-
-static void
-I830DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index)
-{
-   ScreenPtr pScreen = pWin->drawable.pScreen;
-   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-   BoxPtr pbox;
-   int nbox;
-   int buffer, first_buffer, last_buffer;
-
-   if (I810_DEBUG & DEBUG_VERBOSE_DRI)
-      ErrorF("I830DRIInitBuffers\n");
-
-   first_buffer = I830_SELECT_BACK;
-   last_buffer = I830_SELECT_DEPTH;
-
-   for (buffer = first_buffer; buffer <= last_buffer; buffer++) {
-      pbox = REGION_RECTS(prgn);
-      nbox = REGION_NUM_RECTS(prgn);
-
-      if (!I830SelectBuffer(pScrn, buffer))
-	 continue;
-
-      if (buffer == I830_SELECT_DEPTH) {
-	 switch (pScrn->bitsPerPixel) {
-	 case 16:
-	    I830SetupForSolidFill(pScrn, 0xffff, GXcopy, -1);
-	    break;
-	 case 32:
-	    I830SetupForSolidFill(pScrn, 0xffffff, GXcopy, -1);
-	    break;
-	 }
-      } else
-	 I830SetupForSolidFill(pScrn, 0, GXcopy, -1);
-      while (nbox--) {
-	 I830SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
-				     pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
-	 pbox++;
-      }
-   }
-
-   I830SelectBuffer(pScrn, I830_SELECT_FRONT);
-   i830MarkSync(pScrn);
-}
-
-/* This routine is a modified form of XAADoBitBlt with the calls to
- * ScreenToScreenBitBlt built in. My routine has the prgnSrc as source
- * instead of destination. My origin is upside down so the ydir cases
- * are reversed.
- */
-static void
-I830DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
-		   RegionPtr prgnSrc, CARD32 index)
-{
-   ScreenPtr pScreen = pParent->drawable.pScreen;
-   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-   BoxPtr pboxTmp, pboxNext, pboxBase;
-   DDXPointPtr pptTmp, pptNew2 = NULL;
-   int xdir, ydir;
-
-#if 0
-   int screenwidth = pScrn->virtualX;
-   int screenheight = pScrn->virtualY;
-#else
-   int screenwidth = pScreen->width;
-   int screenheight = pScreen->height;
-#endif
-
-   BoxPtr pbox = REGION_RECTS(prgnSrc);
-   int nbox = REGION_NUM_RECTS(prgnSrc);
-
-   BoxPtr pboxNew1 = NULL;
-   BoxPtr pboxNew2 = NULL;
-   DDXPointPtr pptNew1 = NULL;
-   DDXPointPtr pptSrc = &ptOldOrg;
-
-   int dx = pParent->drawable.x - ptOldOrg.x;
-   int dy = pParent->drawable.y - ptOldOrg.y;
-   int buffer, first_buffer, last_buffer;
-
-   /* If the copy will overlap in Y, reverse the order */
-   if (dy > 0) {
-      ydir = -1;
-
-      if (nbox > 1) {
-	 /* Keep ordering in each band, reverse order of bands */
-	 pboxNew1 = (BoxPtr) xalloc(sizeof(BoxRec) * nbox);
-	 if (!pboxNew1)
-	    return;
-	 pptNew1 = (DDXPointPtr) xalloc(sizeof(DDXPointRec) * nbox);
-	 if (!pptNew1) {
-	    xfree(pboxNew1);
-	    return;
-	 }
-	 pboxBase = pboxNext = pbox + nbox - 1;
-	 while (pboxBase >= pbox) {
-	    while ((pboxNext >= pbox) && (pboxBase->y1 == pboxNext->y1))
-	       pboxNext--;
-	    pboxTmp = pboxNext + 1;
-	    pptTmp = pptSrc + (pboxTmp - pbox);
-	    while (pboxTmp <= pboxBase) {
-	       *pboxNew1++ = *pboxTmp++;
-	       *pptNew1++ = *pptTmp++;
-	    }
-	    pboxBase = pboxNext;
-	 }
-	 pboxNew1 -= nbox;
-	 pbox = pboxNew1;
-	 pptNew1 -= nbox;
-	 pptSrc = pptNew1;
-      }
-   } else {
-      /* No changes required */
-      ydir = 1;
-   }
-
-   /* If the regions will overlap in X, reverse the order */
-   if (dx > 0) {
-      xdir = -1;
-
-      if (nbox > 1) {
-	 /*reverse orderof rects in each band */
-	 pboxNew2 = (BoxPtr) xalloc(sizeof(BoxRec) * nbox);
-	 pptNew2 = (DDXPointPtr) xalloc(sizeof(DDXPointRec) * nbox);
-	 if (!pboxNew2 || !pptNew2) {
-	    if (pptNew2)
-	       xfree(pptNew2);
-	    if (pboxNew2)
-	       xfree(pboxNew2);
-	    if (pboxNew1) {
-	       xfree(pptNew1);
-	       xfree(pboxNew1);
-	    }
-	    return;
-	 }
-	 pboxBase = pboxNext = pbox;
-	 while (pboxBase < pbox + nbox) {
-	    while ((pboxNext < pbox + nbox) && (pboxNext->y1 == pboxBase->y1))
-	       pboxNext++;
-	    pboxTmp = pboxNext;
-	    pptTmp = pptSrc + (pboxTmp - pbox);
-	    while (pboxTmp != pboxBase) {
-	       *pboxNew2++ = *--pboxTmp;
-	       *pptNew2++ = *--pptTmp;
-	    }
-	    pboxBase = pboxNext;
-	 }
-	 pboxNew2 -= nbox;
-	 pbox = pboxNew2;
-	 pptNew2 -= nbox;
-	 pptSrc = pptNew2;
-      }
-   } else {
-      /* No changes are needed */
-      xdir = 1;
-   }
-
-   /* SelectBuffer isn't really a good concept for the i810.
-    */
-   I830EmitFlush(pScrn);
-   first_buffer = I830_SELECT_BACK;
-   last_buffer = I830_SELECT_DEPTH;
-
-   for (buffer = first_buffer; buffer <= last_buffer; buffer++) {
-      if (!I830SelectBuffer(pScrn, buffer))
-	 continue;
-      I830SetupForScreenToScreenCopy(pScrn, xdir, ydir, GXcopy, -1, -1);
-      pbox = REGION_RECTS(prgnSrc);
-      nbox = REGION_NUM_RECTS(prgnSrc);
-      for (; nbox--; pbox++) {
-
-	 int x1 = pbox->x1;
-	 int y1 = pbox->y1;
-	 int destx = x1 + dx;
-	 int desty = y1 + dy;
-	 int w = pbox->x2 - x1 + 1;
-	 int h = pbox->y2 - y1 + 1;
-
-	 if (destx < 0)
-	    x1 -= destx, w += destx, destx = 0;
-	 if (desty < 0)
-	    y1 -= desty, h += desty, desty = 0;
-	 if (destx + w > screenwidth)
-	    w = screenwidth - destx;
-	 if (desty + h > screenheight)
-	    h = screenheight - desty;
-	 if (w <= 0)
-	    continue;
-	 if (h <= 0)
-	    continue;
-
-	 if (I810_DEBUG & DEBUG_VERBOSE_DRI)
-	    ErrorF("MoveBuffers %d,%d %dx%d dx: %d dy: %d\n",
-		   x1, y1, w, h, dx, dy);
-
-	 I830SubsequentScreenToScreenCopy(pScrn, x1, y1, destx, desty, w, h);
-      }
-   }
-
-   I830SelectBuffer(pScrn, I830_SELECT_FRONT);
-   I830EmitFlush(pScrn);
-
-   if (pboxNew2) {
-      xfree(pptNew2);
-      xfree(pboxNew2);
-   }
-   if (pboxNew1) {
-      xfree(pptNew1);
-      xfree(pboxNew1);
-   }
-   i830MarkSync(pScrn);
-}
-
-static void
-I830DRITransitionTo3d(ScreenPtr pScreen)
-{
-   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-   I830Ptr pI830 = I830PTR(pScrn);
-
-   pI830->want_vblank_interrupts = TRUE;
-   I830DRISetVBlankInterrupt(pScrn, TRUE);
-}
-
-static void
-I830DRITransitionTo2d(ScreenPtr pScreen)
-{
-   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-   I830Ptr pI830 = I830PTR(pScrn);
-
-   pI830->want_vblank_interrupts = FALSE;
-   I830DRISetVBlankInterrupt(pScrn, FALSE);
-}
-
-static int
-i830_name_buffer (ScrnInfoPtr pScrn, i830_memory *mem)
-{
-    if (mem && mem->bo)
-    {
-	if (!mem->gem_name)
-	{
-	    int ret;
-	    ret = dri_bo_flink(mem->bo, &mem->gem_name);
-	    if (ret != 0)
-	    {
-		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-			   "[drm] failed to name buffer %d\n", -errno);
-		return -1;
-	    }
-	}
-	return mem->gem_name;
-    }
-    return -1;
-}
-
-/**
- * Update the SAREA fields with current buffer information.
- *
- * Most of the SAREA fields are already updated by i830_do_addmap().
- *
- * This does include other SAREA initialization which will actually be constant
- * over the lifetime of the server.
- */
-static void
-i830_update_sarea(ScrnInfoPtr pScrn, drmI830Sarea *sarea)
-{
-   ScreenPtr pScreen = pScrn->pScreen;
-   I830Ptr pI830 = I830PTR(pScrn);
-
-   if (pI830->directRenderingType == DRI_DRI2)
-       return;
-
-   sarea->width = pScreen->width;
-   sarea->height = pScreen->height;
-   sarea->pitch = pScrn->displayWidth;
-   sarea->virtualX = pScrn->virtualX;
-   sarea->virtualY = pScrn->virtualY;
-
-   sarea->front_tiled = (pI830->front_buffer->tiling != TILE_NONE);
-   sarea->back_tiled = (pI830->back_buffer->tiling != TILE_NONE);
-   sarea->depth_tiled = (pI830->depth_buffer->tiling != TILE_NONE);
-   sarea->rotated_tiled = FALSE;
-
-   sarea->log_tex_granularity = pI830->TexGranularity;
-
-   sarea->front_bo_handle = i830_name_buffer (pScrn, pI830->front_buffer);
-   sarea->back_bo_handle = i830_name_buffer (pScrn, pI830->back_buffer);
-   sarea->depth_bo_handle = i830_name_buffer (pScrn, pI830->depth_buffer);
-
-   /* The rotation is now handled entirely by the X Server, so just leave the
-    * DRI unaware.
-    */
-   sarea->rotation = 0;
-   sarea->rotated_offset = -1;
-   sarea->rotated_size = 0;
-   sarea->rotated_pitch = pScrn->displayWidth;
-}
-
-/**
- * Updates the DRI mapping for the given i830_memory struct, with the given
- * flags.
- */
-static int
-i830_do_addmap(ScrnInfoPtr pScrn, i830_memory *mem,
-	       drm_handle_t *sarea_handle, int *sarea_size, int *sarea_offset)
-{
-    I830Ptr pI830 = I830PTR(pScrn);
-    int size = mem->size;
-
-    if (mem == pI830->front_buffer) {
-	/* Workaround for XAA pixmap cache: Don't use front_buffer->size
-	 * and instead, calculate the visible frontbuffer size and round to
-	 * avoid irritating the assertions of older DRI drivers.
-	 */
-	size = ROUND_TO_PAGE(pScrn->displayWidth * pScrn->virtualY *
-			     pI830->cpp);
-    }
-
-    if (*sarea_handle != 0 &&
-	(*sarea_size != size || *sarea_offset != mem->offset))
-    {
-	drmRmMap(pI830->drmSubFD, *sarea_handle);
-	*sarea_handle = 0;
-	*sarea_size = 0;
-	*sarea_offset = 0;
-    }
-
-    if (*sarea_handle == 0) {
-	int ret;
-
-	ret = drmAddMap(pI830->drmSubFD,
-			(drm_handle_t)(mem->offset + pI830->LinearAddr),
-			size, DRM_AGP, 0,
-			(drmAddress) sarea_handle);
-	if (ret == 0) {
-	    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-		       "[drm] mapped %s at 0x%08lx, handle = 0x%08x\n",
-		       mem->name, mem->offset + pI830->LinearAddr,
-		       (int)*sarea_handle);
-	    *sarea_size = size;
-	    *sarea_offset = mem->offset;
-	} else {
-	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		       "[drm] failed to map %s at 0x%08lx\n",
-		       mem->name, mem->offset + pI830->LinearAddr);
-	    return FALSE;
-	}
-    }
-
-    return TRUE;
-}
-
-/**
- * Updates the DRM mappings with the current buffer information.
- *
- * Some old DRI drivers may be unprepared for buffers actually moving at
- * runtime, which would likely result in bus errors on software fallbacks or
- * hangs or misrendering on hardware rendering.
- */
-static Bool
-i830_update_dri_mappings(ScrnInfoPtr pScrn, drmI830Sarea *sarea)
-{
-   I830Ptr pI830 = I830PTR(pScrn);
-
-   if (!i830_do_addmap(pScrn, pI830->front_buffer, &sarea->front_handle,
-		       &sarea->front_size, &sarea->front_offset)) {
-       xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling DRI.\n");
-       return FALSE;
-   }
-
-   if (!i830_do_addmap(pScrn, pI830->back_buffer, &sarea->back_handle,
-		       &sarea->back_size, &sarea->back_offset)) {
-       xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling DRI.\n");
-       return FALSE;
-   }
-
-   sarea->third_handle = 0;
-   sarea->third_offset = 0;
-   sarea->third_size = 0;
-
-   if (!i830_do_addmap(pScrn, pI830->depth_buffer, &sarea->depth_handle,
-		       &sarea->depth_size, &sarea->depth_offset)) {
-       xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling DRI.\n");
-       return FALSE;
-   }
-
-   if (pI830->allocate_classic_textures) {
-       if (!i830_do_addmap(pScrn, pI830->textures, &sarea->tex_handle,
-			   &sarea->tex_size, &sarea->tex_offset)) {
-	   xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling DRI.\n");
-	   return FALSE;
-       }
-   }
-
-   return TRUE;
-}
-
-static void
-i830_update_screen_private(ScrnInfoPtr pScrn, drmI830Sarea *sarea)
-{
-   I830Ptr pI830 = I830PTR(pScrn);
-
-   pI830->pDRIInfo->frameBufferPhysicalAddress = (char *) pI830->LinearAddr;
-   pI830->pDRIInfo->frameBufferStride = pScrn->displayWidth * pI830->cpp;
-   pI830->pDRIInfo->frameBufferSize = sarea->front_size;
-#if DRI_DRIVER_FRAMEBUFFER_MAP
-   pI830->pDRIInfo->hFrameBuffer = sarea->front_handle;
-#endif
-}
-
-/**
- * Update the SAREA fields, DRI mappings, and screen info passed through the
- * protocol.
- *
- * This gets called both at startup and after any of the buffers might have
- * been relocated.
- */
-Bool
-i830_update_dri_buffers(ScrnInfoPtr pScrn)
-{
-   ScreenPtr pScreen = pScrn->pScreen;
-   I830Ptr pI830 = I830PTR(pScrn);
-   drmI830Sarea *sarea;
-   Bool success;
-
-   if (pI830->directRenderingType != DRI_XF86DRI)
-       return TRUE;
-
-   sarea = (drmI830Sarea *) DRIGetSAREAPrivate(pScreen);
-
-   success = i830_update_dri_mappings(pScrn, sarea);
-   if (!success)
-       return FALSE;
-   i830_update_sarea(pScrn, sarea);
-   i830_update_screen_private(pScrn, sarea);
-
-   return TRUE;
-}
-
-Bool
-I830DRISetVBlankInterrupt (ScrnInfoPtr pScrn, Bool on)
-{
-    I830Ptr pI830 = I830PTR(pScrn);
-    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-    drmI830VBlankPipe pipe;
-
-    /* If we have no 3d running, then don't bother enabling the vblank
-     * interrupt.
-     */
-    if (!pI830->want_vblank_interrupts)
-	on = FALSE;
-
-    if (pI830->directRenderingType == DRI_XF86DRI && pI830->drmMinor >= 5) {
-	if (on) {
-	    if (xf86_config->num_crtc > 1 && xf86_config->crtc[1]->enabled)
-		if (pI830->drmMinor >= 6)
-		    pipe.pipe = DRM_I830_VBLANK_PIPE_A | DRM_I830_VBLANK_PIPE_B;
-		else
-		    pipe.pipe = DRM_I830_VBLANK_PIPE_B;
-	    else
-		pipe.pipe = DRM_I830_VBLANK_PIPE_A;
-	} else {
-	    pipe.pipe = 0;
-	}
-	if (drmCommandWrite(pI830->drmSubFD, DRM_I830_SET_VBLANK_PIPE,
-			    &pipe, sizeof (pipe))) {
-	    return FALSE;
-	}
-    }
-
-    return TRUE;
-}
-
-Bool
-I830DRILock(ScrnInfoPtr pScrn)
-{
-   I830Ptr pI830 = I830PTR(pScrn);
-
-   if (pI830->directRenderingType == DRI_XF86DRI && !pI830->LockHeld) {
-      DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
-      pI830->LockHeld = 1;
-      if (!pI830->memory_manager)
-	  i830_refresh_ring(pScrn);
-      return TRUE;
-   }
-   else
-      return FALSE;
-}
-
-
-
-void
-I830DRIUnlock(ScrnInfoPtr pScrn)
-{
-   I830Ptr pI830 = I830PTR(pScrn);
-
-   if (pI830->directRenderingType == DRI_XF86DRI && pI830->LockHeld) {
-      DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
-      pI830->LockHeld = 0;
-   }
-}
-
-#ifdef DRI2
 
 typedef struct {
     PixmapPtr pPixmap;
@@ -1755,5 +319,3 @@ void I830DRI2CloseScreen(ScreenPtr pScreen)
     DRI2CloseScreen(pScreen);
     pI830->directRenderingType = DRI_NONE;
 }
-
-#endif
diff --git a/src/i830_driver.c b/src/i830_driver.c
index f1ea511..1fc7632 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -206,11 +206,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "i830_hwmc.h"
 #endif
 
-#ifdef XF86DRI
-#include "dri.h"
 #include <sys/ioctl.h>
 #include "i915_drm.h"
-#endif
 
 #ifdef XF86DRM_MODE
 #include <xf86drmMode.h>
@@ -1627,7 +1624,6 @@ I830AccelMethodInit(ScrnInfoPtr pScrn)
     if (!xf86ReturnOptValBool(pI830->Options, OPTION_DRI, TRUE))
 	pI830->directRenderingType = DRI_DISABLED;
 
-#ifdef XF86DRI
     if (pI830->accel == ACCEL_NONE) {
 	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DRI is disabled because it "
 		"needs 2D acceleration.\n");
@@ -1637,7 +1633,6 @@ I830AccelMethodInit(ScrnInfoPtr pScrn)
 		"runs only at depths 16 and 24.\n");
 	pI830->directRenderingType = DRI_DISABLED;
     }
-#endif /* XF86DRI */
 
     I830MapMMIO(pScrn);
 
@@ -1667,12 +1662,8 @@ I830AccelMethodInit(ScrnInfoPtr pScrn)
 
     SaveHWState(pScrn);
     pI830->can_resize = FALSE;
-    if (pI830->accel == ACCEL_UXA && pI830->directRenderingType != DRI_XF86DRI)
+    if (pI830->accel == ACCEL_UXA)
 	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",
@@ -1714,7 +1705,7 @@ I830DrmModeInit(ScrnInfoPtr pScrn)
     }
 
     pI830->can_resize = FALSE;
-    if (pI830->accel == ACCEL_UXA && pI830->directRenderingType != DRI_XF86DRI)
+    if (pI830->accel == ACCEL_UXA)
 	pI830->can_resize = TRUE;
 
     xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@@ -1744,7 +1735,6 @@ I830DrmModeInit(ScrnInfoPtr pScrn)
     }
 
     pI830->directRenderingType = DRI_NONE;
-    pI830->allocate_classic_textures = FALSE;
 
     i830_init_bufmgr(pScrn);
 #endif
@@ -1976,23 +1966,11 @@ I830PreInit(ScrnInfoPtr pScrn, int flags)
        xf86SetOperatingState(resVgaMem, pI830->pEnt->index, ResDisableOpr);
    }
 
-#if defined(XF86DRI)
-   /* Load the dri module if requested. */
-   if (xf86ReturnOptValBool(pI830->Options, OPTION_DRI, FALSE) &&
-       pI830->directRenderingType != DRI_DISABLED) {
-      if (xf86LoadSubModule(pScrn, "dri")) {
-	 xf86LoaderReqSymLists(I810driSymbols, I810drmSymbols, NULL);
-      }
-   }
-#endif
-
-#if defined(DRI2)
    /* Load the dri2 module if requested. */
    if (xf86ReturnOptValBool(pI830->Options, OPTION_DRI, FALSE) &&
        pI830->directRenderingType != DRI_DISABLED) {
        xf86LoadSubModule(pScrn, "dri2");
    }
-#endif
 
    pI830->preinit = FALSE;
 
@@ -2268,9 +2246,6 @@ RestoreHWState(ScrnInfoPtr pScrn)
 
    DPRINTF(PFX, "RestoreHWState\n");
 
-#ifdef XF86DRI
-   I830DRISetVBlankInterrupt (pScrn, FALSE);
-#endif
    /* Disable outputs */
    for (i = 0; i < xf86_config->num_output; i++) {
       xf86OutputPtr   output = xf86_config->output[i];
@@ -2582,16 +2557,6 @@ IntelEmitInvarientState(ScrnInfoPtr pScrn)
    if (pI830->accel == ACCEL_NONE)
       return;
 
-#ifdef XF86DRI
-   if (pI830->directRenderingType == DRI_XF86DRI) {
-      drmI830Sarea *sarea = DRIGetSAREAPrivate(pScrn->pScreen);
-
-      /* Mark that the X Server was the last holder of the context */
-      if (sarea)
-	 sarea->ctxOwner = DRIGetContext(pScrn->pScreen);
-   }
-#endif
-
    /* If we've emitted our state since the last clobber by another client,
     * skip it.
     */
@@ -2638,10 +2603,8 @@ I830BlockHandler(int i,
 	* fashion.
 	*/
        intel_batch_flush(pScrn, flushed);
-#ifdef XF86DRI
        if (pI830->memory_manager)
 	 drmCommandNone(pI830->drmSubFD, DRM_I915_GEM_THROTTLE);
-#endif
 
        pI830->need_mi_flush = FALSE;
     }
@@ -2703,7 +2666,6 @@ i830_try_memory_allocation(ScrnInfoPtr pScrn)
 {
     I830Ptr pI830 = I830PTR(pScrn);
     Bool tiled = pI830->tiling;
-    Bool xf86dri = pI830->directRenderingType == DRI_XF86DRI;
 
     xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 	    "Attempting memory allocation with %stiled buffers.\n",
@@ -2716,9 +2678,6 @@ i830_try_memory_allocation(ScrnInfoPtr pScrn)
 	if (!i830_allocate_pwrctx(pScrn))
 	    goto failed;
 
-    if (xf86dri && !i830_allocate_3d_memory(pScrn))
-	goto failed;
-
     xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%siled allocation successful.\n",
 	    tiled ? "T" : "Unt");
     return TRUE;
@@ -2783,18 +2742,6 @@ i830_memory_init(ScrnInfoPtr pScrn)
 		"disabled\n");
     pI830->fb_compression = FALSE;
 
-    /* Try again, but leave DRI enabled */
-    if (pI830->directRenderingType == DRI_XF86DRI) {
-	if (i830_try_memory_allocation(pScrn))
-	    return TRUE;
-	else {
-	    i830_reset_allocations(pScrn);
-	    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Couldn't allocate 3D memory, "
-		    "disabling DRI.\n");
-	    pI830->directRenderingType = DRI_NONE;
-	}
-    }
-
     if (i830_try_memory_allocation(pScrn))
 	return TRUE;
 
@@ -2904,9 +2851,7 @@ I830SwapPipes(ScrnInfoPtr pScrn)
     *       alone in that case.
     * Also make sure the DRM can handle the swap.
     */
-   if (I830LVDSPresent(pScrn) && !IS_I965GM(pI830) && !IS_GM45(pI830) &&
-       (pI830->directRenderingType != DRI_XF86DRI ||
-	(pI830->directRenderingType == DRI_XF86DRI && pI830->drmMinor >= 10))) {
+   if (I830LVDSPresent(pScrn) && !IS_I965GM(pI830) && !IS_GM45(pI830)) {
        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "adjusting plane->pipe mappings "
 		  "to allow for framebuffer compression\n");
        for (c = 0; c < config->num_crtc; c++) {
@@ -3011,14 +2956,6 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
        pI830->directRenderingType = DRI_DRI2;
 #endif
 
-#ifdef XF86DRI
-   /* If DRI hasn't been explicitly disabled, try to initialize it.
-    * It will be used by the memory allocator.
-    */
-   if (!pI830->can_resize && pI830->directRenderingType == DRI_NONE && I830DRIScreenInit(pScreen))
-       pI830->directRenderingType = DRI_XF86DRI;
-#endif
-
    /* Enable tiling by default */
    pI830->tiling = TRUE;
 
@@ -3118,32 +3055,8 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
    }
    i830_init_bufmgr(pScrn);
 
-#ifdef XF86DRI
-   /*
-    * Setup DRI after visuals have been established, but before fbScreenInit
-    * is called.   fbScreenInit will eventually call into the drivers
-    * InitGLXVisuals call back.
-    */
-   if (pI830->directRenderingType == DRI_XF86DRI) {
-      if (pI830->accel == ACCEL_NONE) {
-	 xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "DRI is disabled because it "
-		    "needs 2D acceleration.\n");
-	 pI830->directRenderingType = DRI_NONE;
-      }
-   }
-
-   if (pI830->directRenderingType == DRI_XF86DRI &&
-       !I830DRIDoMappings(pScreen))
-       pI830->directRenderingType = DRI_NONE;
-
-   /* If we failed for any reason, free DRI memory. */
-   if (pI830->directRenderingType != DRI_XF86DRI &&
-       pI830->back_buffer != NULL)
-       i830_free_3d_memory(pScrn);
-
    if (!pI830->use_drm_mode)
        I830SwapPipes(pScrn);
-#endif
 
    pScrn->fbOffset = pI830->front_buffer->offset;
 
@@ -3222,15 +3135,6 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
       xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 		 "Hardware cursor initialization failed\n");
 
-#ifdef XF86DRI
-   /* Must be called before EnterVT, so we can acquire the DRI lock when
-    * binding our memory.
-    */
-   if (pI830->directRenderingType == DRI_XF86DRI &&
-       !I830DRIFinishScreenInit(pScreen))
-       pI830->directRenderingType = DRI_NONE;
-#endif
-
    /* Must force it before EnterVT, so we are in control of VT and
     * later memory should be bound when allocating, e.g rotate_mem */
    pScrn->vtSema = TRUE;
@@ -3266,9 +3170,8 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 #ifdef I830_XV
 #ifdef INTEL_XVMC
     pI830->XvMCEnabled = FALSE;
-    from =  (pI830->directRenderingType == DRI_XF86DRI &&
-	     xf86GetOptValBool(pI830->Options, OPTION_XVMC,
-			       &pI830->XvMCEnabled)) ? X_CONFIG : X_DEFAULT;
+    from =  xf86GetOptValBool(pI830->Options, OPTION_XVMC,
+			      &pI830->XvMCEnabled) ? X_CONFIG : X_DEFAULT;
     xf86DrvMsg(pScrn->scrnIndex, from, "Intel XvMC decoder %sabled\n",
 	       pI830->XvMCEnabled ? "en" : "dis");
 #endif
@@ -3280,13 +3183,8 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
    /* Setup 3D engine, needed for rotation too */
    IntelEmitInvarientState(pScrn);
 
-#if defined(XF86DRI) || defined(DRI2)
+#if defined(DRI2)
    switch (pI830->directRenderingType) {
-   case DRI_XF86DRI:
-      pI830->directRenderingOpen = TRUE;
-      xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-		 "direct rendering: XF86DRI Enabled\n");
-      break;
    case DRI_DRI2:
       pI830->directRenderingOpen = TRUE;
       xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: DRI2 Enabled\n");
@@ -3377,17 +3275,6 @@ I830LeaveVT(int scrnIndex, int flags)
 
    i830SetHotkeyControl(pScrn, HOTKEY_BIOS_SWITCH);
 
-#ifdef XF86DRI
-   if (pI830->directRenderingOpen &&
-       pI830->directRenderingType == DRI_XF86DRI) {
-      DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
-
-      if (!pI830->memory_manager) {
-	  I830DRISetVBlankInterrupt (pScrn, FALSE);
-	  drmCtlUninstHandler(pI830->drmSubFD);
-      }
-   }
-#endif
 
 #ifndef HAVE_FREE_SHADOW
    for (o = 0; o < config->num_crtc; o++) {
@@ -3429,7 +3316,6 @@ I830LeaveVT(int scrnIndex, int flags)
 
    i830_unbind_all_memory(pScrn);
 
-#ifdef XF86DRI
    if (pI830->memory_manager && !pI830->use_drm_mode) {
       int ret;
 
@@ -3440,7 +3326,6 @@ I830LeaveVT(int scrnIndex, int flags)
       if (ret != 0)
 	 FatalError("DRM_I915_LEAVEVT failed: %s\n", strerror(ret));
    }
-#endif /* XF86DRI */
 
    if ((pI830->accel == ACCEL_EXA || pI830->accel == ACCEL_UXA) && IS_I965G(pI830))
       gen4_render_state_cleanup(pScrn);
@@ -3448,12 +3333,10 @@ I830LeaveVT(int scrnIndex, int flags)
    if (pI830->AccelInfoRec)
       pI830->AccelInfoRec->NeedToSync = FALSE;
 
-#ifdef XF86DRI
    ret = drmDropMaster(pI830->drmSubFD);
    if (ret)
       xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
 		 "drmDropMaster failed: %s\n", strerror(ret));
-#endif
 }
 
 /*
@@ -3469,12 +3352,10 @@ I830EnterVT(int scrnIndex, int flags)
 
    DPRINTF(PFX, "Enter VT\n");
 
-#ifdef XF86DRI
    ret = drmSetMaster(pI830->drmSubFD);
    if (ret)
       xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
 		 "drmDropMaster failed: %s\n", strerror(ret));
-#endif
 
    /*
     * Only save state once per server generation since that's what most
@@ -3508,7 +3389,6 @@ I830EnterVT(int scrnIndex, int flags)
    if (!pI830->use_drm_mode)
        i830_disable_render_standby(pScrn);
 
-#ifdef XF86DRI
    if (pI830->memory_manager && !pI830->use_drm_mode) {
       int ret;
 
@@ -3519,7 +3399,6 @@ I830EnterVT(int scrnIndex, int flags)
       if (ret != 0)
 	 FatalError("DRM_I915_ENTERVT failed: %s\n", strerror(ret));
    }
-#endif /* XF86DRI */
 
    if (!i830_bind_all_memory(pScrn))
       return FALSE;
@@ -3571,54 +3450,6 @@ I830EnterVT(int scrnIndex, int flags)
        i830DescribeOutputConfiguration(pScrn);
    }
 
-#ifdef XF86DRI
-   if (pI830->directRenderingType == DRI_XF86DRI) {
-       /* HW status is fixed, we need to set it up before any drm
-	* operation which accessing that page, like irq install, etc.
-	*/
-       if (pI830->starting && !pI830->memory_manager) {
-	   if (pI830->hw_status != NULL && !I830DRISetHWS(pScrn)) {
-		   xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-			   "Fail to setup hardware status page.\n");
-		   I830DRICloseScreen(pScrn->pScreen);
-		   return FALSE;
-	   }
-	   if (!pI830->memory_manager && !I830DRIInstIrqHandler(pScrn)) {
-	       I830DRICloseScreen(pScrn->pScreen);
-	       return FALSE;
-	   }
-       }
-
-      /* Update buffer offsets in sarea and mappings, since buffer offsets
-       * may have changed.
-       */
-      if (!i830_update_dri_buffers(pScrn))
-	 FatalError("i830_update_dri_buffers() failed\n");
-
-      I830DRISetVBlankInterrupt (pScrn, TRUE);
-
-      if (!pI830->starting) {
-         ScreenPtr pScreen = pScrn->pScreen;
-         drmI830Sarea *sarea = (drmI830Sarea *) DRIGetSAREAPrivate(pScreen);
-         int i;
-
-	 I830DRIResume(screenInfo.screens[scrnIndex]);
-
-	 if (!pI830->memory_manager)
-	    i830_refresh_ring(pScrn);
-	 I830Sync(pScrn);
-
-	 sarea->texAge++;
-	 for(i = 0; i < I830_NR_TEX_REGIONS+1 ; i++)
-	    sarea->texList[i].age = sarea->texAge;
-
-	 DPRINTF(PFX, "calling dri unlock\n");
-	 DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
-      }
-      pI830->LockHeld = 0;
-   }
-#endif
-
    /* Set the hotkey to just notify us.  We could check its results
     * periodically and attempt to do something, but it seems like we basically
     * never get results when we should, and this should all be better handled
@@ -3705,20 +3536,10 @@ I830CloseScreen(int scrnIndex, ScreenPtr pScreen)
    dri_bufmgr_destroy(pI830->bufmgr);
    pI830->bufmgr = NULL;
 
-#ifdef XF86DRI
-   if (pI830->directRenderingOpen &&
-       pI830->directRenderingType == DRI_XF86DRI) {
-      pI830->directRenderingOpen = FALSE;
-      I830DRICloseScreen(pScreen);
-   }
-#endif
-
-#ifdef DRI2
    if (pI830->directRenderingOpen && pI830->directRenderingType == DRI_DRI2) {
       pI830->directRenderingOpen = FALSE;
       I830DRI2CloseScreen(pScreen);
    }
-#endif
 
    xf86GARTCloseScreen(scrnIndex);
 
diff --git a/src/i830_exa.c b/src/i830_exa.c
index 7413ae2..03000a3 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -737,8 +737,6 @@ I830EXAInit(ScreenPtr pScreen)
 	}
     }
 
-    I830SelectBuffer(pScrn, I830_SELECT_FRONT);
-
     return TRUE;
 }
 
@@ -1041,26 +1039,8 @@ i830_uxa_init (ScreenPtr pScreen)
     pScreen->CreatePixmap = i830_uxa_create_pixmap;
     pScreen->DestroyPixmap = i830_uxa_destroy_pixmap;
 
-    I830SelectBuffer(scrn, I830_SELECT_FRONT);
-
     uxa_set_fallback_debug(pScreen, i830->fallback_debug);
 
     return TRUE;
 }
 #endif /* I830_USE_UXA */
-
-#ifdef XF86DRI
-
-#ifndef ExaOffscreenMarkUsed
-extern void ExaOffscreenMarkUsed(PixmapPtr);
-#endif
-
-unsigned long long
-I830TexOffsetStart(PixmapPtr pPix)
-{
-    exaMoveInPixmap(pPix);
-    ExaOffscreenMarkUsed(pPix);
-
-    return exaGetPixmapOffset(pPix);
-}
-#endif
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 470734e..38bf08d 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -107,9 +107,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "i830.h"
 #include "i810_reg.h"
-#ifdef XF86DRI
 #include "i915_drm.h"
-#endif
 
 #define ALIGN(i,m)    (((i) + (m) - 1) & ~((m) - 1))
 
@@ -225,7 +223,6 @@ i830_bind_memory(ScrnInfoPtr pScrn, i830_memory *mem)
     if (mem == NULL || mem->bound)
 	return TRUE;
 
-#ifdef XF86DRI
     if (mem->bo != NULL) {
 	if (dri_bo_pin(mem->bo, mem->alignment) != 0) {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -238,7 +235,6 @@ i830_bind_memory(ScrnInfoPtr pScrn, i830_memory *mem)
 	mem->offset = mem->bo->offset;
 	mem->end = mem->offset + mem->size;
     }
-#endif
 
     if (!mem->bound) {
 	if (!pI830->gtt_acquired)
@@ -274,7 +270,6 @@ i830_unbind_memory(ScrnInfoPtr pScrn, i830_memory *mem)
 	!pI830->kernel_exec_fencing)
 	i830_clear_tiling(pScrn, mem->fence_nr);
 
-#ifdef XF86DRI
     if (mem->bo != NULL) {
 	if (dri_bo_unpin(mem->bo) == 0) {
 	    mem->bound = FALSE;
@@ -286,7 +281,6 @@ i830_unbind_memory(ScrnInfoPtr pScrn, i830_memory *mem)
 	    return FALSE;
 	}
     }
-#endif
 
     if (mem->key == -1 || xf86UnbindGARTMemory(pScrn->scrnIndex, mem->key)) {
 	mem->bound = FALSE;
@@ -305,7 +299,6 @@ i830_free_memory(ScrnInfoPtr pScrn, i830_memory *mem)
     /* Free any AGP memory. */
     i830_unbind_memory(pScrn, mem);
 
-#ifdef XF86DRI
     if (mem->bo != NULL) {
 	I830Ptr pI830 = I830PTR(pScrn);
 	dri_bo_unreference (mem->bo);
@@ -323,7 +316,6 @@ i830_free_memory(ScrnInfoPtr pScrn, i830_memory *mem)
 	xfree(mem);
 	return;
     }
-#endif
 	    /* Disconnect from the list of allocations */
     if (mem->prev != NULL)
 	mem->prev->next = mem->next;
@@ -352,14 +344,12 @@ i830_reset_allocations(ScrnInfoPtr pScrn)
     while (pI830->memory_list->next->next != NULL) {
 	i830_memory *mem = pI830->memory_list->next;
 
-#ifdef XF86DRI
 	/* Don't reset BO allocator, which we set up at init. */
 	if (pI830->memory_manager == mem) {
 	    mem = mem->next;
 	    if (mem->next == NULL)
 		break;
 	}
-#endif	
 
 	i830_free_memory(pScrn, mem);
     }
@@ -383,30 +373,10 @@ i830_reset_allocations(ScrnInfoPtr pScrn)
     pI830->exa_offscreen = NULL;
     pI830->overlay_regs = NULL;
     pI830->power_context = NULL;
-#ifdef XF86DRI
-    pI830->back_buffer = NULL;
-    pI830->depth_buffer = NULL;
-    pI830->textures = NULL;
-#endif
     pI830->ring.mem = NULL;
     pI830->fake_bufmgr_mem = NULL;
 }
 
-void
-i830_free_3d_memory(ScrnInfoPtr pScrn)
-{
-    I830Ptr pI830 = I830PTR(pScrn);
-
-#ifdef XF86DRI
-    i830_free_memory(pScrn, pI830->back_buffer);
-    pI830->back_buffer = NULL;
-    i830_free_memory(pScrn, pI830->depth_buffer);
-    pI830->depth_buffer = NULL;
-    i830_free_memory(pScrn, pI830->textures);
-    pI830->textures = NULL;
-#endif
-}
-
 /**
  * Initialize's the driver's video memory allocator to allocate in the
  * given range.
@@ -421,13 +391,9 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long offset, unsigned long size)
 {
     I830Ptr pI830 = I830PTR(pScrn);
     i830_memory *start, *end;
-#ifdef XF86DRI
-    int dri_major, dri_minor, dri_patch;
     struct drm_i915_getparam gp;
     struct drm_i915_setparam sp;
     int has_gem;
-    int has_dri;
-#endif
 
     start = xcalloc(1, sizeof(*start));
     if (start == NULL)
@@ -464,18 +430,9 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long offset, unsigned long size)
 
     pI830->memory_list = start;
 
-#ifdef XF86DRI
     has_gem = FALSE;
-    has_dri = FALSE;
-    
-    if (pI830->directRenderingType == DRI_XF86DRI &&
-	xf86LoaderCheckSymbol ("DRIQueryVersion"))
-    {
-	DRIQueryVersion(&dri_major, &dri_minor, &dri_patch);
-	has_dri = TRUE;
-    }
 
-    if (pI830->directRenderingType >= DRI_XF86DRI)
+    if (pI830->directRenderingType >= DRI_DRI2)
     {
 	has_gem = FALSE;
 	gp.param = I915_PARAM_HAS_GEM;
@@ -490,10 +447,7 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long offset, unsigned long size)
      * 5.4 or newer so we can rely on the lock being held after DRIScreenInit,
      * rather than after DRIFinishScreenInit.
      */
-    if ((pI830->directRenderingType == DRI_XF86DRI && has_gem && has_dri &&
-	(dri_major > 5 || (dri_major == 5 && dri_minor >= 4))) ||
-	(pI830->directRenderingType == DRI_DRI2 && has_gem))
-    {
+    if (pI830->directRenderingType == DRI_DRI2 && has_gem) {
 	int mmsize;
 
 	/* Take over all of the graphics aperture minus enough to for
@@ -562,10 +516,7 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long offset, unsigned long size)
 	    i830_free_memory(pScrn, pI830->memory_manager);
 	    pI830->memory_manager = NULL;
 	}
-    } else {
-	pI830->allocate_classic_textures = TRUE;
     }
-#endif /* XF86DRI */
 
     return TRUE;
 }
@@ -798,7 +749,6 @@ i830_allocate_agp_memory(ScrnInfoPtr pScrn, i830_memory *mem, int flags)
     return TRUE;
 }
 
-#ifdef XF86DRI
 static i830_memory *
 i830_allocate_memory_bo(ScrnInfoPtr pScrn, const char *name,
 			unsigned long size, unsigned long pitch,
@@ -886,7 +836,6 @@ i830_allocate_memory_bo(ScrnInfoPtr pScrn, const char *name,
 
     return mem;
 }
-#endif /* XF86DRI */
 
 /* Allocates video memory at the given size, pitch, alignment and tile format.
  *
@@ -913,9 +862,7 @@ i830_allocate_memory(ScrnInfoPtr pScrn, const char *name,
 		     enum tile_format tile_format)
 {
     i830_memory *mem;
-#ifdef XF86DRI
     I830Ptr pI830 = I830PTR(pScrn);
-#endif
 
     /* Manage tile alignment and size constraints */
     if (tile_format != TILE_NONE) {
@@ -935,14 +882,12 @@ i830_allocate_memory(ScrnInfoPtr pScrn, const char *name,
 	size = i830_get_fence_size(pI830, size);
 	alignment = i830_get_fence_alignment(pI830, size);
     }
-#ifdef XF86DRI
     if (pI830->use_drm_mode || (pI830->memory_manager &&
 				!(flags & NEED_PHYSICAL_ADDR) &&
 				!(flags & NEED_LIFETIME_FIXED)))
     {
 	return i830_allocate_memory_bo(pScrn, name, size, pitch, alignment, flags, tile_format);
     } else
-#endif /* XF86DRI */
     {
 	mem = i830_allocate_aperture(pScrn, name, size, pitch, alignment, flags, tile_format);
 	if (mem == NULL)
@@ -1516,167 +1461,6 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn)
     return TRUE;
 }
 
-#ifdef XF86DRI
-static unsigned int
-myLog2(unsigned int n)
-{
-    unsigned int log2 = 1;
-
-    while (n > 1) {
-	n >>= 1;
-	log2++;
-    }
-    return log2;
-}
-
-static Bool
-i830_allocate_backbuffer(ScrnInfoPtr pScrn, i830_memory **buffer,
-			 const char *name)
-{
-    I830Ptr pI830 = I830PTR(pScrn);
-    unsigned int pitch = pScrn->displayWidth * pI830->cpp;
-    unsigned long size;
-    int height;
-    enum tile_format tile_format = TILE_NONE;;
-
-    if (pI830->rotation & (RR_Rotate_0 | RR_Rotate_180))
-	height = pScrn->virtualY;
-    else
-	height = pScrn->virtualX;
-
-    /* Try to allocate on the best tile-friendly boundaries. */
-    if (pI830->tiling && IsTileable(pScrn, pitch))
-    {
-	size = ROUND_TO_PAGE(pitch * ALIGN(height, 16));
-	tile_format = TILE_XMAJOR;
-    }
-    else
-    {
-	size = ROUND_TO_PAGE(pitch * height);
-	tile_format = TILE_NONE;
-    }
-    *buffer = i830_allocate_memory(pScrn, name, size, pitch,
-				   GTT_PAGE_SIZE,
-				   ALIGN_BOTH_ENDS |
-				   ALLOW_SHARING,
-				   tile_format);
-
-    if (*buffer == NULL) {
-	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-		   "Failed to allocate %s space.\n", name);
-	return FALSE;
-    }
-
-    return TRUE;
-}
-
-static Bool
-i830_allocate_depthbuffer(ScrnInfoPtr pScrn)
-{
-    I830Ptr pI830 = I830PTR(pScrn);
-    unsigned long size;
-    unsigned int pitch = pScrn->displayWidth * pI830->cpp;
-    int height;
-    int flags;
-    enum tile_format tile_format = TILE_NONE;
-
-    height = pScrn->virtualY;
-
-    /* First try allocating it tiled */
-    flags = ALLOW_SHARING;
-    if (pI830->tiling && IsTileable(pScrn, pitch))
-    {
-	/* The 965 requires that the depth buffer be in Y Major format, while
-	 * the rest appear to fail when handed that format.
-	 */
-	tile_format = IS_I965G(pI830) ? TILE_YMAJOR: TILE_XMAJOR;
-	height = ALIGN(height, 16);
-	flags |= ALIGN_BOTH_ENDS;
-    }
-    size = ROUND_TO_PAGE(pitch * height);
-
-    pI830->depth_buffer =
-	    i830_allocate_memory(pScrn, "depth buffer", size, pitch,
-				 GTT_PAGE_SIZE, flags, tile_format);
-
-    if (pI830->depth_buffer == NULL) {
-	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-		   "Failed to allocate depth buffer space.\n");
-	return FALSE;
-    }
-
-    return TRUE;
-}
-
-static Bool
-i830_allocate_texture_memory(ScrnInfoPtr pScrn)
-{
-    I830Ptr pI830 = I830PTR(pScrn);
-    unsigned long size;
-    int i;
-
-    if (pI830->allocate_classic_textures) {
-	/* XXX: auto-sizing */
-	size = MB(32);
-	i = myLog2(size / I830_NR_TEX_REGIONS);
-	if (i < I830_LOG_MIN_TEX_REGION_SIZE)
-	    i = I830_LOG_MIN_TEX_REGION_SIZE;
-	pI830->TexGranularity = i;
-	/* Truncate size */
-	size >>= i;
-	size <<= i;
-	if (size < KB(512)) {
-	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		       "Less than 512 kBytes for texture space (real %ld"
-		       "kBytes).\n",
-		       size / 1024);
-	    return FALSE;
-	}
-	/* Now that the DRM uses the sarea to get the offsets of the buffers,
-	 * and we update the classic DRM mappings and the sarea contents on
-	 * changes, the NEED_LIFETIME_FIXED is no longer true and should be
-	 * made conditional on DRM version.
-	 */
-	pI830->textures = i830_allocate_memory(pScrn, "classic textures", size,
-					       PITCH_NONE,
-					       GTT_PAGE_SIZE,
-					       ALLOW_SHARING |
-					       NEED_LIFETIME_FIXED,
-					       TILE_NONE);
-	if (pI830->textures == NULL) {
-	    xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-		       "Failed to allocate texture space.\n");
-	    return FALSE;
-	}
-    }
-
-    return TRUE;
-}
-
-static Bool
-i830_allocate_hwstatus(ScrnInfoPtr pScrn)
-{
-    I830Ptr pI830 = I830PTR(pScrn);
-    int flags;
-
-    /* The current DRM will leak the HWS mapping if we update the address
-     * after init (at best), so allocate it fixed for its lifetime
-     * (i.e. not through buffer objects).
-     */
-    flags = NEED_LIFETIME_FIXED;
-    if (HWS_NEED_NONSTOLEN(pI830))
-	    flags |= NEED_NON_STOLEN;
-    pI830->hw_status = i830_allocate_memory(pScrn, "HW status",
-	    HWSTATUS_PAGE_SIZE, PITCH_NONE, GTT_PAGE_SIZE, flags,
-					    TILE_NONE);
-    if (pI830->hw_status == NULL) {
-	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-		"Failed to allocate hw status page.\n");
-	return FALSE;
-    }
-    return TRUE;
-}
-
 Bool
 i830_allocate_pwrctx(ScrnInfoPtr pScrn)
 {
@@ -1698,31 +1482,6 @@ i830_allocate_pwrctx(ScrnInfoPtr pScrn)
     return TRUE;
 }
 
-Bool
-i830_allocate_3d_memory(ScrnInfoPtr pScrn)
-{
-    I830Ptr pI830 = I830PTR(pScrn);
-
-    DPRINTF(PFX, "i830_allocate_3d_memory\n");
-
-    if (!pI830->memory_manager && HWS_NEED_GFX(pI830)) {
-	if (!i830_allocate_hwstatus(pScrn))
-	    return FALSE;
-    }
-
-    if (!i830_allocate_backbuffer(pScrn, &pI830->back_buffer, "back buffer"))
-	return FALSE;
-
-    if (!i830_allocate_depthbuffer(pScrn))
-	return FALSE;
-
-    if (!i830_allocate_texture_memory(pScrn))
-	return FALSE;
-
-    return TRUE;
-}
-#endif
-
 /**
  * Sets up tiled surface registers ("fences") for the hardware.
  *
diff --git a/src/i830_xaa.c b/src/i830_xaa.c
index ede7cc2..a118055 100644
--- a/src/i830_xaa.c
+++ b/src/i830_xaa.c
@@ -249,27 +249,7 @@ I830CheckTiling(ScrnInfoPtr pScrn)
 {
    I830Ptr pI830 = I830PTR(pScrn);
 
-   if (pI830->bufferOffset == pI830->front_buffer->offset &&
-       pI830->front_buffer->tiling != TILE_NONE)
-   {
-       return TRUE;
-   }
-#ifdef XF86DRI
-   if (pI830->back_buffer != NULL &&
-       pI830->bufferOffset == pI830->back_buffer->offset &&
-       pI830->back_buffer->tiling != TILE_NONE)
-   {
-       return TRUE;
-   }
-   if (pI830->depth_buffer != NULL &&
-       pI830->bufferOffset == pI830->depth_buffer->offset &&
-       pI830->depth_buffer->tiling != TILE_NONE)
-   {
-       return TRUE;
-   }
-#endif
-
-   return FALSE;
+   return pI830->front_buffer->tiling != TILE_NONE;
 }
 
 void
@@ -331,7 +311,7 @@ I830SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h)
 	}
 	OUT_BATCH(pI830->BR[13]);
 	OUT_BATCH((h << 16) | (w * pI830->cpp));
-	OUT_BATCH(pI830->bufferOffset + (y * pScrn->displayWidth + x) *
+	OUT_BATCH(pI830->front_buffer->offset + (y * pScrn->displayWidth + x) *
 		  pI830->cpp);
 	OUT_BATCH(pI830->BR[16]);
 	OUT_BATCH(0);
@@ -409,10 +389,10 @@ I830SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int src_x1, int src_y1,
 	OUT_BATCH(pI830->BR[13]);
 	OUT_BATCH((dst_y1 << 16) | (dst_x1 & 0xffff));
 	OUT_BATCH((dst_y2 << 16) | (dst_x2 & 0xffff));
-	OUT_BATCH(pI830->bufferOffset);
+	OUT_BATCH(pI830->front_buffer->offset);
 	OUT_BATCH((src_y1 << 16) | (src_x1 & 0xffff));
 	OUT_BATCH(pI830->BR[13] & 0xFFFF);
-	OUT_BATCH(pI830->bufferOffset);
+	OUT_BATCH(pI830->front_buffer->offset);
 
 	ADVANCE_BATCH();
     }
@@ -490,7 +470,7 @@ I830SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int pattx, int patty,
 	OUT_BATCH(pI830->BR[13]);
 	OUT_BATCH((y1 << 16) | x1);
 	OUT_BATCH((y2 << 16) | x2);
-	OUT_BATCH(pI830->bufferOffset);
+	OUT_BATCH(pI830->front_buffer->offset);
 	OUT_BATCH(pI830->BR[18]);		/* bg */
 	OUT_BATCH(pI830->BR[19]);		/* fg */
 	OUT_BATCH(pI830->BR[16]);		/* pattern data */
@@ -571,7 +551,7 @@ I830SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
 	       "%d,%d %dx%x %d\n", x, y, w, h, skipleft);
 
     /* Fill out register values */
-    pI830->BR[9] = (pI830->bufferOffset +
+    pI830->BR[9] = (pI830->front_buffer->offset +
 		    (y * pScrn->displayWidth + x) * pI830->cpp);
     pI830->BR[11] = ((1 << 16) | w);
 }
@@ -662,7 +642,7 @@ I830SubsequentScanlineImageWriteRect(ScrnInfoPtr pScrn, int x, int y,
 	       "%d,%d %dx%x %d\n", x, y, w, h, skipleft);
 
     /* Fill out register values */
-    pI830->BR[9] = (pI830->bufferOffset +
+    pI830->BR[9] = (pI830->front_buffer->offset +
 		    (y * pScrn->displayWidth + x) * pI830->cpp);
     pI830->BR[11] = ((1 << 16) | w);
 }
-- 
1.6.2.2




More information about the Intel-gfx mailing list