summaryrefslogtreecommitdiff
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
parent5b8577ae3200d967b4316156f16028cbcfd21983 (diff)
- Add DRI resume support (Micha Feigin) bug 2063
-rw-r--r--src/aticonsole.c5
-rw-r--r--src/atidri.c85
-rw-r--r--src/atidri.h4
3 files changed, 71 insertions, 23 deletions
diff --git a/src/aticonsole.c b/src/aticonsole.c
index 1b87a956..9c020e80 100644
--- a/src/aticonsole.c
+++ b/src/aticonsole.c
@@ -40,6 +40,7 @@
#ifdef XF86DRI_DEVEL
#include "mach64_common.h"
+#include "atidri.h"
#endif
#include "mach64_common.h"
@@ -315,6 +316,8 @@ ATIEnterVT
if (pATI->directRenderingEnabled)
{
+ /* get the Mach64 back into shape after resume */
+ ATIDRIResume(pScreen);
DRIUnlock(pScreen);
}
@@ -350,6 +353,8 @@ ATIEnterVT
if (pATI->directRenderingEnabled)
{
+ /* get the Mach64 back into shape after resume */
+ ATIDRIResume(pScreen);
DRIUnlock(pScreen);
}
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.
*/
diff --git a/src/atidri.h b/src/atidri.h
index 77622bb4..3df07eca 100644
--- a/src/atidri.h
+++ b/src/atidri.h
@@ -38,6 +38,10 @@
#define ATI_AGP_MAX_MODE 2
+/* Imported from the radeon suspend code writen by cpbotha@ieee.org
+ * to enable suspend/resume support for the mach64 card.
+ */
+extern void ATIDRIResume(ScreenPtr pScreen);
extern Bool ATIDRIScreenInit(ScreenPtr);
extern Bool ATIDRIFinishScreenInit(ScreenPtr);
extern void ATIDRICloseScreen(ScreenPtr);