1/* 2 * Main global data and definitions 3 * 4 * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1) Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2) Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3) The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESSED OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Thomas Winischhofer <thomas@winischhofer.net> 29 * others (old code base) 30 * 31 */ 32#ifndef _XGI_H_ 33#define _XGI_H_ 34 35/*************** 36#define DEBUG 37#define DEBUG1 38#define DEBUG2 39#define DEBUG3 40#define DEBUG4 41#define DEBUG5 42#define DEBUGI2C 43*****************/ 44 45#ifndef XGI_VIDEO_HW /* avoid compile error in xgi_videohw.c; weird! */ 46/* Jong 07/27/2009; use run-time debug instead except for HW acceleration routines */ 47extern Bool g_bRunTimeDebug; 48#define RUNTIMEDEBUG(p) if(g_bRunTimeDebug)p; 49 50/* Jong@08052009 */ 51#ifdef DEBUGI2C 52#define PDEBUGI2C(p) p 53#else 54#define PDEBUGI2C(p) 55#endif 56 57#ifdef DEBUG 58#define PDEBUG(p) RUNTIMEDEBUG(p) 59#else 60#define PDEBUG(p) 61#endif 62 63#ifdef DEBUG1 64#define PDEBUG1(p) RUNTIMEDEBUG(p) 65#else 66#define PDEBUG1(p) 67#endif 68 69#ifdef DEBUG2 70#define PDEBUG2(p) RUNTIMEDEBUG(p) 71#else 72#define PDEBUG2(p) 73#endif 74 75#ifdef DEBUG3 76#define PDEBUG3(p) RUNTIMEDEBUG(p) 77#else 78#define PDEBUG3(p) 79#endif 80 81#ifdef DEBUG4 82#define PDEBUG4(p) RUNTIMEDEBUG(p) 83#else 84#define PDEBUG4(p) 85#endif 86 87#ifdef DEBUG5 88#define PDEBUG5(p) RUNTIMEDEBUG(p) 89#else 90#define PDEBUG5(p) 91#endif 92 93#ifdef CDEBUG 94#define CPDEBUG(p) p 95#else 96#define CPDEBUG(p) 97#endif 98 99#ifdef CDEBUG1 100#define CPDEBUG1(p) p 101#else 102#define CPDEBUG1(p) 103#endif 104 105#ifdef CDEBUG2 106#define CPDEBUG2(p) p 107#else 108#define CPDEBUG2(p) 109#endif 110 111#ifdef CDEBUG3 112#define CPDEBUG3(p) p 113#else 114#define CPDEBUG3(p) 115#endif 116 117#ifdef CDEBUG4 118#define CPDEBUG4(p) p 119#else 120#define CPDEBUG4(p) 121#endif 122 123#ifdef CDEBUG5 124#define CPDEBUG5(p) p 125#else 126#define CPDEBUG5(p) 127#endif 128 129#ifdef ACCELDEBUG 130#define PACCELDEBUG(p) p 131#else 132#define PACCELDEBUG(p) 133#endif 134#endif 135 136/* Always unlock the registers (should be set!) */ 137#define UNLOCK_ALWAYS 138 139#undef XGI_CP 140 141#ifdef XSERVER_LIBPCIACCESS 142#include <pciaccess.h> 143#else 144#include "xf86Pci.h" 145#endif 146#include "xf86Cursor.h" 147#include "xf86xv.h" 148#include "compiler.h" 149 150#ifdef XORG_VERSION_CURRENT 151#include "xorgVersion.h" 152 153/* #if XORG_VERSION_CURRENT > XORG_VERSION_NUMERIC(7,0,0,0,0) */ 154#if ((XORG_VERSION_CURRENT > XORG_VERSION_NUMERIC(7,0,0,0,0)) || (XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(2,0,0,0,0)) ) 155#define XGIISXORGPOST70 156#endif 157 158#if (XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(6,9,0,0,0) ) 159#define XGI_USE_EXA 160#endif 161 162#endif 163 164/* Jong 01/13/2009; support EXA */ 165#define XGI_USE_XAA 166/* #define XGI_USE_EXA */ 167 168#ifdef XGI_USE_XAA 169#include "xaa.h" 170#endif 171#ifdef XGI_USE_EXA 172#include "exa.h" 173#endif 174 175#include "vgaHW.h" 176#include "vbe.h" 177 178/* 179#ifdef XORG_VERSION_CURRENT 180#include "xorgVersion.h" 181#endif */ 182 183/* #define XGIISXORGPOST70 */ 184 185#include "xgi_pci.h" 186#include "osdef.h" 187#include "vgatypes.h" 188#include "vb_struct.h" 189 190#ifdef XF86DRI 191#define XGINEWDRI 192#undef XGINEWDRI2 193 194#ifdef XF86_VERSION_CURRENT 195#if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,4,99,99,0) /* Adapt this when the time has come */ 196#define XGINEWDRI2 197#endif 198#endif /* XF86_VERSION_CURRENT */ 199 200#include "xf86drm.h" 201#include "sarea.h" 202#define _XF86DRI_SERVER_ 203 204/* Jong@09032009 */ 205#ifdef XORG_VERSION_CURRENT 206#if ( (XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(6,9,0,0,0)) || (XORG_VERSION_CURRENT <= XORG_VERSION_NUMERIC(2,0,0,0,0)) ) 207#include "X11/dri/xf86dri.h" 208#else 209#include "xf86dri.h" 210#endif 211#endif 212 213#include "dri.h" 214#include "GL/glxint.h" 215#include "xgi_dri.h" 216#endif 217 218#ifdef XSERVER_LIBPCIACCESS 219#define VENDOR_ID(p) (p)->vendor_id 220#define DEVICE_ID(p) (p)->device_id 221#define SUBSYS_ID(p) (p)->subdevice_id 222#define CHIP_REVISION(p) (p)->revision 223#else 224#define VENDOR_ID(p) (p)->vendor 225#define DEVICE_ID(p) (p)->chipType 226#define SUBSYS_ID(p) (p)->subsysCard 227#define CHIP_REVISION(p) (p)->chipRev 228#endif 229 230#if 1 231#define XGIDUALHEAD /* Include Dual Head code */ 232#endif 233 234#if 1 235#define XGIMERGED /* Include Merged-FB mode */ 236#endif 237 238#ifdef XGIMERGED 239#if 1 240#define XGIXINERAMA /* Include Pseudo-Xinerama for MergedFB mode */ 241#define XGI_XINERAMA_MAJOR_VERSION 1 242#define XGI_XINERAMA_MINOR_VERSION 1 243#endif 244#endif 245 246#if 1 247#define XGIGAMMA /* Include code for gamma correction */ 248#endif 249 250/* Jong 09/28/2007; disable this because it causes cursor drawing incorrectly */ 251#if 0 /* Include code for color hardware cursors */ 252#define XGI_ARGB_CURSOR 253#endif 254 255#if 0 /* Include YPbPr support on VB */ 256#define ENABLE_YPBPR 257#endif 258 259#ifdef XGIMERGED 260#ifdef XGIXINERAMA 261#define EXTENSION_PROC_ARGS void * 262#include "extnsionst.h" /* required */ 263#include <X11/extensions/panoramiXproto.h> /* required */ 264#endif 265#endif 266 267#if 1 268#define XGIVRAMQ /* Use VRAM queue mode on 315 series */ 269#endif 270 271#undef XGI315DRI /* define this if dri is adapted for 315/330 series */ 272 273#ifndef PCI_VENDOR_XGI 274#define PCI_VENDOR_XGI 0x18CA 275#endif 276#ifndef PCI_CHIP_XGIXG40 277#define PCI_CHIP_XGIXG40 0x0040 278#endif 279#ifndef PCI_CHIP_XGIXG20 280#define PCI_CHIP_XGIXG20 0x0020 281#endif 282 283/* Jong 09/18/2007; patch to GIT */ 284#ifndef PCI_CHIP_XGIXG27 285#define PCI_CHIP_XGIXG27 0x0027 286#endif 287 288/* Jong 01/07/2008; support New XG21 */ 289#ifndef PCI_CHIP_XGIXG21 290#define PCI_CHIP_XGIXG21 0x0021 291#endif 292 293#define CONFIG_DRM_XGI 294 295#define XGI_NAME "XGI" 296#define XGI_DRIVER_NAME "xgi" 297#define XGI_CURRENT_VERSION ((PACKAGE_VERSION_MAJOR << 16) | \ 298 (PACKAGE_VERSION_MINOR << 8) | \ 299 PACKAGE_VERSION_PATCHLEVEL) 300 301/* pXGI->Flags (old series only) */ 302#define SYNCDRAM 0x00000001 303#define RAMFLAG 0x00000002 304#define ESS137xPRESENT 0x00000004 305#define SECRETFLAG 0x00000008 306#define A6326REVAB 0x00000010 307#define MMIOMODE 0x00010000 308#define LFBQMODE 0x00020000 309#define AGPQMODE 0x00040000 310#define UMA 0x80000000 311 312#define BIOS_BASE 0xC0000 313#define BIOS_SIZE 0x10000 314 315#define SR_BUFFER_SIZE 5 316#define CR_BUFFER_SIZE 5 317 318#define XGI_VBFlagsVersion 1 319 320/* VBFlags - if anything is changed here, increase VBFlagsVersion! */ 321#define CRT2_DEFAULT 0x00000001 322#define CRT2_LCD 0x00000002 /* Never change the order of the CRT2_XXX entries */ 323#define CRT2_TV 0x00000004 324#define CRT2_VGA 0x00000008 325#define TV_NTSC 0x00000010 326#define TV_PAL 0x00000020 327#define TV_HIVISION 0x00000040 328#define TV_YPBPR 0x00000080 329#define TV_AVIDEO 0x00000100 330#define TV_SVIDEO 0x00000200 331#define TV_SCART 0x00000400 332#define VB_CONEXANT 0x00000800 /* 661 series only */ 333#define VB_TRUMPION VB_CONEXANT /* 300 series only */ 334#define TV_PALM 0x00001000 335#define TV_PALN 0x00002000 336#define TV_NTSCJ 0x00001000 337#define VB_302ELV 0x00004000 338#define TV_CHSCART 0x00008000 339#define TV_CHYPBPR525I 0x00010000 340#define CRT1_VGA 0x00000000 341#define CRT1_LCDA 0x00020000 342#define VGA2_CONNECTED 0x00040000 343#define DISPTYPE_CRT1 0x00080000 /* CRT1 connected and used */ 344 345#define SINGLE_MODE 0x20000000 /* CRT1 or CRT2; determined by DISPTYPE_CRTx */ 346#define MIRROR_MODE 0x40000000 /* CRT1 + CRT2 identical (mirror mode) */ 347#define DUALVIEW_MODE 0x80000000 /* CRT1 + CRT2 independent (dual head mode) */ 348 349/* Aliases: */ 350#define CRT2_ENABLE (CRT2_LCD | CRT2_TV | CRT2_VGA) 351#define TV_STANDARD (TV_NTSC | TV_PAL | TV_PALM | TV_PALN | TV_NTSCJ) 352#define TV_INTERFACE (TV_AVIDEO|TV_SVIDEO|TV_SCART|TV_HIVISION|TV_YPBPR) 353 354/* Only if TV_YPBPR is set: */ 355#define TV_YPBPR525I TV_NTSC 356#define TV_YPBPR525P TV_PAL 357#define TV_YPBPR750P TV_PALM 358#define TV_YPBPR1080I TV_PALN 359#define TV_YPBPRALL (TV_YPBPR525I | TV_YPBPR525P | TV_YPBPR750P | TV_YPBPR1080I) 360 361#define TV_YPBPR43LB TV_CHSCART 362#define TV_YPBPR43 TV_CHYPBPR525I 363#define TV_YPBPR169 (TV_CHSCART | TV_CHYPBPR525I) 364#define TV_YPBPRAR (TV_CHSCART | TV_CHYPBPR525I) 365 366 367#define DISPTYPE_DISP2 CRT2_ENABLE 368#define DISPTYPE_DISP1 DISPTYPE_CRT1 369#define VB_DISPMODE_SINGLE SINGLE_MODE /* alias */ 370#define VB_DISPMODE_MIRROR MIRROR_MODE /* alias */ 371#define VB_DISPMODE_DUAL DUALVIEW_MODE /* alias */ 372#define DISPLAY_MODE (SINGLE_MODE | MIRROR_MODE | DUALVIEW_MODE) 373 374/* PresetMode argument */ 375#define XGI_MODE_SIMU 0 376#define XGI_MODE_CRT1 1 377#define XGI_MODE_CRT2 2 378 379/* pXGI->MiscFlags */ 380#define MISC_CRT1OVERLAY 0x00000001 /* Current display mode supports overlay */ 381#define MISC_PANELLINKSCALER 0x00000002 /* Panel link is currently scaling */ 382#define MISC_CRT1OVERLAYGAMMA 0x00000004 /* Current display mode supports overlay gamma corr on CRT1 */ 383#define MISC_TVNTSC1024 0x00000008 /* Current display mode is TV NTSC/PALM/YPBPR525I 1024x768 */ 384 385 386#define HW_DEVICE_EXTENSION XGI_HW_DEVICE_INFO 387 388#define BITMASK(h,l) (((unsigned)(1U << ((h)-(l)+1))-1)<<(l)) 389#define GENMASK(mask) BITMASK(1?mask,0?mask) 390 391typedef unsigned long ULong; 392typedef unsigned short UShort; 393typedef unsigned char UChar; 394 395 396/* ChipFlags */ 397/* Use only lower 16 bit for chip id! (xgictrl) */ 398#define XGICF_LARGEOVERLAY 0x00000001 399#define XGICF_Is651 0x00000002 400#define XGICF_IsM650 0x00000004 401#define XGICF_IsM652 0x00000008 402#define XGICF_IsM653 0x00000010 403#define XGICF_Is652 0x00000020 404#define XGICF_Is65x (XGICF_Is651|XGICF_IsM650|XGICF_IsM652|XGICF_IsM653|XGICF_Is652) 405#define XGICF_IsM661 0x00000100 /* M661FX */ 406#define XGICF_IsM741 0x00000200 407#define XGICF_IsM760 0x00000400 408#define XGICF_IsM661M 0x00000800 /* M661MX */ 409#define XGICF_IsM66x (XGICF_IsM661 | XGICF_IsM741 | XGICF_IsM760 | XGICF_IsM661M) 410#define XGICF_315Core 0x00010000 /* 3D: Real 315 */ 411#define XGICF_Real256ECore 0x00020000 /* 3D: Similar to 315 core, no T&L? (65x, 661, 740, 741) */ 412#define XGICF_XabreCore 0x00040000 /* 3D: Real Xabre */ 413#define XGICF_Ultra256Core 0x00080000 /* 3D: Similar to Xabre, no T&L?, no P:Shader? (660, 760) */ 414#define XGICF_UseLCDA 0x01000000 415#define XGICF_760UMA 0x10000000 /* 760: UMA active */ 416#define XGICF_CRT2HWCKaputt 0x20000000 /* CRT2 Mono HWCursor engine buggy */ 417#define XGICF_Glamour3 0x40000000 418#define XGICF_Integrated 0x80000000 419 420/* Direct Xv-API */ 421#define XGI_SD_IS300SERIES 0x00000001 422#define XGI_SD_IS315SERIES 0x00000002 423#define XGI_SD_IS330SERIES 0x00000004 424#define XGI_SD_SUPPORTPALMN 0x00000008 /* tv chip supports pal-m, pal-n */ 425#define XGI_SD_SUPPORT2OVL 0x00000010 /* set = 2 overlays, clear = support SWITCHCRT xv prop */ 426#define XGI_SD_SUPPORTTVPOS 0x00000020 /* supports changing tv position */ 427#define XGI_SD_ISDUALHEAD 0x00000040 /* Driver is in dual head mode */ 428#define XGI_SD_ISMERGEDFB 0x00000080 /* Driver is in merged fb mode */ 429#define XGI_SD_ISDHSECONDHEAD 0x00000100 /* Dual head: This is CRT1 (=second head) */ 430#define XGI_SD_ISDHXINERAMA 0x00000200 /* Dual head: We are running Xinerama */ 431#define XGI_SD_VBHASSCART 0x00000400 /* videobridge has SCART instead of VGA2 */ 432#define XGI_SD_ISDEPTH8 0x00000800 /* Depth is 8, no independent gamma correction */ 433#define XGI_SD_ENABLED 0x00002000 /* xgictrl is enabled (by option) */ 434#define XGI_SD_PSEUDOXINERAMA 0x00004000 /* pseudo xinerama is active */ 435#define XGI_SD_SUPPORTLCDA 0x00008000 /* Support LCD Channel A */ 436#define XGI_SD_SUPPORTNTSCJ 0x00010000 /* tv chip supports ntsc-j */ 437#define XGI_SD_ADDLSUPFLAG 0x00020000 /* 1 = the following flags are valid */ 438#define XGI_SD_SUPPORTVGA2 0x00040000 /* CRT2=VGA supported */ 439#define XGI_SD_SUPPORTSCART 0x00080000 /* CRT2=SCART supported */ 440#define XGI_SD_SUPPORTOVERSCAN 0x00100000 /* Overscan flag supported */ 441#define XGI_SD_SUPPORTXVGAMMA1 0x00200000 /* Xv Gamma correction for CRT1 supported */ 442#define XGI_SD_SUPPORTTV 0x00400000 /* CRT2=TV supported */ 443#define XGI_SD_SUPPORTYPBPR 0x00800000 /* CRT2=YPbPr (525i, 525p, 750p, 1080i) is supported */ 444#define XGI_SD_SUPPORTHIVISION 0x01000000 /* CRT2=HiVision is supported */ 445#define XGI_SD_SUPPORTYPBPRAR 0x02000000 /* YPbPr aspect ratio is supported */ 446#define XGI_SD_SUPPORTSCALE 0x04000000 /* Scaling of LCD panel supported */ 447#define XGI_SD_SUPPORTCENTER 0x08000000 /* If scaling supported: Centering of screen [NOT] supported (TMDS only) */ 448 449#define XGI_DIRECTKEY 0x03145792 450 451/* XGICtrl: Check mode for CRT2 */ 452#define XGI_CF2_LCD 0x01 453#define XGI_CF2_TV 0x02 454#define XGI_CF2_VGA2 0x04 455#define XGI_CF2_TVPAL 0x08 456#define XGI_CF2_TVNTSC 0x10 /* + NTSC-J */ 457#define XGI_CF2_TVPALM 0x20 458#define XGI_CF2_TVPALN 0x40 459#define XGI_CF2_CRT1LCDA 0x80 460#define XGI_CF2_TYPEMASK (XGI_CF2_LCD | XGI_CF2_TV | XGI_CF2_VGA2 | XGI_CF2_CRT1LCDA) 461#define XGI_CF2_TVSPECIAL (XGI_CF2_LCD | XGI_CF2_TV) 462#define XGI_CF2_TVSPECMASK (XGI_CF2_TVPAL | XGI_CF2_TVNTSC | XGI_CF2_TVPALM | XGI_CF2_TVPALN) 463#define XGI_CF2_TVHIVISION XGI_CF2_TVPAL 464#define XGI_CF2_TVYPBPR525I XGI_CF2_TVNTSC 465#define XGI_CF2_TVYPBPR525P (XGI_CF2_TVPAL | XGI_CF2_TVNTSC) 466#define XGI_CF2_TVYPBPR750P XGI_CF2_TVPALM 467#define XGI_CF2_TVYPBPR1080I (XGI_CF2_TVPALM | XGI_CF2_TVPAL) 468 469/* AGP stuff for DRI */ 470#define AGP_PAGE_SIZE 4096 471#define AGP_PAGES 2048 /* Default: 2048 pages @ 4096 = 8MB */ 472/* 300 */ 473#define AGP_CMDBUF_PAGES 256 474#define AGP_CMDBUF_SIZE (AGP_PAGE_SIZE * AGP_CMDBUF_PAGES) 475/* 315/330 */ 476#define AGP_VTXBUF_PAGES 512 477#define AGP_VTXBUF_SIZE (AGP_PAGE_SIZE * AGP_VTXBUF_PAGES) 478 479#define VOLARI_CQSIZE (1024*1024) 480#define VOLARI_CQSIZEXG20 (128*1024) 481#define VOLARI_CURSOR_SHAPE_SIZE (64*64*4) 482 483/* For backup of register contents */ 484typedef struct { 485 unsigned char xgiRegs3C4[0x50]; 486 unsigned char xgiRegs3D4[0x90]; 487 unsigned char xgiRegs3C2; 488 unsigned char xgiCapt[0x60]; 489 unsigned char xgiVid[0x50]; 490 unsigned char VBPart1[0x50]; 491 unsigned char VBPart2[0x100]; 492 unsigned char VBPart3[0x50]; 493 unsigned char VBPart4[0x50]; 494 unsigned short ch70xx[64]; 495 unsigned long xgiMMIO85C0; 496 unsigned char xgi6326tv[0x46]; 497 unsigned long xgiRegsPCI50, xgiRegsPCIA0; 498} XGIRegRec, *XGIRegPtr; 499 500 501/* XGIFBLayout is mainly there because of DGA. It holds the 502 * current layout parameters needed for acceleration and other 503 * stuff. When switching mode using DGA, these are set up 504 * accordingly and not necessarily match pScrn's. Therefore, 505 * driver modules should read these values instead of pScrn's. 506 */ 507typedef struct { 508 int bitsPerPixel; /* = pScrn->bitsPerPixel */ 509 int depth; /* = pScrn->depth */ 510 int displayWidth; /* = pScrn->displayWidth */ 511 DisplayModePtr mode; /* = pScrn->currentMode */ 512} XGIFBLayout; 513 514/* Dual head private entity structure */ 515typedef struct { 516 ScrnInfoPtr pScrn_1; 517 ScrnInfoPtr pScrn_2; 518 unsigned char * BIOS; 519 VB_DEVICE_INFO *XGI_Pr; 520 int CRT2ModeNo; /* Current display mode for CRT2 */ 521 Bool CRT2ModeSet; /* CRT2 mode has been set */ 522 unsigned char CRT2CR30, CRT2CR31, CRT2CR35, CRT2CR38; 523 int refCount; 524 525 /** 526 * Number of entities 527 * 528 * \bug 529 * This field is tested in one place, but it doesn't appear to ever be 530 * set or modified. 531 */ 532 int lastInstance; 533 534 Bool DisableDual; /* Emergency flag */ 535 Bool ErrorAfterFirst; /* Emergency flag: Error after first init -> Abort second */ 536 int maxUsedClock; /* Max used pixelclock on master head */ 537 538 /** 539 * Framebuffer addresses and sizes 540 * 541 * \bug 542 * These 4 fields are set, but the stored values don't appear to be used. 543 */ 544 unsigned long masterFbAddress; 545 unsigned long masterFbSize; 546 unsigned long slaveFbAddress; 547 unsigned long slaveFbSize; 548 549 unsigned char * FbBase; /* VRAM linear address */ 550 unsigned char * IOBase; /* MMIO linear address */ 551 552 /** 553 * Map / unmap queue counter. 554 * 555 * \bug 556 * These vales are tested, set to zero, or decremented. However, I don't 557 * see anywhere in the code where they are incremented. 558 */ 559 unsigned short MapCountIOBase; 560 unsigned short MapCountFbBase; 561 562 Bool forceUnmapIOBase; /* ignore counter and unmap */ 563 Bool forceUnmapFbBase; /* ignore counter and unmap */ 564#ifdef __alpha__ 565 unsigned char * IOBaseDense; /* MMIO for Alpha platform */ 566 unsigned short MapCountIOBaseDense; 567 Bool forceUnmapIOBaseDense; /* ignore counter and unmap */ 568#endif 569 BOOLEAN CRT1gamma; 570 571 /** 572 * \bug This field is tested and set to \c NULL but never used. 573 */ 574 unsigned char *RenderAccelArray; 575 unsigned char * FbBase1; 576 unsigned long OnScreenSize1; 577 578#ifdef XGI_CP 579 XGI_CP_H_ENT 580#endif 581} XGIEntRec, *XGIEntPtr; 582 583#define XGIPTR(p) ((XGIPtr)((p)->driverPrivate)) 584#define XAAPTR(p) ((XAAInfoRecPtr)(XGIPTR(p)->AccelInfoPtr)) 585 586#define ExtRegSize 0x40 587 588 589/* Relative merge position */ 590typedef enum { 591 xgiLeftOf, 592 xgiRightOf, 593 xgiAbove, 594 xgiBelow, 595 xgiClone 596} XGIScrn2Rel; 597 598typedef struct MonitorRange { 599 float loH,hiH,loV,hiV ; 600}MonitorRangeRec,*MonitorRangePtr ; 601 602typedef struct { 603 ScrnInfoPtr pScrn; /* -------------- DON'T INSERT ANYTHING HERE --------------- */ 604#ifdef XSERVER_LIBPCIACCESS 605 struct pci_device * PciInfo; 606#else 607 pciVideoPtr PciInfo; /* -------- OTHERWISE xgi_dri.so MUST BE RECOMPILED -------- */ 608 PCITAG PciTag; 609#endif 610 EntityInfoPtr pEnt; 611 int Chipset; 612 int ChipRev; 613 VB_DEVICE_INFO *XGI_Pr; /* For new mode switching code */ 614 unsigned long FbAddress; /* VRAM physical address (in DHM: for each Fb!) */ 615 unsigned long realFbAddress; /* For DHM/PCI mem mapping: store global FBAddress */ 616 unsigned char * FbBase; /* VRAM virtual linear address */ 617 CARD32 IOAddress; /* MMIO physical address */ 618 unsigned char * IOBase; /* MMIO linear address */ 619 IOADDRESS IODBase; /* Base of PIO memory area */ 620#ifdef __alpha__ 621 unsigned char * IOBaseDense; /* MMIO for Alpha platform */ 622#endif 623 XGIIOADDRESS RelIO; /* Relocated IO Ports baseaddress */ 624 unsigned char * BIOS; 625 int MemClock; 626 int BusWidth; 627 int MinClock; 628 int MaxClock; 629 int Flags; /* HW config flags */ 630 long FbMapSize; /* Used for Mem Mapping - DON'T CHANGE THIS */ 631 long availMem; /* Really available Fb mem (minus TQ, HWCursor) */ 632 unsigned long maxxfbmem; /* limit fb memory X is to use to this (KB) */ 633 unsigned long xgifbMem; /* heapstart of xgifb (if running) */ 634 unsigned long dhmOffset; /* Offset to memory for each head (0 or ..) */ 635 DGAModePtr DGAModes; 636 int numDGAModes; 637 Bool DGAactive; 638 Bool NoAccel; 639 Bool useEXA; /* Jong 01/13/2009; support EXA */ 640 Bool NoXvideo; 641 Bool TurboQueue; 642 int ForceCRT1Type; 643 int ForceCRT2Type; 644 int OptROMUsage; 645 Bool ValidWidth; 646 unsigned char myCR63; 647 unsigned long VBFlags; /* Video bridge configuration */ 648 unsigned long VBFlags_backup; /* Backup for SlaveMode-modes */ 649 650 short scrnOffset; /* Screen pitch (data) */ 651 short scrnPitch; /* Screen pitch (display; regarding interlace) */ 652 unsigned long DstColor; 653 int xcurrent; /* for temp use in accel */ 654 int ycurrent; /* for temp use in accel */ 655 int CommandReg; 656 657 Bool HWCursor; 658 CARD16 CursorSize; /* Size of HWCursor area (bytes) */ 659 xf86CursorInfoPtr CursorInfoPtr; 660 unsigned CursorOffset; 661 662 /** 663 * \bug This field is set to \c FALSE but never used. 664 */ 665 Bool DoColorExpand; 666 667 XGIRegRec SavedReg; 668 XGIRegRec ModeReg; 669 670#ifdef XGI_USE_XAA 671 XAAInfoRecPtr AccelInfoPtr; 672#endif 673#ifdef XGI_USE_EXA /* Jong 01/13/2009; support EXA */ 674 ExaDriverPtr EXADriverPtr; 675 int fillPitch, fillBpp; 676 CARD32 fillDstBase; 677 int copyBpp; 678 int copySPitch, copyDPitch; 679 CARD32 copySrcBase, copyDstBase; 680 int copyXdir, copyYdir; 681 ExaOffscreenArea* exa_scratch; 682 unsigned int exa_scratch_next; 683#endif 684 685 CloseScreenProcPtr CloseScreen; 686 Bool (*ModeInit)(ScrnInfoPtr pScrn, DisplayModePtr mode); 687 void (*XGISave)(ScrnInfoPtr pScrn, XGIRegPtr xgireg); 688 void (*XGISave2)(ScrnInfoPtr pScrn, XGIRegPtr xgireg); 689 void (*XGISave3)(ScrnInfoPtr pScrn, XGIRegPtr xgireg); 690 void (*XGIRestore)(ScrnInfoPtr pScrn, XGIRegPtr xgireg); 691 void (*XGIRestore2)(ScrnInfoPtr pScrn, XGIRegPtr xgireg); 692 void (*XGIRestore3)(ScrnInfoPtr pScrn, XGIRegPtr xgireg); 693 void (*LoadCRT2Palette)(ScrnInfoPtr pScrn, int numColors, 694 int *indicies, LOCO *colors, VisualPtr pVisual); 695 696 int cmdQueueLen; /* Current cmdQueueLength (for 2D and 3D) */ 697 unsigned long cmdQueueLenMax; 698 unsigned long cmdQueueLenMin; 699 unsigned char *cmdQueueBase; 700 int *cmdQueueLenPtr; /* Ptr to variable holding the current queue length */ 701 unsigned int cmdQueueOffset; 702 unsigned int cmdQueueSize; 703 unsigned long cmdQueueSizeMask; 704 705 /** 706 * \bug This field is set but never used. 707 */ 708 unsigned int agpWantedPages; 709 710#ifdef XF86DRI 711 unsigned long agpHandle; 712 unsigned long agpAddr; 713 unsigned char *agpBase; 714 unsigned int agpSize; 715 unsigned long agpVtxBufAddr; /* 315 series */ 716 unsigned char *agpVtxBufBase; 717 unsigned int agpVtxBufSize; 718 unsigned int agpVtxBufFree; 719 xgiRegion agp; 720 Bool irqEnabled; 721 int irq; 722#endif 723 unsigned long DRIheapstart, DRIheapend; 724 725 void (*RenderCallback)(ScrnInfoPtr); 726 727 /** 728 * \bug This field is tested and set to \c NULL but never used. 729 */ 730 unsigned char *RenderAccelArray; 731 732 /** 733 * \bug This field is to \c TRUE but never used. 734 */ 735 Bool doRender; 736 737 int PerColorExpandBufferSize; 738 int ColorExpandBufferNumber; 739 unsigned char *ColorExpandBufferAddr[32]; 740 int ColorExpandBufferScreenOffset[32]; 741 742 /** 743 * \bug This field is read but never initialized. 744 */ 745 int ImageWriteBufferSize; 746 747 unsigned char *ImageWriteBufferAddr; 748 749 int Rotate; 750 751 BOOLEAN HaveCustomModes; /* Jong 07/27/2009; support customer modes */ 752 753 /* ShadowFB support */ 754 Bool ShadowFB; 755 unsigned char *ShadowPtr; 756 int ShadowPitch; 757 758 /** 759 * \bug This field is set but never used. 760 */ 761 Bool loadDRI; 762 763#ifdef XF86DRI 764 Bool directRenderingEnabled; 765 DRIInfoPtr pDRIInfo; 766 int drmSubFD; 767 int numVisualConfigs; 768 __GLXvisualConfig* pVisualConfigs; 769 XGIConfigPrivPtr pVisualConfigsPriv; 770#endif 771 772 HW_DEVICE_EXTENSION xgi_HwDevExt; /* For new mode switching code */ 773 XF86VideoAdaptorPtr adaptor; 774 ScreenBlockHandlerProcPtr BlockHandler; 775 776 /** 777 * \bug This field is tested and used but never set. 778 */ 779 void (*VideoTimerCallback)(ScrnInfoPtr, Time); 780 781 void (*ResetXv)(ScrnInfoPtr); 782 void (*ResetXvGamma)(ScrnInfoPtr); 783 784 OptionInfoPtr Options; 785 786 /** 787 * \bug This field is used but never initialized. 788 */ 789 unsigned char LCDon; 790 Bool Blank; 791 int CRT1off; /* 1=CRT1 off, 0=CRT1 on */ 792 CARD16 LCDheight; /* Vertical resolution of LCD panel */ 793 CARD16 LCDwidth; /* Horizontal resolution of LCD panel */ 794 vbeInfoPtr pVbe; /* For VESA mode switching */ 795 UCHAR ScratchSet[16]; 796 MonitorRangeRec CRT1Range,CRT2Range; 797 798#ifdef XGIDUALHEAD 799 BOOL DualHeadMode; /* TRUE if we use dual head mode */ 800 BOOL SecondHead; /* TRUE is this is the second head */ 801 XGIEntPtr entityPrivate; /* Ptr to private entity (see above) */ 802#endif 803 XGIFBLayout CurrentLayout; /* Current framebuffer layout */ 804 BOOL Primary; /* Display adapter is primary */ 805 xf86Int10InfoPtr pInt; /* Our int10 */ 806 807 /** 808 * Use our own default modes? 809 * 810 * \bug This field is set but never used. 811 */ 812 Bool noInternalModes; 813 814 int ForceTVType, SenseYPbPr; 815 int NonDefaultPAL, NonDefaultNTSC; 816 unsigned long ForceYPbPrType, ForceYPbPrAR; 817 unsigned long lockcalls; /* Count unlock calls for debug */ 818 819 Atom xvBrightness, xvContrast, xvColorKey, xvHue, xvSaturation; 820 Atom xvAutopaintColorKey, xvSetDefaults, xvSwitchCRT; 821 Atom xvDisableGfx, xvDisableGfxLR, xvTVXPosition, xvTVYPosition; 822 Atom xvDisableColorkey, xvUseChromakey, xvChromaMin, xvChromaMax; 823 Atom xvInsideChromakey, xvYUVChromakey; 824 Atom xvGammaRed, xvGammaGreen, xvGammaBlue; 825#ifdef XGI_CP 826 XGI_CP_H 827#endif 828 unsigned long ChipFlags; 829 unsigned long XGI_SD_Flags; 830 BOOLEAN UseHWARGBCursor; 831 BOOLEAN HWARGBCursor; 832 int vb; 833 BOOLEAN restorebyset; 834 BOOLEAN nocrt2ddcdetection; 835 BOOLEAN forcecrt2redetection; 836 BOOLEAN CRT1gamma, CRT1gammaGiven, CRT2gamma, XvGamma, XvGammaGiven; 837 int XvDefCon, XvDefBri, XvDefHue, XvDefSat; 838 BOOLEAN XvDefDisableGfx, XvDefDisableGfxLR; 839 BOOLEAN XvUseMemcpy; 840 int XvGammaRed, XvGammaGreen, XvGammaBlue; 841 CARD8 XvGammaRampRed[256], XvGammaRampGreen[256], XvGammaRampBlue[256]; 842 BOOLEAN disablecolorkeycurrent; 843 CARD32 colorKey; 844 CARD32 MiscFlags; 845 846#ifdef XGI_USE_XAA 847 FBLinearPtr AccelLinearScratch; 848#endif 849 850 float zClearVal; 851 unsigned long bClrColor, dwColor; 852 int AllowHotkey; 853 BOOLEAN enablexgictrl; 854 short Video_MaxWidth, Video_MaxHeight; 855 short scrnPitch2; 856 int CurXPreset ; 857 int CurYPreset ; 858 unsigned long mmioSize; 859#ifdef XGIMERGED 860 Bool MergedFB, MergedFBAuto; 861 XGIScrn2Rel CRT2Position; 862 char * CRT2HSync; 863 char * CRT2VRefresh; 864 char * MetaModes; 865 ScrnInfoPtr CRT2pScrn; 866 DisplayModePtr CRT1Modes; 867 DisplayModePtr CRT1CurrentMode; 868 int CRT1frameX0; 869 int CRT1frameY0; 870 int CRT1frameX1; 871 int CRT1frameY1; 872 Bool CheckForCRT2; 873 int MergedFBXDPI, MergedFBYDPI; 874#ifdef XGIXINERAMA 875 Bool UsexgiXinerama; 876 Bool CRT2IsScrn0; 877 ExtensionEntry *XineramaExtEntry; 878 int xgiXineramaVX, xgiXineramaVY; 879 Bool AtLeastOneNonClone; 880#endif 881#endif 882 883 /* Added for 3D */ 884 unsigned long cmdQueue_shareWP_only2D; 885 unsigned long *pCQ_shareWritePort; 886 void (*SetThreshold)(ScrnInfoPtr pScrn, DisplayModePtr mode, 887 unsigned short *Low, unsigned short *High); 888 889 XGI_DSReg SRList[ExtRegSize] ; 890 XGI_DSReg CRList[ExtRegSize] ; 891 892 /** 893 * Total number of iterations to wait in \c Volari_Idle. 894 */ 895 unsigned int idle_wait_count; 896 897//:::: for capture 898 Bool v4l_videoin; 899 int v4l_devnum; /* v4l device number, 0,1,2....*/ 900//~:::: 901 902 int TargetRefreshRate; 903 Bool IgnoreDDC; 904 905 Bool Non_DDC_DefaultMode; 906 int Non_DDC_DefaultResolutionX ; 907 int Non_DDC_DefaultResolutionY ; 908 int Non_DDC_DefaultRefreshRate ; 909} XGIRec, *XGIPtr; 910 911#ifdef XGIDUALHEAD 912# define IS_DUAL_HEAD(x) ((x)->DualHeadMode) 913# define IS_SECOND_HEAD(x) ((x)->SecondHead) 914# define ENTITY_PRIVATE(x) ((x)->entityPrivate) 915#else 916# define IS_DUAL_HEAD(x) FALSE 917# define IS_SECOND_HEAD(x) FALSE 918# define ENTITY_PRIVATE(x) NULL 919#endif 920 921 922#define SEQ_ADDRESS_PORT 0x0014 923#define MISC_OUTPUT_REG_WRITE_PORT 0x0012 924#define MISC_OUTPUT_REG_READ_PORT 0x001C 925#define GRAPH_ADDRESS_PORT 0x001E 926#define VIDEO_SUBSYSTEM_ENABLE_PORT 0x0013 927#define CRTC_ADDRESS_PORT_COLOR 0x0024 928#define PCI_COMMAND 0x04 929 930#define SDMPTR(x) ((XGIMergedDisplayModePtr)(x->currentMode->Private)) 931#define CDMPTR ((XGIMergedDisplayModePtr)(pXGI->CurrentLayout.mode->Private)) 932 933#define BOUND(test,low,hi) { \ 934 if(test < low) test = low; \ 935 if(test > hi) test = hi; } 936 937#define REBOUND(low,hi,test) { \ 938 if(test < low) { \ 939 hi += test-low; \ 940 low = test; } \ 941 if(test > hi) { \ 942 low += test-hi; \ 943 hi = test; } } 944 945typedef struct _MergedDisplayModeRec { 946 DisplayModePtr CRT1; 947 DisplayModePtr CRT2; 948 XGIScrn2Rel CRT2Position; 949} XGIMergedDisplayModeRec, *XGIMergedDisplayModePtr; 950 951 952typedef struct _region { 953 int x0,x1,y0,y1; 954} region; 955 956 957extern void xgiOptions(ScrnInfoPtr pScrn); 958extern const OptionInfoRec * XGIAvailableOptions(int chipid, int busid); 959extern void XGISetup(ScrnInfoPtr pScrn); 960extern void XGIVGAPreInit(ScrnInfoPtr pScrn); 961extern Bool XGIAccelInit(ScreenPtr pScreen); 962extern Bool XGIHWCursorInit(ScreenPtr pScreen); 963extern Bool XGIDGAInit(ScreenPtr pScreen); 964extern void XGIInitVideo(ScreenPtr pScreen); 965 966extern int XGI_GetCHTVlumabandwidthcvbs(ScrnInfoPtr pScrn); 967 968int XG40Mclk(XGIPtr pXGI); 969 970void XGINew_InitVBIOSData(PXGI_HW_DEVICE_INFO HwDeviceExtension, PVB_DEVICE_INFO pVBInfo) ; 971int compute_vclk(int Clock, int *out_n, int *out_dn, int *out_div, 972 int *out_sbit, int *out_scale); 973 974void XGI_WaitBeginRetrace(XGIIOADDRESS RelIO); 975void XGI_WaitEndRetrace(XGIIOADDRESS RelIO); 976 977/* 2005/11/21 added by jjtseng */ 978#define DelayS(sec) usleep((sec)*1000000) 979#define DelayMS(millisec) usleep((millisec)*1000) 980#define DelayUS(microsec) usleep((microsec)) 981/*~jjtseng 2005/11/21 */ 982 983Bool Volari_AccelInit(ScreenPtr pScreen) ; 984/* void XGI_UnLockCRT2(PXGI_HW_DEVICE_INFO,USHORT BaseAddr); */ 985/* void XGI_LockCRT2(PXGI_HW_DEVICE_INFO,USHORT BaseAddr); */ 986/* void XGI_DisableBridge(PXGI_HW_DEVICE_INFO,USHORT BaseAddr); */ 987/* void XGI_EnableBridge(PXGI_HW_DEVICE_INFO,USHORT BaseAddr); */ 988#endif 989 990extern USHORT XGI_GetModeID(ULONG VBFlags, int HDisplay, int VDisplay, 991 int Depth, int LCDwith, int LCDheight); 992 993extern BOOLEAN XGI_SearchModeID(const XGI_StStruct *SModeIDTable, 994 const XGI_ExtStruct *EModeIDTable, unsigned char VGAINFO, 995 USHORT *ModeNo, USHORT *ModeIdIndex); 996 997extern UCHAR XGI_GetModePtr(const XGI_StStruct *SModeIDTable, 998 unsigned ModeType, USHORT ModeNo, USHORT ModeIdIndex); 999 1000extern void XGI_SetReg(XGIIOADDRESS port, USHORT index, USHORT data); 1001extern void XGI_SetRegByte(XGIIOADDRESS port, USHORT data); 1002extern void XGI_SetRegShort(XGIIOADDRESS port, USHORT data); 1003extern void XGI_SetRegLong(XGIIOADDRESS port, ULONG data); 1004extern UCHAR XGI_GetReg(XGIIOADDRESS port, USHORT index); 1005extern UCHAR XGI_GetRegByte(XGIIOADDRESS port); 1006extern USHORT XGI_GetRegShort(XGIIOADDRESS port); 1007extern ULONG XGI_GetRegLong(XGIIOADDRESS port); 1008extern void XGI_SetRegANDOR(XGIIOADDRESS Port, USHORT Index, USHORT DataAND, 1009 USHORT DataOR); 1010extern void XGI_SetRegAND(XGIIOADDRESS Port, USHORT Index, USHORT DataAND); 1011extern void XGI_SetRegOR(XGIIOADDRESS Port, USHORT Index, USHORT DataOR); 1012 1013#ifndef __NetBSD__ 1014#define uint8_t CARD8 1015#endif 1016 1017extern void XGI_WriteDAC(XGIIOADDRESS dac_data, unsigned shift, 1018 unsigned ordering, uint8_t red, uint8_t green, uint8_t blue); 1019 1020#ifdef DEBUG 1021void XGIDumpRegs(ScrnInfoPtr pScrn); 1022 1023/** 1024 * Write value to the PC's 0x80 debug port. 1025 * 1026 * \bug 1027 * I'm pretty sure the debug 0x80 only exists on PCs. Should this routine 1028 * be a no-op on non-x86 and non-x86-64 architectures? 1029 */ 1030#define Newdebugcode(dbg_code) outb(0x80, dbg_code) 1031#else 1032#define Newdebugcode(dbg_code) 1033#endif 1034