summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTilman Sauerbeck <tilman@code-monkey.de>2007-04-16 20:47:57 +0200
committerTilman Sauerbeck <tilman@code-monkey.de>2007-04-16 20:47:57 +0200
commit370c1d36f9e3025870f41e39c06b12689d51e688 (patch)
tree0bc13a92b46c77b82440a7e44b7938e82505f4b8
parent3bdda29f071f9e205530472cde96372ba2731876 (diff)
parent7b080d993ceda7b181e0611ed0c997c8aecc9ad7 (diff)
Merge branch 'master' into randr-1.2
Conflicts: src/mga.h src/mga_dacG.c src/mga_dri.c src/mga_driver.c
-rw-r--r--src/mga.h29
-rw-r--r--src/mga_dri.c219
-rw-r--r--src/mga_driver.c70
-rw-r--r--src/mga_exa.c124
-rw-r--r--src/mga_g_crtc.c8
-rw-r--r--src/mga_g_output.c6
-rw-r--r--src/mga_storm.c182
-rw-r--r--src/mga_vga.c215
-rw-r--r--util/stormdwg.c10
9 files changed, 611 insertions, 252 deletions
diff --git a/src/mga.h b/src/mga.h
index c5d967e..8a3cf6b 100644
--- a/src/mga.h
+++ b/src/mga.h
@@ -158,6 +158,32 @@ void MGAdbg_outreg32(ScrnInfoPtr, int,int, char*);
outTi3026dreg(TVP3026_DATA, tmp | (val)); \
} while (0)
+#define MGAWAITVSYNC() \
+ do { \
+ unsigned int count = 0; \
+ unsigned int status = 0; \
+ do { \
+ status = INREG( MGAREG_Status ); \
+ count++; \
+ } while( ( status & 0x08 ) && (count < 250000) );\
+ count = 0; \
+ status = 0; \
+ do { \
+ status = INREG( MGAREG_Status ); \
+ count++; \
+ } while( !( status & 0x08 ) && (count < 250000) );\
+ } while (0)
+
+#define MGAWAITBUSY() \
+ do { \
+ unsigned int count = 0; \
+ unsigned int status = 0; \
+ do { \
+ status = INREG8( MGAREG_Status + 2 ); \
+ count++; \
+ } while( ( status & 0x01 ) && (count < 500000) ); \
+ } while (0)
+
#define PORT_OFFSET (0x1F00 - 0x300)
#define MGA_VERSION 4000
@@ -593,6 +619,9 @@ long MGAG450SavePLLFreq(ScrnInfoPtr pScrn, mga_pll_t pll);
void MGAprintDac(ScrnInfoPtr pScrn);
void MGAG200SESaveFonts(ScrnInfoPtr, vgaRegPtr);
void MGAG200SERestoreFonts(ScrnInfoPtr, vgaRegPtr);
+void MGAG200SESaveMode(ScrnInfoPtr, vgaRegPtr);
+void MGAG200SERestoreMode(ScrnInfoPtr, vgaRegPtr);
+void MGAG200SEHWProtect(ScrnInfoPtr, Bool);
Bool MgaGCrtc1Init(ScrnInfoPtr pScrn);
Bool MgaGCrtc2Init(ScrnInfoPtr pScrn);
diff --git a/src/mga_dri.c b/src/mga_dri.c
index f1a128c..ce81982 100644
--- a/src/mga_dri.c
+++ b/src/mga_dri.c
@@ -76,13 +76,6 @@
static char MGAKernelDriverName[] = "mga";
static char MGAClientDriverName[] = "mga";
-/* DRI buffer management
- */
-extern void mgaDRIInitBuffers( WindowPtr pWin, RegionPtr prgn, CARD32 index );
-extern void mgaDRIMoveBuffers( WindowPtr pParent, DDXPointRec ptOldOrg,
- RegionPtr prgnSrc, CARD32 index );
-
-
/* 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
@@ -446,7 +439,6 @@ MGADRISwapContext( ScreenPtr pScreen, DRISyncType syncType,
}
}
-#ifdef USE_XAA
void MGASelectBuffer( ScrnInfoPtr pScrn, int which )
{
MGAPtr pMga = MGAPTR(pScrn);
@@ -468,8 +460,6 @@ void MGASelectBuffer( ScrnInfoPtr pScrn, int which )
break;
}
}
-#endif
-
static unsigned int mylog2( unsigned int n )
{
@@ -861,6 +851,200 @@ static Bool MGADRIBuffersInit( ScreenPtr pScreen )
return TRUE;
}
+#ifdef USE_XAA
+static void MGADRIInitBuffersXAA(WindowPtr pWin, RegionPtr prgn,
+ CARD32 index)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ MGAPtr pMga = MGAPTR(pScrn);
+ BoxPtr pbox = REGION_RECTS(prgn);
+ int nbox = REGION_NUM_RECTS(prgn);
+ XAAInfoRecPtr xaa = pMga->AccelInfoRec;
+
+ CHECK_DMA_QUIESCENT(MGAPTR(pScrn), pScrn);
+
+ xaa->SetupForSolidFill(pScrn, 0, GXcopy, -1);
+
+ while (nbox--) {
+ MGASelectBuffer(pScrn, MGA_BACK);
+ xaa->SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
+ pbox->x2-pbox->x1, pbox->y2-pbox->y1);
+ MGASelectBuffer(pScrn, MGA_DEPTH);
+ xaa->SubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
+ pbox->x2-pbox->x1, pbox->y2-pbox->y1);
+ pbox++;
+ }
+
+ MGASelectBuffer(pScrn, MGA_FRONT);
+
+ pMga->AccelInfoRec->NeedToSync = TRUE;
+}
+#endif
+
+#ifdef USE_EXA
+static void MGADRIInitBuffersEXA(WindowPtr pWin, RegionPtr prgn,
+ CARD32 index)
+{
+ /* FIXME */
+}
+#endif
+
+#ifdef USE_XAA
+/*
+ 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.
+*/
+static void MGADRIMoveBuffersXAA(WindowPtr pParent, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc, CARD32 index)
+{
+ ScreenPtr pScreen = pParent->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ MGAPtr pMga = MGAPTR(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;
+ XAAInfoRecPtr xaa = pMga->AccelInfoRec;
+
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
+ 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;
+ }
+
+ xaa->SetupForScreenToScreenCopy(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;
+
+ MGASelectBuffer(pScrn, MGA_BACK);
+ xaa->SubsequentScreenToScreenCopy(pScrn, x1, y1, destx, desty, w, h);
+ MGASelectBuffer(pScrn, MGA_DEPTH);
+ xaa->SubsequentScreenToScreenCopy(pScrn, x1, y1, destx, desty, w, h);
+ }
+ MGASelectBuffer(pScrn, MGA_FRONT);
+
+ if (pboxNew2) {
+ DEALLOCATE_LOCAL(pptNew2);
+ DEALLOCATE_LOCAL(pboxNew2);
+ }
+ if (pboxNew1) {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+
+ pMga->AccelInfoRec->NeedToSync = TRUE;
+
+}
+#endif
+
+#ifdef USE_EXA
+static void MGADRIMoveBuffersEXA(WindowPtr pParent, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc, CARD32 index)
+{
+ /* FIXME */
+}
+#endif
Bool MGADRIScreenInit( ScreenPtr pScreen )
{
@@ -1003,8 +1187,19 @@ Bool MGADRIScreenInit( ScreenPtr pScreen )
pDRIInfo->DestroyContext = MGADestroyContext;
pDRIInfo->SwapContext = MGADRISwapContext;
- pDRIInfo->InitBuffers = mgaDRIInitBuffers;
- pDRIInfo->MoveBuffers = mgaDRIMoveBuffers;
+#ifdef USE_EXA
+ if (pMga->Exa) {
+ pDRIInfo->InitBuffers = MGADRIInitBuffersEXA;
+ pDRIInfo->MoveBuffers = MGADRIMoveBuffersEXA;
+ } else {
+#endif
+#ifdef USE_XAA
+ pDRIInfo->InitBuffers = MGADRIInitBuffersXAA;
+ pDRIInfo->MoveBuffers = MGADRIMoveBuffersXAA;
+#endif
+#ifdef USE_EXA
+ }
+#endif
pDRIInfo->bufferRequests = DRI_ALL_WINDOWS;
diff --git a/src/mga_driver.c b/src/mga_driver.c
index 590c5f2..ed923e8 100644
--- a/src/mga_driver.c
+++ b/src/mga_driver.c
@@ -698,6 +698,7 @@ MGACountRam(ScrnInfoPtr pScrn)
int ProbeSize = 8192;
int SizeFound = 2048;
CARD32 biosInfo = 0;
+ CARD8 seq1;
#if 0
/* This isn't correct. It looks like this can have arbitrary
@@ -770,6 +771,16 @@ MGACountRam(ScrnInfoPtr pScrn)
MGAMapMem(pScrn);
base = pMga->FbBase;
+ if (pMga->is_G200SE) {
+ OUTREG8(MGAREG_SEQ_INDEX, 0x01);
+ seq1 = INREG8(MGAREG_SEQ_DATA);
+ seq1 |= 0x20;
+ MGAWAITVSYNC();
+ MGAWAITBUSY();
+ OUTREG8(MGAREG_SEQ_DATA, seq1);
+ usleep(20000);
+ }
+
/* turn MGA mode on - enable linear frame buffer (CRTCEXT3) */
OUTREG8(MGAREG_CRTCEXT_INDEX, 3);
tmp = INREG8(MGAREG_CRTCEXT_DATA);
@@ -790,7 +801,7 @@ MGACountRam(ScrnInfoPtr pScrn)
base[1] = 0;
for (Offset = 0x100000; Offset < (ProbeSize * 1024);
- Offset += 0x1000) {
+ Offset += 0x1000) {
FirstMemoryVal1 = base[Offset];
FirstMemoryVal2 = base[Offset+1];
SecondMemoryVal1 = base[Offset+0x100];
@@ -845,8 +856,17 @@ MGACountRam(ScrnInfoPtr pScrn)
OUTREG8(MGAREG_CRTCEXT_INDEX, 3);
OUTREG8(MGAREG_CRTCEXT_DATA, tmp);
+ if (pMga->is_G200SE) {
+ OUTREG8(MGAREG_SEQ_INDEX, 0x01);
+ seq1 = INREG8(MGAREG_SEQ_DATA);
+ seq1 &= ~0x20;
+ MGAWAITVSYNC();
+ MGAWAITBUSY();
+ OUTREG8(MGAREG_SEQ_DATA, seq1);
+ usleep(20000);
+ }
MGAUnmapMem(pScrn);
- }
+ }
return SizeFound;
}
@@ -1254,6 +1274,9 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
if (pMga->SecondCrtc)
flags24 = Support32bppFb;
+ if (pMga->is_G200SE)
+ pScrn->confScreen->defaultdepth = 16;
+
if (!xf86SetDepthBpp(pScrn, 0, 0, 0, flags24)) {
return FALSE;
} else {
@@ -1304,6 +1327,14 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
memcpy(pMga->Options, MGAOptions, sizeof(MGAOptions));
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pMga->Options);
+ if (pMga->is_G200SE) {
+ /* Disable MTRR support on PCIe systems */
+ CARD32 temp = pciReadLong(pMga->PciTag, 0xDC);
+ if ((temp & 0x0000FF00) != 0x0) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling MTRR support.\n");
+ pScrn->options = xf86ReplaceBoolOption(pScrn->options, "MTRR", FALSE);
+ }
+ }
#if !defined(__powerpc__)
pMga->softbooted = FALSE;
@@ -1737,6 +1768,21 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
}
MGAUnmapMem(pScrn);
+ if (!pScrn->monitor->DDC && pMga->is_G200SE) {
+ /* Jam in ranges big enough for 1024x768 */
+ if (!pScrn->monitor->nHsync) {
+ pScrn->monitor->nHsync = 1;
+ pScrn->monitor->hsync[0].lo = 31.5;
+ pScrn->monitor->hsync[0].hi = 48.0;
+ }
+ if (!pScrn->monitor->nVrefresh) {
+ pScrn->monitor->nVrefresh = 1;
+ pScrn->monitor->vrefresh[0].lo = 56.0;
+ pScrn->monitor->vrefresh[0].hi = 75.0;
+ }
+ }
+
+
/*
* If the driver can do gamma correction, it should call xf86SetGamma()
* here.
@@ -2183,7 +2229,11 @@ MGASetMode(ScrnInfoPtr scrn, DisplayModePtr mode)
return FALSE;
/* Program the registers */
- vgaHWProtect(pScrn, TRUE);
+ if (pMga->is_G200SE) {
+ MGAG200SEHWProtect(pScrn, TRUE);
+ } else {
+ vgaHWProtect(pScrn, TRUE);
+ }
vgaReg = &hwp->ModeReg;
mgaReg = &pMga->ModeReg;
#endif
@@ -2193,7 +2243,11 @@ MGASetMode(ScrnInfoPtr scrn, DisplayModePtr mode)
MGAStormSync(scrn);
MGAStormEngineInit(scrn);
- vgaHWProtect(scrn, FALSE);
+ if (pMga->is_G200SE) {
+ MGAG200SEHWProtect(scrn, FALSE);
+ } else {
+ vgaHWProtect(scrn, FALSE);
+ }
if (xf86IsPc98()) {
if (pMga->Chipset == PCI_CHIP_MGA2064)
@@ -2202,6 +2256,11 @@ MGASetMode(ScrnInfoPtr scrn, DisplayModePtr mode)
outb(0xfac, 0x02);
}
+ if (pMga->is_G200SE) {
+ OUTREG8(0x1FDE, 0x06);
+ OUTREG8(0x1FDF, 0x14);
+ }
+
return TRUE;
}
@@ -2434,8 +2493,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
* InitGLXVisuals call back.
* The DRI does not work when textured video is enabled at this time.
*/
- if ((pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) ||
- (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI)) {
+ if (pMga->is_G200SE) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Not supported by hardware, not initializing the DRI\n");
pMga->directRenderingEnabled = FALSE;
diff --git a/src/mga_exa.c b/src/mga_exa.c
index 17618f5..c39af50 100644
--- a/src/mga_exa.c
+++ b/src/mga_exa.c
@@ -227,11 +227,6 @@ mgaPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int xdir, int ydir, int alu,
*/
QUIESCE_DMA(pSrc);
- DEBUG_MSG(("s: %x@%x d: %x@%x xdir %d ydir %d alu %d pm %d\n",
- exaGetPixmapOffset(pSrc), exaGetPixmapPitch(pSrc),
- exaGetPixmapOffset(pDst), exaGetPixmapPitch(pDst),
- xdir, ydir, alu, planemask));
-
if (xdir < 0)
blit_direction |= BLIT_LEFT;
@@ -261,8 +256,6 @@ mgaCopy(PixmapPtr pDst, int srcx, int srcy, int dstx, int dsty, int w, int h)
PMGA(pDst);
int start, end;
- DEBUG_MSG((" %d,%d -> %d,%d %dx%d\n", srcx, srcy, dstx,dsty, w, h));
-
w--;
if (pMga->BltScanDirection & BLIT_UP) {
@@ -277,9 +270,6 @@ mgaCopy(PixmapPtr pDst, int srcx, int srcy, int dstx, int dsty, int w, int h)
else
end += w;
- DEBUG_MSG((" end %d start %d dstx %d dsty %d w %d h %d\n",
- end, start, dstx, dsty, w, h));
-
WAITFIFO(4);
OUTREG(MGAREG_AR0, end);
OUTREG(MGAREG_AR3, start);
@@ -360,6 +350,8 @@ static Bool
mgaCheckComposite(int op, PicturePtr pSrcPict, PicturePtr pMaskPict,
PicturePtr pDstPict)
{
+ MGAPtr pMga = xf86Screens[pSrcPict->pDrawable->pScreen->myNum]->driverPrivate;
+
if (op >= sizeof(mgaBlendOp) / sizeof(mgaBlendOp[0])) {
DEBUG_MSG(("unsupported op %x\n", op));
return FALSE;
@@ -383,10 +375,9 @@ mgaCheckComposite(int op, PicturePtr pSrcPict, PicturePtr pMaskPict,
return FALSE;
}
- /* FIXME
- * Doing this operation in hardware is broken atm :/
- */
- if (op == PictOpAdd && pSrcPict->format == PICT_a8 &&
+ /* Only the G550 can perform Add on A8 textures, it seems. */
+ if (pMga->Chipset != PCI_CHIP_MGAG550 &&
+ op == PictOpAdd && pSrcPict->format == PICT_a8 &&
pDstPict->format == PICT_a8)
return FALSE;
@@ -732,6 +723,33 @@ mgaUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h,
src += src_pitch;
}
+ exaMarkSync(pDst->drawable.pScreen);
+
+ return TRUE;
+}
+
+static Bool
+mgaDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h,
+ char *dst, int dst_pitch)
+{
+ PMGA(pSrc);
+
+ char *src = pSrc->devPrivate.ptr;
+ int src_pitch = exaGetPixmapPitch(pSrc);
+
+ int cpp = (pSrc->drawable.bitsPerPixel + 7) / 8;
+ int bytes = w * cpp;
+
+ src += y * src_pitch + x * cpp;
+
+ QUIESCE_DMA(pSrc);
+
+ while (h--) {
+ memcpy (dst, src, bytes);
+ src += src_pitch;
+ dst += dst_pitch;
+ }
+
return TRUE;
}
@@ -749,6 +767,80 @@ mgaWaitMarker(ScreenPtr pScreen, int marker)
while (INREG (MGAREG_Status) & 0x10000);
}
+static void
+init_dri(ScrnInfoPtr pScrn)
+{
+ MGAPtr pMga = MGAPTR(pScrn);
+ MGADRIServerPrivatePtr dri = pMga->DRIServerInfo;
+ int cpp = pScrn->bitsPerPixel / 8;
+ int widthBytes = pScrn->displayWidth * cpp;
+ int bufferSize = ((pScrn->virtualY * widthBytes + MGA_BUFFER_ALIGN)
+ & ~MGA_BUFFER_ALIGN);
+ int maxlines, mb;
+
+ switch (pMga->Chipset) {
+ case PCI_CHIP_MGAG200_SE_A_PCI:
+ case PCI_CHIP_MGAG200_SE_B_PCI:
+ mb = 1;
+ break;
+ default:
+ mb = 16;
+ break;
+ }
+
+ maxlines = (min(pMga->FbUsableSize, mb * 1024 * 1024)) /
+ (pScrn->displayWidth * pMga->CurrentLayout.bitsPerPixel / 8);
+
+ dri->frontOffset = 0;
+ dri->frontPitch = widthBytes;
+
+ /* Try for front, back, depth, and two framebuffers worth of
+ * pixmap cache. Should be enough for a fullscreen background
+ * image plus some leftovers.
+ */
+ dri->textureSize = pMga->FbMapSize - 5 * bufferSize;
+
+ /* If that gives us less than half the available memory, let's
+ * be greedy and grab some more. Sorry, I care more about 3D
+ * performance than playing nicely, and you'll get around a full
+ * framebuffer's worth of pixmap cache anyway.
+ */
+ if (dri->textureSize < (int)pMga->FbMapSize / 2) {
+ dri->textureSize = pMga->FbMapSize - 4 * bufferSize;
+ }
+
+ /* Check to see if there is more room available after the maximum
+ * scanline for textures.
+ */
+ if ((int) pMga->FbMapSize - maxlines * widthBytes - bufferSize * 2
+ > dri->textureSize) {
+ dri->textureSize = pMga->FbMapSize - maxlines * widthBytes -
+ bufferSize * 2;
+ }
+
+ /* Set a minimum usable local texture heap size. This will fit
+ * two 256x256x32bpp textures.
+ */
+ if (dri->textureSize < 512 * 1024) {
+ dri->textureOffset = 0;
+ dri->textureSize = 0;
+ }
+
+ /* Reserve space for textures */
+ dri->textureOffset = (pMga->FbMapSize - dri->textureSize +
+ MGA_BUFFER_ALIGN) & ~MGA_BUFFER_ALIGN;
+
+ /* Reserve space for the shared depth buffer */
+ dri->depthOffset = (dri->textureOffset - bufferSize +
+ MGA_BUFFER_ALIGN) & ~MGA_BUFFER_ALIGN;
+ dri->depthPitch = widthBytes;
+
+ /* Reserve space for the shared back buffer */
+ dri->backOffset = (dri->depthOffset - bufferSize +
+ MGA_BUFFER_ALIGN) & ~MGA_BUFFER_ALIGN;
+ dri->backPitch = widthBytes;
+}
+
Bool
mgaExaInit(ScreenPtr pScreen)
{
@@ -806,6 +898,10 @@ mgaExaInit(ScreenPtr pScreen)
}
pExa->UploadToScreen = mgaUploadToScreen;
+ pExa->DownloadFromScreen = mgaDownloadFromScreen;
+
+ if (pMga->directRenderingEnabled)
+ init_dri(pScrn);
return exaDriverInit(pScreen, pExa);
}
diff --git a/src/mga_g_crtc.c b/src/mga_g_crtc.c
index 3f4fb4f..030a6bd 100644
--- a/src/mga_g_crtc.c
+++ b/src/mga_g_crtc.c
@@ -433,9 +433,7 @@ state_set(xf86CrtcPtr crtc, MgaCrtcStatePtr state,
MGA1064_MISC_CTL_DAC_RAM_CS;
if (pMga->HasSDRAM)
- state->Option = 0x40499121;
- else
- state->Option = 0x4049cd21;
+ state->Option = 0x40049120;
state->Option2 = 0x00008000;
break;
@@ -698,7 +696,7 @@ state_restore(xf86CrtcPtr crtc, MgaCrtcStatePtr state,
/* This handles restoring the generic VGA registers. */
if (pMga->is_G200SE) {
- vgaHWRestore(scrn, vga, VGA_SR_MODE);
+ MGAG200SERestoreMode(scrn, vga);
if (vga_flags & VGA_SR_FONTS)
MGAG200SERestoreFonts(scrn, vga);
@@ -752,7 +750,7 @@ state_save(xf86CrtcPtr crtc, MgaCrtcStatePtr state, int vga_flags)
* in the generic VGA portion.
*/
if (pMga->is_G200SE) {
- vgaHWSave(scrn, vga, VGA_SR_MODE);
+ MGAG200SESaveMode(scrn, vga);
if (vga_flags & VGA_SR_FONTS)
MGAG200SESaveFonts(scrn, vga);
diff --git a/src/mga_g_output.c b/src/mga_g_output.c
index e1a918f..2234219 100644
--- a/src/mga_g_output.c
+++ b/src/mga_g_output.c
@@ -150,7 +150,13 @@ output_dac1_dpms(xf86OutputPtr output, int mode)
break;
}
+ MGAWAITVSYNC();
+ MGAWAITBUSY();
+
OUTREG8(MGAREG_SEQ_DATA, seq1);
+
+ usleep(20000);
+
OUTREG8(MGAREG_CRTCEXT_DATA, crtcext1);
#endif
diff --git a/src/mga_storm.c b/src/mga_storm.c
index ccc17b3..67338d9 100644
--- a/src/mga_storm.c
+++ b/src/mga_storm.c
@@ -143,12 +143,6 @@ static void mgaSubsequentDashedTwoPointLine( ScrnInfoPtr pScrn,
static void mgaRestoreAccelState( ScrnInfoPtr pScrn );
-#ifdef XF86DRI
-void mgaDRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index);
-void mgaDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
- RegionPtr prgnSrc, CARD32 index);
-#endif
-
static void MGASetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1,
int x2, int y2);
static void MGADisableClipping(ScrnInfoPtr pScrn);
@@ -2570,179 +2564,3 @@ MGAFillCacheBltRects(
SET_SYNC_FLAG(infoRec);
}
-
-
-#if defined(XF86DRI)
-void
-mgaDRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- MGAPtr pMga = MGAPTR(pScrn);
- BoxPtr pbox = REGION_RECTS(prgn);
- int nbox = REGION_NUM_RECTS(prgn);
-
- CHECK_DMA_QUIESCENT(MGAPTR(pScrn), pScrn);
-
- mgaSetupForSolidFill(pScrn, 0, GXcopy, -1);
- while (nbox--) {
- MGASelectBuffer(pScrn, MGA_BACK);
- mgaSubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
- pbox->x2-pbox->x1, pbox->y2-pbox->y1);
- MGASelectBuffer(pScrn, MGA_DEPTH);
- mgaSubsequentSolidFillRect(pScrn, pbox->x1, pbox->y1,
- pbox->x2-pbox->x1, pbox->y2-pbox->y1);
- pbox++;
- }
- MGASelectBuffer(pScrn, MGA_FRONT);
-
- pMga->AccelInfoRec->NeedToSync = TRUE;
-}
-
-/*
- 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
-mgaDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
- RegionPtr prgnSrc, CARD32 index)
-{
- ScreenPtr pScreen = pParent->drawable.pScreen;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- MGAPtr pMga = MGAPTR(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;
-
- CHECK_DMA_QUIESCENT(MGAPTR(pScrn), pScrn);
-
- 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;
- }
-
- mgaSetupForScreenToScreenCopy(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;
-
- MGASelectBuffer(pScrn, MGA_BACK);
- mgaSubsequentScreenToScreenCopy(pScrn, x1, y1, destx, desty, w, h);
- MGASelectBuffer(pScrn, MGA_DEPTH);
- mgaSubsequentScreenToScreenCopy(pScrn, x1, y1, destx, desty, w, h);
- }
- MGASelectBuffer(pScrn, MGA_FRONT);
-
- if (pboxNew2) {
- DEALLOCATE_LOCAL(pptNew2);
- DEALLOCATE_LOCAL(pboxNew2);
- }
- if (pboxNew1) {
- DEALLOCATE_LOCAL(pptNew1);
- DEALLOCATE_LOCAL(pboxNew1);
- }
-
- pMga->AccelInfoRec->NeedToSync = TRUE;
-}
-
-#endif /* XF86DRI */
diff --git a/src/mga_vga.c b/src/mga_vga.c
index fbbfc60..2268017 100644
--- a/src/mga_vga.c
+++ b/src/mga_vga.c
@@ -1,9 +1,15 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "misc.h"
#include "xf86.h"
#include "xf86_OSproc.h"
#include "vgaHW.h"
#include "compiler.h"
#include "xf86cmap.h"
+#include "mga.h"
+#include "mga_reg.h"
#define TEXT_AMOUNT 16384
#define FONT_AMOUNT (8*8192)
@@ -12,9 +18,11 @@ void
MGAG200SERestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore)
{
vgaHWPtr hwp = VGAHWPTR(scrninfp);
+ MGAPtr pMga = MGAPTR(scrninfp);
int savedIOBase;
unsigned char miscOut, attr10, gr1, gr3, gr4, gr5, gr6, gr8, seq2, seq4;
Bool doMap = FALSE;
+ unsigned char scrn;
/* If nothing to do, return now */
if (!hwp->FontInfo1 && !hwp->FontInfo2 && !hwp->TextInfo)
@@ -48,7 +56,14 @@ MGAG200SERestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore)
/* Force into colour mode */
hwp->writeMiscOut(hwp, miscOut | 0x01);
- vgaHWBlankScreen(scrninfp, FALSE);
+ scrn = hwp->readSeq(hwp, 0x01);
+ scrn |= 0x20;/* blank screen */
+ vgaHWSeqReset(hwp, TRUE);
+ MGAWAITVSYNC();
+ MGAWAITBUSY();
+ hwp->writeSeq(hwp, 0x01, scrn);/* change mode */
+ usleep(20000);
+ vgaHWSeqReset(hwp, FALSE);
/*
* here we temporarily switch to 16 colour planar mode, to simply
@@ -66,36 +81,28 @@ MGAG200SERestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore)
hwp->writeGr(hwp, 0x01, 0x00); /* all planes come from CPU */
}
+ hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
+ hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
+ hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
+
if (hwp->FontInfo1) {
hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
slowbcopy_tobus(hwp->FontInfo1, hwp->Base, FONT_AMOUNT);
}
if (hwp->FontInfo2) {
hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
slowbcopy_tobus(hwp->FontInfo2, hwp->Base, FONT_AMOUNT);
}
if (hwp->TextInfo) {
hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
slowbcopy_tobus(hwp->TextInfo, hwp->Base, TEXT_AMOUNT);
hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
slowbcopy_tobus((unsigned char *)hwp->TextInfo + TEXT_AMOUNT,
hwp->Base, TEXT_AMOUNT);
}
@@ -113,7 +120,14 @@ MGAG200SERestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore)
hwp->writeSeq(hwp, 0x04, seq4);
hwp->IOBase = savedIOBase;
- vgaHWBlankScreen(scrninfp, TRUE);
+ scrn = hwp->readSeq(hwp, 0x01);
+ scrn &= ~0x20;/* enable screen */
+ vgaHWSeqReset(hwp, TRUE);
+ MGAWAITVSYNC();
+ MGAWAITBUSY();
+ hwp->writeSeq(hwp, 0x01, scrn);/* change mode */
+ usleep(20000);
+ vgaHWSeqReset(hwp, FALSE);
if (doMap)
vgaHWUnmapMem(scrninfp);
@@ -124,9 +138,11 @@ void
MGAG200SESaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save)
{
vgaHWPtr hwp = VGAHWPTR(scrninfp);
+ MGAPtr pMga = MGAPTR(scrninfp);
int savedIOBase;
unsigned char miscOut, attr10, gr4, gr5, gr6, seq2, seq4;
Bool doMap = FALSE;
+ unsigned char scrn;
if (hwp->Base == NULL) {
doMap = TRUE;
@@ -157,7 +173,14 @@ MGAG200SESaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save)
/* Force into colour mode */
hwp->writeMiscOut(hwp, miscOut | 0x01);
- vgaHWBlankScreen(scrninfp, FALSE);
+ scrn = hwp->readSeq(hwp, 0x01);
+ scrn |= 0x20;/* blank screen */
+ vgaHWSeqReset(hwp, TRUE);
+ MGAWAITVSYNC();
+ MGAWAITBUSY();
+ hwp->writeSeq(hwp, 0x01, scrn);/* change mode */
+ usleep(20000);
+ vgaHWSeqReset(hwp, FALSE);
/*
* get the character sets, and text screen if required
@@ -171,34 +194,25 @@ MGAG200SESaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save)
#if 0
hwp->writeAttr(hwp, 0x10, 0x01); /* graphics mode */
#endif
+ hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
+ hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
+ hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
if (hwp->FontInfo1 || (hwp->FontInfo1 = xalloc(FONT_AMOUNT))) {
hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
hwp->writeGr(hwp, 0x04, 0x02); /* read plane 2 */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
slowbcopy_frombus(hwp->Base, hwp->FontInfo1, FONT_AMOUNT);
}
if (hwp->FontInfo2 || (hwp->FontInfo2 = xalloc(FONT_AMOUNT))) {
hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
hwp->writeGr(hwp, 0x04, 0x03); /* read plane 3 */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
slowbcopy_frombus(hwp->Base, hwp->FontInfo2, FONT_AMOUNT);
}
if (hwp->TextInfo || (hwp->TextInfo = xalloc(2 * TEXT_AMOUNT))) {
hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
hwp->writeGr(hwp, 0x04, 0x00); /* read plane 0 */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
slowbcopy_frombus(hwp->Base, hwp->TextInfo, TEXT_AMOUNT);
hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
- hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
hwp->writeGr(hwp, 0x04, 0x01); /* read plane 1 */
- hwp->writeGr(hwp, 0x05, 0x00); /* write mode 0, read mode 0 */
- hwp->writeGr(hwp, 0x06, 0x05); /* set graphics */
slowbcopy_frombus(hwp->Base,
(unsigned char *)hwp->TextInfo + TEXT_AMOUNT, TEXT_AMOUNT);
}
@@ -213,8 +227,153 @@ MGAG200SESaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save)
hwp->writeMiscOut(hwp, miscOut);
hwp->IOBase = savedIOBase;
- vgaHWBlankScreen(scrninfp, TRUE);
+ scrn = hwp->readSeq(hwp, 0x01);
+ scrn &= ~0x20;/* enable screen */
+ vgaHWSeqReset(hwp, TRUE);
+ MGAWAITVSYNC();
+ MGAWAITBUSY();
+ hwp->writeSeq(hwp, 0x01, scrn);/* change mode */
+ usleep(20000);
+ vgaHWSeqReset(hwp, FALSE);
if (doMap)
vgaHWUnmapMem(scrninfp);
}
+
+void
+MGAG200SERestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore)
+{
+ vgaHWPtr hwp = VGAHWPTR(scrninfp);
+ MGAPtr pMga = MGAPTR(scrninfp);
+ int i;
+ unsigned char scrn;
+
+ if (restore->MiscOutReg & 0x01)
+ hwp->IOBase = VGA_IOBASE_COLOR;
+ else
+ hwp->IOBase = VGA_IOBASE_MONO;
+
+ hwp->writeMiscOut(hwp, restore->MiscOutReg);
+
+ for (i = 1; i < restore->numSequencer; i++)
+ {
+ MGAWAITVSYNC();
+ MGAWAITBUSY();
+ hwp->writeSeq(hwp, i, restore->Sequencer[i]);
+ usleep(20000);
+ }
+
+ scrn = hwp->readSeq(hwp, 0x01);
+ scrn |= 0x20;/* blank screen */
+ vgaHWSeqReset(hwp, TRUE);
+ MGAWAITVSYNC();
+ MGAWAITBUSY();
+ hwp->writeSeq(hwp, 0x01, scrn);/* change mode */
+ usleep(20000);
+
+ /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 of CRTC[17] */
+ hwp->writeCrtc(hwp, 17, restore->CRTC[17] & ~0x80);
+
+ for (i = 0; i < restore->numCRTC; i++)
+ hwp->writeCrtc(hwp, i, restore->CRTC[i]);
+
+ for (i = 0; i < restore->numGraphics; i++)
+ hwp->writeGr(hwp, i, restore->Graphics[i]);
+
+ hwp->enablePalette(hwp);
+
+ for (i = 0; i < restore->numAttribute; i++)
+ hwp->writeAttr(hwp, i, restore->Attribute[i]);
+
+ hwp->disablePalette(hwp);
+
+ MGAWAITVSYNC();
+ MGAWAITBUSY();
+ hwp->writeSeq(hwp, 1, restore->Sequencer[1]);
+ usleep(20000);
+}
+
+void
+MGAG200SESaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save)
+{
+ vgaHWPtr hwp = VGAHWPTR(scrninfp);
+ int i;
+
+ save->MiscOutReg = hwp->readMiscOut(hwp);
+
+ if (save->MiscOutReg & 0x01)
+ hwp->IOBase = VGA_IOBASE_COLOR;
+ else
+ hwp->IOBase = VGA_IOBASE_MONO;
+
+ for (i = 0; i < save->numCRTC; i++) {
+ save->CRTC[i] = hwp->readCrtc(hwp, i);
+#ifdef DEBUG
+ ErrorF("CRTC[0x%02x] = 0x%02x\n", i, save->CRTC[i]);
+#endif
+ }
+
+ hwp->enablePalette(hwp);
+
+ for (i = 0; i < save->numAttribute; i++) {
+ save->Attribute[i] = hwp->readAttr(hwp, i);
+#ifdef DEBUG
+ ErrorF("Attribute[0x%02x] = 0x%02x\n", i, save->Attribute[i]);
+#endif
+ }
+
+ hwp->disablePalette(hwp);
+
+ for (i = 0; i < save->numGraphics; i++) {
+ save->Graphics[i] = hwp->readGr(hwp, i);
+#ifdef DEBUG
+ ErrorF("Graphics[0x%02x] = 0x%02x\n", i, save->Graphics[i]);
+#endif
+ }
+
+ for (i = 1; i < save->numSequencer; i++) {
+ save->Sequencer[i] = hwp->readSeq(hwp, i);
+#ifdef DEBUG
+ ErrorF("Sequencer[0x%02x] = 0x%02x\n", i, save->Sequencer[i]);
+#endif
+ }
+}
+
+void
+MGAG200SEHWProtect(ScrnInfoPtr pScrn, Bool on)
+{
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+ MGAPtr pMga = MGAPTR(pScrn);
+
+ unsigned char tmp;
+
+ if (pScrn->vtSema) {
+ if (on) {
+ /*
+ * Turn off screen and disable sequencer.
+ */
+ tmp = hwp->readSeq(hwp, 0x01);
+
+ vgaHWSeqReset(hwp, TRUE); /* start synchronous reset */
+ MGAWAITVSYNC();
+ MGAWAITBUSY();
+ hwp->writeSeq(hwp, 0x01, tmp | 0x20); /* disable the display */
+ usleep(20000);
+ hwp->enablePalette(hwp);
+ } else {
+ /*
+ * Reenable sequencer, then turn on screen.
+ */
+
+ tmp = hwp->readSeq(hwp, 0x01);
+
+ MGAWAITVSYNC();
+ MGAWAITBUSY();
+ hwp->writeSeq(hwp, 0x01, tmp & ~0x20); /* reenable display */
+ usleep(20000);
+ vgaHWSeqReset(hwp, FALSE); /* clear synchronousreset */
+
+ hwp->disablePalette(hwp);
+ }
+ }
+}
diff --git a/util/stormdwg.c b/util/stormdwg.c
index 8f04e0e..99f76cc 100644
--- a/util/stormdwg.c
+++ b/util/stormdwg.c
@@ -7,7 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
-char *opcodes[] = {
+const char *opcodes[] = {
"line_open", /* 0000 */
"autoline_open", /* 0001 */
"line_close", /* 0010 */
@@ -29,7 +29,7 @@ char *opcodes[] = {
"iload filter" /* 1111 */
};
-char *atype[] = {
+const char *atype[] = {
"rpl - Write (Replace)", /* 000 */
"rstr - read-modify-write (raster)", /* 001 */
"reserved", /* 010 */
@@ -40,7 +40,7 @@ char *atype[] = {
"I - Gouraud (with depth compare)" /* 111 */
};
-char *zmode[] = {
+const char *zmode[] = {
"NOZCMP - always", /* 000 */
"reserved", /* 001 */
"ZE - depth =", /* 010 */
@@ -51,7 +51,7 @@ char *zmode[] = {
"zgte" /* 111 */
};
-char *bop[] = {
+const char *bop[] = {
"0", /* 0000 */
"~(D|S)", /* 0001 */
"D & ~S", /* 0010 */
@@ -73,7 +73,7 @@ char *bop[] = {
"1" /* 1111 */
};
-char *bitmod[] = {
+const char *bitmod[] = {
"BMONOLEF - Source is mono, or if iload, source is little endian", /* 0000 */
"BPLAN - source is mono from one plane", /* 0001 */
"BFCOL - source is colour, and is formatted from host", /* 0010 */