summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw
diff options
context:
space:
mode:
Diffstat (limited to 'xc/programs/Xserver/hw')
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h27
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c43
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c464
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h50
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h5
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c71
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h70
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h69
8 files changed, 622 insertions, 177 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h
index 92e55c85b..71771f42f 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h
@@ -219,14 +219,30 @@ typedef struct {
drmHandle agpHandle; /* Handle from drmAddMap */
unsigned char *AGP; /* Map */
- int CCEMode;
- int CCEFifoSize;
+ Bool CCEInUse; /* CCE is currently active */
+ int CCEMode; /* CCE mode that server/clients use */
+ int CCEFifoSize; /* Size of the CCE command FIFO */
+ /* CCE ring buffer data */
unsigned long ringStart;
int ringSize;
int ringWrite;
unsigned long ringReadOffset;
+ /* CCE vertex buffer data */
+ unsigned long vbStart;
+ int vbSize;
+
+ /* CCE indirect buffer data */
+ unsigned long indStart;
+ int indSize;
+
+ /* CCE AGP Texture data */
+ unsigned long agpTexStart;
+ int agpTexSize;
+ int log2AGPTexGran;
+
+ /* DRI screen private data */
int fbX;
int fbY;
int backX;
@@ -236,6 +252,7 @@ typedef struct {
int textureX;
int textureY;
int textureSize;
+ int log2TexGran;
#endif
} R128InfoRec, *R128InfoPtr;
@@ -256,13 +273,15 @@ extern void R128WaitForVerticalSync(ScrnInfoPtr pScrn);
extern Bool R128AccelInit(ScreenPtr pScreen);
extern Bool R128CursorInit(ScreenPtr pScreen);
+extern int R128MinBits(int val);
+
#ifdef XF86DRI
extern Bool R128DRIScreenInit(ScreenPtr pScreen);
extern void R128DRICloseScreen(ScreenPtr pScreen);
extern Bool R128DRIFinishScreenInit(ScreenPtr pScreen);
extern void R128DRICCEInitRingBuffer(ScrnInfoPtr pScrn);
-extern void R128LostContext(ScreenPtr pScreen);
-extern void R128SwapContextPrivate(ScreenPtr pScreen);
+extern void R128CCEStart(ScrnInfoPtr pScrn);
+extern void R128CCEStop(ScrnInfoPtr pScrn);
#endif
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c
index 36a2a1092..4db9ba44e 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c
@@ -969,16 +969,20 @@ static void R128EngineInit(ScrnInfoPtr pScrn)
R128WaitForIdle(pScrn);
}
-/* Initialize XAA for supported acceleration and also initialize the
- graphics hardware for acceleration. */
-Bool R128AccelInit(ScreenPtr pScreen)
+#if 0
+#ifdef XF86DRI
+ /* FIXME: When direct rendering is enabled, we should use the CCE to
+ draw 2D commands */
+static void R128CCEAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- R128InfoPtr info = R128PTR(pScrn);
- XAAInfoRecPtr a;
+}
+#endif
+#endif
+
+static void R128MMIOAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a)
+{
+ R128InfoPtr info = R128PTR(pScrn);
- if (!(a = info->accel = XAACreateInfoRec())) return FALSE;
-
a->Flags = (PIXMAP_CACHE
| OFFSCREEN_PIXMAPS
| LINEAR_FRAMEBUFFER);
@@ -1061,12 +1065,29 @@ Bool R128AccelInit(ScreenPtr pScreen)
| SCANLINE_PAD_DWORD
| SYNC_AFTER_IMAGE_WRITE);
#endif
-
- R128EngineInit(pScrn);
+}
+
+/* Initialize XAA for supported acceleration and also initialize the
+ graphics hardware for acceleration. */
+Bool R128AccelInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr info = R128PTR(pScrn);
+ XAAInfoRecPtr a;
+ if (!(a = info->accel = XAACreateInfoRec())) return FALSE;
+
+#if 0
#ifdef XF86DRI
- R128DRICCEInitRingBuffer(pScrn);
+ /* FIXME: When direct rendering is enabled, we should use the CCE to
+ draw 2D commands */
+ if (info->directRenderingEnabled) R128CCEAccelInit(pScrn, a);
+ else
+#endif
#endif
+ R128MMIOAccelInit(pScrn, a);
+
+ R128EngineInit(pScrn);
return XAAInit(pScreen, a);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c
index 07d7f1bf3..d14f8c574 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c
@@ -71,9 +71,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xf86DDC.h"
/* DRI support */
-#if 0
-#include "GL/glxtokens.h"
-#endif
#include "GL/glxint.h"
#include "xf86drm.h"
#include "sarea.h"
@@ -81,6 +78,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xf86dri.h"
#include "dri.h"
#include "r128_dri.h"
+#include "r128_sarea.h"
#include "r128_dripriv.h"
/* Driver data structures */
@@ -100,6 +98,8 @@ do { \
CCEFifoSlots -= entries; \
} while (0)
+/* Wait for at least `entries' slots are free. The actual number of
+ slots available is stored in info->CCEFifoSize. */
static void R128CCEWaitForFifoFunction(ScrnInfoPtr pScrn, int entries)
{
R128InfoPtr info = R128PTR(pScrn);
@@ -115,6 +115,8 @@ static void R128CCEWaitForFifoFunction(ScrnInfoPtr pScrn, int entries)
}
}
+/* Wait until the CCE is completely idle: the FIFO has drained and the
+ CCE is idle. */
static void R128CCEWaitForIdle(ScrnInfoPtr pScrn)
{
R128InfoPtr info = R128PTR(pScrn);
@@ -135,7 +137,48 @@ static void R128CCEWaitForIdle(ScrnInfoPtr pScrn)
}
}
- /* FIXME: this routine is from tdfx */
+/* Start the CCE, but only if it is not already in use and the requested
+ mode is a CCE mode. The mode is stored in info->CCEMode. */
+void R128CCEStart(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+
+ if (info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return;
+
+ R128WaitForIdle(pScrn);
+ OUTREG(R128_PM4_BUFFER_CNTL, info->CCEMode);
+ (void)INREG(R128_PM4_BUFFER_ADDR); /* as per the sample code */
+ OUTREG(R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN);
+ info->CCEInUse = TRUE;
+}
+
+/* Stop the CCE, but only if it is in use and the requested mode is not
+ the non-CCE mode. This function also flushes any outstanding
+ requests before switching modes.*/
+void R128CCEStop(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+
+ if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return;
+
+ R128CCEWaitForIdle(pScrn);
+#if 0
+ /* FIXME: This is needed when we use the ring buffer to flush any
+ unfinished commands */
+ OUTREGP(R128_PM4_BUFFER_DL_WPTR,
+ R128_PM4_BUFFER_DL_DONE, ~R128_PM4_BUFFER_DL_DONE);
+#endif
+ OUTREG(R128_PM4_MICRO_CNTL, 0);
+ OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4);
+ info->CCEInUse = FALSE;
+}
+
+/* Initialize the visual configs that are supported by the hardware.
+ These are combined with the visual configs that the indirect
+ rendering core supports, and the intersection is exported to the
+ client. */
static Bool R128InitVisualConfigs(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
@@ -146,17 +189,15 @@ static Bool R128InitVisualConfigs(ScreenPtr pScreen)
R128ConfigPrivPtr *pR128ConfigPtrs = 0;
int i;
- switch (pScrn->bitsPerPixel) {
- case 8:
+ switch (pR128->pixel_code) {
+ case 8: /* 8bpp mode is not support */
+ case 15: /* FIXME */
+ case 24: /* FIXME */
+ return FALSE;
+
case 16:
- case 24:
- break;
case 32:
-#if 0
numConfigs = 4;
-#else
- numConfigs = 1;
-#endif
if (!(pConfigs
= (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig),
@@ -177,45 +218,55 @@ static Bool R128InitVisualConfigs(ScreenPtr pScreen)
return FALSE;
}
- for (i = 0; i < numConfigs; i++) pR128ConfigPtrs[i] = &pR128Configs[i];
-
- pConfigs[0].vid = -1;
- pConfigs[0].class = -1;
- pConfigs[0].rgba = TRUE;
- if (pScrn->depth == 16) {
- pConfigs[0].redSize = 5;
- pConfigs[0].greenSize = 6;
- pConfigs[0].blueSize = 5;
- pConfigs[0].redMask = 0x0000F800;
- pConfigs[0].greenMask = 0x000007E0;
- pConfigs[0].blueMask = 0x0000001F;
- } else {
- pConfigs[0].redSize = 8;
- pConfigs[0].greenSize = 8;
- pConfigs[0].blueSize = 8;
- pConfigs[0].redMask = 0x00FF0000;
- pConfigs[0].greenMask = 0x0000FF00;
- pConfigs[0].blueMask = 0x000000FF;
+ for (i = 0; i < numConfigs; i++) {
+ pR128ConfigPtrs[i] = &pR128Configs[i];
+
+ pConfigs[i].vid = -1;
+ pConfigs[i].class = -1;
+ pConfigs[i].rgba = TRUE;
+ if (pScrn->depth == 16) {
+ pConfigs[i].redSize = 5;
+ pConfigs[i].greenSize = 6;
+ pConfigs[i].blueSize = 5;
+ pConfigs[i].redMask = 0x0000F800;
+ pConfigs[i].greenMask = 0x000007E0;
+ pConfigs[i].blueMask = 0x0000001F;
+ } else {
+ pConfigs[i].redSize = 8;
+ pConfigs[i].greenSize = 8;
+ pConfigs[i].blueSize = 8;
+ pConfigs[i].redMask = 0x00FF0000;
+ pConfigs[i].greenMask = 0x0000FF00;
+ pConfigs[i].blueMask = 0x000000FF;
+ }
+ pConfigs[i].alphaMask = 0;
+ pConfigs[i].accumRedSize = 0;
+ pConfigs[i].accumGreenSize = 0;
+ pConfigs[i].accumBlueSize = 0;
+ pConfigs[i].accumAlphaSize = 0;
+ pConfigs[i].doubleBuffer = TRUE;
+ pConfigs[i].stereo = FALSE;
+ pConfigs[i].bufferSize = pScrn->depth;
+ pConfigs[i].depthSize = 16; /* FIXME: Support other depth */
+ pConfigs[i].stencilSize = 0; /* buffer depths with the new */
+ pConfigs[i].auxBuffers = 0; /* Mesa code. */
+ pConfigs[i].level = 0;
+ pConfigs[i].visualRating = 0;
+ pConfigs[i].transparentPixel = 0;
+ pConfigs[i].transparentRed = 0;
+ pConfigs[i].transparentGreen = 0;
+ pConfigs[i].transparentBlue = 0;
+ pConfigs[i].transparentAlpha = 0;
+ pConfigs[i].transparentIndex = 0;
}
- pConfigs[0].alphaMask = 0;
- pConfigs[0].accumRedSize = 0;
- pConfigs[0].accumGreenSize = 0;
- pConfigs[0].accumBlueSize = 0;
- pConfigs[0].accumAlphaSize = 0;
- pConfigs[0].doubleBuffer = TRUE;
- pConfigs[0].stereo = FALSE;
- pConfigs[0].bufferSize = pScrn->depth;
- pConfigs[0].depthSize = 16;
- 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;
+
+ /* Turn off double buffer support for certain visuals */
+ pConfigs[1].doubleBuffer = FALSE;
+ pConfigs[3].doubleBuffer = FALSE;
+
+ /* Turn off depth buffer support for certain visuals */
+ pConfigs[2].depthSize = 0;
+ pConfigs[3].depthSize = 0;
break;
}
@@ -226,50 +277,83 @@ static Bool R128InitVisualConfigs(ScreenPtr pScreen)
return TRUE;
}
+/* Create the Rage 128-specific context information */
static Bool R128CreateContext(ScreenPtr pScreen, VisualPtr visual,
drmContext hwContext, void *pVisualConfigPriv,
DRIContextType contextStore)
{
+ /* Nothing yet */
return TRUE;
}
+/* Destroy the Rage 128-specific context information */
static void R128DestroyContext(ScreenPtr pScreen, drmContext hwContext,
DRIContextType contextStore)
{
+ /* Nothing yet */
}
-void R128LostContext(ScreenPtr pScreen)
+/* Called when the X server is woken up to allow the last client's
+ context to be saved and the X server's context to be loaded. This is
+ not necessary for the Rage 128 since the client detects when it's
+ context is not currently loaded and then load's it itself. Since the
+ registers to start and stop the CCE are privileged, only the X server
+ can start/stop the engine. */
+static void R128EnterServer(ScreenPtr pScreen)
{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+#if 1
+ /* FIXME: When the CCE is used for 2D drawing in the X server, we
+ will not need to stop/start the CCE when entering/leaving the X
+ server. */
+ R128CCEStop(pScrn);
+#else
+ R128CCEWaitForIdle(pScrn);
+#endif
}
-void R128SwapContextPrivate(ScreenPtr pScreen)
+/* Called when the X server goes to sleep to allow the X server's
+ context to be saved and the last client's context to be loaded. This
+ is not necessary for the Rage 128 since the client detects when it's
+ context is not currently loaded and then load's it itself. Since the
+ registers to start and stop the CCE are privileged, only the X server
+ can start/stop the engine. */
+static void R128LeaveServer(ScreenPtr pScreen)
{
+#if 1
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- unsigned char *R128MMIO = R128PTR(pScrn)->MMIO;
- R128CCEWaitForIdle(pScrn);
- OUTREGP(R128_PM4_BUFFER_DL_WPTR,
- R128_PM4_BUFFER_DL_DONE, ~R128_PM4_BUFFER_DL_DONE);
- OUTREG(R128_PM4_MICRO_CNTL, 0);
- OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4);
+ /* FIXME: When the CCE is used for 2D drawing in the X server, we
+ will not need to stop/start the CCE when entering/leaving the X
+ server. */
+ R128CCEStart(pScrn);
+#endif
}
+/* Contexts can be swapped by the X server if necessary. This callback
+ is currently only used to perform any functions necessary when
+ entering or leaving the X server, and in the future might not be
+ necessary. */
static void R128DRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
DRIContextType oldContextType, void *oldContext,
DRIContextType newContextType, void *newContext)
{
if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) &&
(newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */
- R128SwapContextPrivate(pScreen);
+ R128EnterServer(pScreen);
}
if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) &&
(newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */
- R128LostContext(pScreen);
+ R128LeaveServer(pScreen);
}
}
+/* Initialize the state of the back and depth buffers. */
static void R128DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index)
{
+#if 0
+ /* FIXME: This routine needs to have acceleration turned on */
ScreenPtr pScreen = pWin->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
R128InfoPtr pR128 = R128PTR(pScrn);
@@ -277,6 +361,8 @@ static void R128DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index)
int nbox;
/* FIXME: Copy XAAPaintWindow() and use REGION_TRANSLATE() */
+ /* FIXME: Only initialize the back and depth buffers for contexts
+ that request them */
pbox = REGION_RECTS(prgn);
nbox = REGION_NUM_RECTS(prgn);
@@ -296,19 +382,28 @@ static void R128DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index)
}
pR128->accel->NeedToSync = TRUE;
+#endif
}
+/* Copy the back and depth buffers when the X server moves a window. */
static void R128DRIMoveBuffers(WindowPtr pWin, DDXPointRec ptOldOrg,
RegionPtr prgnSrc, CARD32 index)
{
+ /* FIXME: This routine needs to have acceleration turned on */
/* FIXME: Copy XAACopyWindow() and use REGION_TRANSLATE() */
+ /* FIXME: Only initialize the back and depth buffers for contexts
+ that request them */
}
+/* Initialize the AGP state. Request memory for use in AGP space, and
+ initialize the Rage 128 registers to point to that memory. */
static Bool R128DRIAgpInit(R128InfoPtr pR128, ScreenPtr pScreen)
{
+ unsigned char *R128MMIO = pR128->MMIO;
unsigned long mode;
unsigned int vendor, device;
int ret;
+ unsigned long cntl;
if (drmAgpAcquire(pR128->drmFD) < 0) {
xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not available\n");
@@ -319,11 +414,17 @@ static Bool R128DRIAgpInit(R128InfoPtr pR128, ScreenPtr pScreen)
not appropriate for this particular
combination of graphics card and AGP
chipset. */
-
+
mode = drmAgpGetMode(pR128->drmFD); /* Default mode */
vendor = drmAgpVendorId(pR128->drmFD);
device = drmAgpDeviceId(pR128->drmFD);
+#if 0
+ /* FIXME: This turns off AGP 2X mode */
+ /* FIXME: Make this configurable */
+ mode &= ~0x00000002;
+#endif
+
xf86DrvMsg(pScreen->myNum, X_INFO,
"[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n",
mode, vendor, device,
@@ -336,7 +437,8 @@ static Bool R128DRIAgpInit(R128InfoPtr pR128, ScreenPtr pScreen)
return FALSE;
}
- pR128->agpSize = 4 * 1024 * 1024; /* FIXME -- arbitrary */
+ /* FIXME: This size was chosen arbitrarily -- make it configurable */
+ pR128->agpSize = 8 * 1024 * 1024;
if ((ret = drmAgpAlloc(pR128->drmFD,
pR128->agpSize, &pR128->agpMemHandle)) < 0) {
xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Out of memory (%d)\n", ret);
@@ -347,7 +449,7 @@ static Bool R128DRIAgpInit(R128InfoPtr pR128, ScreenPtr pScreen)
"[agp] %d kB allocated with handle 0x%08x\n",
pR128->agpSize / 1024, pR128->agpMemHandle);
- pR128->agpOffset = 0; /* FIXME -- arbitrary */
+ pR128->agpOffset = 0;
if (drmAgpBind(pR128->drmFD, pR128->agpMemHandle, pR128->agpOffset) < 0) {
xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Could not bind\n");
drmAgpFree(pR128->drmFD, pR128->agpMemHandle);
@@ -375,9 +477,35 @@ static Bool R128DRIAgpInit(R128InfoPtr pR128, ScreenPtr pScreen)
"[agp] Aperture mapped at 0x%08lx\n",
(unsigned long)pR128->AGP);
+ /* Initialize Rage 128's AGP registers */
+ cntl = INREG(R128_AGP_CNTL);
+ cntl &= ~R128_AGP_APER_SIZE_MASK;
+ switch (pR128->agpSize) {
+ case 256*1024*1024: cntl |= R128_AGP_APER_SIZE_256MB; break;
+ case 128*1024*1024: cntl |= R128_AGP_APER_SIZE_128MB; break;
+ case 64*1024*1024: cntl |= R128_AGP_APER_SIZE_64MB; break;
+ case 32*1024*1024: cntl |= R128_AGP_APER_SIZE_32MB; break;
+ case 16*1024*1024: cntl |= R128_AGP_APER_SIZE_16MB; break;
+ case 8*1024*1024: cntl |= R128_AGP_APER_SIZE_8MB; break;
+ case 4*1024*1024: cntl |= R128_AGP_APER_SIZE_4MB; break;
+ default:
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Illegal aperture size %d kB\n",
+ pR128->agpSize / 1024);
+ drmUnmap(pR128->AGP, pR128->agpSize);
+ pR128->AGP = NULL;
+ drmAgpFree(pR128->drmFD, pR128->agpMemHandle);
+ drmAgpRelease(pR128->drmFD);
+ return FALSE;
+ }
+ OUTREG(R128_AGP_BASE, pR128->agpHandle);
+ OUTREG(R128_AGP_CNTL, cntl);
+
return TRUE;
}
+/* Add a map for the MMIO registers that will be accessed by any
+ DRI-based clients. */
static Bool R128DRIMapInit(R128InfoPtr pR128, ScreenPtr pScreen)
{
/* Map registers */
@@ -392,12 +520,13 @@ static Bool R128DRIMapInit(R128InfoPtr pR128, ScreenPtr pScreen)
return TRUE;
}
+/* Load the microcode for the CCE */
static void R128DRILoadMicrocode(ScrnInfoPtr pScrn)
{
unsigned char *R128MMIO = R128PTR(pScrn)->MMIO;
int i;
unsigned long R128Microcode[] = {
- /* Tedz Special Microcode */
+ /* CCE microcode (from ATI) */
0, 276838400, 0, 268449792, 2, 142, 2, 145, 0, 1076765731, 0, 1617039951,
0, 774592877, 0, 1987540286, 0, 2307490946U, 0, 599558925, 0, 589505315, 0,
596487092, 0, 589505315, 1, 11544576, 1, 206848, 1, 311296, 1, 198656, 2,
@@ -444,26 +573,78 @@ static void R128DRILoadMicrocode(ScrnInfoPtr pScrn)
}
}
+/* Initialize the CCE state, and reserve space in AGP memory for the
+ ring, vertex, indirect buffers (if used by the current CCEMode.
+ Allow the rest of AGP memory to be used for textures. */
static void R128DRICCEInit(ScrnInfoPtr pScrn)
{
- R128InfoPtr info = R128PTR(pScrn);
+ R128InfoPtr info = R128PTR(pScrn);
+ int s, l;
+
+/* FIXME: These sizes ware chosen arbitrarily -- make them configurable */
+/* NOTE: These must be page aligned */
+#define RING_SIZE 1*1024*1024
+#define VERTBUF_SIZE 1*1024*1024
+#define INDBUF_SIZE 1*1024*1024
+
+ /* FIXME: Currently, the ring, vertex and indirect buffers all take
+ space, even when the CCEMode does not use them. Make the use of
+ AGP space configurable by only reserving space for the buffers
+ that are required for the current CCEMode. */
/* Initialize the CCE ring buffer data */
info->ringStart = 0;
- info->ringSize = 8192; /* FIXME */
+ info->ringSize = RING_SIZE;
info->ringWrite = 0;
- info->ringReadOffset = 8192; /* FIXME */
-
- info->CCEMode = R128_PM4_192_DWORD_CCE_PIO; /* FIXME */
- info->CCEFifoSize = 192; /* FIXME */
+ info->ringReadOffset = info->ringStart + info->ringSize + 4096;
+
+ /* Reserve space for the vertex buffer */
+ info->vbStart = info->ringReadOffset + 4096;
+ info->vbSize = VERTBUF_SIZE;
+
+ /* Reserve space for the indirect buffer */
+ info->indStart = info->vbStart + info->vbSize;
+ info->indSize = INDBUF_SIZE;
+
+ /* Reserve the rest for AGP textures */
+ info->agpTexStart = info->indStart + info->indSize;
+ s = (info->agpSize - info->agpTexStart);
+ l = R128MinBits((s-1) / R128_NR_TEX_REGIONS);
+ if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
+ info->agpTexSize = (s >> l) << l;
+ info->log2AGPTexGran = l;
+
+ /* Initialize the CCE ring buffer FIFO size */
+ info->CCEInUse = FALSE;
+ info->CCEMode = R128_CCE_MODE;
+ switch (info->CCEMode) {
+ case R128_PM4_NONPM4: info->CCEFifoSize = 0; break;
+ case R128_PM4_192PIO: info->CCEFifoSize = 192; break;
+ case R128_PM4_192BM: info->CCEFifoSize = 192; break;
+ case R128_PM4_128PIO_64INDBM: info->CCEFifoSize = 128; break;
+ case R128_PM4_128BM_64INDBM: info->CCEFifoSize = 128; break;
+ case R128_PM4_64PIO_128INDBM: info->CCEFifoSize = 64; break;
+ case R128_PM4_64BM_128INDBM: info->CCEFifoSize = 64; break;
+ case R128_PM4_64PIO_64VCBM_64INDBM: info->CCEFifoSize = 64; break;
+ case R128_PM4_64BM_64VCBM_64INDBM: info->CCEFifoSize = 64; break;
+ case R128_PM4_64PIO_64VCPIO_64INDPIO: info->CCEFifoSize = 64; break;
+ }
}
+/* Initialize the ring buffer state for use in the X server and any
+ DRI-based clients. */
void R128DRICCEInitRingBuffer(ScrnInfoPtr pScrn)
{
R128InfoPtr info = R128PTR(pScrn);
unsigned char *R128MMIO = info->MMIO;
unsigned long addr;
+ /* FIXME: When we use the CCE for the X server, we should move this
+ function (and the support functions above) to r128_accel.c */
+
+ /* Initialize CCE data */
+ R128DRICCEInit(pScrn);
+
/* The manual (p. 2) says this address is
in "VM space". This means it's an
offset from the start of AGP space. */
@@ -476,42 +657,41 @@ void R128DRICCEInitRingBuffer(ScrnInfoPtr pScrn)
OUTREG(R128_PM4_BUFFER_DL_RPTR_ADDR, 0x00000000);
#else
/* DL_RPTR_ADDR is a physical address.
- This should probably be in the SAREA. */
+ This should be in the SAREA. */
*(volatile long unsigned *)(info->AGP + info->ringReadOffset) = 0;
OUTREG(R128_PM4_BUFFER_DL_RPTR_ADDR, (info->agpHandle
+ info->ringReadOffset));
#endif
/* Set watermark control */
-#if 1
- OUTREG(R128_PM4_BUFFER_WM_CNTL, 0x00000000);
-#else
OUTREG(R128_PM4_BUFFER_WM_CNTL,
((R128_WATERMARK_L/4) << R128_WMA_SHIFT)
| ((R128_WATERMARK_M/4) << R128_WMB_SHIFT)
| ((R128_WATERMARK_N/4) << R128_WMC_SHIFT)
| ((R128_WATERMARK_K/64) << R128_WB_WM_SHIFT));
-#endif
-#if 1
addr = INREG(R128_PM4_BUFFER_ADDR); /* Force read. Why? Because it's
in the examples... */
-#endif
R128CCEWaitForIdle(pScrn);
/* Turn on bus mastering */
-#if 1
- OUTREGP(R128_BUS_CNTL, R128_BUS_MASTER_DIS, ~R128_BUS_MASTER_DIS);
-#else
OUTREGP(R128_BUS_CNTL, 0, ~R128_BUS_MASTER_DIS);
-#endif
+#if 0
+ /* FIXME: If we use the CCE ring buffer for the X server, we need to
+ start the engine here for the X server. */
+#else
/* Make sure the CCE is off for the X server */
OUTREG(R128_PM4_MICRO_CNTL, 0);
OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4);
+#endif
}
+/* Initialize the screen-specific data structures for the DRI and the
+ Rage 128. This is the main entry point to the device-specific
+ initialization code. It calls device-independent DRI functions to
+ create the DRI data structures and initialize the DRI state. */
Bool R128DRIScreenInit(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
@@ -519,6 +699,21 @@ Bool R128DRIScreenInit(ScreenPtr pScreen)
DRIInfoPtr pDRIInfo;
R128DRIPtr pR128DRI;
+ switch (pR128->pixel_code) {
+ case 8:
+ /* These modes are not supported (yet). */
+ case 15:
+ case 24:
+ return FALSE;
+
+ /* Only 16 and 32 color depths are supports currently. */
+ case 16:
+ case 32:
+ break;
+ }
+
+ /* Create the DRI data structure, and fill it in before calling the
+ DRIScreenInit(). */
if (!(pDRIInfo = DRICreateInfoRec())) return FALSE;
pR128->pDRIInfo = pDRIInfo;
@@ -614,56 +809,25 @@ Bool R128DRIScreenInit(ScreenPtr pScreen)
/* Reset the Graphics Engine */
R128EngineReset(pScrn);
- /* Initialize CCE */
- R128DRICCEInit(pScrn);
-
return TRUE;
}
-void R128DRICloseScreen(ScreenPtr pScreen)
+/* Finish initializing the device-dependent DRI state, and call
+ DRIFinishScreenInit() to complete the device-independent DRI
+ initialization. */
+Bool R128DRIFinishScreenInit(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- R128InfoPtr pR128 = R128PTR(pScrn);
-
- /* De-allocate all AGP resources */
- if (pR128->AGP) {
- drmUnmap(pR128->AGP, pR128->agpSize);
- pR128->AGP = NULL;
- }
- if (pR128->agpMemHandle) {
- drmAgpUnbind(pR128->drmFD, pR128->agpMemHandle);
- drmAgpFree(pR128->drmFD, pR128->agpMemHandle);
- pR128->agpMemHandle = 0;
- drmAgpRelease(pR128->drmFD);
- }
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+ R128SAREAPrivPtr pSAREAPriv;
+ R128DRIPtr pR128DRI;
- DRICloseScreen(pScreen);
-
- if (pR128->pDRIInfo) {
- if (pR128->pDRIInfo->devPrivate) {
- xfree(pR128->pDRIInfo->devPrivate);
- pR128->pDRIInfo->devPrivate = NULL;
- }
- DRIDestroyInfoRec(pR128->pDRIInfo);
- pR128->pDRIInfo = NULL;
- }
- if (pR128->pVisualConfigs) {
- xfree(pR128->pVisualConfigs);
- pR128->pVisualConfigs = NULL;
- }
- if (pR128->pVisualConfigsPriv) {
- xfree(pR128->pVisualConfigsPriv);
- pR128->pVisualConfigsPriv = NULL;
- }
-}
+ pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScreen);
+ memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
+ R128DRICCEInitRingBuffer(pScrn);
+ /* FIXME: R128CCEStart(pScrn); */
-Bool R128DRIFinishScreenInit(ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- R128InfoPtr pR128 = R128PTR(pScrn);
- R128DRIPtr pR128DRI;
-
pR128->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT;
/* pR128->pDRIInfo->driverSwapMethod = DRI_SERVER_SWAP; */
@@ -688,6 +852,7 @@ Bool R128DRIFinishScreenInit(ScreenPtr pScreen)
pR128DRI->textureX = pR128->textureX;
pR128DRI->textureY = pR128->textureY;
pR128DRI->textureSize = pR128->textureSize;
+ pR128DRI->log2TexGran = pR128->log2TexGran;
pR128DRI->CCEMode = pR128->CCEMode;
pR128DRI->CCEFifoSize = pR128->CCEFifoSize;
@@ -697,7 +862,58 @@ Bool R128DRIFinishScreenInit(ScreenPtr pScreen)
pR128DRI->ringWrite = pR128->ringWrite;
pR128DRI->ringReadOffset = pR128->ringReadOffset;
+ pR128DRI->vbStart = pR128->vbStart;
+ pR128DRI->vbSize = pR128->vbSize;
+
+ pR128DRI->indStart = pR128->indStart;
+ pR128DRI->indSize = pR128->indSize;
+
+ pR128DRI->agpTexStart = pR128->agpTexStart;
+ pR128DRI->agpTexSize = pR128->agpTexSize;
+ pR128DRI->log2AGPTexGran = pR128->log2AGPTexGran;
+
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "0x%08lx %d\n",
pR128DRI->registerHandle, pR128DRI->registerSize);
return DRIFinishScreenInit(pScreen);
}
+
+/* The screen is being closed, so clean up any state and free any
+ resources used by the DRI. */
+void R128DRICloseScreen(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+
+ /* De-allocate all AGP resources */
+ if (pR128->AGP) {
+ drmUnmap(pR128->AGP, pR128->agpSize);
+ pR128->AGP = NULL;
+ }
+ if (pR128->agpMemHandle) {
+ drmAgpUnbind(pR128->drmFD, pR128->agpMemHandle);
+ drmAgpFree(pR128->drmFD, pR128->agpMemHandle);
+ pR128->agpMemHandle = 0;
+ drmAgpRelease(pR128->drmFD);
+ }
+
+ /* De-allocate all DRI resources */
+ DRICloseScreen(pScreen);
+
+ /* De-allocate all DRI data structures */
+ if (pR128->pDRIInfo) {
+ if (pR128->pDRIInfo->devPrivate) {
+ xfree(pR128->pDRIInfo->devPrivate);
+ pR128->pDRIInfo->devPrivate = NULL;
+ }
+ DRIDestroyInfoRec(pR128->pDRIInfo);
+ pR128->pDRIInfo = NULL;
+ }
+ if (pR128->pVisualConfigs) {
+ xfree(pR128->pVisualConfigs);
+ pR128->pVisualConfigs = NULL;
+ }
+ if (pR128->pVisualConfigsPriv) {
+ xfree(pR128->pVisualConfigsPriv);
+ pR128->pVisualConfigsPriv = NULL;
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h
index a443c060c..911cde1b5 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h
@@ -28,8 +28,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Rickard E. Faith <faith@precisioninsight.com>
* Kevin E. Martin <kevin@precisioninsight.com>
+ * Rickard E. Faith <faith@precisioninsight.com>
*
*/
@@ -38,36 +38,62 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <xf86drm.h>
+/* The CCE will default to the following mode: */
+#define R128_CCE_MODE R128_PM4_64PIO_64VCBM_64INDBM
typedef struct {
+ /* FIXME: There needs to be two register regions. One to allow
+ read-only access to the block of non-FIFO'd GUI registers
+ (0x0000-0x0FFC), and one to allow read/write acces to the block
+ of FIFO'd GUI registers (0x1000-0x1FFC) */
+
+ /* MMIO register data */
drmHandle registerHandle;
drmSize registerSize;
+
+ /* AGP data */
drmHandle agpHandle;
drmSize agpSize;
- int deviceID;
- int width;
- int height;
- int depth;
- int bpp;
+ /* DRI screen private data */
+ int deviceID; /* PCI device ID */
+ int width; /* Width in pixels of display */
+ int height; /* Height in scanlines of display */
+ int depth; /* Depth of display (8, 15, 16, 24) */
+ int bpp; /* Bit depth of display (8, 16, 24, 32) */
- int fbX;
+ int fbX; /* Start of frame buffer */
int fbY;
- int backX;
+ int backX; /* Start of shared back buffer */
int backY;
- int depthX;
+ int depthX; /* Start of shared depth buffer */
int depthY;
- int textureX;
+ int textureX; /* Start of texture data in frame buffer */
int textureY;
int textureSize;
+ int log2TexGran;
- int CCEMode;
- int CCEFifoSize;
+ int CCEMode; /* CCE mode that server/clients use */
+ int CCEFifoSize; /* Size of the CCE command FIFO */
+ /* CCE ring buffer data */
unsigned long ringStart;
int ringSize;
int ringWrite;
unsigned long ringReadOffset;
+
+ /* CCE vertex buffer data */
+ unsigned long vbStart;
+ int vbSize;
+
+ /* CCE indirect buffer data */
+ unsigned long indStart;
+ int indSize;
+
+ /* CCE AGP Texture data */
+ unsigned long agpTexStart;
+ int agpTexSize;
+ int log2AGPTexGran;
} R128DRIRec, *R128DRIPtr;
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h
index 81c6f2ba8..acec5e269 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h
@@ -51,9 +51,4 @@ typedef struct {
int dummy;
} R128DRIContextRec, *R128DRIContextPtr;
-typedef struct {
- /* Nothing here yet */
- int dummy;
-} R128SAREAPriv;
-
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c
index 944034b1e..df6f0e1e5 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c
@@ -109,6 +109,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "dri.h"
#include "r128_dri.h"
#include "r128_dripriv.h"
+#include "r128_sarea.h"
#endif
/* Driver data structures */
@@ -495,7 +496,7 @@ static void R128Unblank(ScrnInfoPtr pScrn)
}
/* Compute log base 2 of val. */
-static int R128MinBits(int val)
+int R128MinBits(int val)
{
int bits;
@@ -1111,6 +1112,12 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
R128TRACE(("R128ScreenInit %x %d\n", pScrn->memPhysBase, pScrn->fbOffset));
+#ifdef XF86DRI
+ /* Turn off the CCE for now. */
+ info->CCEInUse = FALSE;
+ info->CCEMode = R128_PM4_NONPM4;
+#endif
+
if (!R128MapMem(pScrn)) return FALSE;
pScrn->fbOffset = 0;
#ifdef XF86DRI
@@ -1138,8 +1145,6 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
call into the driver's InitGLXVisuals
call back. */
info->directRenderingEnabled = R128DRIScreenInit(pScreen);
- /* Force the initialization of the context */
- R128LostContext(pScreen);
#endif
@@ -1288,10 +1293,16 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
}
#ifdef XF86DRI
+ /* Allocate frame buffer space for the
+ shared back and depth buffers as well
+ as for local textures. */
if (info->directRenderingEnabled) {
FBAreaPtr fbarea;
+ int width_bytes = pScrn->displayWidth * info->pixel_bytes;
+ int maxy = info->FbMapSize / width_bytes;
+ int l;
- /* Back buffer setup */
+ /* Allocate the shared back buffer */
if ((fbarea = xf86AllocateOffscreenArea(pScreen,
pScrn->virtualX,
pScrn->virtualY,
@@ -1309,7 +1320,7 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
info->backY = -1;
}
- /* Depth buffer setup */
+ /* Allocate the shared depth buffer */
if ((fbarea = xf86AllocateOffscreenArea(pScreen,
pScrn->virtualX,
pScrn->virtualY,
@@ -1326,6 +1337,53 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
info->depthX = -1;
info->depthY = -1;
}
+
+ /* Allocate local texture space */
+ if (((maxy - MemBox.y2 - 1) * width_bytes) >
+ (pScrn->virtualX * pScrn->virtualY * 2 * info->pixel_bytes)) {
+ info->textureX = 0;
+ info->textureY = MemBox.y2 + 1;
+ info->textureSize = (maxy - MemBox.y2 - 1) * width_bytes;
+
+ l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS);
+ if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
+
+ info->log2TexGran = l;
+ info->textureSize = (info->textureSize >> l) << l;
+
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n",
+ info->textureSize/1024,
+ info->textureX, info->textureY,
+ pScrn->displayWidth, maxy);
+ } else if ((fbarea = xf86AllocateOffscreenArea(pScreen,
+ pScrn->virtualX,
+ pScrn->virtualY * 2,
+ 32,
+ NULL, NULL, NULL))) {
+ info->textureX = fbarea->box.x1;
+ info->textureY = fbarea->box.y1;
+ info->textureSize = ((fbarea->box.y2 - fbarea->box.y1) *
+ (fbarea->box.x2 - fbarea->box.x1) *
+ info->pixel_bytes);
+
+ l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS);
+ if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
+
+ info->log2TexGran = l;
+ info->textureSize = (info->textureSize >> l) << l;
+
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n",
+ info->textureSize/1024,
+ fbarea->box.x1, fbarea->box.y1,
+ fbarea->box.x2, fbarea->box.y2);
+ } else {
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "Unable to reserve texture space in frame buffer\n");
+ info->textureX = -1;
+ info->textureY = -1;
+ }
}
#endif
/* Hardware cursor setup */
@@ -1375,8 +1433,8 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
if (serverGeneration == 1)
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
- /* DRI finalization */
#ifdef XF86DRI
+ /* DRI finalization */
if (info->directRenderingEnabled) {
/* Now that mi, cfb, drm and others have
done their thing, complete the DRI
@@ -2050,6 +2108,7 @@ static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen)
R128TRACE(("R128CloseScreen\n"));
#ifdef XF86DRI
+ /* Disable direct rendering */
if (info->directRenderingEnabled) {
R128DRICloseScreen(pScreen);
info->directRenderingEnabled = FALSE;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h
index 50ed5b1d7..64c414a8d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h
@@ -108,6 +108,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R128_AGP_APER_OFFSET 0x0178
#define R128_AGP_BASE 0x0170
#define R128_AGP_CNTL 0x0174
+# define R128_AGP_APER_SIZE_256MB (0x00 << 0)
+# define R128_AGP_APER_SIZE_128MB (0x20 << 0)
+# define R128_AGP_APER_SIZE_64MB (0x30 << 0)
+# define R128_AGP_APER_SIZE_32MB (0x38 << 0)
+# define R128_AGP_APER_SIZE_16MB (0x3c << 0)
+# define R128_AGP_APER_SIZE_8MB (0x3e << 0)
+# define R128_AGP_APER_SIZE_4MB (0x3f << 0)
+# define R128_AGP_APER_SIZE_MASK (0x3f << 0)
#define R128_AGP_COMMAND 0x0f58 /* PCI */
#define R128_AGP_PLL_CNTL 0x0010 /* PLL */
#define R128_AGP_STATUS 0x0f54 /* PCI */
@@ -556,6 +564,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R128_PC_GUI_CTLSTAT 0x1748
#define R128_PC_GUI_MODE 0x1744
#define R128_PC_NGUI_CTLSTAT 0x0184
+# define R128_PC_FLUSH_GUI (3 << 0)
# define R128_PC_FLUSH_ALL 0x00ff
# define R128_PC_BUSY (1 << 31)
#define R128_PC_NGUI_MODE 0x0180
@@ -660,9 +669,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R128_PM4_BUFFER_OFFSET 0x0700
#define R128_PM4_BUFFER_CNTL 0x0704
-# define R128_PM4_NONPM4 (0 << 28)
-# define R128_PM4_192_DWORD_CCE_PIO (1 << 28)
-# define R128_PM4_192_DWORD_CCE_BM (2 << 28)
+# define R128_PM4_NONPM4 (0 << 28)
+# define R128_PM4_192PIO (1 << 28)
+# define R128_PM4_192BM (2 << 28)
+# define R128_PM4_128PIO_64INDBM (3 << 28)
+# define R128_PM4_128BM_64INDBM (4 << 28)
+# define R128_PM4_64PIO_128INDBM (5 << 28)
+# define R128_PM4_64BM_128INDBM (6 << 28)
+# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28)
+# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28)
+# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28)
#define R128_PM4_BUFFER_WM_CNTL 0x0708
# define R128_WMA_SHIFT 0
# define R128_WMB_SHIFT 8
@@ -810,6 +826,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R128_WINDOW_Y_SHIFT 4
# define R128_WINDOW_X_SHIFT 20
+#define R128_Z_OFFSET_C 0x1c90
+#define R128_Z_PITCH_C 0x1c94
#define R128_Z_STEN_CNTL_C 0x1c98
# define R128_Z_PIX_WIDTH_16 (0 << 1)
# define R128_Z_PIX_WIDTH_24 (1 << 1)
@@ -856,7 +874,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R128_STENCIL_ENABLE (1 << 3)
# define R128_SHADE_ENABLE (0 << 4)
# define R128_TEXMAP_ENABLE (1 << 4)
-# define R128_SECONDARY_TEX_ENABLE (1 << 5)
+# define R128_SEC_TEXMAP_ENABLE (1 << 5)
# define R128_FOG_ENABLE (1 << 7)
# define R128_DITHER_ENABLE (1 << 8)
# define R128_ALPHA_ENABLE (1 << 9)
@@ -918,7 +936,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R128_ALPHA_BLEND_DST_DESTCOLOR (8 << 20)
# define R128_ALPHA_BLEND_DST_INVDESTCOLOR (9 << 20)
# define R128_ALPHA_BLEND_DST_SRCALPHASAT (10 << 20)
-# define R128_ALPHA_BLEND_DST_MASK (15 << 16)
+# define R128_ALPHA_BLEND_DST_MASK (15 << 20)
# define R128_ALPHA_TEST_NEVER (0 << 24)
# define R128_ALPHA_TEST_LESS (1 << 24)
# define R128_ALPHA_TEST_LESSEQUAL (2 << 24)
@@ -941,18 +959,22 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R128_MIN_BLEND_MIPLINEAR (3 << 1)
# define R128_MIN_BLEND_LINEARMIPNEAREST (4 << 1)
# define R128_MIN_BLEND_LINEARMIPLINEAR (5 << 1)
+# define R128_MIN_BLEND_MASK (7 << 1)
# define R128_MAG_BLEND_NEAREST (0 << 4)
# define R128_MAG_BLEND_LINEAR (1 << 4)
+# define R128_MAG_BLEND_MASK (7 << 4)
# define R128_MIP_MAP_DISABLE (1 << 7)
# define R128_TEX_CLAMP_S_WRAP (0 << 8)
# define R128_TEX_CLAMP_S_MIRROR (1 << 8)
# define R128_TEX_CLAMP_S_CLAMP (2 << 8)
# define R128_TEX_CLAMP_S_BORDER_COLOR (3 << 8)
+# define R128_TEX_CLAMP_S_MASK (3 << 8)
# define R128_TEX_WRAP_S (1 << 10)
# define R128_TEX_CLAMP_T_WRAP (0 << 11)
# define R128_TEX_CLAMP_T_MIRROR (1 << 11)
# define R128_TEX_CLAMP_T_CLAMP (2 << 11)
# define R128_TEX_CLAMP_T_BORDER_COLOR (3 << 11)
+# define R128_TEX_CLAMP_T_MASK (3 << 11)
# define R128_TEX_WRAP_T (1 << 13)
# define R128_TEX_PERSPECTIVE_DISABLE (1 << 14)
# define R128_DATATYPE_VQ (0 << 16)
@@ -968,8 +990,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R128_DATATYPE_CI16 (10 << 16)
# define R128_DATATYPE_YUV422 (11 << 16)
# define R128_DATATYPE_YUV422_2 (12 << 16)
-# define R128_DATATYPE_AYUV444 (13 << 16)
-# define R128_DATATYPE_ARGB4444 (14 << 16)
+# define R128_DATATYPE_AYUV444 (14 << 16)
+# define R128_DATATYPE_ARGB4444 (15 << 16)
# define R128_PALLETE_EITHER (0 << 20)
# define R128_PALLETE_1 (1 << 20)
# define R128_PALLETE_2 (2 << 20)
@@ -993,14 +1015,17 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R128_COMB_BLEND_PREMULT_INV (13 << 0)
# define R128_COMB_ADD_SIGNED2X (14 << 0)
# define R128_COMB_BLEND_CONST_COLOR (15 << 0)
+# define R128_COMB_MASK (15 << 0)
# define R128_COLOR_FACTOR_TEX (4 << 4)
# define R128_COLOR_FACTOR_NTEX (5 << 4)
# define R128_COLOR_FACTOR_ALPHA (6 << 4)
# define R128_COLOR_FACTOR_NALPHA (7 << 4)
+# define R128_COLOR_FACTOR_MASK (15 << 4)
# define R128_INPUT_FACTOR_CONST_COLOR (2 << 10)
# define R128_INPUT_FACTOR_CONST_ALPHA (3 << 10)
# define R128_INPUT_FACTOR_INT_COLOR (4 << 10)
# define R128_INPUT_FACTOR_INT_ALPHA (5 << 10)
+# define R128_INPUT_FACTOR_MASK (15 << 10)
# define R128_COMB_ALPHA_DIS (0 << 14)
# define R128_COMB_ALPHA_COPY (1 << 14)
# define R128_COMB_ALPHA_COPY_INP (2 << 14)
@@ -1010,19 +1035,34 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R128_COMB_ALPHA_ADD (6 << 14)
# define R128_COMB_ALPHA_ADD_SIGNED (7 << 14)
# define R128_COMB_ALPHA_ADD_SIGNED2X (14 << 14)
+# define R128_COMB_ALPHA_MASK (15 << 14)
# define R128_ALPHA_FACTOR_TEX_ALPHA (6 << 18)
# define R128_ALPHA_FACTOR_NTEX_ALPHA (7 << 18)
+# define R128_ALPHA_FACTOR_MASK (15 << 18)
# define R128_INP_FACTOR_A_CONST_ALPHA (1 << 25)
# define R128_INP_FACTOR_A_INT_ALPHA (2 << 25)
+# define R128_INP_FACTOR_A_MASK (7 << 25)
#define R128_TEX_SIZE_PITCH_C 0x1cb8
-# define R128_TEX_PITCH_SHIFT 0
-# define R128_TEX_SIZE_SHIFT 4
-# define R128_TEX_HEIGHT_SHIFT 8
-# define R128_TEX_MIN_SIZE_SHIFT 12
-# define R128_SEC_TEX_PITCH_SHIFT 16
-# define R128_SEC_TEX_SIZE_SHIFT 20
-# define R128_SEC_TEX_HEIGHT_SHIFT 24
-# define R128_SEC_TEX_MIN_SIZE_SHIFT 28
+# define R128_TEX_PITCH_SHIFT 0
+# define R128_TEX_SIZE_SHIFT 4
+# define R128_TEX_HEIGHT_SHIFT 8
+# define R128_TEX_MIN_SIZE_SHIFT 12
+# define R128_SEC_TEX_PITCH_SHIFT 16
+# define R128_SEC_TEX_SIZE_SHIFT 20
+# define R128_SEC_TEX_HEIGHT_SHIFT 24
+# define R128_SEC_TEX_MIN_SIZE_SHIFT 28
+# define R128_TEX_PITCH_MASK (0x0f << 0)
+# define R128_TEX_SIZE_MASK (0x0f << 4)
+# define R128_TEX_HEIGHT_MASK (0x0f << 8)
+# define R128_TEX_MIN_SIZE_MASK (0x0f << 12)
+# define R128_SEC_TEX_PITCH_MASK (0x0f << 16)
+# define R128_SEC_TEX_SIZE_MASK (0x0f << 20)
+# define R128_SEC_TEX_HEIGHT_MASK (0x0f << 24)
+# define R128_SEC_TEX_MIN_SIZE_MASK (0x0f << 28)
+# define R128_TEX_SIZE_PITCH_SHIFT 0
+# define R128_SEC_TEX_SIZE_PITCH_SHIFT 16
+# define R128_TEX_SIZE_PITCH_MASK (0xffff << 0)
+# define R128_SEC_TEX_SIZE_PITCH_MASK (0xffff << 16)
#define R128_PRIM_TEX_0_OFFSET_C 0x1cbc
#define R128_PRIM_TEX_1_OFFSET_C 0x1cc0
#define R128_PRIM_TEX_2_OFFSET_C 0x1cc4
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h
new file mode 100644
index 000000000..2b835472e
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h
@@ -0,0 +1,69 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+on the rights to use, copy, modify, merge, publish, distribute, sub
+license, and/or sell copies of the Software, and to permit persons to whom
+the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_SAREA_H_
+#define _R128_SAREA_H_
+
+/* Each region is a minimum of 64k, and there are at most 128 of them */
+#define R128_NR_TEX_REGIONS 128
+#define R128_LOG_TEX_GRANULARITY 16
+
+typedef struct {
+ unsigned char next, prev; /* indices to form a circular LRU */
+ unsigned char in_use; /* owned by a client, or free? */
+ int age; /* tracked by clients to update local LRU's */
+} R128TexRegion;
+
+typedef struct {
+ /* Maintain an LRU of contiguous regions of texture space. If you
+ * think you own a region of texture memory, and it has an age
+ * different to the one you set, then you are mistaken and it has
+ * been stolen by another client. If global texAge hasn't changed,
+ * there is no need to walk the list.
+ *
+ * These regions can be used as a proxy for the fine-grained texture
+ * information of other clients - by maintaining them in the same
+ * lru which is used to age their own textures, clients have an
+ * approximate lru for the whole of global texture space, and can
+ * make informed decisions as to which areas to kick out. There is
+ * no need to choose whether to kick out your own texture or someone
+ * else's - simply eject them all in LRU order.
+ */
+ R128TexRegion texList[R128_NR_TEX_REGIONS+1]; /* Last elt is sentinal */
+ int texAge; /* last time texture was uploaded */
+
+ int ctxOwner; /* last context to upload state */
+} R128SAREAPriv, *R128SAREAPrivPtr;
+
+#endif