xf86-video-intel: Branch 'modesetting' - 31 commits - configure.ac man/i810.man src/i810_dri.h src/i810_driver.c src/i830_common.h src/i830_dri.c src/i830_dri.h src/i830_driver.c src/i830.h src/i830_memory.c src/i830_rotate.c src/i830_video.c src/i915_video.c src/packed_yuv_wm.g4a src/wm_prog.h

Eric Anholt anholt at kemper.freedesktop.org
Fri Nov 17 19:47:27 EET 2006


 configure.ac          |   14 ++
 man/i810.man          |   28 +++++
 src/i810_dri.h        |    4 
 src/i810_driver.c     |    9 +
 src/i830.h            |   15 ++
 src/i830_common.h     |    9 +
 src/i830_dri.c        |  112 ++++++++++++++--------
 src/i830_dri.h        |    4 
 src/i830_driver.c     |  253 +++++++++++++++++++++++++++++++++++++++++++++++++-
 src/i830_memory.c     |   76 ++++++++-------
 src/i830_rotate.c     |   43 ++++----
 src/i830_video.c      |  102 ++++++--------------
 src/i915_video.c      |    4 
 src/packed_yuv_wm.g4a |    2 
 src/wm_prog.h         |    2 
 15 files changed, 503 insertions(+), 174 deletions(-)

New commits:
diff-tree 816fc1a76a5ac738e41b172ba8f43137c1521328 (from parents)
Merge: 9948d8377d70e898260c12210151b952b3fb8bf1 7a7bb331e10498e5b8ccec58130bb23334d36562
Author: Eric Anholt <eric at anholt.net>
Date:   Fri Nov 17 00:05:53 2006 -0800

    Merge branch 'modesetting-origin' into modesetting

diff-tree 9948d8377d70e898260c12210151b952b3fb8bf1 (from parents)
Merge: 45a27f80e1c783627f570c309e7a853dcc9af0c1 b649f95ea6fd3555d073fdbf8f2f035dfe1afd33
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Nov 16 19:47:24 2006 -0800

    Merge branch 'master' into modesetting
    
    Conflicts:
    
    	src/i830.h
    	src/i830_cursor.c
    	src/i830_dri.c
    	src/i830_driver.c
    	src/i830_video.c

diff --cc configure.ac
index 257f97b,fc0f9cd..b1dd287
@@@ -113,16 -118,22 +118,21 @@@
  	-Wnested-externs -fno-strict-aliasing"
  fi
  
 -CFLAGS="$CFLAGS $WARN_CFLAGS"
 -
  AM_CONDITIONAL(DRI, test x$DRI = xyes)
  if test "$DRI" = yes; then
-         PKG_CHECK_MODULES(DRI, [libdrm >= 2.0 xf86driproto])
+         PKG_CHECK_MODULES(DRI, [libdrm >= 2.2 xf86driproto])
          AC_DEFINE(XF86DRI,1,[Enable DRI driver support])
          AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support])
  fi
  
+ AM_CONDITIONAL(VIDEO_DEBUG, test x$VIDEO_DEBUG = xyes)
+ if test "$VIDEO_DEBUG" = yes; then
+ 	AC_DEFINE(VIDEO_DEBUG,1,[Enable debug support])
+ fi
+ 
  AC_SUBST([DRI_CFLAGS])
  AC_SUBST([XORG_CFLAGS])
 +AC_SUBST([WARN_CFLAGS])
  AC_SUBST([moduledir])
  
  DRIVER_NAME=i810
diff --cc src/i830.h
index 96f0c29,0df41e3..ea7f1c0
@@@ -86,6 -84,36 +86,13 @@@
   * Paulo César Pereira de Andrade <pcpa at conectiva.com.br>.
   */
  
 -#define PIPE_NONE	0<<0
 -#define PIPE_CRT	1<<0
 -#define PIPE_TV		1<<1
 -#define PIPE_DFP	1<<2
 -#define PIPE_LFP	1<<3
 -#define PIPE_CRT2	1<<4
 -#define PIPE_TV2	1<<5
 -#define PIPE_DFP2	1<<6
 -#define PIPE_LFP2	1<<7
 -
 -typedef struct _VESARec {
 -   /* SVGA state */
 -   pointer state, pstate;
 -   int statePage, stateSize, stateMode, stateRefresh;
 -   CARD32 *savedPal;
 -   int savedScanlinePitch;
 -   /* Don't try to set the refresh rate for any modes. */
 -   Bool useDefaultRefresh;
 -   /* display start */
 -   int x, y;
 -} VESARec, *VESAPtr;
 -
 -
+ #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
+ 
  typedef struct _I830Rec *I830Ptr;
  
  typedef void (*I830WriteIndexedByteFunc)(I830Ptr pI830, IOADDRESS addr,
@@@ -719,12 -582,10 +728,18 @@@
  #define _845_DRAM_RW_CONTROL 0x90
  #define DRAM_WRITE    0x33330000
  
 +/* Compat definitions for older X Servers. */
 +#ifndef M_T_PREFERRED
 +#define M_T_PREFERRED	0x08
 +#endif
 +#ifndef M_T_DRIVER
 +#define M_T_DRIVER	0x40
 +#endif
 +
+ /* 
+  * Xserver MM compatibility. Remove code guarded by this when the
+  * XServer contains the libdrm mm code
+  */
+ #undef XSERVER_LIBDRM_MM
+ 
  #endif /* _I830_H_ */
diff --cc src/i830_dri.c
index 9e4ead0,524c4de..6b17f46
@@@ -1485,9 -1513,12 +1513,13 @@@
  
      if (pI830->directRenderingEnabled && pI830->drmMinor >= 5) {
  	if (on) {
- 	    if (pI830->pipes[1].enabled)
 -	    if (pI830->planeEnabled[1]) {
++	    if (pI830->pipes[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;
 +		pipe.pipe = DRM_I830_VBLANK_PIPE_B;
- 	    else
+ 	    } else
  		pipe.pipe = DRM_I830_VBLANK_PIPE_A;
  	} else {
  	    pipe.pipe = 0;
diff --cc src/i830_driver.c
index 0ea20e4,e950d7c..f5b403a
@@@ -263,9 -265,17 +265,11 @@@
     OPTION_FIXEDPIPE,
     OPTION_ROTATE,
     OPTION_LINEARALLOC,
 -   OPTION_MERGEDFB,
 -   OPTION_METAMODES,
 -   OPTION_SECONDHSYNC,
 -   OPTION_SECONDVREFRESH,
 -   OPTION_SECONDPOSITION,
 -   OPTION_INTELXINERAMA,
+    OPTION_INTELTEXPOOL,
+    OPTION_INTELMMSIZE
  } I830Opts;
  
 -static OptionInfoRec I830BIOSOptions[] = {
 +static OptionInfoRec I830Options[] = {
     {OPTION_NOACCEL,	"NoAccel",	OPTV_BOOLEAN,	{0},	FALSE},
     {OPTION_SW_CURSOR,	"SWcursor",	OPTV_BOOLEAN,	{0},	FALSE},
     {OPTION_CACHE_LINES,	"CacheLines",	OPTV_INTEGER,	{0},	FALSE},
@@@ -281,6 -294,14 +285,8 @@@
     {OPTION_FIXEDPIPE,   "FixedPipe",    OPTV_ANYSTR, 	{0},	FALSE},
     {OPTION_ROTATE,      "Rotate",       OPTV_ANYSTR,    {0},    FALSE},
     {OPTION_LINEARALLOC, "LinearAlloc",  OPTV_INTEGER,   {0},    FALSE},
 -   {OPTION_MERGEDFB, 	"MergedFB",	OPTV_BOOLEAN,	{0},	FALSE},
 -   {OPTION_METAMODES, 	"MetaModes",	OPTV_STRING,	{0},	FALSE},
 -   {OPTION_SECONDHSYNC,	"SecondMonitorHorizSync",OPTV_STRING,	{0}, FALSE },
 -   {OPTION_SECONDVREFRESH,"SecondMonitorVertRefresh",OPTV_STRING,{0}, FALSE },
 -   {OPTION_SECONDPOSITION,"SecondPosition",OPTV_STRING,	{0},	FALSE },
 -   {OPTION_INTELXINERAMA,"MergedXinerama",OPTV_BOOLEAN,	{0},	TRUE},
+    {OPTION_INTELTEXPOOL,"Legacy3D",     OPTV_BOOLEAN,	{0},	FALSE},
+    {OPTION_INTELMMSIZE, "AperTexSize",  OPTV_INTEGER,	{0},	FALSE},
     {-1,			NULL,		OPTV_NONE,	{0},	FALSE}
  };
  /* *INDENT-ON* */
@@@ -741,33 -3831,30 +747,54 @@@
     return TRUE;
  }
  
 +#define HOTKEY_BIOS_SWITCH	0
 +#define HOTKEY_DRIVER_NOTIFY	1
 +
 +/**
 + * Controls the BIOS's behavior on hotkey switch.
 + *
 + * If the mode is HOTKEY_BIOS_SWITCH, the BIOS will be set to do a mode switch
 + * on its own and update the state in the scratch register.
 + * If the mode is HOTKEY_DRIVER_NOTIFY, the BIOS won't do a mode switch and
 + * will just update the state to represent what it would have been switched to.
 + */
 +static void
 +i830SetHotkeyControl(ScrnInfoPtr pScrn, int mode)
 +{
 +   I830Ptr pI830 = I830PTR(pScrn);
 +   CARD8 gr18;
 +
 +   gr18 = pI830->readControl(pI830, GRX, 0x18);
 +   if (mode == HOTKEY_BIOS_SWITCH)
 +      gr18 &= ~HOTKEY_VBIOS_SWITCH_BLOCK;
 +   else
 +      gr18 |= HOTKEY_VBIOS_SWITCH_BLOCK;
 +   pI830->writeControl(pI830, GRX, 0x18, gr18);
 +}
 +
+ #ifdef XF86DRI
+ static void 
+ I830ReduceMMSize(ScrnInfoPtr pScrn, unsigned long newSize,
+ 		 const char *reason)
+ {
+    I830Ptr pI830 = I830PTR(pScrn);
+ 
+    newSize = ROUND_DOWN_TO(newSize, GTT_PAGE_SIZE);
+    if (newSize / GTT_PAGE_SIZE > I830_MM_MINPAGES) {
+       pI830->mmSize = newSize / 1024;
+       xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ 		 "DRM memory manager aperture size is reduced to %d kiB\n"
+ 		 "\t%s\n", pI830->mmSize, reason);
+    } else {
+       xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ 		 "DRM memory manager will be disabled\n\t%s\n", reason);
+       pI830->mmSize = 0;
+    }
+ }
+ #endif
+ 
 -
  static Bool
 -I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
 +I830PreInit(ScrnInfoPtr pScrn, int flags)
  {
     vgaHWPtr hwp;
     I830Ptr pI830;
@@@ -775,14 -3862,22 +802,17 @@@
     rgb defaultWeight = { 0, 0, 0 };
     EntityInfoPtr pEnt;
     I830EntPtr pI830Ent = NULL;					
 -   int mem, memsize;
 +   int mem;
     int flags24;
 -   int defmon = 0;
 -   int i, n;
 -   int DDCclock = 0, DDCclock2 = 0;
 +   int i;
     char *s;
 -   DisplayModePtr p, pMon;
 -   xf86MonPtr monitor = NULL;
 -   pointer pDDCModule = NULL, pVBEModule = NULL;
 +   pointer pVBEModule = NULL;
     Bool enable;
     const char *chipname;
 -   unsigned int ver;
 -   char v[5];
 +   int mem_skip;
+ #ifdef XF86DRI
+    unsigned long savedMMSize;
+ #endif
  
     if (pScrn->numEntities != 1)
        return FALSE;
@@@ -1819,10 -5560,36 +1910,20 @@@
  #endif
        pI830->disableTiling = TRUE; /* no DRI - so disableTiling */
  
+    if (pScrn->displayWidth >= 4096) {
+       xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Cannot support > 1024x768 in leftof/rightof configurations. disabling DRI.\n");
+       pI830->directRenderingDisabled = TRUE;
+    }
+ 
+    if (pScrn->virtualY > 2048) {
+       xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Cannot support > 2048 vertical lines. disabling acceleration.\n");
+       pI830->noAccel = TRUE;
+    }
+ 
     pI830->displayWidth = pScrn->displayWidth;
  
 -   SetPipeAccess(pScrn);
     I830PrintModes(pScrn);
  
 -   if (!pI830->vesa->useDefaultRefresh) {
 -      /*
 -       * This sets the parameters for the VBE modes according to the best
 -       * usable parameters from the Monitor sections modes (usually the
 -       * default VESA modes), allowing for better than default refresh rates.
 -       * This only works for VBE 3.0 and later.  Also, we only do this
 -       * if there are no non-CRT devices attached.
 -       */
 -      SetPipeAccess(pScrn);
 -      I830SetModeParameters(pScrn, pI830->pVbe);
 -   }
 -
 -   /* PreInit shouldn't leave any state changes, so restore this. */
 -   RestoreBIOSMemSize(pScrn);
 -
     /* Don't need MMIO access anymore. */
     if (pI830->swfSaved) {
        OUTREG(SWF0, pI830->saveSWF0);
@@@ -2732,8 -7112,89 +2833,89 @@@
     }
  }
  
+ #ifdef XF86DRI
+ #ifndef DRM_BO_MEM_TT
+ #error "Wrong drm.h file included. You need to compile and install a recent libdrm."
+ #endif
+ 
+ #ifndef XSERVER_LIBDRM_MM
+ 
+ static int
+ I830DrmMMInit(int drmFD, unsigned long pageOffs, unsigned long pageSize,
+ 	      unsigned memType)
+ {
+ 
+    drm_mm_init_arg_t arg;
+    int ret;
+    
+    memset(&arg, 0, sizeof(arg));
+    arg.req.op = mm_init;
+    arg.req.p_offset = pageOffs;
+    arg.req.p_size = pageSize;
+    arg.req.mem_type = memType;
+ 
+    ret = ioctl(drmFD, DRM_IOCTL_MM_INIT, &arg);
+    
+    if (ret)
+       return -errno;
+    
+    return 0;
+    
+ }
+ 
+ static int
+ I830DrmMMTakedown(int drmFD, unsigned memType)
+ {
+    drm_mm_init_arg_t arg;
+    int ret = 0;
+    
+    memset(&arg, 0, sizeof(arg));
+    arg.req.op = mm_takedown;
+    arg.req.mem_type = memType;
+    if (ioctl(drmFD, DRM_IOCTL_MM_INIT, &arg)) {
+       ret = -errno;
+    }
+    
+    return ret;
+ }
+ 
+ static int I830DrmMMLock(int fd, unsigned memType)
+ {
+     drm_mm_init_arg_t arg;
+     int ret;
+ 
+     memset(&arg, 0, sizeof(arg));
+     arg.req.op = mm_lock;
+     arg.req.mem_type = memType;
+ 
+     do{
+ 	ret = ioctl(fd, DRM_IOCTL_MM_INIT, &arg);
+     } while (ret && errno == EAGAIN);
+     
+     return ret;	
+ }
+ 
+ static int I830DrmMMUnlock(int fd, unsigned memType)
+ {
+     drm_mm_init_arg_t arg;
+     int ret;
+ 
+     memset(&arg, 0, sizeof(arg));
+     arg.req.op = mm_unlock;
+     arg.req.mem_type = memType;
+ 
+     do{
+ 	ret = ioctl(fd, DRM_IOCTL_MM_INIT, &arg);
+     } while (ret && errno == EAGAIN);
+     
+     return ret;	
+ }
+ 
+ #endif
+ #endif
+ 
  static Bool
 -I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 +I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
  {
     ScrnInfoPtr pScrn;
     vgaHWPtr hwp;
@@@ -3178,28 -7700,156 +3360,70 @@@
           break;
     }
  
+ 
+ #ifdef XF86DRI
+    if (pI830->directRenderingEnabled && (pI830->mmModeFlags & I830_KERNEL_MM)) {
+       unsigned long aperEnd = ROUND_DOWN_TO(pI830->FbMapSize, GTT_PAGE_SIZE) 
+ 	 / GTT_PAGE_SIZE;
+       unsigned long aperStart = ROUND_TO(pI830->FbMapSize - KB(pI830->mmSize), GTT_PAGE_SIZE) 
+ 	 / GTT_PAGE_SIZE;
+ 
+       if (aperEnd < aperStart || aperEnd - aperStart < I830_MM_MINPAGES) {
+ 	 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 
+ 		    "Too little AGP aperture space for DRM memory manager.\n"
+ 		    "\tPlease increase AGP aperture size from BIOS configuration screen\n"
+ 		    "\tor decrease the amount of video RAM using option \"VideoRam\".\n"
+ 		    "\tDisabling DRI.\n");
+ 	 pI830->directRenderingOpen = FALSE;
+ 	 I830DRICloseScreen(pScreen);
+ 	 pI830->directRenderingEnabled = FALSE;
+       } else {
+ #ifndef XSERVER_LIBDRM_MM
+ 	 if (I830DrmMMInit(pI830->drmSubFD, aperStart, aperEnd - aperStart,
+ 			   DRM_BO_MEM_TT)) {
+ #else
+ 	 if (drmMMInit(pI830->drmSubFD, aperStart, aperEnd - aperStart,
+ 		       DRM_BO_MEM_TT)) {
+ #endif	   
+ 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 
+ 		       "Could not initialize the DRM memory manager.\n");
+ 	    
+ 	    pI830->directRenderingOpen = FALSE;
+ 	    I830DRICloseScreen(pScreen);
+ 	    pI830->directRenderingEnabled = FALSE;
+ 	 } else {
+ 	    xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
+ 		       "Initialized DRM memory manager, %ld AGP pages\n"
+ 		       "\tat AGP offset 0x%lx\n", 
+ 		       aperEnd - aperStart,
+ 		       aperStart);
+ 	 }
+       }
+    }
 -#endif
 -
 -   return TRUE;
 -}
 -
 -
 -static void
 -I830AdjustFrame(int scrnIndex, int x, int y, int flags)
 -{
 -   ScrnInfoPtr pScrn;
 -   I830Ptr pI830;
 -   vbeInfoPtr pVbe;
 -   unsigned long Start;
 -
 -   pScrn = xf86Screens[scrnIndex];
 -   pI830 = I830PTR(pScrn);
 -   pVbe = pI830->pVbe;
 -
 -   DPRINTF(PFX, "I830AdjustFrame: y = %d (+ %d), x = %d (+ %d)\n",
 -	   x, pI830->xoffset, y, pI830->yoffset);
 -
 -   /* Sync the engine before adjust frame */
 -   if (pI830->AccelInfoRec && pI830->AccelInfoRec->NeedToSync) {
 -      (*pI830->AccelInfoRec->Sync)(pScrn);
 -      pI830->AccelInfoRec->NeedToSync = FALSE;
 -   }
 -
 -   if (pI830->MergedFB) {
 -      I830AdjustFrameMerged(scrnIndex, x, y, flags);
 -
 -      if (pI830->pipe == 0) {
 -         OUTREG(DSPABASE, pI830->FrontBuffer.Start + ((pI830->FirstframeY0 * pScrn->displayWidth + pI830->FirstframeX0) * pI830->cpp));
 -         OUTREG(DSPBBASE, pI830->FrontBuffer.Start + ((pI830->pScrn_2->frameY0 * pScrn->displayWidth + pI830->pScrn_2->frameX0) * pI830->cpp));
 -      } else {
 -         OUTREG(DSPBBASE, pI830->FrontBuffer.Start + ((pI830->FirstframeY0 * pScrn->displayWidth + pI830->FirstframeX0) * pI830->cpp));
 -         OUTREG(DSPABASE, pI830->FrontBuffer.Start + ((pI830->pScrn_2->frameY0 * pScrn->displayWidth + pI830->pScrn_2->frameX0) * pI830->cpp));
 -      }
 -
 -      return;
 -   }
 -
 -   if (I830IsPrimary(pScrn))
 -      Start = pI830->FrontBuffer.Start;
 -   else {
 -      I830Ptr pI8301 = I830PTR(pI830->entityPrivate->pScrn_1);
 -      Start = pI8301->FrontBuffer2.Start;
 -   }
 -
 -   /* Sigh...
 -    * It seems that there are quite a few Video BIOS' that get this wrong.
 -    * So, we'll bypass the VBE call and hit the hardware directly.
 -    */
 -
 -   if (pI830->Clone) {
 -      if (!pI830->pipe == 0) {
 -         if (!IS_I965G(pI830)) {
 -            OUTREG(DSPABASE, Start + ((y * pScrn->displayWidth + x) * pI830->cpp));
 -         } else {
 -            OUTREG(DSPABASE, 0);
 -            OUTREG(DSPASURF, Start + ((y * pScrn->displayWidth + x) * pI830->cpp));
 -         }
 -      } else {
 -         if (!IS_I965G(pI830)) {
 -            OUTREG(DSPBBASE, Start + ((y * pScrn->displayWidth + x) * pI830->cpp));
 -         } else {
 -            OUTREG(DSPBBASE, 0);
 -            OUTREG(DSPBSURF, Start + ((y * pScrn->displayWidth + x) * pI830->cpp));
 -         }
 -      }
 -   }
 -
 -   if (pI830->pipe == 0) {
 -      if (!IS_I965G(pI830)) {
 -         OUTREG(DSPABASE, Start + ((y * pScrn->displayWidth + x) * pI830->cpp));
 -      } else {
 -         OUTREG(DSPABASE, 0);
 -         OUTREG(DSPASURF, Start + ((y * pScrn->displayWidth + x) * pI830->cpp));
 -      }
 -   } else {
 -      if (!IS_I965G(pI830)) {
 -         OUTREG(DSPBBASE, Start + ((y * pScrn->displayWidth + x) * pI830->cpp));
 -      } else {
 -         OUTREG(DSPBBASE, 0);
 -         OUTREG(DSPBSURF, Start + ((y * pScrn->displayWidth + x) * pI830->cpp));
 -      }
 -   }
 -}
++#endif
+ 
 -static void
 -I830BIOSFreeScreen(int scrnIndex, int flags)
 -{
 -   I830BIOSFreeRec(xf86Screens[scrnIndex]);
 -   if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
 -      vgaHWFreeHWRec(xf86Screens[scrnIndex]);
 +   return TRUE;
  }
  
 -#ifndef SAVERESTORE_HWSTATE
 -#define SAVERESTORE_HWSTATE 0
 -#endif
 -
 -#if SAVERESTORE_HWSTATE
  static void
 -SaveHWOperatingState(ScrnInfoPtr pScrn)
 +i830AdjustFrame(int scrnIndex, int x, int y, int flags)
  {
 +   ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
     I830Ptr pI830 = I830PTR(pScrn);
 -   I830RegPtr save = &pI830->SavedReg;
 +   int i;
 +
 +   DPRINTF(PFX, "i830AdjustFrame: y = %d (+ %d), x = %d (+ %d)\n",
 +	   x, pI830->xoffset, y, pI830->yoffset);
  
 -   DPRINTF(PFX, "SaveHWOperatingState\n");
 +   /* Sync the engine before adjust frame */
 +   if (pI830->AccelInfoRec && pI830->AccelInfoRec->NeedToSync) {
 +      (*pI830->AccelInfoRec->Sync)(pScrn);
 +      pI830->AccelInfoRec->NeedToSync = FALSE;
 +   }
  
 -   return;
 +   for (i = 0; i < pI830->num_pipes; i++)
 +      if (pI830->pipes[i].enabled)
 +	 i830PipeSetBase(pScrn, i, x, y);
  }
  
  static void
diff --cc src/i830_memory.c
index a14027d,09ef5be..5213177
@@@ -1099,8 -1107,21 +1099,14 @@@
     pI830->MemoryAperture.Start = pI830->StolenMemory.End;
     pI830->MemoryAperture.End = pI830->FbMapSize;
     pI830->MemoryAperture.Size = pI830->FbMapSize - pI830->StolenMemory.Size;
+ #ifdef XF86DRI
+    if (!pI830->directRenderingDisabled) {
+       pI830->MemoryAperture.End -= KB(pI830->mmSize);
+       pI830->MemoryAperture.Size -= KB(pI830->mmSize);
+    }
+ #endif
     pI830->StolenPool.Fixed = pI830->StolenMemory;
     pI830->StolenPool.Total = pI830->StolenMemory;
 -#if ALLOCATE_ALL_BIOSMEM
 -   if (pI830->overrideBIOSMemSize &&
 -       pI830->BIOSMemorySize > pI830->StolenMemory.Size) {
 -      pI830->StolenPool.Total.End = pI830->BIOSMemorySize;
 -      pI830->StolenPool.Total.Size = pI830->BIOSMemorySize;
 -   }
 -#endif
     pI830->StolenPool.Free = pI830->StolenPool.Total;
     pI830->FreeMemory = pI830->TotalVideoRam - pI830->StolenPool.Total.Size;
     pI830->allocatedMemory = 0;
diff --cc src/i830_video.c
index a5cd77c,054d26b..d84c1c9
@@@ -963,21 -941,7 +946,14 @@@
        pPriv->contrast = value;
        overlay->OCLRC0 = (pPriv->contrast << 18) | (pPriv->brightness & 0xff);
        ErrorF("CONTRAST\n");
-       overlay->OCMD &= ~OVERLAY_ENABLE;
        OVERLAY_UPDATE;
- #if 1
-       OVERLAY_OFF;
- #endif
 +   } else if (attribute == xvSaturation) {
 +      if ((value < 0) || (value > 1023))
 +	 return BadValue;
 +      pPriv->saturation = value;
 +      overlay->OCLRC1 = pPriv->saturation;
 +      overlay->OCMD &= ~OVERLAY_ENABLE;
 +      OVERLAY_UPDATE;
- #if 1
-       OVERLAY_OFF;
- #endif
     } else if (pI830->Clone && attribute == xvPipe) {
        if ((value < 0) || (value > 1))
           return BadValue;
diff-tree b649f95ea6fd3555d073fdbf8f2f035dfe1afd33 (from fbb376bd1a4daad4c86e349df98438989ce173f1)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Wed Nov 8 19:01:25 2006 +0000

    Disable some debug message

diff --git a/src/i915_video.c b/src/i915_video.c
index 0833d50..78907ef 100644
--- a/src/i915_video.c
+++ b/src/i915_video.c
@@ -65,8 +65,10 @@ I915DisplayVideoTextured(ScrnInfoPtr pSc
    int nbox, dxo, dyo;
    Bool planar;
 
+#if 0
    ErrorF("I915DisplayVideo: %dx%d (pitch %d)\n", width, height,
 	  video_pitch);
+#endif
 
    switch (id) {
    case FOURCC_UYVY:
@@ -78,7 +80,9 @@ I915DisplayVideoTextured(ScrnInfoPtr pSc
       planar = TRUE;
       break;
    default:
+#if 0
       ErrorF("Unknown format 0x%x\n", id);
+#endif
       planar = FALSE;
       break;
    }
diff-tree fbb376bd1a4daad4c86e349df98438989ce173f1 (from c0ee50c4ee5ff2c594fdf60c9cb8b952e25644de)
Author: Wang Zhenyu <zhenyu.z.wang at intel.com>
Date:   Mon Oct 30 14:15:12 2006 +0800

    Bug 8594: Fix Xv hang with G965

diff --git a/src/packed_yuv_wm.g4a b/src/packed_yuv_wm.g4a
index d312d17..4b6391b 100644
--- a/src/packed_yuv_wm.g4a
+++ b/src/packed_yuv_wm.g4a
@@ -144,7 +144,7 @@ mac.sat (8) m8<1>F g15<8,8,1>F 1F { alig
     */
 mov (8) m1<1>UD g1<8,8,1>UD { align1 mask_disable };
    /* Send framebuffer write message: XXX: acc0? */
-send (16) 0 null g0<8,8,1>UW write (
+send (16) 0 acc0<1>UW g0<8,8,1>UW write (
 	0, /* binding table index 0 */
 	8, /* pixel scoreboard clear */
 	4, /* render target write */
diff --git a/src/wm_prog.h b/src/wm_prog.h
index 708e6eb..d72c651 100644
--- a/src/wm_prog.h
+++ b/src/wm_prog.h
@@ -71,7 +71,7 @@
    { 0x00600041, 0x20007fbc, 0x008d0220, 0x40011687 },
    { 0x80600048, 0x21007fbe, 0x008d01e0, 0x3f800000 },
    { 0x00600201, 0x20200022, 0x008d0020, 0x00000000 },
-   { 0x00800031, 0x20001d3c, 0x008d0000, 0x85a04800 },
+   { 0x00800031, 0x24001d28, 0x008d0000, 0x85a04800 },
    { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
    { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
    { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
diff-tree c0ee50c4ee5ff2c594fdf60c9cb8b952e25644de (from 7d67324fa3a5b5cf0227550316c366752fe4abfb)
Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Date:   Fri Oct 27 19:13:33 2006 +0200

    Add support for the new DRM memory manager.
    Some code are duplicated with the new libdrm.
    Once this code has been released with xserver,
    it can be removed.
    
    See the man page for new options and backwards
    3D driver compatibility.

diff --git a/configure.ac b/configure.ac
index c91b1df..fc0f9cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -122,7 +122,7 @@ CFLAGS="$CFLAGS $WARN_CFLAGS"
 
 AM_CONDITIONAL(DRI, test x$DRI = xyes)
 if test "$DRI" = yes; then
-        PKG_CHECK_MODULES(DRI, [libdrm >= 2.0 xf86driproto])
+        PKG_CHECK_MODULES(DRI, [libdrm >= 2.2 xf86driproto])
         AC_DEFINE(XF86DRI,1,[Enable DRI driver support])
         AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support])
 fi
diff --git a/man/i810.man b/man/i810.man
index 50c2668..a3f25ec 100644
--- a/man/i810.man
+++ b/man/i810.man
@@ -203,6 +203,30 @@ Allows more memory for the offscreen all
 situations where HDTV movies are required to play but not enough offscreen
 memory is usually available. Set this to 8160 for upto 1920x1080 HDTV support.
 Default 0KB (off).
+.TP
+.BI "Option \*qLegacy3D\*q \*q" boolean \*q
+Enable support for the legacy i915_dri.so 3D driver.
+This will, among other things, make the 2D driver tell libGL to
+load the 3D driver i915_dri.so instead of the newer i915tex_dri.so.
+This option is only used for chipsets in the range i830-i945. 
+Default for i830-i945 series: Enabled for i915 drm versions < 1.7.0. Otherwise
+disabled. 
+Default for i810: The option is not used.
+Default for i965: The option is always true.
+.TP
+.BI "Option \*qAperTexSize\*q \*q" integer \*q
+Give the size in kiB of the AGP aperture area that is reserved for the
+DRM memory manager present in i915 drm from version 1.7.0 and upwards,
+and that is used with the 3D driver in Mesa from version 6.5.2 and
+upwards. If the size is set too high to make room for pre-allocated
+VideoRam, the driver will try to reduce it automatically. If you use only
+older Mesa or DRM versions, you may set this value to zero, and
+atctivate the legacy texture pool (see 
+.B "Option \*qLegacy3D\*q"
+). If you run 3D programs with large texture memory requirements, you might
+gain some performance by increasing this value.
+Default: 32768.
+ 
 
 .SH "SEE ALSO"
 __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
diff --git a/src/i810_driver.c b/src/i810_driver.c
index cd6d9d7..5143fd4 100644
--- a/src/i810_driver.c
+++ b/src/i810_driver.c
@@ -313,6 +313,12 @@ const char *I810drmSymbols[] = {
    "drmGetLibVersion",
    "drmGetVersion",
    "drmRmMap",
+#ifdef XSERVER_LIBDRM_MM 
+   "drmMMInit",
+   "drmMMTakedown",
+   "drmMMLock",
+   "drmMMUnlock",
+#endif
    NULL
 };
 
diff --git a/src/i830.h b/src/i830.h
index 38a880f..0df41e3 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -107,6 +107,13 @@ typedef struct _VESARec {
 } VESARec, *VESAPtr;
 
 
+#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
+
 typedef struct _I830Rec *I830Ptr;
 
 typedef void (*I830WriteIndexedByteFunc)(I830Ptr pI830, IOADDRESS addr,
@@ -285,6 +292,8 @@ typedef struct _I830Rec {
    int TexGranularity;
    int drmMinor;
    Bool have3DWindows;
+   int mmModeFlags;
+   int mmSize;
 
    unsigned int front_tiled;
    unsigned int back_tiled;
@@ -573,4 +582,10 @@ Rotation I830GetRotation(ScreenPtr pScre
 #define _845_DRAM_RW_CONTROL 0x90
 #define DRAM_WRITE    0x33330000
 
+/* 
+ * Xserver MM compatibility. Remove code guarded by this when the
+ * XServer contains the libdrm mm code
+ */
+#undef XSERVER_LIBDRM_MM
+
 #endif /* _I830_H_ */
diff --git a/src/i830_dri.c b/src/i830_dri.c
index 21af651..524c4de 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_dri.c,v 1.15 2003/06/18 13:14:17 dawes Exp $ */
+/* $xfree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_dri.c,v 1.15 2003/06/18 13:14:17 dawes Exp $ */
 /**************************************************************************
 
 Copyright 2001 VA Linux Systems Inc., Fremont, California.
@@ -84,8 +84,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "dristruct.h"
 
 static char I830KernelDriverName[] = "i915";
-static char I830ClientDriverName[] = "i915";
+static char I830ClientDriverName[] = "i915tex";
 static char I965ClientDriverName[] = "i965";
+static char I830LegacyClientDriverName[] = "i915";
 
 static Bool I830InitVisualConfigs(ScreenPtr pScreen);
 static Bool I830CreateContext(ScreenPtr pScreen, VisualPtr visual,
@@ -644,10 +645,31 @@ I830DRIScreenInit(ScreenPtr pScreen)
 	    return FALSE;
 	 }
 	 pI830->drmMinor = version->version_minor;
+	 if (!(pI830->mmModeFlags & I830_KERNEL_TEX)) {
+	    if ((version->version_major > 1) ||
+		((version->version_minor >= 7) && 
+		 (version->version_major == 1))) {
+	       pI830->mmModeFlags |= I830_KERNEL_MM;
+	    } else {
+	       pI830->mmModeFlags |= I830_KERNEL_TEX;
+	    }		
+	 } else {
+	    xf86DrvMsg(pScreen->myNum, X_INFO, 
+		       "Not enabling the DRM memory manager.\n");
+	 } 
 	 drmFreeVersion(version);
       }
    }
 
+   /*
+    * Backwards compatibility
+    */
+
+   if ((pDRIInfo->clientDriverName == I830ClientDriverName) && 
+       (pI830->mmModeFlags & I830_KERNEL_TEX)) {
+      pDRIInfo->clientDriverName = I830LegacyClientDriverName;
+   }
+
    return TRUE;
 }
 
@@ -707,18 +729,20 @@ I830DRIMapScreenRegions(ScrnInfoPtr pScr
    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] Depth Buffer = 0x%08x\n",
               (int)sarea->depth_handle);
 
-   if (drmAddMap(pI830->drmSubFD,
-		 (drm_handle_t)sarea->tex_offset + pI830->LinearAddr,
-		 sarea->tex_size, DRM_AGP, 0,
-		 (drmAddress) &sarea->tex_handle) < 0) {
-      xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		 "[drm] drmAddMap(tex_handle) failed. Disabling DRI\n");
-      DRICloseScreen(pScreen);
-      return FALSE;
-   }
-   xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] textures = 0x%08x\n",
-	      (int)sarea->tex_handle);
+   if (pI830->mmModeFlags & I830_KERNEL_TEX) {
+      if (drmAddMap(pI830->drmSubFD,
+		    (drm_handle_t)sarea->tex_offset + pI830->LinearAddr,
+		    sarea->tex_size, DRM_AGP, 0,
+		    (drmAddress) &sarea->tex_handle) < 0) {
+	 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		    "[drm] drmAddMap(tex_handle) failed. Disabling DRI\n");
+	 DRICloseScreen(pScreen);
+	 return FALSE;
+      }
 
+      xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] textures = 0x%08x\n",
+		 (int)sarea->tex_handle);
+   }
    return TRUE;
 }
 
@@ -1475,7 +1499,7 @@ I830UpdateDRIBuffers(ScrnInfoPtr pScrn, 
 
    success = I830DRIMapScreenRegions(pScrn, sarea);
 
-   if (success)
+   if (success && (pI830->mmModeFlags & I830_KERNEL_TEX))
       I830InitTextureHeap(pScrn, sarea);
 
    return success;
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 432f0cb..e950d7c 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -197,6 +197,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #ifdef XF86DRI
 #include "dri.h"
+#include <sys/ioctl.h>
+#include <errno.h>
 #endif
 
 #define BIT(x) (1 << (x))
@@ -268,7 +270,9 @@ typedef enum {
    OPTION_SECONDHSYNC,
    OPTION_SECONDVREFRESH,
    OPTION_SECONDPOSITION,
-   OPTION_INTELXINERAMA
+   OPTION_INTELXINERAMA,
+   OPTION_INTELTEXPOOL,
+   OPTION_INTELMMSIZE
 } I830Opts;
 
 static OptionInfoRec I830BIOSOptions[] = {
@@ -296,6 +300,8 @@ static OptionInfoRec I830BIOSOptions[] =
    {OPTION_SECONDVREFRESH,"SecondMonitorVertRefresh",OPTV_STRING,{0}, FALSE },
    {OPTION_SECONDPOSITION,"SecondPosition",OPTV_STRING,	{0},	FALSE },
    {OPTION_INTELXINERAMA,"MergedXinerama",OPTV_BOOLEAN,	{0},	TRUE},
+   {OPTION_INTELTEXPOOL,"Legacy3D",     OPTV_BOOLEAN,	{0},	FALSE},
+   {OPTION_INTELMMSIZE, "AperTexSize",  OPTV_INTEGER,	{0},	FALSE},
    {-1,			NULL,		OPTV_NONE,	{0},	FALSE}
 };
 /* *INDENT-ON* */
@@ -3825,6 +3831,28 @@ I830IsPrimary(ScrnInfoPtr pScrn)
    return TRUE;
 }
 
+#ifdef XF86DRI
+static void 
+I830ReduceMMSize(ScrnInfoPtr pScrn, unsigned long newSize,
+		 const char *reason)
+{
+   I830Ptr pI830 = I830PTR(pScrn);
+
+   newSize = ROUND_DOWN_TO(newSize, GTT_PAGE_SIZE);
+   if (newSize / GTT_PAGE_SIZE > I830_MM_MINPAGES) {
+      pI830->mmSize = newSize / 1024;
+      xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+		 "DRM memory manager aperture size is reduced to %d kiB\n"
+		 "\t%s\n", pI830->mmSize, reason);
+   } else {
+      xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+		 "DRM memory manager will be disabled\n\t%s\n", reason);
+      pI830->mmSize = 0;
+   }
+}
+#endif
+
+
 static Bool
 I830BIOSPreInit(ScrnInfoPtr pScrn, int flags)
 {
@@ -3847,6 +3875,9 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int f
    const char *chipname;
    unsigned int ver;
    char v[5];
+#ifdef XF86DRI
+   unsigned long savedMMSize;
+#endif
 
    if (pScrn->numEntities != 1)
       return FALSE;
@@ -4243,7 +4274,46 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int f
 		    "runs only at depths 16 and 24.\n");
 	 pI830->directRenderingDisabled = TRUE;
       }
-   }
+
+      pI830->mmModeFlags = 0;
+
+      if (!pI830->directRenderingDisabled) {
+	 Bool tmp = FALSE;
+
+	 if (IS_I965G(pI830))
+	    pI830->mmModeFlags |= I830_KERNEL_TEX;
+
+	 from = X_PROBED;
+	 if (xf86GetOptValBool(pI830->Options, 
+			       OPTION_INTELTEXPOOL, &tmp)) {
+	    from = X_CONFIG;
+	    if (tmp) {
+	       pI830->mmModeFlags |= I830_KERNEL_TEX;
+	    } else {
+	       pI830->mmModeFlags &= ~I830_KERNEL_TEX;
+	    }	       
+	 }
+	 if (from == X_CONFIG || 
+	     (pI830->mmModeFlags & I830_KERNEL_TEX)) { 
+	    xf86DrvMsg(pScrn->scrnIndex, from, 
+		       "Will %stry to allocate texture pool "
+		       "for old Mesa 3D driver.\n",
+		       (pI830->mmModeFlags & I830_KERNEL_TEX) ? 
+		       "" : "not ");
+	 }
+	 pI830->mmSize = I830_MM_MAXSIZE;
+	 from = X_INFO;
+	 if (xf86GetOptValInteger(pI830->Options, OPTION_INTELMMSIZE,
+				  &(pI830->mmSize))) {
+	    from = X_CONFIG;
+	 }
+	 xf86DrvMsg(pScrn->scrnIndex, from, 
+		    "Will try to reserve %d kiB of AGP aperture space\n"
+		    "\tfor the DRM memory manager.\n",
+		    pI830->mmSize);
+      }
+   } 
+   
 #endif
 
    pI830->LinearAlloc = 0;
@@ -5351,9 +5421,15 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int f
     * If DRI is potentially usable, check if there is enough memory available
     * for it, and if there's also enough to allow tiling to be enabled.
     */
+
 #if defined(XF86DRI)
-   if (!I830CheckDRIAvailable(pScrn))
+   if (!I830CheckDRIAvailable(pScrn)) {
       pI830->directRenderingDisabled = TRUE;
+      pI830->mmSize = 0;
+   } else if (pScrn->videoRam > pI830->FbMapSize / 1024 - pI830->mmSize) {
+      I830ReduceMMSize(pScrn, pI830->FbMapSize - KB(pScrn->videoRam), 
+		       "to make room for video memory");
+   }
 
    if (I830IsPrimary(pScrn) && !pI830->directRenderingDisabled) {
       int savedDisplayWidth = pScrn->displayWidth;
@@ -5395,7 +5471,9 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int f
        * If the displayWidth is a tilable pitch, test if there's enough
        * memory available to enable tiling.
        */
+      savedMMSize = pI830->mmSize;
       if (pScrn->displayWidth == pitches[i]) {
+      retry_dryrun:
 	 I830ResetAllocations(pScrn, 0);
 	 if (I830Allocate2DMemory(pScrn, ALLOCATE_DRY_RUN | ALLOC_INITIAL) &&
 	     I830Allocate3DMemory(pScrn, ALLOCATE_DRY_RUN)) {
@@ -5407,7 +5485,13 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int f
 			     "required to\n\tenable tiling mode for DRI.\n",
 			     (memNeeded + 1023) / 1024);
 	       }
-	       if (pI830->MemoryAperture.Size < 0) {
+	       if (pI830->MemoryAperture.Size < 0) {		  
+		  if (KB(pI830->mmSize) > I830_MM_MINPAGES * GTT_PAGE_SIZE) {
+		     I830ReduceMMSize(pScrn, I830_MM_MINPAGES * GTT_PAGE_SIZE,
+				      "to make room in AGP aperture for tiling.");
+		     goto retry_dryrun;
+		  }
+
 		  xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
 			     "Allocation with DRI tiling enabled would "
 			     "exceed the\n"
@@ -5435,7 +5519,9 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int f
 	  * Tiling can't be enabled.  Check if there's enough memory for DRI
 	  * without tiling.
 	  */
+	 pI830->mmSize = savedMMSize;
 	 pI830->disableTiling = TRUE;
+      retry_dryrun2:
 	 I830ResetAllocations(pScrn, 0);
 	 if (I830Allocate2DMemory(pScrn, ALLOCATE_DRY_RUN | ALLOC_INITIAL) &&
 	     I830Allocate3DMemory(pScrn, ALLOCATE_DRY_RUN | ALLOC_NO_TILING)) {
@@ -5448,6 +5534,11 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int f
 			     (memNeeded + 1023) / 1024);
 	       }
 	       if (pI830->MemoryAperture.Size < 0) {
+		  if (KB(pI830->mmSize) > I830_MM_MINPAGES * GTT_PAGE_SIZE) {
+		     I830ReduceMMSize(pScrn, I830_MM_MINPAGES * GTT_PAGE_SIZE,
+				      "to save AGP aperture space for video memory.");
+		     goto retry_dryrun2;
+		  }
 		  xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
 			     "Allocation with DRI enabled would "
 			     "exceed the\n"
@@ -5456,6 +5547,7 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int f
 			     pI830->FbMapSize / 1024,
 			     -pI830->MemoryAperture.Size / 1024);
 	       }
+	       pI830->mmSize = 0;
 	       pI830->directRenderingDisabled = TRUE;
 	       xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling DRI.\n");
 	    }
@@ -7020,6 +7112,87 @@ IntelEmitInvarientState(ScrnInfoPtr pScr
    }
 }
 
+#ifdef XF86DRI
+#ifndef DRM_BO_MEM_TT
+#error "Wrong drm.h file included. You need to compile and install a recent libdrm."
+#endif
+
+#ifndef XSERVER_LIBDRM_MM
+
+static int
+I830DrmMMInit(int drmFD, unsigned long pageOffs, unsigned long pageSize,
+	      unsigned memType)
+{
+
+   drm_mm_init_arg_t arg;
+   int ret;
+   
+   memset(&arg, 0, sizeof(arg));
+   arg.req.op = mm_init;
+   arg.req.p_offset = pageOffs;
+   arg.req.p_size = pageSize;
+   arg.req.mem_type = memType;
+
+   ret = ioctl(drmFD, DRM_IOCTL_MM_INIT, &arg);
+   
+   if (ret)
+      return -errno;
+   
+   return 0;
+   
+}
+
+static int
+I830DrmMMTakedown(int drmFD, unsigned memType)
+{
+   drm_mm_init_arg_t arg;
+   int ret = 0;
+   
+   memset(&arg, 0, sizeof(arg));
+   arg.req.op = mm_takedown;
+   arg.req.mem_type = memType;
+   if (ioctl(drmFD, DRM_IOCTL_MM_INIT, &arg)) {
+      ret = -errno;
+   }
+   
+   return ret;
+}
+
+static int I830DrmMMLock(int fd, unsigned memType)
+{
+    drm_mm_init_arg_t arg;
+    int ret;
+
+    memset(&arg, 0, sizeof(arg));
+    arg.req.op = mm_lock;
+    arg.req.mem_type = memType;
+
+    do{
+	ret = ioctl(fd, DRM_IOCTL_MM_INIT, &arg);
+    } while (ret && errno == EAGAIN);
+    
+    return ret;	
+}
+
+static int I830DrmMMUnlock(int fd, unsigned memType)
+{
+    drm_mm_init_arg_t arg;
+    int ret;
+
+    memset(&arg, 0, sizeof(arg));
+    arg.req.op = mm_unlock;
+    arg.req.mem_type = memType;
+
+    do{
+	ret = ioctl(fd, DRM_IOCTL_MM_INIT, &arg);
+    } while (ret && errno == EAGAIN);
+    
+    return ret;	
+}
+
+#endif
+#endif
+
 static Bool
 I830BIOSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 {
@@ -7527,9 +7700,52 @@ I830BIOSScreenInit(int scrnIndex, Screen
          break;
    }
 
+
+#ifdef XF86DRI
+   if (pI830->directRenderingEnabled && (pI830->mmModeFlags & I830_KERNEL_MM)) {
+      unsigned long aperEnd = ROUND_DOWN_TO(pI830->FbMapSize, GTT_PAGE_SIZE) 
+	 / GTT_PAGE_SIZE;
+      unsigned long aperStart = ROUND_TO(pI830->FbMapSize - KB(pI830->mmSize), GTT_PAGE_SIZE) 
+	 / GTT_PAGE_SIZE;
+
+      if (aperEnd < aperStart || aperEnd - aperStart < I830_MM_MINPAGES) {
+	 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 
+		    "Too little AGP aperture space for DRM memory manager.\n"
+		    "\tPlease increase AGP aperture size from BIOS configuration screen\n"
+		    "\tor decrease the amount of video RAM using option \"VideoRam\".\n"
+		    "\tDisabling DRI.\n");
+	 pI830->directRenderingOpen = FALSE;
+	 I830DRICloseScreen(pScreen);
+	 pI830->directRenderingEnabled = FALSE;
+      } else {
+#ifndef XSERVER_LIBDRM_MM
+	 if (I830DrmMMInit(pI830->drmSubFD, aperStart, aperEnd - aperStart,
+			   DRM_BO_MEM_TT)) {
+#else
+	 if (drmMMInit(pI830->drmSubFD, aperStart, aperEnd - aperStart,
+		       DRM_BO_MEM_TT)) {
+#endif	   
+	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 
+		       "Could not initialize the DRM memory manager.\n");
+	    
+	    pI830->directRenderingOpen = FALSE;
+	    I830DRICloseScreen(pScreen);
+	    pI830->directRenderingEnabled = FALSE;
+	 } else {
+	    xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
+		       "Initialized DRM memory manager, %ld AGP pages\n"
+		       "\tat AGP offset 0x%lx\n", 
+		       aperEnd - aperStart,
+		       aperStart);
+	 }
+      }
+   }
+#endif
+
    return TRUE;
 }
 
+
 static void
 I830AdjustFrame(int scrnIndex, int x, int y, int flags)
 {
@@ -7683,7 +7899,13 @@ I830BIOSLeaveVT(int scrnIndex, int flags
 #ifdef XF86DRI
    if (pI830->directRenderingOpen) {
       DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
-   
+      if (pI830->mmModeFlags & I830_KERNEL_MM) {
+#ifndef XSERVER_LIBDRM_MM
+	 I830DrmMMLock(pI830->drmSubFD, DRM_BO_MEM_TT);
+#else
+	 drmMMLock(pI830->drmSubFD, DRM_BO_MEM_TT);
+#endif
+      }
       I830DRISetVBlankInterrupt (pScrn, FALSE);
       
       drmCtlUninstHandler(pI830->drmSubFD);
@@ -8138,6 +8360,14 @@ I830BIOSEnterVT(int scrnIndex, int flags
 	 for(i = 0; i < I830_NR_TEX_REGIONS+1 ; i++)
 	    sarea->texList[i].age = sarea->texAge;
 
+	 if (pI830->mmModeFlags & I830_KERNEL_MM) {
+#ifndef XSERVER_LIBDRM_MM
+	    I830DrmMMUnlock(pI830->drmSubFD, DRM_BO_MEM_TT);
+#else
+	    drmMMUnlock(pI830->drmSubFD, DRM_BO_MEM_TT);
+#endif
+	 }
+
 	 DPRINTF(PFX, "calling dri unlock\n");
 	 DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
       }
@@ -8351,6 +8581,13 @@ I830BIOSCloseScreen(int scrnIndex, Scree
    pI830->closing = TRUE;
 #ifdef XF86DRI
    if (pI830->directRenderingOpen) {
+      if (pI830->mmModeFlags & I830_KERNEL_MM) {
+#ifndef XSERVER_LIBDRM_MM
+	 I830DrmMMTakedown(pI830->drmSubFD, DRM_BO_MEM_TT);
+#else
+	 drmMMTakedown(pI830->drmSubFD, DRM_BO_MEM_TT);	 
+#endif
+      }
       pI830->directRenderingOpen = FALSE;
       I830DRICloseScreen(pScreen);
    }
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 2d09b2d..09ef5be 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -1107,6 +1107,12 @@ I830ResetAllocations(ScrnInfoPtr pScrn, 
    pI830->MemoryAperture.Start = pI830->StolenMemory.End;
    pI830->MemoryAperture.End = pI830->FbMapSize;
    pI830->MemoryAperture.Size = pI830->FbMapSize - pI830->StolenMemory.Size;
+#ifdef XF86DRI
+   if (!pI830->directRenderingDisabled) {
+      pI830->MemoryAperture.End -= KB(pI830->mmSize);
+      pI830->MemoryAperture.Size -= KB(pI830->mmSize);
+   }
+#endif
    pI830->StolenPool.Fixed = pI830->StolenMemory;
    pI830->StolenPool.Total = pI830->StolenMemory;
 #if ALLOCATE_ALL_BIOSMEM
@@ -1286,37 +1292,41 @@ I830AllocateTextureMemory(ScrnInfoPtr pS
    /* Allocate the remaining space for textures. */
    memset(&(pI830->TexMem), 0, sizeof(pI830->TexMem));
    pI830->TexMem.Key = -1;
-   size = GetFreeSpace(pScrn);
-   if (dryrun && (size < MB(1)))
-      size = MB(1);
-   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)) {
-      if (!dryrun) {
-	 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		"Less than 512 kBytes for texture space (real %ld kBytes).\n", 
-		size / 1024);
+
+   if (pI830->mmModeFlags & I830_KERNEL_TEX) {
+
+      size = GetFreeSpace(pScrn);
+      if (dryrun && (size < MB(1)))
+	 size = MB(1);
+      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)) {
+	 if (!dryrun) {
+	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		       "Less than 512 kBytes for texture space (real %ld kBytes).\n", 
+		       size / 1024);
+	 }
+	 return FALSE;
       }
-      return FALSE;
-   }
-   alloced = I830AllocVidMem(pScrn, &(pI830->TexMem),
-			     &(pI830->StolenPool), size, GTT_PAGE_SIZE,
-			     flags | FROM_ANYWHERE | ALLOCATE_AT_TOP);
-   if (alloced < size) {
-      if (!dryrun) {
-	 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		    "Failed to allocate texture space.\n");
+      alloced = I830AllocVidMem(pScrn, &(pI830->TexMem),
+				&(pI830->StolenPool), size, GTT_PAGE_SIZE,
+				flags | FROM_ANYWHERE | ALLOCATE_AT_TOP);
+      if (alloced < size) {
+	 if (!dryrun) {
+	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		       "Failed to allocate texture space.\n");
+	 }
+	 return FALSE;
       }
-      return FALSE;
+      xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
+		     "%sAllocated %ld kB for textures at 0x%lx\n", s,
+		     alloced / 1024, pI830->TexMem.Start);
    }
-   xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
-		  "%sAllocated %ld kB for textures at 0x%lx\n", s,
-		  alloced / 1024, pI830->TexMem.Start);
 
    return TRUE;
 }
@@ -1514,7 +1524,9 @@ I830FixupOffsets(ScrnInfoPtr pScrn)
       I830FixOffset(pScrn, &(pI830->ContextMem));
       I830FixOffset(pScrn, &(pI830->BackBuffer));
       I830FixOffset(pScrn, &(pI830->DepthBuffer));
-      I830FixOffset(pScrn, &(pI830->TexMem));
+      if (pI830->mmModeFlags & I830_KERNEL_TEX) {
+	 I830FixOffset(pScrn, &(pI830->TexMem));
+      }
    }
 #endif
    return TRUE;
@@ -1913,7 +1925,8 @@ I830BindAGPMemory(ScrnInfoPtr pScrn)
 	    return FALSE;
 	 if (!BindMemRange(pScrn, &(pI830->DepthBuffer)))
 	    return FALSE;
-	 if (!BindMemRange(pScrn, &(pI830->TexMem)))
+	 if ((pI830->mmModeFlags & I830_KERNEL_TEX) && 
+	     !BindMemRange(pScrn, &(pI830->TexMem)))
 	    return FALSE;
       }
 #endif
@@ -1997,7 +2010,8 @@ I830UnbindAGPMemory(ScrnInfoPtr pScrn)
 	    return FALSE;
 	 if (!UnbindMemRange(pScrn, &(pI830->DepthBuffer)))
 	    return FALSE;
-	 if (!UnbindMemRange(pScrn, &(pI830->TexMem)))
+	 if ((pI830->mmModeFlags & I830_KERNEL_TEX) && 
+	     !UnbindMemRange(pScrn, &(pI830->TexMem)))
 	    return FALSE;
       }
 #endif
diff --git a/src/i830_rotate.c b/src/i830_rotate.c
index 020d7e6..0471b55 100644
--- a/src/i830_rotate.c
+++ b/src/i830_rotate.c
@@ -778,7 +778,7 @@ I830Rotate(ScrnInfoPtr pScrn, DisplayMod
       
       /* Do heap teardown here
        */
-      {
+      if (pI8301->mmModeFlags & I830_KERNEL_TEX) {
 	 drmI830MemDestroyHeap destroy;
 	 destroy.region = I830_MEM_REGION_AGP;
 	 
@@ -790,10 +790,11 @@ I830Rotate(ScrnInfoPtr pScrn, DisplayMod
 	 }
       }
       
-      
-      if (pI8301->TexMem.Key != -1)
-         xf86UnbindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key);
-      I830FreeVidMem(pScrn1, &(pI8301->TexMem));
+      if (pI8301->mmModeFlags & I830_KERNEL_TEX) {
+	 if (pI8301->TexMem.Key != -1)
+	    xf86UnbindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key);
+	 I830FreeVidMem(pScrn1, &(pI8301->TexMem));
+      }
       if (pI8301->StolenPool.Allocated.Key != -1) {
          xf86UnbindGARTMemory(pScrn1->scrnIndex, pI8301->StolenPool.Allocated.Key);
          xf86DeallocateGARTMemory(pScrn1->scrnIndex, pI8301->StolenPool.Allocated.Key);
@@ -943,9 +944,11 @@ I830Rotate(ScrnInfoPtr pScrn, DisplayMod
 			      pI8301->disableTiling ? ALLOC_NO_TILING : 0))
          goto BAIL3;
 
-      if (!I830AllocateTextureMemory(pScrn1,
-			      pI8301->disableTiling ? ALLOC_NO_TILING : 0))
-         goto BAIL4;
+      if (pI8301->mmModeFlags & I830_KERNEL_TEX) {
+	 if (!I830AllocateTextureMemory(pScrn1,
+					pI8301->disableTiling ? ALLOC_NO_TILING : 0))
+	    goto BAIL4;
+      }
 
       I830DoPoolAllocation(pScrn1, &(pI8301->StolenPool));
 
@@ -958,8 +961,10 @@ I830Rotate(ScrnInfoPtr pScrn, DisplayMod
          xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->DepthBuffer.Key, pI8301->DepthBuffer.Offset);
       if (pI8301->StolenPool.Allocated.Key != -1)
          xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->StolenPool.Allocated.Key, pI8301->StolenPool.Allocated.Offset);
-      if (pI8301->TexMem.Key != -1)
-         xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key, pI8301->TexMem.Offset);
+      if (pI8301->mmModeFlags & I830_KERNEL_TEX) {
+	 if (pI8301->TexMem.Key != -1)
+	    xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key, pI8301->TexMem.Offset);
+      }
       I830SetupMemoryTiling(pScrn1);
       /* update fence registers */
       for (i = 0; i < 8; i++) 
@@ -1031,7 +1036,6 @@ I830Rotate(ScrnInfoPtr pScrn, DisplayMod
       pI830->AccelInfoRec->maxOffPixWidth = 1;
       pI830->AccelInfoRec->maxOffPixHeight = 1;
    }
-
    return TRUE;
 
 BAIL4:
@@ -1175,11 +1179,12 @@ BAIL0:
 			      pI8301->disableTiling ? ALLOC_NO_TILING : 0))
          xf86DrvMsg(pScrn1->scrnIndex, X_INFO, 
 		    "Oh dear, the depth buffer failed - badness\n");
-
-      if (!I830AllocateTextureMemory(pScrn1,
-			      pI8301->disableTiling ? ALLOC_NO_TILING : 0))
-         xf86DrvMsg(pScrn1->scrnIndex, X_INFO, 
-		    "Oh dear, the texture cache failed - badness\n");
+      if (pI8301->mmModeFlags & I830_KERNEL_TEX) {
+	 if (!I830AllocateTextureMemory(pScrn1,
+					pI8301->disableTiling ? ALLOC_NO_TILING : 0))
+	    xf86DrvMsg(pScrn1->scrnIndex, X_INFO, 
+		       "Oh dear, the texture cache failed - badness\n");
+      }
 
       I830DoPoolAllocation(pScrn1, &(pI8301->StolenPool));
 
@@ -1192,8 +1197,10 @@ BAIL0:
          xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->DepthBuffer.Key, pI8301->DepthBuffer.Offset);
       if (pI8301->StolenPool.Allocated.Key != -1)
          xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->StolenPool.Allocated.Key, pI8301->StolenPool.Allocated.Offset);
-      if (pI8301->TexMem.Key != -1)
-         xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key, pI8301->TexMem.Offset);
+      if (pI8301->mmModeFlags & I830_KERNEL_TEX) {
+	 if (pI8301->TexMem.Key != -1)
+	    xf86BindGARTMemory(pScrn1->scrnIndex, pI8301->TexMem.Key, pI8301->TexMem.Offset);
+      }
       I830SetupMemoryTiling(pScrn1);
       /* update fence registers */
       for (i = 0; i < 8; i++) 
diff-tree 7d67324fa3a5b5cf0227550316c366752fe4abfb (from 20d263805a365be548279758bc39d027d6e56d63)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Mon Oct 23 17:29:17 2006 +0100

    Add some MergedFB checks for accelerator limitations

diff --git a/src/i830_driver.c b/src/i830_driver.c
index 3cee1c8..432f0cb 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -5468,6 +5468,16 @@ I830BIOSPreInit(ScrnInfoPtr pScrn, int f
 #endif
       pI830->disableTiling = TRUE; /* no DRI - so disableTiling */
 
+   if (pScrn->displayWidth >= 4096) {
+      xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Cannot support > 1024x768 in leftof/rightof configurations. disabling DRI.\n");
+      pI830->directRenderingDisabled = TRUE;
+   }
+
+   if (pScrn->virtualY > 2048) {
+      xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Cannot support > 2048 vertical lines. disabling acceleration.\n");
+      pI830->noAccel = TRUE;
+   }
+
    pI830->displayWidth = pScrn->displayWidth;
 
    SetPipeAccess(pScrn);
diff-tree 20d263805a365be548279758bc39d027d6e56d63 (from parents)
Merge: 8548fa53746c9886eccfb67d022136471d8f3316 5ac927d6f05ba6f9608d7e758cbac66e8b3a9db1
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Mon Oct 23 14:24:41 2006 +0100

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/driver/xf86-video-intel

diff-tree 8548fa53746c9886eccfb67d022136471d8f3316 (from adae75ef2f8a655a699e982ca8f26b934dbe950a)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Mon Oct 23 14:23:29 2006 +0100

    Fix manpage to report 8160 instead of 6144 for LinearAlloc.

diff --git a/man/i810.man b/man/i810.man
index fcc5dd8..50c2668 100644
--- a/man/i810.man
+++ b/man/i810.man
@@ -201,7 +201,7 @@ Default: 0 degrees.
 .BI "Option \*qLinearAlloc\*q \*q" integer \*q
 Allows more memory for the offscreen allocator. This usually helps in
 situations where HDTV movies are required to play but not enough offscreen
-memory is usually available. Set this to 6144 for upto 1920x1080 HDTV support.
+memory is usually available. Set this to 8160 for upto 1920x1080 HDTV support.
 Default 0KB (off).
 
 .SH "SEE ALSO"
diff-tree 5ac927d6f05ba6f9608d7e758cbac66e8b3a9db1 (from adae75ef2f8a655a699e982ca8f26b934dbe950a)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Tue Oct 17 13:27:40 2006 +0200

    Don't crash if SetCursorPosition is called with pScrn->currentMode == NULL.
    
    This allows the driver to work with servers that don't have the fix for this
    that was only recently pushed to git.

diff --git a/src/i830_cursor.c b/src/i830_cursor.c
index c5c904c..8343b6b 100644
--- a/src/i830_cursor.c
+++ b/src/i830_cursor.c
@@ -520,11 +520,17 @@ I830SetCursorPosition(ScrnInfoPtr pScrn,
    x -= pScrn->frameX0;
    y -= pScrn->frameY0;
 
-   /* Clamp the cursor position to the visible screen area */
-   if (x >= pScrn->currentMode->HDisplay) x = pScrn->currentMode->HDisplay - 1;
-   if (y >= pScrn->currentMode->VDisplay) y = pScrn->currentMode->VDisplay - 1;
-   if (x <= -I810_CURSOR_X) x = -I810_CURSOR_X + 1;
-   if (y <= -I810_CURSOR_Y) y = -I810_CURSOR_Y + 1;
+   if (pScrn->currentMode) {
+      /* Clamp the cursor position to the visible screen area */
+      if (x >= pScrn->currentMode->HDisplay) x = pScrn->currentMode->HDisplay - 1;
+      if (y >= pScrn->currentMode->VDisplay) y = pScrn->currentMode->VDisplay - 1;
+      if (x <= -I810_CURSOR_X) x = -I810_CURSOR_X + 1;
+      if (y <= -I810_CURSOR_Y) y = -I810_CURSOR_Y + 1;
+   } else {
+      /* Can't ensure the cursor will be visible, so hide it */
+      hide = TRUE;
+      show = FALSE;
+   }
 
 #if 0
    /*
diff-tree adae75ef2f8a655a699e982ca8f26b934dbe950a (from 1d4cfaa391ac41099de11b8f3b21e5eb56543909)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Fri Oct 13 17:10:27 2006 +0100

    Make VIDEO_DEBUG into a configure option

diff --git a/configure.ac b/configure.ac
index 042d67d..c91b1df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,11 @@ AC_ARG_ENABLE(dri, AC_HELP_STRING([--dis
               [DRI="$enableval"],
               [DRI=auto])
 
+AC_ARG_ENABLE(video-debug, AC_HELP_STRING([--enable-video-debug],
+                                  [Enable video debugging support [[default=no]]]),
+              [VIDEO_DEBUG="$enableval"],
+              [VIDEO_DEBUG=no])
+
 
 # Checks for extensions
 XORG_DRIVER_CHECK_EXT(XINERAMA, xineramaproto)
@@ -122,6 +127,11 @@ if test "$DRI" = yes; then
         AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support])
 fi
 
+AM_CONDITIONAL(VIDEO_DEBUG, test x$VIDEO_DEBUG = xyes)
+if test "$VIDEO_DEBUG" = yes; then
+	AC_DEFINE(VIDEO_DEBUG,1,[Enable debug support])
+fi
+
 AC_SUBST([DRI_CFLAGS])
 AC_SUBST([XORG_CFLAGS])
 AC_SUBST([moduledir])
diff --git a/src/i830_video.c b/src/i830_video.c
index db21d87..054d26b 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -1,4 +1,3 @@
-#define VIDEO_DEBUG 0
 /***************************************************************************
  
 Copyright 2000 Intel Corporation.  All Rights Reserved. 
diff-tree 1d4cfaa391ac41099de11b8f3b21e5eb56543909 (from cd9e51cd3ab0b36d2f97dfc6d8850dafe169c221)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Fri Oct 13 13:55:10 2006 +0100

    Bump to 1.7.2

diff --git a/configure.ac b/configure.ac
index 136ff6e..042d67d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-video-i810],
-        1.7.1,
+        1.7.2,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-video-i810)
 
diff --git a/src/i810_dri.h b/src/i810_dri.h
index f5016b6..f090b92 100644
--- a/src/i810_dri.h
+++ b/src/i810_dri.h
@@ -10,7 +10,7 @@
 
 #define I810_MAJOR_VERSION 1
 #define I810_MINOR_VERSION 7
-#define I810_PATCHLEVEL 1
+#define I810_PATCHLEVEL 2
 
 typedef struct {
    drm_handle_t regs;
diff --git a/src/i830_dri.h b/src/i830_dri.h
index a4f5dee..a140497 100644
--- a/src/i830_dri.h
+++ b/src/i830_dri.h
@@ -10,7 +10,7 @@
 
 #define I830_MAJOR_VERSION 1
 #define I830_MINOR_VERSION 7
-#define I830_PATCHLEVEL 1
+#define I830_PATCHLEVEL 2
 
 #define I830_REG_SIZE 0x80000
 
diff-tree cd9e51cd3ab0b36d2f97dfc6d8850dafe169c221 (from 334aa062c333f2c59bc40e1b9239d3ea71c88a8f)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Fri Oct 13 13:54:31 2006 +0100

    Ugh. Turn off debugging.

diff --git a/src/i830_video.c b/src/i830_video.c
index 78ad636..db21d87 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -1,4 +1,4 @@
-#define VIDEO_DEBUG 1
+#define VIDEO_DEBUG 0
 /***************************************************************************
  
 Copyright 2000 Intel Corporation.  All Rights Reserved. 
diff-tree 334aa062c333f2c59bc40e1b9239d3ea71c88a8f (from 8045a7a0af1b276cd7f46ce99d034fd5d503e67c)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Fri Oct 13 12:59:30 2006 +0100

    Bump to 1.7.1

diff --git a/configure.ac b/configure.ac
index 2429353..136ff6e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-video-i810],
-        1.7.0,
+        1.7.1,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-video-i810)
 
diff --git a/src/i810_dri.h b/src/i810_dri.h
index 027a47a..f5016b6 100644
--- a/src/i810_dri.h
+++ b/src/i810_dri.h
@@ -9,8 +9,8 @@
 #define I810_MAX_DRAWABLES 256
 
 #define I810_MAJOR_VERSION 1
-#define I810_MINOR_VERSION 6
-#define I810_PATCHLEVEL 3
+#define I810_MINOR_VERSION 7
+#define I810_PATCHLEVEL 1
 
 typedef struct {
    drm_handle_t regs;
diff --git a/src/i830_dri.h b/src/i830_dri.h
index 3a4cfaf..a4f5dee 100644
--- a/src/i830_dri.h
+++ b/src/i830_dri.h
@@ -10,7 +10,7 @@
 
 #define I830_MAJOR_VERSION 1
 #define I830_MINOR_VERSION 7
-#define I830_PATCHLEVEL 0
+#define I830_PATCHLEVEL 1
 
 #define I830_REG_SIZE 0x80000
 
diff-tree 8045a7a0af1b276cd7f46ce99d034fd5d503e67c (from 6596333b077a692c669f8cb4ae32e145f8da6731)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Fri Oct 13 12:53:53 2006 +0100

    Fix bug #8553 & #8542 - suspend/resume regression from 1.5 driver

diff --git a/src/i830_driver.c b/src/i830_driver.c
index a69a9a3..3cee1c8 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -8041,7 +8041,11 @@ I830BIOSEnterVT(int scrnIndex, int flags
       * the Video BIOS with our saved devices, and only when that fails,
       * we'll warm boot it.
       */
-      if (!I830Set640x480(pScrn)) {
+      /* Check Pipe conf registers or possibly HTOTAL/VTOTAL for 0x00000000)*/
+      CARD32 temp;
+      Bool set = I830Set640x480(pScrn);
+      temp = pI830->pipe ? INREG(PIPEBCONF) : INREG(PIPEACONF);
+      if (!set || !(temp & 0x80000000)) {
          xf86Int10InfoPtr pInt;
 
          xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
diff-tree 6596333b077a692c669f8cb4ae32e145f8da6731 (from c7a23908a0ef45b14b438f656a5f15582bfcbc1c)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Fri Oct 13 12:48:16 2006 +0100

    Fix some warnings

diff --git a/src/i830_video.c b/src/i830_video.c
index 0eeaccb..78ad636 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -1,4 +1,4 @@
-#define VIDEO_DEBUG 0
+#define VIDEO_DEBUG 1
 /***************************************************************************
  
 Copyright 2000 Intel Corporation.  All Rights Reserved. 
@@ -160,7 +160,7 @@ Edummy(const char *dummy, ...)
    do { 								\
       BEGIN_LP_RING(8);							\
       OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE);                       	\
-      OUT_RING(MI_NOOP);    						\  
+      OUT_RING(MI_NOOP);    						\
       if (!*pI830->overlayOn) {						\
 	 OUT_RING(MI_NOOP);						\
 	 OUT_RING(MI_NOOP);						\
@@ -188,7 +188,7 @@ Edummy(const char *dummy, ...)
 	 int spin = 1000000;						\
 	 BEGIN_LP_RING(6);						\
          OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE);                   	\
-         OUT_RING(MI_NOOP);    						\  
+         OUT_RING(MI_NOOP);    						\
 	 OUT_RING(MI_OVERLAY_FLIP | MI_OVERLAY_FLIP_OFF);		\
          if (IS_I965G(pI830)) 						\
             OUT_RING(pI830->OverlayMem->Start | OFC_UPDATE); 		\
@@ -881,9 +881,6 @@ I830StopVideo(ScrnInfoPtr pScrn, pointer
    I830PortPrivPtr pPriv = (I830PortPrivPtr) data;
    I830Ptr pI830 = I830PTR(pScrn);
 
-   I830OverlayRegPtr overlay =
-	 (I830OverlayRegPtr) (pI830->FbBase + pI830->OverlayMem->Start);
-
    if (pPriv->textured)
       return;
 
@@ -3267,8 +3264,6 @@ I830BlockHandler(int i,
    ScrnInfoPtr pScrn = xf86Screens[i];
    I830Ptr pI830 = I830PTR(pScrn);
    I830PortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn);
-   I830OverlayRegPtr overlay =
-	 (I830OverlayRegPtr) (pI830->FbBase + pI830->OverlayMem->Start);
 
    pScreen->BlockHandler = pI830->BlockHandler;
 
@@ -3398,9 +3393,6 @@ I830StopSurface(XF86SurfacePtr surface)
    if (pPriv->isOn) {
       I830Ptr pI830 = I830PTR(pScrn);
 
-      I830OverlayRegPtr overlay =
-	    (I830OverlayRegPtr) (pI830->FbBase + pI830->OverlayMem->Start);
-
       ErrorF("StopSurface\n");
 
       I830ResetVideo(pScrn);
diff-tree c7a23908a0ef45b14b438f656a5f15582bfcbc1c (from 07cdc60be8ebe5d0c21149f3cd2aeb8fed05022a)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Fri Oct 6 13:35:39 2006 +0100

    Fix server regeneration problem mapping the aperture

diff --git a/src/i810_driver.c b/src/i810_driver.c
index 22635c8..cd6d9d7 100644
--- a/src/i810_driver.c
+++ b/src/i810_driver.c
@@ -1186,14 +1186,13 @@ I810MapMem(ScrnInfoPtr pScrn)
    long i;
 
    for (i = 2; i < pI810->FbMapSize; i <<= 1) ;
-   pI810->FbMapSize = i;
 
    if (!I810MapMMIO(pScrn))
       return FALSE;
 
    pI810->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
 				 pI810->PciTag,
-				 pI810->LinearAddr, pI810->FbMapSize);
+				 pI810->LinearAddr, i);
    if (!pI810->FbBase)
       return FALSE;
 
diff-tree 07cdc60be8ebe5d0c21149f3cd2aeb8fed05022a (from 8da10d15f84ccc992b828546af5ba0d848e7263e)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Wed Oct 4 11:05:30 2006 +0100

    Fix bug #5795, VT switching fails because of a bad test on some platforms.

diff --git a/src/i830_driver.c b/src/i830_driver.c
index 9c86fe5..a69a9a3 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -2620,37 +2620,15 @@ static Bool
 I830Set640x480(ScrnInfoPtr pScrn)
 {
    I830Ptr pI830 = I830PTR(pScrn);
-   int m = 0x30; /* 640x480 8bpp */
+   int m;
 
-   switch (pScrn->depth) {
-   case 15:
-	 m = 0x40;
-	 break;
-   case 16:
-	 m = 0x41;
-	 break;
-   case 24:
-	 m = 0x50;
-	 break;
-   }
-
-   m |= (1 << 15) | (1 << 14);
+   /* 640x480 8bpp */
+   m = 0x30 | (1 << 15) | (1 << 14);
    if (VBESetVBEMode(pI830->pVbe, m, NULL))
 	   return TRUE;
 
-
    /* if the first failed, let's try the next - usually 800x600 */
-   m = 0x32;
-   switch (pScrn->depth) {
-   case 15:
-   case 16:
-	 m = 0x42;
-	 break;
-   case 24:
-	 m = 0x52;
-	 break;
-   }
-   m |= (1 << 15) | (1 << 14);
+   m = 0x32 | (1 << 15) | (1 << 14);
 
    if (VBESetVBEMode(pI830->pVbe, m, NULL))
 	   return TRUE;
diff-tree 8da10d15f84ccc992b828546af5ba0d848e7263e (from f337eea9e73cbf5c71d07df50d2e5b661a1f34cf)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Tue Oct 3 22:00:14 2006 -0700

    Enable XV_PORT attribute even when not in Clone mode.
    
    As Clone mode is now something that can change after server startup, always
    enable the XV_PORT attribute as we cannot change the list of reported
    attributes.
    (cherry picked from 1bc1cedbcdf6ea4d2a3e8b07b553ac50b3c126f4 commit)

diff --git a/src/i830_video.c b/src/i830_video.c
index 2c357d6..0eeaccb 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -681,8 +681,7 @@ I830SetupImageVideoOverlay(ScreenPtr pSc
 
    adapt->pPortPrivates[0].ptr = (pointer) (pPriv);
    adapt->nAttributes = NUM_ATTRIBUTES;
-   if (pI830->Clone)
-      adapt->nAttributes += CLONE_ATTRIBUTES;
+   adapt->nAttributes += CLONE_ATTRIBUTES;
    if (IS_I9XX(pI830))
       adapt->nAttributes += GAMMA_ATTRIBUTES; /* has gamma */
    adapt->pAttributes = xnfalloc(sizeof(XF86AttributeRec) * adapt->nAttributes);
@@ -690,10 +689,8 @@ I830SetupImageVideoOverlay(ScreenPtr pSc
    att = adapt->pAttributes;
    memcpy((char *)att, (char*)Attributes, sizeof(XF86AttributeRec)* NUM_ATTRIBUTES);
    att+=NUM_ATTRIBUTES;
-   if (pI830->Clone) {
-      memcpy((char*)att, (char*)CloneAttributes, sizeof(XF86AttributeRec) * CLONE_ATTRIBUTES);
-      att+=CLONE_ATTRIBUTES;
-   }
+   memcpy((char*)att, (char*)CloneAttributes, sizeof(XF86AttributeRec) * CLONE_ATTRIBUTES);
+   att+=CLONE_ATTRIBUTES;
    if (IS_I9XX(pI830)) {
       memcpy((char*)att, (char*)GammaAttributes, sizeof(XF86AttributeRec) * GAMMA_ATTRIBUTES);
       att+=GAMMA_ATTRIBUTES;
@@ -752,8 +749,7 @@ I830SetupImageVideoOverlay(ScreenPtr pSc
    xvDoubleBuffer = MAKE_ATOM("XV_DOUBLE_BUFFER");
 
    /* Allow the pipe to be switched from pipe A to B when in clone mode */
-   if (pI830->Clone)
-     xvPipe = MAKE_ATOM("XV_PIPE");
+   xvPipe = MAKE_ATOM("XV_PIPE");
    
    if (IS_I9XX(pI830)) {
      xvGamma0 = MAKE_ATOM("XV_GAMMA0");
@@ -1031,7 +1027,7 @@ I830GetPortAttribute(ScrnInfoPtr pScrn,
       *value = pPriv->brightness;
    } else if (attribute == xvContrast) {
       *value = pPriv->contrast;
-   } else if (pI830->Clone && attribute == xvPipe) {
+   } else if (attribute == xvPipe) {
       *value = pPriv->pipe;
    } else if (attribute == xvGamma0 && (IS_I9XX(pI830))) {
       *value = pPriv->gamma0;
diff-tree f337eea9e73cbf5c71d07df50d2e5b661a1f34cf (from 2b9bdd8a4021231e4b5f4c5831a46c9ff1e38081)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Mon Oct 2 11:16:42 2006 +0100

    silence warning

diff --git a/src/i830_driver.c b/src/i830_driver.c
index 2506f53..9c86fe5 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1343,7 +1343,7 @@ I830UpdateXineramaScreenInfo(ScrnInfoPtr
     Bool usenonrect = pI830->NonRect;
     const char *rectxine = "\t... setting up rectangular Xinerama layout\n";
 #ifdef XF86DRI
-    drmI830Sarea *sarea;
+    drmI830Sarea *sarea = NULL;
 
     if (pI830->directRenderingEnabled) {
        sarea = (drmI830Sarea *) DRIGetSAREAPrivate(pScrn1->pScreen);
diff-tree 2b9bdd8a4021231e4b5f4c5831a46c9ff1e38081 (from eca082ca0fec12973a4dbb0106b841136b5b6cdb)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Mon Oct 2 11:12:23 2006 +0100

    bump to 1.7.0

diff --git a/configure.ac b/configure.ac
index a27822e..2429353 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-video-i810],
-        1.6.5,
+        1.7.0,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-video-i810)
 
diff-tree eca082ca0fec12973a4dbb0106b841136b5b6cdb (from cece9a455b54ab184a3277c164ee6dfa65b70f48)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Sat Sep 30 13:44:43 2006 +0100

    Missing gamma bit

diff --git a/src/i830_cursor.c b/src/i830_cursor.c
index c9e04e9..c5c904c 100644
--- a/src/i830_cursor.c
+++ b/src/i830_cursor.c
@@ -655,7 +655,7 @@ I830ShowCursor(ScrnInfoPtr pScrn)
       temp &= ~(CURSOR_FORMAT_MASK | CURSOR_GAMMA_ENABLE);
       temp |= CURSOR_ENABLE;
       if (pI830->CursorIsARGB)
-         temp |= CURSOR_FORMAT_ARGB;
+         temp |= CURSOR_FORMAT_ARGB | CURSOR_GAMMA_ENABLE;
       else 
          temp |= CURSOR_FORMAT_3C;
       OUTREG(CURSOR_CONTROL, temp);
diff-tree cece9a455b54ab184a3277c164ee6dfa65b70f48 (from 2013b839de3733fd12becb2cc3c1daadde329eb4)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Sat Sep 30 13:27:27 2006 +0100

    Fix issues with Xv locking up the engine. bug #7915.

diff --git a/src/i830_video.c b/src/i830_video.c
index b87e4eb..2c357d6 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -158,11 +158,11 @@ Edummy(const char *dummy, ...)
 
 #define OVERLAY_UPDATE						\
    do { 								\
-      BEGIN_LP_RING(6);							\
-      OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE);			\
-      OUT_RING(MI_NOOP);						\
+      BEGIN_LP_RING(8);							\
+      OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE);                       	\
+      OUT_RING(MI_NOOP);    						\  
       if (!*pI830->overlayOn) {						\
-         OUT_RING(MI_NOOP);						\
+	 OUT_RING(MI_NOOP);						\
 	 OUT_RING(MI_NOOP);						\
 	 OUT_RING(MI_OVERLAY_FLIP | MI_OVERLAY_FLIP_ON);		\
 	 ErrorF("Overlay goes from off to on\n");			\
@@ -172,10 +172,12 @@ Edummy(const char *dummy, ...)
 	 OUT_RING(MI_NOOP);						\
 	 OUT_RING(MI_OVERLAY_FLIP | MI_OVERLAY_FLIP_CONTINUE);		\
       }									\
-      if (IS_I965G(pI830)) 					\
+      if (IS_I965G(pI830)) 						\
          OUT_RING(pI830->OverlayMem->Start | OFC_UPDATE); 		\
       else								\
 	 OUT_RING(pI830->OverlayMem->Physical | OFC_UPDATE);		\
+      OUT_RING(MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);		\
+      OUT_RING(MI_NOOP);						\
       ADVANCE_LP_RING();						\
       ErrorF("OVERLAY_UPDATE\n");					\
    } while(0)
@@ -184,20 +186,11 @@ Edummy(const char *dummy, ...)
    do { 								\
       if (*pI830->overlayOn) {						\
 	 int spin = 1000000;						\
-	 BEGIN_LP_RING(12);						\
-	 OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE);			\
-	 OUT_RING(MI_NOOP);						\
-	 OUT_RING(MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);	\
-	 OUT_RING(MI_NOOP);						\
-	 OUT_RING(MI_OVERLAY_FLIP | MI_OVERLAY_FLIP_CONTINUE);		\
-         if (IS_I965G(pI830)) 					\
-            OUT_RING(pI830->OverlayMem->Start | OFC_UPDATE); 		\
-         else								\
-	    OUT_RING(pI830->OverlayMem->Physical | OFC_UPDATE);		\
-	 OUT_RING(MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);	\
-	 OUT_RING(MI_NOOP);						\
+	 BEGIN_LP_RING(6);						\
+         OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE);                   	\
+         OUT_RING(MI_NOOP);    						\  
 	 OUT_RING(MI_OVERLAY_FLIP | MI_OVERLAY_FLIP_OFF);		\
-         if (IS_I965G(pI830)) 					\
+         if (IS_I965G(pI830)) 						\
             OUT_RING(pI830->OverlayMem->Start | OFC_UPDATE); 		\
          else								\
 	    OUT_RING(pI830->OverlayMem->Physical | OFC_UPDATE);		\
@@ -420,7 +413,7 @@ I830InitVideo(ScreenPtr pScreen)
    XF86VideoAdaptorPtr overlayAdaptor = NULL, texturedAdaptor = NULL;
    int num_adaptors;
 
-   DPRINTF(PFX, "I830InitVideo\n");
+   ErrorF("I830InitVideo\n");
 
 #if 0
    {
@@ -494,7 +487,7 @@ I830ResetVideo(ScrnInfoPtr pScrn)
    I830OverlayRegPtr overlay =
 	 (I830OverlayRegPtr) (pI830->FbBase + pI830->OverlayMem->Start);
 
-   DPRINTF(PFX, "I830ResetVideo: base: %p, offset: 0x%lx, obase: %p\n",
+   ErrorF("I830ResetVideo: base: %p, offset: 0x%lx, obase: %p\n",
 	   pI830->FbBase, pI830->OverlayMem->Start, overlay);
    /*
     * Default to maximum image size in YV12
@@ -663,7 +656,7 @@ I830SetupImageVideoOverlay(ScreenPtr pSc
    I830PortPrivPtr pPriv;
    XF86AttributePtr att;
 
-   DPRINTF(PFX, "I830SetupImageVideoOverlay\n");
+   ErrorF("I830SetupImageVideoOverlay\n");
 
    if (!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
 			 sizeof(I830PortPrivRec) + sizeof(DevUnion))))
@@ -789,7 +782,7 @@ I830SetupImageVideoTextured(ScreenPtr pS
    int nports = 16, i;
    int nAttributes;
 
-   DPRINTF(PFX, "I830SetupImageVideoOverlay\n");
+   ErrorF("I830SetupImageVideoOverlay\n");
 
    nAttributes = NUM_TEXTURED_ATTRIBUTES;
 
@@ -898,18 +891,16 @@ I830StopVideo(ScrnInfoPtr pScrn, pointer
    if (pPriv->textured)
       return;
 
-   DPRINTF(PFX, "I830StopVideo\n");
+   ErrorF("I830StopVideo\n");
 
    REGION_EMPTY(pScrn->pScreen, &pPriv->clip);
 
    if (shutdown) {
       if (pPriv->videoStatus & CLIENT_VIDEO_ON) {
 
-	 overlay->OCMD &= ~OVERLAY_ENABLE;
+	 I830ResetVideo(pScrn);
 	 OVERLAY_UPDATE;
-#if 1
 	 OVERLAY_OFF;
-#endif
 
          if (pI830->entityPrivate)
             pI830->entityPrivate->XvInUse = -1;
@@ -1671,8 +1662,11 @@ I830DisplayVideo(ScrnInfoPtr pScrn, int 
       I830ResetVideo(pScrn);
 
    /* Ensure overlay is turned on with OVERLAY_ENABLE at 0 */
-   if (!*pI830->overlayOn)
+   if (!*pI830->overlayOn) {
+      ErrorF("TURNING ON OVERLAY BEFORE UPDATE\n");
+      I830ResetVideo(pScrn);
       OVERLAY_UPDATE;
+   }
 
    /* Fix up the dstBox if outside the visible screen */
    {
@@ -2873,7 +2867,7 @@ I830AllocateMemory(ScrnInfoPtr pScrn, FB
    ScreenPtr pScreen;
    FBLinearPtr new_linear = NULL;
 
-   DPRINTF(PFX, "I830AllocateMemory\n");
+   ErrorF("I830AllocateMemory\n");
 
    if (linear) {
       if (linear->size >= size)
@@ -2945,7 +2939,7 @@ I830PutImage(ScrnInfoPtr pScrn,
    int pitchAlignMask;
    int extraLinear;
 
-   DPRINTF(PFX, "I830PutImage: src: (%d,%d)(%d,%d), dst: (%d,%d)(%d,%d)\n"
+   ErrorF("I830PutImage: src: (%d,%d)(%d,%d), dst: (%d,%d)(%d,%d)\n"
 	   "width %d, height %d\n", src_x, src_y, src_w, src_h, drw_x, drw_y,
 	   drw_w, drw_h, width, height);
 
@@ -3296,11 +3290,10 @@ I830BlockHandler(int i,
 	 if (pPriv->offTime < now) {
 	    /* Turn off the overlay */
 	    ErrorF("BLOCKHANDLER\n");
-	    overlay->OCMD &= ~OVERLAY_ENABLE;
+
+	    I830ResetVideo(pScrn);
             OVERLAY_UPDATE;
-#if 1
             OVERLAY_OFF;
-#endif
 
 	    pPriv->videoStatus = FREE_TIMER;
 	    pPriv->freeTime = now + FREE_DELAY;
@@ -3413,11 +3406,10 @@ I830StopSurface(XF86SurfacePtr surface)
 	    (I830OverlayRegPtr) (pI830->FbBase + pI830->OverlayMem->Start);
 
       ErrorF("StopSurface\n");
-      overlay->OCMD &= ~OVERLAY_ENABLE;
+
+      I830ResetVideo(pScrn);
       OVERLAY_UPDATE;
-#if 1
       OVERLAY_OFF;
-#endif
 
       if (pI830->entityPrivate)
          pI830->entityPrivate->XvInUse = -1;
diff-tree 2013b839de3733fd12becb2cc3c1daadde329eb4 (from fe691953f08b4d299295f91450412404ba42810b)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Sep 28 13:49:44 2006 +0200

    Always call I830UpdateXineramaScreenInfo() unconditionally, and document why.

diff --git a/src/i830_driver.c b/src/i830_driver.c
index fc768af..2506f53 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -2064,9 +2064,6 @@ I830XineramaExtensionInit(ScrnInfoPtr pS
        pI830->I830XineramaVY = 0;
 
     }
-
-    I830UpdateXineramaScreenInfo(pScrn);
-
 }
 
 static void
@@ -7491,6 +7488,9 @@ I830BIOSScreenInit(int scrnIndex, Screen
       xf86DrvMsg(pScrn->scrnIndex, X_INFO, "libshadow is version %d.%d.%d, required 1.1.0 or greater for rotation.\n",pI830->shadowReq.majorversion,pI830->shadowReq.minorversion,pI830->shadowReq.patchlevel);
    }
 
+   /* Call this unconditionally, as it also sets some fields in the SAREA */
+   I830UpdateXineramaScreenInfo(pScrn);
+
    if (serverGeneration == 1)
       xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
 
@@ -8235,6 +8235,7 @@ I830BIOSSwitchMode(int scrnIndex, Displa
 
    /* Since RandR (indirectly) uses SwitchMode(), we need to
     * update our Xinerama info here, too, in case of resizing
+    * Call this unconditionally, as it also sets some fields in the SAREA
     */
    I830UpdateXineramaScreenInfo(pScrn);
 
diff-tree fe691953f08b4d299295f91450412404ba42810b (from 06c5f7bd076e9ba4b925e061a40b837714bc8267)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Aug 31 18:35:10 2006 +0200

    Store viewport limits of both pipes in SAREA.
    
    This allows DRI clients to determine which pipe they should synchronize buffer
    swaps of each window to.

diff --git a/src/i830_common.h b/src/i830_common.h
index c3ef4cd..79455b6 100644
--- a/src/i830_common.h
+++ b/src/i830_common.h
@@ -121,6 +121,15 @@ typedef struct {
         unsigned int depth_tiled;
         unsigned int rotated_tiled;
         unsigned int rotated2_tiled;
+
+	int pipeA_x;
+	int pipeA_y;
+	int pipeA_w;
+	int pipeA_h;
+	int pipeB_x;
+	int pipeB_y;
+	int pipeB_w;
+	int pipeB_h;
 } drmI830Sarea;
 
 /* Flags for perf_boxes
diff --git a/src/i830_dri.h b/src/i830_dri.h
index 41f8a90..3a4cfaf 100644
--- a/src/i830_dri.h
+++ b/src/i830_dri.h
@@ -9,8 +9,8 @@
 #define I830_MAX_DRAWABLES 256
 
 #define I830_MAJOR_VERSION 1
-#define I830_MINOR_VERSION 6
-#define I830_PATCHLEVEL 4
+#define I830_MINOR_VERSION 7
+#define I830_PATCHLEVEL 0
 
 #define I830_REG_SIZE 0x80000
 
diff --git a/src/i830_driver.c b/src/i830_driver.c
index ffa93f8..fc768af 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1342,15 +1342,49 @@ I830UpdateXineramaScreenInfo(ScrnInfoPtr
     Bool infochanged = FALSE;
     Bool usenonrect = pI830->NonRect;
     const char *rectxine = "\t... setting up rectangular Xinerama layout\n";
+#ifdef XF86DRI
+    drmI830Sarea *sarea;
+
+    if (pI830->directRenderingEnabled) {
+       sarea = (drmI830Sarea *) DRIGetSAREAPrivate(pScrn1->pScreen);
+    }
+#endif
 
     pI830->MBXNR1XMAX = pI830->MBXNR1YMAX = pI830->MBXNR2XMAX = pI830->MBXNR2YMAX = 65536;
     pI830->HaveNonRect = pI830->HaveOffsRegions = FALSE;
 
-    if(!pI830->MergedFB) return;
+    if(!pI830->MergedFB) {
+#ifdef XF86DRI
+       if (pI830->directRenderingEnabled) {
+          sarea->pipeA_x = sarea->pipeA_y = sarea->pipeB_x = sarea->pipeB_y = 0;
 
-    if(I830noPanoramiXExtension) return;
+          if (pI830->planeEnabled[0]) {
+             sarea->pipeA_w = pScrn1->virtualX;
+             sarea->pipeA_h = pScrn1->virtualY;
+          } else {
+             sarea->pipeA_w = 0;
+             sarea->pipeA_h = 0;
+          }
+
+          if (pI830->planeEnabled[1]) {
+             sarea->pipeB_w = pScrn1->virtualX;
+             sarea->pipeB_h = pScrn1->virtualY;
+          } else {
+             sarea->pipeB_w = 0;
+             sarea->pipeB_h = 0;
+          }
+       }
+#endif
 
-    if(!I830XineramadataPtr) return;
+       return;
+    }
+
+    if (I830noPanoramiXExtension || !I830XineramadataPtr) {
+#ifdef XF86DRI
+       if (!pI830->directRenderingEnabled)
+#endif
+	  return;
+    }
 
     if(pI830->SecondIsScrn0) {
        scrnnum1 = 1;
@@ -1631,14 +1665,30 @@ I830UpdateXineramaScreenInfo(ScrnInfoPtr
 
     }
 
-    I830XineramadataPtr[scrnnum1].x = x1;
-    I830XineramadataPtr[scrnnum1].y = y1;
-    I830XineramadataPtr[scrnnum1].width = w1;
-    I830XineramadataPtr[scrnnum1].height = h1;
-    I830XineramadataPtr[scrnnum2].x = x2;
-    I830XineramadataPtr[scrnnum2].y = y2;
-    I830XineramadataPtr[scrnnum2].width = w2;
-    I830XineramadataPtr[scrnnum2].height = h2;
+#ifdef XF86DRI
+    if (pI830->directRenderingEnabled) {
+       sarea->pipeA_x = x1;
+       sarea->pipeA_y = y1;
+       sarea->pipeA_w = w1;
+       sarea->pipeA_h = h1;
+       sarea->pipeB_x = x2;
+       sarea->pipeB_y = y2;
+       sarea->pipeB_w = w2;
+       sarea->pipeB_h = h2;
+    }
+#endif
+
+    if (I830XineramadataPtr && !I830noPanoramiXExtension) {
+       I830XineramadataPtr[scrnnum1].x = x1;
+       I830XineramadataPtr[scrnnum1].y = y1;
+       I830XineramadataPtr[scrnnum1].width = w1;
+       I830XineramadataPtr[scrnnum1].height = h1;
+       I830XineramadataPtr[scrnnum2].x = x2;
+       I830XineramadataPtr[scrnnum2].y = y2;
+       I830XineramadataPtr[scrnnum2].width = w2;
+       I830XineramadataPtr[scrnnum2].height = h2;
+    } else
+       return;
 
     if(infochanged) {
        xf86DrvMsg(pScrn1->scrnIndex, X_INFO,
@@ -8186,9 +8236,7 @@ I830BIOSSwitchMode(int scrnIndex, Displa
    /* Since RandR (indirectly) uses SwitchMode(), we need to
     * update our Xinerama info here, too, in case of resizing
     */
-   if(pI830->MergedFB) {
-      I830UpdateXineramaScreenInfo(pScrn);
-   }
+   I830UpdateXineramaScreenInfo(pScrn);
 
    return ret;
 }
diff-tree 06c5f7bd076e9ba4b925e061a40b837714bc8267 (from 89cbc6e215a5f313ccc17370424c35630cf75892)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Wed Aug 30 19:45:33 2006 +0200

    If the DRM can handle it, enable vertical blank interrupts for both pipes.

diff --git a/src/i830_dri.c b/src/i830_dri.c
index 92f8d4a..21af651 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1489,9 +1489,12 @@ I830DRISetVBlankInterrupt (ScrnInfoPtr p
 
     if (pI830->directRenderingEnabled && pI830->drmMinor >= 5) {
 	if (on) {
-	    if (pI830->planeEnabled[1])
-		pipe.pipe = DRM_I830_VBLANK_PIPE_B;
-	    else
+	    if (pI830->planeEnabled[1]) {
+		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;
diff-tree 89cbc6e215a5f313ccc17370424c35630cf75892 (from 6614b4bda2e079fd1e56e0825894481b80e2df58)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Aug 24 10:30:27 2006 +0200

    Only enable the IRQ after DRIFinishScreenInit.
    
    This makes sure we've been assigned a context ID, so the interrupt context
    won't mess things up if it grabs the HW lock.

diff --git a/src/i830_dri.c b/src/i830_dri.c
index c9b52c4..92f8d4a 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -835,29 +835,6 @@ I830DRIDoMappings(ScreenPtr pScreen)
       I830SetParam(pScrn, I830_SETPARAM_USE_MI_BATCHBUFFER_START, 1 );
    }
 
-   /* Okay now initialize the dma engine */
-   {
-      pI830DRI->irq = drmGetInterruptFromBusID(pI830->drmSubFD,
-					       ((pciConfigPtr) pI830->
-						PciInfo->thisCard)->busnum,
-					       ((pciConfigPtr) pI830->
-						PciInfo->thisCard)->devnum,
-					       ((pciConfigPtr) pI830->
-						PciInfo->thisCard)->funcnum);
-
-      if (drmCtlInstHandler(pI830->drmSubFD, pI830DRI->irq)) {
-	 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		    "[drm] failure adding irq handler\n");
-	 pI830DRI->irq = 0;
-	 DRICloseScreen(pScreen);
-	 return FALSE;
-      }
-      else
-	 xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-		    "[drm] dma control initialized, using IRQ %d\n",
-		    pI830DRI->irq);
-   }
-
    pI830DRI = (I830DRIPtr) pI830->pDRIInfo->devPrivate;
    pI830DRI->deviceID = pI830->PciInfo->chipType;
    pI830DRI->width = pScrn->virtualX;
@@ -982,7 +959,34 @@ I830DRIFinishScreenInit(ScreenPtr pScree
       pI830->allowPageFlip = 0;
 
 
-   return DRIFinishScreenInit(pScreen);
+   if (!DRIFinishScreenInit(pScreen))
+      return FALSE;
+
+   /* Okay now initialize the dma engine */
+   {
+      I830DRIPtr pI830DRI = (I830DRIPtr) pI830->pDRIInfo->devPrivate;
+
+      pI830DRI->irq = drmGetInterruptFromBusID(pI830->drmSubFD,
+					       ((pciConfigPtr) pI830->
+						PciInfo->thisCard)->busnum,
+					       ((pciConfigPtr) pI830->
+						PciInfo->thisCard)->devnum,
+					       ((pciConfigPtr) pI830->
+						PciInfo->thisCard)->funcnum);
+
+      if (drmCtlInstHandler(pI830->drmSubFD, pI830DRI->irq)) {
+	 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+		    "[drm] failure adding irq handler\n");
+	 pI830DRI->irq = 0;
+	 DRICloseScreen(pScreen);
+	 return FALSE;
+      }
+      else
+	 xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+		    "[drm] dma control initialized, using IRQ %d\n",
+		    pI830DRI->irq);
+	 return TRUE;
+   }
 }
 
 void
diff-tree 6614b4bda2e079fd1e56e0825894481b80e2df58 (from parents)
Merge: d6ca9feb78a9211758510751bbf47013caabff49 b3ddcf3348365873aed4a2b8b2750b330fb4cf26
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Mon Sep 25 12:04:01 2006 +0100

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/driver/xf86-video-intel

diff-tree d6ca9feb78a9211758510751bbf47013caabff49 (from 564c830a91afda76706a8c4c2f3287d0b8d514e9)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Mon Sep 25 12:03:27 2006 +0100

    Fix bug #7943 where video flickers when changing
    attributes. This code was a leftover from testing lockups
    and shouldn't be needed anymore.

diff --git a/src/i830_video.c b/src/i830_video.c
index c044ddd..b87e4eb 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -951,22 +951,14 @@ I830SetPortAttribute(ScrnInfoPtr pScrn,
       pPriv->brightness = value;
       overlay->OCLRC0 = (pPriv->contrast << 18) | (pPriv->brightness & 0xff);
       ErrorF("BRIGHTNESS\n");
-      overlay->OCMD &= ~OVERLAY_ENABLE;
       OVERLAY_UPDATE;
-#if 1
-      OVERLAY_OFF;
-#endif
    } else if (attribute == xvContrast) {
       if ((value < 0) || (value > 255))
 	 return BadValue;
       pPriv->contrast = value;
       overlay->OCLRC0 = (pPriv->contrast << 18) | (pPriv->brightness & 0xff);
       ErrorF("CONTRAST\n");
-      overlay->OCMD &= ~OVERLAY_ENABLE;
       OVERLAY_UPDATE;
-#if 1
-      OVERLAY_OFF;
-#endif
    } else if (pI830->Clone && attribute == xvPipe) {
       if ((value < 0) || (value > 1))
          return BadValue;
@@ -980,11 +972,7 @@ I830SetPortAttribute(ScrnInfoPtr pScrn,
       else 
          overlay->OCONFIG |= OVERLAY_PIPE_B;
       ErrorF("PIPE CHANGE\n");
-      overlay->OCMD &= ~OVERLAY_ENABLE;
       OVERLAY_UPDATE;
-#if 1
-      OVERLAY_OFF;
-#endif
    } else if (attribute == xvGamma0 && (IS_I9XX(pI830))) {
       pPriv->gamma0 = value; 
    } else if (attribute == xvGamma1 && (IS_I9XX(pI830))) {
@@ -1011,11 +999,7 @@ I830SetPortAttribute(ScrnInfoPtr pScrn,
 	 break;
       }
       ErrorF("COLORKEY\n");
-      overlay->OCMD &= ~OVERLAY_ENABLE;
       OVERLAY_UPDATE;
-#if 1
-      OVERLAY_OFF;
-#endif
       REGION_EMPTY(pScrn->pScreen, &pPriv->clip);
    } else if(attribute == xvDoubleBuffer) {
       if ((value < 0) || (value > 1))
@@ -1026,20 +1010,20 @@ I830SetPortAttribute(ScrnInfoPtr pScrn,
    } else
       return BadMatch;
 
-   /* We've already confirmed that the overlay is off, ready for updating */
+   /* Ensure that the overlay is off, ready for updating */
    if ((attribute == xvGamma0 ||
         attribute == xvGamma1 ||
         attribute == xvGamma2 ||
         attribute == xvGamma3 ||
         attribute == xvGamma4 ||
         attribute == xvGamma5) && (IS_I9XX(pI830))) {
+	CARD32 r = overlay->OCMD & OVERLAY_ENABLE;
         ErrorF("GAMMA\n");
         overlay->OCMD &= ~OVERLAY_ENABLE;
         OVERLAY_UPDATE;
-#if 1
-        OVERLAY_OFF;
-#endif
 	I830UpdateGamma(pScrn);
+        overlay->OCMD |= r;
+        OVERLAY_UPDATE;
    }
 
    return Success;
diff-tree b3ddcf3348365873aed4a2b8b2750b330fb4cf26 (from 564c830a91afda76706a8c4c2f3287d0b8d514e9)
Author: A Costa <agcosta at gis.net>
Date:   Thu Sep 21 23:18:43 2006 +1000

    Typo fix in man page (Debian bug #364559).

diff --git a/man/i810.man b/man/i810.man
index d8c2cd2..fcc5dd8 100644
--- a/man/i810.man
+++ b/man/i810.man
@@ -49,7 +49,7 @@ DRI is enabled.  This amount may be chan
 entry in the config file
 .B "Device"
 section.  It may be set to any reasonable value up to 64MB for older
-chipsets or 128MB for newer chipets.  It is advisable to check the
+chipsets or 128MB for newer chipsets.  It is advisable to check the
 __xservername__
 log file to check if any features have been disabled because of insufficient
 video memory.  In particular, DRI support or tiling mode may be disabled
diff-tree 564c830a91afda76706a8c4c2f3287d0b8d514e9 (from parents)
Merge: bf49084ad700f064b732bf39a163209eee1d6845 b970166eab95ac024ff481b0f5fd9aaf3644aabf
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Wed Sep 13 16:34:10 2006 +0100

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/driver/xf86-video-intel

diff-tree bf49084ad700f064b732bf39a163209eee1d6845 (from 8b9d7a5f8560ee55ca5cb5376517a4246cd79fb9)
Author: root <root at jetpack.demon.co.uk>
Date:   Wed Sep 13 16:32:39 2006 +0100

    bump max Xvideo height to 1088 to cope with some players.

diff --git a/src/i830_video.c b/src/i830_video.c
index bbf1df7..c044ddd 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -130,9 +130,9 @@ static Atom xvBrightness, xvContrast, xv
 static Atom xvGamma0, xvGamma1, xvGamma2, xvGamma3, xvGamma4, xvGamma5;
 
 #define IMAGE_MAX_WIDTH		1920
-#define IMAGE_MAX_HEIGHT	1080
+#define IMAGE_MAX_HEIGHT	1088
 #define IMAGE_MAX_WIDTH_LEGACY	1024
-#define IMAGE_MAX_HEIGHT_LEGACY	1080
+#define IMAGE_MAX_HEIGHT_LEGACY	1088
 
 /*
  * Broadwater requires a bit of extra video memory for state information



More information about the xorg-commit mailing list