static Bool
BW2ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
{
    ScrnInfoPtr pScrn;
    Bw2Ptr pBw2;
    int ret;

    /*
     * First get the ScrnInfoRec
     */
    pScrn = xf86Screens[pScreen->myNum];

    pBw2 = GET_BW2_FROM_SCRN(pScrn);

    /* Map the BW2 memory */
    pBw2->fb = xf86MapSbusMem(pBw2->psdp, BW2_RAM_VOFF,
			      pBw2->psdp->width * pBw2->psdp->height / 8);

    if (!pBw2->fb)
	return FALSE;

    /* Darken the screen for aesthetic reasons and set the viewport */
    BW2SaveScreen(pScreen, SCREEN_SAVER_ON);

    /*
     * 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();

    /* Set the bits per RGB for 8bpp mode */
    pScrn->rgbBits = 8;

    /* Setup the visuals we support. */

    if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
			  pScrn->rgbBits, pScrn->defaultVisual))
	return FALSE;

    /*
     * Call the framebuffer layer's ScreenInit function, and fill in other
     * pScreen fields.
     */

    ret = xf1bppScreenInit(pScreen, pBw2->fb, pScrn->virtualX,
			   pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
			   pScrn->virtualX);
    if (!ret)
	return FALSE;

    miInitializeBackingStore(pScreen);
    xf86SetBackingStore(pScreen);
    xf86SetSilkenMouse(pScreen);

    xf86SetBlackWhitePixels(pScreen);

    /* Initialise cursor functions */
    miDCInitialize(pScreen, xf86GetPointerScreenFuncs());

    /* Initialise default colourmap */
    if (!miCreateDefColormap(pScreen))
	return FALSE;

    pBw2->CloseScreen = pScreen->CloseScreen;
    pScreen->CloseScreen = BW2CloseScreen;
    pScreen->SaveScreen = BW2SaveScreen;

    /* Report any unused options (only for the first generation) */
    if (serverGeneration == 1) {
	xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
    }

    /* unblank the screen */
    BW2SaveScreen(pScreen, SCREEN_SAVER_OFF);

    /* Done */
    return TRUE;
}
static Bool
CG3ScreenInit(SCREEN_INIT_ARGS_DECL)
{
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
    Cg3Ptr pCg3;
    int ret;

    pCg3 = GET_CG3_FROM_SCRN(pScrn);

    /* Map the CG3 memory */
    pCg3->fb =
	xf86MapSbusMem (pCg3->psdp, CG3_RAM_VOFF,
			(pCg3->psdp->width * pCg3->psdp->height));

    if (! pCg3->fb)
	return FALSE;

    /* Darken the screen for aesthetic reasons and set the viewport */
    CG3SaveScreen(pScreen, SCREEN_SAVER_ON);

    /*
     * 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();

    /* Set the bits per RGB for 8bpp mode */
    pScrn->rgbBits = 8;

    /* Setup the visuals we support. */

    if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
			  pScrn->rgbBits, pScrn->defaultVisual))
	return FALSE;

    miSetPixmapDepths ();
	
    /*
     * Call the framebuffer layer's ScreenInit function, and fill in other
     * pScreen fields.
     */

    ret = fbScreenInit(pScreen, pCg3->fb, pScrn->virtualX,
		       pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
		       pScrn->virtualX, 8);
    if (!ret)
	return FALSE;

#ifdef RENDER
    fbPictureInit (pScreen, 0, 0);
#endif

    xf86SetBackingStore(pScreen);
    xf86SetSilkenMouse(pScreen);

    xf86SetBlackWhitePixels(pScreen);

    /* Initialise cursor functions */
    miDCInitialize (pScreen, xf86GetPointerScreenFuncs());

    /* Initialise default colourmap */
    if (!miCreateDefColormap(pScreen))
	return FALSE;

    if(!xf86SbusHandleColormaps(pScreen, pCg3->psdp))
	return FALSE;

    pCg3->CloseScreen = pScreen->CloseScreen;
    pScreen->CloseScreen = CG3CloseScreen;
    pScreen->SaveScreen = CG3SaveScreen;

    /* Report any unused options (only for the first generation) */
    if (serverGeneration == 1) {
	xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
    }

    /* unblank the screen */
    CG3SaveScreen(pScreen, SCREEN_SAVER_OFF);

    /* Done */
    return TRUE;
}