trident.h revision 14330f12
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/* Banked framebuffer only supported on ISA */ 50#ifdef HAVE_ISA 51#define LINEAR() (pTrident->Linear) 52#else 53#define LINEAR() (1) 54#endif 55 56#define PCI_CHIP_2200 0x2200 57 58typedef struct { 59 unsigned char tridentRegs3x4[0x100]; 60 unsigned char tridentRegs3CE[0x100]; 61 unsigned char tridentRegs3C4[0x100]; 62 unsigned char tridentRegsDAC[0x01]; 63 unsigned char tridentRegsClock[0x05]; 64 unsigned char DacRegs[0x300]; 65} TRIDENTRegRec, *TRIDENTRegPtr; 66 67#define VGA_REGNUM_ABOUT_TV 19 68#define TRIDENTPTR(p) ((TRIDENTPtr)((p)->driverPrivate)) 69 70typedef struct { 71 ScrnInfoPtr pScrn; 72 pciVideoPtr PciInfo; 73 uint32_t PciTag; 74 EntityInfoPtr pEnt; 75 ExaDriverPtr EXADriverPtr; 76 int useEXA; 77 int Chipset; 78 int DACtype; 79 int RamDac; 80 int ChipRev; 81 int HwBpp; 82 int BppShift; 83 CARD32 IOAddress; 84 unsigned long FbAddress; 85 unsigned char * IOBase; 86 unsigned char * FbBase; 87 long FbMapSize; 88 unsigned long PIOBase; 89 Bool NoAccel; 90 Bool HWCursor; 91 Bool UsePCIRetry; 92 Bool UsePCIBurst; 93 Bool NewClockCode; 94 Bool Clipping; 95 Bool DstEnable; 96 Bool ROP; 97 Bool HasSGRAM; 98 Bool MUX; 99 Bool IsCyber; 100 Bool CyberShadow; 101 Bool CyberStretch; 102 Bool NoMMIO; 103 Bool MMIOonly; 104 Bool ShadowFB; 105 Bool Linear; 106 DGAModePtr DGAModes; 107 int numDGAModes; 108 Bool DGAactive; 109 int DGAViewportStatus; 110 unsigned char * ShadowPtr; 111 int ShadowPitch; 112 RefreshAreaFuncPtr RefreshArea; 113 void (*PointerMoved)(int index, int x, int y); 114 int Rotate; 115 float frequency; 116 unsigned char REGPCIReg; 117 unsigned char REGNewMode1; 118 CARD8 SaveClock1; 119 CARD8 SaveClock2; 120 CARD8 SaveClock3; 121 int MinClock; 122 int MaxClock; 123 int MUXThreshold; 124 int currentClock; 125 int MCLK; 126 int dwords; 127 int h; 128 int x; 129 int w; 130 int y; 131 int lcdMode; 132 Bool lcdActive; 133 Bool doInit; 134#ifdef READOUT 135 Bool DontSetClock; 136#endif 137 TRIDENTRegRec SavedReg; 138 TRIDENTRegRec ModeReg; 139 I2CBusPtr DDC; 140 CARD16 EngineOperation; 141 CARD32 PatternLocation; 142 CARD32 BltScanDirection; 143 CARD32 DrawFlag; 144 CARD16 LinePattern; 145 RamDacRecPtr RamDacRec; 146 int CursorOffset; 147 xf86CursorInfoPtr CursorInfoRec; 148 xf86Int10InfoPtr Int10; 149 vbeInfoPtr pVbe; 150#ifdef VBE_INFO 151 vbeModeInfoPtr vbeModes; 152#endif 153 XAAInfoRecPtr AccelInfoRec; 154 CloseScreenProcPtr CloseScreen; 155 ScreenBlockHandlerProcPtr BlockHandler; 156 int panelWidth; 157 int panelHeight; 158 unsigned int (*ddc1Read)(ScrnInfoPtr); 159 CARD8* XAAScanlineColorExpandBuffers[2]; 160 CARD8* XAAImageScanlineBuffer[1]; 161 void (*InitializeAccelerator)(ScrnInfoPtr); 162 void (*VideoTimerCallback)(ScrnInfoPtr, Time); 163 XF86VideoAdaptorPtr adaptor; 164 int videoKey; 165 int hsync; 166 int hsync_rskew; 167 int vsync; 168 int vsync_bskew; 169 CARD32 videoFlags; 170 int keyOffset; 171 int OverrideHsync; 172 int OverrideVsync; 173 int OverrideBskew; 174 int OverrideRskew; 175 OptionInfoPtr Options; 176 Bool shadowNew; 177 int displaySize; 178 int dspOverride; 179 Bool GammaBrightnessOn; 180 int brightness; 181 double gamma; 182 int FPDelay; /* just for debugging - will go away */ 183 int TVChipset; /* 0: None 1: VT1621 2: CH7005C*/ 184 int TVSignalMode; /* 0: NTSC 1: PAL */ 185 Bool TVRegSet; /* 0: User not customer TV Reg, 1: User customer TV Reg */ 186 unsigned char TVRegUserSet[2][128]; /*[0][128] for Reg Index, [1][128] for Reg Value */ 187 unsigned char DefaultTVDependVGASetting[VGA_REGNUM_ABOUT_TV+0x62]; /* VGA_REGNUM_ABOUT_TV: VGA Reg, 0x62: TV Reg */ 188} TRIDENTRec, *TRIDENTPtr; 189 190typedef struct { 191 CARD8 mode; 192 int display_x; 193 int display_y; 194 int clock; 195 int shadow_0; 196 int shadow_3; 197 int shadow_4; 198 int shadow_5; 199 int shadow_6; 200 int shadow_7; 201 int shadow_10; 202 int shadow_11; 203 int shadow_16; 204 int shadow_HiOrd; 205} tridentLCD; 206 207#define LCD_ACTIVE 0x01 208#define CRT_ACTIVE 0x02 209 210extern tridentLCD LCD[]; 211 212typedef struct { 213 int x_res; 214 int y_res; 215 int mode; 216} biosMode; 217 218typedef struct { 219 int x_res; 220 int y_res; 221 CARD8 GR5a; 222 CARD8 GR5c; 223} newModes; 224 225/* Prototypes */ 226 227Bool TRIDENTClockSelect(ScrnInfoPtr pScrn, int no); 228Bool TRIDENTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); 229void TRIDENTAdjustFrame(int scrnIndex, int x, int y, int flags); 230Bool TRIDENTDGAInit(ScreenPtr pScreen); 231Bool TRIDENTI2CInit(ScreenPtr pScreen); 232void TRIDENTInitVideo(ScreenPtr pScreen); 233void TRIDENTResetVideo(ScrnInfoPtr pScrn); 234unsigned int Tridentddc1Read(ScrnInfoPtr pScrn); 235void TVGARestore(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg); 236void TVGASave(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg); 237Bool TVGAInit(ScrnInfoPtr pScrn, DisplayModePtr mode); 238void TridentRestore(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg); 239void TridentSave(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg); 240Bool TridentInit(ScrnInfoPtr pScrn, DisplayModePtr mode); 241Bool TridentAccelInit(ScreenPtr pScreen); 242Bool XPAccelInit(ScreenPtr pScreen); 243Bool XP4XaaInit(ScreenPtr pScreen); 244Bool XP4ExaInit(ScreenPtr pScreen); 245Bool ImageAccelInit(ScreenPtr pScreen); 246Bool BladeXaaInit(ScreenPtr pScreen); 247Bool BladeExaInit(ScreenPtr pScreen); 248Bool TridentHWCursorInit(ScreenPtr pScreen); 249int TridentFindMode(int xres, int yres, int depth); 250void TGUISetClock(ScrnInfoPtr pScrn, int clock, unsigned char *a, unsigned char *b); 251void TGUISetMCLK(ScrnInfoPtr pScrn, int clock, unsigned char *a, unsigned char *b); 252void tridentSetModeBIOS(ScrnInfoPtr pScrn, DisplayModePtr mode); 253void TridentOutIndReg(ScrnInfoPtr pScrn, 254 CARD32 reg, unsigned char mask, unsigned char data); 255unsigned char TridentInIndReg(ScrnInfoPtr pScrn, CARD32 reg); 256void TridentLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, LOCO *colors, VisualPtr pVisual); 257void TridentSetOverscan(ScrnInfoPtr pScrn, int overscan); 258int TGUISetRead(ScreenPtr pScreen, int bank); 259int TGUISetWrite(ScreenPtr pScreen, int bank); 260int TGUISetReadWrite(ScreenPtr pScreen, int bank); 261int TVGA8900SetRead(ScreenPtr pScreen, int bank); 262int TVGA8900SetWrite(ScreenPtr pScreen, int bank); 263int TVGA8900SetReadWrite(ScreenPtr pScreen, int bank); 264void TridentFindClock(ScrnInfoPtr pScrn, int clock); 265float CalculateMCLK(ScrnInfoPtr pScrn); 266void TRIDENTRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 267void TRIDENTShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf); 268void TRIDENTPointerMoved(int index, int x, int y); 269void TRIDENTRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 270void TRIDENTRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 271void TRIDENTRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 272void TRIDENTRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 273 274void VIA_TVInit(ScrnInfoPtr pScrn); 275void VIA_SaveTVDepentVGAReg(ScrnInfoPtr pScrn); 276void VIA_RestoreTVDependVGAReg(ScrnInfoPtr pScrn); 277void VIA_DumpReg(ScrnInfoPtr pScrn); 278 279/* 280 * Trident Chipset Definitions 281 */ 282 283/* Supported chipsets */ 284typedef enum { 285 TVGA8200LX, 286 TVGA8800BR, 287 TVGA8800CS, 288 TVGA8900B, 289 TVGA8900C, 290 TVGA8900CL, 291 TVGA8900D, 292 TVGA9000, 293 TVGA9000i, 294 TVGA9100B, 295 TVGA9200CXr, 296 TGUI9400CXi, 297 TGUI9420DGi, 298 TGUI9430DGi, 299 TGUI9440AGi, 300 CYBER9320, 301 TGUI9660, 302 TGUI9680, 303 PROVIDIA9682, 304 CYBER9382, 305 CYBER9385, 306 PROVIDIA9685, 307 CYBER9388, 308 CYBER9397, 309 CYBER9397DVD, 310 CYBER9520, 311 CYBER9525DVD, 312 IMAGE975, 313 IMAGE985, 314 BLADE3D, 315 CYBERBLADEI7, 316 CYBERBLADEI7D, 317 CYBERBLADEI1, 318 CYBERBLADEI1D, 319 CYBERBLADEAI1, 320 CYBERBLADEAI1D, 321 CYBERBLADEE4, 322 BLADEXP, 323 CYBERBLADEXPAI1, 324 CYBERBLADEXP4, 325 XP5 326} TRIDENTType; 327 328#define UseMMIO (pTrident->NoMMIO == FALSE) 329 330#define IsPciCard (pTrident->pEnt->location.type == BUS_PCI) 331 332#ifdef HAVE_ISA 333# define IsPrimaryCard ((xf86IsPrimaryPci(pTrident->PciInfo)) || \ 334 (xf86IsPrimaryIsa())) 335#else 336# define IsPrimaryCard (xf86IsPrimaryPci(pTrident->PciInfo)) 337#endif 338 339#define HAS_DST_TRANS ((pTrident->Chipset == PROVIDIA9682) || \ 340 (pTrident->Chipset == PROVIDIA9685) || \ 341 (pTrident->Chipset == BLADEXP) || \ 342 (pTrident->Chipset == CYBERBLADEXPAI1)) 343 344#define Is3Dchip ((pTrident->Chipset == CYBER9397) || \ 345 (pTrident->Chipset == CYBER9397DVD) || \ 346 (pTrident->Chipset == CYBER9520) || \ 347 (pTrident->Chipset == CYBER9525DVD) || \ 348 (pTrident->Chipset == CYBERBLADEE4) || \ 349 (pTrident->Chipset == IMAGE975) || \ 350 (pTrident->Chipset == IMAGE985) || \ 351 (pTrident->Chipset == CYBERBLADEI7) || \ 352 (pTrident->Chipset == CYBERBLADEI7D) || \ 353 (pTrident->Chipset == CYBERBLADEI1) || \ 354 (pTrident->Chipset == CYBERBLADEI1D) || \ 355 (pTrident->Chipset == CYBERBLADEAI1) || \ 356 (pTrident->Chipset == CYBERBLADEAI1D) || \ 357 (pTrident->Chipset == BLADE3D) || \ 358 (pTrident->Chipset == CYBERBLADEXPAI1) || \ 359 (pTrident->Chipset == CYBERBLADEXP4) || \ 360 (pTrident->Chipset == XP5) || \ 361 (pTrident->Chipset == BLADEXP)) 362 363/* 364 * Trident DAC's 365 */ 366 367#define TKD8001 0 368#define TGUIDAC 1 369 370/* 371 * Video Flags 372 */ 373 374#define VID_ZOOM_INV 0x1 375#define VID_ZOOM_MINI 0x2 376#define VID_OFF_SHIFT_4 0x4 377#define VID_ZOOM_NOMINI 0x8 378#define VID_DOUBLE_LINEBUFFER_FOR_WIDE_SRC 0x10 379#endif /* _TRIDENT_H_ */ 380 381