diff options
Diffstat (limited to 'src/mga_driver.c')
-rw-r--r-- | src/mga_driver.c | 779 |
1 files changed, 52 insertions, 727 deletions
diff --git a/src/mga_driver.c b/src/mga_driver.c index 258e146..6e88df5 100644 --- a/src/mga_driver.c +++ b/src/mga_driver.c @@ -225,7 +225,6 @@ static const OptionInfoRec MGAOptions[] = { { OPTION_TV, "TV", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_TVSTANDARD, "TVStandard", OPTV_ANYSTR, {0}, FALSE }, { OPTION_CABLETYPE, "CableType", OPTV_ANYSTR, {0}, FALSE }, - { OPTION_NOHAL, "NoHal", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_SWAPPED_HEAD, "SwappedHead", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_DRI, "DRI", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_MERGEDFB, "MergedFB", OPTV_BOOLEAN, {0}, FALSE }, @@ -413,22 +412,6 @@ static const char *fbdevHWSymbols[] = { NULL }; -#ifdef USEMGAHAL -static const char *halSymbols[] = { - "MGACloseLibrary", - "MGAGetBOARDHANDLESize", - "MGAGetHardwareInfo", - "MGAOpenLibrary", - "MGARestoreVgaState", - "MGASaveVgaState", - "MGASetMode", - "MGASetVgaMode", - "MGAValidateMode", - "MGAValidateVideoParameters", - "HALSetDisplayStart", - NULL -}; -#endif #ifdef XFree86LOADER static MODULESETUPPROTO(mgaSetup); @@ -483,9 +466,6 @@ mgaSetup(pointer module, pointer opts, int *errmaj, int *errmin) #ifdef XF86DRI drmSymbols, driSymbols, #endif -#ifdef USEMGAHAL - halSymbols, -#endif NULL); /* @@ -1142,10 +1122,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 @@ -1286,51 +1262,14 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) || (pMga->Chipset == PCI_CHIP_MGAG550); pMga->is_G200SE = (pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) || (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI); - pMga->is_HAL_chipset = ((pMga->Chipset == PCI_CHIP_MGAG200_PCI) || - (pMga->Chipset == PCI_CHIP_MGAG200) || - (pMga->Chipset == PCI_CHIP_MGAG200_SE_A_PCI) || - (pMga->Chipset == PCI_CHIP_MGAG200_SE_B_PCI) || - (pMga->Chipset == PCI_CHIP_MGAG400) || - (pMga->Chipset == PCI_CHIP_MGAG550)); - -#ifdef USEMGAHAL - if (HAL_CHIPSETS) { - 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")) { - xf86LoaderReqSymLists(halSymbols, NULL); - 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)) { + if (!MGA_DH_NEEDS_HAL(pMga)) { pMga->DualHeadEnabled = TRUE; } else if (xf86IsPrimInitDone(pScrn->entityList[0])) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "This card requires the \"mga_hal\" module for dual-head operation\n" - "\tIt can be found at the Matrox web site <http://www.matrox.com>\n"); + "Dual-head not supported for this card.\n"); } } @@ -1613,39 +1552,8 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) pMga->TexturedVideo = TRUE; } if (xf86ReturnOptValBool(pMga->Options, OPTION_MERGEDFB, FALSE)) { - if(!MGAISGx50(pMga)) { - 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"); - } /* MGA_NOT_HAL */ - } /* ISMGAGx50() */ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "\"Merged Framebuffer\" mode not supported.\n"); } if (pMga->FBDev) { /* check for linux framebuffer device */ @@ -2033,10 +1941,7 @@ 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; @@ -2135,80 +2040,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 (pMga->HasSDRAM) { /* don't bother checking */ } else if ((pMga->PciInfo->subsysCard == PCI_CARD_MILL_G200_SD) || @@ -2217,16 +2048,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) (pMga->PciInfo->subsysCard == PCI_CARD_PROD_G100_SD)) { pMga->HasSDRAM = TRUE; xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Has SDRAM\n"); - } - /* - * Can we trust HALlib to set the memory configuration - * registers correctly? - */ - else if ((pMga->softbooted || pMga->Primary -#ifdef USEMGAHAL - /*|| pMga->HALLoaded*/ -#endif - ) && + } else if ((pMga->softbooted || pMga->Primary) && (pMga->Chipset != PCI_CHIP_MGA2064) && (pMga->Chipset != PCI_CHIP_MGA2164) && (pMga->Chipset != PCI_CHIP_MGA2164_AGP)) { @@ -2245,10 +2067,7 @@ 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)); + xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V); /* Set the current mode to the first in the list */ pScrn->currentMode = pScrn->modes; @@ -2433,47 +2252,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) MGAPreInitMergedFB(pScrn,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; @@ -2614,9 +2392,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 */ @@ -2626,135 +2401,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 @@ -2769,9 +2415,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)) { @@ -2790,56 +2433,6 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) vgaHWProtect(pScrn, TRUE); 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) { @@ -2847,58 +2440,7 @@ 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( - switch (pMga->Chipset) { - case PCI_CHIP_MGA1064: - case PCI_CHIP_MGAG100: - case PCI_CHIP_MGAG100_PCI: - case PCI_CHIP_MGAG200: - case PCI_CHIP_MGAG200_PCI: - case PCI_CHIP_MGAG200_SE_A_PCI: - case PCI_CHIP_MGAG200_SE_B_PCI: - case PCI_CHIP_MGAG400: - case PCI_CHIP_MGAG550: - 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); - } - if (pMga->Overlay8Plus24 == TRUE) { - outMGAdac(MGA1064_MUL_CTL, MGA1064_MUL_CTL_32bits); - outMGAdac(MGA1064_COL_KEY_MSK_LSB,0xFF); - outMGAdac(MGA1064_COL_KEY_LSB,pMga->colorKey); - outMGAdac(MGA1064_COL_KEY_MSK_MSB,0xFF); - outMGAdac(MGA1064_COL_KEY_MSB,0xFF); - } - break; - default: - break; - } - ); /* MGA_HAL */ -#endif - - MGA_NOT_HAL((*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE)); + (*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE); MGAStormSync(pScrn); MGAStormEngineInit(pScrn); @@ -3010,14 +2552,6 @@ MGARestore(ScrnInfoPtr pScrn) /* Only restore text mode fonts/text for the primary card */ 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); @@ -3104,81 +2638,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 && - (pMga->PciInfo->subsysCard == 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); @@ -3537,101 +3002,11 @@ 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; + return FALSE; } else return MGAModeInit(xf86Screens[scrnIndex], mode); } - - /* Adjusts coordinates to match Panning granularity. - * does nothing if the HALlib is not loaded - */ -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 -} - /* * This function is used to initialize the Start Address - the first @@ -3652,45 +3027,34 @@ MGAAdjustFrame(int scrnIndex, int x, int y, int flags) pMga = MGAPTR(pScrn); pLayout = &pMga->CurrentLayout; - /* 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; - - Base = (y * pLayout->displayWidth + x + pMga->YDstOrg) >> - (3 - pMga->BppShifts[(pLayout->bitsPerPixel >> 3) - 1]); + /* wanted to improve panning granularity problems without risking + * compatibility issues. Existing code looked hardware dependent. + */ + if (pMga->ShowCache && y && pScrn->vtSema) + y += pScrn->virtualY - 1; + + Base = (y * pLayout->displayWidth + x + pMga->YDstOrg) >> + (3 - pMga->BppShifts[(pLayout->bitsPerPixel >> 3) - 1]); - if (pLayout->bitsPerPixel == 24) { - if (pMga->Chipset == PCI_CHIP_MGAG400 || pMga->Chipset == PCI_CHIP_MGAG550) + if (pLayout->bitsPerPixel == 24) { + if (pMga->Chipset == PCI_CHIP_MGAG400 || pMga->Chipset == PCI_CHIP_MGAG550) Base &= ~1; /*1 Not sure why */ - Base *= 3; - } - /* find start of retrace */ - while (INREG8(0x1FDA) & 0x08); - while (!(INREG8(0x1FDA) & 0x08)); - /* wait until we're past the start (fixseg.c in the DDK) */ - count = INREG(MGAREG_VCOUNT) + 2; - while(INREG(MGAREG_VCOUNT) < count); + Base *= 3; + } + + /* find start of retrace */ + while (INREG8(0x1FDA) & 0x08); + while (!(INREG8(0x1FDA) & 0x08)); + /* wait until we're past the start (fixseg.c in the DDK) */ + count = INREG(MGAREG_VCOUNT) + 2; + while (INREG(MGAREG_VCOUNT) < count); - OUTREG16(MGAREG_CRTC_INDEX, (Base & 0x00FF00) | 0x0C); - OUTREG16(MGAREG_CRTC_INDEX, ((Base & 0x0000FF) << 8) | 0x0D); - OUTREG8(MGAREG_CRTCEXT_INDEX, 0x00); - tmp = INREG8(MGAREG_CRTCEXT_DATA); - OUTREG8(MGAREG_CRTCEXT_DATA, (tmp & 0xF0) | ((Base & 0x0F0000) >> 16)); - ); + OUTREG16(MGAREG_CRTC_INDEX, (Base & 0x00FF00) | 0x0C); + OUTREG16(MGAREG_CRTC_INDEX, ((Base & 0x0000FF) << 8) | 0x0D); + OUTREG8(MGAREG_CRTCEXT_INDEX, 0x00); + tmp = INREG8(MGAREG_CRTCEXT_DATA); + OUTREG8(MGAREG_CRTCEXT_DATA, (tmp & 0xF0) | ((Base & 0x0F0000) >> 16)); } @@ -3705,26 +3069,14 @@ 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; - - /* 3-85 c2offset - * 3-93 c2startadd0 - * 3-96 c2vcount - */ - - Base = (y * pLayout->displayWidth + x) * pLayout->bitsPerPixel >> 3; - Base += pMga->DstOrg; - Base &= 0x01ffffc0; - OUTREG(MGAREG_C2STARTADD0, Base); - ); + + if (pMga->ShowCache && y && pScrn->vtSema) + y += pScrn->virtualY - 1; + + Base = (y * pLayout->displayWidth + x) * pLayout->bitsPerPixel >> 3; + Base += pMga->DstOrg; + Base &= 0x01ffffc0; + OUTREG(MGAREG_C2STARTADD0, Base); } /* @@ -3824,9 +3176,11 @@ MGALeaveVT(int scrnIndex, int flags) DRILock(pScreen, 0); } #endif -#ifdef USEMGAHAL - MGA_HAL( RESTORE_TEXTMODE_ON_DVI(pMga); ); -#endif + + /* FIXME: + * + * RESTORE_TEXTMODE_ON_DVI(pMga) + */ } @@ -3846,9 +3200,11 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen) MGAPtr pMga = MGAPTR(pScrn); MGAEntPtr pMgaEnt = NULL; -#ifdef USEMGAHAL - MGA_HAL( RESTORE_TEXTMODE_ON_DVI(pMga); ); -#endif + /* FIXME: + * + * RESTORE_TEXTMODE_ON_DVI(pMga); + */ + if (pMga->MergedFB) MGACloseScreenMerged(scrnIndex, pScreen); @@ -3877,37 +3233,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); |