📄 s3misc.c
字号:
pScreen->CloseScreen = s3CloseScreen;#ifndef OSKIT pScreen->SaveScreen = s3SaveScreen; s3savepScreen = pScreen; return (cfbCreateDefColormap(pScreen));#else /* Install some sort of default colormap? */ return (TRUE);#endif}/* * s3EnterLeaveVT -- grab/ungrab the current VT completely. */voids3EnterLeaveVT(enter, screen_idx) Bool enter; int screen_idx;{#ifndef OSKIT PixmapPtr pspix = 0;#endif /* !OSKIT */ ScreenPtr pScreen = s3savepScreen;#ifndef OSKIT if (!xf86Exiting && !xf86Resetting) { /* cfbGetScreenPixmap(pScreen) */ switch (s3InfoRec.bitsPerPixel) { case 8: pspix = (PixmapPtr)pScreen->devPrivate; break; case 16: pspix = (PixmapPtr)pScreen->devPrivates[cfb16ScreenPrivateIndex].ptr; break; case 24: pspix = (PixmapPtr)pScreen->devPrivates[cfb24ScreenPrivateIndex].ptr; break; case 32: pspix = (PixmapPtr)pScreen->devPrivates[cfb32ScreenPrivateIndex].ptr; break; } }#endif /* !OSKIT */ if (enter) {#ifdef PC98 s3EnterLeaveMachdep(S3PC98SERVER_ENTER);#endif xf86MapDisplay(screen_idx, VGA_REGION); if (s3VideoMem != vgaBase) xf86MapDisplay(screen_idx, LINEAR_REGION); if (!xf86Resetting) { ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); s3Unlock(); s3Init(s3InfoRec.modes); s3InitEnvironment(); AlreadyInited = TRUE; s3RestoreDACvalues(); s3ImageInit();#ifndef OSKIT s3FontCache8Init();#endif /* !OSKIT */ s3RestoreColor0(pScreen);#ifndef OSKIT (void)s3CursorInit(0, pScreen); s3RestoreCursor(pScreen);#endif /* !OSKIT */ s3AdjustFrame(pScr->frameX0, pScr->frameY0);#ifndef OSKIT if ((pointer)pspix->devPrivate.ptr != s3VideoMem && ppix) { pspix->devPrivate.ptr = s3VideoMem; (*s3ImageWriteFunc)(0, 0, pScreen->width, pScreen->height, ppix->devPrivate.ptr, PixmapBytePad(s3DisplayWidth, pScreen->rootDepth), 0, 0, s3alu[GXcopy], ~0); }#endif /* !OSKIT */ }#ifndef OSKIT if (ppix) { (pScreen->DestroyPixmap)(ppix); ppix = NULL; }#endif /* !OSKIT */ } else { /* Make sure that another driver hasn't disabled IO */ xf86MapDisplay(screen_idx, VGA_REGION); if (s3VideoMem != vgaBase) xf86MapDisplay(screen_idx, LINEAR_REGION);#ifndef OSKIT if (!xf86Exiting) { ppix = (pScreen->CreatePixmap)(pScreen, s3DisplayWidth, pScreen->height, pScreen->rootDepth); if (ppix) { (*s3ImageReadFunc)(0, 0, pScreen->width, pScreen->height, ppix->devPrivate.ptr, PixmapBytePad(s3DisplayWidth, pScreen->rootDepth), 0, 0, ~0); pspix->devPrivate.ptr = ppix->devPrivate.ptr; } }#endif /* !OSKIT */#ifdef XFreeXDGA if (s3InfoRec.directMode & XF86DGADirectGraphics) { s3HideCursor(); } else#endif if (AlreadyInited) { s3CleanUp(); AlreadyInited = FALSE; } xf86UnMapDisplay(screen_idx, VGA_REGION); if (s3VideoMem != vgaBase) xf86UnMapDisplay(screen_idx, LINEAR_REGION);#ifdef XFreeXDGA if (s3InfoRec.directMode & XF86DGADirectGraphics) { /* make sure we are in linear mode */ s3EnableLinear(); s3Unlock(); }#endif#ifdef PC98 s3EnterLeaveMachdep(S3PC98SERVER_LEAVE);#endif }}/* * s3CloseScreen -- called to ensure video is enabled when server exits. */Bools3CloseScreen(screen_idx, pScreen) int screen_idx; ScreenPtr pScreen;{ /* * Hmm... The server may shut down even if it is not running on the current * vt. Let's catch this case here. */ xf86Exiting = TRUE; if (xf86VTSema) s3EnterLeaveVT(LEAVE, screen_idx);#ifndef OSKIT else if (ppix) { /* * 7-Jan-94 CEG: The server is not running on the current vt. * Free the screen snapshot taken when the server vt was left. */ (s3savepScreen->DestroyPixmap)(ppix); ppix = NULL; }#endif return (TRUE);}/* * s3SaveScreen -- blank the screen. */Bools3SaveScreen(pScreen, on) ScreenPtr pScreen; Bool on;{ unsigned char scrn;#ifndef OSKIT if (on) SetTimeSinceLastInputEvent();#endif /* !OSKIT */ if (xf86VTSema) { /* the server is running on the current vt */ /* so just go for it */ outb(0x3C4,1); scrn = inb(0x3C5); if (on) { scrn &= 0xDF; /* enable screen */ } else { scrn |= 0x20; /* blank screen */ } outw(0x3C4, 0x0100); /* syncronous reset */ outw(0x3C4, (scrn << 8) | 0x01); /* change mode */ outw(0x3C4, 0x0300); /* end reset */ } return (TRUE);}/* * s3DPMSSet -- Sets VESA Display Power Management Signaling (DPMS) Mode */#ifdef DPMSExtensionvoids3DPMSSet(PowerManagementMode) int PowerManagementMode;{ unsigned char seq1, extsync; if (!xf86VTSema) return; switch (PowerManagementMode) { case DPMSModeOn: /* Screen: On; HSync: On, VSync: On */ seq1 = 0x00; extsync = 0x00; break; case DPMSModeStandby: /* Screen: Off; HSync: Off, VSync: On */ seq1 = 0x20; extsync = 0x10; break; case DPMSModeSuspend: /* Screen: Off; HSync: On, VSync: Off */ seq1 = 0x20; extsync = 0x40; break; case DPMSModeOff: /* Screen: Off; HSync: Off, VSync: Off */ seq1 = 0x20; extsync = 0x50; break; } outw(0x3C4, 0x0608); /* Unlock SRD */ outw(0x3C4, 0x0100); /* Synchronous Reset */ outb(0x3C4, 0x01); /* Select SEQ1 */ seq1 |= inb(0x3C5) & ~0x20; outb(0x3C5, seq1); outb(0x3C4, 0x0D); /* Select SEQD */ extsync |= inb(0x3C5) & ~0xF0; usleep(10000); outb(0x3C5, extsync); outw(0x3C4, 0x0300); /* End Reset */ outw(0x3C4, 0x0008); /* Lock SRD */}#endifstatic debugcache = 0;Bools3SwitchMode(mode) DisplayModePtr mode;{ WaitIdle(); /* wait till idle */ if (OFLG_ISSET(OPTION_SHOWCACHE, &s3InfoRec.options)) { debugcache++; if (debugcache & 1) { mode = mode->prev; s3InfoRec.modes=mode; } } if (s3Init(mode)) { s3ModeSwitched = TRUE;#if notyet s3Restore(vgaNewVideoState);#endif s3ImageInit(); /* mode switching changes the memory bank */#ifndef OSKIT s3RestoreCursor(s3savepScreen);#endif /* !OSKIT */ return (TRUE); } else { ErrorF("Mode switch failed because of hardware initialisation error\n"); s3ImageInit(); return (FALSE); }}voids3AdjustFrame(int x, int y){ int Base, origBase; unsigned char tmp; extern int s3AdjustCursorXPos; /* for s3Cursor.c */ extern int s3HDisplay; if (OFLG_ISSET(OPTION_SHOWCACHE, &s3InfoRec.options)) { if ( debugcache & 1) y += 512; } if (x > s3DisplayWidth - s3HDisplay) x = s3DisplayWidth - s3HDisplay; /* so may S3 cards have problems with some odd base addresses, * to catch them all only even base values will be used. */ origBase = (y * s3DisplayWidth + x) * s3Bpp; Base = (origBase >> 2) & ~1; if (S3_964_SERIES(s3ChipId) && DAC_IS_BT485_SERIES) { if ((Base & 0x3f) >= 0x3c) Base = (Base & ~0x3f) | 0x3b; else if (s3Bpp>1 && (Base & 0x3f) == 0x3a) Base = (Base & ~0x3f) | 0x39; else if (s3Bpp>2 && (Base & 0x1f) == 0x1a) Base = (Base & ~0x1f) | 0x19; } if (S3_964_SERIES(s3ChipId) && (DAC_IS_TI3025 || DAC_IS_TI3026 || DAC_IS_TI3030 || DAC_IS_IBMRGB)) { int px, py, a;#ifndef OSKIT miPointerPosition(&px, &py);#else px = py = 0;#endif if (s3Bpp == 3) { if (DAC_IS_TI3030 || DAC_IS_IBMRGB528) a = 12; else a = 6; if (px-x > s3HDisplay/2) Base = ((origBase + (a-1)*4) >> 2) & ~1; Base -= Base % a; } else { if (s3Bpp==1 && !DAC_IS_TI3030 && !DAC_IS_IBMRGB528) a = 4-1; else a = 8-1; if (px-x > s3HDisplay/2) Base = ((origBase + a*4) >> 2) & ~1; Base &= ~a; } } outb(vgaCRIndex, 0x31); outb(vgaCRReg, ((Base & 0x030000) >> 12) | s3Port31); s3Port51 &= ~0x03; s3Port51 |= ((Base & 0x0c0000) >> 18); outb(vgaCRIndex, 0x51); /* Don't override current bank selection */ tmp = (inb(vgaCRReg) & ~0x03) | (s3Port51 & 0x03); outb(vgaCRReg, tmp); outw(vgaCRIndex, (Base & 0x00FF00) | 0x0C); outw(vgaCRIndex, ((Base & 0x00FF) << 8) | 0x0D);#ifndef OSKIT#ifdef XFreeXDGA if (!(s3InfoRec.directMode & XF86DGADirectMouse)) {#endif s3AdjustCursorXPos = (origBase - (Base << 2)) / s3Bpp; if (s3ModeSwitched) { s3ModeSwitched = FALSE; s3RestoreCursor(s3savepScreen); } else { s3RepositionCursor(s3savepScreen); }#ifdef XFreeXDGA }#endif#endif /* !OSKIT */#ifdef XFreeXDGA if (s3InfoRec.directMode & XF86DGADirectGraphics) { /* Wait until vertical retrace is in progress. */ s3WaitRetrace(); }#endif}/* * Force optimising compilers to read *addr */static Bools3TryAddress(addr, value, physaddr, stage) long *addr; long value; long physaddr; int stage;{ long tmp; tmp = *addr; if (OFLG_ISSET(OPTION_FB_DEBUG, &s3InfoRec.options)) { if (stage == 0 && tmp != 0xFFFFFFFF) { ErrorF("Memory found at 0x%08X (read 0x%08X)\n", physaddr, tmp); } else { ErrorF("Stage %d: address = 0x%08X, read 0x%08X\n", stage, physaddr, tmp); } } if (tmp == value) return TRUE; else return FALSE;}void s3SetVidPage(vPage) int vPage;{ s3BankSelect(vPage);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -