if(pMga->SecondCrtc == FALSE && pMga->HWCursor == TRUE) {
case PCI_CHIP_MGAG550: if(pMga->SecondCrtc == FALSE && pMga->HWCursor == TRUE) {
MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode){    vgaHWPtr hwp = VGAHWPTR(pScrn);    vgaRegPtr vgaReg;    MGAPtr pMga = MGAPTR(pScrn);    MGARegPtr mgaReg;#ifdef USEMGAHAL    Bool digital1 = FALSE;    Bool digital2 = FALSE;    Bool tv1 = FALSE;    Bool tv2 = FALSE;    ULONG status;    Bool swap_head      = xf86ReturnOptValBool(pMga->Options, OPTION_SWAPPED_HEAD, FALSE);    if (pMga->pMgaHwInfo)    {	digital1 = ISDIGITAL1(pMga);	digital2 = ISDIGITAL2(pMga);	tv1 = ISTV1(pMga);	tv2 = ISTV2(pMga);    }#endif    vgaHWUnlock(hwp);    /* Initialise the ModeReg values */    if (!vgaHWInit(pScrn, mode))	return FALSE;    pScrn->vtSema = TRUE;    if (!(*pMga->ModeInit)(pScrn, mode))	return FALSE;    /* Program the registers */    vgaHWProtect(pScrn, TRUE);    vgaReg = &hwp->ModeReg;    mgaReg = &pMga->ModeReg;#ifdef USEMGAHAL    MGA_HAL(    FillModeInfoStruct(pScrn,mode);    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) {	    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;    /* 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;    }    /* Validates the Video parameters */    if ((status = MGAValidateVideoParameters(pMga->pBoard, pMga->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 XF86DRI   if (pMga->directRenderingEnabled) {       DRILock(screenInfo.screens[pScrn->scrnIndex], 0);   }#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;    }        );	/* 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_MGAG400:	      	      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));    MGAStormSync(pScrn);    MGAStormEngineInit(pScrn);    vgaHWProtect(pScrn, FALSE);    if (xf86IsPc98()) {	if (pMga->Chipset == PCI_CHIP_MGA2064)	    outb(0xfac, 0x01);	else	    outb(0xfac, 0x02);    }    pMga->CurrentLayout.mode = mode;#ifdef XF86DRI   if (pMga->directRenderingEnabled)     DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);#endif    return TRUE;}