FFBSaveScreen(pScreen, SCREEN_SAVER_OFF);
FFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv){    ScrnInfoPtr pScrn;    FFBPtr pFfb;    sbusDevicePtr psdp;    int ret;    unsigned int afb_fem;    VisualPtr visual;    /* Add in our Dbe hook. */    if (!FFBDbePreInit(pScreen))	return FALSE;    pScrn = xf86Screens[pScreen->myNum];    pFfb = GET_FFB_FROM_SCRN(pScrn);    psdp = pFfb->psdp;    /* Map the FFB framebuffer, for each view. */    /* 24-bit RGB Dumb view */    pFfb->fb = pFfb->dfb24 = xf86MapSbusMem(psdp, FFB_DFB24_VOFF, 0x1000000);    /* 8-bit R Dumb view */    pFfb->dfb8r = xf86MapSbusMem(psdp, FFB_DFB8R_VOFF, 0x400000);    /* 8-bit X Dumb view */    pFfb->dfb8x = xf86MapSbusMem(psdp, FFB_DFB8X_VOFF, 0x400000);    /* 32-bit RGB Smart view */    pFfb->sfb32 = xf86MapSbusMem(psdp, FFB_SFB32_VOFF, 0x1000000);    /* 8-bit R Smart view */    pFfb->sfb8r = xf86MapSbusMem(psdp, FFB_SFB8R_VOFF, 0x400000);    /* 8-bit X Smart view */    pFfb->sfb8x = xf86MapSbusMem(psdp, FFB_SFB8X_VOFF, 0x400000);    /* Map the rendering pipeline */    pFfb->regs = xf86MapSbusMem(psdp, FFB_FBC_REGS_VOFF, sizeof(*pFfb->regs));    /* Map the ramdac */    pFfb->dac = xf86MapSbusMem(psdp, FFB_DAC_VOFF, 8192);    /* Map the board strapping bits */    pFfb->strapping_bits = xf86MapSbusMem(psdp, FFB_EXP_VOFF, 8192);    if (!pFfb->dfb24 || !pFfb->dfb8r || !pFfb->dfb8x ||	!pFfb->sfb32 || !pFfb->sfb8r || !pFfb->sfb8x ||	!pFfb->regs || !pFfb->dac || !pFfb->strapping_bits) {	if (pFfb->dfb24) {	    xf86UnmapSbusMem(psdp, pFfb->dfb24, 0x1000000);	    pFfb->dfb24 = NULL;	}	if (pFfb->dfb8r) {	    xf86UnmapSbusMem(psdp, pFfb->dfb8r, 0x400000);	    pFfb->dfb8r = NULL;	}	if (pFfb->dfb8x) {	    xf86UnmapSbusMem(psdp, pFfb->dfb8x, 0x400000);	    pFfb->dfb8x = NULL;	}	if (pFfb->sfb32) {	    xf86UnmapSbusMem(psdp, pFfb->sfb32, 0x1000000);	    pFfb->sfb32 = NULL;	}	if (pFfb->sfb8r) {	    xf86UnmapSbusMem(psdp, pFfb->sfb8r, 0x400000);	    pFfb->sfb8r = NULL;	}	if (pFfb->sfb8x) {	    xf86UnmapSbusMem(psdp, pFfb->sfb8x, 0x400000);	    pFfb->sfb8x = NULL;	}	if (pFfb->regs) {	    xf86UnmapSbusMem(psdp, pFfb->regs, sizeof(*pFfb->regs));	    pFfb->regs = NULL;	}	if (pFfb->dac) {	    xf86UnmapSbusMem(psdp, pFfb->dac, 8192);	    pFfb->dac = NULL;	}	if (pFfb->strapping_bits) {	    xf86UnmapSbusMem(psdp, (void *)pFfb->strapping_bits, 8192);	    pFfb->strapping_bits = NULL;	}	return FALSE;    }    /* Probe for the type of FFB/AFB we have. */    FFBProbeBoardType(pFfb);    /* Now that we have the board type, we can init the ramdac layer. */    if (FFBDacInit(pFfb) == FALSE)	return FALSE;    /* OK, a fun gross hack to detect if this is     * AFB and if so whether the correct firmware     * has been loaded.  The machine will flatline     * if you try to use certain acceleration features     * without the full firmware loaded.     *     * The bootup Elite3D/AFB firmware is minimal, and     * will leave the FloatEnableMask register at a     * value of 0x01.  Creator{,3D} lacks the FEM register     * and will return a "nonsense" value on attempts to     * read this location.  After experimentation, an     * appropriate definition for "nonsense" seems to     * be anything with all low 7 bits not 0x3f, 0x07,     * of 0x01.     *     * If the FEM register is non-zero and is some value     * other than 0x1 (usually 0x3f or 0x7 depending upon     * whether the card has 3 or 6 floats) we can assume     * the correct firmware has been loaded. -DaveM     */    afb_fem = *(unsigned int *)((char *)pFfb->regs + 0x1540);    if ((afb_fem & 0x7f) != 0x3f &&	(afb_fem & 0x7f) != 0x07 &&	(afb_fem & 0x7f) != 0x01)	xf86Msg(X_INFO, "%s: Detected Creator/Creator3D\n", psdp->device);    else {	xf86Msg(X_INFO, "%s: Detected Elite3D M3/M6, checking firmware...\n",		psdp->device);	if (afb_fem == 0x1) {	    xf86Msg(X_INFO, "%s: ... AFB firmware not loaded\n", psdp->device);	    if (!pFfb->NoAccel) {		xf86Msg(X_WARNING,			"%s: Forcing no acceleration on Elite3D M3/M6\n",			psdp->device);		pFfb->NoAccel = TRUE;	    }	} else	    xf86Msg(X_INFO, "%s: ... AFB firmware is loaded\n", psdp->device);    }    /* Darken the screen for aesthetic reasons and set the viewport */    FFBSaveScreen(pScreen, SCREEN_SAVER_ON);    if (pFfb->NoAccel == TRUE) {	    if (!CreatorUnaccelWidInit(pScreen))		    return FALSE;    }    /*     * The next step is to setup the screen's visuals, and initialise the     * framebuffer code.  In cases where the framebuffer's default     * choices for things like visual layouts and bits per RGB are OK,     * this may be as simple as calling the framebuffer's ScreenInit()     * function.  If not, the visuals will need to be setup before calling     * a fb ScreenInit() function and fixed up after.     */    /*     * Reset visual list.     */    miClearVisualTypes();    /* Setup the visuals we support. */    if (!miSetVisualTypes(24, TrueColorMask | DirectColorMask,			  pScrn->rgbBits, TrueColor))	    return FALSE;    if (!miSetVisualTypes(8, PseudoColorMask | GrayScaleMask | StaticGrayMask,			  pScrn->rgbBits, PseudoColor))	    return FALSE;#ifdef XF86DRI    if (pFfb->ffb_type != afb_m3 && pFfb->ffb_type != afb_m6 &&	pFfb->NoAccel == FALSE) {	    pFfb->dri_enabled = FFBDRIScreenInit(pScreen);	    if (pFfb->dri_enabled == TRUE)		    xf86Msg(X_INFO, "%s: DRM initialized\n", psdp->device);	    else		    xf86Msg(X_INFO, "%s: DRM setup failed\n", psdp->device);    } else {	    pFfb->dri_enabled = FALSE;    }#endif    /*     * Call the framebuffer layer's ScreenInit function, and fill in other     * pScreen fields.     */    if (pFfb->NoAccel == TRUE) {	    ret = cfb8_32WidScreenInit(pScreen, pFfb->dfb24, pFfb->dfb8r, pFfb->dfb8x,				       pScrn->virtualX, pScrn->virtualY,				       pScrn->xDpi, pScrn->yDpi,				       2048, 2048, 2048, 8,				       &CreatorUnaccelWidOps);    } else {	    /* Use smart framebuffer aperture for cfb8/cfb32. */	    ret = cfb8_32WidScreenInit(pScreen, pFfb->sfb32, pFfb->sfb8r, pFfb->dfb8x,				       pScrn->virtualX, pScrn->virtualY,				       pScrn->xDpi, pScrn->yDpi,				       2048, 2048, 2048, 8,				       &CreatorUnaccelWidOps);    }    if (!ret)	return FALSE;    miInitializeBackingStore(pScreen);    xf86SetBackingStore(pScreen);    xf86SetSilkenMouse(pScreen);    xf86SetBlackWhitePixels(pScreen);    if (pScrn->bitsPerPixel > 8) {        /* Fixup RGB ordering */        visual = pScreen->visuals + pScreen->numVisuals;        while (--visual >= pScreen->visuals) {	    if ((visual->class | DynamicClass) == DirectColor) {		visual->offsetRed = pScrn->offset.red;		visual->offsetGreen = pScrn->offset.green;		visual->offsetBlue = pScrn->offset.blue;		visual->redMask = pScrn->mask.red;		visual->greenMask = pScrn->mask.green;		visual->blueMask = pScrn->mask.blue;	    }	}    }    if (!pFfb->NoAccel) {	if (!FFBAccelInit(pScreen, pFfb))	    return FALSE;	xf86Msg(X_INFO, "%s: Using acceleration\n", psdp->device);    }    /* Initialise cursor functions */    miDCInitialize(pScreen, xf86GetPointerScreenFuncs());    /* Initialize HW cursor layer.     * Must follow software cursor initialization.     */    if (pFfb->HWCursor) {	if(!FFBHWCursorInit(pScreen)) {	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,		       "Hardware cursor initialization failed\n");	    return(FALSE);	}	xf86SbusHideOsHwCursor(psdp);    }    /* Initialise default colourmap. */    if (!miCreateDefColormap(pScreen))	return FALSE;    /* Initialize colormap layer.     * Must follow initialization of the default colormap.     */    if (!xf86HandleColormaps(pScreen, 256, 8,			     FFBDacLoadPalette, NULL,#if 0			     CMAP_PALETTED_TRUECOLOR |#endif			     CMAP_LOAD_EVEN_IF_OFFSCREEN |			     CMAP_RELOAD_ON_MODE_SWITCH))	return FALSE;    /* Setup DGA support. */    if (!pFfb->NoAccel)	    FFB_InitDGA(pScreen);#ifdef XF86DRI    if (pFfb->dri_enabled) {	    /* Now that mi, cfb, drm and others have done their thing,	     * complete the DRI setup.	     */	    pFfb->dri_enabled = FFBDRIFinishScreenInit(pScreen);	    if (pFfb->dri_enabled)		    xf86Msg(X_INFO, "%s: DRM finish setup complete\n",			    psdp->device);	    else		    xf86Msg(X_INFO, "%s: DRM finish setup failed\n",			    psdp->device);    }#endif    pFfb->CloseScreen = pScreen->CloseScreen;    pScreen->CloseScreen = FFBCloseScreen;    pScreen->SaveScreen = FFBSaveScreen;    (void) xf86DPMSInit(pScreen, FFBDPMSMode, 0);    /* Report any unused options (only for the first generation) */    if (serverGeneration == 1) {	xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);    }    /* unblank the screen */    FFBSaveScreen(pScreen, SCREEN_SAVER_OFF);    /* Done */    return TRUE;}