summaryrefslogtreecommitdiff
path: root/xc
diff options
context:
space:
mode:
authorkeithw <keithw>1999-12-16 05:23:35 +0000
committerkeithw <keithw>1999-12-16 05:23:35 +0000
commitf9584fefc992bfa313fb6f53d7fa0928c1bbff94 (patch)
treea96a41fd43c690d863bc4cffa60c50dcc1115d8e /xc
parenta364d379a925a1af6fc840fa1531984fa335eac7 (diff)
First integration of DRI stuff from the tdfx driver. More or less compiles,
otherwise untested.
Diffstat (limited to 'xc')
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile37
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h88
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c38
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_cursor.c6
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c550
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h27
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dripriv.h24
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c225
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c59
9 files changed, 931 insertions, 123 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile
index 8c1ed8cc4..f13c9c659 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile
@@ -6,22 +6,36 @@ XCOMM
#define IHaveModules
#include <Server.tmpl>
-SRCS = i810_driver.c i810_cursor.c i810_accel.c i810_io.c i810_memory.c i810_wmark.c
+#
+# Uncomment these to build with DRI support when available
+#
+#if BuildXF86DRI
+DRISRCS = i810_dri.c
+DRIOBJS = i810_dri.o
+DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri
+DRIDEFINES = $(GLX_DEFINES)
+#endif
+
+SRCS = i810_driver.c i810_cursor.c i810_accel.c i810_io.c \
+ i810_memory.c i810_wmark.c $(DRISRCS)
-OBJS = i810_driver.o i810_cursor.o i810_accel.o i810_io.o i810_memory.o i810_wmark.o
+OBJS = i810_driver.o i810_cursor.o i810_accel.o i810_io.o \
+ i810_memory.o i810_wmark.o $(DRIOBJS)
#if defined(XF86DriverSDK)
INCLUDES = -I. -I../../include
#else
-INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
- -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
- -I$(XF86SRC)/xaa -I$(XF86SRC)/rac \
- -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa -I$(XF86SRC)/ramdac \
- -I$(XF86SRC)/vgahw -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \
- -I$(SERVERSRC)/Xext \
- -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
- -I$(EXTINCSRC)
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
+ -I$(XF86SRC)/xaa -I$(XF86SRC)/rac \
+ -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa -I$(XF86SRC)/ramdac \
+ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \
+ -I$(SERVERSRC)/Xext \
+ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(EXTINCSRC) \
+ -Ios-support $(DRIINCLUDES)
#endif
+DEFINES = $(DRIDEFINES)
#if MakeHasPosixVariableSubstitutions
SubdirLibraryRule($(OBJS))
@@ -44,6 +58,9 @@ InstallDriverSDKNonExecFile(i810.h,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_accel.c,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_cursor.c,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_driver.c,$(DRIVERSDKDIR)/drivers/i810)
+InstallDriverSDKNonExecFile(i810_dri.c,$(DRIVERSDKDIR)/drivers/i810)
+InstallDriverSDKNonExecFile(i810_dri.h,$(DRIVERSDKDIR)/drivers/i810)
+InstallDriverSDKNonExecFile(i810_dripriv.h,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_io.c,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_memory.c,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_wmark.c,$(DRIVERSDKDIR)/drivers/i810)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h
index 8d56b77a1..b28cf4634 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h
@@ -45,6 +45,19 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xaa.h"
#include "xf86Cursor.h"
+
+#ifdef XF86DRI
+#include "xf86drm.h"
+#include "sarea.h"
+#define _XF86DRI_SERVER_
+#include "xf86dri.h"
+#include "dri.h"
+#include "GL/glxint.h"
+#include "i810_dri.h"
+#include "i810_dripriv.h"
+#endif
+
+
/* Globals */
typedef struct _I810Rec *I810Ptr;
@@ -55,6 +68,12 @@ typedef char (*I810ReadIndexedByteFunc)(I810Ptr pI810, int addr, char index);
typedef void (*I810WriteByteFunc)(I810Ptr pI810, int addr, char value);
typedef char (*I810ReadByteFunc)(I810Ptr pI810, int addr);
+
+#ifdef XF86DRI
+extern void FillPrivateDRI(I810Ptr pI810, I810DRIPtr pI810DRI);
+#endif
+
+
/* Linear region allocated in framebuffer.
*/
typedef struct {
@@ -117,6 +136,11 @@ typedef struct _I810Rec {
int cpp;
int MaxClock;
+ I810MemRange FrontBuffer;
+ I810MemRange BackBuffer;
+ I810MemRange DepthBuffer;
+ I810MemRange TexMem;
+
I810MemRange Cursor;
int CursorPhysical;
int CursorOffset;
@@ -137,6 +161,9 @@ typedef struct _I810Rec {
I810MemRange DcacheMem;
I810MemRange SysMem;
+ I810MemRange SavedDcacheMem;
+ I810MemRange SavedSysMem;
+
unsigned char **ScanlineColorExpandBuffers;
int NumScanlineColorExpandBuffers;
int nextColorExpandBuf;
@@ -152,8 +179,44 @@ typedef struct _I810Rec {
I810ReadIndexedByteFunc readControl;
I810WriteByteFunc writeStandard;
I810ReadByteFunc readStandard;
+
+#ifdef XF86DRI
+ Bool directRenderingEnabled;
+ DRIInfoPtr pDRIInfo;
+ int drmSubFD;
+ int numVisualConfigs;
+ __GLXvisualConfig* pVisualConfigs;
+ I810ConfigPrivPtr pVisualConfigsPriv;
+/* TDFXRegRec DRContextRegs; */
+#endif
+
+
} I810Rec;
+typedef struct {
+/* PROPSAREADATA; */
+ int fifoOwner;
+ int CtxOwner;
+ int TexOwner;
+} I810SAREAPriv;
+
+#define I810PTR(p) ((I810Ptr)((p)->driverPrivate))
+
+#define DRAW_STATE_CLIPPING 0x1
+#define DRAW_STATE_TRANSPARENT 0x2
+#define DRAW_STATE_CLIP1CHANGED 0x4
+
+#define I810_FRONT 0
+#define I810_BACK 1
+#define I810_DEPTH 2
+
+#define I8102XCUTOFF 135000
+
+
+extern Bool I810DRIScreenInit(ScreenPtr pScreen);
+extern void I810DRICloseScreen(ScreenPtr pScreen);
+extern Bool I810DRIFinishScreenInit(ScreenPtr pScreen);
+
#define I810PTR(p) ((I810Ptr)((p)->driverPrivate))
#define I810REGPTR(p) (&(I810PTR(p)->ModeReg))
@@ -170,11 +233,32 @@ extern int I810WaitLpRing( ScrnInfoPtr pScrn, int n, int timeout_usec );
extern void I810Sync( ScrnInfoPtr pScrn );
extern unsigned long I810LocalToPhysical( ScrnInfoPtr pScrn,
unsigned long local );
-extern int I810AllocAligned(ScreenPtr pScreen, I810MemRange *mem,
- int size, int alignment );
+extern int I810AllocLow( I810MemRange *result, I810MemRange *pool, int size );
+extern int I810AllocHigh( I810MemRange *result, I810MemRange *pool, int size );
extern void I810SetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
+
+
+/* These accel funcs are additionally used in the DRI code - I'm not
+ * sure if I really want to do it this way, or if it's actually
+ * appropriate...
+ */
+extern void I810SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir,
+ int ydir, int rop,
+ unsigned int planemask,
+ int trans_color);
+extern void I810SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int srcX,
+ int srcY, int dstX, int dstY,
+ int w, int h);
+extern void I810SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
+ unsigned int planemask);
+extern void I810SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y,
+ int w, int h);
+
+
+
+
#define minb(p) *(volatile CARD8 *)(pI810->MMIOBase + (p))
#define moutb(p,v) *(volatile CARD8 *)(pI810->MMIOBase + (p)) = (v)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c
index ab548794d..08132e2b2 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c
@@ -83,21 +83,6 @@ static unsigned int i810PatternRop[16] = {
0xFF /* GXset */
};
-static void I810SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
- unsigned int planemask);
-static void I810SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y,
- int w, int h);
-
-static void I810SetupForScreenToScreenCopy(ScrnInfoPtr pScrn,
- int xdir, int ydir, int rop,
- unsigned int planemask,
- int transparency_color);
-
-static void I810SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn,
- int x1, int y1,
- int x2, int y2,
- int w, int h);
-
static void I810SetupForMono8x8PatternFill(ScrnInfoPtr pScrn,
int pattx, int patty,
int fg, int bg, int rop,
@@ -192,9 +177,10 @@ I810AccelInit( ScreenPtr pScreen )
*/
/* Scanline color expansion - Use the same scheme as the 3.3 driver.
+ *
*/
- if ( I810AllocAligned( pScreen, &scratch, 64*1024, 8 ) ||
- I810AllocAligned( pScreen, &scratch, 16*1024, 8 ) )
+ if ( I810AllocLow( &scratch, &(pI810->SysMem), 64*1024 ) ||
+ I810AllocLow( &scratch, &(pI810->SysMem), 16*1024 ) )
{
int i;
int width = ((pScrn->displayWidth + 31) & ~31) / 8;
@@ -319,7 +305,7 @@ I810Sync( ScrnInfoPtr pScrn )
}
-static void
+void
I810SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
unsigned int planemask)
{
@@ -337,7 +323,7 @@ I810SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
}
-static void
+void
I810SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h)
{
I810Ptr pI810 = I810PTR(pScrn);
@@ -361,7 +347,7 @@ I810SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h)
}
}
-static void
+void
I810SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop,
unsigned int planemask, int transparency_color)
{
@@ -383,7 +369,7 @@ I810SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop,
pI810->BR[18] = 0;
}
-static void
+void
I810SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1,
int x2, int y2, int w, int h)
{
@@ -576,3 +562,13 @@ I810SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno)
I810GetNextScanlineColorExpandBuffer( pScrn );
}
+
+/* Not really needed for anything:
+ */
+void
+I810SelectBuffer(I810Ptr pI810, int which)
+{
+ if (1)
+ fprintf(stderr, "I810SelectBuffer %d\n", which);
+}
+
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_cursor.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_cursor.c
index 4d7175e87..d5001e6a0 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_cursor.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_cursor.c
@@ -49,6 +49,8 @@ static void I810HideCursor(ScrnInfoPtr pScrn);
static void I810SetCursorColors(ScrnInfoPtr pScrn, int bg, int fb);
static Bool I810UseHWCursor(ScreenPtr pScrn, CursorPtr pCurs);
+
+
Bool
I810CursorInit(ScreenPtr pScreen)
{
@@ -77,7 +79,9 @@ I810CursorInit(ScreenPtr pScreen)
infoPtr->ShowCursor = I810ShowCursor;
infoPtr->UseHWCursor = I810UseHWCursor;
- if (!I810AllocAligned( pScreen, &(pI810->Cursor), 1024, 4096 ) )
+ /* Alloc memory after the frame buffer and pixcache.
+ */
+ if (!I810AllocLow( &(pI810->Cursor), &(pI810->SysMem), 4096 ) )
return FALSE;
pI810->CursorPhysical = I810LocalToPhysical( pScrn, pI810->Cursor.Start );
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c
new file mode 100644
index 000000000..c015fb0e8
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c
@@ -0,0 +1,550 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c,v 1.3 1999/09/27 06:29:57 dawes Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Priv.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb16.h"
+#include "cfb32.h"
+
+#include "miline.h"
+
+#include "GL/glxtokens.h"
+
+#include "i810.h"
+#include "i810_dri.h"
+#include "i810_dripriv.h"
+
+static char I810KernelDriverName[] = "i810";
+static char I810ClientDriverName[] = "i810";
+
+static Bool I810InitVisualConfigs(ScreenPtr pScreen);
+static Bool I810CreateContext(ScreenPtr pScreen, VisualPtr visual,
+ drmContext hwContext, void *pVisualConfigPriv,
+ DRIContextType contextStore);
+static void I810DestroyContext(ScreenPtr pScreen, drmContext hwContext,
+ DRIContextType contextStore);
+static void I810DRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
+ DRIContextType readContextType,
+ void *readContextStore,
+ DRIContextType writeContextType,
+ void *writeContextStore);
+static void I810DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index);
+static void I810DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc, CARD32 index);
+
+static Bool
+I810InitVisualConfigs(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I810Ptr pI810 = I810PTR(pScrn);
+ int numConfigs = 0;
+ __GLXvisualConfig *pConfigs = 0;
+ I810ConfigPrivPtr pI810Configs = 0;
+ I810ConfigPrivPtr *pI810ConfigPtrs = 0;
+ int i;
+
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ case 24:
+ case 32:
+ break;
+ case 16:
+ numConfigs = 4;
+
+ if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig),
+ numConfigs))) {
+ return FALSE;
+ }
+
+ if (!(pI810Configs =
+ (I810ConfigPrivPtr)xnfcalloc(sizeof(I810ConfigPrivRec),
+ numConfigs)))
+ {
+ xfree(pConfigs);
+ return FALSE;
+ }
+
+ if (!(pI810ConfigPtrs =
+ (I810ConfigPrivPtr*)xnfcalloc(sizeof(I810ConfigPrivPtr),
+ numConfigs)))
+ {
+ xfree(pConfigs);
+ xfree(pI810Configs);
+ return FALSE;
+ }
+
+ for (i=0; i<numConfigs; i++)
+ pI810ConfigPtrs[i] = &pI810Configs[i];
+
+ /* config 0: db=FALSE, depth=0
+ config 1: db=FALSE, depth=16
+ config 2: db=TRUE, depth=0;
+ config 3: db=TRUE, depth=16
+ */
+ pConfigs[0].vid = -1;
+ pConfigs[0].class = -1;
+ pConfigs[0].rgba = TRUE;
+ pConfigs[0].redSize = 8;
+ pConfigs[0].greenSize = 8;
+ pConfigs[0].blueSize = 8;
+ pConfigs[0].redMask = 0x00FF0000;
+ pConfigs[0].greenMask = 0x0000FF00;
+ pConfigs[0].blueMask = 0x000000FF;
+ pConfigs[0].alphaMask = 0;
+ pConfigs[0].accumRedSize = 0;
+ pConfigs[0].accumGreenSize = 0;
+ pConfigs[0].accumBlueSize = 0;
+ pConfigs[0].accumAlphaSize = 0;
+ pConfigs[0].doubleBuffer = FALSE;
+ pConfigs[0].stereo = FALSE;
+ pConfigs[0].bufferSize = 16;
+ pConfigs[0].depthSize = 0;
+ pConfigs[0].stencilSize = 0;
+ pConfigs[0].auxBuffers = 0;
+ pConfigs[0].level = 0;
+ pConfigs[0].visualRating = 0;
+ pConfigs[0].transparentPixel = 0;
+ pConfigs[0].transparentRed = 0;
+ pConfigs[0].transparentGreen = 0;
+ pConfigs[0].transparentBlue = 0;
+ pConfigs[0].transparentAlpha = 0;
+ pConfigs[0].transparentIndex = 0;
+
+ pConfigs[1].vid = -1;
+ pConfigs[1].class = -1;
+ pConfigs[1].rgba = TRUE;
+ pConfigs[1].redSize = 8;
+ pConfigs[1].greenSize = 8;
+ pConfigs[1].blueSize = 8;
+ pConfigs[1].redMask = 0x00FF0000;
+ pConfigs[1].greenMask = 0x0000FF00;
+ pConfigs[1].blueMask = 0x000000FF;
+ pConfigs[1].alphaMask = 0;
+ pConfigs[1].accumRedSize = 0;
+ pConfigs[1].accumGreenSize = 0;
+ pConfigs[1].accumBlueSize = 0;
+ pConfigs[1].accumAlphaSize = 0;
+ pConfigs[1].doubleBuffer = FALSE;
+ pConfigs[1].stereo = FALSE;
+ pConfigs[1].bufferSize = 16;
+ pConfigs[1].depthSize = 16;
+ pConfigs[1].stencilSize = 0;
+ pConfigs[1].auxBuffers = 0;
+ pConfigs[1].level = 0;
+ pConfigs[1].visualRating = 0;
+ pConfigs[1].transparentPixel = 0;
+ pConfigs[1].transparentRed = 0;
+ pConfigs[1].transparentGreen = 0;
+ pConfigs[1].transparentBlue = 0;
+ pConfigs[1].transparentAlpha = 0;
+ pConfigs[1].transparentIndex = 0;
+
+ pConfigs[2].vid = -1;
+ pConfigs[2].class = -1;
+ pConfigs[2].rgba = TRUE;
+ pConfigs[2].redSize = 8;
+ pConfigs[2].greenSize = 8;
+ pConfigs[2].blueSize = 8;
+ pConfigs[2].redMask = 0x00FF0000;
+ pConfigs[2].greenMask = 0x0000FF00;
+ pConfigs[2].blueMask = 0x000000FF;
+ pConfigs[2].alphaMask = 0;
+ pConfigs[2].accumRedSize = 0;
+ pConfigs[2].accumGreenSize = 0;
+ pConfigs[2].accumBlueSize = 0;
+ pConfigs[2].accumAlphaSize = 0;
+ pConfigs[2].doubleBuffer = TRUE;
+ pConfigs[2].stereo = FALSE;
+ pConfigs[2].bufferSize = 16;
+ pConfigs[2].depthSize = 0;
+ pConfigs[2].stencilSize = 0;
+ pConfigs[2].auxBuffers = 0;
+ pConfigs[2].level = 0;
+ pConfigs[2].visualRating = 0;
+ pConfigs[2].transparentPixel = 0;
+ pConfigs[2].transparentRed = 0;
+ pConfigs[2].transparentGreen = 0;
+ pConfigs[2].transparentBlue = 0;
+ pConfigs[2].transparentAlpha = 0;
+ pConfigs[2].transparentIndex = 0;
+
+ pConfigs[3].vid = -1;
+ pConfigs[3].class = -1;
+ pConfigs[3].rgba = TRUE;
+ pConfigs[3].redSize = 8;
+ pConfigs[3].greenSize = 8;
+ pConfigs[3].blueSize = 8;
+ pConfigs[3].redMask = 0x00FF0000;
+ pConfigs[3].greenMask = 0x0000FF00;
+ pConfigs[3].blueMask = 0x000000FF;
+ pConfigs[3].alphaMask = 0;
+ pConfigs[3].accumRedSize = 0;
+ pConfigs[3].accumGreenSize = 0;
+ pConfigs[3].accumBlueSize = 0;
+ pConfigs[3].accumAlphaSize = 0;
+ pConfigs[3].doubleBuffer = TRUE;
+ pConfigs[3].stereo = FALSE;
+ pConfigs[3].bufferSize = 16;
+ pConfigs[3].depthSize = 16;
+ pConfigs[3].stencilSize = 0;
+ pConfigs[3].auxBuffers = 0;
+ pConfigs[3].level = 0;
+ pConfigs[3].visualRating = 0;
+ pConfigs[3].transparentPixel = 0;
+ pConfigs[3].transparentRed = 0;
+ pConfigs[3].transparentGreen = 0;
+ pConfigs[3].transparentBlue = 0;
+ pConfigs[3].transparentAlpha = 0;
+ pConfigs[3].transparentIndex = 0;
+ break;
+ }
+ pI810->numVisualConfigs = numConfigs;
+ pI810->pVisualConfigs = pConfigs;
+ pI810->pVisualConfigsPriv = pI810Configs;
+ GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pI810ConfigPtrs);
+ return TRUE;
+}
+
+Bool I810DRIScreenInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I810Ptr pI810 = I810PTR(pScrn);
+ DRIInfoPtr pDRIInfo;
+ I810DRIPtr pI810DRI;
+
+ pDRIInfo = DRICreateInfoRec();
+ if (!pDRIInfo) return FALSE;
+ pI810->pDRIInfo = pDRIInfo;
+
+ pDRIInfo->drmDriverName = I810KernelDriverName;
+ pDRIInfo->clientDriverName = I810ClientDriverName;
+ pDRIInfo->busIdString = xalloc(64);
+ sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d",
+ ((pciConfigPtr)pI810->PciInfo->thisCard)->busnum,
+ ((pciConfigPtr)pI810->PciInfo->thisCard)->devnum,
+ ((pciConfigPtr)pI810->PciInfo->thisCard)->funcnum);
+ pDRIInfo->ddxDriverMajorVersion = 0;
+ pDRIInfo->ddxDriverMinorVersion = 1;
+ pDRIInfo->ddxDriverPatchVersion = 0;
+ pDRIInfo->frameBufferPhysicalAddress = pI810->LinearAddr;
+ pDRIInfo->frameBufferSize = pI810->FbMapSize;
+ pDRIInfo->frameBufferStride = pScrn->displayWidth*pI810->cpp;
+ pDRIInfo->ddxDrawableTableEntry = I810_MAX_DRAWABLES;
+
+ if (SAREA_MAX_DRAWABLES < I810_MAX_DRAWABLES)
+ pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES;
+ else
+ pDRIInfo->maxDrawableTableEntry = I810_MAX_DRAWABLES;
+
+#ifdef NOT_DONE
+ /* FIXME need to extend DRI protocol to pass this size back to client
+ * for SAREA mapping that includes a device private record
+ */
+ pDRIInfo->SAREASize =
+ ((sizeof(XF86DRISAREARec) + 0xfff) & 0x1000); /* round to page */
+ /* + shared memory device private rec */
+#else
+ /* For now the mapping works by using a fixed size defined
+ * in the SAREA header
+ */
+ if (sizeof(XF86DRISAREARec)+sizeof(I810SAREAPriv)>SAREA_MAX) {
+ ErrorF("Data does not fit in SAREA\n");
+ return FALSE;
+ }
+ pDRIInfo->SAREASize = SAREA_MAX;
+#endif
+
+ if (!(pI810DRI = (I810DRIPtr)xnfcalloc(sizeof(I810DRIRec),1))) {
+ DRIDestroyInfoRec(pI810->pDRIInfo);
+ pI810->pDRIInfo=0;
+ return FALSE;
+ }
+ pDRIInfo->devPrivate = pI810DRI;
+ pDRIInfo->devPrivateSize = sizeof(I810DRIRec);
+ pDRIInfo->contextSize = sizeof(I810DRIContextRec);
+
+ pDRIInfo->CreateContext = I810CreateContext;
+ pDRIInfo->DestroyContext = I810DestroyContext;
+ pDRIInfo->SwapContext = I810DRISwapContext;
+ pDRIInfo->InitBuffers = I810DRIInitBuffers;
+ pDRIInfo->MoveBuffers = I810DRIMoveBuffers;
+ pDRIInfo->bufferRequests = DRI_ALL_WINDOWS;
+
+ if (!DRIScreenInit(pScreen, pDRIInfo, &pI810->drmSubFD)) {
+ xfree(pDRIInfo->devPrivate);
+ pDRIInfo->devPrivate=0;
+ DRIDestroyInfoRec(pI810->pDRIInfo);
+ pI810->pDRIInfo=0;
+ return FALSE;
+ }
+
+ pI810DRI->regsSize=0x80000;
+ if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->MMIOAddr,
+ pI810DRI->regsSize, DRM_REGISTERS, 0, &pI810DRI->regs)<0) {
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Registers = 0x%08lx\n",
+ pI810DRI->regs);
+
+ if (!(I810InitVisualConfigs(pScreen))) {
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "visual configs initialized\n" );
+
+ return TRUE;
+}
+
+void
+I810DRICloseScreen(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I810Ptr pI810 = I810PTR(pScrn);
+
+ DRICloseScreen(pScreen);
+
+ if (pI810->pDRIInfo) {
+ if (pI810->pDRIInfo->devPrivate) {
+ xfree(pI810->pDRIInfo->devPrivate);
+ pI810->pDRIInfo->devPrivate=0;
+ }
+ DRIDestroyInfoRec(pI810->pDRIInfo);
+ pI810->pDRIInfo=0;
+ }
+ if (pI810->pVisualConfigs) xfree(pI810->pVisualConfigs);
+ if (pI810->pVisualConfigsPriv) xfree(pI810->pVisualConfigsPriv);
+}
+
+static Bool
+I810CreateContext(ScreenPtr pScreen, VisualPtr visual,
+ drmContext hwContext, void *pVisualConfigPriv,
+ DRIContextType contextStore)
+{
+ I810DRIContextPtr ctx;
+
+ ctx=(I810DRIContextPtr)contextStore;
+ return TRUE;
+}
+
+static void
+I810DestroyContext(ScreenPtr pScreen, drmContext hwContext,
+ DRIContextType contextStore)
+{
+ I810DRIContextPtr ctx;
+ ctx=(I810DRIContextPtr)contextStore;
+}
+
+Bool
+I810DRIFinishScreenInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I810Ptr pI810 = I810PTR(pScrn);
+ I810DRIPtr pI810DRI;
+
+ pI810->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT;
+ /* pI810->pDRIInfo->driverSwapMethod = DRI_SERVER_SWAP; */
+
+ pI810DRI=(I810DRIPtr)pI810->pDRIInfo->devPrivate;
+ pI810DRI->deviceID=pI810->PciInfo->chipType;
+ pI810DRI->width=pScrn->virtualX;
+ pI810DRI->height=pScrn->virtualY;
+ pI810DRI->mem=pScrn->videoRam*1024;
+ pI810DRI->cpp=pI810->cpp;
+ pI810DRI->stride=pI810->cpp*pScrn->displayWidth;
+ pI810DRI->textureOffset=pI810->TexMem.Start;
+ pI810DRI->textureSize=pI810->TexMem.Size;
+ pI810DRI->fbOffset=0;
+ pI810DRI->backOffset=pI810->BackBuffer.Start;
+ pI810DRI->depthOffset=pI810->DepthBuffer.Start;
+
+ return DRIFinishScreenInit(pScreen);
+}
+
+static void
+I810DRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
+ DRIContextType oldContextType, void *oldContext,
+ DRIContextType newContextType, void *newContext)
+{
+#if 0
+ if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) &&
+ (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */
+ I810SwapContextPrivate(pScreen);
+ }
+ if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) &&
+ (newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */
+ I810LostContext(pScreen);
+ }
+#endif
+}
+
+static void
+I810DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I810Ptr pI810 = I810PTR(pScrn);
+ BoxPtr pbox;
+ int nbox;
+
+ /* It looks nicer if these start out black */
+ pbox = REGION_RECTS(prgn);
+ nbox = REGION_NUM_RECTS(prgn);
+
+
+ /* This won't really work - probably need to emit the operations
+ * directly (as done in the Utah driver) instead of trying to reuse
+ * the XAA stuff.
+ */
+ I810SetupForSolidFill(pScrn, 0, GXcopy, -1);
+ while (nbox--) {
+/* I810SelectBuffer(pI810, I810_BACK); */
+ I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
+ pbox->x2-pbox->x1, pbox->y2-pbox->y1);
+/* I810SelectBuffer(pI810, I810_DEPTH); */
+ I810SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
+ pbox->x2-pbox->x1, pbox->y2-pbox->y1);
+ pbox++;
+ }
+/* I810SelectBuffer(pI810, I810_FRONT); */
+
+ pI810->AccelInfoRec->NeedToSync = TRUE;
+}
+
+/*
+ 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
+I810DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc, CARD32 index)
+{
+ ScreenPtr pScreen = pParent->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I810Ptr pI810 = I810PTR(pScrn);
+ int nbox;
+ BoxPtr pbox, pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
+ DDXPointPtr pptTmp, pptNew1, pptNew2;
+ int xdir, ydir;
+ int dx, dy, w, h;
+ DDXPointPtr pptSrc;
+
+ pbox = REGION_RECTS(prgnSrc);
+ nbox = REGION_NUM_RECTS(prgnSrc);
+ pboxNew1 = 0;
+ pptNew1 = 0;
+ pboxNew2 = 0;
+ pboxNew2 = 0;
+ pptSrc = &ptOldOrg;
+
+ dx = pParent->drawable.x - ptOldOrg.x;
+ dy = pParent->drawable.y - ptOldOrg.y;
+
+ /* 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)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
+ if (!pboxNew1) return;
+ pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
+ if (!pptNew1) {
+ DEALLOCATE_LOCAL(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)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
+ pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
+ if (!pboxNew2 || !pptNew2) {
+ if (pptNew2) DEALLOCATE_LOCAL(pptNew2);
+ if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2);
+ if (pboxNew1) {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(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;
+ }
+
+ I810SetupForScreenToScreenCopy(pScrn, xdir, ydir, GXcopy, -1, -1);
+ while (nbox--) {
+ w=pbox->x2-pbox->x1+1;
+ h=pbox->y2-pbox->y1+1;
+/* I810SelectBuffer(pI810, I810_BACK); */
+ I810SubsequentScreenToScreenCopy(pScrn, pbox->x1, pbox->y1,
+ pbox->x1+dx, pbox->y1+dy, w, h);
+/* I810SelectBuffer(pI810, I810_DEPTH); */
+ I810SubsequentScreenToScreenCopy(pScrn, pbox->x1, pbox->y1,
+ pbox->x1+dx, pbox->y1+dy, w, h);
+ pbox++;
+ }
+/* I810SelectBuffer(pI810, I810_FRONT); */
+
+ if (pboxNew2) {
+ DEALLOCATE_LOCAL(pptNew2);
+ DEALLOCATE_LOCAL(pboxNew2);
+ }
+ if (pboxNew1) {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+
+ pI810->AccelInfoRec->NeedToSync = TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h
new file mode 100644
index 000000000..209902eef
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h
@@ -0,0 +1,27 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h,v 1.1 1999/08/29 12:21:03 dawes Exp $ */
+
+#ifndef _I810_DRI_
+#define _I810_DRI_
+
+#include <xf86drm.h>
+
+typedef struct {
+ drmHandle regs;
+ drmSize regsSize;
+ drmAddress regsMap;
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+ int cpp;
+ int stride;
+ int priv1;
+ int priv2;
+ int fbOffset;
+ int backOffset;
+ int depthOffset;
+ int textureOffset;
+ int textureSize;
+} I810DRIRec, *I810DRIPtr;
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dripriv.h b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dripriv.h
new file mode 100644
index 000000000..a56fecc97
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dripriv.h
@@ -0,0 +1,24 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dripriv.h,v 1.1 1999/08/29 12:21:03 dawes Exp $ */
+
+#ifndef _I810_DRIPRIV_H_
+#define _I810_DRIPRIV_H_
+
+#define I810_MAX_DRAWABLES 256
+
+extern void GlxSetVisualConfigs(
+ int nconfigs,
+ __GLXvisualConfig *configs,
+ void **configprivs
+);
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} I810ConfigPrivRec, *I810ConfigPrivPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} I810DRIContextRec, *I810DRIContextPtr;
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c
index 72ede52fc..34289452c 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c
@@ -51,48 +51,29 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xf86Resources.h"
#include "xf86RAC.h"
#include "xf86cmap.h"
-
-/* If the driver uses port I/O directly, it needs: */
-
#include "compiler.h"
-
-/* Drivers using the mi implementation of backing store need: */
-
#include "mibstore.h"
-
-/* All drivers using the vgahw module need this */
-/* This driver needs to be modified to not use vgaHW for multihead operation */
#include "vgaHW.h"
-
-/* Drivers using the mi SW cursor need: */
-
#include "mipointer.h"
-
-/* Drivers using the mi colourmap code need: */
-
#include "micmap.h"
-/* Drivers using cfb need: */
#define PSZ 8
#include "cfb.h"
#undef PSZ
-/* Drivers supporting bpp 16, 24 or 32 with cfb need one or more of: */
-
#include "cfb16.h"
#include "cfb24.h"
#include "cfb32.h"
-
-/* The driver's own header file: */
-
#include "i810.h"
-
#include "miscstruct.h"
-
#include "xf86xv.h"
#include "Xv.h"
+#ifdef XF86DRI
+#include "dri.h"
+#endif
+
/* Required Functions: */
static void I810Identify(int flags);
@@ -110,9 +91,9 @@ static int I810ValidMode(int scrnIndex, DisplayModePtr mode, Bool
verbose, int flags);
#ifdef DPMSExtension
-/* Switch to various Display Power Management System levels */
static void I810DisplayPowerManagementSet(ScrnInfoPtr pScrn,
- int PowerManagermentMode, int flags);
+ int PowerManagermentMode,
+ int flags);
#endif
#define VERSION 4000
@@ -170,8 +151,8 @@ static OptionInfoRec I810Options[] = {
static const char *vgahwSymbols[] = {
"vgaHWGetHWRec",
- "vgaHWSave", /* Added */
- "vgaHWRestore", /* Added */
+ "vgaHWSave",
+ "vgaHWRestore",
"vgaHWProtect",
"vgaHWInit",
"vgaHWMapMem",
@@ -185,7 +166,6 @@ static const char *vgahwSymbols[] = {
0
};
-#if 0
static const char *cfbSymbols[] = {
"cfbScreenInit",
"cfb16ScreenInit",
@@ -211,7 +191,6 @@ static const char *xaaSymbols[] = {
"XAAScreenIndex",
NULL
};
-#endif
static const char *ramdacSymbols[] = {
"xf86InitCursor",
@@ -221,10 +200,43 @@ static const char *ramdacSymbols[] = {
};
+#ifdef XF86DRI
+static const char *drmSymbols[] = {
+ "drmAddBufs",
+ "drmAddMap",
+ "drmAvailable",
+ "drmCtlAddCommand",
+ "drmCtlInstHandler",
+ "drmGetInterruptFromBusID",
+ "drmMapBufs",
+ "drmMarkBufs",
+ "drmUnmapBufs",
+ NULL
+};
+
+static const char *driSymbols[] = {
+ "DRIGetDrawableIndex",
+ "DRIFinishScreenInit",
+ "DRIDestroyInfoRec",
+ "DRICloseScreen",
+ "DRIDestroyInfoRec",
+ "DRIScreenInit",
+ "DRIDestroyInfoRec",
+ "DRICreateInfoRec",
+ "DRILock",
+ "DRIUnlock",
+ "DRIGetSAREAPrivate",
+ "DRIGetContext",
+ "GlxSetVisualConfigs",
+ NULL
+};
+#endif
+
+
#ifndef I810_DEBUG
int I810_DEBUG = (0
/* | DEBUG_ALWAYS_SYNC */
- | DEBUG_VERBOSE_ACCEL
+/* | DEBUG_VERBOSE_ACCEL */
/* | DEBUG_VERBOSE_SYNC */
/* | DEBUG_VERBOSE_VGA */
/* | DEBUG_VERBOSE_RING */
@@ -261,25 +273,30 @@ i810Setup(pointer module, pointer opts, int *errmaj, int *errmin)
{
static Bool setupDone = FALSE;
- /* This module should be loaded only once, but check to be sure. */
-
+ /* This module should be loaded only once, but check to be sure.
+ */
if (!setupDone) {
setupDone = TRUE;
xf86AddDriver(&I810, module, 0);
/*
- * Modules that this driver always requires may be loaded here
- * by calling LoadSubModule().
- */
-
- /*
* Tell the loader about symbols from other modules that this module
* might refer to.
*/
- LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols,
- xf8_32bppSymbols, ramdacSymbols,
- 0 /* ddcsymbols */, 0 /* i2csymbols */, 0 /* shadowSymbols */,
- 0 /* fbdevsymbols */, NULL);
+ LoaderRefSymLists(vgahwSymbols,
+ cfbSymbols,
+ xaaSymbols,
+ xf8_32bppSymbols,
+ ramdacSymbols,
+#ifdef XF86DRI
+ drmSymbols,
+ driSymbols,
+#endif
+ 0 /* ddcsymbols */,
+ 0 /* i2csymbols */,
+ 0 /* shadowSymbols */,
+ 0 /* fbdevsymbols */,
+ NULL);
/*
* The return value must be non-NULL on success even though there
@@ -357,7 +374,7 @@ I810Probe(DriverPtr drv, int flags) {
*/
if (!xf86GetPciVideoInfo()) return FALSE;
- /* Look for Intel based chips */
+ /* Look for i810 devices */
numUsed = xf86MatchPciInstances(I810_NAME, PCI_VENDOR_INTEL,
I810Chipsets, I810PciChipsets,
devSections, numDevSections,
@@ -386,7 +403,8 @@ I810Probe(DriverPtr drv, int flags) {
pScrn->ValidMode = I810ValidMode;
foundScreen = TRUE;
- xf86ConfigActivePciEntity(pScrn, usedChips[i], I810PciChipsets, 0, 0, 0, 0, 0);
+ xf86ConfigActivePciEntity(pScrn, usedChips[i], I810PciChipsets,
+ 0, 0, 0, 0, 0);
}
xfree(pEnt);
}
@@ -518,20 +536,23 @@ I810PreInit(ScrnInfoPtr pScrn, int flags) {
pScrn->chipset = pI810->pEnt->device->chipset;
from = X_CONFIG;
} else if (pI810->pEnt->device->chipID >= 0) {
- pScrn->chipset = (char *)xf86TokenToString(I810Chipsets, pI810->pEnt->device->chipID);
+ pScrn->chipset = (char *)xf86TokenToString(I810Chipsets,
+ pI810->pEnt->device->chipID);
from = X_CONFIG;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n",
pI810->pEnt->device->chipID);
} else {
from = X_PROBED;
- pScrn->chipset = (char *)xf86TokenToString(I810Chipsets, pI810->PciInfo->chipType);
+ pScrn->chipset = (char *)xf86TokenToString(I810Chipsets,
+ pI810->PciInfo->chipType);
}
if (pI810->pEnt->device->chipRev >= 0) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n",
pI810->pEnt->device->chipRev);
}
- xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", (pScrn->chipset!=NULL)?pScrn->chipset:"Unknown i810");
+ xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n",
+ (pScrn->chipset!=NULL)?pScrn->chipset:"Unknown i810");
if (pI810->pEnt->device->MemBase != 0) {
pI810->LinearAddr = pI810->pEnt->device->MemBase;
@@ -599,7 +620,6 @@ I810PreInit(ScrnInfoPtr pScrn, int flags) {
* If the driver can do gamma correction, it should call xf86SetGamma()
* here.
*/
-
{
Gamma zeros = {0.0, 0.0, 0.0};
@@ -1345,7 +1365,17 @@ I810ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
if (!I810SetMode(pScrn, mode)) return FALSE;
+#ifdef XF86DRI
+ if (pI810->directRenderingEnabled) {
+ DRILock(screenInfo.screens[pScrn->scrnIndex]);
+/* I810SwapContextPrivate(screenInfo.screens[pScrn->scrnIndex]); */
+ }
+#endif
DoRestore(pScrn, &hwp->ModeReg, &pI810->ModeReg, FALSE);
+#ifdef XF86DRI
+ if (pI810->directRenderingEnabled)
+ DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
+#endif
return TRUE;
}
@@ -1435,6 +1465,17 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
pScrn->rgbBits, pScrn->defaultVisual))
return FALSE;
+#ifdef XF86DRI
+ /*
+ * Setup DRI after visuals have been established, but before cfbScreenInit
+ * is called. cfbScreenInit will eventually call into the drivers
+ * InitGLXVisuals call back.
+ */
+ pI810->directRenderingEnabled = I810DRIScreenInit(pScreen);
+ /* Force the initialization of the context */
+/* I180LostContext(pScreen); */
+#endif
+
switch (pScrn->bitsPerPixel) {
case 8:
if (!cfbScreenInit(pScreen, pI810->FbBase,
@@ -1496,11 +1537,13 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
if (pScrn->bitsPerPixel==16) {
if (!xf86HandleColormaps(pScreen, 256, 8, I810LoadPalette16, 0,
- CMAP_PALETTED_TRUECOLOR|CMAP_RELOAD_ON_MODE_SWITCH))
+ CMAP_PALETTED_TRUECOLOR|
+ CMAP_RELOAD_ON_MODE_SWITCH))
return FALSE;
} else {
if (!xf86HandleColormaps(pScreen, 256, 8, I810LoadPalette24, 0,
- CMAP_PALETTED_TRUECOLOR|CMAP_RELOAD_ON_MODE_SWITCH))
+ CMAP_PALETTED_TRUECOLOR|
+ CMAP_RELOAD_ON_MODE_SWITCH))
return FALSE;
}
@@ -1508,6 +1551,8 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
xf86DPMSInit(pScreen, I810DisplayPowerManagementSet, 0);
#endif
+
+
#ifdef XvExtension
{
XF86VideoAdaptorPtr *ptr;
@@ -1523,8 +1568,21 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
MemBox.x1=0;
MemBox.x2=pScrn->displayWidth;
MemBox.y1=0;
- MemBox.y2=pI810->FbMapSize/(pScrn->displayWidth*pI810->cpp);
+ MemBox.y2=pScrn->virtualY+128;
+ /* Reserve room for the framebuffer and pixcache, starting at zero
+ * - don't want to fuck around with moving it somewhere else in the
+ * mapping.
+ */
+ I810AllocLow( &(pI810->FrontBuffer),
+ &(pI810->SysMem),
+ ((MemBox.x2 * MemBox.y2 * pI810->cpp) + 4095) & ~4095);
+
+
+ if (pI810->FrontBuffer.Start != 0) {
+ FatalError("Didn't get first block for framebuffer: WTF???");
+ }
+
if (!xf86InitFBManager(pScreen, &MemBox)) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to init memory manager\n");
return FALSE;
@@ -1533,7 +1591,8 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
memset( &(pI810->LpRing), 0, sizeof( I810RingBuffer ) );
if (!xf86ReturnOptValBool(I810Options, OPTION_NOACCEL, FALSE)) {
- if (I810AllocAligned( pScreen, &(pI810->LpRing.mem), 4096, 4096 )) {
+ if (I810AllocLow( &(pI810->LpRing.mem), &(pI810->SysMem), 4096 )) {
+
if (I810_DEBUG & DEBUG_VERBOSE_MEMORY)
fprintf(stderr, "ring buffer at local %lx\n",
pI810->LpRing.mem.Start);
@@ -1561,6 +1620,44 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
}
}
+#ifdef XF86DRI
+
+ /* Preallocate a shared backbuffer and depth buffer. Use a fixed
+ * size pool of texture memory for now.
+ *
+ * TODO: place private back and depth buffers in these spaces until
+ * unable to do so, then switch to shared operation.
+ */
+ if (pI810->directRenderingEnabled) {
+ int size = ((MemBox.x2 * MemBox.y2 * pI810->cpp) + 4095) & ~4095;
+
+ if (I810AllocLow( &(pI810->BackBuffer), &(pI810->SysMem), size) &&
+ I810AllocLow( &(pI810->DepthBuffer), &(pI810->DcacheMem), size) )
+ {
+ I810AllocLow( &(pI810->TexMem), &(pI810->SysMem), pI810->SysMem.Size);
+ }
+ else
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Insufficient memory for back and/or depth buffers");
+ pI810->directRenderingEnabled = 0;
+ }
+ }
+
+ if (pI810->directRenderingEnabled) {
+ /* Now that mi, cfb, drm and others have done their thing,
+ * complete the DRI setup.
+ */
+ pI810->directRenderingEnabled = I810DRIFinishScreenInit(pScreen);
+ }
+
+ if (pI810->directRenderingEnabled) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: Enabled\n");
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: Disabled\n");
+ }
+#endif
+
pScreen->SaveScreen = I810SaveScreen;
pI810->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = I810CloseScreen;
@@ -1622,6 +1719,13 @@ I810AdjustFrame(int scrnIndex, int x, int y, int flags) {
static Bool
I810EnterVT(int scrnIndex, int flags) {
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+#ifdef XF86DRI
+ I810Ptr pI810 = I810PTR(pScrn);
+
+ if (pI810->directRenderingEnabled) {
+ DRIUnlock( screenInfo.screens[scrnIndex] );
+ }
+#endif
if (!I810ModeInit(pScrn, pScrn->currentMode)) return FALSE;
I810AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
@@ -1632,9 +1736,16 @@ static void
I810LeaveVT(int scrnIndex, int flags) {
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
vgaHWPtr hwp = VGAHWPTR(pScrn);
+#ifdef XF86DRI
+ I810Ptr pI810 = I810PTR(pScrn);
+#endif
I810Restore(pScrn);
vgaHWLock(hwp);
+#ifdef XF86DRI
+ if (pI810->directRenderingEnabled)
+ DRILock( screenInfo.screens[scrnIndex] );
+#endif
}
static Bool
@@ -1645,6 +1756,13 @@ I810CloseScreen(int scrnIndex, ScreenPtr pScreen)
I810Ptr pI810 = I810PTR(pScrn);
XAAInfoRecPtr infoPtr = pI810->AccelInfoRec;
+#ifdef XF86DRI
+ if (pI810->directRenderingEnabled) {
+ I810DRICloseScreen(pScreen);
+ pI810->directRenderingEnabled=FALSE;
+ }
+#endif
+
I810Restore(pScrn);
vgaHWLock(hwp);
I810UnmapMem(pScrn);
@@ -1667,6 +1785,11 @@ I810CloseScreen(int scrnIndex, ScreenPtr pScreen)
pI810->CursorInfoRec=0;
}
+ /* Free all allocated video ram.
+ */
+ pI810->SysMem = pI810->SavedSysMem;
+ pI810->DcacheMem = pI810->SavedDcacheMem;
+
pScrn->vtSema=FALSE;
pScreen->CloseScreen = pI810->CloseScreen;
return (*pScreen->CloseScreen)(scrnIndex, pScreen);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c
index bca48d1fd..7f1168d4a 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c
@@ -110,6 +110,9 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
pI810->SysMem.Start = 0;
pI810->SysMem.Size = pages * 4096;
pI810->SysMem.End = pages * 4096;
+
+ pI810->SavedSysMem = pI810->SysMem;
+
pScrn->videoRam = pages * 4;
return TRUE;
@@ -149,48 +152,28 @@ unsigned long I810LocalToPhysical( ScrnInfoPtr pScrn, unsigned long local )
return gart_pg_inf.physical + (local & 4095);
}
-/* Tortured process to get aligned, contiguous memory ranges out of
- * XF4.0's allocrator.
- */
-int I810AllocAligned( ScreenPtr pScreen, I810MemRange *mem,
- int size, int alignment )
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- I810Ptr pI810 = I810PTR(pScrn);
- int width = pScrn->displayWidth * pI810->cpp;
- int alloc_sz = size + alignment;
- unsigned int raw;
-
- if (alloc_sz < width)
- mem->Fbarea = xf86AllocateOffscreenArea(pScreen,
- alloc_sz,
- 1,
- 0,0,0,0);
- else
- mem->Fbarea = xf86AllocateOffscreenArea(pScreen,
- pScrn->displayWidth,
- alloc_sz/width+1,
- 0,0,0,0);
- if (mem->Fbarea == NULL)
- return 0;
-
- raw = mem->Start = ((mem->Fbarea->box.x1 +
- pScrn->displayWidth * mem->Fbarea->box.y1) *
- pI810->cpp);
- mem->Start = (mem->Start + (alignment-1)) & ~(alignment-1);
- mem->Size = size;
- mem->End = mem->Start + size;
-
-
- fprintf(stderr, "alloc aligned( 0x%x 0x%x ) --> 0x%lx (raw 0x%x)\n",
- size, alignment, mem->Start, raw );
-
- return mem->Start;
-}
+int I810AllocLow( I810MemRange *result, I810MemRange *pool, int size )
+{
+ if (size > pool->Size) return 0;
+ pool->Size -= size;
+ result->Size = size;
+ result->Start = pool->Start;
+ result->End = pool->Start += size;
+ return 1;
+}
+int I810AllocHigh( I810MemRange *result, I810MemRange *pool, int size )
+{
+ if (size > pool->Size) return 0;
+ pool->Size -= size;
+ result->Size = size;
+ result->End = pool->End;
+ result->Start = pool->End -= size;
+ return 1;
+}