summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-09-15 16:34:02 +0000
committerAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-09-15 16:34:02 +0000
commit1b368984e8802e9d148af57bda5ba9f5562415ed (patch)
treeeea7adb5c6c9984f73ea5dd459c5e16e29b5fdaf
parent70a541832e31fafcc5c26488992f5bf45812da2e (diff)
-rw-r--r--src/savage_accel.c46
-rw-r--r--src/savage_bci.h6
-rw-r--r--src/savage_cursor.c26
-rw-r--r--src/savage_dri.c2172
-rw-r--r--src/savage_dri.h184
-rw-r--r--src/savage_dripriv.h46
-rw-r--r--src/savage_driver.c477
-rw-r--r--src/savage_driver.h34
-rw-r--r--src/savage_drm.h248
-rw-r--r--src/savage_hwmc.c403
-rw-r--r--src/savage_image.c10
-rw-r--r--src/savage_regs.h95
-rw-r--r--src/savage_sarea.h57
-rw-r--r--src/savage_streams.c461
-rw-r--r--src/savage_streams.h177
-rw-r--r--src/savage_vbe.c110
-rw-r--r--src/savage_video.c539
17 files changed, 4274 insertions, 817 deletions
diff --git a/src/savage_accel.c b/src/savage_accel.c
index e995a6e..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;
@@ -604,7 +608,7 @@ SavageHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop)
if(pm == infoRec->FullPlanemask) {
if(!NO_SRC_ROP(*rop))
ret |= ROP_PAT;
- *rop = XAACopyROP[*rop];
+ *rop = XAAGetCopyROP(*rop);
} else {
switch(*rop) {
case GXnoop:
@@ -621,7 +625,7 @@ SavageHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, int pm, int *rop)
ret |= ROP_PAT | ROP_SRC;
break;
}
- *rop = XAACopyROP_PM[*rop];
+ *rop = XAAGetCopyROP_PM(*rop);
}
return ret;
@@ -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;
@@ -639,7 +643,7 @@ SavageHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop)
if(pm == infoRec->FullPlanemask) {
if(!NO_SRC_ROP(*rop))
ret |= ROP_PAT;
- *rop = XAACopyROP[*rop];
+ *rop = XAAGetCopyROP(*rop);
} else {
switch(*rop) {
case GXnoop:
@@ -654,7 +658,7 @@ SavageHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop)
ret |= ROP_PAT | ROP_SRC;
break;
}
- *rop = XAACopyROP_PM[*rop];
+ *rop = XAAGetCopyROP_PM(*rop);
}
return ret;
@@ -682,7 +686,7 @@ SavageSetupForScreenToScreenCopy(
int cmd;
cmd = BCI_CMD_RECT | BCI_CMD_DEST_GBD | BCI_CMD_SRC_GBD;
- BCI_CMD_SET_ROP( cmd, XAACopyROP[rop] );
+ BCI_CMD_SET_ROP( cmd, XAAGetCopyROP(rop) );
if (transparency_color != -1)
cmd |= BCI_CMD_SEND_COLOR | BCI_CMD_SRC_TRANSPARENT;
@@ -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 f5d44e3..0c57957 100644
--- a/src/savage_bci.h
+++ b/src/savage_bci.h
@@ -10,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
diff --git a/src/savage_cursor.c b/src/savage_cursor.c
index 60fa45d..ad4aa9f 100644
--- a/src/savage_cursor.c
+++ b/src/savage_cursor.c
@@ -81,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
@@ -94,7 +94,10 @@ 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;
@@ -144,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);
@@ -225,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. */
@@ -247,6 +253,7 @@ SavageSetCursorColors(
outCRReg(0x4b, bg >> 16);
return;
}
+#if 0
else if( (pScrn->depth == 15) || (pScrn->depth == 16) )
{
if (pScrn->depth == 15) {
@@ -296,4 +303,5 @@ SavageSetCursorColors(
outCRReg(0x4b, bg);
outCRReg(0x4b, bg);
}
+#endif
}
diff --git a/src/savage_dri.c b/src/savage_dri.c
new file mode 100644
index 0000000..08fa24d
--- /dev/null
+++ b/src/savage_dri.c
@@ -0,0 +1,2172 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef XF86DRI
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Priv.h"
+
+#include "xaalocal.h"
+#include "xaarop.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+#include "xf86fbman.h"
+
+#if 0
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb16.h"
+#include "cfb32.h"
+#endif
+
+#include "miline.h"
+
+
+/*#include "savage_vbe.h"*/
+#include "savage_regs.h"
+#include "savage_driver.h"
+#include "savage_bci.h"
+
+#define _XF86DRI_SERVER_
+#include "GL/glxtokens.h"
+#include "sarea.h"
+#include "savage_dri.h"
+#include "savage_sarea.h"
+
+static char SAVAGEKernelDriverName[] = "savage";
+static char SAVAGEClientDriverName[] = "savage";
+
+static Bool SAVAGEDRIOpenFullScreen(ScreenPtr pScreen);
+static Bool SAVAGEDRICloseFullScreen(ScreenPtr pScreen);
+/* DRI buffer management
+ */
+void SAVAGEDRIInitBuffers( WindowPtr pWin, RegionPtr prgn,
+ CARD32 index );
+void SAVAGEDRIMoveBuffers( WindowPtr pParent, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc, CARD32 index );
+
+/* almost the same besides set src/desc to */
+/* Primary Bitmap Description */
+
+static void
+SAVAGEDRISetupForScreenToScreenCopy(
+ ScrnInfoPtr pScrn, int xdir, int ydir,
+ int rop, unsigned planemask, int transparency_color);
+
+
+static void
+SAVAGEDRISubsequentScreenToScreenCopy(
+ ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2,
+ int w, int h);
+
+
+static void
+SAVAGEDRISetupForSolidFill(
+ ScrnInfoPtr pScrn, int color, int rop, unsigned planemask);
+
+
+static void
+SAVAGEDRISubsequentSolidFillRect(
+ ScrnInfoPtr pScrn, int x, int y, int w, int h);
+
+#if 0
+extern int
+SavageHelpSolidROP(ScrnInfoPtr pScrn, int *fg,int pm,int *rop);
+#endif
+unsigned long SAVAGEDRIGetPhyAddress(ScrnInfoPtr pScrn,void * pointer);
+
+/* Initialize the visual configs that are supported by the hardware.
+ * These are combined with the visual configs that the indirect
+ * rendering core supports, and the intersection is exported to the
+ * client.
+ */
+static Bool SAVAGEInitVisualConfigs( ScreenPtr pScreen )
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ int numConfigs = 0;
+ __GLXvisualConfig *pConfigs = 0;
+ SAVAGEConfigPrivPtr pSAVAGEConfigs = 0;
+ SAVAGEConfigPrivPtr *pSAVAGEConfigPtrs = 0;
+ int i, db, depth, stencil, accum;
+
+ switch ( pScrn->bitsPerPixel ) {
+ case 8:
+ case 24:
+ break;
+
+ case 16:
+ numConfigs = 8;
+
+ pConfigs = (__GLXvisualConfig*)xcalloc( sizeof(__GLXvisualConfig),
+ numConfigs );
+ if ( !pConfigs ) {
+ return FALSE;
+ }
+
+ pSAVAGEConfigs = (SAVAGEConfigPrivPtr)xcalloc( sizeof(SAVAGEConfigPrivRec),
+ numConfigs );
+ if ( !pSAVAGEConfigs ) {
+ xfree( pConfigs );
+ return FALSE;
+ }
+
+ pSAVAGEConfigPtrs = (SAVAGEConfigPrivPtr*)xcalloc( sizeof(SAVAGEConfigPrivPtr),
+ numConfigs );
+ if ( !pSAVAGEConfigPtrs ) {
+ xfree( pConfigs );
+ xfree( pSAVAGEConfigs );
+ return FALSE;
+ }
+
+ for ( i = 0 ; i < numConfigs ; i++ ) {
+ pSAVAGEConfigPtrs[i] = &pSAVAGEConfigs[i];
+ }
+
+ i = 0;
+ depth = 1;
+ for ( accum = 0 ; accum <= 1 ; accum++ ) {
+ for ( stencil = 0 ; stencil <= 1 ; stencil++ ) {
+ for ( db = 1 ; db >= 0 ; db-- ) {
+ pConfigs[i].vid = -1;
+ pConfigs[i].class = -1;
+ pConfigs[i].rgba = TRUE;
+ pConfigs[i].redSize = 5;
+ pConfigs[i].greenSize = 6;
+ pConfigs[i].blueSize = 5;
+ pConfigs[i].alphaSize = 0;
+ pConfigs[i].redMask = 0x0000F800;
+ pConfigs[i].greenMask = 0x000007E0;
+ pConfigs[i].blueMask = 0x0000001F;
+ pConfigs[i].alphaMask = 0;
+ if ( accum ) {
+ pConfigs[i].accumRedSize = 16;
+ pConfigs[i].accumGreenSize = 16;
+ pConfigs[i].accumBlueSize = 16;
+ pConfigs[i].accumAlphaSize = 0;
+ } else {
+ pConfigs[i].accumRedSize = 0;
+ pConfigs[i].accumGreenSize = 0;
+ pConfigs[i].accumBlueSize = 0;
+ pConfigs[i].accumAlphaSize = 0;
+ }
+ if ( db ) {
+ pConfigs[i].doubleBuffer = TRUE;
+ } else {
+ pConfigs[i].doubleBuffer = FALSE;
+ }
+ pConfigs[i].stereo = FALSE;
+ pConfigs[i].bufferSize = 16;
+ if ( depth ) {
+ pConfigs[i].depthSize = 16;
+ } else {
+ pConfigs[i].depthSize = 0;
+ }
+ if ( stencil ) {
+ pConfigs[i].stencilSize = 8;
+ } else {
+ pConfigs[i].stencilSize = 0;
+ }
+ pConfigs[i].auxBuffers = 0;
+ pConfigs[i].level = 0;
+ if ( accum || stencil ) {
+ pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ } else {
+ pConfigs[i].visualRating = GLX_NONE_EXT;
+ }
+ pConfigs[i].transparentPixel = 0;
+ pConfigs[i].transparentRed = 0;
+ pConfigs[i].transparentGreen = 0;
+ pConfigs[i].transparentBlue = 0;
+ pConfigs[i].transparentAlpha = 0;
+ pConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ }
+ }
+ if ( i != numConfigs ) {
+ xf86DrvMsg( pScrn->scrnIndex, X_ERROR,
+ "[drm] Incorrect initialization of visuals\n" );
+ return FALSE;
+ }
+ break;
+
+ case 32:
+ numConfigs = 8;
+
+ pConfigs = (__GLXvisualConfig*)xcalloc( sizeof(__GLXvisualConfig),
+ numConfigs );
+ if ( !pConfigs ) {
+ return FALSE;
+ }
+
+ pSAVAGEConfigs = (SAVAGEConfigPrivPtr)xcalloc( sizeof(SAVAGEConfigPrivRec),
+ numConfigs );
+ if ( !pSAVAGEConfigs ) {
+ xfree( pConfigs );
+ return FALSE;
+ }
+
+ pSAVAGEConfigPtrs = (SAVAGEConfigPrivPtr*)xcalloc( sizeof(SAVAGEConfigPrivPtr),
+ numConfigs );
+ if ( !pSAVAGEConfigPtrs ) {
+ xfree( pConfigs );
+ xfree( pSAVAGEConfigs );
+ return FALSE;
+ }
+
+ for ( i = 0 ; i < numConfigs ; i++ ) {
+ pSAVAGEConfigPtrs[i] = &pSAVAGEConfigs[i];
+ }
+
+ i = 0;
+ for ( accum = 0 ; accum <= 1 ; accum++ ) {
+ for ( depth = 0 ; depth <= 1 ; depth++ ) { /* and stencil */
+ for ( db = 1 ; db >= 0 ; db-- ) {
+ pConfigs[i].vid = -1;
+ pConfigs[i].class = -1;
+ pConfigs[i].rgba = TRUE;
+ pConfigs[i].redSize = 8;
+ pConfigs[i].greenSize = 8;
+ pConfigs[i].blueSize = 8;
+ pConfigs[i].alphaSize = 8;
+ pConfigs[i].redMask = 0x00FF0000;
+ pConfigs[i].greenMask = 0x0000FF00;
+ pConfigs[i].blueMask = 0x000000FF;
+ pConfigs[i].alphaMask = 0;
+ if ( accum ) {
+ pConfigs[i].accumRedSize = 16;
+ pConfigs[i].accumGreenSize = 16;
+ pConfigs[i].accumBlueSize = 16;
+ pConfigs[i].accumAlphaSize = 0;
+ } else {
+ pConfigs[i].accumRedSize = 0;
+ pConfigs[i].accumGreenSize = 0;
+ pConfigs[i].accumBlueSize = 0;
+ pConfigs[i].accumAlphaSize = 0;
+ }
+ if ( db ) {
+ pConfigs[i].doubleBuffer = TRUE;
+ } else {
+ pConfigs[i].doubleBuffer = FALSE;
+ }
+ pConfigs[i].stereo = FALSE;
+ pConfigs[i].bufferSize = 32;
+ if ( depth ) {
+ pConfigs[i].depthSize = 24;
+ pConfigs[i].stencilSize = 8;
+ }
+ else {
+ pConfigs[i].depthSize = 0;
+ pConfigs[i].stencilSize = 0;
+ }
+ pConfigs[i].auxBuffers = 0;
+ pConfigs[i].level = 0;
+ if ( accum ) {
+ pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ } else {
+ pConfigs[i].visualRating = GLX_NONE_EXT;
+ }
+ pConfigs[i].transparentPixel = 0;
+ pConfigs[i].transparentRed = 0;
+ pConfigs[i].transparentGreen = 0;
+ pConfigs[i].transparentBlue = 0;
+ pConfigs[i].transparentAlpha = 0;
+ pConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ }
+ }
+ if ( i != numConfigs ) {
+ xf86DrvMsg( pScrn->scrnIndex, X_ERROR,
+ "[drm] Incorrect initialization of visuals\n" );
+ return FALSE;
+ }
+ break;
+
+ default:
+ /* Unexpected bits/pixels */
+ break;
+ }
+
+ psav->numVisualConfigs = numConfigs;
+ psav->pVisualConfigs = pConfigs;
+ psav->pVisualConfigsPriv = pSAVAGEConfigs;
+
+ GlxSetVisualConfigs( numConfigs, pConfigs, (void **)pSAVAGEConfigPtrs );
+
+ return TRUE;
+}
+
+static Bool SAVAGECreateContext( ScreenPtr pScreen, VisualPtr visual,
+ drm_context_t hwContext, void *pVisualConfigPriv,
+ DRIContextType contextStore )
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo;
+ savageAgpBufferPtr pAgp;
+
+ int ret,size,i;
+ unsigned long handle,map_handle;
+ drm_savage_sarea_t * pShare;
+ unsigned long offset;
+
+ if(psav->xvmcContext)
+ return FALSE;
+ else
+ {
+ psav->DRIrunning++;
+ }
+ /* alloc agp memory to dma */
+ pShare = (drm_savage_sarea_ptr)DRIGetSAREAPrivate(pScreen);
+ pShare->agp_offset=0;
+ /* find the available buffer*/
+ for (i=0,pAgp = pSAVAGEDRIServer->agpBuffer;i<pSAVAGEDRIServer->numBuffer;i++,pAgp++)
+ {
+ if (pAgp->flags==0)
+ break;
+ }
+ if (i >= pSAVAGEDRIServer->numBuffer)
+ {
+ return TRUE;
+ }
+
+ offset=pAgp->agp_offset;
+ size = DRM_SAVAGE_DMA_AGP_SIZE;
+ if (size <=0)
+ return TRUE;
+ ret=drmAgpAlloc( psav->drmFD,size,0,NULL,&handle);
+ if ( ret<0)
+ {
+ return TRUE;
+ }
+ ret=drmAgpBind( psav->drmFD,handle,offset);
+ if (ret<0)
+ {
+ return TRUE;
+ }
+ if (drmAddMap(psav->drmFD,
+ offset,
+ DRM_SAVAGE_DMA_AGP_SIZE,
+ DRM_AGP,
+ 0,
+ &map_handle)<0)
+ {
+ return TRUE;
+ }
+ pAgp->ctxOwner = hwContext;
+ pAgp->flags = 1;
+ pAgp->agp_handle = handle;
+ pAgp->map_handle = map_handle;
+ pShare->agp_offset=map_handle;
+
+ return TRUE;
+
+}
+
+static void SAVAGEDestroyContext( ScreenPtr pScreen, drm_context_t hwContext,
+ DRIContextType contextStore )
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+
+ SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo;
+ savageAgpBufferPtr pAgp;
+ drm_savage_sarea_t * pShare;
+ int i;
+ unsigned long handle,map_handle;
+
+ psav->DRIrunning--;
+
+ pShare = (drm_savage_sarea_ptr)DRIGetSAREAPrivate(pScreen);
+
+ for (i=0,pAgp = pSAVAGEDRIServer->agpBuffer;i<pSAVAGEDRIServer->numBuffer;i++,pAgp++)
+ {
+ if (pAgp->ctxOwner == hwContext)
+ break;
+ }
+ if (i >= pSAVAGEDRIServer->numBuffer || !pAgp->flags || !pAgp->agp_handle)
+ {
+ return;
+ }
+ handle = pAgp->agp_handle;
+ map_handle = pAgp->map_handle;
+ drmRmMap(psav->drmFD,map_handle);
+ drmAgpUnbind(psav->drmFD,handle);
+ drmAgpFree(psav->drmFD,handle);
+ pAgp->flags=0;
+ pAgp->ctxOwner=0;
+}
+
+#if 0
+/* Quiescence, locking
+ */
+#define SAVAGE_TIMEOUT 2048
+
+static void SAVAGEWaitForIdleDMA( ScrnInfoPtr pScrn )
+{
+ SavagePtr psav = SAVPTR(pScrn);
+ int ret;
+ int i = 0;
+
+ for (;;) {
+ do {
+ ret = drmSAVAGEFlushDMA( psav->drmFD,
+ DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH );
+ } while ( ( ret == -EBUSY ) && ( i++ < SAVAGE_TIMEOUT ) );
+
+ if ( ret == 0 )
+ return;
+
+ xf86DrvMsg( pScrn->scrnIndex, X_ERROR,
+ "[dri] Idle timed out, resetting engine...\n" );
+
+ drmSAVAGEEngineReset( psav->drmFD );
+ }
+}
+
+
+void SAVAGEGetQuiescence( ScrnInfoPtr pScrn )
+{
+ SavagePtr psav = SAVPTR(pScrn);
+
+ DRILock( screenInfo.screens[pScrn->scrnIndex], 0 );
+ psav->haveQuiescense = 1;
+
+ if ( psav->directRenderingEnabled ) {
+ SAVAGEFBLayout *pLayout = &psav->CurrentLayout;
+
+ SAVAGEWaitForIdleDMA( pScrn );
+
+ WAITFIFO( 11 );
+ OUTREG( SAVAGEREG_MACCESS, psav->MAccess );
+ OUTREG( SAVAGEREG_PITCH, pLayout->displayWidth );
+
+ psav->PlaneMask = ~0;
+ OUTREG( SAVAGEREG_PLNWT, psav->PlaneMask );
+
+ psav->BgColor = 0;
+ psav->FgColor = 0;
+ OUTREG( SAVAGEREG_BCOL, psav->BgColor );
+ OUTREG( SAVAGEREG_FCOL, psav->FgColor );
+ OUTREG( SAVAGEREG_SRCORG, psav->realSrcOrg );
+
+ psav->SrcOrg = 0;
+ OUTREG( SAVAGEREG_DSTORG, psav->DstOrg );
+ OUTREG( SAVAGEREG_OPMODE, SAVAGEOPM_DMA_BLIT );
+ OUTREG( SAVAGEREG_CXBNDRY, 0xFFFF0000 ); /* (maxX << 16) | minX */
+ OUTREG( SAVAGEREG_YTOP, 0x00000000 ); /* minPixelPointer */
+ OUTREG( SAVAGEREG_YBOT, 0x007FFFFF ); /* maxPixelPointer */
+
+ psav->AccelFlags &= ~CLIPPER_ON;
+ }
+}
+
+void SAVAGEGetQuiescenceShared( ScrnInfoPtr pScrn )
+{
+ SavagePtr psav = SAVPTR(pScrn);
+ SAVAGEEntPtr pSAVAGEEnt = psav->entityPrivate;
+ SavagePtr pSAVAGE2 = SAVPTR(pSAVAGEEnt->pScrn_2);
+
+ DRILock( screenInfo.screens[pSAVAGEEnt->pScrn_1->scrnIndex], 0 );
+
+ psav = SAVPTR(pSAVAGEEnt->pScrn_1);
+ psav->haveQuiescense = 1;
+ pSAVAGE2->haveQuiescense = 1;
+
+ if ( pSAVAGEEnt->directRenderingEnabled ) {
+ SAVAGEWaitForIdleDMA( pSAVAGEEnt->pScrn_1 );
+ psav->RestoreAccelState( pScrn );
+ xf86SetLastScrnFlag( pScrn->entityList[0], pScrn->scrnIndex );
+ }
+}
+
+#endif
+
+/* move in SAVAGEDRISwapContext() */
+#if 0
+static void SAVAGESwapContext( ScreenPtr pScreen )
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+
+ /* Arrange for dma_quiescence and xaa sync to be called as
+ * appropriate.
+ */
+ psav->LockHeld = 1; /* port as pMGA->haveQuiescense*/
+ psav->AccelInfoRec->NeedToSync = TRUE;
+}
+#endif
+
+/* no double-head */
+#if 0
+static void SAVAGESwapContextShared( ScreenPtr pScreen )
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ SAVAGEEntPtr pSAVAGEEnt = psav->entityPrivate;
+ SavagePtr pSAVAGE2 = SAVPTR(pSAVAGEEnt->pScrn_2);
+
+ psav = SAVPTR(pSAVAGEEnt->pScrn_1);
+
+ psav->haveQuiescense = 0;
+ psav->AccelInfoRec->NeedToSync = TRUE;
+
+ pSAVAGE2->haveQuiescense = 0;
+ pSAVAGE2->AccelInfoRec->NeedToSync = TRUE;
+}
+#endif
+
+/* This is really only called from validate/postvalidate as we
+ * override the dri lock/unlock. Want to remove validate/postvalidate
+ * processing, but need to remove all client-side use of drawable lock
+ * first (otherwise there is noone recover when a client dies holding
+ * the drawable lock).
+ *
+ * What does this mean?
+ *
+ * - The above code gets executed every time a
+ * window changes shape or the focus changes, which isn't really
+ * optimal.
+ * - The X server therefore believes it needs to do an XAA sync
+ * *and* a dma quiescense ioctl each time that happens.
+ *
+ * We don't wrap wakeuphandler any longer, so at least we can say that
+ * this doesn't happen *every time the mouse moves*...
+ */
+static void
+SAVAGEDRISwapContext( ScreenPtr pScreen, DRISyncType syncType,
+ DRIContextType oldContextType, void *oldContext,
+ DRIContextType newContextType, void *newContext )
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+
+#if 1
+ /* this case call from DRIDoWakeupandler, */
+ /* swap context in */
+ if ( syncType == DRI_3D_SYNC &&
+ oldContextType == DRI_2D_CONTEXT &&
+ newContextType == DRI_2D_CONTEXT )
+ {
+ psav->LockHeld = 1; /* port as pMGA->haveQuiescense*/
+ psav->AccelInfoRec->NeedToSync = TRUE;
+ }
+ /* this case call from DRIDoBlockHandler, */
+ /* swap context out */
+ else if (syncType == DRI_2D_SYNC &&
+ oldContextType == DRI_NO_CONTEXT &&
+ newContextType == DRI_2D_CONTEXT)
+ {
+ psav->LockHeld = 0;
+ psav->AccelInfoRec->NeedToSync = TRUE;
+ }
+#endif
+}
+
+/* no Double-Head */
+#if 0
+static void
+SAVAGEDRISwapContextShared( ScreenPtr pScreen, DRISyncType syncType,
+ DRIContextType oldContextType, void *oldContext,
+ DRIContextType newContextType, void *newContext )
+{
+#if 0
+ if ( syncType == DRI_3D_SYNC &&
+ oldContextType == DRI_2D_CONTEXT &&
+ newContextType == DRI_2D_CONTEXT )
+ {
+ SAVAGESwapContextShared( pScreen );
+ }
+#endif
+}
+#endif
+
+/* following I810 and R128 swaping method */
+/* MGA swaping method is for their double head */
+#if 0
+static void SAVAGEWakeupHandler( int screenNum, pointer wakeupData,
+ unsigned long result, pointer pReadmask )
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ if ( xf86IsEntityShared( pScrn->entityList[0] ) ) {
+ SAVAGESwapContextShared( pScreen );
+ } else {
+ SAVAGESwapContext( pScreen );
+ }
+}
+
+static void SAVAGEBlockHandler( int screenNum, pointer blockData,
+ pointer pTimeout, pointer pReadmask )
+
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ SAVAGEEntPtr pSAVAGEEnt;
+
+ if ( psav->haveQuiescense ) {
+ if ( xf86IsEntityShared( pScrn->entityList[0] ) ) {
+ /* Restore to first screen */
+ psav->RestoreAccelState( pScrn );
+ xf86SetLastScrnFlag( pScrn->entityList[0], pScrn->scrnIndex );
+ pSAVAGEEnt = psav->entityPrivate;
+
+ if ( pSAVAGEEnt->directRenderingEnabled ) {
+ DRIUnlock( screenInfo.screens[pSAVAGEEnt->pScrn_1->scrnIndex] );
+ }
+ } else {
+ if ( psav->directRenderingEnabled ) {
+ DRIUnlock( pScreen );
+ }
+ }
+ psav->haveQuiescense = 0;
+ }
+}
+#endif
+
+void SAVAGESelectBuffer( ScrnInfoPtr pScrn, int which )
+{
+ SavagePtr psav = SAVPTR(pScrn);
+ SAVAGEDRIPtr pSAVAGEDRI = (SAVAGEDRIPtr)psav->pDRIInfo->devPrivate;
+
+ psav->WaitIdleEmpty(psav);
+
+ OUTREG(0x48C18,INREG(0x48C18)&(~0x00000008));
+
+ switch ( which ) {
+ case SAVAGE_BACK:
+ OUTREG( 0x8170, pSAVAGEDRI->backOffset );
+ OUTREG( 0x8174, pSAVAGEDRI->backBitmapDesc );
+ break;
+ case SAVAGE_DEPTH:
+ OUTREG( 0x8170, pSAVAGEDRI->depthOffset );
+ OUTREG( 0x8174, pSAVAGEDRI->depthBitmapDesc );
+ break;
+ default:
+ case SAVAGE_FRONT:
+ OUTREG( 0x8170, pSAVAGEDRI->frontOffset );
+ OUTREG( 0x8174, pSAVAGEDRI->frontBitmapDesc );
+ break;
+ }
+ OUTREG(0x48C18,INREG(0x48C18)|(0x00000008));
+ psav->WaitIdleEmpty(psav);
+
+}
+
+
+static unsigned int mylog2( unsigned int n )
+{
+ unsigned int log2 = 1;
+
+ n--;
+ while ( n > 1 ) n >>= 1, log2++;
+
+ return log2;
+}
+
+static Bool SAVAGEDRIAgpInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo;
+ unsigned long mode;
+ unsigned int vendor, device;
+ int ret;
+ int size,numbuffer,i;
+ savageAgpBufferPtr agpbuffer;
+
+ /* FIXME: Make these configurable...
+ */
+ /*pSAVAGEDRIServer->agp.size = 16 * 1024 * 1024;*/
+ pSAVAGEDRIServer->agp.size = psav->agpSize * 1024 * 1024;
+ pSAVAGEDRIServer->agp.offset = pSAVAGEDRIServer->agp.size;
+
+ pSAVAGEDRIServer->agpTextures.offset = 0;
+ /*pSAVAGEDRIServer->agpTextures.size = 16*1024*1024;*/
+ pSAVAGEDRIServer->agpTextures.size = psav->agpSize * 1024 * 1024;
+ pSAVAGEDRIServer->logAgpTextureGranularity = 10;
+
+ if ( drmAgpAcquire( psav->drmFD ) < 0 ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] AGP not available\n" );
+ return FALSE;
+ }
+
+ mode = drmAgpGetMode( psav->drmFD ); /* Default mode */
+ vendor = drmAgpVendorId( psav->drmFD );
+ device = drmAgpDeviceId( psav->drmFD );
+
+ mode &= ~SAVAGE_AGP_MODE_MASK;
+
+ switch ( psav->agpMode ) {
+ case 4:
+ mode |= SAVAGE_AGP_4X_MODE;
+ case 2:
+ mode |= SAVAGE_AGP_2X_MODE;
+ case 1:
+ default:
+ mode |= SAVAGE_AGP_1X_MODE;
+ }
+
+ /* mode |= SAVAGE_AGP_1X_MODE;*/
+
+ xf86DrvMsg( pScreen->myNum, X_INFO,
+ "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n",
+ mode, vendor, device,
+ psav->PciInfo->vendor,
+ psav->PciInfo->chipType );
+
+ if ( drmAgpEnable( psav->drmFD, mode ) < 0 ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n" );
+ drmAgpRelease( psav->drmFD );
+ return FALSE;
+ }
+
+ ret = drmAgpAlloc( psav->drmFD, pSAVAGEDRIServer->agp.size,
+ 0, NULL, &pSAVAGEDRIServer->agp.handle );
+ if ( ret < 0 ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] Out of memory (%d)\n", ret );
+ drmAgpRelease( psav->drmFD );
+ return FALSE;
+ }
+ xf86DrvMsg( pScreen->myNum, X_INFO,
+ "[agp] %d kB allocated with handle 0x%08x\n",
+ pSAVAGEDRIServer->agp.size/1024, pSAVAGEDRIServer->agp.handle );
+
+ if ( drmAgpBind( psav->drmFD, pSAVAGEDRIServer->agp.handle, 0 ) < 0 ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] Could not bind memory\n" );
+ drmAgpFree( psav->drmFD, pSAVAGEDRIServer->agp.handle );
+ drmAgpRelease( psav->drmFD );
+ return FALSE;
+ }
+
+ if ( drmAddMap( psav->drmFD,
+ pSAVAGEDRIServer->agpTextures.offset,
+ pSAVAGEDRIServer->agpTextures.size,
+ DRM_AGP, 0,
+ &pSAVAGEDRIServer->agpTextures.handle ) < 0 ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[agp] Could not add agpTextures \n" );
+ return FALSE;
+ }
+ /* pSAVAGEDRIServer->agp_offset=pSAVAGEDRIServer->agpTexture.size;*/
+ xf86DrvMsg( pScreen->myNum, X_INFO,
+ "[agp] agpTextures microcode handle = 0x%08lx\n",
+ pSAVAGEDRIServer->agpTextures.handle );
+
+ /*if ( drmMap( psav->drmFD,
+ pSAVAGEDRIServer->agpTextures.handle,
+ pSAVAGEDRIServer->agpTextures.size,
+ &pSAVAGEDRIServer->agpTextures.map ) < 0 ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[agp] Could not map agpTextures \n" );
+ return FALSE;
+ }*/
+
+ xf86DrvMsg( pScreen->myNum, X_INFO,
+ "[agp] agpTextures mapped at 0x%08lx\n",
+ (unsigned long)pSAVAGEDRIServer->agpTextures.map );
+
+ /* for agp dma buffer*/
+ size = drmAgpSize(psav->drmFD);
+ size -= pSAVAGEDRIServer->agpTextures.size;/*sub texture size*/
+ numbuffer = size / DRM_SAVAGE_DMA_AGP_SIZE;
+ agpbuffer = (savageAgpBufferPtr)xcalloc(sizeof(savageAgpBuffer),numbuffer);
+ for (i=0;i<numbuffer;i++)
+ {
+ agpbuffer[i].ctxOwner = 0;
+ agpbuffer[i].agp_offset =
+ pSAVAGEDRIServer->agpTextures.size + i* DRM_SAVAGE_DMA_AGP_SIZE;
+ agpbuffer[i].flags = 0;
+ agpbuffer[i].agp_handle = 0;
+ }
+ pSAVAGEDRIServer->numBuffer = numbuffer;
+ pSAVAGEDRIServer->agpBuffer = agpbuffer;
+
+ return TRUE;
+}
+
+static Bool SAVAGEDRIMapInit( ScreenPtr pScreen )
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo;
+
+ pSAVAGEDRIServer->registers.size = SAVAGEIOMAPSIZE;
+
+ if ( drmAddMap( psav->drmFD,
+ (drm_handle_t)psav->MmioBase,
+ pSAVAGEDRIServer->registers.size,
+ DRM_REGISTERS,0,
+ &pSAVAGEDRIServer->registers.handle ) < 0 ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[drm] Could not add MMIO registers mapping\n" );
+ return FALSE;
+ }
+
+ pSAVAGEDRIServer->aperture.size = 5 * 0x01000000;
+
+ if ( drmAddMap( psav->drmFD,
+ (drm_handle_t)(psav->ApertureBase),
+ pSAVAGEDRIServer->aperture.size,
+ DRM_FRAME_BUFFER,0,
+ &pSAVAGEDRIServer->aperture.handle ) < 0 ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[drm] Could not add aperture mapping\n" );
+ return FALSE;
+ }
+
+ xf86DrvMsg( pScreen->myNum, X_INFO,
+ "[drm] aperture handle = 0x%08lx\n",
+ pSAVAGEDRIServer->aperture.handle );
+
+ /*if(drmMap(psav->drmFD,
+ pSAVAGEDRIServer->registers.handle,
+ pSAVAGEDRIServer->registers.size,
+ &pSAVAGEDRIServer->registers.map)<0)
+ {
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[drm] Could not map MMIO registers region to virtual\n" );
+ return FALSE;
+
+ }*/
+
+ pSAVAGEDRIServer->status.size = SAREA_MAX;
+
+ if ( drmAddMap( psav->drmFD, 0, pSAVAGEDRIServer->status.size,
+ DRM_SHM, DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL,
+ &pSAVAGEDRIServer->status.handle ) < 0 ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[drm] Could not add status page mapping\n" );
+ return FALSE;
+ }
+ xf86DrvMsg( pScreen->myNum, X_INFO,
+ "[drm] Status handle = 0x%08lx\n",
+ pSAVAGEDRIServer->status.handle );
+
+ if ( drmMap( psav->drmFD,
+ pSAVAGEDRIServer->status.handle,
+ pSAVAGEDRIServer->status.size,
+ &pSAVAGEDRIServer->status.map ) < 0 ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[agp] Could not map status page\n" );
+ return FALSE;
+ }
+ xf86DrvMsg( pScreen->myNum, X_INFO,
+ "[agp] Status page mapped at 0x%08lx\n",
+ (unsigned long)pSAVAGEDRIServer->status.map );
+
+ return TRUE;
+}
+
+/* no need DMA */
+#if 0
+static Bool SAVAGEDRIKernelInit( ScreenPtr pScreen )
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo;
+ drmSAVAGEInit init;
+ int ret;
+
+ memset( &init, 0, sizeof(drmSAVAGEInit) );
+
+ init.sarea_priv_offset = sizeof(XF86DRISAREARec);
+
+ switch ( psav->Chipset ) {
+ case PCI_CHIP_SAVAGEG400:
+ init.chipset = SAVAGE_CARD_TYPE_G400;
+ break;
+ case PCI_CHIP_SAVAGEG200:
+ case PCI_CHIP_SAVAGEG200_PCI:
+ init.chipset = SAVAGE_CARD_TYPE_G200;
+ break;
+ default:
+ return FALSE;
+ }
+ init.sgram = !psav->HasSDRAM;
+
+ init.maccess = psav->MAccess;
+
+ init.fb_cpp = pScrn->bitsPerPixel / 8;
+ init.front_offset = pSAVAGEDRIServer->frontOffset;
+ init.front_pitch = pSAVAGEDRIServer->frontPitch / init.fb_cpp;
+ init.back_offset = pSAVAGEDRIServer->backOffset;
+ init.back_pitch = pSAVAGEDRIServer->backPitch / init.fb_cpp;
+
+ init.depth_cpp = pScrn->bitsPerPixel / 8;
+ init.depth_offset = pSAVAGEDRIServer->depthOffset;
+ init.depth_pitch = pSAVAGEDRIServer->depthPitch / init.depth_cpp;
+
+ init.texture_offset[0] = pSAVAGEDRIServer->textureOffset;
+ init.texture_size[0] = pSAVAGEDRIServer->textureSize;
+
+ init.fb_offset = psav->FbAddress;
+ init.mmio_offset = pSAVAGEDRIServer->registers.handle;
+ init.status_offset = pSAVAGEDRIServer->status.handle;
+
+ init.warp_offset = pSAVAGEDRIServer->warp.handle;
+ init.primary_offset = pSAVAGEDRIServer->primary.handle;
+ init.buffers_offset = pSAVAGEDRIServer->buffers.handle;
+
+ ret = drmSAVAGEInitDMA( psav->drmFD, &init );
+ if ( ret < 0 ) {
+ xf86DrvMsg( pScrn->scrnIndex, X_ERROR,
+ "[drm] Failed to initialize DMA! (%d)\n", ret );
+ return FALSE;
+ }
+
+#if 0
+ /* FIXME: This is just here to clean up after the engine reset test
+ * in the kernel module. Please remove it later...
+ */
+ psav->GetQuiescence( pScrn );
+#endif
+
+ return TRUE;
+}
+
+static Bool SAVAGEDRIBuffersInit( ScreenPtr pScreen )
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo;
+
+
+ pSAVAGEDRIServer->drmBuffers = drmMapBufs( psav->drmFD );
+ if ( !pSAVAGEDRIServer->drmBuffers ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[drm] Failed to map DMA buffers list\n" );
+ return FALSE;
+ }
+ xf86DrvMsg( pScreen->myNum, X_INFO,
+ "[drm] Mapped %d DMA buffers\n",
+ pSAVAGEDRIServer->drmBuffers->count );
+
+ return TRUE;
+}
+#endif
+
+Bool SAVAGEDRIScreenInit( ScreenPtr pScreen )
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ DRIInfoPtr pDRIInfo;
+ SAVAGEDRIPtr pSAVAGEDRI;
+ SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer;
+
+/* disable first....*/
+#if 0
+ switch ( psav->Chipset ) {
+ case PCI_CHIP_SAVAGEG400:
+ case PCI_CHIP_SAVAGEG200:
+#if 0
+ case PCI_CHIP_SAVAGEG200_PCI:
+#endif
+ break;
+ default:
+ xf86DrvMsg( pScrn->scrnIndex, X_ERROR,
+ "[drm] Direct rendering only supported with AGP G200/G400 cards!\n" );
+ return FALSE;
+ }
+#endif
+
+ /* Check that the GLX, DRI, and DRM modules have been loaded by testing
+ * for canonical symbols in each module.
+ */
+ if ( !xf86LoaderCheckSymbol( "GlxSetVisualConfigs" ) ) return FALSE;
+ if ( !xf86LoaderCheckSymbol( "DRIScreenInit" ) ) return FALSE;
+ if ( !xf86LoaderCheckSymbol( "drmAvailable" ) ) return FALSE;
+ if ( !xf86LoaderCheckSymbol( "DRIQueryVersion" ) ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[dri] SAVAGEDRIScreenInit failed (libdri.a too old)\n" );
+ return FALSE;
+ }
+
+/* disable first */
+#if 1
+ /* Check the DRI version */
+ {
+ int major, minor, patch;
+ DRIQueryVersion( &major, &minor, &patch );
+ if ( major != 4 || minor < 0 ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[dri] SAVAGEDRIScreenInit failed because of a version mismatch.\n"
+ "[dri] libDRI version = %d.%d.%d but version 4.0.x is needed.\n"
+ "[dri] Disabling the DRI.\n",
+ major, minor, patch );
+ return FALSE;
+ }
+ }
+#endif
+
+ xf86DrvMsg( pScreen->myNum, X_INFO,
+ "[drm] bpp: %d depth: %d\n",
+ pScrn->bitsPerPixel, pScrn->depth );
+
+ if ( (pScrn->bitsPerPixel / 8) != 2 &&
+ (pScrn->bitsPerPixel / 8) != 4 ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[dri] Direct rendering only supported in 16 and 32 bpp modes\n" );
+ return FALSE;
+ }
+
+ pDRIInfo = DRICreateInfoRec();
+ if ( !pDRIInfo ) {
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[dri] DRICreateInfoRec() failed\n" );
+ return FALSE;
+ }
+ psav->pDRIInfo = pDRIInfo;
+
+ pDRIInfo->drmDriverName = SAVAGEKernelDriverName;
+ pDRIInfo->clientDriverName = SAVAGEClientDriverName;
+ if (xf86LoaderCheckSymbol("DRICreatePCIBusID")) {
+ pDRIInfo->busIdString = DRICreatePCIBusID(psav->PciInfo);
+ } else {
+ pDRIInfo->busIdString = xalloc(64);
+ sprintf(pDRIInfo->busIdString,
+ "PCI:%d:%d:%d",
+ psav->PciInfo->bus,
+ psav->PciInfo->device,
+ psav->PciInfo->func);
+ }
+ pDRIInfo->ddxDriverMajorVersion = 1/*SAVAGE_MAJOR_VERSION*/;
+ pDRIInfo->ddxDriverMinorVersion = 1/*SAVAGE_MINOR_VERSION*/;
+ pDRIInfo->ddxDriverPatchVersion = 16/*SAVAGE_PATCHLEVEL*/;
+ pDRIInfo->frameBufferPhysicalAddress = psav->FrameBufferBase;
+ pDRIInfo->frameBufferSize = psav->videoRambytes;
+ pDRIInfo->frameBufferStride = pScrn->displayWidth*(pScrn->bitsPerPixel/8);
+ pDRIInfo->ddxDrawableTableEntry = SAVAGE_MAX_DRAWABLES;
+
+/* mark off these... we use default */
+#if 0
+ pDRIInfo->wrap.BlockHandler = SAVAGEBlockHandler;
+ pDRIInfo->wrap.WakeupHandler = SAVAGEWakeupHandler;
+#endif
+
+ pDRIInfo->wrap.ValidateTree = NULL;
+ pDRIInfo->wrap.PostValidateTree = NULL;
+
+ pDRIInfo->createDummyCtx = TRUE;
+ pDRIInfo->createDummyCtxPriv = FALSE;
+
+ if ( SAREA_MAX_DRAWABLES < SAVAGE_MAX_DRAWABLES ) {
+ pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES;
+ } else {
+ pDRIInfo->maxDrawableTableEntry = SAVAGE_MAX_DRAWABLES;
+ }
+
+ /* For now the mapping works by using a fixed size defined
+ * in the SAREA header.
+ */
+ if ( sizeof(XF86DRISAREARec) + sizeof(SAVAGESAREAPrivRec) > SAREA_MAX ) {
+ xf86DrvMsg( pScrn->scrnIndex, X_ERROR,
+ "[drm] Data does not fit in SAREA\n" );
+ return FALSE;
+ }
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO,
+ "[drm] Sarea %d+%d: %d\n",
+ sizeof(XF86DRISAREARec), sizeof(SAVAGESAREAPrivRec),
+ sizeof(XF86DRISAREARec) + sizeof(SAVAGESAREAPrivRec) );
+
+ pDRIInfo->SAREASize = SAREA_MAX;
+
+ pSAVAGEDRI = (SAVAGEDRIPtr)xcalloc( sizeof(SAVAGEDRIRec), 1 );
+ if ( !pSAVAGEDRI ) {
+ DRIDestroyInfoRec( psav->pDRIInfo );
+ psav->pDRIInfo = 0;
+ xf86DrvMsg( pScrn->scrnIndex, X_ERROR,
+ "[drm] Failed to allocate memory for private record\n" );
+ return FALSE;
+ }
+
+ pSAVAGEDRIServer = (SAVAGEDRIServerPrivatePtr)
+ xcalloc( sizeof(SAVAGEDRIServerPrivateRec), 1 );
+ if ( !pSAVAGEDRIServer ) {
+ xfree( pSAVAGEDRI );
+ DRIDestroyInfoRec( psav->pDRIInfo );
+ psav->pDRIInfo = 0;
+ xf86DrvMsg( pScrn->scrnIndex, X_ERROR,
+ "[drm] Failed to allocate memory for private record\n" );
+ return FALSE;
+ }
+ psav->DRIServerInfo = pSAVAGEDRIServer;
+
+ pDRIInfo->devPrivate = pSAVAGEDRI;
+ pDRIInfo->devPrivateSize = sizeof(SAVAGEDRIRec);
+ pDRIInfo->contextSize = sizeof(SAVAGEDRIContextRec);
+
+ pDRIInfo->CreateContext = SAVAGECreateContext;
+ pDRIInfo->DestroyContext = SAVAGEDestroyContext;
+
+/* we don't have double head */
+#if 0
+ if ( xf86IsEntityShared( pScrn->entityList[0] ) ) {
+ pDRIInfo->SwapContext = SAVAGEDRISwapContextShared;
+ } else
+#endif
+
+ {
+ pDRIInfo->SwapContext = SAVAGEDRISwapContext;
+ }
+
+#if 0
+ switch( pScrn->bitsPerPixel ) {
+ case 8:
+ pDRIInfo->InitBuffers = Savage8DRIInitBuffers;
+ pDRIInfo->MoveBuffers = Savage8DRIMoveBuffers;
+ case 16:
+ pDRIInfo->InitBuffers = Savage16DRIInitBuffers;
+ pDRIInfo->MoveBuffers = Savage16DRIMoveBuffers;
+ case 24:
+ pDRIInfo->InitBuffers = Savage24DRIInitBuffers;
+ pDRIInfo->MoveBuffers = Savage24DRIMoveBuffers;
+ case 32:
+ pDRIInfo->InitBuffers = Savage32DRIInitBuffers;
+ pDRIInfo->MoveBuffers = Savage32DRIMoveBuffers;
+ }
+#endif
+
+ pDRIInfo->InitBuffers = SAVAGEDRIInitBuffers;
+ pDRIInfo->MoveBuffers = SAVAGEDRIMoveBuffers;
+ pDRIInfo->OpenFullScreen = SAVAGEDRIOpenFullScreen;
+ pDRIInfo->CloseFullScreen = SAVAGEDRICloseFullScreen;
+ pDRIInfo->bufferRequests = DRI_ALL_WINDOWS;
+
+ if ( !DRIScreenInit( pScreen, pDRIInfo, &psav->drmFD ) ) {
+ xfree( pSAVAGEDRIServer );
+ psav->DRIServerInfo = 0;
+ xfree( pDRIInfo->devPrivate );
+ pDRIInfo->devPrivate = 0;
+ DRIDestroyInfoRec( psav->pDRIInfo );
+ psav->pDRIInfo = 0;
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[drm] DRIScreenInit failed. Disabling DRI.\n" );
+ return FALSE;
+ }
+
+/* Disable these */
+#if 1
+ /* Check the SAVAGE DRM version */
+ {
+ drmVersionPtr version = drmGetVersion(psav->drmFD);
+ if ( version ) {
+ if ( version->version_major != 1 ||
+ version->version_minor < 0 ) {
+ /* incompatible drm version */
+ xf86DrvMsg( pScreen->myNum, X_ERROR,
+ "[dri] SAVAGEDRIScreenInit failed because of a version mismatch.\n"
+ "[dri] savage.o kernel module version is %d.%d.%d but version 3.0.x is needed.\n"
+ "[dri] Disabling DRI.\n",
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel );
+ drmFreeVersion( version );
+ SAVAGEDRICloseScreen( pScreen ); /* FIXME: ??? */
+ return FALSE;
+ }
+ drmFreeVersion( version );
+ }
+ }
+#endif
+
+#if 0
+ /* Calculate texture constants for AGP texture space.
+ * FIXME: move!
+ */
+ {
+ CARD32 agpTextureOffset = SAVAGE_DMA_BUF_SZ * SAVAGE_DMA_BUF_NR;
+ CARD32 agpTextureSize = pSAVAGEDRI->agp.size - agpTextureOffset;
+
+ i = mylog2(agpTextureSize / SAVAGE_NR_TEX_REGIONS);
+ if (i < SAVAGE_LOG_MIN_TEX_REGION_SIZE)
+ i = SAVAGE_LOG_MIN_TEX_REGION_SIZE;
+
+ pSAVAGEDRI->logAgpTextureGranularity = i;
+ pSAVAGEDRI->agpTextureSize = (agpTextureSize >> i) << i;
+ pSAVAGEDRI->agpTextureOffset = agpTextureOffset;
+ }
+#endif
+
+ if ( !SAVAGEDRIAgpInit( pScreen ) ) {
+ DRICloseScreen( pScreen );
+ return FALSE;
+ }
+
+ if ( !SAVAGEDRIMapInit( pScreen ) ) {
+ DRICloseScreen( pScreen );
+ return FALSE;
+ }
+
+ if ( !SAVAGEInitVisualConfigs( pScreen ) ) {
+ DRICloseScreen( pScreen );
+ return FALSE;
+ }
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[dri] visual configs initialized\n" );
+
+ return TRUE;
+}
+
+
+Bool SAVAGEDRIFinishScreenInit( ScreenPtr pScreen )
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo;
+ SAVAGEDRIPtr pSAVAGEDRI = (SAVAGEDRIPtr)psav->pDRIInfo->devPrivate;
+ int i;
+ unsigned int TileStride;
+
+
+ if ( !psav->pDRIInfo )
+ return FALSE;
+
+ psav->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT;
+
+ /* NOTE: DRIFinishScreenInit must be called before *DRIKernelInit
+ * because *DRIKernelInit requires that the hardware lock is held by
+ * the X server, and the first time the hardware lock is grabbed is
+ * in DRIFinishScreenInit.
+ */
+ if ( !DRIFinishScreenInit( pScreen ) ) {
+ SAVAGEDRICloseScreen( pScreen );
+ return FALSE;
+ }
+
+/* no dma...... */
+#if 0
+ if ( !SAVAGEDRIKernelInit( pScreen ) ) {
+ SAVAGEDRICloseScreen( pScreen );
+ return FALSE;
+ }
+
+ if ( !SAVAGEDRIBuffersInit( pScreen ) ) {
+ SAVAGEDRICloseScreen( pScreen );
+ return FALSE;
+ }
+
+ switch ( psav->Chipset ) {
+ case PCI_CHIP_SAVAGEG400:
+ pSAVAGEDRI->chipset = SAVAGE_CARD_TYPE_G400;
+ break;
+ case PCI_CHIP_SAVAGEG200:
+ case PCI_CHIP_SAVAGEG200_PCI:
+ pSAVAGEDRI->chipset = SAVAGE_CARD_TYPE_G200;
+ break;
+ default:
+ return FALSE;
+ }
+#endif
+
+ pSAVAGEDRI->chipset = psav->Chipset;
+ pSAVAGEDRI->width = pScrn->virtualX;
+ pSAVAGEDRI->height = pScrn->virtualY;
+ pSAVAGEDRI->mem = pScrn->videoRam * 1024;
+ pSAVAGEDRI->cpp = pScrn->bitsPerPixel / 8;
+ pSAVAGEDRI->zpp =pSAVAGEDRI->cpp;
+ pSAVAGEDRI->agpMode = psav->agpMode;
+
+ pSAVAGEDRI->frontOffset = pSAVAGEDRIServer->frontOffset;
+ pSAVAGEDRI->frontbufferSize = pSAVAGEDRIServer->frontbufferSize;
+ pSAVAGEDRI->frontbuffer = psav->FrameBufferBase +
+ pSAVAGEDRI->frontOffset;
+ pSAVAGEDRI->frontPitch = pSAVAGEDRIServer->frontPitch;
+ pSAVAGEDRI->IsfrontTiled = psav->bTiled; /* AGD: was 0 */
+
+ if(pSAVAGEDRI->IsfrontTiled)
+ {
+ if(pSAVAGEDRI->cpp==2)
+ TileStride = (pSAVAGEDRI->width+63)&(~63);
+ else
+ TileStride = (pSAVAGEDRI->width+31)&(~31);
+
+ if ((psav->Chipset == S3_TWISTER)
+ || (psav->Chipset == S3_PROSAVAGE)
+ || (psav->Chipset == S3_PROSAVAGEDDR)
+ || (psav->Chipset == S3_SUPERSAVAGE))
+ {
+ pSAVAGEDRI->frontBitmapDesc = 0x10000000 | /* block write disabled */
+ (1<<24) | /* destination tile format */
+ (pScrn->bitsPerPixel<<16) | /* bpp */
+ TileStride; /* stride */
+ } else {
+ pSAVAGEDRI->frontBitmapDesc = 0x10000000 | /* block write disabled */
+ ((pSAVAGEDRI->cpp==2)?
+ BCI_BD_TILE_16:BCI_BD_TILE_32) | /*16/32 bpp tile format */
+ (pScrn->bitsPerPixel<<16) | /* bpp */
+ TileStride; /* stride */
+ pSAVAGEDRI->frontPitch = TileStride;
+ }
+ }
+ else
+ {
+ pSAVAGEDRI->frontBitmapDesc = 0x10000000 | /* AGD: block write should be disabled: was 0x00000000 */
+ pScrn->bitsPerPixel<<16 |
+ pSAVAGEDRI->width;
+ }
+
+ pSAVAGEDRI->backOffset = pSAVAGEDRIServer->backOffset;
+ pSAVAGEDRI->backbufferSize = pSAVAGEDRIServer->backbufferSize;
+ pSAVAGEDRI->backbuffer = psav->FrameBufferBase +
+ pSAVAGEDRI->backOffset;
+ pSAVAGEDRI->backPitch = pSAVAGEDRIServer->backPitch;
+
+ {
+ if(pSAVAGEDRI->cpp==2)
+ TileStride = (pSAVAGEDRI->width+63)&(~63);
+ else
+ TileStride = (pSAVAGEDRI->width+31)&(~31);
+
+ if ((psav->Chipset == S3_TWISTER)
+ || (psav->Chipset == S3_PROSAVAGE)
+ || (psav->Chipset == S3_PROSAVAGEDDR)
+ || (psav->Chipset == S3_SUPERSAVAGE)) /* AGD: supersavage may work like savage4/MX/IX, I just don't know. */
+ { /* It's here since the 2D driver sets it up like prosavage */
+ pSAVAGEDRI->backBitmapDesc = 0x10000000 |
+ (1<<24) |
+ (pScrn->bitsPerPixel<<16) |
+ TileStride;
+ } else {
+ pSAVAGEDRI->backBitmapDesc = 0x10000000 |
+ ((pSAVAGEDRI->cpp==2)?
+ BCI_BD_TILE_16:BCI_BD_TILE_32) |
+ (pScrn->bitsPerPixel<<16) |
+ TileStride;
+ }
+ }
+
+ pSAVAGEDRI->depthOffset = pSAVAGEDRIServer->depthOffset;
+ pSAVAGEDRI->depthbufferSize = pSAVAGEDRIServer->depthbufferSize;
+ pSAVAGEDRI->depthbuffer = psav->FrameBufferBase +
+ pSAVAGEDRI->depthOffset;
+ pSAVAGEDRI->depthPitch = pSAVAGEDRIServer->depthPitch;
+
+ {
+ if(pSAVAGEDRI->zpp==2)
+ TileStride = (pSAVAGEDRI->width+63)&(~63);
+ else
+ TileStride = (pSAVAGEDRI->width+31)&(~31);
+
+ if ((psav->Chipset == S3_TWISTER)
+ || (psav->Chipset == S3_PROSAVAGE)
+ || (psav->Chipset == S3_PROSAVAGEDDR)
+ || (psav->Chipset == S3_SUPERSAVAGE))
+ {
+ pSAVAGEDRI->depthBitmapDesc = 0x10000000 |
+ (1<<24) |
+ (pScrn->bitsPerPixel<<16) |
+ TileStride;
+ } else {
+ pSAVAGEDRI->depthBitmapDesc = 0x10000000 |
+ ((pSAVAGEDRI->zpp==2)?
+ BCI_BD_TILE_16:BCI_BD_TILE_32) |
+ (pScrn->bitsPerPixel<<16) |
+ TileStride;
+ }
+ }
+
+ pSAVAGEDRI->textureOffset = pSAVAGEDRIServer->textureOffset;
+ pSAVAGEDRI->textures = psav->FrameBufferBase +
+ pSAVAGEDRI->textureOffset;
+ pSAVAGEDRI->textureSize = pSAVAGEDRIServer->textureSize;
+
+ i = mylog2( pSAVAGEDRI->textureSize / SAVAGE_NR_TEX_REGIONS );
+ if ( i < SAVAGE_LOG_MIN_TEX_REGION_SIZE )
+ i = SAVAGE_LOG_MIN_TEX_REGION_SIZE;
+
+ pSAVAGEDRI->logTextureGranularity = i;
+ pSAVAGEDRI->textureSize = (pSAVAGEDRI->textureSize >> i) << i; /* truncate */
+
+ pSAVAGEDRI->agpTextures.handle = pSAVAGEDRIServer->agpTextures.handle;
+ pSAVAGEDRI->agpTextures.offset = pSAVAGEDRIServer->agpTextures.offset;
+ pSAVAGEDRI->agpTextures.size = pSAVAGEDRIServer->agpTextures.size;
+ pSAVAGEDRI->agpTextures.map = pSAVAGEDRIServer->agpTextures.map;
+
+ i = mylog2( pSAVAGEDRI->agpTextures.size / SAVAGE_NR_TEX_REGIONS );
+ if ( i < SAVAGE_LOG_MIN_TEX_REGION_SIZE )
+ i = SAVAGE_LOG_MIN_TEX_REGION_SIZE;
+
+ pSAVAGEDRI->logAgpTextureGranularity = i;
+ pSAVAGEDRI->agpTextures.size = (pSAVAGEDRI->agpTextures.size >> i) << i; /* truncate */
+
+ pSAVAGEDRI->aperture.handle = pSAVAGEDRIServer->aperture.handle;
+ pSAVAGEDRI->aperture.size = pSAVAGEDRIServer->aperture.size;
+ pSAVAGEDRI->aperture.map = pSAVAGEDRIServer->aperture.map;
+ {
+ unsigned int shift = 0;
+
+ if(pSAVAGEDRI->width > 1024)
+ shift = 1;
+
+ /* pSAVAGEDRI->aperturePitch = psav->ulAperturePitch; */
+ pSAVAGEDRI->aperturePitch = psav->ul3DAperturePitch;
+ }
+
+ {
+ unsigned int value = 0;
+
+ OUTREG(0x850C,(INREG(0x850C) | 0x00008000)); /* AGD: I don't think this does anything on 3D/MX/IX */
+ /* maybe savage4 too... */
+ /* we don't use Y range flag,so comment it */
+ /*
+ if(pSAVAGEDRI->width <= 1024)
+ value |= (1<<29);
+ */
+ if ((psav->Chipset == S3_SAVAGE_MX) /* 3D/MX/IX seem to set up the tile stride differently */
+ || (psav->Chipset == S3_SAVAGE3D)) {
+ if(pSAVAGEDRI->cpp == 2)
+ {
+ value |= ((psav->l3DDelta / 4) >> 5) << 24; /* I assume psav->l3DDelta for 3D */
+ value |= 2<<30;
+ } else {
+ value |= ((psav->l3DDelta / 4) >> 5) << 24; /* I assume psav->l3DDelta for 3D */
+ value |= 3<<30;
+ }
+
+ OUTREG(0x48C40, value|(pSAVAGEDRI->frontOffset) ); /* front */
+ OUTREG(0x48C44, value|(pSAVAGEDRI->backOffset) ); /* back */
+ OUTREG(0x48C48, value|(pSAVAGEDRI->depthOffset) ); /* depth */
+ } else {
+ if(pSAVAGEDRI->cpp == 2)
+ {
+ value |= (((pSAVAGEDRI->width + 0x3F) & 0xFFC0) >> 6) << 20;
+ value |= 2<<30;
+ } else {
+ value |= (((pSAVAGEDRI->width + 0x1F) & 0xFFE0) >> 5) << 20;
+ value |= 3<<30;
+ }
+
+ OUTREG(0x48C40, value|(pSAVAGEDRI->frontOffset >> 5) ); /* front */
+ OUTREG(0x48C44, value|(pSAVAGEDRI->backOffset >> 5) ); /* back */
+ OUTREG(0x48C48, value|(pSAVAGEDRI->depthOffset >> 5) ); /* depth */
+ }
+ }
+
+ pSAVAGEDRI->registers.handle = pSAVAGEDRIServer->registers.handle;
+ pSAVAGEDRI->registers.size = pSAVAGEDRIServer->registers.size;
+ pSAVAGEDRI->registers.map = pSAVAGEDRIServer->registers.map;
+
+ pSAVAGEDRI->BCIcmdBuf.handle = pSAVAGEDRIServer->registers.handle+0x00010000;
+ pSAVAGEDRI->BCIcmdBuf.size = 0x00020000;
+ pSAVAGEDRI->BCIcmdBuf.map = (drmAddress)( (unsigned int)
+ pSAVAGEDRIServer->registers.map +
+ 0x00010000);
+
+ pSAVAGEDRI->status.handle = pSAVAGEDRIServer->status.handle;
+ pSAVAGEDRI->status.size = pSAVAGEDRIServer->status.size;
+ pSAVAGEDRI->shadowStatus = psav->ShadowStatus;
+
+/* no DMA now ....*/
+#if 0
+ pSAVAGEDRI->primary.handle = pSAVAGEDRIServer->primary.handle;
+ pSAVAGEDRI->primary.size = pSAVAGEDRIServer->primary.size;
+ pSAVAGEDRI->buffers.handle = pSAVAGEDRIServer->buffers.handle;
+ pSAVAGEDRI->buffers.size = pSAVAGEDRIServer->buffers.size;
+#endif
+
+ pSAVAGEDRI->sarea_priv_offset = sizeof(XF86DRISAREARec);
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers]pSAVAGEDRIServer:\n" );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] reserved_map_agpstart:0x%08x\n",pSAVAGEDRIServer->reserved_map_agpstart);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] reserved_map_idx:0x%08x\n",pSAVAGEDRIServer->reserved_map_idx);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] sarea_priv_offset:0x%08lx\n",pSAVAGEDRIServer->sarea_priv_offset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] chipset:0x%08x\n",pSAVAGEDRIServer->chipset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] sgram:0x%08x\n",pSAVAGEDRIServer->sgram);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] frontbufferSize:0x%08x\n",pSAVAGEDRIServer->frontbufferSize);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] frontOffset:0x%08x\n",pSAVAGEDRIServer->frontOffset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] frontPitch:0x%08x\n",pSAVAGEDRIServer->frontPitch);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] backbufferSize:0x%08x\n",pSAVAGEDRIServer->backbufferSize);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] backOffset:0x%08x\n",pSAVAGEDRIServer->backOffset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] backPitch:0x%08x\n",pSAVAGEDRIServer->backPitch);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] depthbufferSize:0x%08x\n",pSAVAGEDRIServer->depthbufferSize);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] depthOffset:0x%08x\n",pSAVAGEDRIServer->depthOffset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] depthPitch:0x%08x\n",pSAVAGEDRIServer->depthPitch);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] textureOffset:0x%08x\n",pSAVAGEDRIServer->textureOffset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] textureSize:0x%08x\n",pSAVAGEDRIServer->textureSize);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] textureSize:0x%08x\n",pSAVAGEDRIServer->textureSize);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] logTextureGranularity:0x%08x\n",pSAVAGEDRIServer->logTextureGranularity);
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agp:handle:0x%08lx\n",pSAVAGEDRIServer->agp.handle);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agp:offset:0x%08lx\n",pSAVAGEDRIServer->agp.offset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agp:size:0x%08lx\n",pSAVAGEDRIServer->agp.size);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agp:map:0x%08lx\n",(unsigned long)pSAVAGEDRIServer->agp.map);
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] registers:handle:0x%08lx\n",pSAVAGEDRIServer->registers.handle);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] registers:offset:0x%08lx\n",pSAVAGEDRIServer->registers.offset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] registers:size:0x%08lx\n",pSAVAGEDRIServer->registers.size);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] registers:map:0x%08lx\n",(unsigned long)pSAVAGEDRIServer->registers.map);
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] status:handle:0x%08lx\n",pSAVAGEDRIServer->status.handle);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] status:offset:0x%08lx\n",pSAVAGEDRIServer->status.offset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] status:size:0x%08lx\n",pSAVAGEDRIServer->status.size);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] status:map:0x%08lx\n",(unsigned long)pSAVAGEDRIServer->status.map);
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agpTextures:handle:0x%08lx\n",pSAVAGEDRIServer->agpTextures.handle);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agpTextures:offset:0x%08lx\n",pSAVAGEDRIServer->agpTextures.offset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agpTextures:size:0x%08lx\n",pSAVAGEDRIServer->agpTextures.size);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] apgTextures:map:0x%08lx\n",(unsigned long)pSAVAGEDRIServer->agpTextures.map);
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] logAgpTextureGranularity:0x%08x\n",pSAVAGEDRIServer->logAgpTextureGranularity);
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers]pSAVAGEDRI:\n" );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] chipset:0x%08x\n",pSAVAGEDRI->chipset );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] width:0x%08x\n",pSAVAGEDRI->width );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] height:0x%08x\n",pSAVAGEDRI->height );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] mem:0x%08lx\n",pSAVAGEDRI->mem );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] cpp:%d\n",pSAVAGEDRI->cpp );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] zpp:%d\n",pSAVAGEDRI->zpp );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agpMode:%d\n",pSAVAGEDRI->agpMode );
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] frontbuffer:0x%08lx\n",pSAVAGEDRI->frontbuffer);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] frontbufferSize:0x%08x\n",pSAVAGEDRI->frontbufferSize);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] frontOffset:0x%08x\n",pSAVAGEDRI->frontOffset );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] frontPitch:0x%08x\n",pSAVAGEDRI->frontPitch );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] frontBitmapDesc:0x%08lx\n",pSAVAGEDRI->frontBitmapDesc );
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] backbuffer:0x%08lx\n",pSAVAGEDRI->backbuffer);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] backbufferSize:0x%08x\n",pSAVAGEDRI->backbufferSize);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] backOffset:0x%08x\n",pSAVAGEDRI->backOffset );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] backPitch:0x%08x\n",pSAVAGEDRI->backPitch );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] backBitmapDesc:0x%08lx\n",pSAVAGEDRI->backBitmapDesc );
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] depthbuffer:0x%08lx\n",pSAVAGEDRI->depthbuffer);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] depthbufferSize:0x%08x\n",pSAVAGEDRI->depthbufferSize);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] depthOffset:0x%08x\n",pSAVAGEDRI->depthOffset );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] depthPitch:0x%08x\n",pSAVAGEDRI->depthPitch );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] depthBitmapDesc:0x%08lx\n",pSAVAGEDRI->depthBitmapDesc );
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] textures:0x%08lx\n",pSAVAGEDRI->textures );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] textureOffset:0x%08x\n",pSAVAGEDRI->textureOffset );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] textureSize:0x%08x\n",pSAVAGEDRI->textureSize );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] logTextureGranularity:0x%08x\n",pSAVAGEDRI->logTextureGranularity );
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agpBufferOffset:0x%08x\n",pSAVAGEDRI->agpBufferOffset );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agpTextureOffset:0x%08x\n",pSAVAGEDRI->agpTextureOffset );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agpTextureSize:0x%08x\n",pSAVAGEDRI->agpTextureSize );
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] logAgpTextureGranularity:0x%08x\n",pSAVAGEDRI->logAgpTextureGranularity );
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agpTextures:handle:0x%08lx\n",pSAVAGEDRI->agpTextures.handle);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agpTextures:offset:0x%08lx\n",pSAVAGEDRI->agpTextures.offset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] agpTextures:size:0x%08lx\n",pSAVAGEDRI->agpTextures.size);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] apgTextures:map:0x%08lx\n",(unsigned long)pSAVAGEDRI->agpTextures.map);
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] registers:handle:0x%08lx\n",pSAVAGEDRI->registers.handle);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] registers:offset:0x%08lx\n",pSAVAGEDRI->registers.offset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] registers:size:0x%08lx\n",pSAVAGEDRI->registers.size);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] registers:map:0x%08lx\n",(unsigned long)pSAVAGEDRI->registers.map);
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] aperture:handle:0x%08lx\n",pSAVAGEDRI->aperture.handle);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] aperture:offset:0x%08lx\n",pSAVAGEDRI->aperture.offset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] aperture:size:0x%08lx\n",pSAVAGEDRI->aperture.size);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] aperture:map:0x%08lx\n",(unsigned long)pSAVAGEDRI->aperture.map);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] aperturePitch:0x%08x\n",pSAVAGEDRI->aperturePitch);
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] BCIcmdBuf:handle:0x%08lx\n",pSAVAGEDRI->BCIcmdBuf.handle);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] BCIcmdBuf:offset:0x%08lx\n",pSAVAGEDRI->BCIcmdBuf.offset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] BCIcmdBuf:size:0x%08lx\n",pSAVAGEDRI->BCIcmdBuf.size);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] BCIcmdBuf:map:0x%08lx\n",(unsigned long)pSAVAGEDRI->BCIcmdBuf.map);
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] status:handle:0x%08lx\n",pSAVAGEDRI->status.handle);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] status:offset:0x%08lx\n",pSAVAGEDRI->status.offset);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] status:size:0x%08lx\n",pSAVAGEDRI->status.size);
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] status:map:0x%08lx\n",(unsigned long)pSAVAGEDRI->status.map);
+
+ xf86DrvMsg( pScrn->scrnIndex, X_INFO, "[junkers] sarea_priv_offset:0x%08lx\n",pSAVAGEDRI->sarea_priv_offset);
+
+ return TRUE;
+}
+
+
+void SAVAGEDRICloseScreen( ScreenPtr pScreen )
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo;
+
+/* no DMA now..... */
+#if 0
+ if ( pSAVAGEDRIServer->drmBuffers ) {
+ drmUnmapBufs( pSAVAGEDRIServer->drmBuffers );
+ pSAVAGEDRIServer->drmBuffers = NULL;
+ }
+
+ drmSAVAGECleanupDMA( psav->drmFD );
+#endif
+
+ if ( pSAVAGEDRIServer->status.map ) {
+ drmUnmap( pSAVAGEDRIServer->status.map, pSAVAGEDRIServer->status.size );
+ pSAVAGEDRIServer->status.map = NULL;
+ }
+
+ if ( pSAVAGEDRIServer->registers.map ) {
+ drmUnmap( pSAVAGEDRIServer->registers.map, pSAVAGEDRIServer->registers.size );
+ pSAVAGEDRIServer->registers.map = NULL;
+ }
+
+
+ if ( pSAVAGEDRIServer->agpTextures.map ) {
+ drmUnmap( pSAVAGEDRIServer->agpTextures.map,
+ pSAVAGEDRIServer->agpTextures.size );
+ pSAVAGEDRIServer->agpTextures.map = NULL;
+ }
+
+ if (pSAVAGEDRIServer->status.handle)
+ drmRmMap(psav->drmFD,pSAVAGEDRIServer->status.handle);
+
+ if (pSAVAGEDRIServer->registers.handle)
+ drmRmMap(psav->drmFD,pSAVAGEDRIServer->registers.handle);
+
+ if (pSAVAGEDRIServer->agpTextures.handle)
+ drmRmMap(psav->drmFD,pSAVAGEDRIServer->agpTextures.handle);
+
+/* no DMA now.... */
+#if 0
+ if ( pSAVAGEDRIServer->buffers.map ) {
+ drmUnmap( pSAVAGEDRIServer->buffers.map, pSAVAGEDRIServer->buffers.size );
+ pSAVAGEDRIServer->buffers.map = NULL;
+ }
+ if ( pSAVAGEDRIServer->primary.map ) {
+ drmUnmap( pSAVAGEDRIServer->primary.map, pSAVAGEDRIServer->primary.size );
+ pSAVAGEDRIServer->primary.map = NULL;
+ }
+ if ( pSAVAGEDRIServer->warp.map ) {
+ drmUnmap( pSAVAGEDRIServer->warp.map, pSAVAGEDRIServer->warp.size );
+ pSAVAGEDRIServer->warp.map = NULL;
+ }
+#endif
+
+ if ( pSAVAGEDRIServer->agp.handle ) {
+ drmAgpUnbind( psav->drmFD, pSAVAGEDRIServer->agp.handle );
+ drmAgpFree( psav->drmFD, pSAVAGEDRIServer->agp.handle );
+ pSAVAGEDRIServer->agp.handle = 0;
+ drmAgpRelease( psav->drmFD );
+ }
+
+ DRICloseScreen( pScreen );
+
+ /*Don't use shadow status any more*/
+ psav->ShadowVirtual = NULL;
+ psav->ShadowPhysical = 0;
+
+ if(psav->reserved)
+ xf86FreeOffscreenLinear(psav->reserved);
+
+ if ( psav->pDRIInfo ) {
+ if ( psav->pDRIInfo->devPrivate ) {
+ xfree( psav->pDRIInfo->devPrivate );
+ psav->pDRIInfo->devPrivate = 0;
+ }
+ DRIDestroyInfoRec( psav->pDRIInfo );
+ psav->pDRIInfo = 0;
+ }
+ if ( psav->DRIServerInfo ) {
+ xfree( psav->DRIServerInfo );
+ psav->DRIServerInfo = 0;
+ }
+ if ( psav->pVisualConfigs ) {
+ xfree( psav->pVisualConfigs );
+ }
+ if ( psav->pVisualConfigsPriv ) {
+ xfree( psav->pVisualConfigsPriv );
+ }
+}
+
+void
+SAVAGEDRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ BoxPtr pbox = REGION_RECTS(prgn);
+ int nbox = REGION_NUM_RECTS(prgn);
+
+
+#if 0
+ CHECK_DMA_QUIESCENT(SAVPTR(pScrn), pScrn);
+#endif
+#if 0
+ if(!psav->LockHeld)
+ psav->LockHeld = 1;
+ SAVAGEDRISetupForSolidFill(pScrn, 0, GXcopy, -1);
+ while (nbox--) {
+ SAVAGESelectBuffer(pScrn, SAVAGE_BACK);
+ SAVAGEDRISubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
+ pbox->x2-pbox->x1, pbox->y2-pbox->y1);
+ SAVAGESelectBuffer(pScrn, SAVAGE_DEPTH);
+ SAVAGEDRISubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
+ pbox->x2-pbox->x1, pbox->y2-pbox->y1);
+ pbox++;
+ }
+#endif
+#if 0
+ {
+ SAVAGEDRIPtr pSAVAGEDRI = (SAVAGEDRIPtr)psav->pDRIInfo->devPrivate;
+ unsigned int *bcicmd;
+ BCI_GET_PTR;
+ /*bcicmd = (unsigned int *) psav->BciMem;
+ *(bcicmd) = 0x4BCC8000;
+ *(bcicmd) = 0x00F80000;
+ *(bcicmd) = 0x02000200;
+ *(bcicmd) = 0x01000100;*/
+ BCI_SEND(0x4BCC8000);
+ BCI_SEND(0x00F80000);
+ BCI_SEND(0x02000200);
+ BCI_SEND(0x01000100);
+ sleep(5);
+ }
+#endif
+#if 0
+ SAVAGESelectBuffer(pScrn, SAVAGE_FRONT);
+ psav->AccelInfoRec->NeedToSync = TRUE;
+#endif
+}
+
+/*
+ This routine is a modified form of XAADoBitBlt with the calls to
+ ScreenToScreenBitBlt built in. My routine has the prgnSrc as source
+ instead of destination. My origin is upside down so the ydir cases
+ are reversed.
+*/
+
+void
+SAVAGEDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc, CARD32 index)
+{
+ ScreenPtr pScreen = pParent->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ int nbox;
+ BoxPtr pbox, pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
+ DDXPointPtr pptTmp, pptNew1, pptNew2;
+ int xdir, ydir;
+ int dx, dy;
+ DDXPointPtr pptSrc;
+ int screenwidth = pScrn->virtualX;
+ int screenheight = pScrn->virtualY;
+
+#if 1
+#if 0
+ CHECK_DMA_QUIESCENT(SAVPTR(pScrn), pScrn);
+#endif
+ if(!psav->LockHeld)
+ psav->LockHeld = 1;
+
+ pbox = REGION_RECTS(prgnSrc);
+ nbox = REGION_NUM_RECTS(prgnSrc);
+ pboxNew1 = 0;
+ pptNew1 = 0;
+ pboxNew2 = 0;
+ pboxNew2 = 0;
+ pptSrc = &ptOldOrg;
+
+ dx = pParent->drawable.x - ptOldOrg.x;
+ dy = pParent->drawable.y - ptOldOrg.y;
+
+ /* If the copy will overlap in Y, reverse the order */
+ if (dy>0) {
+ ydir = -1;
+
+ if (nbox>1) {
+ /* Keep ordering in each band, reverse order of bands */
+ pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
+ if (!pboxNew1) return;
+ pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
+ if (!pptNew1) {
+ DEALLOCATE_LOCAL(pboxNew1);
+ return;
+ }
+ pboxBase = pboxNext = pbox+nbox-1;
+ while (pboxBase >= pbox) {
+ while ((pboxNext >= pbox) && (pboxBase->y1 == pboxNext->y1))
+ pboxNext--;
+ pboxTmp = pboxNext+1;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp <= pboxBase) {
+ *pboxNew1++ = *pboxTmp++;
+ *pptNew1++ = *pptTmp++;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew1 -= nbox;
+ pbox = pboxNew1;
+ pptNew1 -= nbox;
+ pptSrc = pptNew1;
+ }
+ } else {
+ /* No changes required */
+ ydir = 1;
+ }
+
+ /* If the regions will overlap in X, reverse the order */
+ if (dx>0) {
+ xdir = -1;
+
+ if (nbox > 1) {
+ /*reverse orderof rects in each band */
+ pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
+ pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
+ if (!pboxNew2 || !pptNew2) {
+ if (pptNew2) DEALLOCATE_LOCAL(pptNew2);
+ if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2);
+ if (pboxNew1) {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+ return;
+ }
+ pboxBase = pboxNext = pbox;
+ while (pboxBase < pbox+nbox) {
+ while ((pboxNext < pbox+nbox) &&
+ (pboxNext->y1 == pboxBase->y1))
+ pboxNext++;
+ pboxTmp = pboxNext;
+ pptTmp = pptSrc + (pboxTmp - pbox);
+ while (pboxTmp != pboxBase) {
+ *pboxNew2++ = *--pboxTmp;
+ *pptNew2++ = *--pptTmp;
+ }
+ pboxBase = pboxNext;
+ }
+ pboxNew2 -= nbox;
+ pbox = pboxNew2;
+ pptNew2 -= nbox;
+ pptSrc = pptNew2;
+ }
+ } else {
+ /* No changes are needed */
+ xdir = 1;
+ }
+#if 0
+ SAVAGEDRISetupForScreenToScreenCopy(pScrn, xdir, ydir, GXcopy, -1, -1);
+ for ( ; nbox-- ; pbox++)
+ {
+ int x1 = pbox->x1;
+ int y1 = pbox->y1;
+ int destx = x1 + dx;
+ int desty = y1 + dy;
+ int w = pbox->x2 - x1 + 1;
+ int h = pbox->y2 - y1 + 1;
+
+ if ( destx < 0 ) x1 -= destx, w += destx, destx = 0;
+ if ( desty < 0 ) y1 -= desty, h += desty, desty = 0;
+ if ( destx + w > screenwidth ) w = screenwidth - destx;
+ if ( desty + h > screenheight ) h = screenheight - desty;
+ if ( w <= 0 ) continue;
+ if ( h <= 0 ) continue;
+
+ SAVAGESelectBuffer(pScrn, SAVAGE_BACK);
+ SAVAGEDRISubsequentScreenToScreenCopy(pScrn, x1, y1,
+ destx,desty, w, h);
+ SAVAGESelectBuffer(pScrn, SAVAGE_DEPTH);
+ SAVAGEDRISubsequentScreenToScreenCopy(pScrn, x1,y1,
+ destx,desty, w, h);
+ }
+ SAVAGESelectBuffer(pScrn, SAVAGE_FRONT);
+
+ if (pboxNew2) {
+ DEALLOCATE_LOCAL(pptNew2);
+ DEALLOCATE_LOCAL(pboxNew2);
+ }
+ if (pboxNew1) {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+
+ psav->AccelInfoRec->NeedToSync = TRUE;
+#endif
+#endif
+}
+
+static void
+SAVAGEDRISetupForScreenToScreenCopy(
+ ScrnInfoPtr pScrn,
+ int xdir,
+ int ydir,
+ int rop,
+ unsigned planemask,
+ int transparency_color)
+{
+ SavagePtr psav = SAVPTR(pScrn);
+ int cmd =0;
+
+ cmd = BCI_CMD_RECT | BCI_CMD_DEST_PBD | BCI_CMD_SRC_PBD_COLOR;
+ BCI_CMD_SET_ROP( cmd, XAAGetCopyROP(rop) );
+ if (transparency_color != -1)
+ cmd |= BCI_CMD_SEND_COLOR | BCI_CMD_SRC_TRANSPARENT;
+
+ if (xdir == 1 ) cmd |= BCI_CMD_RECT_XP;
+ if (ydir == 1 ) cmd |= BCI_CMD_RECT_YP;
+
+ psav->SavedBciCmd = cmd;
+ psav->SavedBgColor = transparency_color;
+
+}
+
+static void
+SAVAGEDRISubsequentScreenToScreenCopy(
+ ScrnInfoPtr pScrn,
+ int x1,
+ int y1,
+ int x2,
+ int y2,
+ int w,
+ int h)
+{
+ SavagePtr psav = SAVPTR(pScrn);
+ BCI_GET_PTR;
+
+ if (!w || !h) return;
+ if (!(psav->SavedBciCmd & BCI_CMD_RECT_XP)) {
+ w --;
+ x1 += w;
+ x2 += w;
+ w ++;
+ }
+ if (!(psav->SavedBciCmd & BCI_CMD_RECT_YP)) {
+ h --;
+ y1 += h;
+ y2 += h;
+ h ++;
+ }
+
+ psav->WaitQueue(psav,6);
+ BCI_SEND(psav->SavedBciCmd);
+ if (psav->SavedBgColor != -1)
+ BCI_SEND(psav->SavedBgColor);
+ BCI_SEND(BCI_X_Y(x1, y1));
+ BCI_SEND(BCI_X_Y(x2, y2));
+ BCI_SEND(BCI_W_H(w, h));
+
+}
+
+
+/*
+ * SetupForSolidFill is also called to set up for lines.
+ */
+#if 0
+static void
+SAVAGEDRISetupForSolidFill(
+ ScrnInfoPtr pScrn,
+ int color,
+ int rop,
+ unsigned planemask)
+{
+ SavagePtr psav = SAVPTR(pScrn);
+ XAAInfoRecPtr xaaptr = GET_XAAINFORECPTR_FROM_SCRNINFOPTR( pScrn );
+ int cmd;
+ int mix;
+
+ cmd = BCI_CMD_RECT
+ | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP
+ | BCI_CMD_DEST_PBD | BCI_CMD_SRC_SOLID;
+
+ /* Don't send a color if we don't have to. */
+
+ if( rop == GXcopy )
+ {
+ if( color == 0 )
+ rop = GXclear;
+ else if( color == xaaptr->FullPlanemask )
+ rop = GXset;
+ }
+
+#if 1
+ mix = SavageHelpSolidROP( pScrn, &color, planemask, &rop );
+#endif
+ if( mix & ROP_PAT )
+ cmd |= BCI_CMD_SEND_COLOR;
+
+ BCI_CMD_SET_ROP( cmd, rop );
+
+ psav->SavedBciCmd = cmd;
+ psav->SavedFgColor = color;
+}
+#endif
+
+static void
+SAVAGEDRISubsequentSolidFillRect(
+ ScrnInfoPtr pScrn,
+ int x,
+ int y,
+ int w,
+ int h)
+{
+ SavagePtr psav = SAVPTR(pScrn);
+ BCI_GET_PTR;
+
+ if( !w || !h )
+ return;
+
+ psav->WaitQueue(psav,5);
+
+ BCI_SEND(psav->SavedBciCmd);
+ if( psav->SavedBciCmd & BCI_CMD_SEND_COLOR )
+ BCI_SEND(psav->SavedFgColor);
+ BCI_SEND(BCI_X_Y(x, y));
+ BCI_SEND(BCI_W_H(w, h));
+}
+
+
+static Bool
+SAVAGEDRIOpenFullScreen(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+ SavagePtr psav = SAVPTR(pScrn);
+ unsigned int vgaCRIndex = hwp->IOBase + 4;
+ unsigned int vgaCRReg = hwp->IOBase + 5;
+ SAVAGEDRIPtr pSAVAGEDRI = (SAVAGEDRIPtr)psav->pDRIInfo->devPrivate;
+ unsigned int TileStride;
+ unsigned int WidthinTiles;
+ unsigned int depth;
+
+ OUTREG(0x48C18, INREG(0x48C18) & 0xFFFFFFF7);
+ /*VGAOUT8(vgaCRIndex,0x66);
+ VGAOUT8(vgaCRReg, VGAIN8(vgaCRReg)|0x10);*/
+ VGAOUT8(vgaCRIndex,0x69);
+ VGAOUT8(vgaCRReg, 0x80);
+
+ depth = pScrn->bitsPerPixel;
+
+ if(depth == 16)
+ {
+ WidthinTiles = (pSAVAGEDRI->width+63)>>6;
+ TileStride = (pSAVAGEDRI->width+63)&(~63);
+
+ }
+ else
+ {
+ WidthinTiles = (pSAVAGEDRI->width+31)>>5;
+ TileStride = (pSAVAGEDRI->width+31)&(~31);
+
+ }
+
+
+ /* set primary stream stride */
+ {
+ unsigned int value;
+
+ /*value = 0x80000000|(WidthinTiles<<24)|(TileStride*depth/8);*/
+ value = 0x80000000|(WidthinTiles<<24);
+ if(depth == 32)
+ value |= 0x40000000;
+
+ OUTREG(PRI_STREAM_STRIDE, value);
+
+ }
+
+ /* set global bitmap descriptor */
+ {
+ unsigned int value;
+ value = 0x10000000|
+ 0x00000009|
+ 0x01000000|
+ (depth<<16) | TileStride;
+
+ OUTREG(0x816C,value);
+
+ }
+
+ OUTREG(0x48C18, INREG(0x48C18) | 0x8);
+
+ return TRUE;
+}
+
+static Bool
+SAVAGEDRICloseFullScreen(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr psav = SAVPTR(pScrn);
+ SAVAGEDRIPtr pSAVAGEDRI = (SAVAGEDRIPtr)psav->pDRIInfo->devPrivate;
+ unsigned int depth = pScrn->bitsPerPixel;
+ BCI_GET_PTR;
+
+ BCI_SEND(0xC0FF0000);
+ psav->WaitIdleEmpty(psav);
+ OUTREG(0x48C18, INREG(0x48C18) & 0xFFFFFFF7);
+ /* set primary stream stride */
+ {
+ /* MM81C0 and 81C4 are used to control primary stream. */
+ OUTREG32(PRI_STREAM_FBUF_ADDR0,0x00000000);
+ OUTREG32(PRI_STREAM_FBUF_ADDR1,0x00000000);
+
+ /* FIFO control */
+ OUTREG32(0X81EC,0Xffffffff);
+
+ if (!psav->bTiled) {
+ OUTREG32(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 */
+ OUTREG32(PRI_STREAM_STRIDE,
+ (((psav->lDelta * 2) << 16) & 0x3FFFE000)
+ | 0x80000000 | (psav->lDelta & 0x00001fff));
+ }
+ else if (pScrn->bitsPerPixel == 32) {
+ OUTREG32(PRI_STREAM_STRIDE,
+ (((psav->lDelta * 2) << 16) & 0x3FFFE000)
+ | 0xC0000000 | (psav->lDelta & 0x00001fff));
+ }
+
+
+ }
+
+ /* set global bitmap descriptor */
+ {
+ OUTREG32(S3_GLB_BD_LOW,psav->GlobalBD.bd2.LoPart );
+ OUTREG32(S3_GLB_BD_HIGH,psav->GlobalBD.bd2.HiPart | BCI_ENABLE | S3_LITTLE_ENDIAN | S3_BD64);
+
+ }
+
+ OUTREG(0x48C18, INREG(0x48C18) | 0x8);
+ return TRUE;
+}
+/* get the physics address (for shadow status)*/
+unsigned long SAVAGEDRIGetPhyAddress(ScrnInfoPtr pScrn,void * pointer)
+{
+
+ SavagePtr psav = SAVPTR(pScrn);
+
+ drm_savage_get_physcis_address_t req;
+ int ret;
+
+ req.v_address = (unsigned long )pointer;
+ ret = ioctl(psav->drmFD, DRM_IOCTL_SAVAGE_GET_PHYSICS_ADDRESS,&req);
+ if (ret != 1)
+ fprintf(stderr,"[GetPhyAddress],Wrong virtual address.\n");
+ return req.p_address;
+}
+
+#endif
diff --git a/src/savage_dri.h b/src/savage_dri.h
new file mode 100644
index 0000000..af62e76
--- /dev/null
+++ b/src/savage_dri.h
@@ -0,0 +1,184 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef __SAVAGE_DRI_H__
+#define __SAVAGE_DRI_H__
+
+#include "xf86drm.h"
+#include "drm.h"
+
+#define SAVAGE_DEFAULT_AGP_MODE 1
+#define SAVAGE_MAX_AGP_MODE 4
+
+/* Buffer are aligned on 4096 byte boundaries.
+ */
+/* this is used for backbuffer, depthbuffer, etc..*/
+/* alignment */
+
+#define SAVAGE_BUFFER_ALIGN 0x00000fff
+
+typedef struct{
+ drm_context_t ctxOwner;
+ unsigned long agp_offset;
+ unsigned long agp_handle;
+ unsigned long map_handle;
+ int flags;
+} savageAgpBuffer , *savageAgpBufferPtr;
+
+typedef struct _server{
+ int reserved_map_agpstart;
+ int reserved_map_idx;
+
+#if 0
+ int buffer_map_idx;
+#endif
+
+ int sarea_priv_offset;
+
+#if 0
+ int primary_size;
+ int warp_ucode_size;
+#endif
+
+ int chipset;
+ int sgram; /* seems no use */
+
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+ unsigned int frontbufferSize;
+
+ unsigned int backOffset;
+ unsigned int backPitch;
+ unsigned int backbufferSize;
+
+ unsigned int depthOffset;
+ unsigned int depthPitch;
+ unsigned int depthbufferSize;
+
+ unsigned int textureOffset;
+ int textureSize;
+ int logTextureGranularity;
+
+ drmRegion agp;
+
+ /* PCI mappings */
+ drmRegion aperture;
+ drmRegion registers;
+ drmRegion status;
+
+ /* AGP mappings */
+#if 0
+ drmRegion warp;
+ drmRegion primary;
+ drmRegion buffers;
+#endif
+
+ drmRegion agpTextures;
+ int logAgpTextureGranularity;
+
+#if 0
+ drmBufMapPtr drmBuffers;
+#endif
+ /*for agp*/
+ int numBuffer;
+ savageAgpBufferPtr agpBuffer;
+} SAVAGEDRIServerPrivateRec, *SAVAGEDRIServerPrivatePtr;
+
+typedef struct {
+ int chipset;
+ int width;
+ int height;
+ int mem;
+ int cpp;
+ int zpp;
+
+ int agpMode;
+
+ drm_handle_t frontbuffer;
+ unsigned int frontbufferSize;
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+ unsigned int frontBitmapDesc; /*Bitmap Descriptior*/
+ unsigned int IsfrontTiled;
+
+ drm_handle_t backbuffer;
+ unsigned int backbufferSize;
+ unsigned int backOffset;
+ unsigned int backPitch;
+ unsigned int backBitmapDesc; /*Bitmap Descriptior*/
+
+ drm_handle_t depthbuffer;
+ unsigned int depthbufferSize;
+ unsigned int depthOffset;
+ unsigned int depthPitch;
+ unsigned int depthBitmapDesc; /*Bitmap Descriptior*/
+
+
+
+ drm_handle_t textures;
+ drm_handle_t xvmcSurfHandle;
+ unsigned int textureOffset;
+ unsigned int textureSize;
+ int logTextureGranularity;
+
+ /* Allow calculation of setup dma addresses.
+ */
+ unsigned int agpBufferOffset;
+
+ unsigned int agpTextureOffset;
+ unsigned int agpTextureSize;
+ drmRegion agpTextures;
+ int logAgpTextureGranularity;
+
+/* unsigned int mAccess;*/
+
+ drmRegion aperture;
+ unsigned int aperturePitch; /* in byte */
+
+
+ drmRegion registers;
+ drmRegion BCIcmdBuf;
+ drmRegion status;
+
+#if 0
+ drmRegion primary;
+ drmRegion buffers;
+#endif
+ /*For shadow status*/
+ unsigned long sareaPhysAddr;
+
+ unsigned int sarea_priv_offset;
+ int shadowStatus;
+} SAVAGEDRIRec, *SAVAGEDRIPtr;
+
+#endif
+
+
+
+
+
+
+
+
diff --git a/src/savage_dripriv.h b/src/savage_dripriv.h
new file mode 100644
index 0000000..19e4487
--- /dev/null
+++ b/src/savage_dripriv.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __SAVAGE_DRIPRIV_H__
+#define __SAVAGE_DRIPRIV_H__
+
+#include "GL/glxint.h"
+
+#define SAVAGE_MAX_DRAWABLES 256
+
+extern void GlxSetVisualConfigs( int nconfigs,
+ __GLXvisualConfig *configs,
+ void **configprivs );
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} SAVAGEConfigPrivRec, *SAVAGEConfigPrivPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} SAVAGEDRIContextRec, *SAVAGEDRIContextPtr;
+
+#endif
diff --git a/src/savage_driver.c b/src/savage_driver.c
index 8415d10..c2e63b8 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 }
};
@@ -229,7 +235,7 @@ static const char *vgaHWSymbols[] = {
"vgaHWSetMmioFuncs",
"vgaHWSetStdFuncs",
"vgaHWUnmapMem",
- "vgaHWddc1SetSpeed",
+ "vgaHWddc1SetSpeedWeak",
#if 0
"vgaHWFreeHWRec",
"vgaHWMapMem",
@@ -247,6 +253,13 @@ static const char *ramdacSymbols[] = {
NULL
};
+static const char *int10Symbols[] = {
+ "xf86ExecX86int10",
+ "xf86Int10AllocPages",
+ "xf86int10Addr",
+ "xf86Int10FreePages"
+};
+
static const char *vbeSymbols[] = {
"VBEInit",
"vbeDoEDID",
@@ -281,13 +294,14 @@ static const char *i2cSymbols[] = {
};
static const char *xaaSymbols[] = {
- "XAACopyROP",
- "XAACopyROP_PM",
+ "XAAGetCopyROP",
+ "XAAGetCopyROP_PM",
"XAACreateInfoRec",
"XAADestroyInfoRec",
"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",
@@ -323,7 +325,7 @@ static XF86ModuleVersionInfo SavageVersRec = {
MODULEVENDORSTRING,
MODINFOSTRING1,
MODINFOSTRING2,
- XF86_VERSION_CURRENT,
+ XORG_VERSION_CURRENT,
VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL,
ABI_CLASS_VIDEODRV,
ABI_VIDEODRV_VERSION,
@@ -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;
}
@@ -1481,7 +1529,13 @@ static Bool SavageEnterVT(int scrnIndex, int flags)
gpScrn = pScrn;
SavageEnableMMIO(pScrn);
SavageSave(pScrn);
- return SavageModeInit(pScrn, pScrn->currentMode);
+ if(SavageModeInit(pScrn, pScrn->currentMode)) {
+ /* some BIOSes seem to enable HW cursor on PM resume */
+ if (!SAVPTR(pScrn)->hwc_on)
+ SavageHideCursor( pScrn );
+ return TRUE;
+ }
+ return FALSE;
}
@@ -1495,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);
}
@@ -1740,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);
@@ -1748,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 );
@@ -1770,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;
@@ -1787,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
@@ -1824,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 );
@@ -1895,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 );
}
@@ -2167,7 +2227,7 @@ static Bool SavageMapMMIO(ScrnInfoPtr pScrn)
return TRUE;
}
-
+#define TRANSPARENCY_KEY 0xff;
static Bool SavageMapFB(ScrnInfoPtr pScrn)
{
@@ -2240,6 +2300,7 @@ static Bool SavageScreenInit(int scrnIndex, ScreenPtr pScreen,
SavagePtr psav;
EntityInfoPtr pEnt;
int ret;
+ int colormapFlags;
TRACE(("SavageScreenInit()\n"));
@@ -2247,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;
@@ -2285,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)
@@ -2305,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;
+ }
}
}
}
@@ -2364,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);
@@ -2388,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)
@@ -2432,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;
}
@@ -2550,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;
@@ -2691,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;
@@ -2736,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);
@@ -2744,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;
@@ -2792,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;
@@ -2824,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);
@@ -2847,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);
@@ -2871,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);
@@ -2885,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);
}
@@ -2947,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 ))
@@ -2964,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);
@@ -2976,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. */
@@ -3232,7 +3428,8 @@ SavageDDC1(int scrnIndex)
OutI2CREG(psav,tmp | 0x12);
if ((pMon = xf86PrintEDID(
- xf86DoEDID_DDC1(scrnIndex,vgaHWddc1SetSpeed,SavageDDC1Read))) != NULL)
+ xf86DoEDID_DDC1(scrnIndex,vgaHWddc1SetSpeedWeak(),
+ SavageDDC1Read))) != NULL)
success = TRUE;
xf86SetDDCproperties(pScrn,pMon);
diff --git a/src/savage_driver.h b/src/savage_driver.h
index 4375302..ccf3972 100644
--- a/src/savage_driver.h
+++ b/src/savage_driver.h
@@ -3,6 +3,8 @@
#ifndef SAVAGE_VGAHWMMIO_H
#define SAVAGE_VGAHWMMIO_H
+#define MODE_24 24
+
#include "xf86_ansic.h"
#include "compiler.h"
#include "vgaHW.h"
@@ -15,6 +17,7 @@
#include "mipointer.h"
#include "micmap.h"
#include "fb.h"
+#include "fboverlay.h"
#include "xf86cmap.h"
#include "vbe.h"
#include "xaa.h"
@@ -70,6 +73,10 @@ typedef struct {
unsigned int MMPR0, MMPR1, MMPR2, MMPR3;
} SavageRegRec, *SavageRegPtr;
+typedef struct {
+ CARD32 redMask, greenMask, blueMask;
+ int redShift, greenShift, blueShift;
+} savageOverlayRec;
typedef struct _Savage {
SavageRegRec SavedReg;
@@ -85,7 +92,7 @@ typedef struct _Savage {
int videoRambytes;
int videoRamKbytes;
int MemOffScreen;
- CARD32 CursorKByte;
+ int CursorKByte;
/* These are physical addresses. */
unsigned long FrameBufferBase;
@@ -178,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. */
@@ -203,6 +208,11 @@ typedef struct _Savage {
int dwBCIWait2DIdle;
XF86OffscreenImagePtr offscreenImages;
+ /* Support for Overlays */
+ unsigned char * FBStart2nd;
+ savageOverlayRec overlay;
+ int overlayDepth;
+ int primStreamBpp;
} SavageRec, *SavagePtr;
/* Video flags. */
@@ -213,7 +223,6 @@ typedef struct _Savage {
/* Make the names of these externals driver-unique */
#define gpScrn savagegpScrn
-#define myOUTREG savageOUTREG
#define readdw savagereaddw
#define readfb savagereadfb
#define writedw savagewritedw
@@ -272,5 +281,22 @@ unsigned short SavageGetBIOSModes(
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_drm.h b/src/savage_drm.h
new file mode 100644
index 0000000..62bd49b
--- /dev/null
+++ b/src/savage_drm.h
@@ -0,0 +1,248 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __SAVAGE_DRM_H__
+#define __SAVAGE_DRM_H__
+
+#ifndef __SAVAGE_SAREA_DEFINES__
+#define __SAVAGE_SAREA_DEFINES__
+
+#define DRM_SAVAGE_MEM_PAGE (1UL<<12)
+#define DRM_SAVAGE_MEM_WORK 32
+#define DRM_SAVAGE_MEM_LOCATION_PCI 1
+#define DRM_SAVAGE_MEM_LOCATION_AGP 2
+#define DRM_SAVAGE_DMA_AGP_SIZE (16*1024*1024)
+
+typedef struct drm_savage_alloc_cont_mem
+{
+ size_t size; /*size of buffer*/
+ unsigned long type; /*4k page or word*/
+ unsigned long alignment;
+ unsigned long location; /*agp or pci*/
+
+ unsigned long phyaddress;
+ unsigned long linear;
+} drm_savage_alloc_cont_mem_t;
+
+typedef struct drm_savage_get_physcis_address
+{
+ unsigned long v_address;
+ unsigned long p_address;
+}drm_savage_get_physcis_address_t;
+
+/*ioctl number*/
+#define DRM_IOCTL_SAVAGE_ALLOC_CONTINUOUS_MEM \
+ DRM_IOWR(0x40,drm_savage_alloc_cont_mem_t)
+#define DRM_IOCTL_SAVAGE_GET_PHYSICS_ADDRESS \
+ DRM_IOWR(0x41, drm_savage_get_physcis_address_t)
+#define DRM_IOCTL_SAVAGE_FREE_CONTINUOUS_MEM \
+ DRM_IOWR(0x42, drm_savage_alloc_cont_mem_t)
+
+#define SAVAGE_FRONT 0x1
+#define SAVAGE_BACK 0x2
+#define SAVAGE_DEPTH 0x4
+#define SAVAGE_STENCIL 0x8
+
+/* What needs to be changed for the current vertex dma buffer?
+ */
+#define SAVAGE_UPLOAD_CTX 0x1
+#define SAVAGE_UPLOAD_TEX0 0x2
+#define SAVAGE_UPLOAD_TEX1 0x4
+#define SAVAGE_UPLOAD_PIPE 0x8 /* <- seems should be removed, Jiayo Hsu */
+#define SAVAGE_UPLOAD_TEX0IMAGE 0x10 /* handled client-side */
+#define SAVAGE_UPLOAD_TEX1IMAGE 0x20 /* handled client-side */
+#define SAVAGE_UPLOAD_2D 0x40
+#define SAVAGE_WAIT_AGE 0x80 /* handled client-side */
+#define SAVAGE_UPLOAD_CLIPRECTS 0x100 /* handled client-side */
+/*frank:add Buffer state 2001/11/15*/
+#define SAVAGE_UPLOAD_BUFFERS 0x200
+/* original marked off in MGA drivers , Jiayo Hsu Oct.23,2001 */
+
+/* Keep these small for testing.
+ */
+#define SAVAGE_NR_SAREA_CLIPRECTS 8
+
+/* 2 heaps (1 for card, 1 for agp), each divided into upto 128
+ * regions, subject to a minimum region size of (1<<16) == 64k.
+ *
+ * Clients may subdivide regions internally, but when sharing between
+ * clients, the region size is the minimum granularity.
+ */
+
+#define SAVAGE_CARD_HEAP 0
+#define SAVAGE_AGP_HEAP 1
+#define SAVAGE_NR_TEX_HEAPS 2
+#define SAVAGE_NR_TEX_REGIONS 16 /* num. of global texture manage list element*/
+#define SAVAGE_LOG_MIN_TEX_REGION_SIZE 16 /* each region 64K, Jiayo Hsu */
+
+#endif /* __SAVAGE_SAREA_DEFINES__ */
+
+/* drm_tex_region_t define in drm.h */
+
+typedef drm_tex_region_t drm_savage_tex_region_t;
+
+/* Setup registers for 2D, X server
+ */
+typedef struct {
+ unsigned int pitch;
+} drm_savage_server_regs_t;
+
+
+typedef struct _drm_savage_sarea {
+ /* The channel for communication of state information to the kernel
+ * on firing a vertex dma buffer.
+ */
+ unsigned int setup[28]; /* 3D context registers */
+ drm_savage_server_regs_t server_state;
+
+ unsigned int dirty;
+
+ unsigned int vertsize; /* vertext size */
+
+ /* The current cliprects, or a subset thereof.
+ */
+ drm_clip_rect_t boxes[SAVAGE_NR_SAREA_CLIPRECTS];
+ unsigned int nbox;
+
+ /* Information about the most recently used 3d drawable. The
+ * client fills in the req_* fields, the server fills in the
+ * exported_ fields and puts the cliprects into boxes, above.
+ *
+ * The client clears the exported_drawable field before
+ * clobbering the boxes data.
+ */
+ unsigned int req_drawable; /* the X drawable id */
+ unsigned int req_draw_buffer; /* SAVAGE_FRONT or SAVAGE_BACK */
+
+ unsigned int exported_drawable;
+ unsigned int exported_index;
+ unsigned int exported_stamp;
+ unsigned int exported_buffers;
+ unsigned int exported_nfront;
+ unsigned int exported_nback;
+ int exported_back_x, exported_front_x, exported_w;
+ int exported_back_y, exported_front_y, exported_h;
+ drm_clip_rect_t exported_boxes[SAVAGE_NR_SAREA_CLIPRECTS];
+
+ /* Counters for aging textures and for client-side throttling.
+ */
+ unsigned int status[4];
+
+
+ /* LRU lists for texture memory in agp space and on the card.
+ */
+ drm_tex_region_t texList[SAVAGE_NR_TEX_HEAPS][SAVAGE_NR_TEX_REGIONS+1];
+ unsigned int texAge[SAVAGE_NR_TEX_HEAPS];
+
+ /* Mechanism to validate card state.
+ */
+ int ctxOwner;
+ unsigned long shadow_status[64];/*too big?*/
+
+ /*agp offset*/
+ unsigned long agp_offset;
+} drm_savage_sarea_t,*drm_savage_sarea_ptr;
+
+
+/* WARNING: If you change any of these defines, make sure to change the
+ * defines in the Xserver file (xf86drmMga.h)
+ */
+
+typedef struct drm_savage_init {
+
+ unsigned long sarea_priv_offset;
+
+ int chipset;
+ int sgram;
+
+ unsigned int maccess;
+
+ unsigned int fb_cpp;
+ unsigned int front_offset, front_pitch;
+ unsigned int back_offset, back_pitch;
+
+ unsigned int depth_cpp;
+ unsigned int depth_offset, depth_pitch;
+
+ unsigned int texture_offset[SAVAGE_NR_TEX_HEAPS];
+ unsigned int texture_size[SAVAGE_NR_TEX_HEAPS];
+
+ unsigned long fb_offset;
+ unsigned long mmio_offset;
+ unsigned long status_offset;
+#if 0
+/*============================================================*/
+ unsigned long warp_offset;
+ unsigned long primary_offset;
+ unsigned long buffers_offset;
+/*============================================================*/
+#endif /*end #if 0 */
+} drm_savage_init_t;
+
+typedef struct drm_savage_fullscreen {
+ enum {
+ SAVAGE_INIT_FULLSCREEN = 0x01,
+ SAVAGE_CLEANUP_FULLSCREEN = 0x02
+ } func;
+} drm_savage_fullscreen_t;
+
+typedef struct drm_savage_clear {
+ unsigned int flags;
+ unsigned int clear_color;
+ unsigned int clear_depth;
+ unsigned int color_mask;
+ unsigned int depth_mask;
+} drm_savage_clear_t;
+
+typedef struct drm_savage_vertex {
+ int idx; /* buffer to queue */
+ int used; /* bytes in use */
+ int discard; /* client finished with buffer? */
+} drm_savage_vertex_t;
+
+typedef struct drm_savage_indices {
+ int idx; /* buffer to queue */
+ unsigned int start;
+ unsigned int end;
+ int discard; /* client finished with buffer? */
+} drm_savage_indices_t;
+
+typedef struct drm_savage_iload {
+ int idx;
+ unsigned int dstorg;
+ unsigned int length;
+} drm_savage_iload_t;
+
+typedef struct _drm_savage_blit {
+ unsigned int planemask;
+ unsigned int srcorg;
+ unsigned int dstorg;
+ int src_pitch, dst_pitch;
+ int delta_sx, delta_sy;
+ int delta_dx, delta_dy;
+ int height, ydir; /* flip image vertically */
+ int source_pitch, dest_pitch;
+} drm_savage_blit_t;
+
+#endif
diff --git a/src/savage_hwmc.c b/src/savage_hwmc.c
new file mode 100644
index 0000000..37d314d
--- /dev/null
+++ b/src/savage_hwmc.c
@@ -0,0 +1,403 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86_ansic.h"
+#include "compiler.h"
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+#include "xf86fbman.h"
+#include "regionstr.h"
+
+#include "savage_driver.h"
+#include "savage_dri.h"
+
+#include "xf86xv.h"
+#include "xf86xvmc.h"
+#include "Xv.h"
+#include "XvMC.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "dixstruct.h"
+#include "fourcc.h"
+
+#define SAVAGE_MAX_SURFACES 5
+#define SAVAGE_MAX_SUBPICTURES 1
+
+#define XVMC_IDCT_8BIT 0x80000000
+
+
+int SAVAGEXvMCCreateContext (ScrnInfoPtr pScrn, XvMCContextPtr pContext,
+ int *num_priv, long **priv );
+void SAVAGEXvMCDestroyContext (ScrnInfoPtr pScrn, XvMCContextPtr pContext);
+
+int SAVAGEXvMCCreateSurface (ScrnInfoPtr pScrn, XvMCSurfacePtr pSurf,
+ int *num_priv, long **priv );
+void SAVAGEXvMCDestroySurface (ScrnInfoPtr pScrn, XvMCSurfacePtr pSurf);
+
+int SAVAGEXvMCCreateSubpicture (ScrnInfoPtr pScrn, XvMCSubpicturePtr pSurf,
+ int *num_priv, long **priv );
+void SAVAGEXvMCDestroySubpicture (ScrnInfoPtr pScrn, XvMCSubpicturePtr pSurf);
+
+
+typedef struct {
+ drm_context_t drmcontext;
+ unsigned int fbBase;
+ unsigned int MMIOHandle;
+ unsigned int MMIOSize;
+ unsigned int SurfaceHandle;
+ unsigned int SurfaceOffset;
+ unsigned int SurfaceSize;
+ unsigned int DCTBlockHandle;
+ unsigned int DCTBlockOffset;
+ unsigned int DCTBlockSize;
+ unsigned int ApertureHandle;
+ unsigned int ApertureSize;
+ unsigned int bitsPerPixel;
+ unsigned int frameX0;
+ unsigned int frameY0;
+ unsigned int IOBase;
+ unsigned int displayWidth;
+ char busIdString[10];
+ char pad[2];
+} SAVAGEXvMCCreateContextRec;
+
+
+static int yv12_subpicture_index_list[1] =
+{
+ FOURCC_IA44
+};
+
+static XF86MCImageIDList yv12_subpicture_list =
+{
+ 1,
+ yv12_subpicture_index_list
+};
+
+static XF86MCSurfaceInfoRec savage_YV12_mpg2_surface =
+{
+ FOURCC_YV12,
+ XVMC_CHROMA_FORMAT_420,
+ 0,
+ 720,
+ 576,
+ 720,
+ 576,
+ XVMC_MPEG_2,
+ XVMC_OVERLAID_SURFACE | XVMC_INTRA_UNSIGNED | XVMC_BACKEND_SUBPICTURE | XVMC_IDCT_8BIT,
+ &yv12_subpicture_list
+};
+
+static XF86MCSurfaceInfoPtr ppSI[1] =
+{
+ (XF86MCSurfaceInfoPtr)&savage_YV12_mpg2_surface,
+};
+
+/* List of subpicture types that we support */
+static XF86ImageRec ia44_subpicture = XVIMAGE_IA44;
+
+static XF86ImagePtr savage_subpicture_list[1] =
+{
+ (XF86ImagePtr)&ia44_subpicture,
+};
+
+/* Fill in the device dependent adaptor record.
+ * This is named "SAVAGE Video Overlay" because this code falls under the
+ * XV extenstion, the name must match or it won't be used.
+ *
+ * Surface and Subpicture - see above
+ * Function pointers to functions below
+ */
+static XF86MCAdaptorRec pAdapt =
+{
+ "Savage Streams Engine", /* name */
+ 1, /* num_surfaces */
+ ppSI, /* surfaces */
+ 1, /* num_subpictures */
+ savage_subpicture_list, /* subpictures */
+ (xf86XvMCCreateContextProcPtr)SAVAGEXvMCCreateContext,
+ (xf86XvMCDestroyContextProcPtr)SAVAGEXvMCDestroyContext,
+ (xf86XvMCCreateSurfaceProcPtr)SAVAGEXvMCCreateSurface,
+ (xf86XvMCDestroySurfaceProcPtr)SAVAGEXvMCDestroySurface,
+ (xf86XvMCCreateSubpictureProcPtr)SAVAGEXvMCCreateSubpicture,
+ (xf86XvMCDestroySubpictureProcPtr)SAVAGEXvMCDestroySubpicture
+};
+
+static XF86MCAdaptorPtr ppAdapt[1] =
+{
+ (XF86MCAdaptorPtr)&pAdapt
+};
+
+/**************************************************************************
+ *
+ * SAVAGEInitMC
+ *
+ * Initialize the hardware motion compenstation extention for this
+ * hardware. The initialization routines want the address of the pointers
+ * to the structures, not the address of the structures. This means we
+ * allocate (or create static?) the pointer memory and pass that
+ * address. This seems a little convoluted.
+ *
+ * We need to allocate memory for the device depended adaptor record.
+ * This is what holds the pointers to all our device functions.
+ *
+ * We need to map the overlay registers into the drm.
+ *
+ * We need to map the surfaces into the drm.
+ *
+ * Inputs:
+ * Screen pointer
+ *
+ * Outputs:
+ * None, this calls the device independent screen initialization
+ * function.
+ *
+ * Revisions:
+ *
+ **************************************************************************/
+Bool SAVAGEInitMC(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SavagePtr pSAVAGE = SAVPTR(pScrn);
+ DRIInfoPtr pDRIInfo = pSAVAGE->pDRIInfo;
+ SAVAGEDRIPtr pSAVAGEDriPriv = (SAVAGEDRIPtr)pDRIInfo->devPrivate;
+ int i;
+ unsigned int offset;
+
+ /* Clear the Surface Allocation */
+ for(i=0; i<SAVAGE_MAX_SURFACES; i++) {
+ pSAVAGE->surfaceAllocation[i] = 0;
+ }
+
+ if(pSAVAGE->hwmcSize == 0)
+ {
+ xf86DrvMsg(X_ERROR, pScrn->scrnIndex,
+ "SAVAGEInitMC: There is not enough memory!\n");
+ return FALSE;
+ }
+
+ offset = pSAVAGE->hwmcOffset + pSAVAGE->FrameBufferBase;
+
+ if(drmAddMap(pSAVAGE->drmFD, offset, pSAVAGE->hwmcSize,
+ DRM_FRAME_BUFFER, 0, &pSAVAGEDriPriv->xvmcSurfHandle) < 0)
+ {
+
+ xf86DrvMsg(X_ERROR, pScrn->scrnIndex,
+ "SAVAGEInitMC: Cannot add map to drm!\n");
+ return FALSE;
+ }
+
+ return xf86XvMCScreenInit(pScreen, 1, ppAdapt);
+}
+
+/**************************************************************************
+ *
+ * SAVAGEXvMCCreateContext
+ *
+ * Some info about the private data:
+ *
+ * Set *num_priv to the number of 32bit words that make up the size of
+ * of the data that priv will point to.
+ *
+ * *priv = (long *) xcalloc (elements, sizeof(element))
+ * *num_priv = (elements * sizeof(element)) >> 2;
+ *
+ **************************************************************************/
+
+int SAVAGEXvMCCreateContext (ScrnInfoPtr pScrn, XvMCContextPtr pContext,
+ int *num_priv, long **priv )
+{
+ SavagePtr pSAVAGE = SAVPTR(pScrn);
+ DRIInfoPtr pDRIInfo = pSAVAGE->pDRIInfo;
+ SAVAGEDRIPtr pSAVAGEDriPriv = (SAVAGEDRIPtr)pDRIInfo->devPrivate;
+ SAVAGEXvMCCreateContextRec *contextRec;
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+
+
+ if(!pSAVAGE->directRenderingEnabled) {
+ xf86DrvMsg(X_ERROR, pScrn->scrnIndex,
+ "SAVAGEXvMCCreateContext: Cannot use XvMC without DRI!\n");
+ return BadAlloc;
+ }
+
+ /* Context Already in use! */
+ if(pSAVAGE->xvmcContext) {
+ xf86DrvMsg(X_WARNING, pScrn->scrnIndex,
+ "SAVAGEXvMCCreateContext: 2 XvMC Contexts Attempted, not supported.\n");
+ return BadAlloc;
+ }
+
+ *priv = xcalloc(1,sizeof(SAVAGEXvMCCreateContextRec));
+ contextRec = (SAVAGEXvMCCreateContextRec *)*priv;
+
+ if(!*priv) {
+ *num_priv = 0;
+ return(BadAlloc);
+ }
+
+ *num_priv = sizeof(SAVAGEXvMCCreateContextRec) >> 2;
+
+ if(drmCreateContext(pSAVAGE->drmFD, &(contextRec->drmcontext) ) < 0) {
+ xf86DrvMsg(X_ERROR, pScrn->scrnIndex,
+ "SAVAGEXvMCCreateContext: Unable to create DRMContext!\n");
+ xfree(*priv);
+ return(BadAlloc);
+ }
+
+ drmAuthMagic(pSAVAGE->drmFD, pContext->flags);
+
+ pSAVAGE->xvmcContext = contextRec->drmcontext;
+ contextRec->fbBase = pScrn->memPhysBase;
+
+ contextRec->MMIOHandle = pSAVAGEDriPriv->registers.handle;
+ contextRec->MMIOSize = pSAVAGEDriPriv->registers.size;
+
+ contextRec->DCTBlockHandle = pSAVAGEDriPriv->agpTextures.handle;
+ contextRec->DCTBlockOffset = pSAVAGEDriPriv->agpTextures.offset;
+ contextRec->DCTBlockSize = pSAVAGEDriPriv->agpTextures.size;
+
+ contextRec->SurfaceHandle = pSAVAGEDriPriv->xvmcSurfHandle;
+ contextRec->SurfaceOffset = pSAVAGE->hwmcOffset;
+ contextRec->SurfaceSize = pSAVAGE->hwmcSize;
+
+ contextRec->ApertureHandle = pSAVAGEDriPriv->aperture.handle;
+ contextRec->ApertureSize = pSAVAGEDriPriv->aperture.size;
+
+ contextRec->bitsPerPixel = pScrn->bitsPerPixel;
+ contextRec->frameX0 = pScrn->frameX0;
+ contextRec->frameY0 = pScrn->frameY0;
+ contextRec->IOBase = hwp->IOBase;
+ contextRec->displayWidth = pScrn->displayWidth;
+
+
+ strncpy (contextRec->busIdString, pDRIInfo->busIdString, 9);
+
+ return Success;
+}
+
+
+int SAVAGEXvMCCreateSurface (ScrnInfoPtr pScrn, XvMCSurfacePtr pSurf,
+ int *num_priv, long **priv )
+{
+ SavagePtr pSAVAGE = SAVPTR(pScrn);
+ int i;
+ /* This size is used for flip, mixer, subpicture and palette buffers*/
+ unsigned int offset = ((786*576*2 + 2048)*5 + 2048) & 0xfffff800;
+
+ *priv = (long *)xcalloc(2,sizeof(long));
+
+ if(!*priv) {
+ xf86DrvMsg(X_ERROR, pScrn->scrnIndex,
+ "SAVAGEXvMCCreateSurface: Unable to allocate memory!\n");
+ *num_priv = 0;
+ return (BadAlloc);
+ }
+ *num_priv = 1;
+
+ /* Surface Arrangement is different based on 6 or 7 Surfaces */
+ for(i = 0; i < SAVAGE_MAX_SURFACES; i++) {
+ if(!pSAVAGE->surfaceAllocation[i]) {
+ pSAVAGE->surfaceAllocation[i] = pSurf->surface_id;
+ (*priv)[0] = offset + (576 * 786 * 2 + 2048) * i;
+ /* UV data starts at 0 offset, each set is 288k * */
+ return Success;
+ }
+ }
+
+ (*priv)[0] = 0;
+ return BadAlloc;
+}
+
+int SAVAGEXvMCCreateSubpicture (ScrnInfoPtr pScrn, XvMCSubpicturePtr pSubp,
+ int *num_priv, long **priv )
+{
+ SavagePtr pSAVAGE = SAVPTR(pScrn);
+ int i;
+
+ *priv = (long *)xcalloc(1,sizeof(long));
+
+ if(!*priv) {
+ xf86DrvMsg(X_ERROR, pScrn->scrnIndex,
+ "SAVAGEXvMCCreateSubpicture: Unable to allocate memory!\n");
+ *num_priv = 0;
+ return (BadAlloc);
+ }
+
+ *num_priv = 1;
+
+ for(i = SAVAGE_MAX_SURFACES; i < SAVAGE_MAX_SURFACES + SAVAGE_MAX_SUBPICTURES; i++) {
+ if(!pSAVAGE->surfaceAllocation[i]) {
+ pSAVAGE->surfaceAllocation[i] = pSubp->subpicture_id;
+ (*priv)[0] = ( 576*1024 * i);
+ return Success;
+ }
+ }
+
+ (*priv)[0] = 0;
+ return BadAlloc;
+}
+
+void SAVAGEXvMCDestroyContext (ScrnInfoPtr pScrn, XvMCContextPtr pContext)
+{
+ SavagePtr pSAVAGE = SAVPTR(pScrn);
+
+ drmDestroyContext(pSAVAGE->drmFD,pSAVAGE->xvmcContext);
+ pSAVAGE->xvmcContext = 0;
+}
+
+void SAVAGEXvMCDestroySurface (ScrnInfoPtr pScrn, XvMCSurfacePtr pSurf)
+{
+ SavagePtr pSAVAGE = SAVPTR(pScrn);
+ int i;
+
+ for(i=0; i<SAVAGE_MAX_SURFACES; i++) {
+ if(pSAVAGE->surfaceAllocation[i] == pSurf->surface_id) {
+ pSAVAGE->surfaceAllocation[i] = 0;
+ return;
+ }
+ }
+ return;
+}
+
+void SAVAGEXvMCDestroySubpicture (ScrnInfoPtr pScrn, XvMCSubpicturePtr pSubp)
+{
+ SavagePtr pSAVAGE = SAVPTR(pScrn);
+ int i;
+
+ for(i = SAVAGE_MAX_SURFACES; i < SAVAGE_MAX_SURFACES + SAVAGE_MAX_SUBPICTURES; i++) {
+ if(pSAVAGE->surfaceAllocation[i] == pSubp->subpicture_id) {
+ pSAVAGE->surfaceAllocation[i] = 0;
+ return;
+ }
+ }
+ return;
+}
+
+
+
+
+
+
diff --git a/src/savage_image.c b/src/savage_image.c
index 8b9605b..9530bff 100644
--- a/src/savage_image.c
+++ b/src/savage_image.c
@@ -102,7 +102,7 @@ SavageWriteBitmapCPUToScreenColorExpand (
cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP
| BCI_CMD_SEND_COLOR | BCI_CMD_CLIP_LR
| BCI_CMD_DEST_GBD | BCI_CMD_SRC_MONO;
- cmd |= XAACopyROP[rop] << 16;
+ cmd |= XAAGetCopyROP(rop) << 16;
if( bg == -1 )
cmd |= BCI_CMD_SRC_TRANSPARENT;
@@ -160,7 +160,7 @@ SavageSetupForImageWrite(
| BCI_CMD_CLIP_LR
| BCI_CMD_DEST_GBD | BCI_CMD_SRC_COLOR;
- cmd |= XAACopyROP[rop] << 16;
+ cmd |= XAAGetCopyROP(rop) << 16;
if( transparency_color != -1 )
cmd |= BCI_CMD_SRC_TRANSPARENT;
@@ -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 0f807a1..92f0584 100644
--- a/src/savage_regs.h
+++ b/src/savage_regs.h
@@ -66,97 +66,6 @@ enum S3CHIPTAGS {
#define STREAMS_TIMEOUT_REG 0x8208
#define MISC_TIMEOUT_REG 0x820c
-/* 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 SUBSYS_STAT_REG 0x8504
@@ -198,8 +107,8 @@ enum S3CHIPTAGS {
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) {}; \
} \
}
diff --git a/src/savage_sarea.h b/src/savage_sarea.h
new file mode 100644
index 0000000..d4287cf
--- /dev/null
+++ b/src/savage_sarea.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef __SAVAGE_SAREA_H__
+#define __SAVAGE_SAREA_H__
+
+#include "drm.h"
+
+/* WARNING: If you change any of these defines, make sure to change
+ * the kernel include file as well (savage_drm.h)
+ */
+#ifndef __SAVAGE_SAREA_DEFINES__
+#define __SAVAGE_SAREA_DEFINES__
+#endif
+typedef drm_savage_sarea_t SAVAGESAREAPrivRec;
+typedef drm_savage_sarea_t *SAVAGESAREAPrivPtr;
+
+
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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 ea37260..25e64da 100644
--- a/src/savage_vbe.c
+++ b/src/savage_vbe.c
@@ -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->PAL ? 0x08 : 0x04;
- 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 );
@@ -127,13 +127,13 @@ SavageSetVESAMode( SavagePtr psav, int n, int Refresh )
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);
}
@@ -184,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." );
@@ -200,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
@@ -221,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) &&
@@ -256,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
{
@@ -281,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;
@@ -297,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 4e9b5f3..56c9a8f 100644
--- a/src/savage_video.c
+++ b/src/savage_video.c
@@ -7,6 +7,7 @@
#include "xaalocal.h"
#include "savage_driver.h"
+#include "savage_streams.h"
#define OFF_DELAY 200 /* milliseconds */
#define FREE_DELAY 60000
@@ -17,7 +18,7 @@
#define TIMER_MASK (OFF_TIMER | FREE_TIMER)
-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);
@@ -32,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;
@@ -73,9 +68,6 @@ static void (*SavageDisplayVideo)(
short drw_w, short drw_h
) = NULL;
-static void OverlayParamInit(ScrnInfoPtr pScrn);
-static void InitStreamsForExpansion(ScrnInfoPtr pScrn);
-
/*static void SavageBlockHandler(int, pointer, pointer, pointer);*/
#define XVTRACE 4
@@ -207,76 +199,6 @@ typedef struct {
#define GET_PORT_PRIVATE(pScrn) \
(SavagePortPrivPtr)((SAVPTR(pScrn))->adaptor->pPortPrivates[0].ptr)
-/**************************************
- 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))
-
static
unsigned int GetBlendForFourCC( int id )
{
@@ -296,238 +218,31 @@ 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 %04lx, was %08lx, want %08lx,",
- offset, (unsigned long)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 %08lx\n", (unsigned long)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. */
-
- 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) );
-}
-
-#undef OUTREG
-#if 0
-#define OUTREG(a,v) myOUTREG(psav,a,v)
-#else
-#define OUTREG(addr,val) MMIO_OUT32(psav->MapBase, addr, val)
-#endif
-
-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 );
- }
-
- /* Primary stream reflects the frame buffer. */
-
- 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 );
-
- 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) ||
-#if 0 /* I don't think commenting this out is correct (EE) */
+
+ if( (psav->Chipset == S3_SAVAGE_MX) ||
(psav->Chipset == S3_SUPERSAVAGE) ||
-#endif
- (psav->Chipset == S3_SAVAGE2000) )
- {
- jStreamsControl = VGAIN8( vgaCRReg ) | ENABLE_STREAM1;
-
- /* Wait for VBLANK. */
-
- VerticalRetraceWait(psav);
-
- /* 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", (char *)&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
- {
- jStreamsControl = VGAIN8( vgaCRReg ) | ENABLE_STREAMS_OLD;
-
- /* Wait for VBLANK. */
-
- VerticalRetraceWait(psav);
-
- /* Fire up streams! */
-
- VGAOUT16( vgaCRIndex, (jStreamsControl << 8) | EXT_MISC_CTRL2 );
-
- SavageInitStreamsOld( pScrn );
+ (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(psav);
-
- /* 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_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 );
-
- psav->videoFlags &= ~VF_STREAMS_ON;
}
-
void SavageInitVideo(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
@@ -546,7 +261,6 @@ void SavageInitVideo(ScreenPtr pScreen)
newAdaptor = SavageSetupImageVideo(pScreen);
SavageInitOffscreenImages(pScreen);
- SavageInitStreams = SavageInitStreamsNew;
SavageSetColor = SavageSetColorNew;
SavageSetColorKey = SavageSetColorKeyNew;
SavageDisplayVideo = SavageDisplayVideoNew;
@@ -557,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;
@@ -590,9 +303,6 @@ void SavageInitVideo(ScreenPtr pScreen)
if( newAdaptor )
{
- if( SavageInitStreams == SavageInitStreamsNew )
- SavageInitStreams(pScrn);
- psav->videoFlags = 0;
psav->videoFourCC = 0;
}
}
@@ -967,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;
@@ -1178,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,
@@ -1194,26 +921,22 @@ SavageDisplayVideoOld(
SavagePortPrivPtr pPriv = psav->adaptor->pPortPrivates[0].ptr;
/*DisplayModePtr mode = pScrn->currentMode;*/
int vgaCRIndex, vgaCRReg, vgaIOBase;
- unsigned int ssControl;
+ 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);
}
/* 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. */
@@ -1227,15 +950,12 @@ SavageDisplayVideoOld(
/* 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) );
-
- ssControl = 0;
+ OUTREG(SSTREAM_WINDOW_SIZE_REG, OS_WH(dstBox->x2-dstBox->x1,
+ dstBox->y2-dstBox->y1));
if( src_w > (drw_w << 1) )
{
@@ -1276,7 +996,7 @@ SavageDisplayVideoOld(
VGAOUT8(vgaCRIndex, 0x93);
VGAOUT8(vgaCRReg, pitch);
}
-
+ OUTREG(STREAMS_FIFO_REG, 0x2 | 25 << 5 | 32 << 11);
}
static void
@@ -1302,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);
}
@@ -1352,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. */
@@ -1402,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 */
@@ -1483,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 */
@@ -1577,50 +1281,6 @@ SavageQueryImageAttributes(
return size;
}
-#if 0
-
-static void
-CHIPSBlockHandler (
- int i,
- pointer blockData,
- pointer pTimeout,
- pointer pReadmask
-){
- ScreenPtr pScreen = screenInfo.screens[i];
- ScrnInfoPtr pScrn = xf86Screens[i];
- CHIPSPtr cPtr = CHIPSPTR(pScrn);
- CHIPSPortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn);
- unsigned char mr3c;
-
- pScreen->BlockHandler = cPtr->BlockHandler;
-
- (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
-
- pScreen->BlockHandler = CHIPSBlockHandler;
-
- CHIPSHiQVSync(pScrn);
- if(pPriv->videoStatus & TIMER_MASK) {
- UpdateCurrentTime();
- if(pPriv->videoStatus & OFF_TIMER) {
- if(pPriv->offTime < currentTime.milliseconds) {
- mr3c = cPtr->readMR(cPtr, 0x3C);
- cPtr->writeMR(cPtr, 0x3C, (mr3c & 0xFE));
- pPriv->videoStatus = FREE_TIMER;
- pPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
- }
- } else { /* FREE_TIMER */
- if(pPriv->freeTime < currentTime.milliseconds) {
- if(pPriv->area) {
- xf86FreeOffscreenArea(pPriv->area);
- pPriv->area = NULL;
- }
- pPriv->videoStatus = 0;
- }
- }
- }
-}
-
-#endif
/****************** Offscreen stuff ***************/
@@ -1688,7 +1348,7 @@ SavageStopSurface(
if(pPriv->isOn) {
/*SavagePtr psav = SAVPTR(surface->pScrn);*/
- SavageStreamsOff( surface->pScrn );
+ SavageClipVWindow(surface->pScrn);
pPriv->isOn = FALSE;
}
@@ -1823,96 +1483,3 @@ SavageInitOffscreenImages(ScreenPtr pScreen)
xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1);
}
-
-/* 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 */