summaryrefslogtreecommitdiff
path: root/src/atidri.c
diff options
context:
space:
mode:
authorAlex Deucher <agd5f@yahoo.com>2004-12-19 06:56:37 +0000
committerAlex Deucher <agd5f@yahoo.com>2004-12-19 06:56:37 +0000
commit97cfd7b1489a9510cd233d6dc7154c210f32b9f5 (patch)
tree9dc5f4c31e299877129273d3fc343a28813180bd /src/atidri.c
parent5b8577ae3200d967b4316156f16028cbcfd21983 (diff)
- Add DRI resume support (Micha Feigin) bug 2063
Diffstat (limited to 'src/atidri.c')
-rw-r--r--src/atidri.c85
1 files changed, 62 insertions, 23 deletions
diff --git a/src/atidri.c b/src/atidri.c
index d5e1c898..c3fd9765 100644
--- a/src/atidri.c
+++ b/src/atidri.c
@@ -638,34 +638,15 @@ static int Mach64MinBits(int val)
return bits;
}
-/* Initialize the AGP state. Request memory for use in AGP space, and
- * initialize the Rage Pro registers to point to that memory.
- */
-static Bool ATIDRIAgpInit( ScreenPtr pScreen )
+static Bool ATIDRISetAgpMode( ScreenPtr pScreen )
{
ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum];
ATIPtr pATI = ATIPTR(pScreenInfo);
ATIDRIServerInfoPtr pATIDRIServer = pATI->pDRIServerInfo;
- unsigned long mode;
- unsigned int vendor, device;
- int ret;
- unsigned long cntl;
- int s, l;
-
- pATIDRIServer->agpSize = ATI_DEFAULT_AGP_SIZE;
- pATIDRIServer->agpMode = ATI_DEFAULT_AGP_MODE;
- pATIDRIServer->bufferSize = ATI_DEFAULT_BUFFER_SIZE;
- pATIDRIServer->ringSize = 16; /* 16 kB ring */
-
- if ( drmAgpAcquire( pATI->drmFD ) < 0 ) {
- xf86DrvMsg( pScreen->myNum, X_WARNING, "[agp] AGP not available\n" );
- return FALSE;
- }
-
- mode = drmAgpGetMode( pATI->drmFD ); /* Default mode */
- vendor = drmAgpVendorId( pATI->drmFD );
- device = drmAgpDeviceId( pATI->drmFD );
+ unsigned long mode = drmAgpGetMode( pATI->drmFD ); /* Default mode */
+ unsigned int vendor = drmAgpVendorId( pATI->drmFD );
+ unsigned int device = drmAgpDeviceId( pATI->drmFD );
if (pATI->OptionAGPMode > 0 && pATI->OptionAGPMode <= ATI_AGP_MAX_MODE) {
pATIDRIServer->agpMode = pATI->OptionAGPMode;
@@ -727,6 +708,35 @@ static Bool ATIDRIAgpInit( ScreenPtr pScreen )
return FALSE;
}
+ return TRUE;
+}
+
+/* Initialize the AGP state. Request memory for use in AGP space, and
+ * initialize the Rage Pro registers to point to that memory.
+ */
+static Bool ATIDRIAgpInit( ScreenPtr pScreen )
+{
+ ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum];
+ ATIPtr pATI = ATIPTR(pScreenInfo);
+ ATIDRIServerInfoPtr pATIDRIServer = pATI->pDRIServerInfo;
+
+ int ret;
+ unsigned long cntl;
+ int s, l;
+
+ pATIDRIServer->agpSize = ATI_DEFAULT_AGP_SIZE;
+ pATIDRIServer->agpMode = ATI_DEFAULT_AGP_MODE;
+ pATIDRIServer->bufferSize = ATI_DEFAULT_BUFFER_SIZE;
+ pATIDRIServer->ringSize = 16; /* 16 kB ring */
+
+ if ( drmAgpAcquire( pATI->drmFD ) < 0 ) {
+ xf86DrvMsg( pScreen->myNum, X_WARNING, "[agp] AGP not available\n" );
+ return FALSE;
+ }
+
+ if (!ATIDRISetAgpMode( pScreen ))
+ return FALSE;
+
pATIDRIServer->agpOffset = 0;
ret = drmAgpAlloc( pATI->drmFD, pATIDRIServer->agpSize*1024*1024,
@@ -1431,6 +1441,35 @@ Bool ATIDRIFinishScreenInit( ScreenPtr pScreen )
return TRUE;
}
+/*
+ * This function will attempt to get the Mach64 hardware back into shape
+ * after a resume from disc. Its an extract from ATIDRIAgpInit and ATIDRIFinishScreenInit
+ * This also calls a new ioctl in the mach64 DRM that in its turn is
+ * an extraction of the hardware-affecting bits from mach64_do_init_drm()
+ * (see atidrm.c)
+ * I am assuming here that pATI->pDRIServerInfo doesn't change
+ * elsewhere in incomaptible ways.
+ * How will this code react to resuming after a failed resumeor pci based dri ?
+ */
+void ATIDRIResume( ScreenPtr pScreen )
+{
+ ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum];
+ ATIPtr pATI = ATIPTR(pScreenInfo);
+ ATIDRIServerInfoPtr pATIDRIServer = pATI->pDRIServerInfo;
+
+ int ret;
+
+ xf86DrvMsg( pScreen->myNum, X_INFO,
+ "[RESUME] Attempting to re-init Mach64 hardware.\n");
+
+ if (!pATIDRIServer->IsPCI) {
+ if (!ATIDRISetAgpMode(pScreen))
+ return;
+
+ outm( AGP_BASE, drmAgpBase(pATI->drmFD) );
+ }
+}
+
/* The screen is being closed, so clean up any state and free any
* resources used by the DRI.
*/