diff options
-rw-r--r-- | src/savage_accel.c | 36 | ||||
-rw-r--r-- | src/savage_bci.h | 47 | ||||
-rw-r--r-- | src/savage_cursor.c | 62 | ||||
-rw-r--r-- | src/savage_driver.c | 458 | ||||
-rw-r--r-- | src/savage_driver.h | 230 | ||||
-rw-r--r-- | src/savage_image.c | 6 | ||||
-rw-r--r-- | src/savage_regs.h | 376 | ||||
-rw-r--r-- | src/savage_streams.c | 461 | ||||
-rw-r--r-- | src/savage_streams.h | 177 | ||||
-rw-r--r-- | src/savage_vbe.c | 132 | ||||
-rw-r--r-- | src/savage_video.c | 745 |
11 files changed, 1233 insertions, 1497 deletions
diff --git a/src/savage_accel.c b/src/savage_accel.c index 9cf3fdc..680ae1e 100644 --- a/src/savage_accel.c +++ b/src/savage_accel.c @@ -23,6 +23,7 @@ #include "savage_driver.h" #include "savage_regs.h" #include "savage_bci.h" +#include "savage_streams.h" /* Forward declaration of functions used in the driver */ @@ -47,7 +48,7 @@ static void SavageSetupForSolidFill( ScrnInfoPtr pScrn, int color, int rop, - unsigned planemask); + unsigned int planemask); static void SavageSubsequentSolidFillRect( ScrnInfoPtr pScrn, @@ -82,7 +83,7 @@ static void SavageSetupForScreenToScreenColorExpand( int bg, int fg, int rop, - unsigned planemask); + unsigned int planemask); static void SavageSubsequentScreenToScreenColorExpand( ScrnInfoPtr pScrn, @@ -98,7 +99,7 @@ static void SavageSetupForCPUToScreenColorExpandFill( int fg, int bg, int rop, - unsigned planemask); + unsigned int planemask); static void SavageSubsequentScanlineCPUToScreenColorExpandFill( ScrnInfoPtr pScrn, @@ -119,7 +120,7 @@ static void SavageSetupForMono8x8PatternFill( int fg, int bg, int rop, - unsigned planemask); + unsigned int planemask); static void SavageSubsequentMono8x8PatternFillRect( ScrnInfoPtr pScrn, @@ -421,7 +422,10 @@ SavageInitAccel(ScreenPtr pScreen) #if 1 xaaptr->SetupForScreenToScreenCopy = SavageSetupForScreenToScreenCopy; xaaptr->SubsequentScreenToScreenCopy = SavageSubsequentScreenToScreenCopy; - xaaptr->ScreenToScreenCopyFlags = NO_TRANSPARENCY | NO_PLANEMASK | ROP_NEEDS_SOURCE; + xaaptr->ScreenToScreenCopyFlags = 0 + | NO_TRANSPARENCY + | NO_PLANEMASK + | ROP_NEEDS_SOURCE; #endif @@ -492,7 +496,7 @@ SavageInitAccel(ScreenPtr pScreen) xaaptr->SubsequentSolidFillTrap = SavageSubsequentSolidFillTrap; #endif - xaaptr->SolidBresenhamLineErrorTermBits = 14; + xaaptr->SolidBresenhamLineErrorTermBits = 13; #endif /* ImageWrite */ @@ -594,7 +598,7 @@ SavageAccelSync(ScrnInfoPtr pScrn) */ static int -SavageHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop) +SavageHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, unsigned int pm, int *rop) { XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); int ret = 0; @@ -629,7 +633,7 @@ SavageHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop) static int -SavageHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop) +SavageHelpSolidROP(ScrnInfoPtr pScrn, int *fg, unsigned int pm, int *rop) { XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn); int ret = 0; @@ -722,7 +726,7 @@ SavageSubsequentScreenToScreenCopy( psav->WaitQueue(psav,6); BCI_SEND(psav->SavedBciCmd); - if (psav->SavedBgColor != -1) + if (psav->SavedBgColor != 0xffffffff) BCI_SEND(psav->SavedBgColor); BCI_SEND(BCI_X_Y(x1, y1)); BCI_SEND(BCI_X_Y(x2, y2)); @@ -739,7 +743,7 @@ SavageSetupForSolidFill( ScrnInfoPtr pScrn, int color, int rop, - unsigned planemask) + unsigned int planemask) { SavagePtr psav = SAVPTR(pScrn); XAAInfoRecPtr xaaptr = GET_XAAINFORECPTR_FROM_SCRNINFOPTR( pScrn ); @@ -756,7 +760,7 @@ SavageSetupForSolidFill( { if( color == 0 ) rop = GXclear; - else if( color == xaaptr->FullPlanemask ) + else if( (unsigned int)color == xaaptr->FullPlanemask ) rop = GXset; } @@ -802,7 +806,7 @@ SavageSetupForScreenToScreenColorExpand( int bg, int fg, int rop, - unsigned planemask) + unsigned int planemask) { /* SavagePtr psav = SAVPTR(pScrn); */ } @@ -827,7 +831,7 @@ SavageSetupForCPUToScreenColorExpandFill( int fg, int bg, int rop, - unsigned planemask) + unsigned int planemask) { SavagePtr psav = SAVPTR(pScrn); int cmd; @@ -877,7 +881,7 @@ SavageSubsequentScanlineCPUToScreenColorExpandFill( w = (w + 31) & ~31; if( psav->SavedBciCmd & BCI_CMD_SEND_COLOR ) BCI_SEND(psav->SavedFgColor); - if( psav->SavedBgColor != -1 ) + if( psav->SavedBgColor != 0xffffffff ) BCI_SEND(psav->SavedBgColor); BCI_SEND(BCI_X_Y(x, y)); BCI_SEND(BCI_W_H(w, 1)); @@ -929,7 +933,7 @@ SavageSetupForMono8x8PatternFill( int fg, int bg, int rop, - unsigned planemask) + unsigned int planemask) { SavagePtr psav = SAVPTR(pScrn); int cmd; @@ -980,7 +984,7 @@ SavageSubsequentMono8x8PatternFillRect( BCI_SEND(psav->SavedBciCmd); if( psav->SavedBciCmd & BCI_CMD_SEND_COLOR ) BCI_SEND(psav->SavedFgColor); - if( psav->SavedBgColor != -1 ) + if( psav->SavedBgColor != 0xffffffff ) BCI_SEND(psav->SavedBgColor); BCI_SEND(BCI_X_Y(x, y)); BCI_SEND(BCI_W_H(w, h)); diff --git a/src/savage_bci.h b/src/savage_bci.h index 2e58de2..0c57957 100644 --- a/src/savage_bci.h +++ b/src/savage_bci.h @@ -1,45 +1,8 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_bci.h,v 1.2 2001/10/01 13:44:09 eich Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_bci.h,v 1.3 2002/05/14 20:19:51 alanh Exp $ */ #ifndef _S3BCI_H_ #define _S3BCI_H_ - -/* BCI Control Register */ -#define S3_BCI_CONTROL 0x816C - -/* - * High 8 bit of primary bitmap descriptor 2 register. - * Bits 25-24: Tile Format 00 = Linear ; 10 = 16 bits; 11 = 32 bits (Savage4) - * 00 = Linear ; 01 = Tile; 10 = Texture tiling format/ Destination Tiling format - * 11 = Reserved/Destination tiling format. - */ - - - -#define TILE_LINEAR 0 -#define TILE_FORMAT_LINEAR 0 -#define TILE_TEXTURE 2 -#define TILE_DESTINATION 1 -#define TILE_FORMAT_DESTINATION16 2 -#define TILE_FORMAT_DESTINATION32 3 - -/* BD - BCI enable */ -/* savage4, MX, IX, 3D */ -#define BCI_ENABLE 8 -/* twister, prosavage */ -/* not sure which one supersavage fits into */ -#define BCI_ENABLE_TWISTER 0 - -#define S3_BIG_ENDIAN 4 -#define S3_LITTLE_ENDIAN 0 -#define S3_BD64 1 - - - -/* Global Bitmap Descriptor */ -#define S3_BCI_GLB_BD_LOW 0x8168 -#define S3_BCI_GLB_BD_HIGH 0x816C - #define REVERSE_BYTE_ORDER32(dword) {\ unsigned int temp; \ dword = (temp & 0xFF) << 24; \ @@ -47,10 +10,10 @@ dword |= (temp & 0xFF0000) >> 8; \ dword |= (temp & 0xFF000000) >> 24; } -#define BCI_GET_PTR volatile unsigned int * bci_ptr = (unsigned int *) psav->BciMem -#define BCI_RESET bci_ptr = (unsigned int *) psav->BciMem +#define BCI_GET_PTR volatile CARD32 * bci_ptr = (CARD32 *) psav->BciMem +#define BCI_RESET bci_ptr = (CARD32 *) psav->BciMem -#define BCI_SEND(dw) (*bci_ptr++ = (unsigned int)(dw)) +#define BCI_SEND(dw) (*bci_ptr++ = (CARD32)(dw)) #define BCI_CMD_NOP 0x40000000 #define BCI_CMD_RECT 0x48000000 @@ -108,7 +71,7 @@ #define BCI_BD_TILE_MASK 0x03000000 #define BCI_BD_TILE_NONE 0x00000000 #define BCI_BD_TILE_16 0x02000000 -#define BCI_BD_TILE_32 0x03000000 +#define BCI_BD_TILE_32 0x04000000 #define BCI_BD_GET_BPP(bd) (((bd) >> 16) & 0xFF) #define BCI_BD_SET_BPP(bd, bpp) ((bd) |= (((bpp) & 0xFF) << 16)) #define BCI_BD_GET_STRIDE(bd) ((bd) & 0xFFFF) diff --git a/src/savage_cursor.c b/src/savage_cursor.c index 614b3e5..ad4aa9f 100644 --- a/src/savage_cursor.c +++ b/src/savage_cursor.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_cursor.c,v 1.6 2001/11/02 16:24:51 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_cursor.c,v 1.7 2002/05/14 20:19:51 alanh Exp $ */ /* * Hardware cursor support for S3 Savage 4.0 driver. Taken with @@ -24,9 +24,7 @@ static void SavageSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg); #define outCRReg(reg, val) (VGAHWPTR(pScrn))->writeCrtc( VGAHWPTR(pScrn), reg, val ) #define inSRReg(reg) (VGAHWPTR(pScrn))->readSeq( VGAHWPTR(pScrn), reg ) #define outSRReg(reg, val) (VGAHWPTR(pScrn))->writeSeq( VGAHWPTR(pScrn), reg, val ) -#if 0 #define inStatus1() (VGAHWPTR(pScrn))->readST01( VGAHWPTR(pScrn) ) -#endif /* * certain HW cursor operations seem @@ -41,6 +39,27 @@ static void SavageSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg); } #define MAX_CURS 64 +/* + * Disable HW Cursor on stretched LCDs. We don't know how to + * detect if display is stretched. Therefore we cannot rescale + * the HW cursor position. + */ + +static Bool +SavageUseHWCursor(ScreenPtr pScr, CursorPtr pCurs) +{ + ScrnInfoPtr pScrn = xf86Screens[pScr->myNum]; + SavagePtr psav = SAVPTR(pScrn); + + if (psav->PanelX != pScrn->currentMode->HDisplay + || psav->PanelY != pScrn->currentMode->VDisplay) { + /* BIT 1 : CRT is active, BIT 2 : LCD is active */ + unsigned char cr6d = inCRReg( 0x6d ); + if (cr6d & 0x02) + return FALSE; + } + return TRUE; +} Bool SavageHWCursorInit(ScreenPtr pScreen) @@ -62,7 +81,7 @@ SavageHWCursorInit(ScreenPtr pScreen) HARDWARE_CURSOR_AND_SOURCE_WITH_MASK | HARDWARE_CURSOR_BIT_ORDER_MSBFIRST | HARDWARE_CURSOR_INVERT_MASK; - +#if 0 /* * The /MX family is apparently unique among the Savages, in that * the cursor color is always straight RGB. The rest of the Savages @@ -75,15 +94,22 @@ SavageHWCursorInit(ScreenPtr pScreen) || S3_SAVAGE_MOBILE_SERIES(psav->Chipset) ) - infoPtr->Flags |= HARDWARE_CURSOR_TRUECOLOR_AT_8BPP; + infoPtr->Flags |= HARDWARE_CURSOR_TRUECOLOR_AT_8BPP; +#endif + /* With streams engine the Cursor seems to be ALWAYS TrueColor */ + infoPtr->Flags |= HARDWARE_CURSOR_TRUECOLOR_AT_8BPP; infoPtr->SetCursorColors = SavageSetCursorColors; infoPtr->SetCursorPosition = SavageSetCursorPosition; infoPtr->LoadCursorImage = SavageLoadCursorImage; infoPtr->HideCursor = SavageHideCursor; infoPtr->ShowCursor = SavageShowCursor; - infoPtr->UseHWCursor = NULL; + if ((S3_SAVAGE_MOBILE_SERIES(psav->Chipset) + || (psav->Chipset == S3_PROSAVAGE)) && !psav->CrtOnly) + infoPtr->UseHWCursor = SavageUseHWCursor; + else + infoPtr->UseHWCursor = NULL; if( !psav->CursorKByte ) psav->CursorKByte = pScrn->videoRam - 4; @@ -95,8 +121,9 @@ SavageHWCursorInit(ScreenPtr pScreen) void SavageShowCursor(ScrnInfoPtr pScrn) { - /* Turn cursor on. */ + /* Turn cursor on. */ outCRReg( 0x45, inCRReg(0x45) | 0x01 ); + SAVPTR(pScrn)->hwc_on = TRUE; } @@ -104,12 +131,12 @@ void SavageHideCursor(ScrnInfoPtr pScrn) { /* Turn cursor off. */ - if( S3_SAVAGE4_SERIES( SAVPTR(pScrn)->Chipset ) ) { waitHSync(5); } outCRReg( 0x45, inCRReg(0x45) & 0xfe ); + SAVPTR(pScrn)->hwc_on = FALSE; } static void @@ -120,8 +147,8 @@ SavageLoadCursorImage( SavagePtr psav = SAVPTR(pScrn); /* Set cursor location in frame buffer. */ - outCRReg( 0x4d, (0xff & psav->CursorKByte)); - outCRReg( 0x4c, (0xff00 & psav->CursorKByte) >> 8); + outCRReg( 0x4d, (0xff & (CARD32)psav->CursorKByte)); + outCRReg( 0x4c, (0xff00 & (CARD32)psav->CursorKByte) >> 8); /* Upload the cursor image to the frame buffer. */ memcpy(psav->FBBase + psav->CursorKByte * 1024, src, 1024); @@ -201,11 +228,14 @@ SavageSetCursorColors( bNeedExtra = (psav->CursorInfoRec->Flags & HARDWARE_CURSOR_TRUECOLOR_AT_8BPP); - if( - S3_SAVAGE_MOBILE_SERIES(psav->Chipset) || - (pScrn->depth == 24) || - ((pScrn->depth == 8) && bNeedExtra) - ) + /* With the streams engine on HW Cursor seems to be 24bpp ALWAYS */ + if( 1 +#if 0 + || S3_SAVAGE_MOBILE_SERIES(psav->Chipset) || + (pScrn->depth == 24) || + ((pScrn->depth == 8) && bNeedExtra) +#endif + ) { /* Do it straight, full 24 bit color. */ @@ -223,6 +253,7 @@ SavageSetCursorColors( outCRReg(0x4b, bg >> 16); return; } +#if 0 else if( (pScrn->depth == 15) || (pScrn->depth == 16) ) { if (pScrn->depth == 15) { @@ -272,4 +303,5 @@ SavageSetCursorColors( outCRReg(0x4b, bg); outCRReg(0x4b, bg); } +#endif } diff --git a/src/savage_driver.c b/src/savage_driver.c index 4a6cc2c..4a0ec2b 100644 --- a/src/savage_driver.c +++ b/src/savage_driver.c @@ -24,6 +24,7 @@ #include "savage_driver.h" #include "savage_bci.h" +#define TRANSPARENCY_KEY 0xff; /* * prototypes @@ -60,6 +61,7 @@ static void SavageLoadPalette(ScrnInfoPtr pScrn, int numColors, static void SavageLoadPaletteSavage4(ScrnInfoPtr pScrn, int numColors, int *indicies, LOCO *colors, VisualPtr pVisual); +static void SavageUpdateKey(ScrnInfoPtr pScrn, int r, int g, int b); static void SavageCalcClock(long freq, int min_m, int min_n1, int max_n1, int min_n2, int max_n2, long freq_min, long freq_max, unsigned int *mdiv, @@ -175,24 +177,26 @@ static PciChipsets SavagePciChipsets[] = { }; typedef enum { - OPTION_PCI_BURST - ,OPTION_PCI_RETRY - ,OPTION_NOACCEL - ,OPTION_LCD_CENTER - ,OPTION_LCDCLOCK - ,OPTION_MCLK - ,OPTION_REFCLK - ,OPTION_SHOWCACHE - ,OPTION_SWCURSOR - ,OPTION_HWCURSOR - ,OPTION_SHADOW_FB - ,OPTION_ROTATE - ,OPTION_USEBIOS - ,OPTION_SHADOW_STATUS - ,OPTION_CRT_ONLY - ,OPTION_TV_ON - ,OPTION_TV_PAL - ,OPTION_FORCE_INIT + OPTION_PCI_BURST, + OPTION_PCI_RETRY, + OPTION_NOACCEL, + OPTION_LCD_CENTER, + OPTION_LCDCLOCK, + OPTION_MCLK, + OPTION_REFCLK, + OPTION_SHOWCACHE, + OPTION_SWCURSOR, + OPTION_HWCURSOR, + OPTION_SHADOW_FB, + OPTION_ROTATE, + OPTION_USEBIOS, + OPTION_SHADOW_STATUS, + OPTION_CRT_ONLY, + OPTION_TV_ON, + OPTION_TV_PAL, + OPTION_FORCE_INIT, + OPTION_OVERLAY, + OPTION_T_KEY } SavageOpts; @@ -210,6 +214,8 @@ static const OptionInfoRec SavageOptions[] = { OPTION_TV_ON, "TvOn", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_TV_PAL, "PAL", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_FORCE_INIT,"ForceInit", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_OVERLAY, "Overlay", OPTV_ANYSTR, {0}, FALSE }, + { OPTION_T_KEY, "TransparencyKey", OPTV_ANYSTR, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE } }; @@ -247,6 +253,13 @@ static const char *ramdacSymbols[] = { NULL }; +static const char *int10Symbols[] = { + "xf86ExecX86int10", + "xf86Int10AllocPages", + "xf86int10Addr", + "xf86Int10FreePages" +}; + static const char *vbeSymbols[] = { "VBEInit", "vbeDoEDID", @@ -288,6 +301,7 @@ static const char *xaaSymbols[] = { "XAAHelpPatternROP", "XAAHelpSolidROP", "XAAInit", + "XAAScreenIndex", NULL }; @@ -296,18 +310,6 @@ static const char *shadowSymbols[] = { NULL }; -static const char *int10Symbols[] = { - "xf86ExecX86int10", -#if 0 - "xf86FreeInt10", -#endif - "xf86InitInt10", - "xf86Int10AllocPages", - "xf86Int10FreePages", - "xf86int10Addr", - NULL -}; - static const char *fbSymbols[] = { "fbPictureInit", "fbScreenInit", @@ -398,7 +400,7 @@ ShadowWait( SavagePtr psav ) BCI_SEND( 0x98000000 + psav->ShadowCounter ); while( - (psav->ShadowVirtual[1] & 0x7fff) != psav->ShadowCounter && + (int)(psav->ShadowVirtual[1] & 0x7fff) != psav->ShadowCounter && (loop++ < MAXLOOP) ) ; @@ -419,7 +421,7 @@ static int WaitQueue3D( SavagePtr psav, int v ) { int loop = 0; - int slots = MAXFIFO - v; + CARD32 slots = MAXFIFO - v; mem_barrier(); if( psav->ShadowVirtual ) @@ -440,7 +442,7 @@ static int WaitQueue4( SavagePtr psav, int v ) { int loop = 0; - int slots = MAXFIFO - v; + CARD32 slots = MAXFIFO - v; if( !psav->NoPCIRetry ) return 0; @@ -460,7 +462,7 @@ static int WaitQueue2K( SavagePtr psav, int v ) { int loop = 0; - int slots = MAXFIFO - v; + CARD32 slots = MAXFIFO - v; if( !psav->NoPCIRetry ) return 0; @@ -828,6 +830,8 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: shadow FB enabled\n"); } + psav->primStreamBpp = pScrn->bitsPerPixel; + if ((s = xf86GetOptValString(psav->Options, OPTION_ROTATE))) { if(!xf86NameCmp(s, "CW")) { /* accel is disabled below for shadowFB */ @@ -858,6 +862,48 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) psav->NoAccel = TRUE; } + if ((s = xf86GetOptValString(psav->Options, OPTION_OVERLAY))) { + + if (psav->shadowFB) { + xf86DrvMsg(pScrn->scrnIndex,X_INFO, + "Option \"Overlay\" not supported with shadowFB\n"); + } else { + if (pScrn->depth == 8) { + if (!*s || !xf86NameCmp(s, "24")) { + psav->overlayDepth = 24; + psav->NoAccel = TRUE; /* Preliminary */ + pScrn->colorKey = TRANSPARENCY_KEY; + pScrn->overlayFlags = OVERLAY_8_32_DUALFB; + } else if (!xf86NameCmp(s, "16")) { + psav->overlayDepth = 16; + psav->NoAccel = TRUE; /* Preliminary */ + pScrn->colorKey = TRANSPARENCY_KEY; + pScrn->overlayFlags = OVERLAY_8_32_DUALFB; + } else { + xf86DrvMsg(pScrn->scrnIndex,X_WARNING,"Wrong argument: " + "\"%s\" Ingnoring\n",s); + } + } else if (pScrn->depth != 15) { + psav->overlayDepth = 8; + psav->NoAccel = TRUE; /* Preliminary */ + pScrn->colorKey = TRANSPARENCY_KEY; + pScrn->overlayFlags = OVERLAY_8_32_DUALFB; + if (*s && (xf86NameCmp(s, "8"))) + xf86DrvMsg(pScrn->scrnIndex,X_WARNING,"Wrong argument: " + "\"%s\" for depth %i overlay depth must be 8\n", + s,pScrn->depth); + } else { + xf86DrvMsg(pScrn->scrnIndex,X_WARNING,"Overlay not " + "supported for depth 15\n"); + } + if (psav->overlayDepth) { + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"%i/%i Overlay enabled\n", + pScrn->depth,psav->overlayDepth); + psav->primStreamBpp = 8; + } + } + } + if (pScrn->bitsPerPixel == 24 && !psav->NoAccel) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "HW acceleration not possible with depth 32 and bpp 24.\n"); @@ -937,15 +983,10 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) return FALSE; } psav->EntityIndex = pEnt->index; - - if (xf86LoadSubModule(pScrn, "int10")) { - xf86LoaderReqSymLists(int10Symbols, NULL); - psav->pInt10 = xf86InitInt10(pEnt->index); - } - + if (xf86LoadSubModule(pScrn, "vbe")) { xf86LoaderReqSymLists(vbeSymbols, NULL); - psav->pVbe = VBEInit(psav->pInt10, pEnt->index); + psav->pVbe = VBEInit(NULL, pEnt->index); } @@ -1002,6 +1043,7 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) if (!SavageMapMMIO(pScrn)) { SavageFreeRec(pScrn); vbeFree(psav->pVbe); + psav->pVbe = NULL; return FALSE; } @@ -1032,6 +1074,7 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) if (!xf86SetGamma(pScrn, zeros)) { vbeFree(psav->pVbe); + psav->pVbe = NULL; SavageFreeRec(pScrn); return FALSE; } @@ -1103,6 +1146,41 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) pScrn->videoRam); } + /* Do the DDC dance. */ + + { + ddc = xf86LoadSubModule(pScrn, "ddc"); + if (ddc) { + xf86MonPtr pMon = NULL; + + xf86LoaderReqSymLists(ddcSymbols, NULL); +/* + * On many machines, the attempt to read DDC information via VBE puts the + * BIOS access into a state which prevents me from reading mode information. + * This is a complete mystery to me. + */ + if ((psav->pVbe) + && ((pMon = xf86PrintEDID(vbeDoEDID(psav->pVbe, ddc))) != NULL)) + xf86SetDDCproperties(pScrn,pMon); + else if (( psav->Chipset != S3_PROSAVAGE ) + && !SavageDDC1(pScrn->scrnIndex)) { + if ( xf86LoadSubModule(pScrn, "i2c") ) { + xf86LoaderReqSymLists(i2cSymbols,NULL); + if (SavageI2CInit(pScrn)) { + unsigned char tmp; + + InI2CREG(psav,tmp); + OutI2CREG(psav,tmp | 0x13); + xf86SetDDCproperties(pScrn,xf86PrintEDID( + xf86DoEDID_DDC2(pScrn->scrnIndex,psav->I2C))); + OutI2CREG(psav,tmp); + } + } + } + } + } + + /* Get video RAM */ if( !pScrn->videoRam && psav->pVbe ) { /* If VBE is available, ask it about onboard memory. */ @@ -1202,44 +1280,6 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) break; } - /* Do the DDC dance. */ - - if( psav->Chipset != S3_PROSAVAGE ) { - ddc = xf86LoadSubModule(pScrn, "ddc"); - if (ddc) { -#if 0 - xf86MonPtr pMon = NULL; -#endif - - xf86LoaderReqSymLists(ddcSymbols, NULL); -#if 0 -/* - * On many machines, the attempt to read DDC information via VBE puts the - * BIOS access into a state which prevents me from reading mode information. - * This is a complete mystery to me. - */ - if ((psav->pVbe) - && ((pMon = xf86PrintEDID(vbeDoEDID(psav->pVbe, ddc))) != NULL)) - xf86SetDDCproperties(pScrn,pMon); - else -#endif - if (!SavageDDC1(pScrn->scrnIndex)) { - if ( xf86LoadSubModule(pScrn, "i2c") ) { - xf86LoaderReqSymLists(i2cSymbols,NULL); - if (SavageI2CInit(pScrn)) { - unsigned char tmp; - - InI2CREG(psav,tmp); - OutI2CREG(psav,tmp | 0x13); - xf86SetDDCproperties(pScrn,xf86PrintEDID( - xf86DoEDID_DDC2(pScrn->scrnIndex,psav->I2C))); - OutI2CREG(psav,tmp); - } - } - } - } - } - /* Savage ramdac speeds */ pScrn->numClocks = 4; pScrn->clock[0] = 250000; @@ -1374,6 +1414,7 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "xf86ValidateModes failure\n"); SavageFreeRec(pScrn); vbeFree(psav->pVbe); + psav->pVbe = NULL; return FALSE; } @@ -1383,6 +1424,7 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); SavageFreeRec(pScrn); vbeFree(psav->pVbe); + psav->pVbe = NULL; return FALSE; } @@ -1395,7 +1437,7 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) SavageFreeBIOSModeTable( psav, &psav->ModeTable ); } - psav->ModeTable = SavageGetBIOSModeTable( psav, pScrn->bitsPerPixel ); + psav->ModeTable = SavageGetBIOSModeTable( psav, psav->primStreamBpp ); if( !psav->ModeTable || !psav->ModeTable->NumModes ) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, @@ -1436,6 +1478,7 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) if (xf86LoadSubModule(pScrn, "fb") == NULL) { SavageFreeRec(pScrn); vbeFree(psav->pVbe); + psav->pVbe = NULL; return FALSE; } @@ -1445,6 +1488,7 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) if( !xf86LoadSubModule(pScrn, "xaa") ) { SavageFreeRec(pScrn); vbeFree(psav->pVbe); + psav->pVbe = NULL; return FALSE; } xf86LoaderReqSymLists(xaaSymbols, NULL ); @@ -1454,6 +1498,7 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) if (!xf86LoadSubModule(pScrn, "ramdac")) { SavageFreeRec(pScrn); vbeFree(psav->pVbe); + psav->pVbe = NULL; return FALSE; } xf86LoaderReqSymLists(ramdacSymbols, NULL); @@ -1463,12 +1508,15 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags) if (!xf86LoadSubModule(pScrn, "shadowfb")) { SavageFreeRec(pScrn); vbeFree(psav->pVbe); + psav->pVbe = NULL; return FALSE; } xf86LoaderReqSymLists(shadowSymbols, NULL); } vbeFree(psav->pVbe); + psav->pVbe = NULL; + return TRUE; } @@ -1501,6 +1549,7 @@ static void SavageLeaveVT(int scrnIndex, int flags) TRACE(("SavageLeaveVT(%d)\n", flags)); gpScrn = pScrn; + SavageStreamsOff(pScrn); SavageWriteMode(pScrn, vgaSavePtr, SavageSavePtr, FALSE); SavageDisableMMIO(pScrn); } @@ -1746,6 +1795,10 @@ static void SavageWriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, VGAOUT8(vgaCRIndex, 0x53); VGAOUT8(vgaCRReg, VGAIN8(vgaCRReg) & ~0x10); + /* Disable HW cursor */ + + VGAOUT16(vgaCRIndex, 0x0045); + /* Set the color mode. */ VGAOUT8(vgaCRIndex, 0x67); @@ -1754,7 +1807,8 @@ static void SavageWriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, /* Enable gamma correction. */ VGAOUT8(0x3c4, 0x1b); - if( (pScrn->bitsPerPixel == 32) && !psav->DGAactive ) + if( (pScrn->bitsPerPixel == 32) && !psav->DGAactive + && ! psav->FBStart2nd ) VGAOUT8(0x3c5, 0x28 ); else VGAOUT8(0x3c5, 0x00 ); @@ -1776,7 +1830,7 @@ static void SavageWriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, if( pScrn->displayWidth >= 1024 ) { - if(pScrn->bitsPerPixel == 32 ) + if(psav->primStreamBpp == 32 ) { if( restore->refresh >= 130 ) cr79 = 0x03; @@ -1793,7 +1847,7 @@ static void SavageWriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, cr79 = 0x08; } } - else if( pScrn->bitsPerPixel == 16) + else if( psav->primStreamBpp == 16) { /* The windows driver uses 0x13 for 16-bit 130Hz, but I see terrible @@ -1830,7 +1884,7 @@ static void SavageWriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, VGAOUT8(vgaCRIndex, 0x50); VGAOUT8(vgaCRReg, VGAIN8(vgaCRReg) | 0xC1); - width = (pScrn->displayWidth * (pScrn->bitsPerPixel / 8)) >> 3; + width = (pScrn->displayWidth * (psav->primStreamBpp / 8)) >> 3; VGAOUT16(vgaCRIndex, ((width & 0xff) << 8) | 0x13 ); VGAOUT16(vgaCRIndex, ((width & 0x300) << 4) | 0x51 ); @@ -1901,7 +1955,7 @@ static void SavageWriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, * switch to mode 3 here seems to eliminate the issue. */ - if( ((restore->CR31 & 0x0a) == 0) && psav->pInt10 ) { + if( ((restore->CR31 & 0x0a) == 0) && psav->pVbe ) { SavageSetTextMode( psav ); } @@ -2173,7 +2227,7 @@ static Bool SavageMapMMIO(ScrnInfoPtr pScrn) return TRUE; } - +#define TRANSPARENCY_KEY 0xff; static Bool SavageMapFB(ScrnInfoPtr pScrn) { @@ -2246,6 +2300,7 @@ static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, SavagePtr psav; EntityInfoPtr pEnt; int ret; + int colormapFlags; TRACE(("SavageScreenInit()\n")); @@ -2253,13 +2308,27 @@ static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, psav = SAVPTR(pScrn); pEnt = xf86GetEntityInfo(pScrn->entityList[0]); - psav->pVbe = VBEInit(NULL, pEnt->index); + if (!psav->pVbe) + psav->pVbe = VBEInit(NULL, pEnt->index); SavageEnableMMIO(pScrn); if (!SavageMapFB(pScrn)) return FALSE; + psav->FBStart2nd = 0; + + if (psav->overlayDepth) { + if ((pScrn->virtualX * pScrn->virtualY * + (DEPTH_BPP(DEPTH_2ND(pScrn))) >> 3) + > (psav->CursorKByte * 1024)) + xf86DrvMsg(pScrn->scrnIndex,X_WARNING, + "Not enough memory for overlay mode: disabling\n"); + else psav->FBStart2nd = psav->FBStart + + ((pScrn->virtualX * pScrn->virtualY + 0xff) & ~0xff); + + } + if( psav->ShadowStatus ) { psav->ShadowPhysical = psav->FrameBufferBase + psav->CursorKByte*1024 + 4096 - 32; @@ -2291,19 +2360,27 @@ static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, miClearVisualTypes(); - if (pScrn->bitsPerPixel == 16) { - if (!miSetVisualTypes(pScrn->depth, TrueColorMask, - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; - if (!miSetPixmapDepths ()) - return FALSE; - } else { - if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), - pScrn->rgbBits, pScrn->defaultVisual)) - return FALSE; - if (!miSetPixmapDepths ()) - return FALSE; - } + { + int visual; + + visual = ((psav->FBStart2nd && pScrn->bitsPerPixel > 8) + || pScrn->bitsPerPixel == 16) ? TrueColorMask + : miGetDefaultVisualMask(DEPTH_BPP(pScrn->depth)); + if (!miSetVisualTypes(pScrn->depth, visual, + pScrn->rgbBits, pScrn->defaultVisual)) + return FALSE; + + if (psav->FBStart2nd) {/* we have overlay */ + visual = psav->overlayDepth > 8 ? TrueColorMask : + miGetDefaultVisualMask(DEPTH_BPP(psav->overlayDepth)); + if (!miSetVisualTypes(psav->overlayDepth, visual, + psav->overlayDepth > 8 ? 8 : 6, + pScrn->defaultVisual)) + return FALSE; + } + } + if (!miSetPixmapDepths ()) + return FALSE; ret = SavageInternalScreenInit(scrnIndex, pScreen); if (!ret) @@ -2311,18 +2388,61 @@ static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, xf86SetBlackWhitePixels(pScreen); - if (pScrn->bitsPerPixel > 8) { + { VisualPtr visual; - visual = pScreen->visuals + pScreen->numVisuals; while (--visual >= pScreen->visuals) { - if ((visual->class | DynamicClass) == DirectColor) { - visual->offsetRed = pScrn->offset.red; - visual->offsetGreen = pScrn->offset.green; - visual->offsetBlue = pScrn->offset.blue; - visual->redMask = pScrn->mask.red; - visual->greenMask = pScrn->mask.green; - visual->blueMask = pScrn->mask.blue; + if ((visual->class | DynamicClass) == DirectColor + && visual->nplanes > MAX_PSEUDO_DEPTH) { + if (visual->nplanes == pScrn->depth) { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } else if (visual->offsetRed > 8 + || visual->offsetGreen > 8 + || visual->offsetBlue > 8) { + /* + * mi has set these wrong. fix it here -- we cannot use pScrn + * as this is set up for the default depth 8. + */ + int tmp; + int c_s = 0; + + tmp = visual->offsetBlue; + visual->offsetBlue = visual->offsetRed; + visual->offsetRed = tmp; + tmp = visual->blueMask; + visual->blueMask = visual->redMask; + visual->redMask = tmp; + switch (DEPTH_2ND(pScrn)) { + case 16: + visual->offsetRed = 11; + visual->offsetGreen = 5; + visual->offsetBlue = 0; + visual->redMask = 0xF800; + visual->greenMask = 0x7E0; + visual->blueMask = 0x1F; + break; + case 24: + visual->offsetRed = 16; + visual->offsetGreen = 8; + visual->offsetBlue = 0; + visual->redMask = 0xFF0000; + visual->greenMask = 0xFF00; + visual->blueMask = 0xFF; + c_s = 2; + break; + } + psav->overlay.redMask = visual->redMask; + psav->overlay.greenMask = visual->greenMask; + psav->overlay.blueMask = visual->blueMask; + psav->overlay.redShift = visual->offsetRed + c_s; + psav->overlay.greenShift = visual->offsetGreen + c_s; + psav->overlay.blueShift = visual->offsetBlue + c_s; + } } } } @@ -2370,19 +2490,17 @@ static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, if (!miCreateDefColormap(pScreen)) return FALSE; + colormapFlags = CMAP_RELOAD_ON_MODE_SWITCH + | ((psav->FBStart2nd) ? 0 : CMAP_PALETTED_TRUECOLOR); + if (psav->Chipset == S3_SAVAGE4) { if (!xf86HandleColormaps(pScreen, 256, 6, SavageLoadPaletteSavage4, - NULL, - CMAP_RELOAD_ON_MODE_SWITCH - | CMAP_PALETTED_TRUECOLOR - )) + NULL, colormapFlags )) return FALSE; } else { if (!xf86HandleColormaps(pScreen, 256, 6, SavageLoadPalette, NULL, - CMAP_RELOAD_ON_MODE_SWITCH - | CMAP_PALETTED_TRUECOLOR - )) - return FALSE; + colormapFlags )) + return FALSE; } vgaHWBlankScreen(pScrn, FALSE); @@ -2394,7 +2512,7 @@ static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen, if (xf86DPMSInit(pScreen, SavageDPMS, 0) == FALSE) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "DPMS initialization failed\n"); - if( !psav->NoAccel && !SavagePanningCheck(pScrn) ) + if( !psav->FBStart2nd && !SavagePanningCheck(pScrn) ) SavageInitVideo( pScreen ); if (serverGeneration == 1) @@ -2438,10 +2556,38 @@ static int SavageInternalScreenInit(int scrnIndex, ScreenPtr pScreen) FBStart = psav->FBStart; } - ret = fbScreenInit(pScreen, FBStart, width, height, - pScrn->xDpi, pScrn->yDpi, - displayWidth, - pScrn->bitsPerPixel); + if (!psav->FBStart2nd) { + ret = fbScreenInit(pScreen, FBStart, width, height, + pScrn->xDpi, pScrn->yDpi, + displayWidth, + pScrn->bitsPerPixel); + } else { + FbOverlayScrPrivPtr pScrPriv; + int Depth2nd = DEPTH_2ND(pScrn); + if (!fbSetupScreen (pScreen, FBStart, width, height, + pScrn->xDpi, pScrn->yDpi, displayWidth, 8)) + return FALSE; + if (pScrn->depth == 8) { + ret = fbOverlayFinishScreenInit (pScreen, FBStart, + psav->FBStart2nd, width, + height,pScrn->xDpi, pScrn->yDpi, + displayWidth,displayWidth, + 8, DEPTH_BPP(Depth2nd), + 8, Depth2nd); + pScrPriv = fbOverlayGetScrPriv(pScreen); + pScrPriv->layer[0].key = pScrn->colorKey; + } else { + ret = fbOverlayFinishScreenInit (pScreen, psav->FBStart2nd, + FBStart, + width, height,pScrn->xDpi, + pScrn->yDpi, + displayWidth,displayWidth, + DEPTH_BPP(Depth2nd), 8, + Depth2nd, 8); + pScrPriv = fbOverlayGetScrPriv(pScreen); + pScrPriv->layer[1].key = pScrn->colorKey; + } + } return ret; } @@ -2556,7 +2702,7 @@ static Bool SavageModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) new->CR67 = 0x40; /* 16bpp, 1 pixels/clock */ break; case 24: - if (pScrn->bitsPerPixel == 24 ) + if (psav->primStreamBpp == 24 ) new->CR67 = 0x70; else new->CR67 = 0xd0; @@ -2697,12 +2843,12 @@ static Bool SavageModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) new->SR29 = (r & 4) | (m & 0x100) >> 5 | (n & 0x40) >> 2; if (psav->fifo_moderate) { - if (pScrn->bitsPerPixel < 24) + if (psav->primStreamBpp < 24) new->MMPR0 -= 0x8000; else new->MMPR0 -= 0x4000; } else if (psav->fifo_aggressive) { - if (pScrn->bitsPerPixel < 24) + if (psav->primStreamBpp < 24) new->MMPR0 -= 0xc000; else new->MMPR0 -= 0x6000; @@ -2742,7 +2888,7 @@ static Bool SavageModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) (((mode->CrtcVDisplay - 1) & 0x400) >> 9) | (((mode->CrtcVSyncStart) & 0x400) >> 8) | (((mode->CrtcVSyncStart) & 0x400) >> 6) | 0x40; - width = (pScrn->displayWidth * (pScrn->bitsPerPixel / 8)) >> 3; + width = (pScrn->displayWidth * (psav->primStreamBpp / 8)) >> 3; new->CR91 = vganew->CRTC[19] = 0xff & width; new->CR51 = (0x300 & width) >> 4; new->CR90 = 0x80 | (width >> 8); @@ -2750,9 +2896,9 @@ static Bool SavageModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) /* Set frame buffer description. */ - if (pScrn->bitsPerPixel <= 8) + if (psav->primStreamBpp <= 8) new->CR50 = 0; - else if (pScrn->bitsPerPixel <= 16) + else if (psav->primStreamBpp <= 16) new->CR50 = 0x10; else new->CR50 = 0x30; @@ -2798,6 +2944,11 @@ static Bool SavageModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) /* do it! */ SavageWriteMode(pScrn, vganew, new, TRUE); + SavageStreamsOn(pScrn); + + if (psav->FBStart2nd) + SavageInitSecondaryStream(pScrn); + SavageAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); return TRUE; @@ -2830,6 +2981,7 @@ static Bool SavageCloseScreen(int scrnIndex, ScreenPtr pScreen) } if (pScrn->vtSema) { + SavageStreamsOff(pScrn); SavageWriteMode(pScrn, vgaSavePtr, SavageSavePtr, FALSE); vgaHWLock(hwp); SavageUnmapMem(pScrn, 0); @@ -2853,7 +3005,7 @@ static Bool SavageSaveScreen(ScreenPtr pScreen, int mode) SavageShowCursor( pScrn ); else SavageHideCursor( pScrn ); - SAVPTR(pScrn)->hwc_on = TRUE; + SAVPTR(pScrn)->hwc_on = TRUE; /*restore */ } return vgaHWSaveScreen(pScreen, mode); @@ -2877,7 +3029,7 @@ void SavageAdjustFrame(int scrnIndex, int x, int y, int flags) y += pScrn->virtualY - 1; Base = ((y * pScrn->displayWidth + (x&~1)) * - (pScrn->bitsPerPixel / 8)) >> 2; + (psav->primStreamBpp / 8)) >> 2; /* now program the start address registers */ VGAOUT16(vgaCRIndex, (Base & 0x00ff00) | 0x0c); VGAOUT16(vgaCRIndex, ((Base & 0x00ff) << 8) | 0x0d); @@ -2891,6 +3043,7 @@ void SavageAdjustFrame(int scrnIndex, int x, int y, int flags) Bool SavageSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) { TRACE(("SavageSwitchMode\n")); + SavageStreamsOff(xf86Screens[scrnIndex]); return SavageModeInit(xf86Screens[scrnIndex], mode); } @@ -2953,14 +3106,48 @@ void SavageLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, { SavagePtr psav = SAVPTR(pScrn); int i, index; - + int updateKey = -1; + for (i=0; i<numColors; i++) { index = indicies[i]; + if (index == pScrn->colorKey) updateKey = index; VGAOUT8(0x3c8, index); VGAOUT8(0x3c9, colors[index].red); VGAOUT8(0x3c9, colors[index].green); VGAOUT8(0x3c9, colors[index].blue); } + if (updateKey != -1) + SavageUpdateKey(pScrn, colors[updateKey].red, colors[updateKey].green, + colors[updateKey].blue); +} + +#define Shift(v,d) ((d) < 0 ? ((v) >> (-d)) : ((v) << (d))) + +static void +SavageUpdateKey(ScrnInfoPtr pScrn, int r, int g, int b) +{ + ScreenPtr pScreen; + SavagePtr psav = SAVPTR(pScrn); + FbOverlayScrPrivPtr pScrOvlPriv; + CARD32 key; + int ul = 0, ol = 1; + + if (pScrn->depth != 8) { + ul = 1; + ol = 0; + } + if (!(pScreen = pScrn->pScreen) + || !(pScrOvlPriv = fbOverlayGetScrPriv(pScreen))) + return; + key = ((Shift(r,psav->overlay.redShift) & psav->overlay.redMask) + | (Shift(g,psav->overlay.greenShift) & psav->overlay.greenMask) + | (Shift(b,psav->overlay.blueShift) & psav->overlay.blueMask)); + if (pScrOvlPriv->layer[ol].key != key) { + pScrOvlPriv->layer[ol].key = key; + (*pScrOvlPriv->PaintKey) (&pScrOvlPriv->layer[ol].u.run.pixmap->drawable, + &pScrOvlPriv->layer[ul].u.run.region, + pScrOvlPriv->layer[ol].key, ol); + } } #define inStatus1() (hwp->readST01( hwp )) @@ -2970,7 +3157,8 @@ void SavageLoadPaletteSavage4(ScrnInfoPtr pScrn, int numColors, int *indicies, { SavagePtr psav = SAVPTR(pScrn); int i, index; - + int updateKey = -1; + vgaHWPtr hwp = VGAHWPTR(pScrn); VerticalRetraceWait(psav); @@ -2982,11 +3170,13 @@ void SavageLoadPaletteSavage4(ScrnInfoPtr pScrn, int numColors, int *indicies, VGAOUT8(0x3c9, colors[index].red); VGAOUT8(0x3c9, colors[index].green); VGAOUT8(0x3c9, colors[index].blue); + if (index == pScrn->colorKey) updateKey = index; } + if (updateKey != -1) + SavageUpdateKey(pScrn, colors[updateKey].red, colors[updateKey].green, + colors[updateKey].blue); } - - static void SavageCalcClock(long freq, int min_m, int min_n1, int max_n1, /* Make sure linear addressing is enabled after the BIOS call. */ diff --git a/src/savage_driver.h b/src/savage_driver.h index 712ad00..ccf3972 100644 --- a/src/savage_driver.h +++ b/src/savage_driver.h @@ -1,8 +1,10 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_driver.h,v 1.11 2001/08/09 19:14:13 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_driver.h,v 1.16 2003/01/18 15:22:30 eich Exp $ */ #ifndef SAVAGE_VGAHWMMIO_H #define SAVAGE_VGAHWMMIO_H +#define MODE_24 24 + #include "xf86_ansic.h" #include "compiler.h" #include "vgaHW.h" @@ -15,36 +17,13 @@ #include "mipointer.h" #include "micmap.h" #include "fb.h" +#include "fboverlay.h" #include "xf86cmap.h" #include "vbe.h" #include "xaa.h" #include "xf86xv.h" #include "savage_regs.h" -#include "savage_vbe.h" - -#ifdef XF86DRI -#define _XF86DRI_SERVER_ -#include "savage_dripriv.h" -#include "savage_dri.h" -#include "savage_drm.h" -#include "dri.h" -#include "GL/glxint.h" -#endif - - -#ifndef uint -typedef unsigned int uint; -#endif -#ifndef ulong -typedef unsigned long ulong; -#endif -#ifndef ushort -typedef unsigned short ushort; -#endif -#ifndef uchar -typedef unsigned char uchar; -#endif #define VGAIN8(addr) MMIO_IN8(psav->MapBase+0x8000, addr) #define VGAIN16(addr) MMIO_IN16(psav->MapBase+0x8000, addr) @@ -54,26 +33,10 @@ typedef unsigned char uchar; #define VGAOUT16(addr,val) MMIO_OUT16(psav->MapBase+0x8000, addr, val) #define VGAOUT(addr,val) MMIO_OUT32(psav->MapBase+0x8000, addr, val) -#define INREG8(addr) MMIO_IN8(psav->MapBase, addr) +#define INREG(addr) MMIO_IN32(psav->MapBase, addr) +#define OUTREG(addr,val) MMIO_OUT32(psav->MapBase, addr, val) #define INREG16(addr) MMIO_IN16(psav->MapBase, addr) -#define INREG32(addr) MMIO_IN32(psav->MapBase, addr) -#define OUTREG8(addr,val) MMIO_OUT8(psav->MapBase, addr, val) #define OUTREG16(addr,val) MMIO_OUT16(psav->MapBase, addr, val) -#define OUTREG32(addr,val) MMIO_OUT32(psav->MapBase, addr, val) -#define INREG(addr) INREG32(addr) -#define OUTREG(addr,val) OUTREG32(addr,val) - -#if X_BYTE_ORDER == X_LITTLE_ENDIAN -#define B_O16(x) (x) -#define B_O32(x) (x) -#else -#define B_O16(x) ((((x) & 0xff) << 8) | (((x) & 0xff) >> 8)) -#define B_O32(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) \ - | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24)) -#endif -#define L_ADD(x) (B_O32(x) & 0xffff) + ((B_O32(x) >> 12) & 0xffff00) - -#define SAVAGEIOMAPSIZE 0x80000 #define SAVAGE_CRT_ON 1 #define SAVAGE_LCD_ON 2 @@ -110,47 +73,10 @@ typedef struct { unsigned int MMPR0, MMPR1, MMPR2, MMPR3; } SavageRegRec, *SavageRegPtr; -/* Tiling defines */ -#define TILE_SIZE_BYTE 2048 /* 0x800, 2K */ - -#define TILEHEIGHT_16BPP 16 -#define TILEHEIGHT_32BPP 16 -#define TILEHEIGHT 16 /* all 16 and 32bpp tiles are 16 lines high */ - -#define TILEWIDTH_BYTES 128 /* 2048/TILEHEIGHT (** not for use w/8bpp tiling) */ -#define TILEWIDTH8BPP_BYTES 64 /* 2048/TILEHEIGHT_8BPP */ -#define TILEWIDTH_16BPP 64 /* TILEWIDTH_BYTES/2-BYTES-PER-PIXEL */ -#define TILEWIDTH_32BPP 32 /* TILEWIDTH_BYTES/4-BYTES-PER-PIXEL */ - -/* Bitmap descriptor structures for BCI */ -typedef struct _HIGH { - ushort Stride; - uchar Bpp; - uchar ResBWTile; -} HIGH; - -typedef struct _BMPDESC1 { - ulong Offset; - HIGH HighPart; -} BMPDESC1; - -typedef struct _BMPDESC2 { - ulong LoPart; - ulong HiPart; -} BMPDESC2; - -typedef union _BMPDESC { - BMPDESC1 bd1; - BMPDESC2 bd2; -} BMPDESC; - -typedef struct _StatInfo { - int origMode; - int pageCnt; - pointer statBuf; - int realSeg; - int realOff; -} StatInfoRec,*StatInfoPtr; +typedef struct { + CARD32 redMask, greenMask, blueMask; + int redShift, greenShift, blueShift; +} savageOverlayRec; typedef struct _Savage { SavageRegRec SavedReg; @@ -162,20 +88,15 @@ typedef struct _Savage { int Bpp, Bpl, ScissB; unsigned PlaneMask; I2CBusPtr I2C; - I2CBusPtr DVI; - unsigned char DDCPort; - unsigned char I2CPort; int videoRambytes; int videoRamKbytes; int MemOffScreen; - int endfb; - CARD32 CursorKByte; + int CursorKByte; /* These are physical addresses. */ unsigned long FrameBufferBase; unsigned long MmioBase; - unsigned long ApertureBase; unsigned long ShadowPhysical; /* These are linear addresses. */ @@ -183,7 +104,6 @@ typedef struct _Savage { unsigned char* BciMem; unsigned char* MapBaseDense; unsigned char* FBBase; - unsigned char* ApertureMap; unsigned char* FBStart; CARD32 volatile * ShadowVirtual; @@ -205,6 +125,7 @@ typedef struct _Savage { Bool fifo_moderate; Bool fifo_aggressive; Bool hwcursor; + Bool hwc_on; Bool NoAccel; Bool shadowFB; Bool UseBIOS; @@ -218,7 +139,6 @@ typedef struct _Savage { int iDevInfo; int iDevInfoPrim; - Bool FPExpansion; int PanelX; /* panel width */ int PanelY; /* panel height */ int iResX; /* crtc X display */ @@ -265,8 +185,6 @@ typedef struct _Savage { unsigned int SavedSbdOffset; unsigned int SavedSbd; - /* Support for Int10 processing */ - xf86Int10InfoPtr pInt10; SavageModeTablePtr ModeTable; /* Support for the Savage command overflow buffer. */ @@ -290,64 +208,11 @@ typedef struct _Savage { int dwBCIWait2DIdle; XF86OffscreenImagePtr offscreenImages; -#ifdef XF86DRI - int LockHeld; - Bool directRenderingEnabled; - DRIInfoPtr pDRIInfo; - int drmFD; - int numVisualConfigs; - __GLXvisualConfig* pVisualConfigs; - SAVAGEConfigPrivPtr pVisualConfigsPriv; - SAVAGEDRIServerPrivatePtr DRIServerInfo; - - -#if 0 - Bool haveQuiescense; - void (*GetQuiescence)(ScrnInfoPtr pScrn); -#endif - - int agpMode; - drmSize agpSize; - FBLinearPtr reserved; - - unsigned int surfaceAllocation[7]; - unsigned int xvmcContext; - unsigned int DRIrunning; - unsigned int hwmcOffset; - unsigned int hwmcSize; - -#endif - - Bool bDisableXvMC; - Bool disableCOB; - Bool BCIforXv; - - /* Bitmap Descriptors for BCI */ - BMPDESC GlobalBD; - BMPDESC PrimaryBD; - BMPDESC SecondBD; - /* do we disable tile mode by option? */ - Bool bDisableTile; - /* if we enable tile,we only support tile under 16/32bpp */ - Bool bTiled; - int lDelta; - int ulAperturePitch; /* aperture pitch */ - - int l3DDelta; - int ul3DAperturePitch; /* pitch for 3D */ - /* - * cxMemory is number of pixels across screen width - * cyMemory is number of scanlines in available adapter memory. - * - * cxMemory * cyMemory is used to determine how much memory to - * allocate to our heap manager. So make sure that any space at the - * end of video memory set aside at bInitializeHardware time is kept - * out of the cyMemory calculation. - */ - int cxMemory,cyMemory; - - StatInfoRec StatInfo; /* save the SVGA state */ - + /* Support for Overlays */ + unsigned char * FBStart2nd; + savageOverlayRec overlay; + int overlayDepth; + int primStreamBpp; } SavageRec, *SavagePtr; /* Video flags. */ @@ -356,40 +221,13 @@ typedef struct _Savage { #define SAVPTR(p) ((SavagePtr)((p)->driverPrivate)) -/* add for support DRI */ -#ifdef XF86DRI - -#define SAVAGE_FRONT 0x1 -#define SAVAGE_BACK 0x2 -#define SAVAGE_DEPTH 0x4 -#define SAVAGE_STENCIL 0x8 - -Bool SAVAGEDRIScreenInit( ScreenPtr pScreen ); -Bool SAVAGEInitMC(ScreenPtr pScreen); -void SAVAGEDRICloseScreen( ScreenPtr pScreen ); -Bool SAVAGEDRIFinishScreenInit( ScreenPtr pScreen ); - -Bool SAVAGELockUpdate( ScrnInfoPtr pScrn, drmLockFlags flags ); - -#if 0 -void SAVAGEGetQuiescence( ScrnInfoPtr pScrn ); -void SAVAGEGetQuiescenceShared( ScrnInfoPtr pScrn ); -#endif - -void SAVAGESelectBuffer(ScrnInfoPtr pScrn, int which); - -#if 0 -Bool SAVAGECleanupDma(ScrnInfoPtr pScrn); -Bool SAVAGEInitDma(ScrnInfoPtr pScrn, int prim_size); -#endif - -#define SAVAGE_AGP_1X_MODE 0x01 -#define SAVAGE_AGP_2X_MODE 0x02 -#define SAVAGE_AGP_4X_MODE 0x04 -#define SAVAGE_AGP_MODE_MASK 0x07 - -#endif - +/* Make the names of these externals driver-unique */ +#define gpScrn savagegpScrn +#define readdw savagereaddw +#define readfb savagereadfb +#define writedw savagewritedw +#define writefb savagewritefb +#define writescan savagewritescan /* Prototypes. */ @@ -412,7 +250,6 @@ Bool SavageInitAccel(ScreenPtr); void SavageInitialize2DEngine(ScrnInfoPtr); void SavageSetGBD(ScrnInfoPtr); void SavageAccelSync(ScrnInfoPtr); -/*int SavageHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop);*/ /* In savage_i2c.c. */ @@ -431,7 +268,6 @@ void SavageRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void SavageSetTextMode( SavagePtr psav ); void SavageSetVESAMode( SavagePtr psav, int n, int Refresh ); -void SavageSetPanelEnabled( SavagePtr psav, Bool active ); void SavageFreeBIOSModeTable( SavagePtr psav, SavageModeTablePtr* ppTable ); SavageModeTablePtr SavageGetBIOSModeTable( SavagePtr psav, int iDepth ); @@ -440,9 +276,27 @@ unsigned short SavageGetBIOSModes( int iDepth, SavageModeEntryPtr s3vModeTable ); + /* In savage_video.c */ void SavageInitVideo( ScreenPtr pScreen ); +/* In savage_streams.c */ + +void SavageStreamsOn(ScrnInfoPtr pScrn); +void SavageStreamsOff(ScrnInfoPtr pScrn); +void SavageInitSecondaryStream(ScrnInfoPtr pScrn); + +#if (MODE_24 == 32) +# define BYTES_PP24 4 +#else +# define BYTES_PP24 3 +#endif + + +#define DEPTH_BPP(depth) (depth == 24 ? (BYTES_PP24 << 3) : (depth + 7) & ~0x7) +#define DEPTH_2ND(pScrn) (pScrn->depth > 8 ? pScrn->depth\ + : SAVPTR(pScrn)->overlayDepth) + #endif /* SAVAGE_VGAHWMMIO_H */ diff --git a/src/savage_image.c b/src/savage_image.c index 9cf4f0f..9530bff 100644 --- a/src/savage_image.c +++ b/src/savage_image.c @@ -181,13 +181,11 @@ void SavageSubsequentImageWriteRect { SavagePtr psav = SAVPTR(pScrn); BCI_GET_PTR; - int count; - count = ((w * pScrn->bitsPerPixel + 31) / 32) * h; - psav->WaitQueue( psav, count ); + psav->WaitQueue( psav, 6 ); BCI_SEND(psav->SavedBciCmd); BCI_SEND(BCI_CLIP_LR(x+skipleft, x+w-1)); - if( psav->SavedBgColor != -1 ) + if( psav->SavedBgColor != 0xffffffff ) BCI_SEND(psav->SavedBgColor); BCI_SEND(BCI_X_Y(x, y)); BCI_SEND(BCI_W_H(w, h)); diff --git a/src/savage_regs.h b/src/savage_regs.h index d66b2e3..92f0584 100644 --- a/src/savage_regs.h +++ b/src/savage_regs.h @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_regs.h,v 1.10 2001/11/04 22:17:48 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_regs.h,v 1.11 2002/05/14 20:19:52 alanh Exp $ */ #ifndef _SAVAGE_REGS_H #define _SAVAGE_REGS_H @@ -29,17 +29,12 @@ #define S3_SAVAGE3D_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX)) -#define S3_SAVAGE4_SERIES(chip) ((chip==S3_SAVAGE4) \ - || (chip==S3_PROSAVAGE) \ - || (chip==S3_TWISTER) \ - || (chip==S3_PROSAVAGEDDR)) +#define S3_SAVAGE4_SERIES(chip) ((chip==S3_SAVAGE4) || (chip==S3_PROSAVAGE)) #define S3_SAVAGE_MOBILE_SERIES(chip) ((chip==S3_SAVAGE_MX) || (chip==S3_SUPERSAVAGE)) #define S3_SAVAGE_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE2000)) -#define S3_MOBILE_TWISTER_SERIES(chip) ((chip==S3_TWISTER) \ - ||(chip==S3_PROSAVAGEDDR)) /* Chip tags. These are used to group the adapters into * related families. @@ -51,8 +46,6 @@ enum S3CHIPTAGS { S3_SAVAGE_MX, S3_SAVAGE4, S3_PROSAVAGE, - S3_TWISTER, - S3_PROSAVAGEDDR, S3_SUPERSAVAGE, S3_SAVAGE2000, S3_LAST @@ -73,253 +66,6 @@ enum S3CHIPTAGS { #define STREAMS_TIMEOUT_REG 0x8208 #define MISC_TIMEOUT_REG 0x820c -#define SAVAGE_NEWMMIO_REGBASE_S3 0x1000000 /* 16MB */ -#define SAVAGE_NEWMMIO_REGBASE_S4 0x0000000 -#define SAVAGE_NEWMMIO_REGSIZE 0x0080000 /* 512kb */ -#define SAVAGE_NEWMMIO_VGABASE 0x8000 - -#define ADVANCED_FUNC_CTRL 0x850C - -/* - * CR/SR registers MMIO offset - * MISC Output Register(W:0x3c2,R:0x3cc) controls CR is 0X83Cx or 0X83Bx - * but do we need to set MISC Output Register ??? - * (Note that CRT_ADDRESS_REG and CRT_DATA_REG are assumed to be COLOR)??? - */ -#define MMIO_BASE_OF_VGA3C0 0X83C0 -#define MMIO_BASE_OF_VGA3D0 0X83D0 - -#define ATTR_ADDRESS_REG \ - (MMIO_BASE_OF_VGA3C0 + (0x03C0 - 0x03C0)) -#define ATTR_DATA_WRITE_REG \ - (MMIO_BASE_OF_VGA3C0 + (0x03C0 - 0x03C0)) -#define ATTR_DATA_READ_REG \ - (MMIO_BASE_OF_VGA3C0 + (0x03C1 - 0x03C0)) -#define VIDEO_SUBSYSTEM_ENABLE \ - (MMIO_BASE_OF_VGA3C0 + (0x03C3 - 0x03C0)) -#define SEQ_ADDRESS_REG \ - (MMIO_BASE_OF_VGA3C0 + (0x03C4 - 0x03C0)) -#define SEQ_DATA_REG \ - (MMIO_BASE_OF_VGA3C0 + (0x03C5 - 0x03C0)) -#define DAC_PIXEL_MASK_REG \ - (MMIO_BASE_OF_VGA3C0 + (0x03C6 - 0x03C0)) -#define DAC_PEL_MASK \ - (MMIO_BASE_OF_VGA3C0 + (0x03C6 - 0x03C0)) -#define DAC_STATUS_REG \ - (MMIO_BASE_OF_VGA3C0 + (0x03C7 - 0x03C0)) -#define DAC_ADDRESS_READ_REG \ - (MMIO_BASE_OF_VGA3C0 + (0x03C7 - 0x03C0)) -#define DAC_ADDRESS_WRITE_REG \ - (MMIO_BASE_OF_VGA3C0 + (0x03C8 - 0x03C0)) -#define DAC_DATA_REG \ - (MMIO_BASE_OF_VGA3C0 + (0x03C9 - 0x03C0)) -#define DAC_DATA_REG_PORT \ - (MMIO_BASE_OF_VGA3C0 + (0x03C9 - 0x03C0)) -#define MISC_OUTPUT_REG_WRITE \ - (MMIO_BASE_OF_VGA3C0 + (0x03C2 - 0x03C0)) -#define MISC_OUTPUT_REG_READ \ - (MMIO_BASE_OF_VGA3C0 + (0x03CC - 0x03C0)) -#define GR_ADDRESS_REG \ - (MMIO_BASE_OF_VGA3C0 + (0x03CE - 0x03C0)) -#define GR_DATA_REG \ - (MMIO_BASE_OF_VGA3C0 + (0x03CF - 0x03C0)) -#define WAKEUP_REG \ - (MMIO_BASE_OF_VGA3C0 + (0x0510 - 0x03C0)) - -#define CRT_ADDRESS_REG \ - (MMIO_BASE_OF_VGA3D0 + (0x03D4 - 0x03D0)) -#define CRT_DATA_REG \ - (MMIO_BASE_OF_VGA3D0 + (0x03D5 - 0x03D0)) -#define SYSTEM_CONTROL_REG \ - (MMIO_BASE_OF_VGA3D0 + (0x03DA - 0x03D0)) - -/* GX-3 Configuration/Status Registers */ -#define S3_SHADOW_STATUS 0x48C0C -#define S3_BUFFER_THRESHOLD 0x48C10 -#define S3_OVERFLOW_BUFFER 0x48C14 -#define S3_OVERFLOW_BUFFER_PTR 0x48C18 - -#define ENABLE_BCI 0x08 /* MM48C18_3 */ -#define ENABLE_COMMAND_OVERFLOW_BUF 0x04 /* MM48C18_2 */ -#define ENABLE_COMMAND_BUF_STATUS_UPDATE 0x02 /* MM48C18_1 */ -#define ENABLE_SHADOW_STATUS_UPDATE 0x01 /* MM48C0C_0 */ - - -#define MEMORY_CTRL0_REG 0xCA -#define MEMORY_CTRL1_REG 0xCB -#define MEMORY_CTRL2_REG 0xCC - -#define MEMORY_CONFIG_REG 0x31 - -/* bitmap descriptor register */ -#define S3_GLB_BD_LOW 0X8168 -#define S3_GLB_BD_HIGH 0X816C -#define S3_PRI_BD_LOW 0X8170 -#define S3_PRI_BD_HIGH 0X8174 -#define S3_SEC_BD_LOW 0X8178 -#define S3_SEC_BD_HIGH 0X817c - - -/**** S3 streams processor*****/ - -#define EXT_MISC_CTRL2 0x67 -/* CR67[2] = 1 : enable stream 1 */ -#define ENABLE_STREAM1 0x04 -/* CR67[1] = 1 : enable stream 2 */ -#define ENABLE_STREAM2 0x02 -/* mask to clear CR67[2,1] */ -#define NO_STREAMS 0xF9 -/* CR67[3] = 1 : Mem-mapped regs */ -#define USE_MM_FOR_PRI_STREAM 0x08 -#define HDM_SHIFT 16 -#define HDSCALE_4 (2 << HDM_SHIFT) -#define HDSCALE_8 (3 << HDM_SHIFT) -#define HDSCALE_16 (4 << HDM_SHIFT) -#define HDSCALE_32 (5 << HDM_SHIFT) -#define HDSCALE_64 (6 << HDM_SHIFT) - -/* Old Streams */ - -#define ENABLE_STREAMS_OLD 0x0c -#define NO_STREAMS_OLD 0xf3 -/* CR69[0] = 1 : Mem-mapped regs */ -#define USE_MM_FOR_PRI_STREAM_OLD 0x01 - - -#define SELECT_IGA1 0x4026 -#define SELECT_IGA2_READS_WRITES 0x4f26 - -#define MEM_PS1 0x10 /*CRCA_4 :Primary stream 1*/ -#define MEM_PS2 0x20 /*CRCA_5 :Primary stream 2*/ -#define MEM_SS1 0x40 /*CRCA_6 :Secondary stream 1*/ -#define MEM_SS2 0x80 /*CRCA_7 :Secondary stream 2*/ - -/* - * There are two different streams engines used in the Savage line. - * The old engine is in the 3D, 4, Pro, and Twister. - * The new engine is in the 2000, MX, IX, and Super. - */ - -/* Stream Processor 1 */ - -/* Primary Stream 1 Frame Buffer Address 0 */ -#define PRI_STREAM_FBUF_ADDR0 0x81c0 -/* Primary Stream 1 Frame Buffer Address 0 */ -#define PRI_STREAM_FBUF_ADDR1 0x81c4 -/* Primary Stream 1 Stride */ -#define PRI_STREAM_STRIDE 0x81c8 -/* Primary Stream 1 Frame Buffer Size */ -#define PRI_STREAM_BUFFERSIZE 0x8214 - -/* Secondary stream 1 Color/Chroma Key Control */ -#define SEC_STREAM_CKEY_LOW 0x8184 -/* Secondary stream 1 Chroma Key Upper Bound */ -#define SEC_STREAM_CKEY_UPPER 0x8194 -/* Blend Control of Secondary Stream 1 & 2 */ -#define BLEND_CONTROL 0x8190 -/* Secondary Stream 1 Color conversion/Adjustment 1 */ -#define SEC_STREAM_COLOR_CONVERT1 0x8198 -/* Secondary Stream 1 Color conversion/Adjustment 2 */ -#define SEC_STREAM_COLOR_CONVERT2 0x819c -/* Secondary Stream 1 Color conversion/Adjustment 3 */ -#define SEC_STREAM_COLOR_CONVERT3 0x81e4 -/* Secondary Stream 1 Horizontal Scaling */ -#define SEC_STREAM_HSCALING 0x81a0 -/* Secondary Stream 1 Frame Buffer Size */ -#define SEC_STREAM_BUFFERSIZE 0x81a8 -/* Secondary Stream 1 Horizontal Scaling Normalization (2K only) */ -#define SEC_STREAM_HSCALE_NORMALIZE 0x81ac -/* Secondary Stream 1 Horizontal Scaling */ -#define SEC_STREAM_VSCALING 0x81e8 -/* Secondary Stream 1 Frame Buffer Address 0 */ -#define SEC_STREAM_FBUF_ADDR0 0x81d0 -/* Secondary Stream 1 Frame Buffer Address 1 */ -#define SEC_STREAM_FBUF_ADDR1 0x81d4 -/* Secondary Stream 1 Frame Buffer Address 2 */ -#define SEC_STREAM_FBUF_ADDR2 0x81ec -/* Secondary Stream 1 Stride */ -#define SEC_STREAM_STRIDE 0x81d8 -/* Secondary Stream 1 Window Start Coordinates */ -#define SEC_STREAM_WINDOW_START 0x81f8 -/* Secondary Stream 1 Window Size */ -#define SEC_STREAM_WINDOW_SZ 0x81fc -/* Secondary Streams Tile Offset */ -#define SEC_STREAM_TILE_OFF 0x821c -/* Secondary Stream 1 Opaque Overlay Control */ -#define SEC_STREAM_OPAQUE_OVERLAY 0x81dc - - -/* Stream Processor 2 */ - -/* Primary Stream 2 Frame Buffer Address 0 */ -#define PRI_STREAM2_FBUF_ADDR0 0x81b0 -/* Primary Stream 2 Frame Buffer Address 1 */ -#define PRI_STREAM2_FBUF_ADDR1 0x81b4 -/* Primary Stream 2 Stride */ -#define PRI_STREAM2_STRIDE 0x81b8 -/* Primary Stream 2 Frame Buffer Size */ -#define PRI_STREAM2_BUFFERSIZE 0x8218 - -/* Secondary Stream 2 Color/Chroma Key Control */ -#define SEC_STREAM2_CKEY_LOW 0x8188 -/* Secondary Stream 2 Chroma Key Upper Bound */ -#define SEC_STREAM2_CKEY_UPPER 0x818c -/* Secondary Stream 2 Horizontal Scaling */ -#define SEC_STREAM2_HSCALING 0x81a4 -/* Secondary Stream 2 Horizontal Scaling */ -#define SEC_STREAM2_VSCALING 0x8204 -/* Secondary Stream 2 Frame Buffer Size */ -#define SEC_STREAM2_BUFFERSIZE 0x81ac -/* Secondary Stream 2 Frame Buffer Address 0 */ -#define SEC_STREAM2_FBUF_ADDR0 0x81bc -/* Secondary Stream 2 Frame Buffer Address 1 */ -#define SEC_STREAM2_FBUF_ADDR1 0x81e0 -/* Secondary Stream 2 Frame Buffer Address 2 */ -#define SEC_STREAM2_FBUF_ADDR2 0x8208 -/* Multiple Buffer/LPB and Secondary Stream 2 Stride */ -#define SEC_STREAM2_STRIDE_LPB 0x81cc -/* Secondary Stream 2 Color conversion/Adjustment 1 */ -#define SEC_STREAM2_COLOR_CONVERT1 0x81f0 -/* Secondary Stream 2 Color conversion/Adjustment 2 */ -#define SEC_STREAM2_COLOR_CONVERT2 0x81f4 -/* Secondary Stream 2 Color conversion/Adjustment 3 */ -#define SEC_STREAM2_COLOR_CONVERT3 0x8200 -/* Secondary Stream 2 Window Start Coordinates */ -#define SEC_STREAM2_WINDOW_START 0x820c -/* Secondary Stream 2 Window Size */ -#define SEC_STREAM2_WINDOW_SZ 0x8210 -/* Secondary Stream 2 Opaque Overlay Control */ -#define SEC_STREAM2_OPAQUE_OVERLAY 0x8180 - -/* streams registers for old engine */ -#define PSTREAM_CONTROL_REG 0x8180 -#define COL_CHROMA_KEY_CONTROL_REG 0x8184 -#define SSTREAM_CONTROL_REG 0x8190 -#define CHROMA_KEY_UPPER_BOUND_REG 0x8194 -#define SSTREAM_STRETCH_REG 0x8198 -#define COLOR_ADJUSTMENT_REG 0x819C -#define BLEND_CONTROL_REG 0x81A0 -#define PSTREAM_FBADDR0_REG 0x81C0 -#define PSTREAM_FBADDR1_REG 0x81C4 -#define PSTREAM_STRIDE_REG 0x81C8 -#define DOUBLE_BUFFER_REG 0x81CC -/* updated by peterzhu,original define is DOUBLE_BUFFER_REG*/ -#define MULTIPLE_BUFFER_REG 0x81CC -#define SSTREAM_FBADDR0_REG 0x81D0 -#define SSTREAM_FBADDR1_REG 0x81D4 -#define SSTREAM_STRIDE_REG 0x81D8 -#define SSTREAM_VSCALE_REG 0x81E0 -#define SSTREAM_VINITIAL_REG 0x81E4 -#define SSTREAM_LINES_REG 0x81E8 -#define STREAMS_FIFO_REG 0x81EC -#define PSTREAM_WINDOW_START_REG 0x81F0 -#define PSTREAM_WINDOW_SIZE_REG 0x81F4 -#define SSTREAM_WINDOW_START_REG 0x81F8 -#define SSTREAM_WINDOW_SIZE_REG 0x81FC -#define FIFO_CONTROL 0x8200 -#define PSTREAM_FBSIZE_REG 0x8300 -#define SSTREAM_FBSIZE_REG 0x8304 -#define SSTREAM_FBADDR2_REG 0x8308 #define SUBSYS_STAT_REG 0x8504 @@ -331,43 +77,6 @@ enum S3CHIPTAGS { #define MONO_PAT_0 0xa4e8 #define MONO_PAT_1 0xa4ec -#define TILED_SURFACE_REGISTER_0 0x48c40 -#define TILED_SURFACE_REGISTER_1 0x48c44 -#define TILED_SURFACE_REGISTER_2 0x48c48 -#define TILED_SURFACE_REGISTER_3 0x48c4c -#define TILED_SURFACE_REGISTER_4 0x48c50 - -#define TILED_SURF_BPP4 0x00000000 /* bits 31-30=00 for 4 bits/pixel */ -#define TILED_SURF_BPP8 0x40000000 /* bits 31-30=01 for 8 bits/pixel */ -#define TILED_SURF_BPP16 0x80000000 /* bits 31-30=10 for 16 bits/pixel */ -#define TILED_SURF_BPP32 0xC0000000 /* bits 31-30=11 for 32 bits/pixel */ - -/* Streams Processor macros */ -#define H_Shift 0 -#define H_Mask (((1L << 11) - 1) << H_Shift) -#define W_Shift 16 -#define W_Mask (((1L << 11) - 1) << W_Shift) - -#define Y_Shift 0 -#define Y_Mask (((1L << 11) - 1) << Y_Shift) -#define X_Shift 16 -#define X_Mask (((1L << 11) - 1) << X_Shift) - -#define XY(x,y) ((((x+1)<<X_Shift)&X_Mask) | (((y+1)<<Y_Shift)&Y_Mask)) -#define WH(w,h) ((((w-1)<<W_Shift)&W_Mask) | (((h)<<H_Shift)&H_Mask)) - - -/* - * CR88_4 =1 : disable block write - * the "2D" is partly to set this apart from "BLOCK_WRITE_DISABLE" - * constant used for bitmap descriptor - */ -#define DISABLE_BLOCK_WRITE_2D 0x10 -#define BLOCK_WRITE_DISABLE 0x0 - -/* CR31[0] set = Enable 8MB display memory through 64K window at A0000H. */ -#define ENABLE_CPUA_BASE_A0000 0x01 - /* Constants for CR69. */ #define CRT_ACTIVE 0x01 @@ -388,69 +97,6 @@ enum S3CHIPTAGS { #define MAXFIFO 0x7f00 -#define inStatus1() (VGAHWPTR(pScrn))->readST01( VGAHWPTR(pScrn) ) - - -/* - * unprotect CRTC[0-7] - * CR11_7 = 0: Writing to all CRT Controller registers enabled - * = 1: Writing to all bits of CR0~CR7 except CR7_4 disabled - */ -#define UnProtectCRTC() \ -do { \ - uchar byte; \ - OUTREG8(CRT_ADDRESS_REG,0x11); \ - byte = INREG8(CRT_DATA_REG) & 0X7F; \ - OUTREG16(CRT_ADDRESS_REG,byte << 8 | 0x11); \ -} while (0) - -/* - * unlock extended regs - * CR38:unlock CR20~CR3F - * CR39:unlock CR40~CRFF - * SR08:unlock SR09~SRFF - */ -#define UnLockExtRegs() \ -do { \ - OUTREG16(CRT_ADDRESS_REG,0X4838); \ - OUTREG16(CRT_ADDRESS_REG,0XA039); \ - OUTREG16(SEQ_ADDRESS_REG,0X0608); \ -} while (0) - -#define VerticalRetraceWait() \ -do { \ - INREG8(CRT_ADDRESS_REG); \ - OUTREG8(CRT_ADDRESS_REG, 0x17); \ - if (INREG8(CRT_DATA_REG) & 0x80) { \ - int i = 0x10000; \ - while ((INREG8(SYSTEM_CONTROL_REG) & 0x08) == 0x08 && i--) ; \ - i = 0x10000; \ - while ((INREG8(SYSTEM_CONTROL_REG) & 0x08) == 0x00 && i--) ; \ - } \ -} while (0) - -/* - * Jiayo Hsu, Mar 21, 2002 - * modify this to scalable schema,because different chips have differnt regs, - * besides add in patch code for Paramount(SuperSavage) from 2K - */ -#define InI2CREG(a,reg) \ -do { \ - OUTREG8(CRT_ADDRESS_REG, reg); \ - if (psav->Chipset == S3_SUPERSAVAGE) \ - OUTREG8(CRT_DATA_REG, INREG8(CRT_DATA_REG)); \ - a = INREG8(CRT_DATA_REG); \ -} while (0) - -#define OutI2CREG(a,reg) \ -do { \ - OUTREG8(CRT_ADDRESS_REG, reg); \ - if (psav->Chipset == S3_SUPERSAVAGE) \ - OUTREG8(CRT_DATA_REG, a); \ - OUTREG8(CRT_DATA_REG, a); \ -} while (0) - -#if 0 /* tim's code */ /* * NOTE: don't remove 'VGAIN8(vgaCRIndex);'. * If not present it will cause lockups on Savage4. @@ -461,11 +107,23 @@ do { \ VGAIN8(psav->vgaIOBase+4); \ VGAOUT8(psav->vgaIOBase+4, 0x17); \ if (VGAIN8(psav->vgaIOBase+5) & 0x80) { \ - while ((VGAIN8(psav->vgaIOBase + 0x0a) & 0x08) == 0x08) ; \ - while ((VGAIN8(psav->vgaIOBase + 0x0a) & 0x08) == 0x00) ; \ + while ((VGAIN8(psav->vgaIOBase + 0x0a) & 0x08) == 0x08) {}; \ + while ((VGAIN8(psav->vgaIOBase + 0x0a) & 0x08) == 0x00) {}; \ } \ } -#endif /* tim's code */ + +#define I2C_REG 0xa0 +#define InI2CREG(psav,a) \ +{ \ + VGAOUT8(psav->vgaIOBase + 4, I2C_REG); \ + a = VGAIN8(psav->vgaIOBase + 5); \ +} + +#define OutI2CREG(psav,a) \ +{ \ + VGAOUT8(psav->vgaIOBase + 4, I2C_REG); \ + VGAOUT8(psav->vgaIOBase + 5, a); \ +} #define HZEXP_COMP_1 0x54 #define HZEXP_BORDER 0x58 diff --git a/src/savage_streams.c b/src/savage_streams.c new file mode 100644 index 0000000..88936e3 --- /dev/null +++ b/src/savage_streams.c @@ -0,0 +1,461 @@ +#include "Xv.h" +#include "dix.h" +#include "dixstruct.h" + +#include "savage_driver.h" +#include "savage_streams.h" + +#define STREAMS_TRACE 4 + +static void SavageInitStreamsOld(ScrnInfoPtr pScrn); +static void SavageInitStreamsNew(ScrnInfoPtr pScrn); + +static void OverlayParamInit(ScrnInfoPtr pScrn); +static void InitStreamsForExpansion(ScrnInfoPtr pScrn); + +static void +SavageInitSecondaryStreamOld(ScrnInfoPtr pScrn) +{ + SavagePtr psav = SAVPTR(pScrn); + vgaHWPtr hwp; + unsigned short vgaIOBase, vgaCRIndex, vgaCRReg; + int offset = (psav->FBStart2nd - psav->FBStart); + int colorkey = pScrn->colorKey; + int pitch = pScrn->displayWidth * DEPTH_BPP(DEPTH_2ND(pScrn))/8; + CARD8 cr92; + + hwp = VGAHWPTR(pScrn); + vgaHWGetIOBase(hwp); + vgaIOBase = hwp->IOBase; + vgaCRIndex = vgaIOBase + 4; + vgaCRReg = vgaIOBase + 5; + + OUTREG(COL_CHROMA_KEY_CONTROL_REG, 0x37000000 | (colorkey & 0xFF)); + OUTREG(CHROMA_KEY_UPPER_BOUND_REG, 0x00000000 | (colorkey & 0xFF)); + OUTREG(BLEND_CONTROL_REG, 0x05000000 ); + OUTREG(SSTREAM_CONTROL_REG, SSTREAMS_MODE(DEPTH_BPP(DEPTH_2ND(pScrn))) + << 24 | pScrn->displayWidth ); + OUTREG(SSTREAM_STRETCH_REG, 1 << 15); + OUTREG(SSTREAM_VSCALE_REG, 1 << 15); + OUTREG(SSTREAM_LINES_REG, pScrn->virtualY ); + OUTREG(SSTREAM_VINITIAL_REG, 0 ); + OUTREG(SSTREAM_FBADDR0_REG, offset & 0x1ffffff & ~BASE_PAD); + OUTREG(SSTREAM_FBADDR1_REG, 0 ); + + OUTREG(SSTREAM_STRIDE_REG, pitch); + OUTREG(SSTREAM_WINDOW_START_REG, OS_XY(0,0)); + OUTREG(SSTREAM_WINDOW_SIZE_REG, + OS_WH(pScrn->displayWidth, pScrn->virtualY)); + + pitch = (pitch + 7) / 8; + VGAOUT8(vgaCRIndex, 0x92); + cr92 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, (cr92 & 0x40) | (pitch >> 8) | 0x80); + VGAOUT8(vgaCRIndex, 0x93); + VGAOUT8(vgaCRReg, pitch); + OUTREG(STREAMS_FIFO_REG, 2 | 25 << 5 | 32 << 11); +} + +static void +SavageInitSecondaryStreamNew(ScrnInfoPtr pScrn) +{ + SavagePtr psav = SAVPTR(pScrn); + vgaHWPtr hwp; + unsigned short vgaIOBase, vgaCRIndex, vgaCRReg; + int offset = (psav->FBStart2nd - psav->FBStart); + int colorkey = pScrn->colorKey; + int pitch = pScrn->displayWidth * DEPTH_BPP(DEPTH_2ND(pScrn))/8; + CARD8 cr92; + + hwp = VGAHWPTR(pScrn); + + vgaHWGetIOBase(hwp); + vgaIOBase = hwp->IOBase; + vgaCRIndex = vgaIOBase + 4; + vgaCRReg = vgaIOBase + 5; + + OUTREG( SEC_STREAM_CKEY_LOW, 0x47000000 | (colorkey & 0xFF)); + OUTREG( SEC_STREAM_CKEY_UPPER, 0x47000000 | (colorkey & 0xFF)); + OUTREG( BLEND_CONTROL, SSTREAMS_MODE(DEPTH_BPP(DEPTH_2ND(pScrn))) << 9 + | 0x08 ); + if( psav->Chipset == S3_SAVAGE2000 ) { + OUTREG(SEC_STREAM_HSCALING, 1 << 15); + OUTREG(SEC_STREAM_HSCALE_NORMALIZE, 2048 << 16 ); + OUTREG(SEC_STREAM_VSCALING, 1 << 15); + } else { + OUTREG(SEC_STREAM_HSCALING,((pScrn->displayWidth &0xfff)<<20) | 1<<15); + /* BUGBUG need to add 00040000 if src stride > 2048 */ + OUTREG(SEC_STREAM_VSCALING,((pScrn->virtualY &0xfff)<<20) | 1<<15); + } + + OUTREG(SEC_STREAM_FBUF_ADDR0, offset & (0x7ffffff & ~BASE_PAD)); + OUTREG(SEC_STREAM_STRIDE, pitch); + OUTREG(SEC_STREAM_WINDOW_START, OS_XY(0,0)); + /* ? width may need to be increased by 1 */ + OUTREG(SEC_STREAM_WINDOW_SZ, OS_WH(pScrn->displayWidth, pScrn->virtualY)); + + pitch = (pitch + 7) / 8; + VGAOUT8(vgaCRIndex, 0x92); + cr92 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, (cr92 & 0x40) | (pitch >> 8) | 0x80); + VGAOUT8(vgaCRIndex, 0x93); + VGAOUT8(vgaCRReg, pitch); +} + +void +SavageInitSecondaryStream(ScrnInfoPtr pScrn) +{ + SavagePtr psav = SAVPTR(pScrn); + + if( S3_SAVAGE_MOBILE_SERIES(psav->Chipset) || + (psav->Chipset == S3_SUPERSAVAGE) || + (psav->Chipset == S3_SAVAGE2000) ) + SavageInitSecondaryStreamNew(pScrn); + else + SavageInitSecondaryStreamOld(pScrn); +} + +void SavageInitStreamsOld(ScrnInfoPtr pScrn) +{ + SavagePtr psav = SAVPTR(pScrn); + unsigned long jDelta; + unsigned long format = 0; + + /* + * For the OLD streams engine, several of these registers + * cannot be touched unless streams are on. Seems backwards to me; + * I'd want to set 'em up, then cut 'em loose. + */ + + xf86ErrorFVerb(STREAMS_TRACE, "SavageInitStreams\n" ); + + /* Primary stream reflects the frame buffer. */ + + if (psav->FBStart2nd) { + jDelta = pScrn->displayWidth; + format = 0 << 24; + } else { + jDelta = pScrn->displayWidth * (pScrn->bitsPerPixel + 7) / 8; + switch( pScrn->depth ) { + case 8: format = 0 << 24; break; + case 15: format = 3 << 24; break; + case 16: format = 5 << 24; break; + case 24: format = 7 << 24; break; + } + } + + OUTREG( PSTREAM_WINDOW_START_REG, OS_XY(0,0) ); + OUTREG( PSTREAM_WINDOW_SIZE_REG, OS_WH(pScrn->displayWidth, pScrn->virtualY) ); + OUTREG( PSTREAM_FBADDR0_REG, pScrn->fbOffset ); + OUTREG( PSTREAM_FBADDR1_REG, 0 ); + OUTREG( PSTREAM_STRIDE_REG, jDelta ); + OUTREG( PSTREAM_CONTROL_REG, format ); + OUTREG( PSTREAM_FBSIZE_REG, jDelta * pScrn->virtualY >> 3 ); + + OUTREG( COL_CHROMA_KEY_CONTROL_REG, 0 ); + OUTREG( SSTREAM_CONTROL_REG, 0 ); + OUTREG( CHROMA_KEY_UPPER_BOUND_REG, 0 ); + OUTREG( SSTREAM_STRETCH_REG, 0 ); + OUTREG( COLOR_ADJUSTMENT_REG, 0 ); + OUTREG( BLEND_CONTROL_REG, 1 << 24 ); + OUTREG( DOUBLE_BUFFER_REG, 0 ); + OUTREG( SSTREAM_FBADDR0_REG, 0 ); + OUTREG( SSTREAM_FBADDR1_REG, 0 ); + OUTREG( SSTREAM_FBADDR2_REG, 0 ); +/* OUTREG( SSTREAM_FBSIZE_REG, 0 ); */ + OUTREG( SSTREAM_STRIDE_REG, 0 ); + OUTREG( SSTREAM_VSCALE_REG, 0 ); + OUTREG( SSTREAM_LINES_REG, 0 ); + OUTREG( SSTREAM_VINITIAL_REG, 0 ); + OUTREG( SSTREAM_WINDOW_START_REG, OS_XY(0xfffe, 0xfffe) ); + OUTREG( SSTREAM_WINDOW_SIZE_REG, OS_WH(10,2) ); + OUTREG(STREAMS_FIFO_REG, 2 | 25 << 5 | 32 << 11); + + { + vgaHWPtr hwp; + unsigned short vgaIOBase, vgaCRIndex, vgaCRReg; + unsigned char cr90; + + hwp = VGAHWPTR(pScrn); + + vgaHWGetIOBase(hwp); + vgaIOBase = hwp->IOBase; + vgaCRIndex = vgaIOBase + 4; + vgaCRReg = vgaIOBase + 5; + + VGAOUT8(vgaCRIndex, 0x90); + cr90 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, (cr90 & 0x7F)); + } +} + +static void +SavageInitStreamsNew(ScrnInfoPtr pScrn) +{ + SavagePtr psav = SAVPTR(pScrn); + unsigned long jDelta; + + xf86ErrorFVerb(STREAMS_TRACE, "SavageInitStreams\n" ); + + if( + S3_SAVAGE_MOBILE_SERIES(psav->Chipset) && + !psav->CrtOnly && + !psav->TvOn + ) { + OverlayParamInit( pScrn ); + } + + /* Primary stream reflects the frame buffer. */ + + if (psav->FBStart2nd) + jDelta = pScrn->displayWidth; + else + jDelta = pScrn->displayWidth * (pScrn->bitsPerPixel + 7) / 8; + + OUTREG( PRI_STREAM_BUFFERSIZE, jDelta * pScrn->virtualY >> 3 ); + OUTREG( PRI_STREAM_FBUF_ADDR0, pScrn->fbOffset ); + OUTREG( PRI_STREAM_STRIDE, jDelta ); + + OUTREG( SEC_STREAM_CKEY_LOW, 0 ); + OUTREG( SEC_STREAM_CKEY_UPPER, 0 ); + OUTREG( SEC_STREAM_HSCALING, 0 ); + OUTREG( SEC_STREAM_VSCALING, 0 ); + OUTREG( BLEND_CONTROL, 0 ); + OUTREG( SEC_STREAM_FBUF_ADDR0, 0 ); + OUTREG( SEC_STREAM_FBUF_ADDR1, 0 ); + OUTREG( SEC_STREAM_FBUF_ADDR2, 0 ); + OUTREG( SEC_STREAM_WINDOW_START, 0 ); + OUTREG( SEC_STREAM_WINDOW_SZ, 0 ); +/* OUTREG( SEC_STREAM_BUFFERSIZE, 0 ); */ + OUTREG( SEC_STREAM_TILE_OFF, 0 ); + OUTREG( SEC_STREAM_OPAQUE_OVERLAY, 0 ); + OUTREG( SEC_STREAM_STRIDE, 0 ); + + /* These values specify brightness, contrast, saturation and hue. */ + OUTREG( SEC_STREAM_COLOR_CONVERT1, 0x0000C892 ); + OUTREG( SEC_STREAM_COLOR_CONVERT2, 0x00039F9A ); + OUTREG( SEC_STREAM_COLOR_CONVERT3, 0x01F1547E ); +#if 0 + { + vgaHWPtr hwp; + unsigned short vgaIOBase, vgaCRIndex, vgaCRReg; + hwp = VGAHWPTR(pScrn); + unsigned char cr90; + + vgaHWGetIOBase(hwp); + vgaIOBase = hwp->IOBase; + vgaCRIndex = vgaIOBase + 4; + vgaCRReg = vgaIOBase + 5; + + VGAOUT8(vgaCRIndex, 0x90); + cr90 = VGAIN8(vgaCRReg); + VGAOUT8(vgaCRReg, (cr90 & 0x7F)); + } +#endif +} + + +/* Function to get lcd factor, display offset for overlay use + * Input: pScrn; Output: x,yfactor, displayoffset in pScrn + */ +static void OverlayParamInit(ScrnInfoPtr pScrn) +{ + SavagePtr psav = SAVPTR(pScrn); + + psav = SAVPTR(pScrn); + psav->cxScreen = pScrn->currentMode->HDisplay; + InitStreamsForExpansion(pScrn); +} + +/* Function to calculate lcd expansion x,y factor and offset for overlay + */ +static void InitStreamsForExpansion(ScrnInfoPtr pScrn) +{ + SavagePtr psav = SAVPTR(pScrn); + int PanelSizeX,PanelSizeY; + int ViewPortWidth,ViewPortHeight; + int XExpansion, YExpansion; + int XFactor, YFactor; + int Hstate, Vstate; + + static CARD32 Xfactors[] = { + 0x00010001, + 0x00010001, /* 1 */ + 0, + 0x00090008, /* 3 */ + 0x00050004, /* 4 */ + 0, + 0x00030002, /* 6 */ + 0x00020001 /* 7 */ + }; + + static CARD32 Yfactors[] = { + 0x00010001, 0x00010001, + 0, 0x00060005, + 0x00050004, 0x00040003, + 0, 0x00030002, + 0x00020001, 0x00050002, + 0x000C0005, 0x00080003, + 0x00090004, 0, + 0x00030001, 0x00040001, + }; + + + + PanelSizeX = psav->PanelX; + PanelSizeY = psav->PanelY; + ViewPortWidth = pScrn->currentMode->HDisplay; + ViewPortHeight = pScrn->currentMode->VDisplay; + + if( PanelSizeX == 1408 ) + PanelSizeX = 1400; + + XExpansion = 0x00010001; + YExpansion = 0x00010001; + + psav->displayXoffset = 0; + psav->displayYoffset = 0; + + VGAOUT8(0x3C4, HZEXP_COMP_1); + Hstate = VGAIN8(0x3C5); + VGAOUT8(0x3C4, VTEXP_COMP_1); + Vstate = VGAIN8(0x3C5); + VGAOUT8(0x3C4, HZEXP_FACTOR_IGA1); + XFactor = VGAIN8(0x3C5); + VGAOUT8(0x3C4, VTEXP_FACTOR_IGA1); + YFactor = VGAIN8(0x3C5); + + if( Hstate & EC1_EXPAND_ON ) + { + XExpansion = Xfactors[XFactor>>4]; + } + + if( Vstate & EC1_EXPAND_ON ) + { + YExpansion = Yfactors[YFactor>>4]; + } + + psav->XExp1 = XExpansion >> 16; + psav->XExp2 = XExpansion & 0xFFFF; + + psav->YExp1 = YExpansion >> 16; + psav->YExp2 = YExpansion & 0xFFFF; + + psav->displayXoffset = + ((PanelSizeX - (psav->XExp1 * ViewPortWidth) / psav->XExp2) / 2 + 7) & 0xfff8; + psav->displayYoffset = + ((PanelSizeY - (psav->YExp1 * ViewPortHeight) / psav->YExp2) / 2); + +} /* InitStreamsForExpansionPM */ + +void +SavageStreamsOn(ScrnInfoPtr pScrn) +{ + SavagePtr psav = SAVPTR(pScrn); + unsigned char jStreamsControl; + unsigned short vgaCRIndex = psav->vgaIOBase + 4; + unsigned short vgaCRReg = psav->vgaIOBase + 5; + + xf86ErrorFVerb(STREAMS_TRACE, "SavageStreamsOn\n" ); + + /* Sequence stolen from streams.c in M7 NT driver */ + + + xf86EnableIO(); + + /* Unlock extended registers. */ + + VGAOUT16(vgaCRIndex, 0x4838); + VGAOUT16(vgaCRIndex, 0xa039); + VGAOUT16(0x3c4, 0x0608); + + VGAOUT8( vgaCRIndex, EXT_MISC_CTRL2 ); + + if( S3_SAVAGE_MOBILE_SERIES(psav->Chipset) || +#if 0 /* I don't think commenting this out is correct (EE) */ + (psav->Chipset == S3_SUPERSAVAGE) || +#endif + (psav->Chipset == S3_SAVAGE2000) ) + { + SavageInitStreamsNew( pScrn ); + + jStreamsControl = VGAIN8( vgaCRReg ) | ENABLE_STREAM1; + + /* Wait for VBLANK. */ + + VerticalRetraceWait(psav); + + /* Fire up streams! */ + + VGAOUT16( vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2 ); + + /* These values specify brightness, contrast, saturation and hue. */ + OUTREG( SEC_STREAM_COLOR_CONVERT1, 0x0000C892 ); + OUTREG( SEC_STREAM_COLOR_CONVERT2, 0x00039F9A ); + OUTREG( SEC_STREAM_COLOR_CONVERT3, 0x01F1547E ); + } + else + { + jStreamsControl = VGAIN8( vgaCRReg ) | ENABLE_STREAMS_OLD; + + /* Wait for VBLANK. */ + + VerticalRetraceWait(psav); + + /* Fire up streams! */ + + VGAOUT16( vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2 ); + + SavageInitStreamsOld( pScrn ); + } + + /* Wait for VBLANK. */ + + VerticalRetraceWait(psav); + + /* Turn on secondary stream TV flicker filter, once we support TV. */ + + /* SR70 |= 0x10 */ + +} + +void +SavageStreamsOff(ScrnInfoPtr pScrn) +{ + SavagePtr psav = SAVPTR(pScrn); + unsigned char jStreamsControl; + unsigned short vgaCRIndex = psav->vgaIOBase + 4; + unsigned short vgaCRReg = psav->vgaIOBase + 5; + + xf86ErrorFVerb(STREAMS_TRACE, "SavageStreamsOff\n" ); + + xf86EnableIO(); + + /* Unlock extended registers. */ + + VGAOUT16(vgaCRIndex, 0x4838); + VGAOUT16(vgaCRIndex, 0xa039); + VGAOUT16(0x3c4, 0x0608); + + VGAOUT8( vgaCRIndex, EXT_MISC_CTRL2 ); + if( S3_SAVAGE_MOBILE_SERIES(psav->Chipset) || + (psav->Chipset == S3_SUPERSAVAGE) || + (psav->Chipset == S3_SAVAGE2000) ) + jStreamsControl = VGAIN8( vgaCRReg ) & NO_STREAMS; + else + jStreamsControl = VGAIN8( vgaCRReg ) & NO_STREAMS_OLD; + + /* Wait for VBLANK. */ + + VerticalRetraceWait(psav); + + /* Kill streams. */ + + VGAOUT16( vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2 ); + + VGAOUT16( vgaCRIndex, 0x0093 ); + VGAOUT8( vgaCRIndex, 0x92 ); + VGAOUT8( vgaCRReg, VGAIN8(vgaCRReg) & 0x40 ); + +} + diff --git a/src/savage_streams.h b/src/savage_streams.h new file mode 100644 index 0000000..9707765 --- /dev/null +++ b/src/savage_streams.h @@ -0,0 +1,177 @@ +#ifndef __SAVAGE_STREAMS_H__ + +# define __SAVAGE_STREAMS_H__ + +/************************************** + S3 streams processor +**************************************/ + +#define EXT_MISC_CTRL2 0x67 + +/* New streams */ + +/* CR67[2] = 1 : enable stream 1 */ +#define ENABLE_STREAM1 0x04 +/* CR67[1] = 1 : enable stream 2 */ +#define ENABLE_STREAM2 0x02 +/* mask to clear CR67[2,1] */ +#define NO_STREAMS 0xF9 +/* CR67[3] = 1 : Mem-mapped regs */ +#define USE_MM_FOR_PRI_STREAM 0x08 + +#define HDM_SHIFT 16 +#define HDSCALE_4 (2 << HDM_SHIFT) +#define HDSCALE_8 (3 << HDM_SHIFT) +#define HDSCALE_16 (4 << HDM_SHIFT) +#define HDSCALE_32 (5 << HDM_SHIFT) +#define HDSCALE_64 (6 << HDM_SHIFT) + +/* Old Streams */ + +#define ENABLE_STREAMS_OLD 0x0c +#define NO_STREAMS_OLD 0xf3 +/* CR69[0] = 1 : Mem-mapped regs */ +#define USE_MM_FOR_PRI_STREAM_OLD 0x01 + + +/* + * There are two different streams engines used in the Savage line. + * The old engine is in the 3D, 4, Pro, and Twister. + * The new engine is in the 2000, MX, IX, and Super. + */ + + +/* streams registers for old engine */ +#define PSTREAM_CONTROL_REG 0x8180 +#define COL_CHROMA_KEY_CONTROL_REG 0x8184 +#define SSTREAM_CONTROL_REG 0x8190 +#define CHROMA_KEY_UPPER_BOUND_REG 0x8194 +#define SSTREAM_STRETCH_REG 0x8198 +#define COLOR_ADJUSTMENT_REG 0x819C +#define BLEND_CONTROL_REG 0x81A0 +#define PSTREAM_FBADDR0_REG 0x81C0 +#define PSTREAM_FBADDR1_REG 0x81C4 +#define PSTREAM_STRIDE_REG 0x81C8 +#define DOUBLE_BUFFER_REG 0x81CC +#define SSTREAM_FBADDR0_REG 0x81D0 +#define SSTREAM_FBADDR1_REG 0x81D4 +#define SSTREAM_STRIDE_REG 0x81D8 +#define SSTREAM_VSCALE_REG 0x81E0 +#define SSTREAM_VINITIAL_REG 0x81E4 +#define SSTREAM_LINES_REG 0x81E8 +#define STREAMS_FIFO_REG 0x81EC +#define PSTREAM_WINDOW_START_REG 0x81F0 +#define PSTREAM_WINDOW_SIZE_REG 0x81F4 +#define SSTREAM_WINDOW_START_REG 0x81F8 +#define SSTREAM_WINDOW_SIZE_REG 0x81FC +#define FIFO_CONTROL 0x8200 +#define PSTREAM_FBSIZE_REG 0x8300 +#define SSTREAM_FBSIZE_REG 0x8304 +#define SSTREAM_FBADDR2_REG 0x8308 + +#define OS_XY(x,y) (((x+1)<<16)|(y+1)) +#define OS_WH(x,y) (((x-1)<<16)|(y)) + +/* New Streams Processor */ +/* Stream Processor 1 */ + +/* Primary Stream 1 Frame Buffer Address 0 */ +#define PRI_STREAM_FBUF_ADDR0 0x81c0 +/* Primary Stream 1 Frame Buffer Address 0 */ +#define PRI_STREAM_FBUF_ADDR1 0x81c4 +/* Primary Stream 1 Stride */ +#define PRI_STREAM_STRIDE 0x81c8 +/* Primary Stream 1 Frame Buffer Size */ +#define PRI_STREAM_BUFFERSIZE 0x8214 + +/* Secondary stream 1 Color/Chroma Key Control */ +#define SEC_STREAM_CKEY_LOW 0x8184 +/* Secondary stream 1 Chroma Key Upper Bound */ +#define SEC_STREAM_CKEY_UPPER 0x8194 +/* Blend Control of Secondary Stream 1 & 2 */ +#define BLEND_CONTROL 0x8190 +/* Secondary Stream 1 Color conversion/Adjustment 1 */ +#define SEC_STREAM_COLOR_CONVERT1 0x8198 +/* Secondary Stream 1 Color conversion/Adjustment 2 */ +#define SEC_STREAM_COLOR_CONVERT2 0x819c +/* Secondary Stream 1 Color conversion/Adjustment 3 */ +#define SEC_STREAM_COLOR_CONVERT3 0x81e4 +/* Secondary Stream 1 Horizontal Scaling */ +#define SEC_STREAM_HSCALING 0x81a0 +/* Secondary Stream 1 Frame Buffer Size */ +#define SEC_STREAM_BUFFERSIZE 0x81a8 +/* Secondary Stream 1 Horizontal Scaling Normalization (2K only) */ +#define SEC_STREAM_HSCALE_NORMALIZE 0x81ac +/* Secondary Stream 1 Horizontal Scaling */ +#define SEC_STREAM_VSCALING 0x81e8 +/* Secondary Stream 1 Frame Buffer Address 0 */ +#define SEC_STREAM_FBUF_ADDR0 0x81d0 +/* Secondary Stream 1 Frame Buffer Address 1 */ +#define SEC_STREAM_FBUF_ADDR1 0x81d4 +/* Secondary Stream 1 Frame Buffer Address 2 */ +#define SEC_STREAM_FBUF_ADDR2 0x81ec +/* Secondary Stream 1 Stride */ +#define SEC_STREAM_STRIDE 0x81d8 +/* Secondary Stream 1 Window Start Coordinates */ +#define SEC_STREAM_WINDOW_START 0x81f8 +/* Secondary Stream 1 Window Size */ +#define SEC_STREAM_WINDOW_SZ 0x81fc +/* Secondary Streams Tile Offset */ +#define SEC_STREAM_TILE_OFF 0x821c +/* Secondary Stream 1 Opaque Overlay Control */ +#define SEC_STREAM_OPAQUE_OVERLAY 0x81dc + + +/* Stream Processor 2 */ + +/* Primary Stream 2 Frame Buffer Address 0 */ +#define PRI_STREAM2_FBUF_ADDR0 0x81b0 +/* Primary Stream 2 Frame Buffer Address 1 */ +#define PRI_STREAM2_FBUF_ADDR1 0x81b4 +/* Primary Stream 2 Stride */ +#define PRI_STREAM2_STRIDE 0x81b8 +/* Primary Stream 2 Frame Buffer Size */ +#define PRI_STREAM2_BUFFERSIZE 0x8218 + +/* Secondary Stream 2 Color/Chroma Key Control */ +#define SEC_STREAM2_CKEY_LOW 0x8188 +/* Secondary Stream 2 Chroma Key Upper Bound */ +#define SEC_STREAM2_CKEY_UPPER 0x818c +/* Secondary Stream 2 Horizontal Scaling */ +#define SEC_STREAM2_HSCALING 0x81a4 +/* Secondary Stream 2 Horizontal Scaling */ +#define SEC_STREAM2_VSCALING 0x8204 +/* Secondary Stream 2 Frame Buffer Size */ +#define SEC_STREAM2_BUFFERSIZE 0x81ac +/* Secondary Stream 2 Frame Buffer Address 0 */ +#define SEC_STREAM2_FBUF_ADDR0 0x81bc +/* Secondary Stream 2 Frame Buffer Address 1 */ +#define SEC_STREAM2_FBUF_ADDR1 0x81e0 +/* Secondary Stream 2 Frame Buffer Address 2 */ +#define SEC_STREAM2_FBUF_ADDR2 0x8208 +/* Multiple Buffer/LPB and Secondary Stream 2 Stride */ +#define SEC_STREAM2_STRIDE_LPB 0x81cc +/* Secondary Stream 2 Color conversion/Adjustment 1 */ +#define SEC_STREAM2_COLOR_CONVERT1 0x81f0 +/* Secondary Stream 2 Color conversion/Adjustment 2 */ +#define SEC_STREAM2_COLOR_CONVERT2 0x81f4 +/* Secondary Stream 2 Color conversion/Adjustment 3 */ +#define SEC_STREAM2_COLOR_CONVERT3 0x8200 +/* Secondary Stream 2 Window Start Coordinates */ +#define SEC_STREAM2_WINDOW_START 0x820c +/* Secondary Stream 2 Window Size */ +#define SEC_STREAM2_WINDOW_SZ 0x8210 +/* Secondary Stream 2 Opaque Overlay Control */ +#define SEC_STREAM2_OPAQUE_OVERLAY 0x8180 + + +#define BASE_PAD 0xf + +#define STREAMS_MODE32 0x7 +#define STREAMS_MODE24 0x6 +#define STREAMS_MODE16 0x5 /* @@@ */ + +#define SSTREAMS_MODE(bpp) (bpp > 16 ? (bpp > 24 ? STREAMS_MODE32 :\ + STREAMS_MODE24) : STREAMS_MODE16) + +#endif /*__SAVAGE_STREAMS_H__*/ diff --git a/src/savage_vbe.c b/src/savage_vbe.c index 70059ca..25e64da 100644 --- a/src/savage_vbe.c +++ b/src/savage_vbe.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_vbe.c,v 1.9 2001/05/19 02:05:55 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_vbe.c,v 1.11 2002/05/14 20:19:52 alanh Exp $ */ #include "savage_driver.h" #include "savage_vbe.h" @@ -35,18 +35,18 @@ SavageSetTextMode( SavagePtr psav ) { /* Restore display device if changed. */ if( psav->iDevInfo != psav->iDevInfoPrim ) { - SavageClearVM86Regs( psav->pInt10 ); - psav->pInt10->ax = 0x4f14; - psav->pInt10->bx = 0x0003; - psav->pInt10->cx = psav->iDevInfoPrim; - xf86ExecX86int10( psav->pInt10 ); + SavageClearVM86Regs( psav->pVbe->pInt10 ); + psav->pVbe->pInt10->ax = 0x4f14; + psav->pVbe->pInt10->bx = 0x0003; + psav->pVbe->pInt10->cx = psav->iDevInfoPrim; + xf86ExecX86int10( psav->pVbe->pInt10 ); } - SavageClearVM86Regs( psav->pInt10 ); + SavageClearVM86Regs( psav->pVbe->pInt10 ); - psav->pInt10->ax = 0x83; + psav->pVbe->pInt10->ax = 0x83; - xf86ExecX86int10( psav->pInt10 ); + xf86ExecX86int10( psav->pVbe->pInt10 ); } @@ -69,31 +69,31 @@ SavageSetVESAMode( SavagePtr psav, int n, int Refresh ) /* Establish the refresh rate for this mode. */ - SavageClearVM86Regs( psav->pInt10 ); - psav->pInt10->ax = 0x4f14; /* S3 extensions */ - psav->pInt10->bx = 0x0001; /* Set default refresh rate */ - psav->pInt10->cx = n & 0x3fff; - psav->pInt10->di = Refresh & 0xffff; + SavageClearVM86Regs( psav->pVbe->pInt10 ); + psav->pVbe->pInt10->ax = 0x4f14; /* S3 extensions */ + psav->pVbe->pInt10->bx = 0x0001; /* Set default refresh rate */ + psav->pVbe->pInt10->cx = n & 0x3fff; + psav->pVbe->pInt10->di = Refresh & 0xffff; - xf86ExecX86int10( psav->pInt10 ); + xf86ExecX86int10( psav->pVbe->pInt10 ); /* Set TV type if TV is on. */ if( psav->TvOn ) { - SavageClearVM86Regs( psav->pInt10 ); - psav->pInt10->ax = 0x4f14; /* S3 extensions */ - psav->pInt10->bx = 0x0007; /* TV extensions */ - psav->pInt10->cx = psav->PAL ? 0x08 : 0x04; - psav->pInt10->dx = 0x0c; - xf86ExecX86int10( psav->pInt10 ); + SavageClearVM86Regs( psav->pVbe->pInt10 ); + psav->pVbe->pInt10->ax = 0x4f14; /* S3 extensions */ + psav->pVbe->pInt10->bx = 0x0007; /* TV extensions */ + psav->pVbe->pInt10->cx = psav->PAL ? 0x08 : 0x04; + psav->pVbe->pInt10->dx = 0x0c; + xf86ExecX86int10( psav->pVbe->pInt10 ); } /* Manipulate output device set. */ if( psav->iDevInfo != iDevInfo ) { - SavageClearVM86Regs( psav->pInt10 ); - psav->pInt10->ax = 0x4f14; /* S3 extensions */ - psav->pInt10->bx = 0x0003; /* set active devices */ - psav->pInt10->cx = psav->iDevInfo; - xf86ExecX86int10( psav->pInt10 ); + SavageClearVM86Regs( psav->pVbe->pInt10 ); + psav->pVbe->pInt10->ax = 0x4f14; /* S3 extensions */ + psav->pVbe->pInt10->bx = 0x0003; /* set active devices */ + psav->pVbe->pInt10->cx = psav->PAL ? 0x08 : 0x04; + xf86ExecX86int10( psav->pVbe->pInt10 ); /* Re-fetch actual device set. */ psav->iDevInfo = SavageGetDevice( psav ); @@ -123,36 +123,17 @@ SavageSetVESAMode( SavagePtr psav, int n, int Refresh ) } -void -SavageSetPanelEnabled( SavagePtr psav, Bool active ) -{ - int iDevInfo; - if( !psav->PanelX ) - return; /* no panel */ - iDevInfo = SavageGetDevice( psav ); - if( active ) - iDevInfo |= LCD_ACTIVE; - else - iDevInfo &= ~LCD_ACTIVE; - SavageClearVM86Regs( psav->pInt10 ); - psav->pInt10->ax = 0x4f14; /* S3 extensions */ - psav->pInt10->bx = 0x0003; /* set active devices */ - psav->pInt10->cx = iDevInfo; - xf86ExecX86int10( psav->pInt10 ); -} - - /* Function to get supported device list. */ static int SavageGetDevice( SavagePtr psav ) { - SavageClearVM86Regs( psav->pInt10 ); - psav->pInt10->ax = 0x4f14; /* S3 extensions */ - psav->pInt10->bx = 0x0103; /* get active devices */ + SavageClearVM86Regs( psav->pVbe->pInt10 ); + psav->pVbe->pInt10->ax = 0x4f14; /* S3 extensions */ + psav->pVbe->pInt10->bx = 0x0103; /* get active devices */ - xf86ExecX86int10( psav->pInt10 ); + xf86ExecX86int10( psav->pVbe->pInt10 ); - return ((psav->pInt10->cx) & 0xf); + return ((psav->pVbe->pInt10->cx) & 0xf); } @@ -169,6 +150,7 @@ SavageFreeBIOSModeTable( SavagePtr psav, SavageModeTablePtr* ppTable ) xfree( pMode->RefreshRate ); pMode->RefreshRate = NULL; } + pMode++; } xfree( *ppTable ); @@ -202,15 +184,14 @@ SavageGetBIOSModes( unsigned short iModeCount = 0; unsigned short int *mode_list; pointer vbeLinear = NULL; - vbeControllerInfoPtr vbe = NULL; + VbeInfoBlock *vbe; int vbeReal; struct vbe_mode_info_block * vmib; if( !psav->pVbe ) return 0; - vbe = (vbeControllerInfoPtr) psav->pVbe->memory; - vbeLinear = xf86Int10AllocPages( psav->pInt10, 1, &vbeReal ); + vbeLinear = xf86Int10AllocPages( psav->pVbe->pInt10, 1, &vbeReal ); if( !vbeLinear ) { ErrorF( "Cannot allocate scratch page in real mode memory." ); @@ -218,12 +199,11 @@ SavageGetBIOSModes( } vmib = (struct vbe_mode_info_block *) vbeLinear; - for ( - mode_list = xf86int10Addr( psav->pInt10, L_ADD(vbe->VideoModePtr) ); - *mode_list != 0xffff; - mode_list++ - ) - { + if (!(vbe = VBEGetVBEInfo(psav->pVbe))) + return 0; + + for (mode_list = vbe->VideoModePtr; *mode_list != 0xffff; mode_list++) { + /* * This is a HACK to work around what I believe is a BUG in the * Toshiba Satellite BIOSes in 08/2000 and 09/2000. The BIOS @@ -239,15 +219,15 @@ SavageGetBIOSModes( if( *mode_list >= 0x0200 ) continue; - SavageClearVM86Regs( psav->pInt10 ); + SavageClearVM86Regs( psav->pVbe->pInt10 ); - psav->pInt10->ax = 0x4f01; - psav->pInt10->cx = *mode_list; - psav->pInt10->es = SEG_ADDR(vbeReal); - psav->pInt10->di = SEG_OFF(vbeReal); - psav->pInt10->num = 0x10; + psav->pVbe->pInt10->ax = 0x4f01; + psav->pVbe->pInt10->cx = *mode_list; + psav->pVbe->pInt10->es = SEG_ADDR(vbeReal); + psav->pVbe->pInt10->di = SEG_OFF(vbeReal); + psav->pVbe->pInt10->num = 0x10; - xf86ExecX86int10( psav->pInt10 ); + xf86ExecX86int10( psav->pVbe->pInt10 ); if( (vmib->bits_per_pixel == iDepth) && @@ -274,8 +254,8 @@ SavageGetBIOSModes( /* Query the refresh rates at this mode. */ - psav->pInt10->cx = *mode_list; - psav->pInt10->dx = 0; + psav->pVbe->pInt10->cx = *mode_list; + psav->pVbe->pInt10->dx = 0; do { @@ -299,14 +279,14 @@ SavageGetBIOSModes( } } - psav->pInt10->ax = 0x4f14; /* S3 extended functions */ - psav->pInt10->bx = 0x0201; /* query refresh rates */ - psav->pInt10->num = 0x10; - xf86ExecX86int10( psav->pInt10 ); + psav->pVbe->pInt10->ax = 0x4f14; /* S3 extended functions */ + psav->pVbe->pInt10->bx = 0x0201; /* query refresh rates */ + psav->pVbe->pInt10->num = 0x10; + xf86ExecX86int10( psav->pVbe->pInt10 ); - s3vModeTable->RefreshRate[iRefresh++] = psav->pInt10->di; + s3vModeTable->RefreshRate[iRefresh++] = psav->pVbe->pInt10->di; } - while( psav->pInt10->dx ); + while( psav->pVbe->pInt10->dx ); s3vModeTable->RefreshCount = iRefresh; @@ -315,7 +295,9 @@ SavageGetBIOSModes( } } - xf86Int10FreePages( psav->pInt10, vbeLinear, 1 ); + VBEFreeVBEInfo(vbe); + + xf86Int10FreePages( psav->pVbe->pInt10, vbeLinear, 1 ); return iModeCount; } diff --git a/src/savage_video.c b/src/savage_video.c index 2e4d78d..56c9a8f 100644 --- a/src/savage_video.c +++ b/src/savage_video.c @@ -1,14 +1,13 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_video.c,v 1.7 2001/11/21 22:43:01 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_video.c,v 1.17tsi Exp $ */ #include "Xv.h" #include "dix.h" #include "dixstruct.h" #include "fourcc.h" +#include "xaalocal.h" #include "savage_driver.h" -#include "savage_regs.h" -#include "savage_bci.h" - +#include "savage_streams.h" #define OFF_DELAY 200 /* milliseconds */ #define FREE_DELAY 60000 @@ -19,24 +18,7 @@ #define TIMER_MASK (OFF_TIMER | FREE_TIMER) -#define HSCALING_Shift 0 -#define HSCALING_Mask (((1L << 16)-1) << HSCALING_Shift) -#define HSCALING(w0,w1) ((((unsigned int)(((double)w0/(double)w1) * (1 << 15))) \ - << HSCALING_Shift) \ - & HSCALING_Mask) - -#define VSCALING_Shift 0 -#define VSCALING_Mask (((1L << 20)-1) << VSCALING_Shift) -#define VSCALING(h0,h1) ((((unsigned int) (((double)h0/(double)h1) * (1 << 15))) \ - << VSCALING_Shift) \ - & VSCALING_Mask) - -#ifndef XvExtension -void SavageInitVideo(ScreenPtr pScreen) {} -void SavageResetVideo(ScrnInfoPtr pScrn) {} -#else - -void myOUTREG( SavagePtr psav, unsigned long offset, unsigned long value ); +void savageOUTREG( SavagePtr psav, unsigned long offset, unsigned long value ); static XF86VideoAdaptorPtr SavageSetupImageVideo(ScreenPtr); static void SavageInitOffscreenImages(ScreenPtr); @@ -51,14 +33,8 @@ static int SavagePutImage( ScrnInfoPtr, static int SavageQueryImageAttributes(ScrnInfoPtr, int, unsigned short *, unsigned short *, int *, int *); -void SavageStreamsOn(ScrnInfoPtr pScrn, int id); -void SavageStreamsOff(ScrnInfoPtr pScrn); void SavageResetVideo(ScrnInfoPtr pScrn); -static void SavageInitStreamsOld(ScrnInfoPtr pScrn); -static void SavageInitStreamsNew(ScrnInfoPtr pScrn); -static void (*SavageInitStreams)(ScrnInfoPtr pScrn) = NULL; - static void SavageSetColorKeyOld(ScrnInfoPtr pScrn); static void SavageSetColorKeyNew(ScrnInfoPtr pScrn); static void (*SavageSetColorKey)(ScrnInfoPtr pScrn) = NULL; @@ -92,10 +68,6 @@ static void (*SavageDisplayVideo)( short drw_w, short drw_h ) = NULL; -static void OverlayTwisterInit(ScrnInfoPtr pScrn); -static void OverlayParamInit(ScrnInfoPtr pScrn); -static void InitStreamsForExpansion(ScrnInfoPtr pScrn); - /*static void SavageBlockHandler(int, pointer, pointer, pointer);*/ #define XVTRACE 4 @@ -227,17 +199,6 @@ typedef struct { #define GET_PORT_PRIVATE(pScrn) \ (SavagePortPrivPtr)((SAVPTR(pScrn))->adaptor->pPortPrivates[0].ptr) - -/* - * There are two different streams engines used in the Savage line. - * The old engine is in the 3D, 4, Pro, and Twister. - * The new engine is in the 2000, MX, IX, and Super. - */ - - -#define OS_XY(x,y) (((x+1)<<16)|(y+1)) -#define OS_WH(x,y) (((x-1)<<16)|(y)) - static unsigned int GetBlendForFourCC( int id ) { @@ -257,280 +218,29 @@ unsigned int GetBlendForFourCC( int id ) } } -void myOUTREG( SavagePtr psav, unsigned long offset, unsigned long value ) +void savageOUTREG( SavagePtr psav, unsigned long offset, unsigned long value ) { - ErrorF( "MMIO %04x, was %08x, want %08x,", - offset, MMIO_IN32( psav->MapBase, offset ), value ); + ErrorF( "MMIO %08lx, was %08lx, want %08lx,", + offset, (CARD32)MMIO_IN32( psav->MapBase, offset ), value ); MMIO_OUT32( psav->MapBase, offset, value ); - ErrorF( " now %08x\n", MMIO_IN32( psav->MapBase, offset ) ); + ErrorF( " now %08lx\n", (CARD32)MMIO_IN32( psav->MapBase, offset ) ); } -void SavageInitStreamsOld(ScrnInfoPtr pScrn) -{ - SavagePtr psav = SAVPTR(pScrn); - /*unsigned long jDelta;*/ - unsigned long format = 0; - /* - * For the OLD streams engine, several of these registers - * cannot be touched unless streams are on. Seems backwards to me; - * I'd want to set 'em up, then cut 'em loose. - */ - - xf86ErrorFVerb(XVTRACE, "SavageInitStreams\n" ); - - /* Primary stream reflects the frame buffer. */ - -/* I don't know if these are needed here or not. seems to work either way - * and the stride should have already been set properly in SavageSetGBD() - */ - if (!psav->bTiled) { - OUTREG(PRI_STREAM_STRIDE, - (((psav->lDelta * 2) << 16) & 0x3FFFE000) | - (psav->lDelta & 0x00001fff)); - } - else if (pScrn->bitsPerPixel == 16) { - /* Scanline-length-in-bytes/128-bytes-per-tile * 256 Qwords/tile */ - OUTREG(PRI_STREAM_STRIDE, - (((psav->lDelta * 2) << 16) & 0x3FFFE000) - | 0x80000000 | (psav->lDelta & 0x00001fff)); - } - else if (pScrn->bitsPerPixel == 32) { - OUTREG(PRI_STREAM_STRIDE, - (((psav->lDelta * 2) << 16) & 0x3FFFE000) - | 0xC0000000 | (psav->lDelta & 0x00001fff)); - } - OUTREG(PSTREAM_FBSIZE_REG, - pScrn->virtualY * pScrn->virtualX * (pScrn->bitsPerPixel >> 3)); - - switch( pScrn->depth ) { - case 8: format = 0 << 24; break; - case 15: format = 3 << 24; break; - case 16: format = 5 << 24; break; - case 24: format = 7 << 24; break; - } - - /*jDelta = pScrn->displayWidth * pScrn->bitsPerPixel / 8;*/ - OUTREG( PSTREAM_WINDOW_START_REG, OS_XY(0,0) ); - OUTREG( PSTREAM_WINDOW_SIZE_REG, OS_WH(pScrn->displayWidth, pScrn->virtualY) ); - OUTREG( PSTREAM_FBADDR0_REG, pScrn->fbOffset ); - OUTREG( PSTREAM_FBADDR1_REG, 0 ); - /*OUTREG( PSTREAM_STRIDE_REG, jDelta );*/ - OUTREG( PSTREAM_CONTROL_REG, format ); - /*OUTREG( PSTREAM_FBSIZE_REG, jDelta * pScrn->virtualY >> 3 );*/ - - OUTREG( COL_CHROMA_KEY_CONTROL_REG, 0 ); - OUTREG( SSTREAM_CONTROL_REG, 0 ); - OUTREG( CHROMA_KEY_UPPER_BOUND_REG, 0 ); - OUTREG( SSTREAM_STRETCH_REG, 0 ); - OUTREG( COLOR_ADJUSTMENT_REG, 0 ); - OUTREG( BLEND_CONTROL_REG, 1 << 24 ); - OUTREG( DOUBLE_BUFFER_REG, 0 ); - OUTREG( SSTREAM_FBADDR0_REG, 0 ); - OUTREG( SSTREAM_FBADDR1_REG, 0 ); - OUTREG( SSTREAM_FBADDR2_REG, 0 ); -/* OUTREG( SSTREAM_FBSIZE_REG, 0 ); */ - OUTREG( SSTREAM_STRIDE_REG, 0 ); - OUTREG( SSTREAM_VSCALE_REG, 0 ); - OUTREG( SSTREAM_LINES_REG, 0 ); - OUTREG( SSTREAM_VINITIAL_REG, 0 ); - OUTREG( SSTREAM_WINDOW_START_REG, OS_XY(0xfffe, 0xfffe) ); - OUTREG( SSTREAM_WINDOW_SIZE_REG, OS_WH(10,2) ); - - if (S3_MOBILE_TWISTER_SERIES(psav->Chipset) && - psav->FPExpansion) { - OverlayTwisterInit(pScrn); - } - -} - -void SavageInitStreamsNew(ScrnInfoPtr pScrn) -{ - SavagePtr psav = SAVPTR(pScrn); - /*unsigned long jDelta;*/ - - xf86ErrorFVerb(XVTRACE, "SavageInitStreams\n" ); - - if( - S3_SAVAGE_MOBILE_SERIES(psav->Chipset) && - !psav->CrtOnly && - !psav->TvOn - ) { - OverlayParamInit( pScrn ); - } - -/* I don't know if these are needed here or not. seems to work either way - * and the stride should have already been set properly in SavageSetGBD() - */ - /* Primary stream reflects the frame buffer. */ - OUTREG32(PRI_STREAM_FBUF_ADDR0, pScrn->fbOffset); - if (!psav->bTiled) { - OUTREG(PRI_STREAM_STRIDE, - (((psav->lDelta * 2) << 16) & 0x3FFFE000) | - (psav->lDelta & 0x00001fff)); - } - else if (pScrn->bitsPerPixel == 16) { - /* Scanline-length-in-bytes/128-bytes-per-tile * 256 Qwords/tile */ - OUTREG(PRI_STREAM_STRIDE, - (((psav->lDelta * 2) << 16) & 0x3FFFE000) - | 0x80000000 | (psav->lDelta & 0x00001fff)); - } - else if (pScrn->bitsPerPixel == 32) { - OUTREG(PRI_STREAM_STRIDE, - (((psav->lDelta * 2) << 16) & 0x3FFFE000) - | 0xC0000000 | (psav->lDelta & 0x00001fff)); - } - OUTREG(PSTREAM_FBSIZE_REG, - pScrn->virtualX * pScrn->virtualY * (pScrn->bitsPerPixel >> 3)); - /* Primary stream reflects the frame buffer. */ -#if 0 - jDelta = pScrn->displayWidth * pScrn->bitsPerPixel / 8; - OUTREG( PRI_STREAM_BUFFERSIZE, jDelta * pScrn->virtualY >> 3 ); - OUTREG( PRI_STREAM_FBUF_ADDR0, pScrn->fbOffset ); - OUTREG( PRI_STREAM_STRIDE, jDelta ); -#endif - OUTREG( SEC_STREAM_CKEY_LOW, 0 ); - OUTREG( SEC_STREAM_CKEY_UPPER, 0 ); - OUTREG( SEC_STREAM_HSCALING, 0 ); - OUTREG( SEC_STREAM_VSCALING, 0 ); - OUTREG( BLEND_CONTROL, 0 ); - OUTREG( SEC_STREAM_FBUF_ADDR0, 0 ); - OUTREG( SEC_STREAM_FBUF_ADDR1, 0 ); - OUTREG( SEC_STREAM_FBUF_ADDR2, 0 ); - OUTREG( SEC_STREAM_WINDOW_START, 0 ); - OUTREG( SEC_STREAM_WINDOW_SZ, 0 ); -/* OUTREG( SEC_STREAM_BUFFERSIZE, 0 ); */ - OUTREG( SEC_STREAM_TILE_OFF, 0 ); - OUTREG( SEC_STREAM_OPAQUE_OVERLAY, 0 ); - OUTREG( SEC_STREAM_STRIDE, 0 ); - - /* These values specify brightness, contrast, saturation and hue. */ - OUTREG( SEC_STREAM_COLOR_CONVERT1, 0x0000C892 ); - OUTREG( SEC_STREAM_COLOR_CONVERT2, 0x00039F9A ); - OUTREG( SEC_STREAM_COLOR_CONVERT3, 0x01F1547E ); -} - -void SavageStreamsOn(ScrnInfoPtr pScrn, int id) +static void +SavageClipVWindow(ScrnInfoPtr pScrn) { SavagePtr psav = SAVPTR(pScrn); - unsigned char jStreamsControl; - unsigned short vgaCRIndex = psav->vgaIOBase + 4; - unsigned short vgaCRReg = psav->vgaIOBase + 5; - - xf86ErrorFVerb(XVTRACE, "SavageStreamsOn\n" ); - - /* Sequence stolen from streams.c in M7 NT driver */ - - xf86EnableIO(); - - /* Unlock extended registers. */ - - VGAOUT16(vgaCRIndex, 0x4838); - VGAOUT16(vgaCRIndex, 0xa039); - VGAOUT16(0x3c4, 0x0608); - - if( - S3_SAVAGE_MOBILE_SERIES(psav->Chipset) && - !psav->CrtOnly && - !psav->TvOn - ) { - OverlayParamInit( pScrn ); - } - - VGAOUT8( vgaCRIndex, EXT_MISC_CTRL2 ); - - if( S3_SAVAGE_MOBILE_SERIES(psav->Chipset) || - (psav->Chipset == S3_SAVAGE2000) ) - { - jStreamsControl = VGAIN8( vgaCRReg ) | ENABLE_STREAM1; - - /* Wait for VBLANK. */ - - VerticalRetraceWait(); - - /* Fire up streams! */ - - VGAOUT16( vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2 ); - - psav->blendBase = GetBlendForFourCC( id ) << 9; - xf86ErrorFVerb(XVTRACE+1,"Format %4.4s, blend is %08x\n", &id, psav->blendBase ); - OUTREG( BLEND_CONTROL, psav->blendBase | 0x08 ); - - /* These values specify brightness, contrast, saturation and hue. */ - OUTREG( SEC_STREAM_COLOR_CONVERT1, 0x0000C892 ); - OUTREG( SEC_STREAM_COLOR_CONVERT2, 0x00039F9A ); - OUTREG( SEC_STREAM_COLOR_CONVERT3, 0x01F1547E ); - } - else - { - if (S3_MOBILE_TWISTER_SERIES(psav->Chipset) - && psav->FPExpansion) { - jStreamsControl = VGAIN8( vgaCRReg ) | ENABLE_STREAMS_OLD; /* tim */ - /*jStreamsControl = VGAIN8( vgaCRReg ) | 0x8c;*/ /* S3 */ - } else { - jStreamsControl = VGAIN8( vgaCRReg ) | ENABLE_STREAMS_OLD; /* tim */ - /*jStreamsControl = VGAIN8( vgaCRReg ) | 0x04;*/ /* S3 */ - } - /* Wait for VBLANK. */ - - VerticalRetraceWait(); - - /* Fire up streams! */ - - VGAOUT16( vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2 ); - - SavageInitStreamsOld( pScrn ); + + if( (psav->Chipset == S3_SAVAGE_MX) || + (psav->Chipset == S3_SUPERSAVAGE) || + (psav->Chipset == S3_SAVAGE2000) ) { + OUTREG(SEC_STREAM_WINDOW_SZ, 0); + + } else { + OUTREG( SSTREAM_WINDOW_SIZE_REG, 1); + OUTREG( SSTREAM_WINDOW_START_REG, 0x03ff03ff); } - - /* Wait for VBLANK. */ - - VerticalRetraceWait(); - - /* Turn on secondary stream TV flicker filter, once we support TV. */ - - /* SR70 |= 0x10 */ - - psav->videoFlags |= VF_STREAMS_ON; - psav->videoFourCC = id; -} - -void SavageStreamsOff(ScrnInfoPtr pScrn) -{ - SavagePtr psav = SAVPTR(pScrn); - unsigned char jStreamsControl; - unsigned short vgaCRIndex = psav->vgaIOBase + 4; - unsigned short vgaCRReg = psav->vgaIOBase + 5; - - xf86ErrorFVerb(XVTRACE, "SavageStreamsOff\n" ); - - xf86EnableIO(); - - /* Unlock extended registers. */ - - VGAOUT16(vgaCRIndex, 0x4838); - VGAOUT16(vgaCRIndex, 0xa039); - VGAOUT16(0x3c4, 0x0608); - - VGAOUT8( vgaCRIndex, EXT_MISC_CTRL2 ); - if( S3_SAVAGE_MOBILE_SERIES(psav->Chipset) || - (psav->Chipset == S3_SAVAGE2000) ) - jStreamsControl = VGAIN8( vgaCRReg ) & NO_STREAMS; - else - jStreamsControl = VGAIN8( vgaCRReg ) & NO_STREAMS_OLD; - - /* Wait for VBLANK. */ - - VerticalRetraceWait(); - - /* Kill streams. */ - - VGAOUT16( vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2 ); - - VGAOUT16( vgaCRIndex, 0x0093 ); - VGAOUT8( vgaCRIndex, 0x92 ); - VGAOUT8( vgaCRReg, VGAIN8(vgaCRReg) & 0x40 ); - - psav->videoFlags &= ~VF_STREAMS_ON; } void SavageInitVideo(ScreenPtr pScreen) @@ -544,13 +254,13 @@ void SavageInitVideo(ScreenPtr pScreen) xf86ErrorFVerb(XVTRACE,"SavageInitVideo\n"); if( S3_SAVAGE_MOBILE_SERIES(psav->Chipset) || + (psav->Chipset == S3_SUPERSAVAGE) || (psav->Chipset == S3_SAVAGE2000) ) { newAdaptor = SavageSetupImageVideo(pScreen); SavageInitOffscreenImages(pScreen); - SavageInitStreams = SavageInitStreamsNew; SavageSetColor = SavageSetColorNew; SavageSetColorKey = SavageSetColorKeyNew; SavageDisplayVideo = SavageDisplayVideoNew; @@ -561,7 +271,6 @@ void SavageInitVideo(ScreenPtr pScreen) SavageInitOffscreenImages(pScreen); /*DELETENEXTLINE*/ /* Since newAdaptor is still NULL, these are still disabled for now. */ - SavageInitStreams = SavageInitStreamsOld; SavageSetColor = SavageSetColorOld; SavageSetColorKey = SavageSetColorKeyOld; SavageDisplayVideo = SavageDisplayVideoOld; @@ -594,9 +303,6 @@ void SavageInitVideo(ScreenPtr pScreen) if( newAdaptor ) { - if( SavageInitStreams == SavageInitStreamsNew ) - SavageInitStreams(pScrn); - psav->videoFlags = 0; psav->videoFourCC = 0; } } @@ -709,7 +415,7 @@ void SavageSetColorOld( ScrnInfoPtr pScrn ) SavagePortPrivPtr pPriv = psav->adaptor->pPortPrivates[0].ptr; xf86ErrorFVerb(XVTRACE, "bright %d, contrast %d, saturation %d, hue %d\n", - pPriv->brightness, pPriv->contrast, pPriv->saturation, pPriv->hue ); + pPriv->brightness, (int)pPriv->contrast, (int)pPriv->saturation, pPriv->hue ); if( (psav->videoFourCC == FOURCC_RV15) || @@ -751,7 +457,7 @@ void SavageSetColorNew( ScrnInfoPtr pScrn ) unsigned long assembly; xf86ErrorFVerb(XVTRACE, "bright %d, contrast %d, saturation %d, hue %d\n", - pPriv->brightness, pPriv->contrast, pPriv->saturation, pPriv->hue ); + pPriv->brightness, (int)pPriv->contrast, (int)pPriv->saturation, pPriv->hue ); if( psav->videoFourCC == FOURCC_Y211 ) k = 1.0; /* YUV */ @@ -779,20 +485,20 @@ void SavageSetColorNew( ScrnInfoPtr pScrn ) k2 = (int)(dk2+0.5) & 0x1ff; k3 = (int)(dk3+0.5) & 0x1ff; assembly = (k3<<18) | (k2<<9) | k1; - xf86ErrorFVerb(XVTRACE+1, "CC1 = %08x ", assembly ); + xf86ErrorFVerb(XVTRACE+1, "CC1 = %08lx ", assembly ); OUTREG( SEC_STREAM_COLOR_CONVERT1, assembly ); k4 = (int)(dk4+0.5) & 0x1ff; k5 = (int)(dk5+0.5) & 0x1ff; k6 = (int)(dk6+0.5) & 0x1ff; assembly = (k6<<18) | (k5<<9) | k4; - xf86ErrorFVerb(XVTRACE+1, "CC2 = %08x ", assembly ); + xf86ErrorFVerb(XVTRACE+1, "CC2 = %08lx ", assembly ); OUTREG( SEC_STREAM_COLOR_CONVERT2, assembly ); k7 = (int)(dk7+0.5) & 0x1ff; kb = (int)(dkb+0.5) & 0xffff; assembly = (kb<<9) | k7; - xf86ErrorFVerb(XVTRACE+1, "CC3 = %08x\n", assembly ); + xf86ErrorFVerb(XVTRACE+1, "CC3 = %08lx\n", assembly ); OUTREG( SEC_STREAM_COLOR_CONVERT3, assembly ); } @@ -873,14 +579,14 @@ SavageSetupImageVideo(ScreenPtr pScreen) pPriv->lastKnownPitch = 0; /* gotta uninit this someplace */ - REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); + REGION_NULL(pScreen, &pPriv->clip); psav->adaptor = adapt; - #if 0 +#if 0 psav->BlockHandler = pScreen->BlockHandler; pScreen->BlockHandler = SavageBlockHandler; - #endif +#endif return adapt; } @@ -971,7 +677,8 @@ SavageStopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown) REGION_EMPTY(pScrn->pScreen, &pPriv->clip); if(shutdown) { - SavageStreamsOff( pScrn ); + SavageClipVWindow(pScrn); +/* SavageStreamsOff( pScrn ); */ if(pPriv->area) { xf86FreeOffscreenArea(pPriv->area); pPriv->area = NULL; @@ -1083,89 +790,6 @@ SavageQueryBestSize( if(*p_w > 16384) *p_w = 16384; } -/* SavageCopyPlanarDataBCI() causes artifacts on the screen when used on savage4. - * It's probably something with the BCI. Maybe we need a waitforidle() or - * something... - */ -static void -SavageCopyPlanarDataBCI( - ScrnInfoPtr pScrn, - unsigned char *srcY, /* Y */ - unsigned char *srcV, /* V */ - unsigned char *srcU, /* U */ - unsigned char *dst, - int srcPitch, int srcPitch2, - int dstPitch, - int h,int w) -{ - SavagePtr psav = SAVPTR(pScrn); - /* half of the dest buffer for copying the YVU data to it ??? */ - unsigned char *dstCopy = (unsigned char *)(((unsigned long)dst - + 2 * srcPitch * h - + 0x0f) & ~0x0f); - /* for pixel transfer */ - unsigned long offsetY = (unsigned long)dstCopy - (unsigned long)psav->FBBase; - unsigned long offsetV = offsetY + srcPitch * h; - unsigned long offsetU = offsetV + srcPitch2 * (h>>1); - unsigned long dstOffset = (unsigned long)dst - (unsigned long)psav->FBBase; - int i; - - BCI_GET_PTR; - - /* copy Y planar */ - for (i=0;i<srcPitch * h;i++) { - dstCopy[i] = srcY[i]; - } - - /* copy V planar */ - dstCopy = dstCopy + srcPitch * h; - for (i=0;i<srcPitch2 * (h>>1);i++) { - dstCopy[i] = srcV[i]; - } - - /* copy U planar */ - dstCopy = dstCopy + srcPitch2 * (h>>1); - for (i=0;i<srcPitch2 * (h>>1);i++) { - dstCopy[i] = srcU[i]; - } - - /* - * Transfer pixel data from one memory location to another location - * and reformat the data during the transfer - * a. program BCI51 to specify the source information - * b. program BCI52 to specify the destination information - * c. program BCI53 to specify the source dimensions - * d. program BCI54 to specify the destination dimensions - * e. (if the data is in YCbCr420 format)program BCI55,BCI56,BCI57 to - * locations of the Y,Cb,and Cr data - * f. program BCI50(command=011) to specify the formatting options and - * kick off the transfer - * this command can be used for color space conversion(YCbCr to RGB) - * or for oversampling, but not for both simultaneously. it can also be - * used to do mastered image transfer when the source is tiled - */ - - w = (w+0xf)&0xff0; - psav->WaitQueue(psav,11); - BCI_SEND(0x96070051); - BCI_SEND(offsetY); - - BCI_SEND(dstOffset); - - BCI_SEND(((h-1)<<16)|((w-1)>>3)); - - BCI_SEND(dstPitch >> 3); - - - BCI_SEND(offsetU); - BCI_SEND(offsetV); - - BCI_SEND((srcPitch2 << 16)| srcPitch2); - - BCI_SEND(0x96010050); - BCI_SEND(0x00200003 | srcPitch); - BCI_SEND(0xC0170000); -} static void SavageCopyData( @@ -1265,6 +889,22 @@ SavageAllocateMemory( } static void +SavageSetBlend(ScrnInfoPtr pScrn, int id) +{ + SavagePtr psav = SAVPTR(pScrn); + + if( S3_SAVAGE_MOBILE_SERIES(psav->Chipset) || + (psav->Chipset == S3_SUPERSAVAGE) || + (psav->Chipset == S3_SAVAGE2000) ) + { + psav->blendBase = GetBlendForFourCC( id ) << 9; + xf86ErrorFVerb(XVTRACE+1,"Format %4.4s, blend is %08x\n", (char*)&id, psav->blendBase ); + OUTREG( BLEND_CONTROL, psav->blendBase | 0x08 ); + } + psav->videoFourCC = id; +} + +static void SavageDisplayVideoOld( ScrnInfoPtr pScrn, int id, @@ -1281,39 +921,22 @@ SavageDisplayVideoOld( SavagePortPrivPtr pPriv = psav->adaptor->pPortPrivates[0].ptr; /*DisplayModePtr mode = pScrn->currentMode;*/ int vgaCRIndex, vgaCRReg, vgaIOBase; - unsigned int ssControl; - int scalratio; + CARD32 ssControl; vgaIOBase = hwp->IOBase; vgaCRIndex = vgaIOBase + 4; vgaCRReg = vgaIOBase + 5; - if( psav->videoFourCC != id ) - SavageStreamsOff(pScrn); - - if( !psav->videoFlags & VF_STREAMS_ON ) - { - SavageStreamsOn(pScrn, id); + if ( psav->videoFourCC != id ) { + SavageSetBlend(pScrn,id); SavageResetVideo(pScrn); } - /* Calculate horizontal scale factor. */ - if (S3_MOBILE_TWISTER_SERIES(psav->Chipset) - && psav->FPExpansion) { - drw_w = (((float)(drw_w * psav->XExp1)/(float)psav->XExp2)+1); - drw_h = (float)(drw_h * psav->YExp1)/(float)psav->YExp2+1; - dstBox->x1 = (float)(dstBox->x1 * psav->XExp1)/(float)psav->XExp2; - dstBox->y1 = (float)(dstBox->y1 * psav->YExp1)/(float)psav->YExp2; - - dstBox->x1 += psav->displayXoffset; - dstBox->y1 += psav->displayYoffset; - } - /* Set surface format. */ - - OUTREG(SSTREAM_CONTROL_REG, - (GetBlendForFourCC(psav->videoFourCC) << 24) + src_w ); + ssControl = (GetBlendForFourCC(psav->videoFourCC) << 24) | src_w; + + OUTREG(SSTREAM_CONTROL_REG, ssControl); /* Calculate horizontal scale factor. */ @@ -1321,73 +944,36 @@ SavageDisplayVideoOld( /* Calculate vertical scale factor. */ - /* - * MM81E8:Secondary Stream Source Line Count - * bit_0~10: # of lines in the source image (before scaling) - * bit_15 = 1: Enable vertical interpolation - * 0: Line duplicaion - */ - OUTREG(SSTREAM_LINES_REG, 0x00008000 | src_h ); + OUTREG(SSTREAM_LINES_REG, src_h ); OUTREG(SSTREAM_VINITIAL_REG, 0 ); - /*OUTREG(SSTREAM_VSCALE_REG, (src_h << 15) / drw_h );*/ - OUTREG(SSTREAM_VSCALE_REG, VSCALING(src_h,drw_h)); + OUTREG(SSTREAM_VSCALE_REG, (src_h << 15) / drw_h ); /* Set surface location and stride. */ - OUTREG(SSTREAM_FBADDR0_REG, (offset + (x1>>15)) & 0x3ffff0 ); - OUTREG(SSTREAM_FBADDR1_REG, 0 ); - + OUTREG(SSTREAM_FBADDR0_REG, (offset + (x1>>15)) & (0x1ffffff & ~BASE_PAD) ); OUTREG(SSTREAM_STRIDE_REG, pitch & 0xfff ); OUTREG(SSTREAM_WINDOW_START_REG, OS_XY(dstBox->x1, dstBox->y1) ); - OUTREG(SSTREAM_WINDOW_SIZE_REG, OS_WH(drw_w, drw_h) ); + OUTREG(SSTREAM_WINDOW_SIZE_REG, OS_WH(dstBox->x2-dstBox->x1, + dstBox->y2-dstBox->y1)); - /* - * Process horizontal scaling - * upscaling and downscaling smaller than 2:1 controled by MM8198 - * MM8190 controls downscaling mode larger than 2:1 - */ - scalratio = 0; - ssControl = 0; -#if 0 if( src_w > (drw_w << 1) ) { - /* BUGBUG shouldn't this be >=? */ if( src_w <= (drw_w << 2) ) ssControl |= HDSCALE_4; - else if( src_w > (drw_w << 3) ) + else if( src_w <= (drw_w << 3) ) ssControl |= HDSCALE_8; - else if( src_w > (drw_w << 4) ) + else if( src_w <= (drw_w << 4) ) ssControl |= HDSCALE_16; - else if( src_w > (drw_w << 5) ) + else if( src_w <= (drw_w << 5) ) ssControl |= HDSCALE_32; - else if( src_w > (drw_w << 6) ) + else if( src_w <= (drw_w << 6) ) ssControl |= HDSCALE_64; } -#endif - if (src_w >= (drw_w * 2)) { - if (src_w < (drw_w * 4)) { - scalratio = HSCALING(2,1); - } else if (src_w < (drw_w * 8)) { - ssControl |= HDSCALE_4; - } else if (src_w < (drw_w * 16)) { - ssControl |= HDSCALE_8; - } else if (src_w < (drw_w * 32)) { - ssControl |= HDSCALE_16; - } else if (src_w < (drw_w * 64)) { - ssControl |= HDSCALE_32; - } else - ssControl |= HDSCALE_64; - } else - scalratio = HSCALING(src_w,drw_w); ssControl |= src_w; ssControl |= (1 << 24); - /* Wait for VBLANK. */ - VerticalRetraceWait(); OUTREG(SSTREAM_CONTROL_REG, ssControl); - if (scalratio) - OUTREG(SSTREAM_STRETCH_REG,scalratio); #if 0 /* Set color key on primary. */ @@ -1410,7 +996,7 @@ SavageDisplayVideoOld( VGAOUT8(vgaCRIndex, 0x93); VGAOUT8(vgaCRReg, pitch); } - + OUTREG(STREAMS_FIFO_REG, 0x2 | 25 << 5 | 32 << 11); } static void @@ -1436,12 +1022,8 @@ SavageDisplayVideoNew( vgaCRIndex = vgaIOBase + 4; vgaCRReg = vgaIOBase + 5; - if( psav->videoFourCC != id ) - SavageStreamsOff(pScrn); - - if( !psav->videoFlags & VF_STREAMS_ON ) - { - SavageStreamsOn(pScrn, id); + if ( psav->videoFourCC != id ) { + SavageSetBlend(pScrn,id); SavageResetVideo(pScrn); } @@ -1486,10 +1068,12 @@ SavageDisplayVideoNew( * are 2 bytes/pixel. */ - OUTREG(SEC_STREAM_FBUF_ADDR0, (offset + (x1>>15)) & 0x7ffff0 ); + OUTREG(SEC_STREAM_FBUF_ADDR0, (offset + (x1>>15)) + & (0x7ffffff & ~BASE_PAD)); OUTREG(SEC_STREAM_STRIDE, pitch & 0xfff ); OUTREG(SEC_STREAM_WINDOW_START, ((dstBox->x1+1) << 16) | (dstBox->y1+1) ); - OUTREG(SEC_STREAM_WINDOW_SZ, ((drw_w) << 16) | drw_h ); + OUTREG(SEC_STREAM_WINDOW_SZ, ((dstBox->x2-dstBox->x1) << 16) + | (dstBox->x2-dstBox->x1) ); #if 0 /* Set color key on primary. */ @@ -1527,6 +1111,7 @@ SavagePutImage( ){ SavagePortPrivPtr pPriv = (SavagePortPrivPtr)data; SavagePtr psav = SAVPTR(pScrn); + ScreenPtr pScreen = pScrn->pScreen; INT32 x1, x2, y1, y2; unsigned char *dst_start; int pitch, new_h, offset, offsetV=0, offsetU=0; @@ -1535,20 +1120,6 @@ SavagePutImage( BoxRec dstBox; CARD32 tmp; /* xf86ErrorFVerb(XVTRACE,"SavagePutImage\n"); */ - - if( psav->cxScreen != pScrn->currentMode->HDisplay ) - { - /* The mode has changed. Recompute the offsets. */ - - if( - S3_SAVAGE_MOBILE_SERIES(psav->Chipset) && - !psav->CrtOnly && - !psav->TvOn - ) { - OverlayParamInit( pScrn ); - } - } - if(drw_w > 16384) drw_w = 16384; /* Clip */ @@ -1616,8 +1187,8 @@ SavagePutImage( npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left; left <<= 1; - offset = (pPriv->area->box.y1 * pitch) + (top * dstPitch); - dst_start = psav->FBBase + offset + left; + offset = ((pPriv->area->box.y1 * pitch)) + (top * dstPitch); + dst_start = (psav->FBBase + ((offset + left) & ~BASE_PAD)); switch(id) { case FOURCC_YV12: /* YV12 */ @@ -1625,23 +1196,13 @@ SavagePutImage( top &= ~1; tmp = ((top >> 1) * srcPitch2) + (left >> 2); offsetU += tmp; - offsetV += tmp; + offsetV += tmp; nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; - if (S3_SAVAGE4_SERIES(psav->Chipset) && psav->BCIforXv - /*&& (!psav->disableCOB)*/) { - SavageCopyPlanarDataBCI( - pScrn, - buf + (top * srcPitch) + (left >> 1), - buf + offsetV, - buf + offsetU, - dst_start, srcPitch, srcPitch2, dstPitch, nlines, npixels); - } else { - SavageCopyPlanarData( - buf + (top * srcPitch) + (left >> 1), - buf + offsetV, - buf + offsetU, - dst_start, srcPitch, srcPitch2, dstPitch, nlines, npixels); - } + SavageCopyPlanarData( + buf + (top * srcPitch) + (left >> 1), + buf + offsetV, + buf + offsetU, + dst_start, srcPitch, srcPitch2, dstPitch, nlines, npixels); break; case FOURCC_Y211: /* Y211 */ case FOURCC_RV15: /* RGB15 */ @@ -1665,7 +1226,6 @@ SavagePutImage( REGION_COPY(pScreen, &pPriv->clip, clipBoxes); /* draw these */ xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes); - } pPriv->videoStatus = CLIENT_VIDEO_ON; @@ -1689,10 +1249,6 @@ SavageQueryImageAttributes( if(offsets) offsets[0] = 0; switch(id) { - case FOURCC_IA44: - if (pitches) pitches[0]=*w; - size=(*w)*(*h); - break; case FOURCC_Y211: size = *w << 2; if(pitches) pitches[0] = size; @@ -1725,6 +1281,7 @@ SavageQueryImageAttributes( return size; } + /****************** Offscreen stuff ***************/ typedef struct { @@ -1791,7 +1348,7 @@ SavageStopSurface( if(pPriv->isOn) { /*SavagePtr psav = SAVPTR(surface->pScrn);*/ - SavageStreamsOff( surface->pScrn ); + SavageClipVWindow(surface->pScrn); pPriv->isOn = FALSE; } @@ -1847,6 +1404,7 @@ SavageDisplaySurface( ){ OffscreenPrivPtr pPriv = (OffscreenPrivPtr)surface->devPrivate.ptr; ScrnInfoPtr pScrn = surface->pScrn; + ScreenPtr pScreen = pScrn->pScreen; SavagePortPrivPtr portPriv = GET_PORT_PRIVATE(pScrn); INT32 x1, y1, x2, y2; BoxRec dstBox; @@ -1883,7 +1441,7 @@ SavageDisplaySurface( pPriv->isOn = TRUE; #if 0 if(portPriv->videoStatus & CLIENT_VIDEO_ON) { - REGION_EMPTY(pScrn->pScreen, &portPriv->clip); + REGION_EMPTY(pScreen, &portPriv->clip); UpdateCurrentTime(); portPriv->videoStatus = FREE_TIMER; portPriv->freeTime = currentTime.milliseconds + FREE_DELAY; @@ -1925,144 +1483,3 @@ SavageInitOffscreenImages(ScreenPtr pScreen) xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1); } - -static -void PatchEnableSPofPanel(ScrnInfoPtr pScrn) -{ - SavagePtr psav = SAVPTR(pScrn); - - UnLockExtRegs(); - - if (pScrn->bitsPerPixel == 8) { - OUTREG8(CRT_ADDRESS_REG,0x90); - OUTREG8(CRT_DATA_REG,INREG8(CRT_DATA_REG)|0x40); - } - else { - OUTREG8(CRT_ADDRESS_REG,0x90); - OUTREG8(CRT_DATA_REG,INREG8(CRT_DATA_REG)|0x48); - } - - VerticalRetraceWait(); - - OUTREG8(CRT_ADDRESS_REG,0x67); - OUTREG8(CRT_DATA_REG,(INREG8(CRT_DATA_REG)&0xf3)|0x04); - - OUTREG8(CRT_ADDRESS_REG,0x65); - OUTREG8(CRT_DATA_REG,INREG8(CRT_DATA_REG)|0xC0); - - if (pScrn->bitsPerPixel == 8) { - OUTREG32(PSTREAM_CONTROL_REG,0x00000000); - } else { - OUTREG32(PSTREAM_CONTROL_REG,0x02000000); - } - OUTREG32(PSTREAM_WINDOW_SIZE_REG, 0x0); - -} - -/* - * Function to get lcd factor, display offset for overlay use - * Input: pScrn; Output: x,yfactor, displayoffset in pScrn - */ -static void OverlayTwisterInit(ScrnInfoPtr pScrn) -{ - SavagePtr psav = SAVPTR(pScrn); - - psav->cxScreen = psav->iResX; - InitStreamsForExpansion(pScrn); - PatchEnableSPofPanel(pScrn); -} - -/* Function to get lcd factor, display offset for overlay use - * Input: pScrn; Output: x,yfactor, displayoffset in pScrn - */ -static void OverlayParamInit(ScrnInfoPtr pScrn) -{ - SavagePtr psav = SAVPTR(pScrn); - - psav = SAVPTR(pScrn); - psav->cxScreen = pScrn->currentMode->HDisplay; - InitStreamsForExpansion(pScrn); -} - -/* Function to calculate lcd expansion x,y factor and offset for overlay - */ -static void InitStreamsForExpansion(ScrnInfoPtr pScrn) -{ - SavagePtr psav = SAVPTR(pScrn); - int PanelSizeX,PanelSizeY; - int ViewPortWidth,ViewPortHeight; - int XExpansion, YExpansion; - int XFactor, YFactor; - int Hstate, Vstate; - - static CARD32 Xfactors[] = { - 0x00010001, - 0x00010001, /* 1 */ - 0, - 0x00090008, /* 3 */ - 0x00050004, /* 4 */ - 0, - 0x00030002, /* 6 */ - 0x00020001 /* 7 */ - }; - - static CARD32 Yfactors[] = { - 0x00010001, 0x00010001, - 0, 0x00060005, - 0x00050004, 0x00040003, - 0, 0x00030002, - 0x00020001, 0x00050002, - 0x000C0005, 0x00080003, - 0x00090004, 0, - 0x00030001, 0x00040001, - }; - - - - PanelSizeX = psav->PanelX; - PanelSizeY = psav->PanelY; - ViewPortWidth = pScrn->currentMode->HDisplay; - ViewPortHeight = pScrn->currentMode->VDisplay; - - if( PanelSizeX == 1408 ) - PanelSizeX = 1400; - - XExpansion = 0x00010001; - YExpansion = 0x00010001; - - psav->displayXoffset = 0; - psav->displayYoffset = 0; - - VGAOUT8(0x3C4, HZEXP_COMP_1); - Hstate = VGAIN8(0x3C5); - VGAOUT8(0x3C4, VTEXP_COMP_1); - Vstate = VGAIN8(0x3C5); - VGAOUT8(0x3C4, HZEXP_FACTOR_IGA1); - XFactor = VGAIN8(0x3C5); - VGAOUT8(0x3C4, VTEXP_FACTOR_IGA1); - YFactor = VGAIN8(0x3C5); - - if( Hstate & EC1_EXPAND_ON ) - { - XExpansion = Xfactors[XFactor>>4]; - } - - if( Vstate & EC1_EXPAND_ON ) - { - YExpansion = Yfactors[YFactor>>4]; - } - - psav->XExp1 = XExpansion >> 16; - psav->XExp2 = XExpansion & 0xFFFF; - - psav->YExp1 = YExpansion >> 16; - psav->YExp2 = YExpansion & 0xFFFF; - - psav->displayXoffset = - ((PanelSizeX - (psav->XExp1 * ViewPortWidth) / psav->XExp2) / 2 + 7) & 0xfff8; - psav->displayYoffset = - ((PanelSizeY - (psav->YExp1 * ViewPortHeight) / psav->YExp2) / 2); - -} /* InitStreamsForExpansionPM */ - -#endif /* XvExtension */ |