From 644fcdfdac61500e61e7bfd5ac98f780d87ef803 Mon Sep 17 00:00:00 2001 From: Tormod Volden Date: Mon, 18 Apr 2011 23:08:55 +0200 Subject: savage: Factor out a SAVAGESetAgpMode and call it on resume This should fix resume with AGP. After all these years... https://bugzilla.kernel.org/show_bug.cgi?id=4607 Signed-off-by: Tormod Volden Reviewed-by: Matt Turner Reviewed-by: Alex Deucher --- src/savage_dri.c | 57 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/src/savage_dri.c b/src/savage_dri.c index 70e50cb..ab86e35 100644 --- a/src/savage_dri.c +++ b/src/savage_dri.c @@ -426,29 +426,11 @@ static unsigned int mylog2( unsigned int n ) return log2; } -static Bool SAVAGEDRIAgpInit(ScreenPtr pScreen) +static Bool SAVAGESetAgpMode(SavagePtr psav, ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - SavagePtr psav = SAVPTR(pScrn); - SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo; - unsigned long mode; - unsigned int vendor, device; - unsigned int offset; - int ret; - - if (psav->agpSize < 2) psav->agpSize = 2; /* at least 2MB for DMA buffers */ - - pSAVAGEDRIServer->agp.size = psav->agpSize * 1024 * 1024; - pSAVAGEDRIServer->agp.offset = pSAVAGEDRIServer->agp.size; /* ? */ - - if ( drmAgpAcquire( psav->drmFD ) < 0 ) { - xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] AGP not available\n" ); - return FALSE; - } - - mode = drmAgpGetMode( psav->drmFD ); /* Default mode */ - vendor = drmAgpVendorId( psav->drmFD ); - device = drmAgpDeviceId( psav->drmFD ); + unsigned long mode = drmAgpGetMode( psav->drmFD ); /* Default mode */ + unsigned int vendor = drmAgpVendorId( psav->drmFD ); + unsigned int device = drmAgpDeviceId( psav->drmFD ); mode &= ~SAVAGE_AGP_MODE_MASK; @@ -462,8 +444,6 @@ static Bool SAVAGEDRIAgpInit(ScreenPtr pScreen) mode |= SAVAGE_AGP_1X_MODE; } - /* mode |= SAVAGE_AGP_1X_MODE;*/ - xf86DrvMsg( pScreen->myNum, X_INFO, "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n", mode, vendor, device, @@ -473,6 +453,32 @@ static Bool SAVAGEDRIAgpInit(ScreenPtr pScreen) if ( drmAgpEnable( psav->drmFD, mode ) < 0 ) { xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n" ); drmAgpRelease( psav->drmFD ); + return FALSE; + } + + return TRUE; +} + +static Bool SAVAGEDRIAgpInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + SavagePtr psav = SAVPTR(pScrn); + SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo; + unsigned int offset; + int ret; + + if (psav->agpSize < 2) + psav->agpSize = 2; /* at least 2MB for DMA buffers */ + + pSAVAGEDRIServer->agp.size = psav->agpSize * 1024 * 1024; + pSAVAGEDRIServer->agp.offset = pSAVAGEDRIServer->agp.size; /* ? */ + + if ( drmAgpAcquire( psav->drmFD ) < 0 ) { + xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] AGP not available\n" ); + return FALSE; + } + + if (!SAVAGESetAgpMode(psav, pScreen)) { pSAVAGEDRIServer->agp.handle = 0; /* indicate that AGP init failed */ return FALSE; } @@ -1294,6 +1300,9 @@ void SAVAGEDRIResume(ScreenPtr pScreen) SAVAGESAREAPrivPtr pSAREAPriv = (SAVAGESAREAPrivPtr)DRIGetSAREAPrivate(pScreen); + if (!psav->IsPCI) { + SAVAGESetAgpMode(psav, pScreen); + } SAVAGEDRISetupTiledSurfaceRegs(psav); /* Assume that 3D state was clobbered, invalidate it by * changing ctxOwner in the sarea. */ -- cgit v1.2.3