📄 s3.c
字号:
/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/s3/s3.c,v 3.155.2.13 1997/07/07 04:11:07 dawes Exp $ *//* * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Thomas Roell not be used in * advertising or publicity pertaining to distribution of the software * without specific, written prior permission. Thomas Roell makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * THOMAS ROELL AND KEVIN E. MARTIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, * IN NO EVENT SHALL THOMAS ROELL OR KEVIN E. MARTIN BE LIABLE FOR ANY * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Thomas Roell, roell@informatik.tu-muenchen.de * * Rewritten for the 8514/A by Kevin E. Martin (martin@cs.unc.edu) * * Header: /home/src/xfree86/mit/server/ddx/xf86/accel/s3/RCS/s3.c,v 2.0 * 1993/02/22 05:58:13 jon Exp * * Modified by Amancio Hasty and Jon Tombs * * Rather severely reorganized by MArk Vojkovich (mvojkovi@ucsd.edu) * *//* $XConsortium: s3.c /main/48 1996/12/28 15:54:30 kaleb $ */#include "misc.h"#ifndef OSKIT#include "cfb.h"#include "pixmapstr.h"#include "fontstruct.h"#endif /* !OSKIT */#include "s3.h"#include "regs3.h"#include "xf86_HWlib.h"#include "xf86_PCI.h"#define XCONFIG_FLAGS_ONLY#include "xf86_Config.h"#include "s3linear.h"#include "s3Bt485.h"#include "Ti302X.h"#include "IBMRGB.h"#include "s3ELSA.h"#ifdef XFreeXDGA#include "X.h"#include "Xproto.h"#include "scrnintstr.h"#include "servermd.h"#define _XF86DGA_SERVER_#include "extensions/xf86dgastr.h"#endif#ifdef PC98#include "pc98_vers.h"#include "s3pc98.h"#endifextern int s3MaxClock;char s3Mbanks;int s3Weight = RGB8_PSEUDO;extern char *xf86VisualNames[];char *clockchip_probed = XCONFIG_GIVEN;extern s3VideoChipPtr s3Drivers[];int vgaInterlaceType = VGA_DIVIDE_VERT;void (*vgaSaveScreenFunc)() = vgaHWSaveScreen;#ifndef OSKITextern int defaultColorVisualClass;#elseint defaultColorVisualClass = -1;#endifstatic int s3ValidMode(#if NeedFunctionPrototypes DisplayModePtr, Bool, int#endif);extern unsigned char *find_bios_string(#if NeedFunctionPrototypes int /* BIOSbase */, char * /* match1 */, char * /* match2 */#endif);ScrnInfoRec s3InfoRec ={ FALSE, /* Bool configured */ -1, /* int tmpIndex */ -1, /* int scrnIndex */ s3Probe, /* Bool (* Probe)() */ (Bool (*)())NoopDDA, /* Bool (* Init)() */ s3ValidMode, /* int (* ValidMode)() */ (void (*)())NoopDDA, /* void (* EnterLeaveVT)() */ (void (*)())NoopDDA, /* void (* EnterLeaveMonitor)() */ (void (*)())NoopDDA, /* void (* EnterLeaveCursor)() */ (void (*)())NoopDDA, /* void (* AdjustFrame)() */ (Bool (*)())NoopDDA, /* Bool (* SwitchMode)() */ vgaDPMSSet, /* void (* DPMSSet)() */ s3PrintIdent, /* void (* PrintIdent)() */ 8, /* int depth */ {5, 6, 5}, /* xrgb weight */ 8, /* int bitsPerPixel */ PseudoColor, /* int defaultVisual */ -1, -1, /* int virtualX,virtualY */ -1, /* int displayWidth */ -1, -1, -1, -1, /* int frameX0, frameY0, frameX1, frameY1 */ {{0}}, /* OFlagSet options */ {{0}}, /* OFlagSet clockOptions */ {{0}}, /* OFlagSet xconfigFlag */ NULL, /* char *chipset */ NULL, /* char *ramdac */ {0, 0, 0, 0}, /* int dacSpeeds[MAXDACSPEEDS] */ 0, /* int dacSpeedBpp */ 0, /* int clocks */ {0,}, /* int clock[MAXCLOCKS] */ 0, /* int maxClock */ 0, /* int videoRam */ 0xC0000, /* int BIOSbase */ 0, /* unsigned long MemBase */ 240, 180, /* int width, height */ 0, /* unsigned long speedup */ NULL, /* DisplayModePtr modes */ NULL, /* MonPtr monitor */ NULL, /* char *clockprog */ -1, /* int textclock */ FALSE, /* Bool bankedMono */ "S3", /* char *name */ {0, }, /* xrgb blackColour */ {0, }, /* xrgb whiteColour */ s3ValidTokens, /* int *validTokens */ S3_PATCHLEVEL, /* char *patchlevel */ 0, /* int IObase */ 0, /* int PALbase */ 0, /* int COPbase */ 0, /* int POSbase */ 0, /* int instance */ 0, /* int s3Madjust */ 0, /* int s3Nadjust */ 0, /* int s3MClk */ 0, /* int chipID */ 0, /* int chipRev */ 0, /* unsigned long VGAbase */ 0, /* int s3RefClk */ -1, /* int s3BlankDelay */ 0, /* int textClockFreq */ NULL, /* char* DCConfig */ NULL, /* char* DCOptions */ 0 /* int MemClk */#ifdef XFreeXDGA ,0, /* int directMode */ s3SetVidPage, /* Set Vid Page */ 0, /* unsigned long physBase */ 0 /* int physSize */#endif};typedef struct S3PCIInformation { int DevID; int ChipType; int ChipRev; unsigned long MemBase;} S3PCIInformation;short s3alu[16] ={ MIX_0, MIX_AND, MIX_SRC_AND_NOT_DST, MIX_SRC, MIX_NOT_SRC_AND_DST, MIX_DST, MIX_XOR, MIX_OR, MIX_NOR, MIX_XNOR, MIX_NOT_DST, MIX_SRC_OR_NOT_DST, MIX_NOT_SRC, MIX_NOT_SRC_OR_DST, MIX_NAND, MIX_1};static unsigned S3_IOPorts[] = { DISP_STAT, H_TOTAL, H_DISP, H_SYNC_STRT, H_SYNC_WID, V_TOTAL, V_DISP, V_SYNC_STRT, V_SYNC_WID, DISP_CNTL, ADVFUNC_CNTL, SUBSYS_STAT, SUBSYS_CNTL, ROM_PAGE_SEL, CUR_Y, CUR_X, DESTY_AXSTP, DESTX_DIASTP, ERR_TERM, MAJ_AXIS_PCNT, GP_STAT, CMD, SHORT_STROKE, BKGD_COLOR, FRGD_COLOR, WRT_MASK, RD_MASK, COLOR_CMP, BKGD_MIX, FRGD_MIX, MULTIFUNC_CNTL, PIX_TRANS, PIX_TRANS_EXT,};static int Num_S3_IOPorts = (sizeof(S3_IOPorts)/sizeof(S3_IOPorts[0]));static SymTabRec s3DacTable[] = { { NORMAL_DAC, "normal" }, { BT485_DAC, "bt485" }, { BT485_DAC, "bt9485" }, { ATT20C505_DAC, "att20c505" }, { TI3020_DAC, "ti3020" }, { ATT20C498_DAC, "att20c498" }, { ATT20C498_DAC, "att21c498" }, { ATT22C498_DAC, "att22c498" }, { TI3025_DAC, "ti3025" }, { TI3026_DAC, "ti3026" }, { TI3030_DAC, "ti3030" }, { IBMRGB525_DAC, "ibm_rgb514" }, { IBMRGB524_DAC, "ibm_rgb524" }, { IBMRGB525_DAC, "ibm_rgb525" }, { IBMRGB524_DAC, "ibm_rgb526" }, { IBMRGB528_DAC, "ibm_rgb528" }, { ATT20C490_DAC, "att20c490" }, { ATT20C490_DAC, "att20c491" }, { ATT20C490_DAC, "ch8391" }, { SC1148x_M2_DAC, "sc11482" }, { SC1148x_M2_DAC, "sc11483" }, { SC1148x_M2_DAC, "sc11484" }, { SC1148x_M3_DAC, "sc11485" }, { SC1148x_M3_DAC, "sc11487" }, { SC1148x_M3_DAC, "sc11489" }, { SC15025_DAC, "sc15025" }, { STG1700_DAC, "stg1700" }, { STG1703_DAC, "stg1703" }, { S3_SDAC_DAC, "s3_sdac" }, { S3_SDAC_DAC, "ics5342" }, /* XXXX should be checked if true */ { S3_GENDAC_DAC, "s3gendac" }, { S3_GENDAC_DAC, "ics5300" }, { S3_TRIO32_DAC, "s3_trio32" }, { S3_TRIO64_DAC, "s3_trio64" }, { S3_TRIO64_DAC, "s3_trio" }, { ATT20C409_DAC, "att20c409" }, { SS2410_DAC, "ss2410" }, { S3_TRIO64V2_DAC, "s3_trio64v2" }, { -1, "" },};static SymTabRec s3ChipTable[] = { { S3_UNKNOWN, "unknown" }, { S3_911, "911" }, { S3_924, "924" }, { S3_801, "801" }, { S3_805, "805" }, { S3_928, "928" }, { S3_TRIO_32_64, "Trio32/64" }, { S3_864, "864" }, { S3_868, "868" }, { S3_964, "964" }, { S3_968, "968" }, { S3_TRIO32, "Trio32" }, { S3_TRIO64, "Trio64" }, { S3_TRIO64VP, "Trio64V+" }, { S3_ViRGE, "ViRGE" }, { S3_ViRGE_VX, "ViRGE/VX" }, { S3_ViRGE_DXGX, "ViRGE/DX or /GX" }, { S3_TRIO64UVP, "Trio64UV+" }, { S3_AURORA64VP, "Aurora64V+" }, { S3_TRIO64V2, "Trio64V2" }, { S3_PLATO_PX, "PLATO/PX" }, { -1, "" },};#ifndef OSKITextern miPointerScreenFuncRec xf86PointerScreenFuncs;#endif /* !OSKIT */ScreenPtr s3savepScreen;Bool s3Localbus = FALSE;Bool s3VLB = FALSE;Bool s3NewMmio = FALSE;Bool s3LinearAperture = FALSE;Bool s3Mmio928 = FALSE;Bool s3PixelMultiplexing = FALSE;Bool s3DAC8Bit = FALSE;Bool s3DACSyncOnGreen = FALSE;Bool s3PCIHack = FALSE;unsigned char s3LinApOpt;unsigned char s3SAM256 = 0x00;int s3BankSize;int s3DisplayWidth;pointer vgaBase = NULL;pointer vgaBaseLow = NULL;pointer vgaBaseHigh = NULL;pointer s3VideoMem = NULL;pointer s3MmioMem = NULL;int s3Trio32FCBug = 0;int s3_968_DashBug = 0;unsigned long s3MemBase = 0;Bool tmp_useSWCursor = FALSE;#ifdef __alpha__unsigned long _bus_base(void);Bool isJensen = FALSE;#endifextern Bool xf86Exiting, xf86Resetting, xf86ProbeFailed;extern int xf86Verbose;int s3ScissR; int s3ScissB;unsigned char s3SwapBits[256];unsigned char s3Port40;unsigned char s3Port51;unsigned char s3Port54;unsigned char s3Port59 = 0x00;unsigned char s3Port5A = 0x00;unsigned char s3Port31 = 0x8d;void (*s3ImageReadFunc)(#if NeedFunctionPrototypes int, int, int, int, char *, int, int, int, unsigned long#endif);void (*s3ImageWriteFunc)(#if NeedFunctionPrototypes int, int, int, int, char *, int, int, int, short, unsigned long#endif);void (*s3ImageFillFunc)(#if NeedFunctionPrototypes int, int, int, int, char *, int, int, int, int, int, short, unsigned long#endif);int s3hotX, s3hotY;Bool s3BlockCursor, s3ReloadCursor;int s3CursorStartX, s3CursorStartY, s3CursorLines;int s3RamdacType = UNKNOWN_DAC;Bool s3UsingPixMux = FALSE;Bool s3Bt485PixMux = FALSE;Bool s3ATT498PixMux = FALSE;int maxRawClock = 0;Bool clockDoublingPossible = FALSE;int s3AdjustCursorXPos = 0;int s3BiosVendor = UNKNOWN_BIOS;static Bool in_s3Probe = TRUE; /* s3ValidMode helpers */static Bool not_safe = TRUE;static int TempVirtualX, TempVirtualY;int s3Bpp;int s3BppDisplayWidth;#ifdef PC98extern Bool BoardInit();extern int pc98BoardType;#endif/* * s3PrintIdent -- print identification message */voids3PrintIdent(){ int i, j, n = 0, c = 0; char *id; ErrorF(" %s: accelerated server for S3 graphics adaptors (Patchlevel %s)\n", s3InfoRec.name, s3InfoRec.patchLevel); ErrorF(" "); for (i = 0; s3Drivers[i]; i++) for (j = 0; (id = (s3Drivers[i]->ChipIdent)(j)); j++, n++) { if (n) { ErrorF(","); c++; if (c + 1 + strlen(id) < 70) { ErrorF(" "); c++; } else { ErrorF("\n "); c = 0; } } ErrorF("%s", id); c += strlen(id); } ErrorF("\n");#ifdef PC98 ErrorF(" PC98: Supported Video Boards:\n\t%s\n",PC98_S3_BOARDS);#endif}unsigned char *find_bios_string(int BIOSbase, char *match1, char *match2){#define BIOS_BSIZE 1024#define BIOS_BASE 0xc0000 static unsigned char bios[BIOS_BSIZE]; static int init=0; int i,j,l1,l2; if (!init) { init = 1; if (xf86ReadBIOS(BIOSbase, 0, bios, BIOS_BSIZE) != BIOS_BSIZE) return NULL; if ((bios[0] != 0x55) || (bios[1] != 0xaa)) return NULL; } if (match1 == NULL)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -