1fe5e51b7Smrg#ifdef HAVE_CONFIG_H
2fe5e51b7Smrg#include "config.h"
3fe5e51b7Smrg#endif
4fe5e51b7Smrg
584354367Smrg#include <unistd.h>
684354367Smrg
7fe5e51b7Smrg#include "misc.h"
8fe5e51b7Smrg#include "xf86.h"
9fe5e51b7Smrg#include "xf86_OSproc.h"
10fe5e51b7Smrg#include "vgaHW.h"
11fe5e51b7Smrg#include "compiler.h"
12fe5e51b7Smrg#include "xf86cmap.h"
13fe5e51b7Smrg#include "mga.h"
14fe5e51b7Smrg#include "mga_reg.h"
15fe5e51b7Smrg
16fe5e51b7Smrg#define TEXT_AMOUNT 16384
17fe5e51b7Smrg#define FONT_AMOUNT (8*8192)
18fe5e51b7Smrg
19fe5e51b7Smrgvoid
20fe5e51b7SmrgMGAG200SERestoreFonts(ScrnInfoPtr scrninfp, vgaRegPtr restore)
21fe5e51b7Smrg{
22fe5e51b7Smrg    vgaHWPtr hwp = VGAHWPTR(scrninfp);
23fe5e51b7Smrg    MGAPtr pMga = MGAPTR(scrninfp);
24fe5e51b7Smrg    int savedIOBase;
25fe5e51b7Smrg    unsigned char miscOut, attr10, gr1, gr3, gr4, gr5, gr6, gr8, seq2, seq4;
26fe5e51b7Smrg    Bool doMap = FALSE;
27fe5e51b7Smrg    unsigned char scrn;
28fe5e51b7Smrg
29fe5e51b7Smrg    /* If nothing to do, return now */
30fe5e51b7Smrg    if (!hwp->FontInfo1 && !hwp->FontInfo2 && !hwp->TextInfo)
31fe5e51b7Smrg	return;
32fe5e51b7Smrg
33fe5e51b7Smrg    if (hwp->Base == NULL) {
34fe5e51b7Smrg	doMap = TRUE;
35fe5e51b7Smrg	if (!vgaHWMapMem(scrninfp)) {
36fe5e51b7Smrg	    xf86DrvMsg(scrninfp->scrnIndex, X_ERROR,
37fe5e51b7Smrg		    "vgaHWRestoreFonts: vgaHWMapMem() failed\n");
38fe5e51b7Smrg	    return;
39fe5e51b7Smrg	}
40fe5e51b7Smrg    }
41fe5e51b7Smrg
42fe5e51b7Smrg    /* save the registers that are needed here */
43fe5e51b7Smrg    miscOut = hwp->readMiscOut(hwp);
44fe5e51b7Smrg    attr10 = hwp->readAttr(hwp, 0x10);
45fe5e51b7Smrg    gr1 = hwp->readGr(hwp, 0x01);
46fe5e51b7Smrg    gr3 = hwp->readGr(hwp, 0x03);
47fe5e51b7Smrg    gr4 = hwp->readGr(hwp, 0x04);
48fe5e51b7Smrg    gr5 = hwp->readGr(hwp, 0x05);
49fe5e51b7Smrg    gr6 = hwp->readGr(hwp, 0x06);
50fe5e51b7Smrg    gr8 = hwp->readGr(hwp, 0x08);
51fe5e51b7Smrg    seq2 = hwp->readSeq(hwp, 0x02);
52fe5e51b7Smrg    seq4 = hwp->readSeq(hwp, 0x04);
53fe5e51b7Smrg
54fe5e51b7Smrg    /* save hwp->IOBase and temporarily set it for colour mode */
55fe5e51b7Smrg    savedIOBase = hwp->IOBase;
56fe5e51b7Smrg    hwp->IOBase = VGA_IOBASE_COLOR;
57fe5e51b7Smrg
58fe5e51b7Smrg    /* Force into colour mode */
59fe5e51b7Smrg    hwp->writeMiscOut(hwp, miscOut | 0x01);
60fe5e51b7Smrg
61fe5e51b7Smrg    scrn = hwp->readSeq(hwp, 0x01);
62fe5e51b7Smrg    scrn |= 0x20;/* blank screen */
63fe5e51b7Smrg    vgaHWSeqReset(hwp, TRUE);
64fe5e51b7Smrg    MGAWAITVSYNC();
65fe5e51b7Smrg    MGAWAITBUSY();
66fe5e51b7Smrg    hwp->writeSeq(hwp, 0x01, scrn);/* change mode */
67fe5e51b7Smrg    usleep(20000);
68fe5e51b7Smrg    vgaHWSeqReset(hwp, FALSE);
69fe5e51b7Smrg
70fe5e51b7Smrg    /*
71fe5e51b7Smrg     * here we temporarily switch to 16 colour planar mode, to simply
72fe5e51b7Smrg     * copy the font-info and saved text.
73fe5e51b7Smrg     *
74fe5e51b7Smrg     * BUG ALERT: The (S)VGA's segment-select register MUST be set correctly!
75fe5e51b7Smrg     */
76fe5e51b7Smrg#if 0
77fe5e51b7Smrg    hwp->writeAttr(hwp, 0x10, 0x01);   /* graphics mode */
78fe5e51b7Smrg#endif
79fe5e51b7Smrg    if (scrninfp->depth == 4) {
80fe5e51b7Smrg	/* GJA */
81fe5e51b7Smrg	hwp->writeGr(hwp, 0x03, 0x00);  /* don't rotate, write unmodified */
82fe5e51b7Smrg	hwp->writeGr(hwp, 0x08, 0xFF);  /* write all bits in a byte */
83fe5e51b7Smrg	hwp->writeGr(hwp, 0x01, 0x00);  /* all planes come from CPU */
84fe5e51b7Smrg    }
85fe5e51b7Smrg
86fe5e51b7Smrg    hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
87fe5e51b7Smrg    hwp->writeGr(hwp, 0x05, 0x00);  /* write mode 0, read mode 0 */
88fe5e51b7Smrg    hwp->writeGr(hwp, 0x06, 0x05);  /* set graphics */
89fe5e51b7Smrg
90fe5e51b7Smrg    if (hwp->FontInfo1) {
91fe5e51b7Smrg	hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
92fe5e51b7Smrg	hwp->writeGr(hwp, 0x04, 0x02);  /* read plane 2 */
93fe5e51b7Smrg	slowbcopy_tobus(hwp->FontInfo1, hwp->Base, FONT_AMOUNT);
94fe5e51b7Smrg    }
95fe5e51b7Smrg
96fe5e51b7Smrg    if (hwp->FontInfo2) {
97fe5e51b7Smrg	hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
98fe5e51b7Smrg	hwp->writeGr(hwp, 0x04, 0x03);  /* read plane 3 */
99fe5e51b7Smrg	slowbcopy_tobus(hwp->FontInfo2, hwp->Base, FONT_AMOUNT);
100fe5e51b7Smrg    }
101fe5e51b7Smrg
102fe5e51b7Smrg    if (hwp->TextInfo) {
103fe5e51b7Smrg	hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
104fe5e51b7Smrg	hwp->writeGr(hwp, 0x04, 0x00);  /* read plane 0 */
105fe5e51b7Smrg	slowbcopy_tobus(hwp->TextInfo, hwp->Base, TEXT_AMOUNT);
106fe5e51b7Smrg	hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
107fe5e51b7Smrg	hwp->writeGr(hwp, 0x04, 0x01);  /* read plane 1 */
108fe5e51b7Smrg	slowbcopy_tobus((unsigned char *)hwp->TextInfo + TEXT_AMOUNT,
109fe5e51b7Smrg		hwp->Base, TEXT_AMOUNT);
110fe5e51b7Smrg    }
111fe5e51b7Smrg
112fe5e51b7Smrg    /* restore the registers that were changed */
113fe5e51b7Smrg    hwp->writeMiscOut(hwp, miscOut);
114fe5e51b7Smrg    hwp->writeAttr(hwp, 0x10, attr10);
115fe5e51b7Smrg    hwp->writeGr(hwp, 0x01, gr1);
116fe5e51b7Smrg    hwp->writeGr(hwp, 0x03, gr3);
117fe5e51b7Smrg    hwp->writeGr(hwp, 0x04, gr4);
118fe5e51b7Smrg    hwp->writeGr(hwp, 0x05, gr5);
119fe5e51b7Smrg    hwp->writeGr(hwp, 0x06, gr6);
120fe5e51b7Smrg    hwp->writeGr(hwp, 0x08, gr8);
121fe5e51b7Smrg    hwp->writeSeq(hwp, 0x02, seq2);
122fe5e51b7Smrg    hwp->writeSeq(hwp, 0x04, seq4);
123fe5e51b7Smrg    hwp->IOBase = savedIOBase;
124fe5e51b7Smrg
125fe5e51b7Smrg    scrn = hwp->readSeq(hwp, 0x01);
126fe5e51b7Smrg    scrn &= ~0x20;/* enable screen */
127fe5e51b7Smrg    vgaHWSeqReset(hwp, TRUE);
128fe5e51b7Smrg    MGAWAITVSYNC();
129fe5e51b7Smrg    MGAWAITBUSY();
130fe5e51b7Smrg    hwp->writeSeq(hwp, 0x01, scrn);/* change mode */
131fe5e51b7Smrg    usleep(20000);
132fe5e51b7Smrg    vgaHWSeqReset(hwp, FALSE);
133fe5e51b7Smrg
134fe5e51b7Smrg    if (doMap)
135fe5e51b7Smrg	vgaHWUnmapMem(scrninfp);
136fe5e51b7Smrg}
137fe5e51b7Smrg
138fe5e51b7Smrg
139fe5e51b7Smrgvoid
140fe5e51b7SmrgMGAG200SESaveFonts(ScrnInfoPtr scrninfp, vgaRegPtr save)
141fe5e51b7Smrg{
142fe5e51b7Smrg    vgaHWPtr hwp = VGAHWPTR(scrninfp);
143fe5e51b7Smrg    MGAPtr pMga = MGAPTR(scrninfp);
144fe5e51b7Smrg    int savedIOBase;
145fe5e51b7Smrg    unsigned char miscOut, attr10, gr4, gr5, gr6, seq2, seq4;
146fe5e51b7Smrg    Bool doMap = FALSE;
147fe5e51b7Smrg    unsigned char scrn;
148fe5e51b7Smrg
149fe5e51b7Smrg    if (hwp->Base == NULL) {
150fe5e51b7Smrg	doMap = TRUE;
151fe5e51b7Smrg	if (!vgaHWMapMem(scrninfp)) {
152fe5e51b7Smrg	    xf86DrvMsg(scrninfp->scrnIndex, X_ERROR,
153fe5e51b7Smrg		    "vgaHWSaveFonts: vgaHWMapMem() failed\n");
154fe5e51b7Smrg	    return;
155fe5e51b7Smrg	}
156fe5e51b7Smrg    }
157fe5e51b7Smrg
158fe5e51b7Smrg    /* If in graphics mode, don't save anything */
159fe5e51b7Smrg    attr10 = hwp->readAttr(hwp, 0x10);
160fe5e51b7Smrg    if (attr10 & 0x01)
161fe5e51b7Smrg	return;
162fe5e51b7Smrg
163fe5e51b7Smrg    /* save the registers that are needed here */
164fe5e51b7Smrg    miscOut = hwp->readMiscOut(hwp);
165fe5e51b7Smrg    gr4 = hwp->readGr(hwp, 0x04);
166fe5e51b7Smrg    gr5 = hwp->readGr(hwp, 0x05);
167fe5e51b7Smrg    gr6 = hwp->readGr(hwp, 0x06);
168fe5e51b7Smrg    seq2 = hwp->readSeq(hwp, 0x02);
169fe5e51b7Smrg    seq4 = hwp->readSeq(hwp, 0x04);
170fe5e51b7Smrg
171fe5e51b7Smrg    /* save hwp->IOBase and temporarily set it for colour mode */
172fe5e51b7Smrg    savedIOBase = hwp->IOBase;
173fe5e51b7Smrg    hwp->IOBase = VGA_IOBASE_COLOR;
174fe5e51b7Smrg
175fe5e51b7Smrg    /* Force into colour mode */
176fe5e51b7Smrg    hwp->writeMiscOut(hwp, miscOut | 0x01);
177fe5e51b7Smrg
178fe5e51b7Smrg    scrn = hwp->readSeq(hwp, 0x01);
179fe5e51b7Smrg    scrn |= 0x20;/* blank screen */
180fe5e51b7Smrg    vgaHWSeqReset(hwp, TRUE);
181fe5e51b7Smrg    MGAWAITVSYNC();
182fe5e51b7Smrg    MGAWAITBUSY();
183fe5e51b7Smrg    hwp->writeSeq(hwp, 0x01, scrn);/* change mode */
184fe5e51b7Smrg    usleep(20000);
185fe5e51b7Smrg    vgaHWSeqReset(hwp, FALSE);
186fe5e51b7Smrg
187fe5e51b7Smrg    /*
188fe5e51b7Smrg     * get the character sets, and text screen if required
189fe5e51b7Smrg     */
190fe5e51b7Smrg    /*
191fe5e51b7Smrg     * Here we temporarily switch to 16 colour planar mode, to simply
192fe5e51b7Smrg     * copy the font-info
193fe5e51b7Smrg     *
194fe5e51b7Smrg     * BUG ALERT: The (S)VGA's segment-select register MUST be set correctly!
195fe5e51b7Smrg     */
196fe5e51b7Smrg#if 0
197fe5e51b7Smrg    hwp->writeAttr(hwp, 0x10, 0x01);   /* graphics mode */
198fe5e51b7Smrg#endif
199fe5e51b7Smrg    hwp->writeSeq(hwp, 0x04, 0x06); /* enable plane graphics */
200fe5e51b7Smrg    hwp->writeGr(hwp, 0x05, 0x00);  /* write mode 0, read mode 0 */
201fe5e51b7Smrg    hwp->writeGr(hwp, 0x06, 0x05);  /* set graphics */
20284354367Smrg    if (hwp->FontInfo1 || (hwp->FontInfo1 = malloc(FONT_AMOUNT))) {
203fe5e51b7Smrg	hwp->writeSeq(hwp, 0x02, 0x04); /* write to plane 2 */
204fe5e51b7Smrg	hwp->writeGr(hwp, 0x04, 0x02);  /* read plane 2 */
205fe5e51b7Smrg	slowbcopy_frombus(hwp->Base, hwp->FontInfo1, FONT_AMOUNT);
206fe5e51b7Smrg    }
20784354367Smrg    if (hwp->FontInfo2 || (hwp->FontInfo2 = malloc(FONT_AMOUNT))) {
208fe5e51b7Smrg	hwp->writeSeq(hwp, 0x02, 0x08); /* write to plane 3 */
209fe5e51b7Smrg	hwp->writeGr(hwp, 0x04, 0x03);  /* read plane 3 */
210fe5e51b7Smrg	slowbcopy_frombus(hwp->Base, hwp->FontInfo2, FONT_AMOUNT);
211fe5e51b7Smrg    }
21284354367Smrg    if (hwp->TextInfo || (hwp->TextInfo = malloc(2 * TEXT_AMOUNT))) {
213fe5e51b7Smrg	hwp->writeSeq(hwp, 0x02, 0x01); /* write to plane 0 */
214fe5e51b7Smrg	hwp->writeGr(hwp, 0x04, 0x00);  /* read plane 0 */
215fe5e51b7Smrg	slowbcopy_frombus(hwp->Base, hwp->TextInfo, TEXT_AMOUNT);
216fe5e51b7Smrg	hwp->writeSeq(hwp, 0x02, 0x02); /* write to plane 1 */
217fe5e51b7Smrg	hwp->writeGr(hwp, 0x04, 0x01);  /* read plane 1 */
218fe5e51b7Smrg	slowbcopy_frombus(hwp->Base,
219fe5e51b7Smrg		(unsigned char *)hwp->TextInfo + TEXT_AMOUNT, TEXT_AMOUNT);
220fe5e51b7Smrg    }
221fe5e51b7Smrg
222fe5e51b7Smrg    /* Restore clobbered registers */
223fe5e51b7Smrg    hwp->writeAttr(hwp, 0x10, attr10);
224fe5e51b7Smrg    hwp->writeGr(hwp, 0x04, gr4);
225fe5e51b7Smrg    hwp->writeGr(hwp, 0x05, gr5);
226fe5e51b7Smrg    hwp->writeGr(hwp, 0x06, gr6);
227fe5e51b7Smrg    hwp->writeSeq(hwp, 0x02, seq2);
228fe5e51b7Smrg    hwp->writeSeq(hwp, 0x04, seq4);
229fe5e51b7Smrg    hwp->writeMiscOut(hwp, miscOut);
230fe5e51b7Smrg    hwp->IOBase = savedIOBase;
231fe5e51b7Smrg
232fe5e51b7Smrg    scrn = hwp->readSeq(hwp, 0x01);
233fe5e51b7Smrg    scrn &= ~0x20;/* enable screen */
234fe5e51b7Smrg    vgaHWSeqReset(hwp, TRUE);
235fe5e51b7Smrg    MGAWAITVSYNC();
236fe5e51b7Smrg    MGAWAITBUSY();
237fe5e51b7Smrg    hwp->writeSeq(hwp, 0x01, scrn);/* change mode */
238fe5e51b7Smrg    usleep(20000);
239fe5e51b7Smrg    vgaHWSeqReset(hwp, FALSE);
240fe5e51b7Smrg
241fe5e51b7Smrg    if (doMap)
242fe5e51b7Smrg	vgaHWUnmapMem(scrninfp);
243fe5e51b7Smrg}
244fe5e51b7Smrg
245fe5e51b7Smrgvoid
246fe5e51b7SmrgMGAG200SERestoreMode(ScrnInfoPtr scrninfp, vgaRegPtr restore)
247fe5e51b7Smrg{
248fe5e51b7Smrg    vgaHWPtr hwp = VGAHWPTR(scrninfp);
249fe5e51b7Smrg    MGAPtr pMga = MGAPTR(scrninfp);
250fe5e51b7Smrg    int i;
251fe5e51b7Smrg    unsigned char scrn;
252fe5e51b7Smrg
253fe5e51b7Smrg    if (restore->MiscOutReg & 0x01)
254fe5e51b7Smrg    hwp->IOBase = VGA_IOBASE_COLOR;
255fe5e51b7Smrg    else
256fe5e51b7Smrg    hwp->IOBase = VGA_IOBASE_MONO;
257fe5e51b7Smrg
258fe5e51b7Smrg    hwp->writeMiscOut(hwp, restore->MiscOutReg);
259fe5e51b7Smrg
260fe5e51b7Smrg
261fe5e51b7Smrg    for (i = 1; i < restore->numSequencer; i++)
262fe5e51b7Smrg    {
263fe5e51b7Smrg    MGAWAITVSYNC();
264fe5e51b7Smrg    MGAWAITBUSY();
265fe5e51b7Smrg	hwp->writeSeq(hwp, i, restore->Sequencer[i]);
266fe5e51b7Smrg	usleep(20000);
267fe5e51b7Smrg    }
268fe5e51b7Smrg
269fe5e51b7Smrg    scrn = hwp->readSeq(hwp, 0x01);
270fe5e51b7Smrg    scrn |= 0x20;/* blank screen */
271fe5e51b7Smrg    vgaHWSeqReset(hwp, TRUE);
272fe5e51b7Smrg    MGAWAITVSYNC();
273fe5e51b7Smrg    MGAWAITBUSY();
274fe5e51b7Smrg    hwp->writeSeq(hwp, 0x01, scrn);/* change mode */
275fe5e51b7Smrg    usleep(20000);
276fe5e51b7Smrg
277fe5e51b7Smrg    /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 of CRTC[17] */
278fe5e51b7Smrg    hwp->writeCrtc(hwp, 17, restore->CRTC[17] & ~0x80);
279fe5e51b7Smrg
280fe5e51b7Smrg    for (i = 0; i < restore->numCRTC; i++)
281fe5e51b7Smrg	hwp->writeCrtc(hwp, i, restore->CRTC[i]);
282fe5e51b7Smrg
283fe5e51b7Smrg    for (i = 0; i < restore->numGraphics; i++)
284fe5e51b7Smrg    hwp->writeGr(hwp, i, restore->Graphics[i]);
285fe5e51b7Smrg
286fe5e51b7Smrg    hwp->enablePalette(hwp);
287fe5e51b7Smrg    for (i = 0; i < restore->numAttribute; i++)
288fe5e51b7Smrg    hwp->writeAttr(hwp, i, restore->Attribute[i]);
289fe5e51b7Smrg    hwp->disablePalette(hwp);
290fe5e51b7Smrg
291fe5e51b7Smrg    MGAWAITVSYNC();
292fe5e51b7Smrg    MGAWAITBUSY();
293fe5e51b7Smrg	hwp->writeSeq(hwp, 1, restore->Sequencer[1]);
294fe5e51b7Smrg    usleep(20000);
295fe5e51b7Smrg}
296fe5e51b7Smrg
297fe5e51b7Smrgvoid
298fe5e51b7SmrgMGAG200SESaveMode(ScrnInfoPtr scrninfp, vgaRegPtr save)
299fe5e51b7Smrg{
300fe5e51b7Smrg    vgaHWPtr hwp = VGAHWPTR(scrninfp);
301fe5e51b7Smrg    int i;
302fe5e51b7Smrg
303fe5e51b7Smrg    save->MiscOutReg = hwp->readMiscOut(hwp);
304fe5e51b7Smrg    if (save->MiscOutReg & 0x01)
305fe5e51b7Smrg    hwp->IOBase = VGA_IOBASE_COLOR;
306fe5e51b7Smrg    else
307fe5e51b7Smrg    hwp->IOBase = VGA_IOBASE_MONO;
308fe5e51b7Smrg
309fe5e51b7Smrg    for (i = 0; i < save->numCRTC; i++) {
310fe5e51b7Smrg    save->CRTC[i] = hwp->readCrtc(hwp, i);
311fe5e51b7Smrg#ifdef DEBUG
312fe5e51b7Smrg    ErrorF("CRTC[0x%02x] = 0x%02x\n", i, save->CRTC[i]);
313fe5e51b7Smrg#endif
314fe5e51b7Smrg    }
315fe5e51b7Smrg
316fe5e51b7Smrg    hwp->enablePalette(hwp);
317fe5e51b7Smrg    for (i = 0; i < save->numAttribute; i++) {
318fe5e51b7Smrg    save->Attribute[i] = hwp->readAttr(hwp, i);
319fe5e51b7Smrg#ifdef DEBUG
320fe5e51b7Smrg    ErrorF("Attribute[0x%02x] = 0x%02x\n", i, save->Attribute[i]);
321fe5e51b7Smrg#endif
322fe5e51b7Smrg    }
323fe5e51b7Smrg    hwp->disablePalette(hwp);
324fe5e51b7Smrg
325fe5e51b7Smrg    for (i = 0; i < save->numGraphics; i++) {
326fe5e51b7Smrg    save->Graphics[i] = hwp->readGr(hwp, i);
327fe5e51b7Smrg#ifdef DEBUG
328fe5e51b7Smrg    ErrorF("Graphics[0x%02x] = 0x%02x\n", i, save->Graphics[i]);
329fe5e51b7Smrg#endif
330fe5e51b7Smrg    }
331fe5e51b7Smrg
332fe5e51b7Smrg    for (i = 1; i < save->numSequencer; i++) {
333fe5e51b7Smrg    save->Sequencer[i] = hwp->readSeq(hwp, i);
334fe5e51b7Smrg#ifdef DEBUG
335fe5e51b7Smrg    ErrorF("Sequencer[0x%02x] = 0x%02x\n", i, save->Sequencer[i]);
336fe5e51b7Smrg#endif
337fe5e51b7Smrg    }
338fe5e51b7Smrg}
339fe5e51b7Smrg
340fe5e51b7Smrgvoid
341fe5e51b7SmrgMGAG200SEHWProtect(ScrnInfoPtr pScrn, Bool on)
342fe5e51b7Smrg{
343fe5e51b7Smrg  vgaHWPtr hwp = VGAHWPTR(pScrn);
344fe5e51b7Smrg  MGAPtr pMga = MGAPTR(pScrn);
345fe5e51b7Smrg
346fe5e51b7Smrg  unsigned char tmp;
347fe5e51b7Smrg
348fe5e51b7Smrg  if (pScrn->vtSema) {
349fe5e51b7Smrg    if (on) {
350fe5e51b7Smrg      /*
351fe5e51b7Smrg       * Turn off screen and disable sequencer.
352fe5e51b7Smrg       */
353fe5e51b7Smrg      tmp = hwp->readSeq(hwp, 0x01);
354fe5e51b7Smrg
355fe5e51b7Smrg      vgaHWSeqReset(hwp, TRUE);         /* start synchronous reset */
356fe5e51b7Smrg      MGAWAITVSYNC();
357fe5e51b7Smrg      MGAWAITBUSY();
358fe5e51b7Smrg      hwp->writeSeq(hwp, 0x01, tmp | 0x20); /* disable the display */
359fe5e51b7Smrg      usleep(20000);
360fe5e51b7Smrg      hwp->enablePalette(hwp);
361fe5e51b7Smrg    } else {
362fe5e51b7Smrg      /*
363d2b10af6Smrg       * Re-enable sequencer, then turn on screen.
364fe5e51b7Smrg       */
365fe5e51b7Smrg
366fe5e51b7Smrg      tmp = hwp->readSeq(hwp, 0x01);
367fe5e51b7Smrg
368fe5e51b7Smrg      MGAWAITVSYNC();
369fe5e51b7Smrg      MGAWAITBUSY();
370d2b10af6Smrg      hwp->writeSeq(hwp, 0x01, tmp & ~0x20);    /* re-enable display */
371fe5e51b7Smrg      usleep(20000);
372fe5e51b7Smrg      vgaHWSeqReset(hwp, FALSE);        /* clear synchronousreset */
373fe5e51b7Smrg
374fe5e51b7Smrg      hwp->disablePalette(hwp);
375fe5e51b7Smrg    }
376fe5e51b7Smrg  }
377fe5e51b7Smrg}
378