cg14_driver.c revision 7a5333bc
1f7ec340bSmacallan/*
2f7ec340bSmacallan * CG14 framebuffer driver.
3f7ec340bSmacallan *
4f7ec340bSmacallan * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com)
5f7ec340bSmacallan *
6f7ec340bSmacallan * Permission is hereby granted, free of charge, to any person obtaining a copy
7f7ec340bSmacallan * of this software and associated documentation files (the "Software"), to deal
8f7ec340bSmacallan * in the Software without restriction, including without limitation the rights
9f7ec340bSmacallan * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10f7ec340bSmacallan * copies of the Software, and to permit persons to whom the Software is
11f7ec340bSmacallan * furnished to do so, subject to the following conditions:
12f7ec340bSmacallan *
13f7ec340bSmacallan * The above copyright notice and this permission notice shall be included in
14f7ec340bSmacallan * all copies or substantial portions of the Software.
15f7ec340bSmacallan *
16f7ec340bSmacallan * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17f7ec340bSmacallan * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18f7ec340bSmacallan * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19f7ec340bSmacallan * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20f7ec340bSmacallan * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21f7ec340bSmacallan * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22f7ec340bSmacallan */
23f7ec340bSmacallan
24f7ec340bSmacallan#ifdef HAVE_CONFIG_H
25f7ec340bSmacallan#include "config.h"
26f7ec340bSmacallan#endif
27f7ec340bSmacallan
287a5333bcSmrg#include <sys/ioctl.h>
29f7ec340bSmacallan#include <string.h>
300d3fa27dSmacallan#include <sys/ioctl.h>
31f7ec340bSmacallan
32f7ec340bSmacallan#include "xf86.h"
33f7ec340bSmacallan#include "xf86_OSproc.h"
34f7ec340bSmacallan#include "mipointer.h"
35f7ec340bSmacallan#include "micmap.h"
36f7ec340bSmacallan
37f7ec340bSmacallan#include "fb.h"
38f7ec340bSmacallan#include "xf86cmap.h"
391a3e96b4Smacallan#include "shadow.h"
40f7ec340bSmacallan#include "cg14.h"
41f7ec340bSmacallan
427a5333bcSmrg#if 0
431a3e96b4Smacallan#define static
447a5333bcSmrg#endif
457a5333bcSmrg
467a5333bcSmrg#include "compat-api.h"
471a3e96b4Smacallan
48f7ec340bSmacallanstatic const OptionInfoRec * CG14AvailableOptions(int chipid, int busid);
49f7ec340bSmacallanstatic void	CG14Identify(int flags);
50f7ec340bSmacallanstatic Bool	CG14Probe(DriverPtr drv, int flags);
51f7ec340bSmacallanstatic Bool	CG14PreInit(ScrnInfoPtr pScrn, int flags);
527a5333bcSmrgstatic Bool	CG14ScreenInit(SCREEN_INIT_ARGS_DECL);
537a5333bcSmrgstatic Bool	CG14EnterVT(VT_FUNC_ARGS_DECL);
547a5333bcSmrgstatic void	CG14LeaveVT(VT_FUNC_ARGS_DECL);
557a5333bcSmrgstatic Bool	CG14CloseScreen(CLOSE_SCREEN_ARGS_DECL);
56f7ec340bSmacallanstatic Bool	CG14SaveScreen(ScreenPtr pScreen, int mode);
57f7ec340bSmacallanstatic void	CG14InitCplane24(ScrnInfoPtr pScrn);
58f7ec340bSmacallanstatic void	CG14ExitCplane24(ScrnInfoPtr pScrn);
591a3e96b4Smacallanstatic void    *CG14WindowLinear(ScreenPtr, CARD32, CARD32, int, CARD32 *,
601a3e96b4Smacallan			      void *);
61f7ec340bSmacallan
62f7ec340bSmacallan/* Required if the driver supports mode switching */
637a5333bcSmrgstatic Bool	CG14SwitchMode(SWITCH_MODE_ARGS_DECL);
64f7ec340bSmacallan/* Required if the driver supports moving the viewport */
657a5333bcSmrgstatic void	CG14AdjustFrame(ADJUST_FRAME_ARGS_DECL);
66f7ec340bSmacallan
67f7ec340bSmacallan/* Optional functions */
687a5333bcSmrgstatic void	CG14FreeScreen(FREE_SCREEN_ARGS_DECL);
697a5333bcSmrgstatic ModeStatus CG14ValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode,
70f7ec340bSmacallan				Bool verbose, int flags);
71f7ec340bSmacallan
72f7ec340bSmacallanvoid CG14Sync(ScrnInfoPtr pScrn);
73f7ec340bSmacallan
74f7ec340bSmacallan#define CG14_VERSION 4000
75f7ec340bSmacallan#define CG14_NAME "SUNCG14"
76f7ec340bSmacallan#define CG14_DRIVER_NAME "suncg14"
77766a8447Smrg#define CG14_MAJOR_VERSION PACKAGE_VERSION_MAJOR
78766a8447Smrg#define CG14_MINOR_VERSION PACKAGE_VERSION_MINOR
79766a8447Smrg#define CG14_PATCHLEVEL PACKAGE_VERSION_PATCHLEVEL
80f7ec340bSmacallan
81f7ec340bSmacallan/*
82f7ec340bSmacallan * This contains the functions needed by the server after loading the driver
83f7ec340bSmacallan * module.  It must be supplied, and gets passed back by the SetupProc
84f7ec340bSmacallan * function in the dynamic case.  In the static case, a reference to this
85f7ec340bSmacallan * is compiled in, and this requires that the name of this DriverRec be
86f7ec340bSmacallan * an upper-case version of the driver name.
87f7ec340bSmacallan */
88f7ec340bSmacallan
89f7ec340bSmacallan_X_EXPORT DriverRec SUNCG14 = {
90f7ec340bSmacallan    CG14_VERSION,
91f7ec340bSmacallan    CG14_DRIVER_NAME,
92f7ec340bSmacallan    CG14Identify,
93f7ec340bSmacallan    CG14Probe,
94f7ec340bSmacallan    CG14AvailableOptions,
95f7ec340bSmacallan    NULL,
96f7ec340bSmacallan    0
97f7ec340bSmacallan};
98f7ec340bSmacallan
991a3e96b4Smacallantypedef enum {
1001a3e96b4Smacallan	OPTION_SHADOW_FB,
1011a3e96b4Smacallan	OPTION_HW_CURSOR,
1021a3e96b4Smacallan	OPTION_SW_CURSOR
1031a3e96b4Smacallan} CG14Opts;
1041a3e96b4Smacallan
105f7ec340bSmacallanstatic const OptionInfoRec CG14Options[] = {
1061a3e96b4Smacallan    { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, TRUE},
107f7ec340bSmacallan    { -1,			NULL,		OPTV_NONE,	{0}, FALSE }
108f7ec340bSmacallan};
109f7ec340bSmacallan
110f7ec340bSmacallan#ifdef XFree86LOADER
111f7ec340bSmacallan
112f7ec340bSmacallanstatic MODULESETUPPROTO(cg14Setup);
113f7ec340bSmacallan
114f7ec340bSmacallanstatic XF86ModuleVersionInfo suncg14VersRec =
115f7ec340bSmacallan{
116f7ec340bSmacallan	"suncg14",
117f7ec340bSmacallan	MODULEVENDORSTRING,
118f7ec340bSmacallan	MODINFOSTRING1,
119f7ec340bSmacallan	MODINFOSTRING2,
120f7ec340bSmacallan	XORG_VERSION_CURRENT,
121f7ec340bSmacallan	CG14_MAJOR_VERSION, CG14_MINOR_VERSION, CG14_PATCHLEVEL,
122f7ec340bSmacallan	ABI_CLASS_VIDEODRV,
123f7ec340bSmacallan	ABI_VIDEODRV_VERSION,
124f7ec340bSmacallan	MOD_CLASS_VIDEODRV,
125f7ec340bSmacallan	{0,0,0,0}
126f7ec340bSmacallan};
127f7ec340bSmacallan
128f7ec340bSmacallan_X_EXPORT XF86ModuleData suncg14ModuleData = {
129f7ec340bSmacallan	&suncg14VersRec,
130f7ec340bSmacallan	cg14Setup,
131f7ec340bSmacallan	NULL
132f7ec340bSmacallan};
133f7ec340bSmacallan
134f7ec340bSmacallanpointer
135f7ec340bSmacallancg14Setup(pointer module, pointer opts, int *errmaj, int *errmin)
136f7ec340bSmacallan{
137f7ec340bSmacallan    static Bool setupDone = FALSE;
138f7ec340bSmacallan
139f7ec340bSmacallan    if (!setupDone) {
140f7ec340bSmacallan	setupDone = TRUE;
141f7ec340bSmacallan	xf86AddDriver(&SUNCG14, module, 0);
142f7ec340bSmacallan
143f7ec340bSmacallan	/*
144f7ec340bSmacallan	 * Modules that this driver always requires can be loaded here
145f7ec340bSmacallan	 * by calling LoadSubModule().
146f7ec340bSmacallan	 */
147f7ec340bSmacallan
148f7ec340bSmacallan	/*
149f7ec340bSmacallan	 * The return value must be non-NULL on success even though there
150f7ec340bSmacallan	 * is no TearDownProc.
151f7ec340bSmacallan	 */
152f7ec340bSmacallan	return (pointer)TRUE;
153f7ec340bSmacallan    } else {
154f7ec340bSmacallan	if (errmaj) *errmaj = LDR_ONCEONLY;
155f7ec340bSmacallan	return NULL;
156f7ec340bSmacallan    }
157f7ec340bSmacallan}
158f7ec340bSmacallan
159f7ec340bSmacallan#endif /* XFree86LOADER */
160f7ec340bSmacallan
161f7ec340bSmacallanstatic Bool
162f7ec340bSmacallanCG14GetRec(ScrnInfoPtr pScrn)
163f7ec340bSmacallan{
164f7ec340bSmacallan    /*
165f7ec340bSmacallan     * Allocate an Cg14Rec, and hook it into pScrn->driverPrivate.
166f7ec340bSmacallan     * pScrn->driverPrivate is initialised to NULL, so we can check if
167f7ec340bSmacallan     * the allocation has already been done.
168f7ec340bSmacallan     */
169f7ec340bSmacallan    if (pScrn->driverPrivate != NULL)
170f7ec340bSmacallan	return TRUE;
171f7ec340bSmacallan
172f7ec340bSmacallan    pScrn->driverPrivate = xnfcalloc(sizeof(Cg14Rec), 1);
173f7ec340bSmacallan    return TRUE;
174f7ec340bSmacallan}
175f7ec340bSmacallan
176f7ec340bSmacallanstatic void
177f7ec340bSmacallanCG14FreeRec(ScrnInfoPtr pScrn)
178f7ec340bSmacallan{
179f7ec340bSmacallan    Cg14Ptr pCg14;
180f7ec340bSmacallan
181f7ec340bSmacallan    if (pScrn->driverPrivate == NULL)
182f7ec340bSmacallan	return;
183f7ec340bSmacallan
184f7ec340bSmacallan    pCg14 = GET_CG14_FROM_SCRN(pScrn);
185f7ec340bSmacallan
1867a5333bcSmrg    free(pScrn->driverPrivate);
187f7ec340bSmacallan    pScrn->driverPrivate = NULL;
188f7ec340bSmacallan
189f7ec340bSmacallan    return;
190f7ec340bSmacallan}
191f7ec340bSmacallan
192f7ec340bSmacallanstatic const OptionInfoRec *
193f7ec340bSmacallanCG14AvailableOptions(int chipid, int busid)
194f7ec340bSmacallan{
195f7ec340bSmacallan    return CG14Options;
196f7ec340bSmacallan}
197f7ec340bSmacallan
198f7ec340bSmacallan/* Mandatory */
199f7ec340bSmacallanstatic void
200f7ec340bSmacallanCG14Identify(int flags)
201f7ec340bSmacallan{
202f7ec340bSmacallan    xf86Msg(X_INFO, "%s: driver for CG14\n", CG14_NAME);
203f7ec340bSmacallan}
204f7ec340bSmacallan
205f7ec340bSmacallan
206f7ec340bSmacallan/* Mandatory */
207f7ec340bSmacallanstatic Bool
208f7ec340bSmacallanCG14Probe(DriverPtr drv, int flags)
209f7ec340bSmacallan{
210f7ec340bSmacallan    int i;
211f7ec340bSmacallan    GDevPtr *devSections;
212f7ec340bSmacallan    int *usedChips;
213f7ec340bSmacallan    int numDevSections;
214f7ec340bSmacallan    int numUsed;
215f7ec340bSmacallan    Bool foundScreen = FALSE;
216f7ec340bSmacallan    EntityInfoPtr pEnt;
217f7ec340bSmacallan
218f7ec340bSmacallan    /*
219f7ec340bSmacallan     * The aim here is to find all cards that this driver can handle,
220f7ec340bSmacallan     * and for the ones not already claimed by another driver, claim the
221f7ec340bSmacallan     * slot, and allocate a ScrnInfoRec.
222f7ec340bSmacallan     *
223f7ec340bSmacallan     * This should be a minimal probe, and it should under no circumstances
224f7ec340bSmacallan     * change the state of the hardware.  Because a device is found, don't
225f7ec340bSmacallan     * assume that it will be used.  Don't do any initialisations other than
226f7ec340bSmacallan     * the required ScrnInfoRec initialisations.  Don't allocate any new
227f7ec340bSmacallan     * data structures.
228f7ec340bSmacallan     */
229f7ec340bSmacallan
230f7ec340bSmacallan    /*
231f7ec340bSmacallan     * Next we check, if there has been a chipset override in the config file.
232f7ec340bSmacallan     * For this we must find out if there is an active device section which
233f7ec340bSmacallan     * is relevant, i.e., which has no driver specified or has THIS driver
234f7ec340bSmacallan     * specified.
235f7ec340bSmacallan     */
236f7ec340bSmacallan
237f7ec340bSmacallan    if ((numDevSections = xf86MatchDevice(CG14_DRIVER_NAME,
238f7ec340bSmacallan					  &devSections)) <= 0) {
239f7ec340bSmacallan	/*
240f7ec340bSmacallan	 * There's no matching device section in the config file, so quit
241f7ec340bSmacallan	 * now.
242f7ec340bSmacallan	 */
243f7ec340bSmacallan	return FALSE;
244f7ec340bSmacallan    }
245f7ec340bSmacallan
246f7ec340bSmacallan    /*
247f7ec340bSmacallan     * We need to probe the hardware first.  We then need to see how this
248f7ec340bSmacallan     * fits in with what is given in the config file, and allow the config
249f7ec340bSmacallan     * file info to override any contradictions.
250f7ec340bSmacallan     */
251f7ec340bSmacallan
252f7ec340bSmacallan    numUsed = xf86MatchSbusInstances(CG14_NAME, SBUS_DEVICE_CG14,
253f7ec340bSmacallan		   devSections, numDevSections,
254f7ec340bSmacallan		   drv, &usedChips);
255f7ec340bSmacallan
2567a5333bcSmrg    free(devSections);
257f7ec340bSmacallan    if (numUsed <= 0)
258f7ec340bSmacallan	return FALSE;
259f7ec340bSmacallan
260f7ec340bSmacallan    if (flags & PROBE_DETECT)
261f7ec340bSmacallan	foundScreen = TRUE;
262f7ec340bSmacallan    else for (i = 0; i < numUsed; i++) {
263f7ec340bSmacallan	pEnt = xf86GetEntityInfo(usedChips[i]);
264f7ec340bSmacallan
265f7ec340bSmacallan	/*
266f7ec340bSmacallan	 * Check that nothing else has claimed the slots.
267f7ec340bSmacallan	 */
268f7ec340bSmacallan	if(pEnt->active) {
269f7ec340bSmacallan	    ScrnInfoPtr pScrn;
270f7ec340bSmacallan
271f7ec340bSmacallan	    /* Allocate a ScrnInfoRec and claim the slot */
272f7ec340bSmacallan	    pScrn = xf86AllocateScreen(drv, 0);
273f7ec340bSmacallan
274f7ec340bSmacallan	    /* Fill in what we can of the ScrnInfoRec */
275f7ec340bSmacallan	    pScrn->driverVersion = CG14_VERSION;
276f7ec340bSmacallan	    pScrn->driverName	 = CG14_DRIVER_NAME;
277f7ec340bSmacallan	    pScrn->name		 = CG14_NAME;
278f7ec340bSmacallan	    pScrn->Probe	 = CG14Probe;
279f7ec340bSmacallan	    pScrn->PreInit	 = CG14PreInit;
280f7ec340bSmacallan	    pScrn->ScreenInit	 = CG14ScreenInit;
281f7ec340bSmacallan  	    pScrn->SwitchMode	 = CG14SwitchMode;
282f7ec340bSmacallan  	    pScrn->AdjustFrame	 = CG14AdjustFrame;
283f7ec340bSmacallan	    pScrn->EnterVT	 = CG14EnterVT;
284f7ec340bSmacallan	    pScrn->LeaveVT	 = CG14LeaveVT;
285f7ec340bSmacallan	    pScrn->FreeScreen	 = CG14FreeScreen;
286f7ec340bSmacallan	    pScrn->ValidMode	 = CG14ValidMode;
287f7ec340bSmacallan	    xf86AddEntityToScreen(pScrn, pEnt->index);
288f7ec340bSmacallan	    foundScreen = TRUE;
289f7ec340bSmacallan	}
2907a5333bcSmrg	free(pEnt);
291f7ec340bSmacallan    }
2927a5333bcSmrg    free(usedChips);
293f7ec340bSmacallan    return foundScreen;
294f7ec340bSmacallan}
295f7ec340bSmacallan
296f7ec340bSmacallan/* Mandatory */
297f7ec340bSmacallanstatic Bool
298f7ec340bSmacallanCG14PreInit(ScrnInfoPtr pScrn, int flags)
299f7ec340bSmacallan{
300f7ec340bSmacallan    Cg14Ptr pCg14;
301f7ec340bSmacallan    sbusDevicePtr psdp = NULL;
3021a3e96b4Smacallan    int i, from;
303f7ec340bSmacallan
304f7ec340bSmacallan    if (flags & PROBE_DETECT) return FALSE;
305f7ec340bSmacallan
306f7ec340bSmacallan    /*
307f7ec340bSmacallan     * Note: This function is only called once at server startup, and
308f7ec340bSmacallan     * not at the start of each server generation.  This means that
309f7ec340bSmacallan     * only things that are persistent across server generations can
310f7ec340bSmacallan     * be initialised here.  xf86Screens[] is (pScrn is a pointer to one
311f7ec340bSmacallan     * of these).  Privates allocated using xf86AllocateScrnInfoPrivateIndex()
312f7ec340bSmacallan     * are too, and should be used for data that must persist across
313f7ec340bSmacallan     * server generations.
314f7ec340bSmacallan     *
315f7ec340bSmacallan     * Per-generation data should be allocated with
316f7ec340bSmacallan     * AllocateScreenPrivateIndex() from the ScreenInit() function.
317f7ec340bSmacallan     */
318f7ec340bSmacallan
319f7ec340bSmacallan    /* Allocate the Cg14Rec driverPrivate */
320f7ec340bSmacallan    if (!CG14GetRec(pScrn)) {
321f7ec340bSmacallan	return FALSE;
322f7ec340bSmacallan    }
323f7ec340bSmacallan    pCg14 = GET_CG14_FROM_SCRN(pScrn);
324f7ec340bSmacallan
325f7ec340bSmacallan    /* Set pScrn->monitor */
326f7ec340bSmacallan    pScrn->monitor = pScrn->confScreen->monitor;
327f7ec340bSmacallan
328f7ec340bSmacallan    /* This driver doesn't expect more than one entity per screen */
329f7ec340bSmacallan    if (pScrn->numEntities > 1)
330f7ec340bSmacallan	return FALSE;
331f7ec340bSmacallan    /* This is the general case */
332f7ec340bSmacallan    for (i = 0; i < pScrn->numEntities; i++) {
333f7ec340bSmacallan	EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]);
334f7ec340bSmacallan
335f7ec340bSmacallan	/* CG14 is purely AFX, but we handle it like SBUS */
336f7ec340bSmacallan	if (pEnt->location.type == BUS_SBUS) {
337f7ec340bSmacallan	    psdp = xf86GetSbusInfoForEntity(pEnt->index);
338f7ec340bSmacallan	    pCg14->psdp = psdp;
339f7ec340bSmacallan	} else
340f7ec340bSmacallan	    return FALSE;
341f7ec340bSmacallan    }
342f7ec340bSmacallan    if (psdp == NULL)
343f7ec340bSmacallan	return FALSE;
344f7ec340bSmacallan
345f7ec340bSmacallan    /*********************
346f7ec340bSmacallan    deal with depth
347f7ec340bSmacallan    *********************/
348f7ec340bSmacallan
349b73528caSmacallan    if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb|Support32bppFb))
350b73528caSmacallan		return FALSE;
351b73528caSmacallan    /* Check that the returned depth is one we support */
352b73528caSmacallan    switch (pScrn->depth) {
353f7ec340bSmacallan	case 32:
354b73528caSmacallan	case 24:
355f7ec340bSmacallan	    /* OK */
356f7ec340bSmacallan	    break;
357f7ec340bSmacallan	default:
358f7ec340bSmacallan	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
359f7ec340bSmacallan		       "Given depth (%d) is not supported by this driver\n",
360f7ec340bSmacallan		       pScrn->depth);
361f7ec340bSmacallan	    return FALSE;
362f7ec340bSmacallan    }
363f7ec340bSmacallan
364f7ec340bSmacallan    /* Collect all of the relevant option flags (fill in pScrn->options) */
365f7ec340bSmacallan    xf86CollectOptions(pScrn, NULL);
366f7ec340bSmacallan    /* Process the options */
3677a5333bcSmrg    if (!(pCg14->Options = malloc(sizeof(CG14Options))))
368f7ec340bSmacallan	return FALSE;
369f7ec340bSmacallan    memcpy(pCg14->Options, CG14Options, sizeof(CG14Options));
370f7ec340bSmacallan    xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pCg14->Options);
3711a3e96b4Smacallan    pCg14->use_shadow = xf86ReturnOptValBool(pCg14->Options, OPTION_SHADOW_FB,
3721a3e96b4Smacallan        TRUE);
373f7ec340bSmacallan
374f7ec340bSmacallan    /*
375f7ec340bSmacallan     * This must happen after pScrn->display has been set because
376f7ec340bSmacallan     * xf86SetWeight references it.
377f7ec340bSmacallan     */
378f7ec340bSmacallan    if (pScrn->depth > 8) {
379b73528caSmacallan	rgb weight = {0, 0, 0};
380f7ec340bSmacallan	rgb mask = {0xff, 0xff00, 0xff0000};
381f7ec340bSmacallan
382f7ec340bSmacallan	if (!xf86SetWeight(pScrn, weight, mask)) {
383f7ec340bSmacallan	    return FALSE;
384f7ec340bSmacallan	}
385f7ec340bSmacallan    }
386f7ec340bSmacallan
387f7ec340bSmacallan    if (!xf86SetDefaultVisual(pScrn, -1))
388f7ec340bSmacallan	return FALSE;
389f7ec340bSmacallan    else if (pScrn->depth > 8) {
390f7ec340bSmacallan	/* We don't currently support DirectColor */
391f7ec340bSmacallan	if (pScrn->defaultVisual != TrueColor) {
392f7ec340bSmacallan	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual"
393f7ec340bSmacallan		       " (%s) is not supported\n",
394f7ec340bSmacallan		       xf86GetVisualName(pScrn->defaultVisual));
395f7ec340bSmacallan	    return FALSE;
396f7ec340bSmacallan	}
397f7ec340bSmacallan    }
398f7ec340bSmacallan
399f7ec340bSmacallan    /*
400f7ec340bSmacallan     * The new cmap code requires this to be initialised.
401f7ec340bSmacallan     */
402f7ec340bSmacallan
403f7ec340bSmacallan    {
404f7ec340bSmacallan	Gamma zeros = {0.0, 0.0, 0.0};
405f7ec340bSmacallan
406f7ec340bSmacallan	if (!xf86SetGamma(pScrn, zeros)) {
407f7ec340bSmacallan	    return FALSE;
408f7ec340bSmacallan	}
409f7ec340bSmacallan    }
410f7ec340bSmacallan
411f7ec340bSmacallan    if (xf86LoadSubModule(pScrn, "fb") == NULL) {
412f7ec340bSmacallan	CG14FreeRec(pScrn);
413f7ec340bSmacallan	return FALSE;
414f7ec340bSmacallan    }
415f7ec340bSmacallan
4161a3e96b4Smacallan    if (pCg14->use_shadow) {
4171a3e96b4Smacallan	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using shadow framebuffer\n");
4181a3e96b4Smacallan	if (xf86LoadSubModule(pScrn, "shadow") == NULL) {
4191a3e96b4Smacallan	    CG14FreeRec(pScrn);
4201a3e96b4Smacallan	    return FALSE;
4211a3e96b4Smacallan	}
4221a3e96b4Smacallan    }
4231a3e96b4Smacallan
4241a3e96b4Smacallan    from = X_DEFAULT;
4251a3e96b4Smacallan    pCg14->HWCursor = TRUE;
4261a3e96b4Smacallan    if (xf86GetOptValBool(pCg14->Options, OPTION_HW_CURSOR, &pCg14->HWCursor))
4271a3e96b4Smacallan	from = X_CONFIG;
4281a3e96b4Smacallan    if (xf86ReturnOptValBool(pCg14->Options, OPTION_SW_CURSOR, FALSE)) {
4291a3e96b4Smacallan	from = X_CONFIG;
4301a3e96b4Smacallan	pCg14->HWCursor = FALSE;
4311a3e96b4Smacallan    }
4321a3e96b4Smacallan    xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
4331a3e96b4Smacallan		pCg14->HWCursor ? "HW" : "SW");
4341a3e96b4Smacallan
435f7ec340bSmacallan    /*********************
436f7ec340bSmacallan    set up clock and mode stuff
437f7ec340bSmacallan    *********************/
438f7ec340bSmacallan
439f7ec340bSmacallan    pScrn->progClock = TRUE;
440f7ec340bSmacallan
441f7ec340bSmacallan    if(pScrn->display->virtualX || pScrn->display->virtualY) {
442f7ec340bSmacallan	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
443f7ec340bSmacallan		   "CG14 does not support a virtual desktop\n");
444f7ec340bSmacallan	pScrn->display->virtualX = 0;
445f7ec340bSmacallan	pScrn->display->virtualY = 0;
446f7ec340bSmacallan    }
447f7ec340bSmacallan
448f7ec340bSmacallan    xf86SbusUseBuiltinMode(pScrn, pCg14->psdp);
449f7ec340bSmacallan    pScrn->currentMode = pScrn->modes;
450f7ec340bSmacallan    pScrn->displayWidth = pScrn->virtualX;
451f7ec340bSmacallan
452f7ec340bSmacallan    /* Set display resolution */
453f7ec340bSmacallan    xf86SetDpi(pScrn, 0, 0);
454f7ec340bSmacallan
455f7ec340bSmacallan    return TRUE;
456f7ec340bSmacallan}
457f7ec340bSmacallan
4581a3e96b4Smacallanstatic Bool
4591a3e96b4SmacallanCG14CreateScreenResources(ScreenPtr pScreen)
4601a3e96b4Smacallan{
4611a3e96b4Smacallan    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
4621a3e96b4Smacallan    Cg14Ptr pCg14 = GET_CG14_FROM_SCRN(pScrn);
4631a3e96b4Smacallan    PixmapPtr pPixmap;
4641a3e96b4Smacallan    Bool ret;
4651a3e96b4Smacallan
4661a3e96b4Smacallan    pScreen->CreateScreenResources = pCg14->CreateScreenResources;
4671a3e96b4Smacallan    ret = pScreen->CreateScreenResources(pScreen);
4681a3e96b4Smacallan    pScreen->CreateScreenResources = CG14CreateScreenResources;
4691a3e96b4Smacallan
4701a3e96b4Smacallan    if (!ret)
4711a3e96b4Smacallan	return FALSE;
4721a3e96b4Smacallan
4731a3e96b4Smacallan    pPixmap = pScreen->GetScreenPixmap(pScreen);
4741a3e96b4Smacallan
4751a3e96b4Smacallan    if (!shadowAdd(pScreen, pPixmap, shadowUpdatePackedWeak(),
4761a3e96b4Smacallan	CG14WindowLinear, 0, NULL)) {
4771a3e96b4Smacallan	return FALSE;
4781a3e96b4Smacallan    }
4791a3e96b4Smacallan    return TRUE;
4801a3e96b4Smacallan}
4811a3e96b4Smacallan
4821a3e96b4Smacallan
4831a3e96b4Smacallanstatic Bool
4841a3e96b4SmacallanCG14ShadowInit(ScreenPtr pScreen)
4851a3e96b4Smacallan{
4861a3e96b4Smacallan    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
4871a3e96b4Smacallan    Cg14Ptr pCg14 = GET_CG14_FROM_SCRN(pScrn);
4881a3e96b4Smacallan
4891a3e96b4Smacallan    if (!shadowSetup(pScreen)) {
4901a3e96b4Smacallan	return FALSE;
4911a3e96b4Smacallan    }
4921a3e96b4Smacallan
4931a3e96b4Smacallan    pCg14->CreateScreenResources = pScreen->CreateScreenResources;
4941a3e96b4Smacallan    pScreen->CreateScreenResources = CG14CreateScreenResources;
4951a3e96b4Smacallan
4961a3e96b4Smacallan    return TRUE;
4971a3e96b4Smacallan}
498f7ec340bSmacallan/* Mandatory */
499f7ec340bSmacallan
500f7ec340bSmacallan/* This gets called at the start of each server generation */
501f7ec340bSmacallan
502f7ec340bSmacallanstatic Bool
5037a5333bcSmrgCG14ScreenInit(SCREEN_INIT_ARGS_DECL)
504f7ec340bSmacallan{
5057a5333bcSmrg    ScrnInfoPtr pScrn;
5067a5333bcSmrg    Cg14Ptr pCg14;
507f7ec340bSmacallan    VisualPtr visual;
508f7ec340bSmacallan    int ret;
509f7ec340bSmacallan
5107a5333bcSmrg    /*
5117a5333bcSmrg     * First get the ScrnInfoRec
5127a5333bcSmrg     */
5137a5333bcSmrg    pScrn = xf86ScreenToScrn(pScreen);
5147a5333bcSmrg
5157a5333bcSmrg    pCg14 = GET_CG14_FROM_SCRN(pScrn);
5167a5333bcSmrg
517f7ec340bSmacallan    /* Map the CG14 memory */
518f7ec340bSmacallan    pCg14->fb = xf86MapSbusMem (pCg14->psdp, CG14_BGR_VOFF, 4 *
519f7ec340bSmacallan				(pCg14->psdp->width * pCg14->psdp->height));
520f7ec340bSmacallan    pCg14->x32 = xf86MapSbusMem (pCg14->psdp, CG14_X32_VOFF,
521f7ec340bSmacallan				 (pCg14->psdp->width * pCg14->psdp->height));
522f7ec340bSmacallan    pCg14->xlut = xf86MapSbusMem (pCg14->psdp, CG14_XLUT_VOFF, 4096);
5231a3e96b4Smacallan    pCg14->curs = xf86MapSbusMem (pCg14->psdp, CG14_CURSOR_VOFF, 4096);
524f7ec340bSmacallan
5251a3e96b4Smacallan    pCg14->width = pCg14->psdp->width;
5261a3e96b4Smacallan    pCg14->height = pCg14->psdp->height;
5271a3e96b4Smacallan
5281a3e96b4Smacallan    if (! pCg14->fb || !pCg14->x32 || !pCg14->xlut || !pCg14->curs) {
5291a3e96b4Smacallan    	xf86Msg(X_ERROR,
5301a3e96b4Smacallan	    "can't mmap something: fd %08x  x32 %08x xlut %08x cursor %08x\n",
5311a3e96b4Smacallan	    (uint32_t)pCg14->fb, (uint32_t)pCg14->x32, (uint32_t)pCg14->xlut,
5321a3e96b4Smacallan	    (uint32_t)pCg14->curs);
533f7ec340bSmacallan	return FALSE;
534b73528caSmacallan    }
535f7ec340bSmacallan
536f7ec340bSmacallan    /* Darken the screen for aesthetic reasons and set the viewport */
537f7ec340bSmacallan    CG14SaveScreen(pScreen, SCREEN_SAVER_ON);
538f7ec340bSmacallan
539f7ec340bSmacallan    /*
540f7ec340bSmacallan     * The next step is to setup the screen's visuals, and initialise the
541f7ec340bSmacallan     * framebuffer code.  In cases where the framebuffer's default
542f7ec340bSmacallan     * choices for things like visual layouts and bits per RGB are OK,
543f7ec340bSmacallan     * this may be as simple as calling the framebuffer's ScreenInit()
544f7ec340bSmacallan     * function.  If not, the visuals will need to be setup before calling
545f7ec340bSmacallan     * a fb ScreenInit() function and fixed up after.
546f7ec340bSmacallan     */
547f7ec340bSmacallan
548f7ec340bSmacallan    /*
549f7ec340bSmacallan     * Reset visual list.
550f7ec340bSmacallan     */
551f7ec340bSmacallan    miClearVisualTypes();
552f7ec340bSmacallan
553f7ec340bSmacallan    /* Setup the visuals we support. */
554f7ec340bSmacallan
555f7ec340bSmacallan    if (!miSetVisualTypes(pScrn->depth, TrueColorMask,
556f7ec340bSmacallan			  pScrn->rgbBits, pScrn->defaultVisual))
557f7ec340bSmacallan	return FALSE;
558f7ec340bSmacallan
559f7ec340bSmacallan    miSetPixmapDepths ();
560f7ec340bSmacallan
5611a3e96b4Smacallan    if (pCg14->use_shadow) {
5621a3e96b4Smacallan	pCg14->shadow = xcalloc(1, pScrn->virtualX * pScrn->virtualY * 4);
5631a3e96b4Smacallan
5641a3e96b4Smacallan	if (!pCg14->shadow) {
5651a3e96b4Smacallan	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
5661a3e96b4Smacallan	        "Failed to allocate shadow framebuffer\n");
5671a3e96b4Smacallan	    return FALSE;
5681a3e96b4Smacallan	}
5691a3e96b4Smacallan    }
5701a3e96b4Smacallan
571f7ec340bSmacallan    /*
572f7ec340bSmacallan     * Call the framebuffer layer's ScreenInit function, and fill in other
573f7ec340bSmacallan     * pScreen fields.
574f7ec340bSmacallan     */
575f7ec340bSmacallan
576f7ec340bSmacallan    CG14InitCplane24(pScrn);
5771a3e96b4Smacallan    ret = fbScreenInit(pScreen, pCg14->use_shadow ? pCg14->shadow : pCg14->fb,
5781a3e96b4Smacallan    		       pScrn->virtualX,
579f7ec340bSmacallan		       pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
580f7ec340bSmacallan		       pScrn->virtualX, pScrn->bitsPerPixel);
581f7ec340bSmacallan
582f7ec340bSmacallan    if (!ret)
583f7ec340bSmacallan	return FALSE;
584f7ec340bSmacallan
5857a5333bcSmrg#if 0
5861a3e96b4Smacallan    /* must be after RGB ordering fixed */
5871a3e96b4Smacallan    fbPictureInit (pScreen, 0, 0);
5881a3e96b4Smacallan
5891a3e96b4Smacallan    if (pCg14->use_shadow && !CG14ShadowInit(pScreen)) {
5901a3e96b4Smacallan	xf86DrvMsg(scrnIndex, X_ERROR,
5911a3e96b4Smacallan		    "shadow framebuffer initialization failed\n");
5921a3e96b4Smacallan	return FALSE;
5931a3e96b4Smacallan    }
5941a3e96b4Smacallan
595f7ec340bSmacallan    miInitializeBackingStore(pScreen);
5967a5333bcSmrg#endif
5977a5333bcSmrg
598f7ec340bSmacallan    xf86SetBackingStore(pScreen);
599f7ec340bSmacallan    xf86SetSilkenMouse(pScreen);
600f7ec340bSmacallan
601f7ec340bSmacallan    xf86SetBlackWhitePixels(pScreen);
602f7ec340bSmacallan
603f7ec340bSmacallan    if (pScrn->bitsPerPixel > 8) {
604f7ec340bSmacallan	/* Fixup RGB ordering */
605f7ec340bSmacallan	visual = pScreen->visuals + pScreen->numVisuals;
606f7ec340bSmacallan	while (--visual >= pScreen->visuals) {
607f7ec340bSmacallan	    if ((visual->class | DynamicClass) == DirectColor) {
608f7ec340bSmacallan		visual->offsetRed = pScrn->offset.red;
609f7ec340bSmacallan		visual->offsetGreen = pScrn->offset.green;
610f7ec340bSmacallan		visual->offsetBlue = pScrn->offset.blue;
611f7ec340bSmacallan		visual->redMask = pScrn->mask.red;
612f7ec340bSmacallan		visual->greenMask = pScrn->mask.green;
613f7ec340bSmacallan		visual->blueMask = pScrn->mask.blue;
614f7ec340bSmacallan	    }
615f7ec340bSmacallan	}
616f7ec340bSmacallan    }
617f7ec340bSmacallan
618f7ec340bSmacallan    /* Initialise cursor functions */
619f7ec340bSmacallan    miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
620f7ec340bSmacallan
6211a3e96b4Smacallan    /* check for hardware cursor support */
6221a3e96b4Smacallan    if (pCg14->HWCursor)
6231a3e96b4Smacallan	CG14SetupCursor(pScreen);
6241a3e96b4Smacallan
625f7ec340bSmacallan    /* Initialise default colourmap */
626f7ec340bSmacallan    if (!miCreateDefColormap(pScreen))
627f7ec340bSmacallan	return FALSE;
628f7ec340bSmacallan
629f7ec340bSmacallan    pCg14->CloseScreen = pScreen->CloseScreen;
630f7ec340bSmacallan    pScreen->CloseScreen = CG14CloseScreen;
631f7ec340bSmacallan    pScreen->SaveScreen = CG14SaveScreen;
632f7ec340bSmacallan
633f7ec340bSmacallan    /* Report any unused options (only for the first generation) */
634f7ec340bSmacallan    if (serverGeneration == 1) {
635f7ec340bSmacallan	xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
636f7ec340bSmacallan    }
637f7ec340bSmacallan
638f7ec340bSmacallan    /* unblank the screen */
639f7ec340bSmacallan    CG14SaveScreen(pScreen, SCREEN_SAVER_OFF);
640f7ec340bSmacallan
641f7ec340bSmacallan    /* Done */
642f7ec340bSmacallan    return TRUE;
643f7ec340bSmacallan}
644f7ec340bSmacallan
645f7ec340bSmacallan
646f7ec340bSmacallan/* Usually mandatory */
647f7ec340bSmacallanstatic Bool
6487a5333bcSmrgCG14SwitchMode(SWITCH_MODE_ARGS_DECL)
649f7ec340bSmacallan{
650b73528caSmacallan    xf86Msg(X_ERROR, "CG14SwitchMode\n");
651f7ec340bSmacallan    return TRUE;
652f7ec340bSmacallan}
653f7ec340bSmacallan
654f7ec340bSmacallan
655f7ec340bSmacallan/*
656f7ec340bSmacallan * This function is used to initialize the Start Address - the first
657f7ec340bSmacallan * displayed location in the video memory.
658f7ec340bSmacallan */
659f7ec340bSmacallan/* Usually mandatory */
660f7ec340bSmacallanstatic void
6617a5333bcSmrgCG14AdjustFrame(ADJUST_FRAME_ARGS_DECL)
662f7ec340bSmacallan{
663f7ec340bSmacallan    /* we don't support virtual desktops */
664f7ec340bSmacallan    return;
665f7ec340bSmacallan}
666f7ec340bSmacallan
667f7ec340bSmacallan/*
668f7ec340bSmacallan * This is called when VT switching back to the X server.  Its job is
669f7ec340bSmacallan * to reinitialise the video mode.
670f7ec340bSmacallan */
671f7ec340bSmacallan
672f7ec340bSmacallan/* Mandatory */
673f7ec340bSmacallanstatic Bool
6747a5333bcSmrgCG14EnterVT(VT_FUNC_ARGS_DECL)
675f7ec340bSmacallan{
6767a5333bcSmrg    SCRN_INFO_PTR(arg);
677f7ec340bSmacallan
678f7ec340bSmacallan    CG14InitCplane24 (pScrn);
679f7ec340bSmacallan    return TRUE;
680f7ec340bSmacallan}
681f7ec340bSmacallan
682f7ec340bSmacallan
683f7ec340bSmacallan/*
684f7ec340bSmacallan * This is called when VT switching away from the X server.
685f7ec340bSmacallan */
686f7ec340bSmacallan
687f7ec340bSmacallan/* Mandatory */
688f7ec340bSmacallanstatic void
6897a5333bcSmrgCG14LeaveVT(VT_FUNC_ARGS_DECL)
690f7ec340bSmacallan{
6917a5333bcSmrg    SCRN_INFO_PTR(arg);
692f7ec340bSmacallan
693f7ec340bSmacallan    CG14ExitCplane24 (pScrn);
694f7ec340bSmacallan    return;
695f7ec340bSmacallan}
696f7ec340bSmacallan
697f7ec340bSmacallan
698f7ec340bSmacallan/*
699f7ec340bSmacallan * This is called at the end of each server generation.  It restores the
700f7ec340bSmacallan * original (text) mode.  It should really also unmap the video memory too.
701f7ec340bSmacallan */
702f7ec340bSmacallan
703f7ec340bSmacallan/* Mandatory */
704f7ec340bSmacallanstatic Bool
7057a5333bcSmrgCG14CloseScreen(CLOSE_SCREEN_ARGS_DECL)
706f7ec340bSmacallan{
7077a5333bcSmrg    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
708f7ec340bSmacallan    Cg14Ptr pCg14 = GET_CG14_FROM_SCRN(pScrn);
7091a3e96b4Smacallan    PixmapPtr pPixmap;
7101a3e96b4Smacallan
7111a3e96b4Smacallan    if (pCg14->use_shadow) {
7121a3e96b4Smacallan
7131a3e96b4Smacallan	pPixmap = pScreen->GetScreenPixmap(pScreen);
7141a3e96b4Smacallan	shadowRemove(pScreen, pPixmap);
7151a3e96b4Smacallan	pCg14->use_shadow = FALSE;
7161a3e96b4Smacallan    }
717f7ec340bSmacallan
718f7ec340bSmacallan    pScrn->vtSema = FALSE;
719b73528caSmacallan    CG14ExitCplane24 (pScrn);
720f7ec340bSmacallan    xf86UnmapSbusMem(pCg14->psdp, pCg14->fb,
721f7ec340bSmacallan		     (pCg14->psdp->width * pCg14->psdp->height * 4));
722f7ec340bSmacallan    xf86UnmapSbusMem(pCg14->psdp, pCg14->x32,
723f7ec340bSmacallan		     (pCg14->psdp->width * pCg14->psdp->height));
724f7ec340bSmacallan    xf86UnmapSbusMem(pCg14->psdp, pCg14->xlut, 4096);
7251a3e96b4Smacallan    xf86UnmapSbusMem(pCg14->psdp, pCg14->curs, 4096);
726f7ec340bSmacallan
727f7ec340bSmacallan    pScreen->CloseScreen = pCg14->CloseScreen;
7287a5333bcSmrg    return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS);
729f7ec340bSmacallan}
730f7ec340bSmacallan
7311a3e96b4Smacallanstatic void *
7321a3e96b4SmacallanCG14WindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode,
7331a3e96b4Smacallan		CARD32 *size, void *closure)
7341a3e96b4Smacallan{
7351a3e96b4Smacallan    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
7361a3e96b4Smacallan    Cg14Ptr pCg14 = GET_CG14_FROM_SCRN(pScrn);
7371a3e96b4Smacallan
7381a3e96b4Smacallan    *size = pCg14->width << 2;
7391a3e96b4Smacallan    return (CARD8 *)pCg14->fb + row * (pCg14->width << 2) + offset;
7401a3e96b4Smacallan}
741f7ec340bSmacallan
742f7ec340bSmacallan/* Free up any per-generation data structures */
743f7ec340bSmacallan
744f7ec340bSmacallan/* Optional */
745f7ec340bSmacallanstatic void
7467a5333bcSmrgCG14FreeScreen(FREE_SCREEN_ARGS_DECL)
747f7ec340bSmacallan{
7487a5333bcSmrg    SCRN_INFO_PTR(arg);
7497a5333bcSmrg    CG14FreeRec(pScrn);
750f7ec340bSmacallan}
751f7ec340bSmacallan
752f7ec340bSmacallan
753f7ec340bSmacallan/* Checks if a mode is suitable for the selected chipset. */
754f7ec340bSmacallan
755f7ec340bSmacallan/* Optional */
756f7ec340bSmacallanstatic ModeStatus
7577a5333bcSmrgCG14ValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags)
758f7ec340bSmacallan{
759f7ec340bSmacallan    if (mode->Flags & V_INTERLACE)
760f7ec340bSmacallan	return(MODE_BAD);
761f7ec340bSmacallan
762f7ec340bSmacallan    return(MODE_OK);
763f7ec340bSmacallan}
764f7ec340bSmacallan
765f7ec340bSmacallan/* Do screen blanking */
766f7ec340bSmacallan
767f7ec340bSmacallan/* Mandatory */
768f7ec340bSmacallanstatic Bool
769f7ec340bSmacallanCG14SaveScreen(ScreenPtr pScreen, int mode)
770f7ec340bSmacallan{
7711bd6d369Smacallan    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
7721bd6d369Smacallan    Cg14Ptr pCg14 = GET_CG14_FROM_SCRN(pScrn);
7731bd6d369Smacallan    int state;
7741bd6d369Smacallan    switch(mode) {
7751bd6d369Smacallan	case SCREEN_SAVER_ON:
7761bd6d369Smacallan	case SCREEN_SAVER_CYCLE:
7771bd6d369Smacallan		state = FBVIDEO_OFF;
7781bd6d369Smacallan		ioctl(pCg14->psdp->fd, FBIOSVIDEO, &state);
7791bd6d369Smacallan		break;
7801bd6d369Smacallan	case SCREEN_SAVER_OFF:
7811bd6d369Smacallan	case SCREEN_SAVER_FORCER:
7821bd6d369Smacallan		state = FBVIDEO_ON;
7831bd6d369Smacallan		ioctl(pCg14->psdp->fd, FBIOSVIDEO, &state);
7841bd6d369Smacallan		break;
7851bd6d369Smacallan	default:
7861bd6d369Smacallan		return FALSE;
7871bd6d369Smacallan    }
788f7ec340bSmacallan    return TRUE;
789f7ec340bSmacallan}
790f7ec340bSmacallan
791f7ec340bSmacallan/*
792f7ec340bSmacallan * This is the implementation of the Sync() function.
793f7ec340bSmacallan */
794f7ec340bSmacallanvoid
795f7ec340bSmacallanCG14Sync(ScrnInfoPtr pScrn)
796f7ec340bSmacallan{
797f7ec340bSmacallan    return;
798f7ec340bSmacallan}
799f7ec340bSmacallan
800f7ec340bSmacallan/*
801f7ec340bSmacallan * This initializes the card for 24 bit mode.
802f7ec340bSmacallan */
803f7ec340bSmacallanstatic void
804f7ec340bSmacallanCG14InitCplane24(ScrnInfoPtr pScrn)
805f7ec340bSmacallan{
806f7ec340bSmacallan  Cg14Ptr pCg14 = GET_CG14_FROM_SCRN(pScrn);
807f7ec340bSmacallan  int size, bpp;
808f7ec340bSmacallan
809f7ec340bSmacallan  size = pScrn->virtualX * pScrn->virtualY;
810f7ec340bSmacallan  bpp = 32;
811f7ec340bSmacallan  ioctl (pCg14->psdp->fd, CG14_SET_PIXELMODE, &bpp);
812f7ec340bSmacallan  memset (pCg14->fb, 0, size * 4);
813f7ec340bSmacallan  memset (pCg14->x32, 0, size);
814f7ec340bSmacallan  memset (pCg14->xlut, 0, 0x200);
815f7ec340bSmacallan}
816f7ec340bSmacallan
817f7ec340bSmacallan/*
818f7ec340bSmacallan * This initializes the card for 8 bit mode.
819f7ec340bSmacallan */
820f7ec340bSmacallanstatic void
821f7ec340bSmacallanCG14ExitCplane24(ScrnInfoPtr pScrn)
822f7ec340bSmacallan{
823f7ec340bSmacallan  Cg14Ptr pCg14 = GET_CG14_FROM_SCRN(pScrn);
824f7ec340bSmacallan  int bpp = 8;
825f7ec340bSmacallan
826f7ec340bSmacallan  ioctl (pCg14->psdp->fd, CG14_SET_PIXELMODE, &bpp);
8271bd6d369Smacallan}
828