1ab47cfaaSmrg/*
2ab47cfaaSmrg * Copyright (C) 1994-2000 The XFree86 Project, Inc.  All Rights Reserved.
3ab47cfaaSmrg * Copyright (c) 2003-2006, X.Org Foundation
4ab47cfaaSmrg *
5ab47cfaaSmrg * Permission is hereby granted, free of charge, to any person obtaining a
6ab47cfaaSmrg * copy of this software and associated documentation files (the "Software"),
7ab47cfaaSmrg * to deal in the Software without restriction, including without limitation
8ab47cfaaSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9ab47cfaaSmrg * and/or sell copies of the Software, and to permit persons to whom the
10ab47cfaaSmrg * Software is furnished to do so, subject to the following conditions:
11ab47cfaaSmrg *
12ab47cfaaSmrg * The above copyright notice and this permission notice shall be included in
13ab47cfaaSmrg * all copies or substantial portions of the Software.
14ab47cfaaSmrg *
15ab47cfaaSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16ab47cfaaSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17ab47cfaaSmrg * FITESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
18ab47cfaaSmrg * COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19ab47cfaaSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20ab47cfaaSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21ab47cfaaSmrg * DEALINGS IN THE SOFTWARE.
22ab47cfaaSmrg *
23ab47cfaaSmrg * Except as contained in this notice, the name of the copyright holder(s)
24ab47cfaaSmrg * and author(s) shall not be used in advertising or otherwise to promote
25ab47cfaaSmrg * the sale, use or other dealings in this Software without prior written
26ab47cfaaSmrg * authorization from the copyright holder(s) and author(s).
27ab47cfaaSmrg */
28ab47cfaaSmrg
29ab47cfaaSmrg/**
30ab47cfaaSmrg * \file savage_cursor.c
31ab47cfaaSmrg * Hardware cursor support for S3 Savage driver. Taken with very few changes
32ab47cfaaSmrg * from the s3virge cursor file.
33ab47cfaaSmrg *
34ab47cfaaSmrg * \author S. Marineau (19/04/97)
35ab47cfaaSmrg * \author Amancio Hasty
36ab47cfaaSmrg * \author Jon Tombs
37ab47cfaaSmrg * \author Tim Roberts
38ab47cfaaSmrg */
39ab47cfaaSmrg
40ab47cfaaSmrg#ifdef HAVE_CONFIG_H
41ab47cfaaSmrg#include "config.h"
42ab47cfaaSmrg#endif
43ab47cfaaSmrg
44ab47cfaaSmrg#include "savage_driver.h"
45ab47cfaaSmrg
46ab47cfaaSmrgstatic void SavageLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src);
47ab47cfaaSmrgstatic void SavageSetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
48ab47cfaaSmrgstatic void SavageSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);
49ab47cfaaSmrg
50ab47cfaaSmrg
51ab47cfaaSmrg/*
52ab47cfaaSmrg * Read/write to the DAC via MMIO
53ab47cfaaSmrg */
54ab47cfaaSmrg
55ab47cfaaSmrg#define inCRReg(reg) (VGAHWPTR(pScrn))->readCrtc( VGAHWPTR(pScrn), reg )
56ab47cfaaSmrg#define outCRReg(reg, val) (VGAHWPTR(pScrn))->writeCrtc( VGAHWPTR(pScrn), reg, val )
57ab47cfaaSmrg#define inSRReg(reg) (VGAHWPTR(pScrn))->readSeq( VGAHWPTR(pScrn), reg )
58ab47cfaaSmrg#define outSRReg(reg, val) (VGAHWPTR(pScrn))->writeSeq( VGAHWPTR(pScrn), reg, val )
59ab47cfaaSmrg#if 0
60ab47cfaaSmrg#define inStatus1() (VGAHWPTR(pScrn))->readST01( VGAHWPTR(pScrn) )
61ab47cfaaSmrg#endif
62ab47cfaaSmrg
63ab47cfaaSmrg/*
64ab47cfaaSmrg * certain HW cursor operations seem
65ab47cfaaSmrg * to require a delay to prevent lockups.
66ab47cfaaSmrg */
67ab47cfaaSmrg#define waitHSync(n) { \
68ab47cfaaSmrg                       int num = n; \
69ab47cfaaSmrg                       while (num--) { \
70aa9e3350Smrg			 while (inStatus1() & 0x01){};\
71aa9e3350Smrg                         while (!(inStatus1() & 0x01)){};\
72ab47cfaaSmrg                        } \
73ab47cfaaSmrg                      }
74ab47cfaaSmrg#define MAX_CURS 64
75ab47cfaaSmrg
76ab47cfaaSmrg/*
77ab47cfaaSmrg * Disable HW Cursor on stretched LCDs. We don't know how to
78ab47cfaaSmrg * detect if display is stretched. Therefore we cannot rescale
79ab47cfaaSmrg * the HW cursor position.
80ab47cfaaSmrg */
81ab47cfaaSmrg
82aa9e3350Smrg#if 0
83ab47cfaaSmrgstatic Bool
84ab47cfaaSmrgSavageUseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
85ab47cfaaSmrg{
86aa9e3350Smrg    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScr);
87ab47cfaaSmrg    SavagePtr psav = SAVPTR(pScrn);
88ab47cfaaSmrg
89ab47cfaaSmrg    if (psav->PanelX != pScrn->currentMode->HDisplay
90ab47cfaaSmrg	|| psav->PanelY != pScrn->currentMode->VDisplay) {
91ab47cfaaSmrg	/* BIT 1 : CRT is active, BIT 2 : LCD is active */
92ab47cfaaSmrg	unsigned char cr6d = inCRReg( 0x6d );
93ab47cfaaSmrg	if (cr6d & 0x02)
94ab47cfaaSmrg	    return FALSE;
95ab47cfaaSmrg    }
96ab47cfaaSmrg    return TRUE;
97ab47cfaaSmrg}
98aa9e3350Smrg#endif
99ab47cfaaSmrg
100ab47cfaaSmrgBool
101ab47cfaaSmrgSavageHWCursorInit(ScreenPtr pScreen)
102ab47cfaaSmrg{
103aa9e3350Smrg    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
104ab47cfaaSmrg    SavagePtr psav = SAVPTR(pScrn);
105ab47cfaaSmrg    xf86CursorInfoPtr infoPtr;
106ab47cfaaSmrg
107ab47cfaaSmrg    infoPtr = xf86CreateCursorInfoRec();
108ab47cfaaSmrg    if(!infoPtr)
109ab47cfaaSmrg        return FALSE;
110ab47cfaaSmrg
111ab47cfaaSmrg    psav->CursorInfoRec = infoPtr;
112ab47cfaaSmrg
113ab47cfaaSmrg    infoPtr->MaxWidth = MAX_CURS;
114ab47cfaaSmrg    infoPtr->MaxHeight = MAX_CURS;
115ab47cfaaSmrg    infoPtr->Flags = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 |
116ab47cfaaSmrg		     HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK |
117ab47cfaaSmrg		     HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
118ab47cfaaSmrg		     HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
119ab47cfaaSmrg	             HARDWARE_CURSOR_INVERT_MASK;
120ab47cfaaSmrg#if 0
121ab47cfaaSmrg    /*
122ab47cfaaSmrg     * The /MX family is apparently unique among the Savages, in that
123ab47cfaaSmrg     * the cursor color is always straight RGB.  The rest of the Savages
124ab47cfaaSmrg     * use palettized values at 8-bit when not clock doubled.
125ab47cfaaSmrg     */
126ab47cfaaSmrg
127ab47cfaaSmrg    if (((psav->Chipset != S3_SAVAGE4)
128ab47cfaaSmrg	 && (inSRReg(0x18) & 0x80) && (inSRReg(0x15) & 0x50))
129ab47cfaaSmrg	|| S3_SAVAGE_MOBILE_SERIES(psav->Chipset))
130ab47cfaaSmrg	infoPtr->Flags |= HARDWARE_CURSOR_TRUECOLOR_AT_8BPP;
131ab47cfaaSmrg#endif
132ab47cfaaSmrg    /*
133ab47cfaaSmrg     * With streams engine the Cursor seems to be ALWAYS TrueColor
134ab47cfaaSmrg     *except at least the Savage4
135ab47cfaaSmrg     */
136ab47cfaaSmrg    if (psav->Chipset != S3_SAVAGE4)
137ab47cfaaSmrg	infoPtr->Flags |= HARDWARE_CURSOR_TRUECOLOR_AT_8BPP;
138ab47cfaaSmrg
139ab47cfaaSmrg    infoPtr->SetCursorColors = SavageSetCursorColors;
140ab47cfaaSmrg    infoPtr->SetCursorPosition = SavageSetCursorPosition;
141ab47cfaaSmrg    infoPtr->LoadCursorImage = SavageLoadCursorImage;
142ab47cfaaSmrg    infoPtr->HideCursor = SavageHideCursor;
143ab47cfaaSmrg    infoPtr->ShowCursor = SavageShowCursor;
144ab47cfaaSmrg    infoPtr->UseHWCursor = NULL;
145ab47cfaaSmrg#if 0 /*AGD:  HW cursor seems to work fine even with expansion... */
146ab47cfaaSmrg    if ((S3_SAVAGE_MOBILE_SERIES(psav->Chipset)
147ab47cfaaSmrg	 || (S3_MOBILE_TWISTER_SERIES(psav->Chipset))) && !psav->CrtOnly)
148ab47cfaaSmrg	infoPtr->UseHWCursor = SavageUseHWCursor;
149ab47cfaaSmrg    else
150ab47cfaaSmrg	infoPtr->UseHWCursor = NULL;
151ab47cfaaSmrg#endif
152ab47cfaaSmrg    if( !psav->CursorKByte )
153ab47cfaaSmrg	psav->CursorKByte = pScrn->videoRam - 4;
154ab47cfaaSmrg
155ab47cfaaSmrg    return xf86InitCursor(pScreen, infoPtr);
156ab47cfaaSmrg}
157ab47cfaaSmrg
158ab47cfaaSmrgvoid
159ab47cfaaSmrgSavageShowCursor(ScrnInfoPtr pScrn)
160ab47cfaaSmrg{
161ab47cfaaSmrg    SavagePtr psav = SAVPTR(pScrn);
162ab47cfaaSmrg
163ab47cfaaSmrg   /* Turn cursor on. */
164ab47cfaaSmrg   if (psav->IsSecondary) {
165ab47cfaaSmrg       SelectIGA2();
166ab47cfaaSmrg       outCRReg( 0x45, inCRReg(0x45) | 0x01 );
167ab47cfaaSmrg       SelectIGA1();
168ab47cfaaSmrg   } else {
169ab47cfaaSmrg       outCRReg( 0x45, inCRReg(0x45) | 0x01 );
170ab47cfaaSmrg   }
171ab47cfaaSmrg   SAVPTR(pScrn)->hwc_on = TRUE;
172ab47cfaaSmrg}
173ab47cfaaSmrg
174ab47cfaaSmrg
175ab47cfaaSmrgvoid
176ab47cfaaSmrgSavageHideCursor(ScrnInfoPtr pScrn)
177ab47cfaaSmrg{
178ab47cfaaSmrg    SavagePtr psav = SAVPTR(pScrn);
179ab47cfaaSmrg
180ab47cfaaSmrg    /* Turn cursor off. */
181ab47cfaaSmrg
182ab47cfaaSmrg    if( S3_SAVAGE4_SERIES( SAVPTR(pScrn)->Chipset ) )
183ab47cfaaSmrg    {
184ab47cfaaSmrg       waitHSync(5);
185ab47cfaaSmrg    }
186ab47cfaaSmrg    if (psav->IsSecondary) {
187ab47cfaaSmrg        SelectIGA2();
188ab47cfaaSmrg	outCRReg( 0x45, inCRReg(0x45) & 0xfe ); /* cursor2 */
189ab47cfaaSmrg	SelectIGA1();
190ab47cfaaSmrg    } else {
191ab47cfaaSmrg        outCRReg( 0x45, inCRReg(0x45) & 0xfe );
192ab47cfaaSmrg    }
193ab47cfaaSmrg    SAVPTR(pScrn)->hwc_on = FALSE;
194ab47cfaaSmrg}
195ab47cfaaSmrg
196ab47cfaaSmrgstatic void
197ab47cfaaSmrgSavageLoadCursorImage(
198ab47cfaaSmrg    ScrnInfoPtr pScrn,
199ab47cfaaSmrg    unsigned char* src)
200ab47cfaaSmrg{
201ab47cfaaSmrg    SavagePtr psav = SAVPTR(pScrn);
202ab47cfaaSmrg
203ab47cfaaSmrg    /* Set cursor location in frame buffer.  */
204ab47cfaaSmrg    if (psav->IsSecondary) {
205ab47cfaaSmrg	SelectIGA2();
206ab47cfaaSmrg    	/* Set cursor location in frame buffer.  */
207ab47cfaaSmrg    	outCRReg( 0x4d, (0xff & psav->CursorKByte));
208ab47cfaaSmrg    	outCRReg( 0x4c, (0xff00 & psav->CursorKByte) >> 8);
209ab47cfaaSmrg	SelectIGA1();
210ab47cfaaSmrg    } else {
211ab47cfaaSmrg        outCRReg( 0x4d, (0xff & (CARD32)psav->CursorKByte));
212ab47cfaaSmrg        outCRReg( 0x4c, (0xff00 & (CARD32)psav->CursorKByte) >> 8);
213ab47cfaaSmrg    }
214ab47cfaaSmrg
215ab47cfaaSmrg    /* Upload the cursor image to the frame buffer. */
216ab47cfaaSmrg    memcpy(psav->FBBase + psav->CursorKByte * 1024, src, 1024);
217ab47cfaaSmrg
218ab47cfaaSmrg    if( S3_SAVAGE4_SERIES( psav->Chipset ) ) {
219ab47cfaaSmrg	/*
220ab47cfaaSmrg	 * Bug in Savage4 Rev B requires us to do an MMIO read after
221ab47cfaaSmrg	 * loading the cursor.
222ab47cfaaSmrg	 */
223ab47cfaaSmrg	volatile unsigned int i = ALT_STATUS_WORD0;
224ab47cfaaSmrg	(void)i++;	/* Not to be optimised out */
225ab47cfaaSmrg    }
226ab47cfaaSmrg}
227ab47cfaaSmrg
228ab47cfaaSmrgstatic void
229ab47cfaaSmrgSavageSetCursorPosition(
230ab47cfaaSmrg     ScrnInfoPtr pScrn,
231ab47cfaaSmrg     int x,
232ab47cfaaSmrg     int y)
233ab47cfaaSmrg{
234ab47cfaaSmrg    SavagePtr psav = SAVPTR(pScrn);
235ab47cfaaSmrg    unsigned char xoff, yoff, byte;
236ab47cfaaSmrg
237ab47cfaaSmrg    if( S3_SAVAGE4_SERIES( SAVPTR(pScrn)->Chipset ) )
238ab47cfaaSmrg    {
239ab47cfaaSmrg	waitHSync(5);
240ab47cfaaSmrg    }
241ab47cfaaSmrg    /* adjust for frame buffer base address granularity */
242ab47cfaaSmrg    if (pScrn->bitsPerPixel == 8)
243ab47cfaaSmrg	x += ((pScrn->frameX0) & 3);
244ab47cfaaSmrg    else if (pScrn->bitsPerPixel == 16)
245ab47cfaaSmrg	x += ((pScrn->frameX0) & 1);
246ab47cfaaSmrg    else if (pScrn->bitsPerPixel == 32)
247ab47cfaaSmrg	x += ((pScrn->frameX0+2) & 3) - 2;
248ab47cfaaSmrg
249ab47cfaaSmrg    /*
250ab47cfaaSmrg    * Make these even when used.  There is a bug/feature on at least
251ab47cfaaSmrg    * some chipsets that causes a "shadow" of the cursor in interlaced
252ab47cfaaSmrg    * mode.  Making this even seems to have no visible effect, so just
253ab47cfaaSmrg    * do it for the generic case.
254ab47cfaaSmrg    */
255ab47cfaaSmrg
256ab47cfaaSmrg    if (x < 0) {
257ab47cfaaSmrg	xoff = ((-x) & 0xFE);
258ab47cfaaSmrg	x = 0;
259ab47cfaaSmrg    } else {
260ab47cfaaSmrg	xoff = 0;
261ab47cfaaSmrg    }
262ab47cfaaSmrg
263ab47cfaaSmrg    if (y < 0) {
264ab47cfaaSmrg	yoff = ((-y) & 0xFE);
265ab47cfaaSmrg	y = 0;
266ab47cfaaSmrg    } else {
267ab47cfaaSmrg	yoff = 0;
268ab47cfaaSmrg    }
269ab47cfaaSmrg
2702b2b4fcbSmrg    /* This is the recommended order to move the cursor */
271ab47cfaaSmrg        if (psav->IsSecondary) {
272ab47cfaaSmrg	SelectIGA2();
273ab47cfaaSmrg    	outCRReg( 0x46, (x & 0xff00)>>8 );
274ab47cfaaSmrg    	outCRReg( 0x47, (x & 0xff) );
275ab47cfaaSmrg    	outCRReg( 0x49, (y & 0xff) );
276ab47cfaaSmrg    	outCRReg( 0x4e, xoff );
277ab47cfaaSmrg    	outCRReg( 0x4f, yoff );
278ab47cfaaSmrg    	outCRReg( 0x48, (y & 0xff00)>>8 );
279ab47cfaaSmrg	SelectIGA1();
280ab47cfaaSmrg    } else {
281ab47cfaaSmrg        outCRReg( 0x46, (x & 0xff00)>>8 );
282ab47cfaaSmrg        outCRReg( 0x47, (x & 0xff) );
283ab47cfaaSmrg        outCRReg( 0x49, (y & 0xff) );
284ab47cfaaSmrg        outCRReg( 0x4e, xoff );
285ab47cfaaSmrg        outCRReg( 0x4f, yoff );
286ab47cfaaSmrg        outCRReg( 0x48, (y & 0xff00)>>8 );
287ab47cfaaSmrg    }
288ab47cfaaSmrg
289ab47cfaaSmrg    /* fix for HW cursor on crtc2 */
290ab47cfaaSmrg    byte = inCRReg( 0x46 );
291ab47cfaaSmrg    outCRReg( 0x46, byte );
292ab47cfaaSmrg
293ab47cfaaSmrg}
294ab47cfaaSmrg
295ab47cfaaSmrg
296ab47cfaaSmrgstatic void
297ab47cfaaSmrgSavageSetCursorColors(
298ab47cfaaSmrg    ScrnInfoPtr pScrn,
299ab47cfaaSmrg    int bg,
300ab47cfaaSmrg    int fg)
301ab47cfaaSmrg{
302ab47cfaaSmrg    SavagePtr psav = SAVPTR(pScrn);
3032b2b4fcbSmrg#if 0
304ab47cfaaSmrg    Bool bNeedExtra = FALSE;
3052b2b4fcbSmrg#endif
306ab47cfaaSmrg
307ab47cfaaSmrg    /* Clock doubled modes need an extra cursor stack write. */
308ab47cfaaSmrg
3092b2b4fcbSmrg#if 0
310ab47cfaaSmrg    bNeedExtra =
311ab47cfaaSmrg        (psav->CursorInfoRec->Flags & HARDWARE_CURSOR_TRUECOLOR_AT_8BPP);
3122b2b4fcbSmrg#endif
313ab47cfaaSmrg
314ab47cfaaSmrg    /* With the streams engine on HW Cursor seems to be 24bpp ALWAYS */
315ab47cfaaSmrg    if( 1
316ab47cfaaSmrg#if 0
317ab47cfaaSmrg	|| S3_SAVAGE_MOBILE_SERIES(psav->Chipset) ||
318ab47cfaaSmrg 	(pScrn->depth == 24) ||
319ab47cfaaSmrg 	((pScrn->depth == 8) && bNeedExtra)
320ab47cfaaSmrg#endif
321ab47cfaaSmrg	)
322ab47cfaaSmrg    {
323ab47cfaaSmrg	/* Do it straight, full 24 bit color. */
324ab47cfaaSmrg       if (psav->IsSecondary) {
325ab47cfaaSmrg            /* cursor 2 */
326ab47cfaaSmrg	    /* Reset the cursor color stack pointer */
327ab47cfaaSmrg	    SelectIGA2();
328ab47cfaaSmrg	    inCRReg(0x45);
329ab47cfaaSmrg	    /* Write low, mid, high bytes - foreground */
330ab47cfaaSmrg	    outCRReg(0x4a, fg);
331ab47cfaaSmrg	    outCRReg(0x4a, fg >> 8);
332ab47cfaaSmrg	    outCRReg(0x4a, fg >> 16);
333ab47cfaaSmrg	    /* Reset the cursor color stack pointer */
334ab47cfaaSmrg	    inCRReg(0x45);
335ab47cfaaSmrg	    /* Write low, mid, high bytes - background */
336ab47cfaaSmrg	    outCRReg(0x4b, bg);
337ab47cfaaSmrg	    outCRReg(0x4b, bg >> 8);
338ab47cfaaSmrg	    outCRReg(0x4b, bg >> 16);
339ab47cfaaSmrg	    SelectIGA1();
340ab47cfaaSmrg	} else {
341ab47cfaaSmrg	    /* Reset the cursor color stack pointer */
342ab47cfaaSmrg	    inCRReg(0x45);
343ab47cfaaSmrg	    /* Write low, mid, high bytes - foreground */
344ab47cfaaSmrg	    outCRReg(0x4a, fg);
345ab47cfaaSmrg	    outCRReg(0x4a, fg >> 8);
346ab47cfaaSmrg	    outCRReg(0x4a, fg >> 16);
347ab47cfaaSmrg	    /* Reset the cursor color stack pointer */
348ab47cfaaSmrg	    inCRReg(0x45);
349ab47cfaaSmrg	    /* Write low, mid, high bytes - background */
350ab47cfaaSmrg	    outCRReg(0x4b, bg);
351ab47cfaaSmrg	    outCRReg(0x4b, bg >> 8);
352ab47cfaaSmrg	    outCRReg(0x4b, bg >> 16);
353ab47cfaaSmrg	}
354ab47cfaaSmrg	return;
355ab47cfaaSmrg    }
356ab47cfaaSmrg#if 0
357ab47cfaaSmrg    else if( (pScrn->depth == 15) || (pScrn->depth == 16) )
358ab47cfaaSmrg    {
359ab47cfaaSmrg	if (pScrn->depth == 15) {
360ab47cfaaSmrg	    fg = ((fg & 0xf80000) >> 9) |
361ab47cfaaSmrg		((fg & 0xf800) >> 6) |
362ab47cfaaSmrg		((fg & 0xf8) >> 3);
363ab47cfaaSmrg	    bg = ((bg & 0xf80000) >> 9) |
364ab47cfaaSmrg		((bg & 0xf800) >> 6) |
365ab47cfaaSmrg		((bg & 0xf8) >> 3);
366ab47cfaaSmrg	} else {
367ab47cfaaSmrg	    fg = ((fg & 0xf80000) >> 8) |
368ab47cfaaSmrg		((fg & 0xfc00) >> 5) |
369ab47cfaaSmrg		((fg & 0xf8) >> 3);
370ab47cfaaSmrg	    bg = ((bg & 0xf80000) >> 8) |
371ab47cfaaSmrg		((bg & 0xfc00) >> 5) |
372ab47cfaaSmrg		((bg & 0xf8) >> 3);
373ab47cfaaSmrg	}
374ab47cfaaSmrg	/* Reset the cursor color stack pointer */
375ab47cfaaSmrg        inCRReg( 0x45 );
376ab47cfaaSmrg        outCRReg( 0x4a, fg );
377ab47cfaaSmrg        outCRReg( 0x4a, fg>>8 );
378ab47cfaaSmrg	if( bNeedExtra )
379ab47cfaaSmrg	{
380ab47cfaaSmrg	    outCRReg( 0x4a, fg );
381ab47cfaaSmrg	    outCRReg( 0x4a, fg>>8 );
382ab47cfaaSmrg	}
383ab47cfaaSmrg	/* Reset the cursor color stack pointer */
384ab47cfaaSmrg        inCRReg( 0x45 );
385ab47cfaaSmrg        outCRReg( 0x4b, bg );
386ab47cfaaSmrg        outCRReg( 0x4b, bg>>8 );
387ab47cfaaSmrg	if( bNeedExtra )
388ab47cfaaSmrg	{
389ab47cfaaSmrg	    outCRReg( 0x4b, bg );
390ab47cfaaSmrg	    outCRReg( 0x4b, bg>>8 );
391ab47cfaaSmrg	}
392ab47cfaaSmrg    }
393ab47cfaaSmrg    else if( pScrn->depth == 8 )
394ab47cfaaSmrg    {
395ab47cfaaSmrg	/* Reset the cursor color stack pointer */
396ab47cfaaSmrg	inCRReg(0x45);
397ab47cfaaSmrg	/* Write foreground */
398ab47cfaaSmrg	outCRReg(0x4a, fg);
399ab47cfaaSmrg	outCRReg(0x4a, fg);
400ab47cfaaSmrg	/* Reset the cursor color stack pointer */
401ab47cfaaSmrg	inCRReg(0x45);
402ab47cfaaSmrg	/* Write background */
403ab47cfaaSmrg	outCRReg(0x4b, bg);
404ab47cfaaSmrg	outCRReg(0x4b, bg);
405ab47cfaaSmrg    }
406ab47cfaaSmrg#endif
407ab47cfaaSmrg}
408