mga.h revision a31a186a
1/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h,v 1.87tsi Exp $ */ 2/* 3 * MGA Millennium (MGA2064W) functions 4 * 5 * Copyright 1996 The XFree86 Project, Inc. 6 * 7 * Authors 8 * Dirk Hohndel 9 * hohndel@XFree86.Org 10 * David Dawes 11 * dawes@XFree86.Org 12 */ 13 14#ifndef MGA_H 15#define MGA_H 16 17#ifdef XSERVER_LIBPCIACCESS 18#include <pciaccess.h> 19#endif 20#include <string.h> 21#include <stdio.h> 22 23#include "compiler.h" 24#include "xaa.h" 25#include "exa.h" 26#include "xf86Cursor.h" 27#include "vgaHW.h" 28#include "colormapst.h" 29#include "xf86DDC.h" 30#include "xf86xv.h" 31 32#ifdef XF86DRI 33#include "xf86drm.h" 34 35#define _XF86DRI_SERVER_ 36#include "mga_dripriv.h" 37#include "dri.h" 38#include "GL/glxint.h" 39 40#include "dri.h" 41 42#include "GL/glxint.h" 43#include "mga_dri.h" 44#endif 45 46#ifdef USEMGAHAL 47#include "client.h" 48#endif 49 50typedef enum { 51 OPTION_SW_CURSOR, 52 OPTION_HW_CURSOR, 53 OPTION_PCI_RETRY, 54 OPTION_SYNC_ON_GREEN, 55 OPTION_NOACCEL, 56 OPTION_SHOWCACHE, 57 OPTION_OVERLAY, 58 OPTION_MGA_SDRAM, 59 OPTION_SHADOW_FB, 60 OPTION_FBDEV, 61 OPTION_COLOR_KEY, 62 OPTION_SET_MCLK, 63 OPTION_OVERCLOCK_MEM, 64 OPTION_VIDEO_KEY, 65 OPTION_ROTATE, 66 OPTION_TEXTURED_VIDEO, 67 OPTION_CRTC2HALF, 68 OPTION_CRTC2RAM, 69 OPTION_INT10, 70 OPTION_AGP_MODE, 71 OPTION_AGP_SIZE, 72 OPTION_DIGITAL1, 73 OPTION_DIGITAL2, 74 OPTION_TV, 75 OPTION_TVSTANDARD, 76 OPTION_CABLETYPE, 77 OPTION_USEIRQZERO, 78 OPTION_NOHAL, 79 OPTION_SWAPPED_HEAD, 80 OPTION_DRI, 81 OPTION_MERGEDFB, 82 OPTION_HSYNC2, 83 OPTION_VREFRESH2, 84 OPTION_MONITOR2POS, 85 OPTION_METAMODES, 86 OPTION_OLDDMA, 87 OPTION_PCIDMA, 88 OPTION_ACCELMETHOD, 89 OPTION_KVM 90} MGAOpts; 91 92 93#if !defined(EXTRADEBUG) 94#define INREG8(addr) MMIO_IN8(pMga->IOBase, addr) 95#define INREG16(addr) MMIO_IN16(pMga->IOBase, addr) 96#define INREG(addr) MMIO_IN32(pMga->IOBase, addr) 97#define OUTREG8(addr, val) MMIO_OUT8(pMga->IOBase, addr, val) 98#define OUTREG16(addr, val) MMIO_OUT16(pMga->IOBase, addr, val) 99#define OUTREG(addr, val) MMIO_OUT32(pMga->IOBase, addr, val) 100#else /* !EXTRADEBUG */ 101CARD8 MGAdbg_inreg8(ScrnInfoPtr, int, int, char*); 102CARD16 MGAdbg_inreg16(ScrnInfoPtr, int, int, char*); 103CARD32 MGAdbg_inreg32(ScrnInfoPtr, int, int, char*); 104void MGAdbg_outreg8(ScrnInfoPtr, int, int, char*); 105void MGAdbg_outreg16(ScrnInfoPtr, int,int, char*); 106void MGAdbg_outreg32(ScrnInfoPtr, int,int, char*); 107#ifndef __GNUC__ 108# define MGA_STRINGIZE(x) #x 109# define MGA_STRINGIFY(x) MGA_STRINGIZE(x) 110# define __FUNCTION__ MGA_STRINGIFY(__FILE__) ", line " MGA_STRINGIFY(__LINE__) 111#endif 112#define INREG8(addr) MGAdbg_inreg8(pScrn, addr, 1, __FUNCTION__) 113#define INREG16(addr) MGAdbg_inreg16(pScrn, addr, 1, __FUNCTION__) 114#define INREG(addr) MGAdbg_inreg32(pScrn, addr, 1, __FUNCTION__) 115#define OUTREG8(addr,val) MGAdbg_outreg8(pScrn, addr, val, __FUNCTION__) 116#define OUTREG16(addr,val) MGAdbg_outreg16(pScrn, addr, val, __FUNCTION__) 117#define OUTREG(addr,val) MGAdbg_outreg32(pScrn, addr, val, __FUNCTION__) 118#endif /* EXTRADEBUG */ 119 120#ifndef PCI_CHIP_MGAG200_SE_A_PCI 121#define PCI_CHIP_MGAG200_SE_A_PCI 0x0522 122#endif 123 124#ifndef PCI_CHIP_MGAG200_SE_B_PCI 125#define PCI_CHIP_MGAG200_SE_B_PCI 0x0524 126#endif 127 128#ifndef PCI_CHIP_MGAG200_WINBOND_PCI 129#define PCI_CHIP_MGAG200_WINBOND_PCI 0x0532 130#endif 131 132#ifndef PCI_CHIP_MGAG200_EV_PCI 133#define PCI_CHIP_MGAG200_EV_PCI 0x0530 134#endif 135 136#ifndef PCI_CHIP_MGAG200_EH_PCI 137#define PCI_CHIP_MGAG200_EH_PCI 0x0533 138#endif 139 140/* 141 * Read/write to the DAC via MMIO 142 */ 143 144/* 145 * These were functions. Use macros instead to avoid the need to 146 * pass pMga to them. 147 */ 148 149#define inMGAdreg(reg) INREG8(RAMDAC_OFFSET + (reg)) 150 151#define outMGAdreg(reg, val) OUTREG8(RAMDAC_OFFSET + (reg), val) 152 153#define inMGAdac(reg) \ 154 (outMGAdreg(MGA1064_INDEX, reg), inMGAdreg(MGA1064_DATA)) 155 156#define outMGAdac(reg, val) \ 157 (outMGAdreg(MGA1064_INDEX, reg), outMGAdreg(MGA1064_DATA, val)) 158 159#define outMGAdacmsk(reg, mask, val) \ 160 do { /* note: mask and reg may get evaluated twice */ \ 161 unsigned char tmp = (mask) ? (inMGAdac(reg) & (mask)) : 0; \ 162 outMGAdreg(MGA1064_INDEX, reg); \ 163 outMGAdreg(MGA1064_DATA, tmp | (val)); \ 164 } while (0) 165 166#define MGAWAITVSYNC() \ 167 do { \ 168 unsigned int count = 0; \ 169 unsigned int status = 0; \ 170 do { \ 171 status = INREG( MGAREG_Status ); \ 172 count++; \ 173 } while( ( status & 0x08 ) && (count < 250000) );\ 174 count = 0; \ 175 status = 0; \ 176 do { \ 177 status = INREG( MGAREG_Status ); \ 178 count++; \ 179 } while( !( status & 0x08 ) && (count < 250000) );\ 180 } while (0) 181 182#define MGAWAITBUSY() \ 183 do { \ 184 unsigned int count = 0; \ 185 unsigned int status = 0; \ 186 do { \ 187 status = INREG8( MGAREG_Status + 2 ); \ 188 count++; \ 189 } while( ( status & 0x01 ) && (count < 500000) ); \ 190 } while (0) 191 192#define PORT_OFFSET (0x1F00 - 0x300) 193 194#define MGA_VERSION 4000 195#define MGA_NAME "MGA" 196#define MGA_C_NAME MGA 197#define MGA_MODULE_DATA mgaModuleData 198#define MGA_DRIVER_NAME "mga" 199 200typedef struct { 201 unsigned char ExtVga[6]; 202 unsigned char DacClk[6]; 203 unsigned char * DacRegs; 204 unsigned long crtc2[0x58]; 205 unsigned char dac2[0x21]; 206 CARD32 Option; 207 CARD32 Option2; 208 CARD32 Option3; 209 long Clock; 210 Bool PIXPLLCSaved; 211 unsigned char PllM; 212 unsigned char PllN; 213 unsigned char PllP; 214} MGARegRec, *MGARegPtr; 215 216/* For programming the second CRTC */ 217typedef struct { 218 CARD32 ulDispWidth; /* Display Width in pixels*/ 219 CARD32 ulDispHeight; /* Display Height in pixels*/ 220 CARD32 ulBpp; /* Bits Per Pixels / input format*/ 221 CARD32 ulPixClock; /* Pixel Clock in kHz*/ 222 CARD32 ulHFPorch; /* Horizontal front porch in pixels*/ 223 CARD32 ulHSync; /* Horizontal Sync in pixels*/ 224 CARD32 ulHBPorch; /* Horizontal back porch in pixels*/ 225 CARD32 ulVFPorch; /* Vertical front porch in lines*/ 226 CARD32 ulVSync; /* Vertical Sync in lines*/ 227 CARD32 ulVBPorch; /* Vertical back Porch in lines*/ 228 CARD32 ulFBPitch; /* Pitch*/ 229 CARD32 flSignalMode; /* Signal Mode*/ 230} xMODEINFO; 231 232 233typedef struct { 234 int brightness; 235 int contrast; 236 Bool doubleBuffer; 237 unsigned char currentBuffer; 238 RegionRec clip; 239 CARD32 colorKey; 240 CARD32 videoStatus; 241 Time offTime; 242 Time freeTime; 243 int lastPort; 244 245#ifdef USE_EXA 246 int size; 247 ExaOffscreenArea *off_screen; 248#endif 249 250 void *video_memory; 251 int video_offset; 252} MGAPortPrivRec, *MGAPortPrivPtr; 253 254typedef struct { 255 Bool isHwCursor; 256 int CursorMaxWidth; 257 int CursorMaxHeight; 258 int CursorFlags; 259 int CursorOffscreenMemSize; 260 Bool (*UseHWCursor)(ScreenPtr, CursorPtr); 261 void (*LoadCursorImage)(ScrnInfoPtr, unsigned char*); 262 void (*ShowCursor)(ScrnInfoPtr); 263 void (*HideCursor)(ScrnInfoPtr); 264 void (*SetCursorPosition)(ScrnInfoPtr, int, int); 265 void (*SetCursorColors)(ScrnInfoPtr, int, int); 266 long maxPixelClock; 267 long MemoryClock; 268 MessageType ClockFrom; 269 MessageType MemClkFrom; 270 Bool SetMemClk; 271 void (*LoadPalette)(ScrnInfoPtr, int, int*, LOCO*, VisualPtr); 272 void (*RestorePalette)(ScrnInfoPtr, unsigned char *); 273 void (*PreInit)(ScrnInfoPtr); 274 void (*Save)(ScrnInfoPtr, vgaRegPtr, MGARegPtr, Bool); 275 void (*Restore)(ScrnInfoPtr, vgaRegPtr, MGARegPtr, Bool); 276 Bool (*ModeInit)(ScrnInfoPtr, DisplayModePtr); 277} MGARamdacRec, *MGARamdacPtr; 278 279 280typedef struct { 281 int bitsPerPixel; 282 int depth; 283 int displayWidth; 284 rgb weight; 285 DisplayModePtr mode; 286} MGAFBLayout; 287 288/* Card-specific driver information */ 289 290typedef struct { 291 Bool update; 292 unsigned char red; 293 unsigned char green; 294 unsigned char blue; 295} MGAPaletteInfo; 296 297#define MGAPTR(p) ((MGAPtr)((p)->driverPrivate)) 298 299/*avoids segfault by returning false if pMgaHwInfo not defined*/ 300#define ISDIGITAL1(p) (p->pMgaHwInfo && ((p->pMgaHwInfo->ulCapsFirstOutput) & MGAHWINFOCAPS_OUTPUT_DIGITAL)) 301#define ISDIGITAL2(p) (p->pMgaHwInfo && ((p->pMgaHwInfo->ulCapsSecondOutput) & MGAHWINFOCAPS_OUTPUT_DIGITAL)) 302#define ISTV1(p) (p->pMgaHwInfo && ((p->pMgaHwInfo->ulCapsFirstOutput) & MGAHWINFOCAPS_OUTPUT_TV)) 303#define ISTV2(p) (p->pMgaHwInfo && ((p->pMgaHwInfo->ulCapsSecondOutput) & MGAHWINFOCAPS_OUTPUT_TV)) 304 305#ifdef DISABLE_VGA_IO 306typedef struct mgaSave { 307#ifdef XSERVER_LIBPCIACCESS 308 struct pci_device * pvp; 309#else 310 pciVideoPtr pvp; 311#endif 312 Bool enable; 313} MgaSave, *MgaSavePtr; 314#endif 315 316 317typedef enum { 318 mgaLeftOf, 319 mgaRightOf, 320 mgaAbove, 321 mgaBelow, 322 mgaClone 323} MgaScrn2Rel; 324 325typedef struct { 326 int lastInstance; 327#ifdef USEMGAHAL 328 LPCLIENTDATA pClientStruct; 329 LPBOARDHANDLE pBoard; 330 LPMGAHWINFO pMgaHwInfo; 331#endif 332 int refCount; 333 CARD32 masterFbAddress; 334 long masterFbMapSize; 335 CARD32 slaveFbAddress; 336 long slaveFbMapSize; 337 int mastervideoRam; 338 int slavevideoRam; 339 Bool directRenderingEnabled; 340 ScrnInfoPtr pScrn_1; 341 ScrnInfoPtr pScrn_2; 342} MGAEntRec, *MGAEntPtr; 343 344/** 345 * Track the range of a voltage controlled osciliator (VCO). 346 */ 347struct mga_VCO { 348 /** 349 * Minimum selectable frequency for this VCO, measured in kHz. 350 */ 351 unsigned min_freq; 352 353 /** 354 * Maximum selectable frequency for this VCO, measured in kHz. 355 * 356 * If this value is zero, then the VCO is not available. 357 */ 358 unsigned max_freq; 359}; 360 361/** 362 * Host interface types that can be set by the card's BIOS. 363 */ 364typedef enum { 365 MGA_HOST_UNKNOWN0 = 0, /**< Meaning unknown. */ 366 MGA_HOST_UNKNOWN1 = 1, /**< Meaning unknown. */ 367 MGA_HOST_UNKNOWN2 = 2, /**< Meaning unknown. */ 368 MGA_HOST_HYBRID = 3, /**< AGP 4x for data xfers only. */ 369 370 /** 371 * PCI interface. Either native or via a universal PCI-to-PCI bridge 372 * chip. The PCI G450 and PCI G550 cards are examples. 373 */ 374 MGA_HOST_PCI = 4, 375 376 MGA_HOST_AGP_1x = 5, /**< AGP 1x capable. */ 377 MGA_HOST_AGP_2x = 6, /**< AGP 2x capable. */ 378 MGA_HOST_AGP_4x = 7 /**< AGP 4x capable. */ 379} mga_host_t; 380 381/** 382 * Card information derrived from BIOS PInS data. 383 */ 384struct mga_bios_values { 385 /** 386 * \name Voltage Controlled Oscilators 387 * \brief Track information about the various VCOs. 388 * 389 * MGA cards have between one and three VCOs that can be used to drive the 390 * various clocks. On older cards, only \c mga_bios_values::pixel VCO is 391 * available. On newer cards, such as the G450 and G550, all three are 392 * available. If \c mga_VCO::max_freq is zero, the VCO is not available. 393 */ 394 /*@{*/ 395 struct mga_VCO system; /**< System VCO. */ 396 struct mga_VCO pixel; /**< Pixel VCO. */ 397 struct mga_VCO video; /**< Video VCO. */ 398 /*@}*/ 399 400 /** 401 * Memory clock speed, measured in kHz. 402 */ 403 unsigned mem_clock; 404 405 /** 406 * PLL reference frequency value. On older cards this is ~14MHz, and on 407 * newer cards it is ~27MHz. 408 */ 409 unsigned pll_ref_freq; 410 411 /** 412 * Some older MGA cards have a "fast bitblt" mode. This is determined 413 * by a capability bit stored in the PInS data. 414 */ 415 Bool fast_bitblt; 416 417 /** 418 * Type of physical interface used for the card. 419 */ 420 mga_host_t host_interface; 421}; 422 423 424/** 425 * Attributes that of an MGA device that can be derrived purely from its 426 * PCI ID. 427 */ 428struct mga_device_attributes { 429 unsigned has_sdram:1; 430 unsigned probe_for_sdram:1; 431 unsigned dual_head_possible:1; 432 unsigned fb_4mb_quirk:1; 433 unsigned hwcursor_1064:1; 434 435 unsigned dri_capable:1; 436 unsigned dri_chipset:3; 437 438 unsigned HAL_chipset:1; 439 440 enum { 441 old_BARs = 0, 442 probe_BARs, 443 new_BARs 444 } BARs:2; 445 446 uint32_t accel_flags; 447 448 /** Default BIOS values. */ 449 struct mga_bios_values default_bios_values; 450 451 /** Default memory probe offset / size values. */ 452 unsigned probe_size; 453 unsigned probe_offset; 454}; 455 456typedef struct { 457#ifdef USEMGAHAL 458 LPCLIENTDATA pClientStruct; 459 LPBOARDHANDLE pBoard; 460 LPMGAMODEINFO pMgaModeInfo; 461 LPMGAHWINFO pMgaHwInfo; 462#endif 463 EntityInfoPtr pEnt; 464 struct mga_bios_values bios; 465 CARD8 BiosOutputMode; 466#ifdef XSERVER_LIBPCIACCESS 467 struct pci_device * PciInfo; 468#else 469 pciVideoPtr PciInfo; 470 PCITAG PciTag; 471 xf86AccessRec Access; 472#endif 473 const struct mga_device_attributes * chip_attribs; 474 int Chipset; 475 int ChipRev; 476 477 int is_Gx50:1; 478 int is_G200SE:1; 479 int is_G200WB:1; 480 int is_G200EV:1; 481 int is_G200EH:1; 482 483 int KVM; 484 485 CARD32 reg_1e24; /* model revision on g200se */ 486 487 Bool Primary; 488 Bool Interleave; 489 int HwBpp; 490 int Roundings[4]; 491 int BppShifts[4]; 492 Bool HasFBitBlt; 493 Bool OverclockMem; 494 int YDstOrg; 495 int DstOrg; 496 int SrcOrg; 497 498 /** 499 * Which BAR corresponds to the framebuffer on this chip? 500 */ 501 unsigned framebuffer_bar; 502 503 /** 504 * Which BAR corresponds to IO space on this chip? 505 */ 506 unsigned io_bar; 507 508 /** 509 * Which BAR corresponds to ILOAD space on this chip? If the value is 510 * -1, then this chip does not have an ILOAD region. 511 */ 512 int iload_bar; 513 514#ifndef XSERVER_LIBPCIACCESS 515 unsigned long IOAddress; 516 unsigned long ILOADAddress; 517 unsigned long BiosAddress; 518 MessageType BiosFrom; 519#endif 520 unsigned long FbAddress; 521 unsigned char * IOBase; 522 unsigned char * FbBase; 523 unsigned char * ILOADBase; 524 unsigned char * FbStart; 525 long FbMapSize; 526 long FbUsableSize; 527 long FbCursorOffset; 528 MGARamdacRec Dac; 529 Bool HasSDRAM; 530 Bool NoAccel; 531 Bool Exa; 532 ExaDriverPtr ExaDriver; 533 Bool SyncOnGreen; 534 Bool HWCursor; 535 Bool UsePCIRetry; 536 Bool ShowCache; 537 Bool ShadowFB; 538 unsigned char * ShadowPtr; 539 int ShadowPitch; 540 int MemClk; 541 int MinClock; 542 int MaxClock; 543 MGARegRec SavedReg; 544 MGARegRec ModeReg; 545 int MaxFastBlitY; 546 CARD32 BltScanDirection; 547 CARD32 FilledRectCMD; 548 CARD32 SolidLineCMD; 549 CARD32 PatternRectCMD; 550 CARD32 DashCMD; 551 CARD32 NiceDashCMD; 552 CARD32 AccelFlags; 553 CARD32 PlaneMask; 554 CARD32 FgColor; 555 CARD32 BgColor; 556 CARD32 MAccess; 557 int FifoSize; 558 int StyleLen; 559 XAAInfoRecPtr AccelInfoRec; 560 xf86CursorInfoPtr CursorInfoRec; 561 DGAModePtr DGAModes; 562 int numDGAModes; 563 Bool DGAactive; 564 int DGAViewportStatus; 565 CARD32 *Atype; 566 CARD32 *AtypeNoBLK; 567 void (*PreInit)(ScrnInfoPtr pScrn); 568 void (*Save)(ScrnInfoPtr, vgaRegPtr, MGARegPtr, Bool); 569 void (*Restore)(ScrnInfoPtr, vgaRegPtr, MGARegPtr, Bool); 570 Bool (*ModeInit)(ScrnInfoPtr, DisplayModePtr); 571 void (*PointerMoved)(int index, int x, int y); 572 CloseScreenProcPtr CloseScreen; 573 ScreenBlockHandlerProcPtr BlockHandler; 574 unsigned int (*ddc1Read)(ScrnInfoPtr); 575 void (*DDC1SetSpeed)(ScrnInfoPtr, xf86ddcSpeed); 576 Bool (*i2cInit)(ScrnInfoPtr); 577 I2CBusPtr DDC_Bus1; 578 I2CBusPtr DDC_Bus2; 579 I2CBusPtr Maven_Bus; 580 I2CDevPtr Maven; 581 char Maven_Version; 582 Bool UseMaven; 583 Bool UseMavenPM; 584 Bool FBDev; 585 int colorKey; 586 int videoKey; 587 int fifoCount; 588 int Rotate; 589 MGAFBLayout CurrentLayout; 590 Bool DrawTransparent; 591 int MaxBlitDWORDS; 592 Bool TexturedVideo; 593 MGAPortPrivPtr portPrivate; 594 unsigned char *ScratchBuffer; 595 unsigned char *ColorExpandBase; 596 int expandRows; 597 int expandDWORDs; 598 int expandRemaining; 599 int expandHeight; 600 int expandY; 601#ifdef XF86DRI 602 Bool directRenderingEnabled; 603 DRIInfoPtr pDRIInfo; 604 int drmFD; 605 int numVisualConfigs; 606 __GLXvisualConfig* pVisualConfigs; 607 MGAConfigPrivPtr pVisualConfigsPriv; 608 MGADRIServerPrivatePtr DRIServerInfo; 609 610 MGARegRec DRContextRegs; 611 612 Bool haveQuiescense; 613 void (*GetQuiescence)(ScrnInfoPtr pScrn); 614 615 int agpMode; 616 int agpSize; 617 618 int irq; 619 CARD32 reg_ien; 620 621 Bool useOldDmaInit; 622 Bool forcePciDma; 623#endif 624 XF86VideoAdaptorPtr adaptor; 625 Bool DualHeadEnabled; 626 Bool Crtc2IsTV; 627 Bool SecondCrtc; 628 Bool SecondOutput; 629 630 GDevPtr device; 631 /* The hardware's real SrcOrg */ 632 int realSrcOrg; 633 MGAEntPtr entityPrivate; 634 void (*SetupForSolidFill)(ScrnInfoPtr pScrn, int color, 635 int rop, unsigned int planemask); 636 void (*SubsequentSolidFillRect)(ScrnInfoPtr pScrn, 637 int x, int y, int w, int h); 638 void (*RestoreAccelState)(ScrnInfoPtr pScrn); 639 int allowedWidth; 640 void (*VideoTimerCallback)(ScrnInfoPtr, Time); 641 void (*PaletteLoadCallback)(ScrnInfoPtr); 642 void (*RenderCallback)(ScrnInfoPtr); 643 Time RenderTime; 644 MGAPaletteInfo palinfo[256]; /* G400 hardware bug workaround */ 645 FBLinearPtr LinearScratch; 646 Bool softbooted; 647#ifdef USEMGAHAL 648 Bool HALLoaded; 649#endif 650 OptionInfoPtr Options; 651 652 /* Exa */ 653 PicturePtr currentSrcPicture; 654 PicturePtr currentMaskPicture; 655 PixmapPtr currentSrc; 656 PixmapPtr currentMask; 657 int src_w2; 658 int src_h2; 659 int mask_w2; 660 int mask_h2; 661 CARD32 src_pitch; /* FIXME kill me */ 662 663/* Merged Framebuffer data */ 664 Bool MergedFB; 665 666 /* Real values specific to monitor1, since the original ones are replaced */ 667 DisplayModePtr M1modes; /* list of actual modes */ 668 DisplayModePtr M1currentMode; /* current mode */ 669 int M1frameX0; /* viewport position */ 670 int M1frameY0; 671 int M1frameX1; 672 int M1frameY1; 673 674 ScrnInfoPtr pScrn2; /*pointer to second CRTC screeninforec, 675 if in merged mode */ 676/* End of Merged Framebuffer Data */ 677 int HALGranularityOffX, HALGranularityOffY; 678} MGARec, *MGAPtr; 679 680extern CARD32 MGAAtype[16]; 681extern CARD32 MGAAtypeNoBLK[16]; 682 683#define USE_RECTS_FOR_LINES 0x00000001 684#define FASTBLT_BUG 0x00000002 685#define CLIPPER_ON 0x00000004 686#define BLK_OPAQUE_EXPANSION 0x00000008 687#define TRANSC_SOLID_FILL 0x00000010 688#define NICE_DASH_PATTERN 0x00000020 689#define TWO_PASS_COLOR_EXPAND 0x00000040 690#define MGA_NO_PLANEMASK 0x00000080 691#define USE_LINEAR_EXPANSION 0x00000100 692#define LARGE_ADDRESSES 0x00000200 693 694#define MGAIOMAPSIZE 0x00004000 695#define MGAILOADMAPSIZE 0x00400000 696 697#define TRANSPARENCY_KEY 255 698#define KEY_COLOR 0 699 700 701/* Prototypes */ 702 703void MGAAdjustFrame(int scrnIndex, int x, int y, int flags); 704Bool MGASwitchMode(int scrnIndex, DisplayModePtr mode, int flags); 705void MGAFillModeInfoStruct(ScrnInfoPtr pScrn, DisplayModePtr mode); 706Bool MGAGetRec(ScrnInfoPtr pScrn); 707void MGAProbeDDC(ScrnInfoPtr pScrn, int index); 708void MGASoftReset(ScrnInfoPtr pScrn); 709void MGAFreeRec(ScrnInfoPtr pScrn); 710Bool mga_read_and_process_bios(ScrnInfoPtr pScrn); 711void MGADisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, 712 int flags); 713void MGAAdjustFrameCrtc2(int scrnIndex, int x, int y, int flags); 714void MGADisplayPowerManagementSetCrtc2(ScrnInfoPtr pScrn, 715 int PowerManagementMode, 716 int flags); 717void MGAAdjustGranularity(ScrnInfoPtr pScrn, int* x, int* y); 718 719 720void MGA2064SetupFuncs(ScrnInfoPtr pScrn); 721void MGAGSetupFuncs(ScrnInfoPtr pScrn); 722 723/* #ifdef USE_XAA */ 724void MGAStormSync(ScrnInfoPtr pScrn); 725void MGAStormEngineInit(ScrnInfoPtr pScrn); 726Bool MGAStormAccelInit(ScreenPtr pScreen); 727Bool mgaAccelInit(ScreenPtr pScreen); 728/* #endif */ 729 730#ifdef USE_EXA 731Bool mgaExaInit(ScreenPtr pScreen); 732#endif 733 734Bool MGAHWCursorInit(ScreenPtr pScreen); 735 736 737void MGAPolyArcThinSolid(DrawablePtr, GCPtr, int, xArc*); 738 739Bool MGADGAInit(ScreenPtr pScreen); 740 741void MGARefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 742void MGARefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 743void MGARefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 744void MGARefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 745void MGARefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox); 746 747void mgaDoSetupForScreenToScreenCopy( ScrnInfoPtr pScrn, int xdir, 748 int ydir, int rop, unsigned int planemask, int trans, unsigned int bpp ); 749 750void mgaDoSetupForSolidFill( ScrnInfoPtr pScrn, int color, int rop, 751 unsigned int planemask, unsigned int bpp ); 752 753void MGAPointerMoved(int index, int x, int y); 754 755void MGAInitVideo(ScreenPtr pScreen); 756void MGAResetVideo(ScrnInfoPtr pScrn); 757 758#ifdef XF86DRI 759 760#define MGA_FRONT 0x1 761#define MGA_BACK 0x2 762#define MGA_DEPTH 0x4 763 764Bool MGADRIScreenInit( ScreenPtr pScreen ); 765void MGADRICloseScreen( ScreenPtr pScreen ); 766Bool MGADRIFinishScreenInit( ScreenPtr pScreen ); 767 768Bool MGALockUpdate( ScrnInfoPtr pScrn, drmLockFlags flags ); 769 770void MGAGetQuiescence( ScrnInfoPtr pScrn ); 771void MGAGetQuiescenceShared( ScrnInfoPtr pScrn ); 772 773void MGASelectBuffer(ScrnInfoPtr pScrn, int which); 774Bool MgaCleanupDma(ScrnInfoPtr pScrn); 775Bool MgaInitDma(ScrnInfoPtr pScrn, int prim_size); 776 777#define MGA_AGP_1X_MODE 0x01 778#define MGA_AGP_2X_MODE 0x02 779#define MGA_AGP_4X_MODE 0x04 780#define MGA_AGP_MODE_MASK 0x07 781 782#endif 783 784Bool MGAMavenRead(ScrnInfoPtr pScrn, I2CByte reg, I2CByte *val); 785 786void MGACRTC2Set(ScrnInfoPtr pScrn, xMODEINFO *pModeInfo); 787void MGAEnableSecondOutPut(ScrnInfoPtr pScrn, xMODEINFO *pModeInfo); 788void MGACRTC2SetPitch(ScrnInfoPtr pSrcn, xMODEINFO *pModeInfo); 789void MGACRTC2SetDisplayStart(ScrnInfoPtr pScrn, xMODEINFO *pModeInfo, CARD32 base, CARD32 ulX, CARD32 ulY); 790 791void MGACRTC2Get(ScrnInfoPtr pScrn, xMODEINFO *pModeInfo); 792void MGACRTC2GetPitch(ScrnInfoPtr pSrcn, xMODEINFO *pModeInfo); 793void MGACRTC2GetDisplayStart(ScrnInfoPtr pScrn, xMODEINFO *pModeInfo, CARD32 base, CARD32 ulX, CARD32 ulY); 794 795double MGAG450SetPLLFreq(ScrnInfoPtr pScrn, long f_out); 796#ifdef DEBUG 797void MGAG450PrintPLL(ScrnInfoPtr pScrn); 798#endif 799long MGAG450SavePLLFreq(ScrnInfoPtr pScrn); 800void MGAprintDac(ScrnInfoPtr pScrn); 801void MGAG200SESaveFonts(ScrnInfoPtr, vgaRegPtr); 802void MGAG200SERestoreFonts(ScrnInfoPtr, vgaRegPtr); 803void MGAG200SESaveMode(ScrnInfoPtr, vgaRegPtr); 804void MGAG200SERestoreMode(ScrnInfoPtr, vgaRegPtr); 805void MGAG200SEHWProtect(ScrnInfoPtr, Bool); 806 807#ifdef USEMGAHAL 808/************ ESC Call Definition ***************/ 809typedef struct { 810 char *function; 811 void (*funcptr)(ScrnInfoPtr pScrn, unsigned long *param, char *out, DisplayModePtr pMode); 812} MGAEscFuncRec, *MGAEscFuncPtr; 813 814typedef struct { 815 char function[32]; 816 unsigned long parameters[32]; 817} EscCmdStruct; 818 819extern LPMGAMODEINFO pMgaModeInfo[2]; 820extern MGAMODEINFO TmpMgaModeInfo[2]; 821 822extern void MGAExecuteEscCmd(ScrnInfoPtr pScrn, char *cmdline , char *sResult, DisplayModePtr pMode); 823void MGAFillDisplayModeStruct(DisplayModePtr pMode, LPMGAMODEINFO pModeInfo); 824/************************************************/ 825#endif 826 827static __inline__ void 828MGA_MARK_SYNC(MGAPtr pMga, ScrnInfoPtr pScrn) 829{ 830#ifdef USE_EXA 831 if (pMga->Exa) 832 exaMarkSync(pScrn->pScreen); 833#endif 834#ifdef USE_XAA 835 if (!pMga->Exa) 836 SET_SYNC_FLAG(pMga->AccelInfoRec); 837#endif 838} 839 840static __inline__ void 841MGA_SYNC(MGAPtr pMga, ScrnInfoPtr pScrn) 842{ 843#ifdef USE_EXA 844 if (pMga->Exa) 845 exaWaitSync(pScrn->pScreen); 846#endif 847#ifdef USE_XAA 848 if (!pMga->Exa && pMga->AccelInfoRec && pMga->AccelInfoRec->NeedToSync) 849 pMga->AccelInfoRec->Sync(pScrn); 850#endif 851} 852 853#endif 854