17104f784Smrg/*
27104f784SmrgCopyright (C) 1994-1999 The XFree86 Project, Inc.  All Rights Reserved.
37104f784SmrgCopyright (C) 2000 Silicon Motion, Inc.  All Rights Reserved.
47104f784SmrgCopyright (C) 2008 Francisco Jerez. All Rights Reserved.
57104f784Smrg
67104f784SmrgPermission is hereby granted, free of charge, to any person obtaining a copy of
77104f784Smrgthis software and associated documentation files (the "Software"), to deal in
87104f784Smrgthe Software without restriction, including without limitation the rights to
97104f784Smrguse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
107104f784Smrgof the Software, and to permit persons to whom the Software is furnished to do
117104f784Smrgso, subject to the following conditions:
127104f784Smrg
137104f784SmrgThe above copyright notice and this permission notice shall be included in all
147104f784Smrgcopies or substantial portions of the Software.
157104f784Smrg
167104f784SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
177104f784SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
187104f784SmrgNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
197104f784SmrgXFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
207104f784SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
217104f784SmrgWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
227104f784Smrg
237104f784SmrgExcept as contained in this notice, the names of The XFree86 Project and
247104f784SmrgSilicon Motion shall not be used in advertising or otherwise to promote the
257104f784Smrgsale, use or other dealings in this Software without prior written
267104f784Smrgauthorization from The XFree86 Project or Silicon Motion.
277104f784Smrg*/
287104f784Smrg
297104f784Smrg#ifdef HAVE_CONFIG_H
307104f784Smrg#include "config.h"
317104f784Smrg#endif
327104f784Smrg
337104f784Smrg#include "smi.h"
347104f784Smrg#include "smi_crtc.h"
357104f784Smrg#include "smilynx.h"
367104f784Smrg
377104f784Smrgstatic unsigned int SMILynx_ddc1Read(ScrnInfoPtr pScrn);
387104f784Smrg
397104f784SmrgBool
407104f784SmrgSMILynx_HWInit(ScrnInfoPtr pScrn)
417104f784Smrg{
427104f784Smrg    SMIPtr pSmi = SMIPTR(pScrn);
437104f784Smrg    SMIRegPtr mode = pSmi->mode;
447104f784Smrg    vgaHWPtr	hwp = VGAHWPTR(pScrn);
457104f784Smrg    int		vgaIOBase  = hwp->IOBase;
467104f784Smrg    int		vgaCRIndex = vgaIOBase + VGA_CRTC_INDEX_OFFSET;
477104f784Smrg    int		vgaCRData  = vgaIOBase + VGA_CRTC_DATA_OFFSET;
487104f784Smrg
497104f784Smrg    ENTER();
507104f784Smrg
517104f784Smrg    if (pSmi->PCIBurst) {
527104f784Smrg	mode->SR17 |= 0x20;
537104f784Smrg    } else {
547104f784Smrg	mode->SR17 &= ~0x20;
557104f784Smrg    }
567104f784Smrg
577104f784Smrg    /* Gamma correction */
587104f784Smrg    if (pSmi->Chipset == SMI_LYNX3DM || pSmi->Chipset == SMI_COUGAR3DR) {
597104f784Smrg	if(pScrn->bitsPerPixel == 8)
607104f784Smrg	    mode->SR66 = (mode->SR66 & 0x33) | 0x00; /* Both RAMLUT on, 6 bits-RAM */
617104f784Smrg	else
627104f784Smrg	    mode->SR66 = (mode->SR66 & 0x33) | 0x04; /* Both RAMLUT on, Gamma correct ON */
637104f784Smrg    }
647104f784Smrg
657104f784Smrg    /* Program MCLK */
667104f784Smrg    if (pSmi->MCLK > 0)
677104f784Smrg	SMI_CommonCalcClock(pScrn->scrnIndex, pSmi->MCLK,
687104f784Smrg			    1, 1, 63, 0, 0,
697104f784Smrg			    pSmi->clockRange.minClock,
707104f784Smrg			    pSmi->clockRange.maxClock,
717104f784Smrg			    &mode->SR6A, &mode->SR6B);
727104f784Smrg
737104f784Smrg    if(!pSmi->useBIOS) {
747104f784Smrg	/* Disable DAC and LCD framebuffer r/w operation */
757104f784Smrg	mode->SR21 |= 0xB0;
767104f784Smrg
777104f784Smrg	/* Power down mode is standby mode, VCLK and MCLK divided by 4 in standby mode */
787104f784Smrg	mode->SR20  = (mode->SR20 & ~0xB0) | 0x10;
797104f784Smrg
807104f784Smrg	/* Set DPMS state to Off */
817104f784Smrg	mode->SR22 |= 0x30;
827104f784Smrg
837104f784Smrg	if (pSmi->Chipset != SMI_COUGAR3DR) {
847104f784Smrg	    /* Select no displays */
857104f784Smrg	    mode->SR31 &= ~0x07;
867104f784Smrg
877104f784Smrg	    /* Disable virtual refresh */
887104f784Smrg	    mode->SR31 &= ~0x80;
897104f784Smrg
907104f784Smrg	    /* Disable expansion */
917104f784Smrg	    mode->SR32 &= ~0x03;
927104f784Smrg	    /* Enable autocentering */
937104f784Smrg	    if (SMI_LYNXM_SERIES(pSmi->Chipset))
947104f784Smrg		mode->SR32 |= 0x04;
957104f784Smrg	    else
967104f784Smrg		mode->SR32 &= ~0x04;
977104f784Smrg
987104f784Smrg	    if (pSmi->lcd == 2) /* Panel is DSTN */
997104f784Smrg		mode->SR21 = 0x00;
1007104f784Smrg
1017104f784Smrg	    /* Enable HW LCD power sequencing */
1027104f784Smrg	    mode->SR34 |= 0x80;
1037104f784Smrg	}
1047104f784Smrg
1057104f784Smrg	/* Disable Vertical Expansion/Vertical Centering/Horizontal Centering */
1067104f784Smrg	mode->CR90[0xE] &= ~0x7;
1077104f784Smrg
1087104f784Smrg	/* use vclk1 */
1097104f784Smrg	mode->SR68 = 0x54;
1107104f784Smrg
1117104f784Smrg	if(pSmi->Dualhead){
1127104f784Smrg	    /* set LCD to vclk2 */
1137104f784Smrg	    mode->SR69 = 0x04;
1147104f784Smrg	}
1157104f784Smrg
1167104f784Smrg	/* Disable panel video */
1177104f784Smrg	mode->SRA0 = 0;
1187104f784Smrg
1197104f784Smrg	mode->CR33 = 0;
1207104f784Smrg	mode->CR3A = 0;
1217104f784Smrg    }
1227104f784Smrg
1237104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x17, mode->SR17);
1247104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x20, mode->SR20);
1257104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21, mode->SR21);
1267104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x22, mode->SR22);
1277104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31, mode->SR31);
1287104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x32, mode->SR32);
1297104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x34, mode->SR34);
1307104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x66, mode->SR66);
1317104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x68, mode->SR68);
1327104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x69, mode->SR69);
1337104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6A, mode->SR6A);
1347104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6B, mode->SR6B);
1357104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0xA0, mode->SRA0);
1367104f784Smrg
1377104f784Smrg    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33, mode->CR33);
1387104f784Smrg    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x3A, mode->CR3A);
1397104f784Smrg    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, mode->CR90[0xE]);
1407104f784Smrg
1417104f784Smrg    LEAVE(TRUE);
1427104f784Smrg}
1437104f784Smrg
1447104f784Smrg/*
1457104f784Smrg * This function performs the inverse of the restore function: It saves all the
1467104f784Smrg * standard and extended registers that we are going to modify to set up a video
1477104f784Smrg * mode.
1487104f784Smrg */
1497104f784Smrg
1507104f784Smrgvoid
1517104f784SmrgSMILynx_Save(ScrnInfoPtr pScrn)
1527104f784Smrg{
1537104f784Smrg    SMIPtr	pSmi = SMIPTR(pScrn);
1547104f784Smrg    int		i;
1557104f784Smrg    CARD32	offset;
1567104f784Smrg    SMIRegPtr	save = pSmi->save;
1577104f784Smrg    vgaHWPtr	hwp = VGAHWPTR(pScrn);
1587104f784Smrg    vgaRegPtr	vgaSavePtr = &hwp->SavedReg;
1597104f784Smrg    int		vgaIOBase  = hwp->IOBase;
1607104f784Smrg    int		vgaCRIndex = vgaIOBase + VGA_CRTC_INDEX_OFFSET;
1617104f784Smrg    int		vgaCRData  = vgaIOBase + VGA_CRTC_DATA_OFFSET;
1627104f784Smrg
1637104f784Smrg    ENTER();
1647104f784Smrg
1657104f784Smrg    /* Save the standard VGA registers */
1667104f784Smrg    vgaHWSave(pScrn, vgaSavePtr, VGA_SR_ALL);
1677104f784Smrg    save->smiDACMask = VGAIN8(pSmi, VGA_DAC_MASK);
1687104f784Smrg    VGAOUT8(pSmi, VGA_DAC_READ_ADDR, 0);
1697104f784Smrg    for (i = 0; i < 256; i++) {
1707104f784Smrg	save->smiDacRegs[i][0] = VGAIN8(pSmi, VGA_DAC_DATA);
1717104f784Smrg	save->smiDacRegs[i][1] = VGAIN8(pSmi, VGA_DAC_DATA);
1727104f784Smrg	save->smiDacRegs[i][2] = VGAIN8(pSmi, VGA_DAC_DATA);
1737104f784Smrg    }
1747104f784Smrg    for (i = 0, offset = 2; i < 8192; i++, offset += 8)
1757104f784Smrg	save->smiFont[i] = *(pSmi->FBBase + offset);
1767104f784Smrg
1777104f784Smrg    /* Now we save all the extended registers we need. */
1787104f784Smrg    save->SR17 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x17);
1797104f784Smrg    save->SR18 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x18);
1807104f784Smrg
1817104f784Smrg    save->SR20 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x20);
1827104f784Smrg    save->SR21 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21);
1837104f784Smrg    save->SR22 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x22);
1847104f784Smrg    save->SR23 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x23);
1857104f784Smrg    save->SR24 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x24);
1867104f784Smrg
1877104f784Smrg    save->SR31 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31);
1887104f784Smrg    save->SR32 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x32);
1897104f784Smrg
1907104f784Smrg    save->SR66 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x66);
1917104f784Smrg    save->SR68 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x68);
1927104f784Smrg    save->SR69 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x69);
1937104f784Smrg    save->SR6A = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6A);
1947104f784Smrg    save->SR6B = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6B);
1957104f784Smrg    save->SR6C = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6C);
1967104f784Smrg    save->SR6D = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6D);
1977104f784Smrg
1987104f784Smrg    save->SR81 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81);
1997104f784Smrg    save->SRA0 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0xA0);
2007104f784Smrg
2017104f784Smrg    if (pSmi->Dualhead) {
2027104f784Smrg	/* dualhead stuff */
2037104f784Smrg	save->SR40 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x40);
2047104f784Smrg	save->SR41 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x41);
2057104f784Smrg	save->SR42 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x42);
2067104f784Smrg	save->SR43 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x43);
2077104f784Smrg	save->SR44 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x44);
2087104f784Smrg	save->SR45 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x45);
2097104f784Smrg	save->SR48 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x48);
2107104f784Smrg	save->SR49 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x49);
2117104f784Smrg	save->SR4A = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x4A);
2127104f784Smrg	save->SR4B = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x4B);
2137104f784Smrg	save->SR4C = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x4C);
2147104f784Smrg
2157104f784Smrg	save->SR50 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x50);
2167104f784Smrg	save->SR51 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x51);
2177104f784Smrg	save->SR52 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x52);
2187104f784Smrg	save->SR53 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x53);
2197104f784Smrg	save->SR54 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x54);
2207104f784Smrg	save->SR55 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x55);
2217104f784Smrg	save->SR56 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x56);
2227104f784Smrg	save->SR57 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x57);
2237104f784Smrg	save->SR5A = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x5A);
2247104f784Smrg
2257104f784Smrg	/* PLL2 stuff */
2267104f784Smrg	save->SR6E = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6E);
2277104f784Smrg	save->SR6F = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6F);
2287104f784Smrg    }
2297104f784Smrg
2307104f784Smrg    if (SMI_LYNXM_SERIES(pSmi->Chipset)) {
2317104f784Smrg	/* Save common registers */
2327104f784Smrg	save->CR30 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x30);
2337104f784Smrg	save->CR3A = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x3A);
2347104f784Smrg	for (i = 0; i < 15; i++) {
2357104f784Smrg	    save->CR90[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x90 + i);
2367104f784Smrg	}
2377104f784Smrg	for (i = 0; i < 14; i++) {
2387104f784Smrg	    save->CRA0[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0xA0 + i);
2397104f784Smrg	}
2407104f784Smrg
2417104f784Smrg	/* Save primary registers */
2427104f784Smrg	VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, save->CR90[14] & ~0x20);
2437104f784Smrg
2447104f784Smrg	save->CR33 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33);
2457104f784Smrg	for (i = 0; i < 14; i++) {
2467104f784Smrg	    save->CR40[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i);
2477104f784Smrg	}
2487104f784Smrg	save->CR9F = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9F);
2497104f784Smrg
2507104f784Smrg	/* Save secondary registers */
2517104f784Smrg	VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, save->CR90[14] | 0x20);
2527104f784Smrg	save->CR33_2 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33);
2537104f784Smrg	for (i = 0; i < 14; i++) {
2547104f784Smrg	    save->CR40_2[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i);
2557104f784Smrg	}
2567104f784Smrg	save->CR9F_2 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9F);
2577104f784Smrg
2587104f784Smrg	/* PDR#1069 */
2597104f784Smrg	VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E, save->CR90[14]);
2607104f784Smrg
2617104f784Smrg    }
2627104f784Smrg    else {
2637104f784Smrg	save->CR30 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x30);
2647104f784Smrg	save->CR33 = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33);
2657104f784Smrg	save->CR3A = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x3A);
2667104f784Smrg	for (i = 0; i < 14; i++) {
2677104f784Smrg	    save->CR40[i] = VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i);
2687104f784Smrg	}
2697104f784Smrg    }
2707104f784Smrg
2717104f784Smrg    save->DPR10 = READ_DPR(pSmi, 0x10);
2727104f784Smrg    save->DPR1C = READ_DPR(pSmi, 0x1C);
2737104f784Smrg    save->DPR20 = READ_DPR(pSmi, 0x20);
2747104f784Smrg    save->DPR24 = READ_DPR(pSmi, 0x24);
2757104f784Smrg    save->DPR28 = READ_DPR(pSmi, 0x28);
2767104f784Smrg    save->DPR2C = READ_DPR(pSmi, 0x2C);
2777104f784Smrg    save->DPR30 = READ_DPR(pSmi, 0x30);
2787104f784Smrg    save->DPR3C = READ_DPR(pSmi, 0x3C);
2797104f784Smrg    save->DPR40 = READ_DPR(pSmi, 0x40);
2807104f784Smrg    save->DPR44 = READ_DPR(pSmi, 0x44);
2817104f784Smrg
2827104f784Smrg    save->VPR00 = READ_VPR(pSmi, 0x00);
2837104f784Smrg    save->VPR0C = READ_VPR(pSmi, 0x0C);
2847104f784Smrg    save->VPR10 = READ_VPR(pSmi, 0x10);
2857104f784Smrg
2867104f784Smrg    if (pSmi->Chipset == SMI_COUGAR3DR) {
2877104f784Smrg	save->FPR00_ = READ_FPR(pSmi, FPR00);
2887104f784Smrg	save->FPR0C_ = READ_FPR(pSmi, FPR0C);
2897104f784Smrg	save->FPR10_ = READ_FPR(pSmi, FPR10);
2907104f784Smrg    }
2917104f784Smrg
2927104f784Smrg    save->CPR00 = READ_CPR(pSmi, 0x00);
2937104f784Smrg
2947104f784Smrg    if (!pSmi->ModeStructInit) {
2957104f784Smrg	vgaHWCopyReg(&hwp->ModeReg, vgaSavePtr);
2967104f784Smrg	memcpy(pSmi->mode, save, sizeof(SMIRegRec));
2977104f784Smrg	pSmi->ModeStructInit = TRUE;
2987104f784Smrg    }
2997104f784Smrg
300eb3dced6Smacallan#ifdef USE_INT10
3017104f784Smrg    if (pSmi->useBIOS && pSmi->pInt10 != NULL) {
3027104f784Smrg	pSmi->pInt10->num = 0x10;
3037104f784Smrg	pSmi->pInt10->ax = 0x0F00;
3047104f784Smrg	xf86ExecX86int10(pSmi->pInt10);
3057104f784Smrg	save->mode = pSmi->pInt10->ax & 0x007F;
3067104f784Smrg	xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Current mode 0x%02X.\n",
3077104f784Smrg		   save->mode);
3087104f784Smrg    }
309eb3dced6Smacallan#endif
3107104f784Smrg    if (xf86GetVerbosity() > 1) {
3117104f784Smrg	xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV,
3127104f784Smrg		       "Saved current video mode.  Register dump:\n");
3137104f784Smrg	SMI_PrintRegs(pScrn);
3147104f784Smrg    }
3157104f784Smrg
3167104f784Smrg    LEAVE();
3177104f784Smrg}
3187104f784Smrg
3197104f784Smrg/*
3207104f784Smrg * This function is used to restore a video mode. It writes out all of the
3217104f784Smrg * standard VGA and extended registers needed to setup a video mode.
3227104f784Smrg */
3237104f784Smrg
3247104f784Smrgvoid
3257104f784SmrgSMILynx_WriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, SMIRegPtr restore)
3267104f784Smrg{
3277104f784Smrg    SMIPtr	pSmi = SMIPTR(pScrn);
3287104f784Smrg    int		i;
3297104f784Smrg    CARD8	tmp;
3307104f784Smrg    CARD32	offset;
3317104f784Smrg    vgaHWPtr	hwp = VGAHWPTR(pScrn);
3327104f784Smrg    int		vgaIOBase  = hwp->IOBase;
3337104f784Smrg    int		vgaCRIndex = vgaIOBase + VGA_CRTC_INDEX_OFFSET;
3347104f784Smrg    int		vgaCRData  = vgaIOBase + VGA_CRTC_DATA_OFFSET;
3357104f784Smrg
3367104f784Smrg    ENTER();
3377104f784Smrg
3387104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x17, restore->SR17);
3397104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x18, restore->SR18);
3407104f784Smrg
3417104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x20, restore->SR20);
3427104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21, restore->SR21);
3437104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x22, restore->SR22);
3447104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x23, restore->SR23);
3457104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x24, restore->SR24);
3467104f784Smrg
3477104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31, restore->SR31);
3487104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x32, restore->SR32);
3497104f784Smrg
3507104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x66, restore->SR66);
3517104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x68, restore->SR68);
3527104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x69, restore->SR69);
3537104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6A, restore->SR6A);
3547104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6B, restore->SR6B);
3557104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6C, restore->SR6C);
3567104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6D, restore->SR6D);
3577104f784Smrg
3587104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, restore->SR81);
3597104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0xA0, restore->SRA0);
3607104f784Smrg
3617104f784Smrg    if (pSmi->useBIOS && restore->mode != 0){
362eb3dced6Smacallan#ifdef USE_INT10
3637104f784Smrg	pSmi->pInt10->num = 0x10;
3647104f784Smrg	pSmi->pInt10->ax = restore->mode | 0x80;
3657104f784Smrg	xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Setting mode 0x%02X\n",
3667104f784Smrg		   restore->mode);
3677104f784Smrg	xf86ExecX86int10(pSmi->pInt10);
3687104f784Smrg
3697104f784Smrg	/* Enable linear mode. */
3707104f784Smrg	outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x18);
3717104f784Smrg	tmp = inb(pSmi->PIOBase + VGA_SEQ_DATA);
3727104f784Smrg	outb(pSmi->PIOBase + VGA_SEQ_DATA, tmp | 0x01);
3737104f784Smrg
3747104f784Smrg	/* Enable DPR/VPR registers. */
3757104f784Smrg	tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21);
3767104f784Smrg	VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21, tmp & ~0x03);
377eb3dced6Smacallan#endif
3787104f784Smrg    } else {
3797104f784Smrg	/* Restore the standard VGA registers */
3807104f784Smrg	vgaHWRestore(pScrn, vgaSavePtr, VGA_SR_ALL);
3817104f784Smrg	if (restore->smiDACMask) {
3827104f784Smrg	    VGAOUT8(pSmi, VGA_DAC_MASK, restore->smiDACMask);
3837104f784Smrg	} else {
3847104f784Smrg	    VGAOUT8(pSmi, VGA_DAC_MASK, 0xFF);
3857104f784Smrg	}
3867104f784Smrg	VGAOUT8(pSmi, VGA_DAC_WRITE_ADDR, 0);
3877104f784Smrg	for (i = 0; i < 256; i++) {
3887104f784Smrg	    VGAOUT8(pSmi, VGA_DAC_DATA, restore->smiDacRegs[i][0]);
3897104f784Smrg	    VGAOUT8(pSmi, VGA_DAC_DATA, restore->smiDacRegs[i][1]);
3907104f784Smrg	    VGAOUT8(pSmi, VGA_DAC_DATA, restore->smiDacRegs[i][2]);
3917104f784Smrg	}
3927104f784Smrg	for (i = 0, offset = 2; i < 8192; i++, offset += 8) {
3937104f784Smrg	    *(pSmi->FBBase + offset) = restore->smiFont[i];
3947104f784Smrg	}
3957104f784Smrg
3967104f784Smrg	if (SMI_LYNXM_SERIES(pSmi->Chipset)) {
3977104f784Smrg	    /* Restore secondary registers */
3987104f784Smrg	    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E,
3997104f784Smrg			  restore->CR90[14] | 0x20);
4007104f784Smrg
4017104f784Smrg	    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33, restore->CR33_2);
4027104f784Smrg	    for (i = 0; i < 14; i++) {
4037104f784Smrg		VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i,
4047104f784Smrg			      restore->CR40_2[i]);
4057104f784Smrg	    }
4067104f784Smrg	    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9F, restore->CR9F_2);
4077104f784Smrg
4087104f784Smrg	    /* Restore primary registers */
4097104f784Smrg	    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9E,
4107104f784Smrg			  restore->CR90[14] & ~0x20);
4117104f784Smrg
4127104f784Smrg	    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33, restore->CR33);
4137104f784Smrg	    for (i = 0; i < 14; i++) {
4147104f784Smrg		VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i,
4157104f784Smrg			      restore->CR40[i]);
4167104f784Smrg	    }
4177104f784Smrg	    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x9F, restore->CR9F);
4187104f784Smrg
4197104f784Smrg	    /* Restore common registers */
4207104f784Smrg	    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x30, restore->CR30);
4217104f784Smrg	    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x3A, restore->CR3A);
4227104f784Smrg
4237104f784Smrg	    for (i = 0; i < 15; i++)
4247104f784Smrg		VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x90 + i,
4257104f784Smrg			      restore->CR90[i]);
4267104f784Smrg
4277104f784Smrg	    for (i = 0; i < 14; i++)
4287104f784Smrg		VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0xA0 + i,
4297104f784Smrg			      restore->CRA0[i]);
4307104f784Smrg
4317104f784Smrg	}else{
4327104f784Smrg	    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x30, restore->CR30);
4337104f784Smrg	    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x33, restore->CR33);
4347104f784Smrg	    VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x3A, restore->CR3A);
4357104f784Smrg	    for (i = 0; i < 14; i++) {
4367104f784Smrg		VGAOUT8_INDEX(pSmi, vgaCRIndex, vgaCRData, 0x40 + i,
4377104f784Smrg			      restore->CR40[i]);
4387104f784Smrg	    }
4397104f784Smrg	}
4407104f784Smrg
4417104f784Smrg	if (pSmi->Dualhead) {
4427104f784Smrg	    /* dualhead stuff */
4437104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x40, restore->SR40);
4447104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x41, restore->SR41);
4457104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x42, restore->SR42);
4467104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x43, restore->SR43);
4477104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x44, restore->SR44);
4487104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x45, restore->SR45);
4497104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x48, restore->SR48);
4507104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x49, restore->SR49);
4517104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x4A, restore->SR4A);
4527104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x4B, restore->SR4B);
4537104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x4C, restore->SR4C);
4547104f784Smrg
4557104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x50, restore->SR50);
4567104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x51, restore->SR51);
4577104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x52, restore->SR52);
4587104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x53, restore->SR53);
4597104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x54, restore->SR54);
4607104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x55, restore->SR55);
4617104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x56, restore->SR56);
4627104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x57, restore->SR57);
4637104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x5A, restore->SR5A);
4647104f784Smrg
4657104f784Smrg	    /* PLL2 stuff */
4667104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6E, restore->SR6E);
4677104f784Smrg	    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x6F, restore->SR6F);
4687104f784Smrg	}
4697104f784Smrg    }
4707104f784Smrg
4717104f784Smrg    /* Reset the graphics engine */
4727104f784Smrg    WRITE_DPR(pSmi, 0x10, restore->DPR10);
4737104f784Smrg    WRITE_DPR(pSmi, 0x1C, restore->DPR1C);
4747104f784Smrg    WRITE_DPR(pSmi, 0x20, restore->DPR20);
4757104f784Smrg    WRITE_DPR(pSmi, 0x24, restore->DPR24);
4767104f784Smrg    WRITE_DPR(pSmi, 0x28, restore->DPR28);
4777104f784Smrg    WRITE_DPR(pSmi, 0x2C, restore->DPR2C);
4787104f784Smrg    WRITE_DPR(pSmi, 0x30, restore->DPR30);
4797104f784Smrg    WRITE_DPR(pSmi, 0x3C, restore->DPR3C);
4807104f784Smrg    WRITE_DPR(pSmi, 0x40, restore->DPR40);
4817104f784Smrg    WRITE_DPR(pSmi, 0x44, restore->DPR44);
4827104f784Smrg
4837104f784Smrg    /* write video controller regs */
4847104f784Smrg    WRITE_VPR(pSmi, 0x00, restore->VPR00);
4857104f784Smrg    WRITE_VPR(pSmi, 0x0C, restore->VPR0C);
4867104f784Smrg    WRITE_VPR(pSmi, 0x10, restore->VPR10);
4877104f784Smrg
4887104f784Smrg    if(pSmi->Chipset == SMI_COUGAR3DR) {
4897104f784Smrg	WRITE_FPR(pSmi, FPR00, restore->FPR00_);
4907104f784Smrg	WRITE_FPR(pSmi, FPR0C, restore->FPR0C_);
4917104f784Smrg	WRITE_FPR(pSmi, FPR10, restore->FPR10_);
4927104f784Smrg    }
4937104f784Smrg
4947104f784Smrg    WRITE_CPR(pSmi, 0x00, restore->CPR00);
4957104f784Smrg
4967104f784Smrg    if (xf86GetVerbosity() > 1) {
4977104f784Smrg	xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV,
4987104f784Smrg		       "Done restoring mode.  Register dump:\n");
4997104f784Smrg	SMI_PrintRegs(pScrn);
5007104f784Smrg    }
5017104f784Smrg
5027104f784Smrg    vgaHWProtect(pScrn, FALSE);
5037104f784Smrg
5047104f784Smrg    LEAVE();
5057104f784Smrg}
5067104f784Smrg
5077104f784Smrg
5087104f784Smrg/*
5097104f784Smrg * SMI_DisplayPowerManagementSet -- Sets VESA Display Power Management
5107104f784Smrg * Signaling (DPMS) Mode.
5117104f784Smrg */
5127104f784Smrgvoid
5137104f784SmrgSMILynx_DisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode,
5147104f784Smrg							  int flags)
5157104f784Smrg{
5167104f784Smrg    SMIPtr	pSmi = SMIPTR(pScrn);
5177104f784Smrg    SMIRegPtr	mode = pSmi->mode;
5187104f784Smrg    vgaHWPtr	hwp = VGAHWPTR(pScrn);
5197104f784Smrg
5207104f784Smrg    ENTER();
5217104f784Smrg
5227104f784Smrg    /* If we already are in the requested DPMS mode, just return */
5237104f784Smrg    if (pSmi->CurrentDPMS != PowerManagementMode) {
5247104f784Smrg	/* Read the required SR registers for the DPMS handler */
5257104f784Smrg	CARD8 SR01 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x01);
5267104f784Smrg
5277104f784Smrg	switch (PowerManagementMode) {
5287104f784Smrg	    case DPMSModeOn:
5297104f784Smrg		SR01 &= ~0x20; /* Screen on */
5307104f784Smrg		mode->SR23 &= ~0xC0; /* Disable chip activity detection */
5317104f784Smrg		break;
5327104f784Smrg	    case DPMSModeStandby:
5337104f784Smrg	    case DPMSModeSuspend:
5347104f784Smrg	    case DPMSModeOff:
5357104f784Smrg		SR01 |= 0x20; /* Screen off */
5367104f784Smrg		mode->SR23 = (mode->SR23 & ~0x07) | 0xD8; /* Enable chip activity detection
5377104f784Smrg							     Enable internal auto-standby mode
5387104f784Smrg							     Enable both IO Write and Host Memory write detect
5397104f784Smrg							     0 minutes timeout */
5407104f784Smrg		break;
5417104f784Smrg	}
5427104f784Smrg
5437104f784Smrg	/* Wait for vertical retrace */
5447104f784Smrg	while (hwp->readST01(hwp) & 0x8) ;
5457104f784Smrg	while (!(hwp->readST01(hwp) & 0x8)) ;
5467104f784Smrg
5477104f784Smrg	/* Write the registers */
5487104f784Smrg	VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x01, SR01);
5497104f784Smrg	VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x23, mode->SR23);
5507104f784Smrg
5517104f784Smrg	/* Set the DPMS mode to every output and CRTC */
5527104f784Smrg	xf86DPMSSet(pScrn, PowerManagementMode, flags);
5537104f784Smrg
5547104f784Smrg	/* Save the current power state */
5557104f784Smrg	pSmi->CurrentDPMS = PowerManagementMode;
5567104f784Smrg    }
5577104f784Smrg
5587104f784Smrg    LEAVE();
5597104f784Smrg}
5607104f784Smrg
5617104f784Smrgstatic unsigned int
5627104f784SmrgSMILynx_ddc1Read(ScrnInfoPtr pScrn)
5637104f784Smrg{
5647104f784Smrg    register vgaHWPtr hwp = VGAHWPTR(pScrn);
5657104f784Smrg    SMIPtr pSmi = SMIPTR(pScrn);
5667104f784Smrg    unsigned int ret;
5677104f784Smrg
5687104f784Smrg    ENTER();
5697104f784Smrg
5707104f784Smrg    while (hwp->readST01(hwp) & 0x8) ;
5717104f784Smrg    while (!(hwp->readST01(hwp) & 0x8)) ;
5727104f784Smrg
5737104f784Smrg    ret = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72) & 0x08;
5747104f784Smrg
5757104f784Smrg    LEAVE(ret);
5767104f784Smrg}
5777104f784Smrg
578621ff18cSmrgstatic void
579621ff18cSmrgSMILynx_ddc1SetSpeed(ScrnInfoPtr pScrn, xf86ddcSpeed speed)
580621ff18cSmrg{
581621ff18cSmrg    vgaHWddc1SetSpeed(pScrn, speed);
582621ff18cSmrg}
583621ff18cSmrg
5847104f784Smrgxf86MonPtr
5857104f784SmrgSMILynx_ddc1(ScrnInfoPtr pScrn)
5867104f784Smrg{
5877104f784Smrg    SMIPtr pSmi = SMIPTR(pScrn);
5887104f784Smrg    xf86MonPtr pMon;
5897104f784Smrg    unsigned char tmp;
5907104f784Smrg
5917104f784Smrg    ENTER();
5927104f784Smrg
5937104f784Smrg    tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72);
5947104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72, tmp | 0x20);
5957104f784Smrg
5965788ca14Smrg    pMon = xf86PrintEDID(xf86DoEDID_DDC1(XF86_SCRN_ARG(pScrn),
597621ff18cSmrg					 SMILynx_ddc1SetSpeed,
5987104f784Smrg					 SMILynx_ddc1Read));
5997104f784Smrg    VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x72, tmp);
6007104f784Smrg
6017104f784Smrg    LEAVE(pMon);
6027104f784Smrg}
6037104f784Smrg
6047104f784Smrg
6057104f784Smrg/* This function is used to debug, it prints out the contents of Lynx regs */
6067104f784Smrgvoid
6077104f784SmrgSMILynx_PrintRegs(ScrnInfoPtr pScrn)
6087104f784Smrg{
6097104f784Smrg    unsigned char i;
6107104f784Smrg    SMIPtr pSmi = SMIPTR(pScrn);
6117104f784Smrg    vgaHWPtr hwp = VGAHWPTR(pScrn);
6127104f784Smrg    int vgaCRIndex = hwp->IOBase + VGA_CRTC_INDEX_OFFSET;
6137104f784Smrg    int vgaCRReg   = hwp->IOBase + VGA_CRTC_DATA_OFFSET;
6147104f784Smrg    int vgaStatus  = hwp->IOBase + VGA_IN_STAT_1_OFFSET;
6157104f784Smrg
6167104f784Smrg    xf86ErrorFVerb(VERBLEV, "MISCELLANEOUS OUTPUT\n    %02X\n",
6177104f784Smrg		   VGAIN8(pSmi, VGA_MISC_OUT_R));
6187104f784Smrg
6197104f784Smrg    xf86ErrorFVerb(VERBLEV, "\nSEQUENCER\n"
6207104f784Smrg		   "    x0 x1 x2 x3  x4 x5 x6 x7  x8 x9 xA xB  xC xD xE xF");
6217104f784Smrg    for (i = 0x00; i <= 0xAF; i++) {
6227104f784Smrg	if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i);
6237104f784Smrg	if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " ");
6247104f784Smrg	xf86ErrorFVerb(VERBLEV, "%02X ",
6257104f784Smrg		       VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, i));
6267104f784Smrg    }
6277104f784Smrg
6287104f784Smrg    xf86ErrorFVerb(VERBLEV, "\n\nCRT CONTROLLER\n"
6297104f784Smrg		   "    x0 x1 x2 x3  x4 x5 x6 x7  x8 x9 xA xB  xC xD xE xF");
6307104f784Smrg    for (i = 0x00; i <= 0xAD; i++) {
6317104f784Smrg	if (i == 0x20) i = 0x30;
6327104f784Smrg	if (i == 0x50) i = 0x90;
6337104f784Smrg	if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i);
6347104f784Smrg	if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " ");
6357104f784Smrg	xf86ErrorFVerb(VERBLEV, "%02X ",
6367104f784Smrg		       VGAIN8_INDEX(pSmi, vgaCRIndex, vgaCRReg, i));
6377104f784Smrg    }
6387104f784Smrg
6397104f784Smrg    xf86ErrorFVerb(VERBLEV, "\n\nGRAPHICS CONTROLLER\n"
6407104f784Smrg		   "    x0 x1 x2 x3  x4 x5 x6 x7  x8 x9 xA xB  xC xD xE xF");
6417104f784Smrg    for (i = 0x00; i <= 0x08; i++) {
6427104f784Smrg	if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i);
6437104f784Smrg	if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " ");
6447104f784Smrg	xf86ErrorFVerb(VERBLEV, "%02X ",
6457104f784Smrg		       VGAIN8_INDEX(pSmi, VGA_GRAPH_INDEX, VGA_GRAPH_DATA, i));
6467104f784Smrg    }
6477104f784Smrg
6487104f784Smrg    xf86ErrorFVerb(VERBLEV, "\n\nATTRIBUTE 0CONTROLLER\n"
6497104f784Smrg		   "    x0 x1 x2 x3  x4 x5 x6 x7  x8 x9 xA xB  xC xD xE xF");
6507104f784Smrg    for (i = 0x00; i <= 0x14; i++) {
6517104f784Smrg	(void) VGAIN8(pSmi, vgaStatus);
6527104f784Smrg	if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i);
6537104f784Smrg	if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " ");
6547104f784Smrg	xf86ErrorFVerb(VERBLEV, "%02X ",
6557104f784Smrg		       VGAIN8_INDEX(pSmi, VGA_ATTR_INDEX, VGA_ATTR_DATA_R, i));
6567104f784Smrg    }
6577104f784Smrg    (void) VGAIN8(pSmi, vgaStatus);
6587104f784Smrg    VGAOUT8(pSmi, VGA_ATTR_INDEX, 0x20);
6597104f784Smrg}
660