[PATCH] Delete support for MGA's proprietary HAL: unifdef USEMGAHAL.
Jamey Sharp
jamey at minilop.net
Thu Sep 15 08:42:02 PDT 2011
This patch produced with:
for f in `git grep -Fwl USEMGAHAL`; do
unifdef -B -UUSEMGAHAL $f | sponge $f
done
Adam Jackson wrote:
Hey, so, remember back in the dark ages when dualhead was this
insanely wild differentiating feature? Matrox thought it was so
special, in fact, that they hid most of the implementation of it
(and a bunch of other stuff) in a binary-only blob called the
HALlib. As you'd expect it was pretty much a cut-and-paste of
the relevant Windows code, and then some open glue to keep it
working; clientlx.c is that glue.
I guess the theory was that if you don't tell people which
registers to duplicate to implement a second pipe in their own
hardware, they won't figure it out? A pretty eyeroll-worthy
idea even at the time, and definitely not something we should be
condoning anymore.
Kill it with fire, but while you're at it, untangle the hideous
mess of MGA_HAL() macros too.
Signed-off-by: Jamey Sharp <jamey at minilop.net>
Cc: Adam Jackson <ajax at redhat.com>
---
So, like this? I've left the MGA_NOT_HAL macros alone because there's
only so much I can take. ;-)
src/mga.h | 38 ---
src/mga_dacG.c | 48 ----
src/mga_driver.c | 604 ------------------------------------------
src/mga_esc.c | 778 ------------------------------------------------------
src/mga_macros.h | 11 -
src/mga_merge.c | 37 ---
6 files changed, 0 insertions(+), 1516 deletions(-)
diff --git a/src/mga.h b/src/mga.h
index c520e86..fced6aa 100644
--- a/src/mga.h
+++ b/src/mga.h
@@ -42,10 +42,6 @@
#include "mga_dri.h"
#endif
-#ifdef USEMGAHAL
-#include "client.h"
-#endif
-
typedef enum {
OPTION_SW_CURSOR,
OPTION_HW_CURSOR,
@@ -329,11 +325,6 @@ typedef enum {
typedef struct {
int lastInstance;
-#ifdef USEMGAHAL
- LPCLIENTDATA pClientStruct;
- LPBOARDHANDLE pBoard;
- LPMGAHWINFO pMgaHwInfo;
-#endif
int refCount;
CARD32 masterFbAddress;
long masterFbMapSize;
@@ -459,12 +450,6 @@ struct mga_device_attributes {
};
typedef struct {
-#ifdef USEMGAHAL
- LPCLIENTDATA pClientStruct;
- LPBOARDHANDLE pBoard;
- LPMGAMODEINFO pMgaModeInfo;
- LPMGAHWINFO pMgaHwInfo;
-#endif
EntityInfoPtr pEnt;
struct mga_bios_values bios;
CARD8 BiosOutputMode;
@@ -650,9 +635,6 @@ typedef struct {
MGAPaletteInfo palinfo[256]; /* G400 hardware bug workaround */
FBLinearPtr LinearScratch;
Bool softbooted;
-#ifdef USEMGAHAL
- Bool HALLoaded;
-#endif
OptionInfoPtr Options;
/* Exa */
@@ -810,26 +792,6 @@ void MGAG200SESaveMode(ScrnInfoPtr, vgaRegPtr);
void MGAG200SERestoreMode(ScrnInfoPtr, vgaRegPtr);
void MGAG200SEHWProtect(ScrnInfoPtr, Bool);
-#ifdef USEMGAHAL
-/************ ESC Call Definition ***************/
-typedef struct {
- char *function;
- void (*funcptr)(ScrnInfoPtr pScrn, unsigned long *param, char *out, DisplayModePtr pMode);
-} MGAEscFuncRec, *MGAEscFuncPtr;
-
-typedef struct {
- char function[32];
- unsigned long parameters[32];
-} EscCmdStruct;
-
-extern LPMGAMODEINFO pMgaModeInfo[2];
-extern MGAMODEINFO TmpMgaModeInfo[2];
-
-extern void MGAExecuteEscCmd(ScrnInfoPtr pScrn, char *cmdline , char *sResult, DisplayModePtr pMode);
-void MGAFillDisplayModeStruct(DisplayModePtr pMode, LPMGAMODEINFO pModeInfo);
-/************************************************/
-#endif
-
static __inline__ void
MGA_MARK_SYNC(MGAPtr pMga, ScrnInfoPtr pScrn)
{
diff --git a/src/mga_dacG.c b/src/mga_dacG.c
index fca1031..b489dea 100644
--- a/src/mga_dacG.c
+++ b/src/mga_dacG.c
@@ -1001,9 +1001,6 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
break;
case PCI_CHIP_MGAG400:
case PCI_CHIP_MGAG550:
-#ifdef USEMGAHAL
- MGA_HAL(break;);
-#endif
if (MGAISGx50(pMga))
break;
@@ -1046,9 +1043,6 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
break;
case PCI_CHIP_MGAG200_SE_A_PCI:
case PCI_CHIP_MGAG200_SE_B_PCI:
-#ifdef USEMGAHAL
- MGA_HAL(break;);
-#endif
pReg->DacRegs[ MGA1064_VREF_CTL ] = 0x03;
pReg->DacRegs[MGA1064_PIX_CLK_CTL] =
MGA1064_PIX_CLK_CTL_SEL_PLL;
@@ -1097,9 +1091,6 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
case PCI_CHIP_MGAG200:
case PCI_CHIP_MGAG200_PCI:
default:
-#ifdef USEMGAHAL
- MGA_HAL(break;);
-#endif
if(pMga->OverclockMem) {
/* 143 Mhz */
pReg->DacRegs[ MGA1064_SYS_PLL_M ] = 0x06;
@@ -1496,21 +1487,6 @@ MGA_NOT_HAL(
MGAG200EHPIXPLLSET(pScrn, mgaReg);
}
); /* MGA_NOT_HAL */
-#ifdef USEMGAHAL
- /*
- * Work around another bug in HALlib: it doesn't restore the
- * DAC width register correctly. MATROX: hint, hint.
- */
- MGA_HAL(
- outMGAdac(MGA1064_MUL_CTL,mgaReg->DacRegs[0]);
- outMGAdac(MGA1064_MISC_CTL,mgaReg->DacRegs[1]);
- if (!MGAISGx50(pMga)) {
- outMGAdac(MGA1064_PIX_PLLC_M,mgaReg->DacRegs[2]);
- outMGAdac(MGA1064_PIX_PLLC_N,mgaReg->DacRegs[3]);
- outMGAdac(MGA1064_PIX_PLLC_P,mgaReg->DacRegs[4]);
- }
- );
-#endif
/* restore CRTCEXT regs */
for (i = 0; i < 6; i++)
OUTREG16(MGAREG_CRTCEXT_INDEX, (mgaReg->ExtVga[i] << 8) | i);
@@ -1650,24 +1626,6 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
* DAC width register correctly.
*/
-#ifdef USEMGAHAL
- /*
- * Work around another bug in HALlib: it doesn't restore the
- * DAC width register correctly (s.o.). MATROX: hint, hint.
- */
- MGA_HAL(
- if (mgaReg->DacRegs == NULL) {
- mgaReg->DacRegs = xnfcalloc(MGAISGx50(pMga) ? 2 : 5, 1);
- }
- mgaReg->DacRegs[0] = inMGAdac(MGA1064_MUL_CTL);
- mgaReg->DacRegs[1] = inMGAdac(MGA1064_MISC_CTL);
- if (!MGAISGx50(pMga)) {
- mgaReg->DacRegs[2] = inMGAdac(MGA1064_PIX_PLLC_M);
- mgaReg->DacRegs[3] = inMGAdac(MGA1064_PIX_PLLC_N);
- mgaReg->DacRegs[4] = inMGAdac(MGA1064_PIX_PLLC_P);
- }
- );
-#endif
MGA_NOT_HAL(
/*
* The port I/O code necessary to read in the extended registers.
@@ -1793,12 +1751,6 @@ MGAGSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
x += 64;
y += 64;
-#ifdef USEMGAHAL
- MGA_HAL(
- x += pMga->HALGranularityOffX;
- y += pMga->HALGranularityOffY;
- );
-#endif
/* cursor update must never occurs during a retrace period (pp 4-160) */
while( INREG( MGAREG_Status ) & 0x08 );
diff --git a/src/mga_driver.c b/src/mga_driver.c
index b140013..0289488 100644
--- a/src/mga_driver.c
+++ b/src/mga_driver.c
@@ -1509,10 +1509,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
int flags24;
MGAEntPtr pMgaEnt = NULL;
Bool Default;
-#ifdef USEMGAHAL
- ULONG status;
- CARD8 MiscCtlReg;
-#endif
/*
* Note: This function is only called once at server startup, and
@@ -1657,37 +1653,9 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMga->is_G200EH = (pMga->Chipset == PCI_CHIP_MGAG200_EH_PCI);
pMga->is_G200ER = (pMga->Chipset == PCI_CHIP_MGAG200_ER_PCI);
-#ifdef USEMGAHAL
- if (pMga->chip_attribs->HAL_chipset) {
- Bool loadHal = TRUE;
-
- from = X_DEFAULT;
- if (xf86FindOption(pMga->device->options, "NoHal")) {
- loadHal = !xf86SetBoolOption(pMga->device->options,
- "NoHal", !loadHal);
- from = X_CONFIG;
- } else if (xf86FindOption(pMga->device->options, "Hal")) {
- loadHal = xf86SetBoolOption(pMga->device->options,
- "Hal", loadHal);
- from = X_CONFIG;
- }
- if (loadHal && xf86LoadSubModule(pScrn, "mga_hal")) {
- xf86DrvMsg(pScrn->scrnIndex, from,"Matrox HAL module used\n");
- pMga->HALLoaded = TRUE;
- } else {
- xf86DrvMsg(pScrn->scrnIndex, from, "Matrox HAL module not loaded "
- "- using builtin mode setup instead\n");
- pMga->HALLoaded = FALSE;
- }
- }
-#endif
-
pMga->DualHeadEnabled = FALSE;
if (xf86IsEntityShared(pScrn->entityList[0])) {/* dual-head mode requested*/
if (
-#ifdef USEMGAHAL
- pMga->HALLoaded ||
-#endif
!MGA_DH_NEEDS_HAL(pMga)) {
pMga->DualHeadEnabled = TRUE;
} else if (xf86IsPrimInitDone(pScrn->entityList[0])) {
@@ -2088,30 +2056,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"\"Merged Framebuffer\" mode only supported on G450 and G550 boards.\n");
} else {
-#ifdef USEMGAHAL
- if(pMga->HALLoaded)
- {
- pMga->MergedFB = TRUE;
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
- "Using \"Merged Framebuffer\" mode.\n");
- /*
- * a few options that won't work well together
- */
- if(pMga->HWCursor) /*Should we give the choice? */
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- " -- Hardware Cursor disabled.\n");
- pMga->HWCursor = FALSE;
- if(pMga->ShadowFB)
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- " -- Shadow Framebuffer disabled.\n");
- pMga->ShadowFB = FALSE;
- if(pMga->FBDev)
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- " -- Framebuffer device disabled.\n");
- pMga->FBDev = FALSE;
- } /* MGA_HAL */
- else
-#endif
{
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"HALLib not loaded! NOT using \"Merged Framebuffer\" mode.\n");
@@ -2404,10 +2348,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
clockRanges->clockIndex = -1; /* programmable */
clockRanges->interlaceAllowed = TRUE;
clockRanges->doubleScanAllowed = TRUE;
-#ifdef USEMGAHAL
- MGA_HAL(clockRanges->interlaceAllowed = FALSE);
- MGA_HAL(clockRanges->doubleScanAllowed = FALSE);
-#endif
if (pMga->SecondCrtc == TRUE)
clockRanges->interlaceAllowed = FALSE;
@@ -2513,80 +2453,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
MGAFreeRec(pScrn);
return FALSE;
}
-#ifdef USEMGAHAL
- MGA_HAL(
-
- if(pMga->SecondCrtc == FALSE) {
-
- pMga->pBoard = xalloc(sizeof(CLIENTDATA) + MGAGetBOARDHANDLESize());
- pMga->pClientStruct = xalloc(sizeof(CLIENTDATA));
- pMga->pClientStruct->pMga = (MGAPtr) pMga;
-
- MGAMapMem(pScrn);
- /*
- * For some reason the MGAOPM_DMA_BLIT bit needs to be set
- * on G200 before opening the HALlib. I don't know why.
- * MATROX: hint, hint.
- */
- /*if (pMga->Chipset == PCI_CHIP_MGAG200 ||
- pMga->Chipset == PCI_CHIP_MGAG200_PCI) */{
- CARD32 opmode;
- opmode = INREG(MGAREG_OPMODE);
- OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT | opmode);
- }
- /* wrapping OpenLibrary to fix broken registers. MATROX: hint, hint. */
- MiscCtlReg = inMGAdac(MGA1064_MISC_CTL);
- MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA));
- outMGAdac(MGA1064_MISC_CTL,MiscCtlReg);
- MGAUnmapMem(pScrn);
- pMga->pMgaHwInfo = xalloc(sizeof(MGAHWINFO));
- MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo);
-
- /* copy the board handles */
- if (pMga->DualHeadEnabled) {
- pMgaEnt->pClientStruct = pMga->pClientStruct;
- pMgaEnt->pBoard = pMga->pBoard;
- pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo;
- }
-
- } else { /* Second CRTC && entity is shared */
- pMga->pBoard = pMgaEnt->pBoard;
- pMga->pClientStruct = pMgaEnt->pClientStruct;
- pMga->pMgaHwInfo = pMgaEnt->pMgaHwInfo;
-
- }
-
- MGAFillModeInfoStruct(pScrn,NULL);
- /* Fields usually handled by MGAFillModeInfoStruct, but are unavailable
- * because no mode is given
- */
- pMga->pMgaModeInfo->ulDispWidth = pScrn->virtualX;
- pMga->pMgaModeInfo->ulDispHeight = pScrn->virtualY;
-
-
- if (ISDIGITAL1(pMga))
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Digital screen detected on first head.\n");
- if (ISTV1(pMga))
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "TV detected on first head.\n");
- if (ISDIGITAL2(pMga))
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Digital screen detected on second head.\n");
- if (ISTV2(pMga))
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "TV detected on second head.\n");
-
-
- if((status = MGAValidateMode(pMga->pBoard,pMga->pMgaModeInfo)) != 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "MGAValidateMode from HALlib found the mode to be invalid.\n"
- "\tError: 0x%lx\n", status);
- return FALSE;
- }
- pScrn->displayWidth = pMga->pMgaModeInfo->ulFBPitch;
- ); /* MGA_HAL */
-#endif
/* If the Device section explicitly set HasSDRAM, don't bother checking.
*/
@@ -2620,9 +2486,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
* driver and if the driver doesn't provide code to set them. They
* are not pre-initialised at all.
*/
-#ifdef USEMGAHAL
- MGA_HAL(xf86SetCrtcForModes(pScrn, 0));
-#endif
MGA_NOT_HAL(xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V));
/* Set the current mode to the first in the list */
@@ -2790,46 +2653,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
};
-#ifdef USEMGAHAL
- MGA_HAL(
- /* Close the library after preinit */
- /* This needs to only happen after this board has completed preinit
- * both times
- */
-
- if(pMga->DualHeadEnabled) {
- /* Entity is shared make sure refcount == 2 */
- /* If ref count is 2 then reset it to 0 */
- if(pMgaEnt->refCount == 2) {
- /* Both boards have done there initialization */
- MGACloseLibrary(pMga->pBoard);
-
- if (pMga->pBoard)
- xfree(pMga->pBoard);
- if (pMga->pClientStruct)
- xfree(pMga->pClientStruct);
- if (pMga->pMgaModeInfo)
- xfree(pMga->pMgaModeInfo);
- if (pMga->pMgaHwInfo)
- xfree(pMga->pMgaHwInfo);
- pMgaEnt->refCount = 0;
- }
- } else {
- MGACloseLibrary(pMga->pBoard);
-
- if (pMga->pBoard)
- xfree(pMga->pBoard);
- if (pMga->pClientStruct)
- xfree(pMga->pClientStruct);
- if (pMga->pMgaModeInfo)
- xfree(pMga->pMgaModeInfo);
- if (pMga->pMgaHwInfo)
- xfree(pMga->pMgaHwInfo);
- }
-
- ); /* MGA_HAL */
-#endif
-
xf86SetPrimInitDone(pScrn->entityList[0]);
return TRUE;
@@ -2995,9 +2818,6 @@ MGASave(ScrnInfoPtr pScrn)
MGARegPtr mgaReg = &pMga->SavedReg;
if(pMga->SecondCrtc == TRUE) return;
-#ifdef USEMGAHAL
- MGA_HAL(if (pMga->pBoard != NULL) MGASaveVgaState(pMga->pBoard));
-#endif
/* I need to save the registers for the second head also */
/* Save the register for 0x80 to 0xa0 */
@@ -3007,135 +2827,6 @@ MGASave(ScrnInfoPtr pScrn)
(*pMga->Save)(pScrn, vgaReg, mgaReg, pMga->Primary);
}
-#ifdef USEMGAHAL
-/* Convert DisplayModeRec parameters in MGAMODEINFO parameters.
-* mode parameter optionnal. */
-void
-MGAFillModeInfoStruct(ScrnInfoPtr pScrn, DisplayModePtr mode)
-{
- const char *s;
- MGAPtr pMga = MGAPTR(pScrn);
-
- Bool digital1 = FALSE;
- Bool digital2 = FALSE;
- Bool tv1 = FALSE;
- Bool tv2 = FALSE;
- Bool swap_head
- = xf86ReturnOptValBool(pMga->Options, OPTION_SWAPPED_HEAD, FALSE);
-
- if(pMga->MergedFB && mode && mode->Private && (mode->PrivSize == 0)) {
- mode = pMga->SecondCrtc ?
- ((MergedDisplayModePtr)mode->Private)->Monitor2
- : ((MergedDisplayModePtr)mode->Private)->Monitor1;
- }
-
-
- if (pMga->pMgaHwInfo)
- {
- digital1 = ISDIGITAL1(pMga);
- digital2 = ISDIGITAL2(pMga);
- tv1 = ISTV1(pMga);
- tv2 = ISTV2(pMga);
- }
-
- /*FIXME: causes segfault elsewhere if not commented*/
- /*if(!pMga->pMgaModeInfo)*/ pMga->pMgaModeInfo = xalloc(sizeof(MGAMODEINFO));
- pMga->pMgaModeInfo->flOutput = 0;
- pMga->pMgaModeInfo->ulDeskWidth = pScrn->virtualX;
- pMga->pMgaModeInfo->ulDeskHeight = pScrn->virtualY;
- pMga->pMgaModeInfo->ulFBPitch = 0;
- pMga->pMgaModeInfo->ulBpp = pScrn->bitsPerPixel;
- pMga->pMgaModeInfo->ulZoom = 1;
- pMga->pMgaModeInfo->flSignalMode = 0x10;
-
- /* Set TV standard */
- if ((s = xf86GetOptValString(pMga->Options, OPTION_TVSTANDARD))) {
- if (!xf86NameCmp(s, "PAL")) {
- pMga->pMgaModeInfo->flSignalMode = 0x00;
- pMga->pMgaModeInfo->ulRefreshRate = 50;
- pMga->pMgaModeInfo->ulTVStandard = TV_PAL;
- } else {
- pMga->pMgaModeInfo->ulRefreshRate = 60;
- pMga->pMgaModeInfo->ulTVStandard = TV_NTSC;
- }
- } else {
- pMga->pMgaModeInfo->ulRefreshRate = 0;
- pMga->pMgaModeInfo->ulTVStandard = TV_NTSC;
- }
-
- /* Set Cable Type */
- if ((s = xf86GetOptValString(pMga->Options, OPTION_CABLETYPE))) {
- if (!xf86NameCmp(s, "SCART_RGB")) {
- pMga->pMgaModeInfo->ulCableType = TV_SCART_RGB;
- } else if (!xf86NameCmp(s, "SCART_COMPOSITE")) {
- pMga->pMgaModeInfo->ulCableType = TV_SCART_COMPOSITE;
- } else if (!xf86NameCmp(s, "SCART_TYPE2")) {
- pMga->pMgaModeInfo->ulCableType = TV_SCART_TYPE2;
- } else {
- pMga->pMgaModeInfo->ulCableType = TV_YC_COMPOSITE;
- }
- } else {
- pMga->pMgaModeInfo->ulCableType = TV_YC_COMPOSITE;
- }
-
- if(mode) {
- pMga->pMgaModeInfo->ulHorizRate = 0;
- pMga->pMgaModeInfo->ulDispWidth = mode->HDisplay;
- pMga->pMgaModeInfo->ulDispHeight = mode->VDisplay;
- pMga->pMgaModeInfo->ulPixClock = mode->Clock;
- pMga->pMgaModeInfo->ulHFPorch = mode->HSyncStart - mode->HDisplay;
- pMga->pMgaModeInfo->ulHSync = mode->HSyncEnd - mode->HSyncStart;
- pMga->pMgaModeInfo->ulHBPorch = mode->HTotal - mode->HSyncEnd;
- pMga->pMgaModeInfo->ulVFPorch = mode->VSyncStart - mode->VDisplay;
- pMga->pMgaModeInfo->ulVSync = mode->VSyncEnd - mode->VSyncStart;
- pMga->pMgaModeInfo->ulVBPorch = mode->VTotal - mode->VSyncEnd;
- }
- /* Use DstOrg directly */
- /* This is an offset in pixels not memory */
- pMga->pMgaModeInfo->ulDstOrg = pMga->DstOrg / (pScrn->bitsPerPixel / 8);
- pMga->pMgaModeInfo->ulDisplayOrg = pMga->DstOrg / (pScrn->bitsPerPixel / 8);
- pMga->pMgaModeInfo->ulPanXGran = 0;
- pMga->pMgaModeInfo->ulPanYGran = 0;
-
- if(pMga->SecondCrtc == TRUE) {
- pMga->pMgaModeInfo->flOutput = MGAMODEINFO_SECOND_CRTC |
- MGAMODEINFO_FORCE_PITCH |
- MGAMODEINFO_FORCE_DISPLAYORG;
- if (digital2) {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_DIGITAL2;
- } else if (tv2) {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_TV;
- } else {
- if (!swap_head) {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_ANALOG2;
- } else {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_ANALOG1;
- }
- }
- } else {
- pMga->pMgaModeInfo->flOutput = MGAMODEINFO_FORCE_PITCH;
- if (digital1) {
- if ((pMga->Chipset == PCI_CHIP_MGAG200) ||
- (pMga->Chipset == PCI_CHIP_MGAG200_PCI)) {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_FLATPANEL1;
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_DIGITAL2;
- } else {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_DIGITAL1;
- }
- } else if (tv1) {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_TV;
- } else {
- if (!swap_head) {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_ANALOG1;
- } else {
- pMga->pMgaModeInfo->flOutput |= MGAMODEINFO_ANALOG2;
- }
- }
- }
- pMga->pMgaModeInfo->ulFBPitch = pScrn->displayWidth;
-}
-#endif
-
/*
* Initialise a new mode. This is currently still using the old
* "initialise struct, restore/write struct to HW" model. That could
@@ -3150,9 +2841,6 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
MGAPtr pMga = MGAPTR(pScrn);
MGARegPtr mgaReg;
-#ifdef USEMGAHAL
- ULONG status;
-#endif
vgaHWUnlock(hwp);
/* if(pMga->MergedFB && mode && mode->Private && (mode->PrivSize == 0)) {
@@ -3175,56 +2863,6 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
}
vgaReg = &hwp->ModeReg;
mgaReg = &pMga->ModeReg;
-#ifdef USEMGAHAL
- MGA_HAL(
- MGAFillModeInfoStruct(pScrn,mode);
-
- /* Validate the parameters */
- if ((status = MGAValidateMode(pMga->pBoard, pMga->pMgaModeInfo)) != 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "MGAValidateMode from HALlib found the mode to be invalid.\n"
- "\tError: %lx\n", status);
- return FALSE;
- }
-
- /*
- * Find mode for second head.
- */
- if(pMga->MergedFB) {
-
- MGAFillModeInfoStruct(pMga->pScrn2,mode);
- /* Validates the Video parameters */
- if ((status = MGAValidateVideoParameters(pMga->pBoard, MGAPTR(pMga->pScrn2)->pMgaModeInfo))
- != 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "MGAValidateVideoParameters from HALlib found the mode to be invalid.\n\tError: %lx\n", status);
- return FALSE;
- }
- }
- ); /*MGA_HAL */
-
-#endif
-
-#ifdef USEMGAHAL
-MGA_HAL(
-
- /*************************** ESC *****************************/
- TmpMgaModeInfo[0] = *pMga->pMgaModeInfo;
-
- if(pMga->SecondCrtc == TRUE)
- pMgaModeInfo[1] = pMga->pMgaModeInfo;
- else
- pMgaModeInfo[0] = pMga->pMgaModeInfo;
-
- TmpMgaModeInfo[0].ulDispWidth = 0;
-
- if(!pMga->MergedFB) /* FIXME: Must deal with this once PowerDesk & MergedFB
- compatibility will exist */
- MGAFillDisplayModeStruct(mode, pMga->pMgaModeInfo);
- /*************************************************************/
-
-); /* MGA_HAL */
-#endif
#ifdef XF86DRI
if (pMga->directRenderingEnabled) {
@@ -3232,38 +2870,6 @@ MGA_HAL(
}
#endif
-#ifdef USEMGAHAL
- MGA_HAL(
- /* Initialize the board */
- if(MGASetMode(pMga->pBoard,pMga->pMgaModeInfo) != 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "MGASetMode returned an error."
- " Make sure to validate the mode before.\n");
- return FALSE;
- }
- if(pMga->MergedFB
- && MGASetMode(pMga->pBoard,MGAPTR(pMga->pScrn2)->pMgaModeInfo) != 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "MGASetMode returned an error."
- " Make sure to validate the mode before.\n");
- }
-
- ); /* MGA_HAL */
-
- /* getting around bugs in the HAL lib. MATROX: hint, hint. */
- MGA_HAL(
- if (pMga->chip_attribs->hwcursor_1064) {
- if(pMga->SecondCrtc == FALSE && pMga->HWCursor == TRUE) {
- outMGAdac(MGA1064_CURSOR_BASE_ADR_LOW,
- pMga->FbCursorOffset >> 10);
- outMGAdac(MGA1064_CURSOR_BASE_ADR_HI,
- pMga->FbCursorOffset >> 18);
- outMGAdac(MGA1064_CURSOR_CTL, 0x00);
- }
- }
- ); /* MGA_HAL */
-#endif
-
MGA_NOT_HAL((*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE));
MGAStormSync(pScrn);
@@ -3450,14 +3056,6 @@ MGARestore(ScrnInfoPtr pScrn)
vgaHWProtect(pScrn, TRUE);
}
if (pMga->Primary) {
-#ifdef USEMGAHAL
- MGA_HAL(
- if(pMga->pBoard != NULL) {
- MGASetVgaMode(pMga->pBoard);
- MGARestoreVgaState(pMga->pBoard);
- }
- ); /* MGA_HAL */
-#endif
(*pMga->Restore)(pScrn, vgaReg, mgaReg, TRUE);
} else {
vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE);
@@ -3566,81 +3164,12 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pPriv = xf86GetEntityPrivate(pScrn->entityList[0], MGAEntityIndex);
pMgaEnt = pPriv->ptr;
pMgaEnt->refCount++;
-#ifdef USEMGAHAL
- MGA_HAL(
- if(pMgaEnt->refCount == 1) {
- CARD8 MiscCtlReg;
- pMga->pBoard = xalloc(sizeof(CLIENTDATA) + MGAGetBOARDHANDLESize());
- pMga->pClientStruct = xalloc(sizeof(CLIENTDATA));
- pMga->pClientStruct->pMga = (MGAPtr) pMga;
-
- /* wrapping OpenLibrary to fix broken registers. MATROX: hint,hint.*/
- MiscCtlReg = inMGAdac(MGA1064_MISC_CTL);
- MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA));
- outMGAdac(MGA1064_MISC_CTL,MiscCtlReg);
- pMga->pMgaHwInfo = xalloc(sizeof(MGAHWINFO));
- MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo);
-
- /* Detecting for type of display */
- if (pMga->pMgaHwInfo->ulCapsSecondOutput & MGAHWINFOCAPS_OUTPUT_TV) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "TV detected\n");
- }
- if (pMga->pMgaHwInfo->ulCapsFirstOutput &
- MGAHWINFOCAPS_OUTPUT_DIGITAL) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Digital Screen detected\n");
- }
- if (pMga->pMgaHwInfo->ulCapsSecondOutput &
- MGAHWINFOCAPS_OUTPUT_DIGITAL) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Digital Screen detected\n");
- }
-
- /* Now copy these to the entitystructure */
- pMgaEnt->pClientStruct = pMga->pClientStruct;
- pMgaEnt->pBoard = pMga->pBoard;
- pMgaEnt->pMgaHwInfo = pMga->pMgaHwInfo;
- } else { /* Ref count is 2 */
- pMga->pClientStruct = pMgaEnt->pClientStruct;
- pMga->pBoard = pMgaEnt->pBoard;
- pMga->pMgaHwInfo = pMgaEnt->pMgaHwInfo;
- }
- ); /* MGA_HAL */
-#endif
} else {
-#ifdef USEMGAHAL
- CARD8 MiscCtlReg;
-
- MGA_HAL(
- pMga->pBoard = xalloc(sizeof(CLIENTDATA) + MGAGetBOARDHANDLESize());
- pMga->pClientStruct = xalloc(sizeof(CLIENTDATA));
- pMga->pClientStruct->pMga = (MGAPtr) pMga;
-
- MiscCtlReg = inMGAdac(MGA1064_MISC_CTL);
- /* wrapping OpenLibrary to fix broken registers. MATROX: hint,hint.*/
- MGAOpenLibrary(pMga->pBoard,pMga->pClientStruct,sizeof(CLIENTDATA));
- outMGAdac(MGA1064_MISC_CTL,MiscCtlReg);
- pMga->pMgaHwInfo = xalloc(sizeof(MGAHWINFO));
- MGAGetHardwareInfo(pMga->pBoard,pMga->pMgaHwInfo);
- ); /* MGA_HAL */
-#endif
}
if (pMga->is_G200SE) {
pScrn->videoRam = VRTemp;
pMga->FbMapSize = FBTemp;
}
-#ifdef USEMGAHAL
- MGA_HAL(
- /* There is a problem in the HALlib: set soft reset bit */
- /* MATROX: hint, hint. */
- if (!pMga->Primary && !pMga->FBDev &&
- (SUBSYS_ID(pMga->PciInfo) == PCI_CARD_MILL_G200_SG)) {
- OUTREG(MGAREG_Reset, 1);
- usleep(200);
- OUTREG(MGAREG_Reset, 0);
- }
- ); /* MGA_HAL */
-#endif
/* Initialise the MMIO vgahw functions */
vgaHWSetMmioFuncs(hwp, pMga->IOBase, PORT_OFFSET);
@@ -3947,66 +3476,8 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
Bool
MGASwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
{
-#ifdef USEMGAHAL
- char sCmdIn[256];
- char sCmdOut[256];
- FILE* fdIn;
-# ifdef MATROX_WRITEBACK
- FILE* fdOut;
-# endif
-#endif
if (mode->Flags & 0x80000000) {
-#ifdef USEMGAHAL
-
-# ifdef MATROX_WRITEBACK
-# define MWB(x) { x; }
-# define MWB_COND(x) x
-# else
-# define MWB(x)
-# define MWB_COND(x) 1
-# endif
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-
- MGA_HAL(
- fdIn = fopen("/tmp/mgaDriverIn", "rt");
- MWB(fdOut = fopen("/tmp/mgaDriverOut", "wt"))
-
- if(fdIn && MWB_COND(fdOut))
- {
-
- fgets(sCmdIn, 255, fdIn);
-
- if(sCmdIn)
- {
-
- MGAExecuteEscCmd(xf86Screens[scrnIndex], sCmdIn, sCmdOut, mode);
-
- /* Remove file and close file descriptor */
- remove("/tmp/mgaDriverIn");
- fclose(fdIn);
- MWB(
- /* Write output data to output file for
- calling application */
- fputs(sCmdOut, fdOut);
- fclose(fdOut);
- )
- mode->Flags &= 0x7FFFFFFF;
- return TRUE;
- }
- else
- {
- mode->Flags &= 0x7FFFFFFF;
- return FALSE;
- }
- }
- else
- {
- mode->Flags &= 0x7FFFFFFF;
- return FALSE;
- }
- )
-#endif
return FALSE;
} else
return MGAModeInit(xf86Screens[scrnIndex], mode);
@@ -4018,28 +3489,6 @@ MGASwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
void
MGAAdjustGranularity(ScrnInfoPtr pScrn, int* x, int* y)
{
-#ifdef USEMGAHAL
- MGA_HAL(
- MGAPtr pMga = MGAPTR(pScrn);
- MGAPtr pMga2;
- int xg = 1;
- int yg = 1;
- if(pMga->pMgaModeInfo && pMga->pMgaModeInfo->ulPanXGran && pMga->pMgaModeInfo->ulPanYGran) {
- xg = pMga->pMgaModeInfo->ulPanXGran;
- yg = pMga->pMgaModeInfo->ulPanYGran;
- }
- if(pMga->pScrn2 && (pMga2 = MGAPTR(pMga->pScrn2)) ) {
-
- if(pMga2->pMgaModeInfo && pMga2->pMgaModeInfo->ulPanXGran && pMga2->pMgaModeInfo->ulPanYGran) {
- xg = max(xg,pMga2->pMgaModeInfo->ulPanXGran);
- yg = max(yg,pMga2->pMgaModeInfo->ulPanYGran);
- }
- }
- xg=16; /*ncoder: temporary */
- *x -= *x % xg;
- *y -= *y % yg;
- );
-#endif
}
@@ -4065,16 +3514,6 @@ MGAAdjustFrame(int scrnIndex, int x, int y, int flags)
/* wanted to improve panning granularity problems without risking
* compatibility issues. Existing code looked hardware dependent.
*/
-#ifdef USEMGAHAL
- MGA_HAL(
- pMga->HALGranularityOffX = x;
- pMga->HALGranularityOffY = y;
- MGAAdjustGranularity(pScrn,&x,&y);
- pMga->HALGranularityOffX = pMga->HALGranularityOffX - x;
- pMga->HALGranularityOffY = pMga->HALGranularityOffY - y;
- HALSetDisplayStart(pMga->pBoard,x,y,0);
- );
-#endif
MGA_NOT_HAL(
if(pMga->ShowCache && y && pScrn->vtSema)
y += pScrn->virtualY - 1;
@@ -4117,12 +3556,6 @@ MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags)
pScrn = xf86Screens[scrnIndex];
pMga = MGAPTR(pScrn);
pLayout = &pMga->CurrentLayout;
-#ifdef USEMGAHAL
- MGA_HAL(
- MGAAdjustGranularity(pScrn,&x,&y);
- HALSetDisplayStart(pMga->pBoard,x,y,1);
- );
-#endif
MGA_NOT_HAL(
if(pMga->ShowCache && y && pScrn->vtSema)
y += pScrn->virtualY - 1;
@@ -4236,9 +3669,6 @@ MGALeaveVT(int scrnIndex, int flags)
DRILock(pScreen, 0);
}
#endif
-#ifdef USEMGAHAL
- MGA_HAL( RESTORE_TEXTMODE_ON_DVI(pMga); );
-#endif
}
@@ -4258,9 +3688,6 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
MGAPtr pMga = MGAPTR(pScrn);
MGAEntPtr pMgaEnt = NULL;
-#ifdef USEMGAHAL
- MGA_HAL( RESTORE_TEXTMODE_ON_DVI(pMga); );
-#endif
if (pMga->MergedFB)
MGACloseScreenMerged(scrnIndex, pScreen);
@@ -4289,37 +3716,6 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
pMgaEnt->refCount--;
}
-#ifdef USEMGAHAL
- MGA_HAL(
- if(pMga->DualHeadEnabled) {
- if(pMgaEnt->refCount == 0) {
- /* Both boards have closed there screen */
- MGACloseLibrary(pMga->pBoard);
-
- if (pMga->pBoard)
- xfree(pMga->pBoard);
- if (pMga->pClientStruct)
- xfree(pMga->pClientStruct);
- if (pMga->pMgaModeInfo)
- xfree(pMga->pMgaModeInfo);
- if (pMga->pMgaHwInfo)
- xfree(pMga->pMgaHwInfo);
- }
- } else {
- MGACloseLibrary(pMga->pBoard);
-
- if (pMga->pBoard)
- xfree(pMga->pBoard);
- if (pMga->pClientStruct)
- xfree(pMga->pClientStruct);
- if (pMga->pMgaModeInfo)
- xfree(pMga->pMgaModeInfo);
- if (pMga->pMgaHwInfo)
- xfree(pMga->pMgaHwInfo);
- }
- ); /* MGA_HAL */
-#endif
-
#ifdef USE_XAA
if (pMga->AccelInfoRec)
XAADestroyInfoRec(pMga->AccelInfoRec);
diff --git a/src/mga_esc.c b/src/mga_esc.c
index e811712..41b734a 100644
--- a/src/mga_esc.c
+++ b/src/mga_esc.c
@@ -10,782 +10,4 @@
#include "config.h"
#endif
-#ifdef USEMGAHAL
-
-/* All drivers should typically include these */
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-/* All drivers need this */
-
-#include "compiler.h"
-
-/* Drivers for PCI hardware need this */
-#include "xf86PciInfo.h"
-
-/* Drivers that need to access the PCI config space directly need this */
-#include "xf86Pci.h"
-
-/* All drivers initialising the SW cursor need this */
-#include "mipointer.h"
-
-/* All drivers implementing backing store need this */
-#include "mibstore.h"
-
-#include "micmap.h"
-
-#include "xf86DDC.h"
-#include "vbe.h"
-
-#include "fb.h"
-#include "dixstruct.h"
-
-#include "mga_reg.h"
-#include "mga.h"
-#include "mga_macros.h"
-
-/* ESC */
-LPMGAMODEINFO pMgaModeInfo[2] = {NULL};
-MGAMODEINFO TmpMgaModeInfo[2] = {{0}};
-
-/* ESC Implementation */
-static void EscHLeft(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscHRight(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscVUp(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscVDown(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscHLarger(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscHSmaller(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscVTaller(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscVSmaller(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscRefresh(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscRestoreVidParm(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscRead(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscWrite(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscHal(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscTest(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-static void EscMerged(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode);
-
-static LPMGAMODEINFO GetModeInfoPtr(ULONG ulScreen);
-static void GetVideoParameterStr(LPMGAMODEINFO pModeInfo, char *sResult);
-static Bool convertNumber(unsigned long *pulNumber, char *sNumber);
-
-
-static MGAEscFuncRec FunctionTable[] = {
- {"hal", EscHal},
- {"test", EscTest},
- {"read", EscRead},
- {"write", EscWrite},
- {"left", EscHLeft},
- {"right", EscHRight},
- {"down", EscVDown},
- {"up", EscVUp},
- {"h+", EscHLarger},
- {"h-", EscHSmaller},
- {"v+", EscVTaller},
- {"v-", EscVSmaller},
- {"refresh", EscRefresh},
- {"undo", EscRestoreVidParm},
- {"merged", EscMerged},
- {NULL,NULL}
-};
-
-
-void MGAFillDisplayModeStruct(DisplayModePtr pMode, LPMGAMODEINFO pModeInfo)
-{
- pMode->Clock = pModeInfo->ulPixClock;
-
- pMode->HDisplay = pModeInfo->ulDispWidth;
- pMode->HSyncStart = pModeInfo->ulDispWidth
- + pModeInfo->ulHFPorch;
- pMode->HSyncEnd = pModeInfo->ulDispWidth
- + pModeInfo->ulHFPorch
- + pModeInfo->ulHSync;
- pMode->HTotal = pModeInfo->ulDispWidth
- + pModeInfo->ulHFPorch
- + pModeInfo->ulHSync
- + pModeInfo->ulHBPorch;
-
- pMode->VDisplay = pModeInfo->ulDispHeight;
- pMode->VSyncStart = pModeInfo->ulDispHeight
- + pModeInfo->ulVFPorch;
- pMode->VSyncEnd = pModeInfo->ulDispHeight
- + pModeInfo->ulVFPorch
- + pModeInfo->ulVSync;
- pMode->VTotal = pModeInfo->ulDispHeight
- + pModeInfo->ulVFPorch
- + pModeInfo->ulVSync
- + pModeInfo->ulVBPorch;
-
- pMode->VRefresh = pModeInfo->ulRefreshRate;
-}
-
-static LPMGAMODEINFO GetModeInfoPtr(ULONG ulScreen)
-{
-
- if ( !TmpMgaModeInfo[ulScreen].ulDispWidth )
- {
- TmpMgaModeInfo[ulScreen] = *pMgaModeInfo[ulScreen];
- }
-
- return &TmpMgaModeInfo[ulScreen];
-}
-
-
-static void GetVideoParameterStr(LPMGAMODEINFO pModeInfo, char *sResult)
-{
- sprintf(sResult, "%d %d %d %d %d %d %d %d %d %d %d",
- pModeInfo->ulDispWidth,
- pModeInfo->ulDispHeight,
- pModeInfo->ulBpp,
- pModeInfo->ulPixClock,
- pModeInfo->ulHFPorch,
- pModeInfo->ulHSync,
- pModeInfo->ulHBPorch,
- pModeInfo->ulVFPorch,
- pModeInfo->ulVSync,
- pModeInfo->ulVBPorch,
- pModeInfo->flSignalMode);
-}
-
-
-static float GetVRefresh(LPMGAMODEINFO pModeInfo)
-{
- ULONG ulHTotal;
- ULONG ulVTotal;
-
- ulHTotal =
- pModeInfo->ulDispWidth +
- pModeInfo->ulHFPorch +
- pModeInfo->ulHSync +
- pModeInfo->ulHBPorch;
-
- ulVTotal =
- pModeInfo->ulDispHeight +
- pModeInfo->ulVFPorch +
- pModeInfo->ulVSync +
- pModeInfo->ulVBPorch;
-
- return ((float)pModeInfo->ulPixClock * 1000.0) / (ulHTotal * ulVTotal);
-}
-
-static void EscHal(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode)
-{
- MGAPtr pMGA = MGAPTR(pScrn);
-
- if(pMGA->HALLoaded)
- strcpy(sResult, "YES");
- else
- strcpy(sResult, "NO");
-
-}
-
-static void EscTest(ScrnInfoPtr pScrn, unsigned long *param, char
-*sResult, DisplayModePtr pMode)
-{
- strcpy(sResult, "YES");
-}
-
-static void EscMerged(ScrnInfoPtr pScrn, unsigned long *param, char
-*sResult, DisplayModePtr pMode)
-{
- strcpy(sResult, "YES");
-}
-
-static void EscRead(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode)
-{
- MGAPtr pMga = MGAPTR(pScrn);
- ULONG ulSource, ulAddr, ulData;
- UCHAR ucIndex;
-
- if ( (param[0] & 0xffff) < 2 )
- {
- strcpy(sResult, "#error 1");
- return;
- }
-
-
- ulSource = param[1] >> 16;
- ulAddr = param[1] & 0xffff;
-
-
- switch( ulSource )
- {
- case 0:
- ulData = INREG(ulAddr);
- sprintf(sResult, "MGA[%04X] = 0x%08X", ulAddr, ulData);
- break;
- case 1:
- ucIndex = INREG8(0x3c00);
- OUTREG8(0x3c00, (UCHAR)ulAddr);
- ulData = (ULONG)INREG8(0x3c0a);
- OUTREG8(0x3c00, ucIndex);
- sprintf(sResult, "DAC[%02X] = 0x%02X", ulAddr, ulData);
- break;
- case 2:
- ucIndex = INREG8(0x1fd4);
- OUTREG8(0x1fd4, (UCHAR)ulAddr);
- ulData = (ULONG)INREG8(0x1fd5);
- OUTREG8(0x1fd4, ucIndex);
- sprintf(sResult, "CRTC[%02X] = 0x%02X", ulAddr, ulData);
- break;
- case 3:
- ucIndex = INREG8(0x1fde);
- OUTREG8(0x1fde, (UCHAR)ulAddr);
- ulData = (ULONG)INREG8(0x1fdf);
- OUTREG8(0x1fde, ucIndex);
- sprintf(sResult, "CRTCEXT[%02X] = 0x%02X", ulAddr, ulData);
- break;
- default:
- strcpy(sResult, "ERROR# 2");
- break;
- }
-}
-
-static void EscWrite(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode)
-{
- MGAPtr pMga = MGAPTR(pScrn);
- ULONG ulSource, ulAddr, ulData;
- UCHAR ucIndex;
-
- if ( (param[0] & 0xffff) < 3 )
- {
- strcpy(sResult, "#error 1");
- return;
- }
-
- ulSource = param[1] >> 16;
- ulAddr = param[1] & 0xffff;
- ulData = param[2];
-
-
- switch( ulSource )
- {
- case 0:
- OUTREG(ulAddr, ulData);
- strcpy(sResult, "OK");
- break;
- case 1:
- ucIndex = INREG8(0x3c00);
- OUTREG8(0x3c00, (UCHAR)ulAddr);
- OUTREG8(0x3c0a, (UCHAR)ulData);
- OUTREG8(0x3c00, ucIndex);
- strcpy(sResult, "OK");
- break;
- case 2:
- ucIndex = INREG8(0x1fd4);
- OUTREG8(0x1fd4, (UCHAR)ulAddr);
- OUTREG8(0x1fd5, (UCHAR)ulData);
- OUTREG8(0x1fd4, ucIndex);
- strcpy(sResult, "OK");
- break;
- case 3:
- ucIndex = INREG8(0x1fde);
- OUTREG8(0x1fde, (UCHAR)ulAddr);
- OUTREG8(0x1fdf, (UCHAR)ulData);
- OUTREG8(0x1fde, ucIndex);
- strcpy(sResult, "OK");
- break;
- default:
- strcpy(sResult, "ERROR# 2");
- break;
- }
-}
-
-static void EscHLeft(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode)
-{
- MGAPtr pMga = MGAPTR(pScrn);
- LPMGAMODEINFO pModeInfo;
-
- pModeInfo = GetModeInfoPtr(param[0] >> 16);
-
- if ( !pMgaModeInfo )
- {
- strcpy(sResult, "#error 1");
- return;
- }
-
-
- if (pModeInfo->ulHBPorch > (8 * param[1]) )
- {
- pModeInfo->ulHBPorch -=8 * param[1];
- pModeInfo->ulHFPorch +=8 * param[1];
- MGASetMode(pMga->pBoard, pModeInfo);
- }
-
- MGAFillDisplayModeStruct(pMode, pModeInfo);
-
- GetVideoParameterStr(pModeInfo, sResult);
-}
-
-
-static void EscHRight(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode)
-{
- MGAPtr pMga = MGAPTR(pScrn);
- LPMGAMODEINFO pModeInfo;
-
- pModeInfo = GetModeInfoPtr(param[0] >> 16);
-
- if ( !pMgaModeInfo )
- {
- strcpy(sResult, "#error 1");
- return;
- }
-
- if (pModeInfo->ulHFPorch > (8 * param[1]) )
- {
- pModeInfo->ulHFPorch -=8 * param[1];
- pModeInfo->ulHBPorch +=8 * param[1];
- MGASetMode(pMga->pBoard, pModeInfo);
- }
-
- MGAFillDisplayModeStruct(pMode, pModeInfo);
-
- GetVideoParameterStr(pModeInfo, sResult);
-}
-
-
-
-static void EscVUp(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode)
-{
- MGAPtr pMga = MGAPTR(pScrn);
- LPMGAMODEINFO pModeInfo;
-
- pModeInfo = GetModeInfoPtr(param[0] >> 16);
-
- if ( !pMgaModeInfo )
- {
- strcpy(sResult, "#error 1");
- return;
- }
-
- if (pModeInfo->ulVBPorch > (param[1]) )
- {
- pModeInfo->ulVBPorch -= param[1];
- pModeInfo->ulVFPorch += param[1];
- MGASetMode(pMga->pBoard, pModeInfo);
- }
-
- MGAFillDisplayModeStruct(pMode, pModeInfo);
-
- GetVideoParameterStr(pModeInfo, sResult);
-}
-
-
-static void EscVDown(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode)
-{
- MGAPtr pMga = MGAPTR(pScrn);
- LPMGAMODEINFO pModeInfo;
-
- pModeInfo = GetModeInfoPtr(param[0] >> 16);
-
- if ( !pMgaModeInfo )
- {
- strcpy(sResult, "#error 1");
- return;
- }
-
- if (pModeInfo->ulVFPorch >= (param[1]) )
- {
- pModeInfo->ulVFPorch -= param[1];
- pModeInfo->ulVBPorch += param[1];
- MGASetMode(pMga->pBoard, pModeInfo);
- }
-
- MGAFillDisplayModeStruct(pMode, pModeInfo);
-
- GetVideoParameterStr(pModeInfo, sResult);
-}
-
-
-static void EscHLarger(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode)
-{
- MGAPtr pMga = MGAPTR(pScrn);
- LPMGAMODEINFO pModeInfo;
- float fRefresh, fPixelClock;
- ULONG ulStep;
-
- pModeInfo = GetModeInfoPtr(param[0] >> 16);
-
- if ( !pMgaModeInfo )
- {
- strcpy(sResult, "#error 1");
- return;
- }
-
- if ((param[0] & 0xffff) > 1)
- {
-
- ulStep = param[1] * 8;
- }
- else
- {
-
- ulStep = 8;
- }
-
- fRefresh = GetVRefresh(pModeInfo);
- fPixelClock = (float)pModeInfo->ulPixClock;
- if (pModeInfo->ulHBPorch >= ulStep )
- {
- pModeInfo->ulHBPorch -= ulStep;
- }
- else
- {
- pModeInfo->ulHBPorch = 0;
- }
- pModeInfo->ulPixClock = (ULONG)( (fRefresh * fPixelClock) / GetVRefresh(pModeInfo));
- MGASetMode(pMga->pBoard, pModeInfo);
-
- MGAFillDisplayModeStruct(pMode, pModeInfo);
-
- GetVideoParameterStr(pModeInfo, sResult);
-}
-
-
-static void EscHSmaller(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode)
-{
- MGAPtr pMga = MGAPTR(pScrn);
- LPMGAMODEINFO pModeInfo;
- float fRefresh, fPixelClock;
- ULONG ulStep;
-
- pModeInfo = GetModeInfoPtr(param[0] >> 16);
-
- if ( !pMgaModeInfo )
- {
- strcpy(sResult, "#error 1");
- return;
- }
-
- if ((param[0] & 0xffff) > 1)
- {
-
- ulStep = param[1] * 8;
- }
- else
- {
-
- ulStep = 8;
- }
-
-
- fRefresh = GetVRefresh(pModeInfo);
- fPixelClock = (float)pModeInfo->ulPixClock;
- pModeInfo->ulHBPorch += ulStep;
- pModeInfo->ulPixClock = (ULONG)( (fRefresh * fPixelClock) / GetVRefresh(pModeInfo));
-
- MGASetMode(pMga->pBoard, pModeInfo);
-
- MGAFillDisplayModeStruct(pMode, pModeInfo);
-
- GetVideoParameterStr(pModeInfo, sResult);
-}
-
-static void EscVTaller(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode)
-{
- MGAPtr pMga = MGAPTR(pScrn);
- LPMGAMODEINFO pModeInfo;
- float fRefresh, fPixelClock;
- ULONG ulStep;
-
- pModeInfo = GetModeInfoPtr(param[0] >> 16);
-
- if ( !pMgaModeInfo )
- {
- strcpy(sResult, "#error 1");
- return;
- }
-
- if ((param[0] & 0xffff) > 1)
- {
-
- ulStep = param[1];
- }
- else
- {
-
- ulStep = 1;
- }
-
- fRefresh = GetVRefresh(pModeInfo);
- fPixelClock = (float)pModeInfo->ulPixClock;
-
- if (pModeInfo->ulVBPorch >= ulStep )
- {
- pModeInfo->ulVBPorch -= ulStep;
- }
- else
- {
- pModeInfo->ulVBPorch = 0;
- }
-
- pModeInfo->ulPixClock = (ULONG)( (fRefresh * fPixelClock) / GetVRefresh(pModeInfo));
- MGASetMode(pMga->pBoard, pModeInfo);
-
- MGAFillDisplayModeStruct(pMode, pModeInfo);
-
- GetVideoParameterStr(pModeInfo, sResult);
-}
-
-static void EscVSmaller(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode)
-{
- MGAPtr pMga = MGAPTR(pScrn);
- LPMGAMODEINFO pModeInfo;
- float fRefresh, fPixelClock;
- ULONG ulStep;
-
- pModeInfo = GetModeInfoPtr(param[0] >> 16);
-
- if ( !pMgaModeInfo )
- {
- strcpy(sResult, "#error 1");
- return;
- }
-
- if ((param[0] & 0xffff) > 1)
- {
-
- ulStep = param[1];
- }
- else
- {
-
- ulStep = 1;
- }
-
-
- fRefresh = GetVRefresh(pModeInfo);
- fPixelClock = (float)pModeInfo->ulPixClock;
- pModeInfo->ulVFPorch += ulStep;
- pModeInfo->ulPixClock = (ULONG)( (fRefresh * fPixelClock) / GetVRefresh(pModeInfo));
- MGASetMode(pMga->pBoard, pModeInfo);
-
- MGAFillDisplayModeStruct(pMode, pModeInfo);
-
- GetVideoParameterStr(pModeInfo, sResult);
-}
-
-
-static void EscRefresh(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode)
-{
- MGAPtr pMga = MGAPTR(pScrn);
- LPMGAMODEINFO pModeInfo;
- float fRefresh, fPixelClock;
-
- pModeInfo = GetModeInfoPtr(param[0] >> 16);
-
- if ( !pMgaModeInfo )
- {
- strcpy(sResult, "#error 1");
- return;
- }
-
- if ((param[0] & 0xffff) < 2)
- {
- strcpy(sResult, "#error 1");
- return;
- }
-
- fRefresh = GetVRefresh(pModeInfo);
-
- fPixelClock = (float)pModeInfo->ulPixClock;
- pModeInfo->ulPixClock = (ULONG)( ((float)param[1] * fPixelClock) / fRefresh);
-
- pModeInfo->ulRefreshRate = param[1];
-
- MGASetMode(pMga->pBoard, pModeInfo);
-
- MGAFillDisplayModeStruct(pMode, pModeInfo);
-
- GetVideoParameterStr(pModeInfo, sResult);
-}
-
-static void EscRestoreVidParm(ScrnInfoPtr pScrn, unsigned long *param, char *sResult, DisplayModePtr pMode)
-{
- MGAPtr pMga = MGAPTR(pScrn);
-
- TmpMgaModeInfo[param[0] >> 16].ulDispWidth = 0;
- MGASetMode(pMga->pBoard, pMgaModeInfo[param[0] >> 16]);
-
- MGAFillDisplayModeStruct(pMode, pMgaModeInfo[param[0] >> 16]);
-
- GetVideoParameterStr(pMgaModeInfo[param[0] >> 16], sResult);
-}
-
-static Bool convertNumber(unsigned long *pulNumber, char *sNumber)
-{
- unsigned long i, ulDigit, shiftHex;
- Bool bResult = TRUE;
-
- if (sNumber == NULL)
- {
- return FALSE;
- }
-
-
- /* Convert number */
- if ( (sNumber[0] == '0') && (sNumber[1] == 'x') )
- {
- shiftHex = 0;
- *pulNumber = 0;
-
- for (i = strlen(sNumber) - 1; i > 1; i--)
- {
- if (shiftHex > 28)
- {
- bResult = FALSE;
- break;
- }
-
- if ( !isxdigit(sNumber[i]) )
- {
- bResult = FALSE;
- break;
- }
-
- ulDigit = toupper(sNumber[i]) - '0';
- if (ulDigit > 9)
- {
- ulDigit -= 7;
- }
- *pulNumber += ulDigit << shiftHex;
- shiftHex += 4;
- }
- }
- else
- {
- for (i = 0; i < strlen(sNumber); i++)
- {
- if ( !isdigit(sNumber[i]) )
- {
- bResult = FALSE;
- break;
- }
- }
- *pulNumber = atoi(sNumber);
- }
-
- return bResult;
-}
-
-static Bool GetEscCommand(char *cmdline, EscCmdStruct *escCmd)
-{
- unsigned long i, paramIndex, ulHI;
- Bool bResult;
- char *pParameter, *function;
-
- bResult = TRUE; /* success */
-
- function = strtok(cmdline, " \t\n,");
-
-
- escCmd->parameters[0] = 0;
- if (function)
- {
- /* Find Screen */
- if (function[1] == ':' )
- {
- escCmd->parameters[0] = (unsigned long)(function[0] - '0') << 16;
- strncpy(escCmd->function, function+2, 32);
- }
- else
- {
- strncpy(escCmd->function, function, 32);
- }
-
- }
- else
- {
- strcpy(escCmd->function, "#ERROR -1");
- escCmd->parameters[0] = 0;
- return FALSE;
- }
-
- paramIndex = 1;
- while ( (pParameter = strtok(NULL, " \t\n,")) != NULL )
- {
- if (paramIndex > 31)
- {
- /* 32 parameters supported */
- break;
- }
-
- i = 0;
- while(pParameter[i] && pParameter[i] != ':')
- {
- i++;
- }
-
- if ( pParameter[i] )
- {
- pParameter[i] = '\0';
- bResult = convertNumber(&escCmd->parameters[paramIndex], &pParameter[i+1]);
- bResult |= convertNumber(&ulHI, pParameter);
- escCmd->parameters[paramIndex] &= 0xffff;
- escCmd->parameters[paramIndex] += ulHI << 16;
- pParameter[i] = ':';
- }
- else
- {
- bResult = convertNumber(&escCmd->parameters[paramIndex], pParameter);
- }
-
-
- if (!bResult)
- {
- break;
- }
- paramIndex++;
- }
-
- escCmd->parameters[0] += paramIndex;
- return bResult;
-
-}
-
-void MGAExecuteEscCmd(ScrnInfoPtr pScrn, char *cmdline , char *sResult, DisplayModePtr pMode)
-{
- int i = 0;
- int ulScreen = 0;
- MGAPtr pMga = MGAPTR(pScrn);
- EscCmdStruct EscCmd;
-
- if (pMga->SecondCrtc)
- {
- ulScreen = 1;
- }
- else
- {
- ulScreen = 0;
- }
-
-
- if (FunctionTable[0].function && GetEscCommand(cmdline, &EscCmd) )
- {
- i = 0;
-
- while ( FunctionTable[i].function && strcmp(FunctionTable[i].function, EscCmd.function) )
- {
- i++;
- }
-
- if (FunctionTable[i].function)
- {
- EscCmd.parameters[0] &= 0xffff;
- EscCmd.parameters[0] |= ulScreen << 16;
-
- FunctionTable[i].funcptr(pScrn, EscCmd.parameters, sResult, pMode);
- }
- else
- {
- strcpy(sResult, "error# -1");
- }
- }
- else
- {
- strcpy(sResult, "error# -1");
- }
-}
-#else
int mga_foo;
-#endif
diff --git a/src/mga_macros.h b/src/mga_macros.h
index bffd063..130651d 100644
--- a/src/mga_macros.h
+++ b/src/mga_macros.h
@@ -74,18 +74,7 @@ while(INREG(MGAREG_DWGSYNC) != MGA_SYNC_XTAG) ; \
#define CHECK_DMA_QUIESCENT(pMGA, pScrn)
#endif
-#ifdef USEMGAHAL
-#define MGA_HAL(x) { \
- MGAPtr pMga = MGAPTR(pScrn); \
- if (pMga->HALLoaded && pMga->chip_attribs->HAL_chipset) { x; } \
-}
-#define MGA_NOT_HAL(x) { \
- MGAPtr pMga = MGAPTR(pScrn); \
- if (!pMga->HALLoaded || !pMga->chip_attribs->HAL_chipset) { x; } \
-}
-#else
#define MGA_NOT_HAL(x) { x; }
-#endif
#define MGAISGx50(x) ((x)->is_Gx50)
diff --git a/src/mga_merge.c b/src/mga_merge.c
index 1fd0572..2affe3b 100644
--- a/src/mga_merge.c
+++ b/src/mga_merge.c
@@ -236,9 +236,6 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, int flags)
int i;
char* s;
ClockRangePtr clockRanges;
-#ifdef USEMGAHAL
- ULONG status;
-#endif
MgaScrn2Rel Monitor2Pos;
xf86DrvMsg(pScrn1->scrnIndex, X_INFO, "==== Start of second screen initialization ====\n");
@@ -252,9 +249,6 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, int flags)
}
pMga = MGAPTR(pScrn);
-#ifdef USEMGAHAL
- pMga->pMgaModeInfo = NULL; /*will be allocated later if NULL*/
-#endif
pMga1 = MGAPTR(pScrn1);
pMga1->pScrn2 = pScrn;
@@ -456,10 +450,6 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, int flags)
clockRanges->clockIndex = -1; /* programmable */
clockRanges->interlaceAllowed = TRUE;
clockRanges->doubleScanAllowed = TRUE;
-#ifdef USEMGAHAL
- MGA_HAL(clockRanges->interlaceAllowed = FALSE);
- MGA_HAL(clockRanges->doubleScanAllowed = FALSE);
-#endif
clockRanges->interlaceAllowed = FALSE; /*no interlace on CRTC2 */
clockRanges->ClockMulFactor = 1;
@@ -562,30 +552,6 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, int flags)
MGAFreeRec(pScrn);
return FALSE;
}
-#ifdef USEMGAHAL
- MGA_HAL(
-
- pMga->pBoard = pMga1->pBoard;
- pMga->pClientStruct = pMga1->pClientStruct;
- pMga->pMgaHwInfo = pMga1->pMgaHwInfo;
-
-
- MGAFillModeInfoStruct(pScrn,NULL);
- /* Fields usually handled by MGAFillModeInfoStruct, but are unavailable
- * because no mode is given
- */
- pMga->pMgaModeInfo->ulDispWidth = pScrn->virtualX;
- pMga->pMgaModeInfo->ulDispHeight = pScrn->virtualY;
-
- if((status = MGAValidateMode(pMga->pBoard,pMga->pMgaModeInfo)) != 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "MGAValidateMode from HALlib found the mode to be invalid.\n"
- "\tError: 0x%lx\n", status);
- return FALSE;
- }
- pScrn->displayWidth = pMga->pMgaModeInfo->ulFBPitch;
- ); /* MGA_HAL */
-#endif
/*
* Set the CRTC parameters for all of the modes based on the type
@@ -595,9 +561,6 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, int flags)
* driver and if the driver doesn't provide code to set them. They
* are not pre-initialised at all.
*/
-#ifdef USEMGAHAL
- MGA_HAL(xf86SetCrtcForModes(pScrn, 0));
-#endif
MGA_NOT_HAL(xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V));
/* Set the current mode to the first in the list */
--
1.7.5.4
More information about the xorg-devel
mailing list