trident.h revision ff89ac2b
1/* 2 * Copyright 1992-2003 by Alan Hourihane, North Wales, UK. 3 * 4 * Permission to use, copy, modify, distribute, and sell this software and its 5 * documentation for any purpose is hereby granted without fee, provided that 6 * the above copyright notice appear in all copies and that both that 7 * copyright notice and this permission notice appear in supporting 8 * documentation, and that the name of Alan Hourihane not be used in 9 * advertising or publicity pertaining to distribution of the software without 10 * specific, written prior permission. Alan Hourihane makes no representations 11 * about the suitability of this software for any purpose. It is provided 12 * "as is" without express or implied warranty. 13 * 14 * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 20 * PERFORMANCE OF THIS SOFTWARE. 21 * 22 * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> 23 */ 24/*#define VBE_INFO*/ 25 26#ifndef _TRIDENT_H_ 27#define _TRIDENT_H_ 28 29#include <stdio.h> 30#include <string.h> 31#include <math.h> 32 33#include "tridentpcirename.h" 34 35#include "exa.h" 36#include "xf86Cursor.h" 37#include "xaa.h" 38#include "xf86RamDac.h" 39#include "compiler.h" 40#include "vgaHW.h" 41#include "xf86i2c.h" 42#include "xf86int10.h" 43#include "shadowfb.h" 44#include "shadow.h" 45#include "xf86xv.h" 46#include "xf86Pci.h" 47#include "vbe.h" 48 49#define PCI_CHIP_2200 0x2200 50 51typedef struct { 52 unsigned char tridentRegs3x4[0x100]; 53 unsigned char tridentRegs3CE[0x100]; 54 unsigned char tridentRegs3C4[0x100]; 55 unsigned char tridentRegsDAC[0x01]; 56 unsigned char tridentRegsClock[0x05]; 57 unsigned char DacRegs[0x300]; 58} TRIDENTRegRec, *TRIDENTRegPtr; 59 60#define VGA_REGNUM_ABOUT_TV 19 61#define TRIDENTPTR(p) ((TRIDENTPtr)((p)->driverPrivate)) 62 63typedef struct { 64 ScrnInfoPtr pScrn; 65 pciVideoPtr PciInfo; 66 PCITAG PciTag; 67 EntityInfoPtr pEnt; 68 ExaDriverPtr EXADriverPtr; 69 int useEXA; 70 int Chipset; 71 int DACtype; 72 int RamDac; 73 int ChipRev; 74 int HwBpp; 75 int BppShift; 76 CARD32 IOAddress; 77 unsigned long FbAddress; 78 unsigned char * IOBase; 79 unsigned char * FbBase; 80 long FbMapSize; 81 IOADDRESS PIOBase; 82 Bool NoAccel; 83 Bool HWCursor; 84 Bool UsePCIRetry; 85 Bool UsePCIBurst; 86 Bool NewClockCode; 87 Bool Clipping; 88 Bool DstEnable; 89 Bool ROP; 90 Bool HasSGRAM; 91 Bool MUX; 92 Bool IsCyber; 93 Bool CyberShadow; 94 Bool CyberStretch; 95 Bool NoMMIO; 96 Bool MMIOonly; 97 Bool ShadowFB; 98 Bool Linear; 99 DGAModePtr DGAModes; 100 int numDGAModes; 101 Bool DGAactive; 102 int DGAViewportStatus; 103 unsigned char * ShadowPtr; 104 int ShadowPitch; 105 RefreshAreaFuncPtr RefreshArea; 106 void (*PointerMoved)(int index, int x, int y); 107 int Rotate; 108 float frequency; 109 unsigned char REGPCIReg; 110 unsigned char REGNewMode1; 111 CARD8 SaveClock1; 112 CARD8 SaveClock2; 113 CARD8 SaveClock3; 114 int MinClock; 115 int MaxClock; 116 int MUXThreshold; 117 int currentClock; 118 int MCLK; 119 int dwords; 120 int h; 121 int x; 122 int w; 123 int y; 124 int lcdMode; 125 Bool lcdActive; 126 Bool doInit; 127#ifdef READOUT 128 Bool DontSetClock; 129#endif 130 TRIDENTRegRec SavedReg; 131 TRIDENTRegRec ModeReg; 132 I2CBusPtr DDC; 133 CARD16 EngineOperation; 134 CARD32 PatternLocation; 135 CARD32 BltScanDirection; 136 CARD32 DrawFlag; 137 CARD16 LinePattern; 138 RamDacRecPtr RamDacRec; 139 int CursorOffset; 140 xf86CursorInfoPtr CursorInfoRec; 141 xf86Int10InfoPtr Int10; 142 vbeInfoPtr pVbe; 143#ifdef VBE_INFO 144 vbeModeInfoPtr vbeModes; 145#endif 146 XAAInfoRecPtr AccelInfoRec; 147 CloseScreenProcPtr CloseScreen; 148 ScreenBlockHandlerProcPtr BlockHandler; 149 int panelWidth; 150 int panelHeight; 151 unsigned int (*ddc1Read)(ScrnInfoPtr); 152 CARD8* XAAScanlineColorExpandBuffers[2]; 153 CARD8* XAAImageScanlineBuffer[1]; 154 void (*InitializeAccelerator)(ScrnInfoPtr); 155 void (*VideoTimerCallback)(ScrnInfoPtr, Time); 156 XF86VideoAdaptorPtr adaptor; 157 int videoKey; 158 int hsync; 159 int hsync_rskew; 160 int vsync; 161 int vsync_bskew; 162 CARD32 videoFlags; 163 int keyOffset; 164 int OverrideHsync; 165 int OverrideVsync; 166 int OverrideBskew; 167 int OverrideRskew; 168 OptionInfoPtr Options; 169 Bool shadowNew; 170 int displaySize; 171 int dspOverride; 172 Bool GammaBrightnessOn; 173 int brightness; 174 double gamma; 175 int FPDelay; /* just for debugging - will go away */ 176 int TVChipset; /* 0: None 1: VT1621 2: CH7005C*/ 177 int TVSignalMode; /* 0: NTSC 1: PAL */ 178 Bool TVRegSet; /* 0: User not customer TV Reg, 1: User customer TV Reg */ 179 unsigned char TVRegUserSet[2][128]; /*[0][128] for Reg Index, [1][128] for Reg Value */ 180 unsigned char DefaultTVDependVGASetting[VGA_REGNUM_ABOUT_TV+0x62]; /* VGA_REGNUM_ABOUT_TV: VGA Reg, 0x62: TV Reg */ 181} TRIDENTRec, *TRIDENTPtr; 182 183typedef struct { 184 CARD8 mode; 185 int display_x; 186 int display_y; 187 int clock; 188 int shadow_0; 189 int shadow_3; 190 int shadow_4; 191 int shadow_5; 192 int shadow_6; 193 int shadow_7; 194 int shadow_10; 195 int shadow_11; 196 int shadow_16; 197 int shadow_HiOrd; 198} tridentLCD; 199 200#define LCD_ACTIVE 0x01 201#define CRT_ACTIVE 0x02 202 203extern tridentLCD LCD[]; 204 205typedef struct { 206 int x_res; 207 int y_res; 208 int mode; 209} biosMode; 210 211typedef struct { 212 int x_res; 213 int y_res; 214 CARD8 GR5a; 215 CARD8 GR5c; 216} newModes; 217 218/* Prototypes */ 219 220Bool TRIDENTClockSelect(ScrnInfoPtr pScrn, int no); 221Bool TRIDENTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); 222void TRIDENTAdjustFrame(int scrnIndex, int x, int y, int flags); 223Bool TRIDENTDGAInit(ScreenPtr pScreen); 224Bool TRIDENTI2CInit(ScreenPtr pScreen); 225void TRIDENTInitVideo(ScreenPtr pScreen); 226void TRIDENTResetVideo(ScrnInfoPtr pScrn); 227unsigned int Tridentddc1Read(ScrnInfoPtr pScrn); 228void TVGARestore(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg); 229void TVGASave(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg); 230Bool TVGAInit(ScrnInfoPtr pScrn, DisplayModePtr mode); 231void TridentRestore(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg); 232void TridentSave(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg); 233Bool TridentInit(ScrnInfoPtr pScrn, DisplayModePtr mode); 234Bool TridentAccelInit(ScreenPtr pScreen); 235Bool XPAccelInit(ScreenPtr pScreen); 236Bool XP4XaaInit(ScreenPtr pScreen); 237Bool XP4ExaInit(ScreenPtr pScreen); 238Bool ImageAccelInit(ScreenPtr pScreen); 239Bool BladeXaaInit(ScreenPtr pScreen); 240Bool BladeExaInit(ScreenPtr pScreen); 241Bool TridentHWCursorInit(ScreenPtr pScreen); 242int TridentFindMode(int xres, int yres, int depth); 243void TGUISetClock(ScrnInfoPtr pScrn, int clock, unsigned char *a, unsigned char *b); 244void TGUISetMCLK(ScrnInfoPtr pScrn, int clock, unsigned char *a, unsigned char *b); 245void tridentSetModeBIOS(ScrnInfoPtr pScrn, DisplayModePtr mode); 246void TridentOutIndReg(ScrnInfoPtr pScrn, 247 CARD32 reg, unsigned char mask, unsigned char data); 248unsigned char TridentInIndReg(ScrnInfoPtr pScrn, CARD32 reg); 249void TridentLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, LOCO *colors, VisualPtr pVisual); 250void TridentSetOverscan(ScrnInfoPtr pScrn, int overscan); 251int TGUISetRead(ScreenPtr pScreen, int bank); 252int TGUISetWrite(ScreenPtr pScreen, int bank); 253int TGUISetReadWrite(ScreenPtr pScreen, int bank); 254int TVGA8900SetRead(ScreenPtr pScreen, int bank); 255int TVGA8900SetWrite(ScreenPtr pScreen, int bank); 256int TVGA8900SetReadWrite(ScreenPtr pScreen, int bank); 257void TridentFindClock(ScrnInfoPtr pScrn, int clock); 258float CalculateMCLK(ScrnInfoPtr pScrn); 259void TRIDENTRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 260void TRIDENTShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf); 261void TRIDENTPointerMoved(int index, int x, int y); 262void TRIDENTRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 263void TRIDENTRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 264void TRIDENTRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 265void TRIDENTRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 266 267void VIA_TVInit(ScrnInfoPtr pScrn); 268void VIA_SaveTVDepentVGAReg(ScrnInfoPtr pScrn); 269void VIA_RestoreTVDependVGAReg(ScrnInfoPtr pScrn); 270void VIA_DumpReg(ScrnInfoPtr pScrn); 271 272/* 273 * Trident Chipset Definitions 274 */ 275 276/* Supported chipsets */ 277typedef enum { 278 TVGA8200LX, 279 TVGA8800BR, 280 TVGA8800CS, 281 TVGA8900B, 282 TVGA8900C, 283 TVGA8900CL, 284 TVGA8900D, 285 TVGA9000, 286 TVGA9000i, 287 TVGA9100B, 288 TVGA9200CXr, 289 TGUI9400CXi, 290 TGUI9420DGi, 291 TGUI9430DGi, 292 TGUI9440AGi, 293 CYBER9320, 294 TGUI9660, 295 TGUI9680, 296 PROVIDIA9682, 297 CYBER9382, 298 CYBER9385, 299 PROVIDIA9685, 300 CYBER9388, 301 CYBER9397, 302 CYBER9397DVD, 303 CYBER9520, 304 CYBER9525DVD, 305 IMAGE975, 306 IMAGE985, 307 BLADE3D, 308 CYBERBLADEI7, 309 CYBERBLADEI7D, 310 CYBERBLADEI1, 311 CYBERBLADEI1D, 312 CYBERBLADEAI1, 313 CYBERBLADEAI1D, 314 CYBERBLADEE4, 315 BLADEXP, 316 CYBERBLADEXPAI1, 317 CYBERBLADEXP4, 318 XP5 319} TRIDENTType; 320 321#define UseMMIO (pTrident->NoMMIO == FALSE) 322 323#define IsPciCard (pTrident->pEnt->location.type == BUS_PCI) 324 325#ifdef HAVE_ISA 326# define IsPrimaryCard ((xf86IsPrimaryPci(pTrident->PciInfo)) || \ 327 (xf86IsPrimaryIsa())) 328#else 329# define IsPrimaryCard (xf86IsPrimaryPci(pTrident->PciInfo)) 330#endif 331 332#define HAS_DST_TRANS ((pTrident->Chipset == PROVIDIA9682) || \ 333 (pTrident->Chipset == PROVIDIA9685) || \ 334 (pTrident->Chipset == BLADEXP) || \ 335 (pTrident->Chipset == CYBERBLADEXPAI1)) 336 337#define Is3Dchip ((pTrident->Chipset == CYBER9397) || \ 338 (pTrident->Chipset == CYBER9397DVD) || \ 339 (pTrident->Chipset == CYBER9520) || \ 340 (pTrident->Chipset == CYBER9525DVD) || \ 341 (pTrident->Chipset == CYBERBLADEE4) || \ 342 (pTrident->Chipset == IMAGE975) || \ 343 (pTrident->Chipset == IMAGE985) || \ 344 (pTrident->Chipset == CYBERBLADEI7) || \ 345 (pTrident->Chipset == CYBERBLADEI7D) || \ 346 (pTrident->Chipset == CYBERBLADEI1) || \ 347 (pTrident->Chipset == CYBERBLADEI1D) || \ 348 (pTrident->Chipset == CYBERBLADEAI1) || \ 349 (pTrident->Chipset == CYBERBLADEAI1D) || \ 350 (pTrident->Chipset == BLADE3D) || \ 351 (pTrident->Chipset == CYBERBLADEXPAI1) || \ 352 (pTrident->Chipset == CYBERBLADEXP4) || \ 353 (pTrident->Chipset == XP5) || \ 354 (pTrident->Chipset == BLADEXP)) 355 356/* 357 * Trident DAC's 358 */ 359 360#define TKD8001 0 361#define TGUIDAC 1 362 363/* 364 * Video Flags 365 */ 366 367#define VID_ZOOM_INV 0x1 368#define VID_ZOOM_MINI 0x2 369#define VID_OFF_SHIFT_4 0x4 370#define VID_ZOOM_NOMINI 0x8 371#define VID_DOUBLE_LINEBUFFER_FOR_WIDE_SRC 0x10 372#endif /* _TRIDENT_H_ */ 373 374