summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c
diff options
context:
space:
mode:
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c')
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c415
1 files changed, 100 insertions, 315 deletions
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 52f3704ec..11e4d2bec 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c,v 1.4 2000/06/26 05:41:32 martin Exp $ */ /* -*- mode: c; c-basic-offset: 4 -*- */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c,v 1.5 2000/08/25 13:42:37 dawes Exp $ */ /* -*- c-basic-offset: 4 -*- */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -87,142 +87,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128.h"
#include "r128_reg.h"
-#define R128_WATERMARK_L 16
-#define R128_WATERMARK_M 8
-#define R128_WATERMARK_N 8
-#define R128_WATERMARK_K 128
-
-static int CCEFifoSlots = 0;
-
-#define R128CCEWaitForFifo(pScrn, entries) \
-do { \
- if (CCEFifoSlots < entries) R128WaitForFifoFunction(pScrn, entries); \
- 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);
- unsigned char *R128MMIO = info->MMIO;
- int i;
-
- for (;;) {
- for (i = 0; i < R128_TIMEOUT; i++) {
- CCEFifoSlots = INREG(R128_PM4_STAT) & R128_PM4_FIFOCNT_MASK;
- if (CCEFifoSlots >= entries) return;
- }
- R128EngineReset(pScrn);
- if (info->CCE2D) R128CCEStart(pScrn);
- }
-}
-
-/* Wait until the CCE is completely idle: the FIFO has drained and the
- CCE is idle. */
-void R128CCEWaitForIdle(ScrnInfoPtr pScrn)
-{
- R128InfoPtr info = R128PTR(pScrn);
- unsigned char *R128MMIO = info->MMIO;
- int i;
-
- if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return;
-
- if (R128CCE_USE_RING_BUFFER(info->CCEMode)) {
- volatile CARD32 *r128RingReadPtr =
- (volatile CARD32 *)(info->ringReadPtr);
- R128SAREAPrivPtr pSAREAPriv;
-
- OUTREGP(R128_PM4_BUFFER_DL_WPTR,
- R128_PM4_BUFFER_DL_DONE, ~R128_PM4_BUFFER_DL_DONE);
-
- pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScrn->pScreen);
-
- for (;;) {
- for (i = 0; i < R128_TIMEOUT; i++) {
- if (*r128RingReadPtr == pSAREAPriv->ringWrite) {
- int pm4stat = INREG(R128_PM4_STAT);
- if ((pm4stat & R128_PM4_FIFOCNT_MASK) >= info->CCEFifoSize
- && !(pm4stat & (R128_PM4_BUSY|R128_PM4_GUI_ACTIVE))) {
- R128EngineFlush(pScrn);
- return;
- }
- }
- }
- R128EngineReset(pScrn);
- if (info->CCE2D) R128CCEStart(pScrn);
- }
- } else {
- R128CCEWaitForFifoFunction(pScrn, info->CCEFifoSize);
-
- for (;;) {
- for (i = 0; i < R128_TIMEOUT; i++) {
- if (!(INREG(R128_PM4_STAT)
- & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) {
- R128EngineFlush(pScrn);
- return;
- }
- }
- R128EngineReset(pScrn);
- if (info->CCE2D) R128CCEStart(pScrn);
- }
- }
-}
-
-/* Reset the ring buffer status, if the engine was reset */
-void R128CCEResetRing(ScrnInfoPtr pScrn)
-{
- R128InfoPtr info = R128PTR(pScrn);
- unsigned char *R128MMIO = info->MMIO;
- R128SAREAPrivPtr pSAREAPriv;
- volatile CARD32 *r128RingReadPtr;
-
- if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return;
-
- r128RingReadPtr = (volatile CARD32 *)(info->ringReadPtr);
- pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScrn->pScreen);
-
- OUTREG(R128_PM4_BUFFER_DL_WPTR, 0);
- OUTREG(R128_PM4_BUFFER_DL_RPTR, 0);
- pSAREAPriv->ringWrite = 0;
- *r128RingReadPtr = 0;
-
- /* Resetting the ring turns off the CCE */
- info->CCEInUse = FALSE;
-}
-
-/* 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 | info->ringSizeLog2QW);
- (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);
- OUTREG(R128_PM4_MICRO_CNTL, 0);
- OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4);
- R128EngineReset(pScrn);
- info->CCEInUse = FALSE;
-}
/* Initialize the visual configs that are supported by the hardware.
These are combined with the visual configs that the indirect
@@ -432,20 +296,22 @@ static void R128EnterServer(ScreenPtr pScreen)
if (info->accel) info->accel->NeedToSync = TRUE;
-#if 1
- if (!info->CCE2D) R128CCEStop(pScrn);
-#else
- if (info->CCE2D) R128CCEWaitForIdle(pScrn);
- else R128CCEStop(pScrn);
-#endif
+ if (!info->CCE2D) {
+ drmR128StopCCE(info->drmFD);
- /* Disable all hardware scissors */
- R128WaitForFifo(pScrn, 3);
- OUTREG(R128_AUX_SC_CNTL, 0);
- OUTREG(R128_SC_TOP_LEFT, (R128_SC_LEFT_DEFAULT |
- R128_SC_TOP_DEFAULT));
- OUTREG(R128_SC_BOTTOM_RIGHT, (R128_SC_RIGHT_DEFAULT |
- R128_SC_BOTTOM_DEFAULT));
+ /* Restore all hardware scissors */
+
+ /* FIXME: This is an evil macro. It requires the 'info'
+ * variable above.
+ */
+ R128WaitForFifo(pScrn, 5);
+
+ OUTREG(R128_SC_LEFT, info->sc_left);
+ OUTREG(R128_SC_RIGHT, info->sc_right);
+ OUTREG(R128_SC_TOP, info->sc_top);
+ OUTREG(R128_SC_BOTTOM, info->sc_bottom);
+ OUTREG(R128_AUX_SC_CNTL, info->aux_sc_cntl);
+ }
}
/* Called when the X server goes to sleep to allow the X server's
@@ -457,14 +323,19 @@ static void R128EnterServer(ScreenPtr pScreen)
static void R128LeaveServer(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- R128InfoPtr pR128 = R128PTR(pScrn);
+ R128InfoPtr info = R128PTR(pScrn);
+ R128MMIO_VARS();
-#if 1
- if (!pR128->CCE2D) R128CCEStart(pScrn);
-#else
- if (pR128->CCE2D) R128CCEWaitForIdle(pScrn);
- else R128CCEStart(pScrn);
-#endif
+ if (!info->CCE2D) {
+ drmR128StartCCE(info->drmFD);
+
+ /* Save all hardware scissors */
+ info->sc_left = INREG(R128_SC_LEFT);
+ info->sc_right = INREG(R128_SC_RIGHT);
+ info->sc_top = INREG(R128_SC_TOP);
+ info->sc_bottom = INREG(R128_SC_BOTTOM);
+ info->aux_sc_cntl = INREG(R128_SC_BOTTOM);
+ }
}
/* Contexts can be swapped by the X server if necessary. This callback
@@ -796,69 +667,62 @@ static Bool R128DRIMapInit(R128InfoPtr pR128, ScreenPtr pScreen)
return TRUE;
}
-/* Initialize the ring buffer state for use in the X server and any
- DRI-based clients. */
-static 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 */
-
- /* The manual (p. 2) says this address is
- in "VM space". This means it's an
- offset from the start of AGP space. */
- OUTREG(R128_PM4_BUFFER_OFFSET, info->ringStart | 0x02000000);
-
- OUTREG(R128_PM4_BUFFER_DL_WPTR, 0);
- OUTREG(R128_PM4_BUFFER_DL_RPTR, 0);
-
- /* DL_RPTR_ADDR is a physical address.
- This should be in the SAREA. */
- *(volatile long unsigned *)(info->ringReadPtr) = 0;
- OUTREG(R128_PM4_BUFFER_DL_RPTR_ADDR, (info->ringReadPtrHandle));
-
- /* Set watermark control */
- 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));
-
- addr = INREG(R128_PM4_BUFFER_ADDR); /* Force read. Why? Because it's
- in the examples... */
-
-#if 0
- R128CCEWaitForIdle(pScrn);
-#endif
-
- /* Turn on bus mastering */
- info->BusCntl &= ~R128_BUS_MASTER_DIS;
- OUTREGP(R128_BUS_CNTL, 0, ~R128_BUS_MASTER_DIS);
-}
-
/* Initialize the kernel data structures. */
static int R128DRIKernelInit(R128InfoPtr pR128, ScreenPtr pScreen)
{
- drmR128Init drmInfo;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ drmR128Init drmInfo;
+ int pitch = pScrn->virtualX;
+ int cpp = pR128->CurrentLayout.pixel_bytes;
+
drmInfo.sarea_priv_offset = sizeof(XF86DRISAREARec);
drmInfo.is_pci = pR128->IsPCI;
drmInfo.cce_mode = pR128->CCEMode;
- drmInfo.cce_fifo_size = pR128->CCEFifoSize;
drmInfo.cce_secure = pR128->CCESecure;
drmInfo.ring_size = pR128->ringSize*1024*1024;
drmInfo.usec_timeout = pR128->CCEusecTimeout;
- drmInfo.fb_offset = pR128->LinearAddr;
- drmInfo.agp_ring_offset = pR128->ringHandle;
- drmInfo.agp_read_ptr_offset = pR128->ringReadPtrHandle;
- drmInfo.agp_vertbufs_offset = pR128->vbHandle;
- drmInfo.agp_indbufs_offset = pR128->indHandle;
- drmInfo.agp_textures_offset = pR128->agpTexHandle;
- drmInfo.mmio_offset = pR128->registerHandle;
+ drmInfo.fb_bpp = pR128->CurrentLayout.pixel_code;
+ drmInfo.depth_bpp = pR128->CurrentLayout.pixel_code;
+
+ drmInfo.front_offset = (pR128->fbY * pitch * cpp +
+ pR128->fbX * cpp);
+ drmInfo.front_pitch = pitch;
+ drmInfo.front_x = pR128->fbX;
+ drmInfo.front_y = pR128->fbY;
+ xf86DrvMsg( pScreen->myNum, X_INFO,
+ "[drm] front offset=%d pitch=%d x=%d y=%d\n",
+ drmInfo.front_offset, drmInfo.front_pitch,
+ drmInfo.front_x, drmInfo.front_y );
+
+ drmInfo.back_offset = (pR128->backY * pitch * cpp +
+ pR128->backX * cpp);
+ drmInfo.back_pitch = pitch;
+ drmInfo.back_x = pR128->backX;
+ drmInfo.back_y = pR128->backY;
+ xf86DrvMsg( pScreen->myNum, X_INFO,
+ "[drm] back offset=%d pitch=%d x=%d y=%d\n",
+ drmInfo.back_offset, drmInfo.back_pitch,
+ drmInfo.back_x, drmInfo.back_y );
+
+ drmInfo.depth_offset = (pR128->depthY * pitch * cpp +
+ pR128->depthX * cpp);
+ drmInfo.depth_pitch = pitch;
+ drmInfo.depth_x = pR128->depthX;
+ drmInfo.depth_y = pR128->depthY;
+ xf86DrvMsg( pScreen->myNum, X_INFO,
+ "[drm] depth offset=%d pitch=%d x=%d y=%d\n",
+ drmInfo.depth_offset, drmInfo.depth_pitch,
+ drmInfo.depth_x, drmInfo.depth_y );
+
+ drmInfo.fb_offset = pR128->LinearAddr;
+ drmInfo.mmio_offset = pR128->registerHandle;
+ drmInfo.ring_offset = pR128->ringHandle;
+ drmInfo.ring_rptr_offset = pR128->ringReadPtrHandle;
+ drmInfo.vertex_buffers_offset = pR128->vbHandle;
+ drmInfo.indirect_buffers_offset = pR128->indHandle;
+ drmInfo.agp_textures_offset = pR128->agpTexHandle;
if (drmR128InitCCE(pR128->drmFD, &drmInfo) < 0) return FALSE;
@@ -901,66 +765,15 @@ static Bool R128DRIBufInit(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[] = {
- /* 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,
- 912273422, 11, 262144, 0, 0, 1, 33559837, 1, 7438, 1, 14809, 1, 6615, 12,
- 28, 1, 6614, 12, 28, 2, 23, 11, 18874368, 0, 16790922, 1, 409600, 9, 30, 1,
- 147854772, 16, 420483072, 3, 8192, 0, 10240, 1, 198656, 1, 15630, 1, 51200,
- 10, 34858, 9, 42, 1, 33559823, 2, 10276, 1, 15717, 1, 15718, 2, 43, 1,
- 15936948, 1, 570480831, 1, 14715071, 12, 322123831, 1, 33953125, 12, 55, 1,
- 33559908, 1, 15718, 2, 46, 4, 2099258, 1, 526336, 1, 442623, 4, 4194365, 1,
- 509952, 1, 459007, 3, 0, 12, 92, 2, 46, 12, 176, 1, 15734, 1, 206848, 1,
- 18432, 1, 133120, 1, 100670734, 1, 149504, 1, 165888, 1, 15975928, 1,
- 1048576, 6, 3145806, 1, 15715, 16, 2150645232U, 2, 268449859, 2, 10307, 12,
- 176, 1, 15734, 1, 15735, 1, 15630, 1, 15631, 1, 5253120, 6, 3145810, 16,
- 2150645232U, 1, 15864, 2, 82, 1, 343310, 1, 1064207, 2, 3145813, 1, 15728,
- 1, 7817, 1, 15729, 3, 15730, 12, 92, 2, 98, 1, 16168, 1, 16167, 1, 16002,
- 1, 16008, 1, 15974, 1, 15975, 1, 15990, 1, 15976, 1, 15977, 1, 15980, 0,
- 15981, 1, 10240, 1, 5253120, 1, 15720, 1, 198656, 6, 110, 1, 180224, 1,
- 103824738, 2, 112, 2, 3145839, 0, 536885440, 1, 114880, 14, 125, 12,
- 206975, 1, 33559995, 12, 198784, 0, 33570236, 1, 15803, 0, 15804, 3,
- 294912, 1, 294912, 3, 442370, 1, 11544576, 0, 811612160, 1, 12593152, 1,
- 11536384, 1, 14024704, 7, 310382726, 0, 10240, 1, 14796, 1, 14797, 1,
- 14793, 1, 14794, 0, 14795, 1, 268679168, 1, 9437184, 1, 268449792, 1,
- 198656, 1, 9452827, 1, 1075854602, 1, 1075854603, 1, 557056, 1, 114880, 14,
- 159, 12, 198784, 1, 1109409213, 12, 198783, 1, 1107312059, 12, 198784, 1,
- 1109409212, 2, 162, 1, 1075854781, 1, 1073757627, 1, 1075854780, 1, 540672,
- 1, 10485760, 6, 3145894, 16, 274741248, 9, 168, 3, 4194304, 3, 4209949, 0,
- 0, 0, 256, 14, 174, 1, 114857, 1, 33560007, 12, 176, 0, 10240, 1, 114858,
- 1, 33560018, 1, 114857, 3, 33560007, 1, 16008, 1, 114874, 1, 33560360, 1,
- 114875, 1, 33560154, 0, 15963, 0, 256, 0, 4096, 1, 409611, 9, 188, 0,
- 10240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0
- };
-
- R128WaitForIdle(pScrn);
-
- OUTREG(R128_PM4_MICROCODE_ADDR, 0);
- for (i = 0; i < 256; i += 1) {
- OUTREG(R128_PM4_MICROCODE_DATAH, R128Microcode[i*2]);
- OUTREG(R128_PM4_MICROCODE_DATAL, R128Microcode[i*2 + 1]);
- }
-}
-
/* Initialize the CCE state, and start the CCE (if used by the X server) */
static void R128DRICCEInit(ScrnInfoPtr pScrn)
{
- R128InfoPtr info = R128PTR(pScrn);
- unsigned char *R128MMIO = info->MMIO;
+ R128InfoPtr info = R128PTR(pScrn);
+
+ /* Mark bus mastering as on */
+ info->BusCntl &= ~R128_BUS_MASTER_DIS;
- /* CCEMode is initialized in r128_driver.c */
+ /* CCEMode is initialized in r128_driver.c */
switch (info->CCEMode) {
case R128_PM4_NONPM4: info->CCEFifoSize = 0; break;
case R128_PM4_192PIO: info->CCEFifoSize = 192; break;
@@ -975,12 +788,11 @@ static void R128DRICCEInit(ScrnInfoPtr pScrn)
}
if (info->CCE2D) {
- /* Make sure the CCE is on for the X server */
- R128CCEStart(pScrn);
+ /* Make sure the CCE is on for the X server */
+ drmR128StartCCE(info->drmFD);
} 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);
+ /* Make sure the CCE is off for the X server */
+ drmR128StopCCE(info->drmFD);
}
}
@@ -1097,6 +909,8 @@ Bool R128DRIScreenInit(ScreenPtr pScreen)
pDRIInfo->devPrivate = NULL;
DRIDestroyInfoRec(pDRIInfo);
pDRIInfo = NULL;
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "Failed to initialize the DRI!\n");
return FALSE;
}
@@ -1126,8 +940,9 @@ Bool R128DRIScreenInit(ScreenPtr pScreen)
R128DRICloseScreen(pScreen);
return FALSE;
}
- /* Initialize PCI */
+
#if 0
+ /* Initialize PCI */
if (pR128->IsPCI && !R128DRIPciInit(pR128, pScreen)) {
R128DRICloseScreen(pScreen);
return FALSE;
@@ -1142,7 +957,6 @@ Bool R128DRIScreenInit(ScreenPtr pScreen)
return FALSE;
}
#endif
-
/* DRIScreenInit doesn't add all the
common mappings. Add additional
mappings here. */
@@ -1150,22 +964,6 @@ Bool R128DRIScreenInit(ScreenPtr pScreen)
R128DRICloseScreen(pScreen);
return FALSE;
}
-
- /* Initialize the ring buffer */
- if (!pR128->IsPCI) R128DRICCEInitRingBuffer(pScrn);
-
- /* Initialize the kernel data structures */
- if (!R128DRIKernelInit(pR128, pScreen)) {
- R128DRICloseScreen(pScreen);
- return FALSE;
- }
-
- /* Initialize vertex buffers list */
- if (!pR128->IsPCI && !R128DRIBufInit(pR128, pScreen)) {
- R128DRICloseScreen(pScreen);
- return FALSE;
- }
-
/* FIXME: When are these mappings unmapped? */
if (!R128InitVisualConfigs(pScreen)) {
@@ -1174,12 +972,6 @@ Bool R128DRIScreenInit(ScreenPtr pScreen)
}
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Visual configs initialized\n");
- /* Load the CCE Microcode */
- R128DRILoadMicrocode(pScrn);
-
- /* Reset the Graphics Engine */
- R128EngineReset(pScrn);
-
return TRUE;
}
@@ -1193,7 +985,19 @@ Bool R128DRIFinishScreenInit(ScreenPtr pScreen)
R128SAREAPrivPtr pSAREAPriv;
R128DRIPtr pR128DRI;
- /* Init and start the CCE */
+ /* Initialize the kernel data structures */
+ if (!R128DRIKernelInit(pR128, pScreen)) {
+ R128DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ /* Initialize the vertex buffers list */
+ if (!pR128->IsPCI && !R128DRIBufInit(pR128, pScreen)) {
+ R128DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ /* Initialize and start the CCE if required */
R128DRICCEInit(pScrn);
pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScreen);
@@ -1245,25 +1049,6 @@ Bool R128DRIFinishScreenInit(ScreenPtr pScreen)
pR128DRI->IsPCI = pR128->IsPCI;
- switch (pR128->Chipset) {
- case PCI_CHIP_RAGE128RE:
- case PCI_CHIP_RAGE128RF:
- case PCI_CHIP_RAGE128RK:
- case PCI_CHIP_RAGE128RL:
- pR128DRI->chipset = R128_CARD_TYPE_R128;
- break;
- case PCI_CHIP_RAGE128PF:
- pR128DRI->chipset = R128_CARD_TYPE_R128_PRO;
- break;
- case PCI_CHIP_RAGE128LE:
- case PCI_CHIP_RAGE128LF:
- pR128DRI->chipset = R128_CARD_TYPE_R128_MOBILITY;
- break;
- default:
- pR128DRI->chipset = R128_CARD_TYPE_R128;
- break;
- }
-
pR128DRI->CCEMode = pR128->CCEMode;
pR128DRI->CCEFifoSize = pR128->CCEFifoSize;
@@ -1280,7 +1065,7 @@ void R128DRICloseScreen(ScreenPtr pScreen)
R128InfoPtr pR128 = R128PTR(pScrn);
/* Stop the CCE if it is still in use */
- if (pR128->CCE2D) R128CCEStop(pScrn);
+ if (pR128->CCE2D) drmR128StopCCE(pR128->drmFD);
/* De-allocate vertex buffers */
if (pR128->vbBufs) {