diff options
author | Eric Anholt <anholt@FreeBSD.org> | 2004-06-16 09:25:58 +0000 |
---|---|---|
committer | Eric Anholt <anholt@FreeBSD.org> | 2004-06-16 09:25:58 +0000 |
commit | 36a913a86056dddecbdc182513d462a70b54b6e8 (patch) | |
tree | 6c2c767adab4577db4e95547c34ef9a2dea1fe8d | |
parent | fdb57a8d76dec198f0a97a62fbaf3b2210cea130 (diff) |
Initial revision
-rw-r--r-- | src/atidri.c | 85 | ||||
-rw-r--r-- | src/atidri.h | 12 | ||||
-rw-r--r-- | src/atidripriv.h | 4 | ||||
-rw-r--r-- | src/radeon_mergedfb.c | 88 |
4 files changed, 58 insertions, 131 deletions
diff --git a/src/atidri.c b/src/atidri.c index c3fd976..d5e1c89 100644 --- a/src/atidri.c +++ b/src/atidri.c @@ -638,15 +638,34 @@ static int Mach64MinBits(int val) return bits; } -static Bool ATIDRISetAgpMode( ScreenPtr pScreen ) +/* 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; - unsigned long mode = drmAgpGetMode( pATI->drmFD ); /* Default mode */ - unsigned int vendor = drmAgpVendorId( pATI->drmFD ); - unsigned int device = drmAgpDeviceId( pATI->drmFD ); + 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 ); if (pATI->OptionAGPMode > 0 && pATI->OptionAGPMode <= ATI_AGP_MAX_MODE) { pATIDRIServer->agpMode = pATI->OptionAGPMode; @@ -708,35 +727,6 @@ static Bool ATIDRISetAgpMode( 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, @@ -1441,35 +1431,6 @@ 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 3df07ec..a0319a6 100644 --- a/src/atidri.h +++ b/src/atidri.h @@ -31,6 +31,8 @@ #ifndef __ATIDRI_H__ #define __ATIDRI_H__ 1 +#include "atiproto.h" + /* DRI driver defaults */ #define ATI_DEFAULT_AGP_SIZE 8 /* MB (must be a power of 2 and > 4MB) */ #define ATI_DEFAULT_AGP_MODE 1 @@ -38,12 +40,8 @@ #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); +extern Bool ATIDRIScreenInit FunctionPrototype((ScreenPtr)); +extern Bool ATIDRIFinishScreenInit FunctionPrototype((ScreenPtr)); +extern void ATIDRICloseScreen FunctionPrototype((ScreenPtr)); #endif /* __ATIDRI_H__ */ diff --git a/src/atidripriv.h b/src/atidripriv.h index af42d6e..b16b14e 100644 --- a/src/atidripriv.h +++ b/src/atidripriv.h @@ -40,6 +40,8 @@ #include "GL/glxint.h" #include "GL/glxtokens.h" +#include "atiproto.h" + #define ATI_MAX_DRAWABLES 256 typedef struct { @@ -52,6 +54,6 @@ typedef struct { int dummy; } ATIDRIContextRec, *ATIDRIContextPtr; -extern void GlxSetVisualConfigs(int, __GLXvisualConfig *, void **); +extern void GlxSetVisualConfigs FunctionPrototype((int, __GLXvisualConfig *, void **)); #endif /* __ATIDRIPRIV_H__ */ diff --git a/src/radeon_mergedfb.c b/src/radeon_mergedfb.c index 89bc19f..e9910e8 100644 --- a/src/radeon_mergedfb.c +++ b/src/radeon_mergedfb.c @@ -29,7 +29,6 @@ /* * Authors: * Alex Deucher <agd5f@yahoo.com> - * Based, in large part, on the sis driver by Thomas Winischhofer. */ #include "xf86.h" @@ -122,9 +121,9 @@ RADEONStrToRanges(range *r, char *s, int max) return rangenum; } -/* Copy and link two modes (i, j) for merged-fb mode +/* Copy and link two modes form merged-fb mode * (Taken from mga, sis drivers) - * Copys mode i, merges j to copy of i, links the result to dest, and returns it. + * Copys mode i, links the result to dest, and returns it. * Links i and j in Private record. * If dest is NULL, return value is copy of i linked to itself. * For mergedfb auto-config, we only check the dimension @@ -204,22 +203,16 @@ RADEONCopyModeNLink(ScrnInfoPtr pScrn, DisplayModePtr dest, mode->VSyncStart += dy; mode->VSyncEnd += dy; mode->VTotal += dy; - - /* Provide a sophisticated fake DotClock in order to trick the vidmode - * extension to allow selecting among a number of modes whose merged result - * looks identical but consists of different modes for CRT1 and CRT2 - */ - mode->Clock = (((i->Clock >> 3) + i->HTotal) << 16) | ((j->Clock >> 2) + j->HTotal); - mode->Clock ^= ((i->VTotal << 19) | (j->VTotal << 3)); + mode->Clock = 0; if( ((mode->HDisplay * ((pScrn->bitsPerPixel + 7) / 8) * mode->VDisplay) > (pScrn->videoRam * 1024)) || - (mode->HDisplay > 8191) || - (mode->VDisplay > 8191) ) { + (mode->HDisplay > 8192) || + (mode->VDisplay > 8192) ) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Skipped \"%s\" (%dx%d), not enough video RAM or beyond hardware specs\n", - mode->name, mode->HDisplay, mode->VDisplay); + "Skipped %dx%d, not enough video RAM or beyond hardware specs\n", + mode->HDisplay, mode->VDisplay); xfree(mode->Private); xfree(mode); @@ -231,8 +224,8 @@ RADEONCopyModeNLink(ScrnInfoPtr pScrn, DisplayModePtr dest, } xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Merged \"%s\" (%dx%d) and \"%s\" (%dx%d) to %dx%d%s\n", - i->name, i->HDisplay, i->VDisplay, j->name, j->HDisplay, j->VDisplay, + "Merged %dx%d and %dx%d to %dx%d%s\n", + i->HDisplay, i->VDisplay, j->HDisplay, j->VDisplay, mode->HDisplay, mode->VDisplay, (srel == radeonClone) ? " (Clone)" : ""); mode->next = mode; @@ -249,7 +242,7 @@ RADEONCopyModeNLink(ScrnInfoPtr pScrn, DisplayModePtr dest, } /* Helper function to find a mode from a given name - * (Taken from mga, sis drivers) + * (Taken from mga driver) */ static DisplayModePtr RADEONGetModeFromName(char* str, DisplayModePtr i) @@ -335,7 +328,7 @@ RADEONGenerateModeListFromLargestModes(ScrnInfoPtr pScrn, } /* Generate the merged-fb mode modelist - * (Taken from mga, sis drivers) + * (Taken from mga driver) */ static DisplayModePtr RADEONGenerateModeListFromMetaModes(ScrnInfoPtr pScrn, char* str, @@ -344,12 +337,11 @@ RADEONGenerateModeListFromMetaModes(ScrnInfoPtr pScrn, char* str, { char* strmode = str; char modename[256]; - Bool gotdash = FALSE, gotplus = FALSE; + Bool gotdash = FALSE; RADEONScrn2Rel sr; DisplayModePtr mode1 = NULL; DisplayModePtr mode2 = NULL; DisplayModePtr result = NULL; - int myslen; RADEONInfoPtr info = RADEONPTR(pScrn); info->AtLeastOneNonClone = FALSE; @@ -358,29 +350,21 @@ RADEONGenerateModeListFromMetaModes(ScrnInfoPtr pScrn, char* str, switch(*str) { case 0: case '-': - case '+': case ' ': - if(strmode != str) { + if((strmode != str)) { - myslen = str - strmode; - if(myslen > 255) myslen = 255; - strncpy(modename, strmode, myslen); - modename[myslen] = 0; + strncpy(modename, strmode, str - strmode); + modename[str - strmode] = 0; if(gotdash) { - if(mode1 == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Error parsing MetaModes parameter\n"); - return NULL; - } + if(mode1 == NULL) return NULL; mode2 = RADEONGetModeFromName(modename, j); if(!mode2) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Mode \"%s\" is not a supported mode for CRT2\n", modename); xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "\t(Skipping metamode \"%s%s%s\")\n", mode1->name, gotplus ? "+" : "-", modename); + "Skipping metamode \"%s-%s\".\n", mode1->name, modename); mode1 = NULL; - gotplus = FALSE; } } else { mode1 = RADEONGetModeFromName(modename, i); @@ -388,31 +372,25 @@ RADEONGenerateModeListFromMetaModes(ScrnInfoPtr pScrn, char* str, char* tmps = str; xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Mode \"%s\" is not a supported mode for CRT1\n", modename); + gotdash = FALSE; while(*tmps == ' ') tmps++; - /* skip the next mode */ - if((*tmps == '-') || (*tmps == '+')) { + if(*tmps == '-') { /* skip the next mode */ tmps++; - /* skip spaces */ - while(*tmps == ' ') tmps++; - /* skip modename */ - while((*tmps != ' ') && (*tmps != '-') && (*tmps != '+') && (*tmps != 0)) tmps++; - myslen = tmps - strmode; - if(myslen > 255) myslen = 255; - strncpy(modename,strmode,myslen); - modename[myslen] = 0; + while((*tmps == ' ') && (*tmps != 0)) tmps++; /* skip spaces */ + while((*tmps != ' ') && (*tmps != '-') && (*tmps != 0)) tmps++; /* skip modename */ + strncpy(modename,strmode,tmps - strmode); + modename[tmps - strmode] = 0; str = tmps-1; } xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "\t(Skipping metamode \"%s\")\n", modename); + "Skipping metamode \"%s\".\n", modename); mode1 = NULL; - gotplus = FALSE; } } gotdash = FALSE; } strmode = str + 1; - gotdash |= ((*str == '-') || (*str == '+')); - gotplus |= (*str == '+'); + gotdash |= (*str == '-'); if(*str != 0) break; /* Fall through otherwise */ @@ -420,23 +398,21 @@ RADEONGenerateModeListFromMetaModes(ScrnInfoPtr pScrn, char* str, default: if(!gotdash && mode1) { sr = srel; - if(gotplus) sr = radeonClone; if(!mode2) { mode2 = RADEONGetModeFromName(mode1->name, j); sr = radeonClone; } if(!mode2) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Mode \"%s\" is not a supported mode for CRT2\n", mode1->name); + "Mode: \"%s\" is not a supported mode for CRT2\n", mode1->name); xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "\t(Skipping metamode \"%s\")\n", modename); + "Skipping metamode \"%s\".\n"); mode1 = NULL; } else { result = RADEONCopyModeNLink(pScrn, result, mode1, mode2, sr); mode1 = NULL; mode2 = NULL; } - gotplus = FALSE; } break; @@ -1000,14 +976,12 @@ RADEONXineramaExtensionInit(ScrnInfoPtr pScrn) return; } -#ifdef PANORAMIX if(!noPanoramiXExtension) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Xinerama active, not initializing Radeon Pseudo-Xinerama\n"); RADEONnoPanoramiXExtension = TRUE; return; } -#endif if(RADEONnoPanoramiXExtension) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -1444,14 +1418,6 @@ RADEONChooseCursorCRTC(ScrnInfoPtr pScrn1, int x, int y) ((RADEONMergedDisplayModePtr)info->CurrentLayout.mode->Private)->CRT2Position; ScrnInfoPtr pScrn2 = info->CRT2pScrn; - /* - Note: we need WaitForIdle here because OUTREGP() involves an INREG() to obtain a previous - value. This fix is needed for RV350 + 3d driver (or we get a lockup otherwise). - - It is also indicated by documentation (we should not be doing INREG if CP engine is active) - */ - RADEONWaitForIdleMMIO(pScrn1); - if (srel == radeonClone) { /* show cursor 2 */ OUTREGP(RADEON_CRTC2_GEN_CNTL, RADEON_CRTC2_CUR_EN, |