Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

847 lines
33 KiB

  1. /******************************Module*Header*******************************\
  2. *
  3. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  4. * !! !!
  5. * !! WARNING: NOT DDK SAMPLE CODE !!
  6. * !! !!
  7. * !! This source code is provided for completeness only and should not be !!
  8. * !! used as sample code for display driver development. Only those sources !!
  9. * !! marked as sample code for a given driver component should be used for !!
  10. * !! development purposes. !!
  11. * !! !!
  12. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  13. *
  14. * Module Name: glglobal.h
  15. *
  16. * Content:
  17. *
  18. * Copyright (c) 1994-1999 3Dlabs Inc. Ltd. All rights reserved.
  19. * Copyright (c) 1995-2003 Microsoft Corporation. All rights reserved.
  20. \*****************************************************************************/
  21. //
  22. // glglobal.h
  23. //
  24. // Common shared area for all components
  25. #ifdef __GLGLOBAL
  26. #pragma message ("FILE : "__FILE__" : Multiple inclusion")
  27. #endif
  28. #define __GLGLOBAL
  29. // Registry locations
  30. #define REGKEYROOT "SOFTWARE\\"
  31. #define REGKEYDIRECTXSUFFIX "\\DirectX"
  32. #define REGKEYDISPLAYSUFFIX "\\Display"
  33. #define REGKEYVFWSUFFIX "\\VFW"
  34. #define MAXCONTEXT 128
  35. #define MAX_SUBBUFFERS 32
  36. // Max no of letters in the device name.
  37. #define MAX_DEVICENAME_SIZE 32
  38. // This many dwords to resend the bad regs every DMAA buffer
  39. #define PERMEDIA_REV1_BAD_READBACK_REGISTER_SPACE 12
  40. #define GLINT_DMA 1
  41. #define GLINT_NON_DMA 2
  42. #define GLINT_FAKE_DMA 8
  43. #define GLINT_UNKNOWN_INTERFACE 0xFF
  44. // Definitions for the various chip types.
  45. #define VENDOR_ID_3DLABS 0x3D3D
  46. #define VENDOR_ID_TI 0x104C
  47. // Allof these ID's are guaranteed to fit into 16 bits
  48. #define NOCHIP_ID 0x0
  49. #define GLINT300SX_ID 0x1
  50. #define GLINT500TX_ID 0x2
  51. #define DELTA_ID 0x3
  52. #define PERMEDIA_ID 0x4
  53. #define TIPERMEDIA_ID 0x3d04
  54. #define GLINTMX_ID 0x6
  55. #define TIPERMEDIA2_ID 0x3d07 // also known as P2C or P2A as of july 98
  56. #define GAMMA_ID 0x8
  57. #define PERMEDIA2_ID 0x9 // also known as P2V
  58. #define PERMEDIA3_ID 0xa
  59. #define GLINTR3_ID 0xb
  60. #define PERMEDIA4_ID 0xc
  61. #define GLINTR4_ID 0xd
  62. #define GAMMA2_ID 0xe
  63. #define GAMMA3_ID 0xf
  64. #define GIGI_ID 0x8000
  65. #define UNKNOWN_DEVICE_ID 0xffff
  66. #define GLINTRX_ID GLINTR3_ID
  67. #define GLINT_ID GLINT300SX_ID
  68. #define P3R3_ID PERMEDIA3_ID
  69. #define PERMEDIA_SUBSYSTEM_ID 0x96
  70. #define PERMEDIA_NT_SUBSYSTEM_ID 0x98
  71. #define PERMEDIA_LC_SUBSYSTEM_ID 0x99
  72. #define PERMEDIA2_SUBSYSTEM_ID 0xa0
  73. // Pointer types - used in mini\pointer.c
  74. #define SOFTWARECURSOR 0
  75. #define HARDWARECURSOR 1
  76. #define GLINT300SX_REV1 (0 | (GLINT300SX_ID << 16))
  77. #define GLINT300SX_REV2 (2 | (GLINT300SX_ID << 16))
  78. #define GLINT500TX_REV1 (1 | (GLINT500TX_ID << 16))
  79. #define GLINTMX_REV1 (1 | (GLINTMX_ID << 16))
  80. #define DELTA_REV1 (1 | (DELTA_ID << 16))
  81. #define PERMEDIA_REV1 (1 | (PERMEDIA_ID << 16))
  82. #define TI_PERMEDIA_REV1 (1 | (TIPERMEDIA_ID << 16))
  83. #define PERMEDIA2_REV0 (0 | (PERMEDIA2_ID << 16))
  84. #define PERMEDIA2_REV1 (1 | (PERMEDIA2_ID << 16))
  85. #define TIPERMEDIA2_REV1 (1 | (TIPERMEDIA2_ID << 16))
  86. #define TIPERMEDIA2_REV2 (0x11 | (TIPERMEDIA2_ID << 16))
  87. #define PERMEDIA3_REV1 (1 | (PERMEDIA3_ID << 16))
  88. #define GLINTR3_REV1 (1 | (GLINTR3_ID << 16))
  89. #define PERMEDIA4_REV1 (1 | (PERMEDIA4_ID << 16))
  90. #define GLINTR4_REV1 (1 | (GLINTR4_ID << 16))
  91. #define GLINT_GETVERSION 1
  92. #define GLINT_IOCTL_ADD_CONTEXT_MEMORY 2
  93. #define GLINT_MEMORY_REQUEST 3
  94. #define GLINT_16TO32_POINTER 4
  95. #define GLINT_I2C 5
  96. #define GLINT_VMI_COMMAND 6
  97. #define GLINT_FILE_IO 7
  98. // defined in demondef.h
  99. //#define GLINT_DEMON_COMMAND 8
  100. #define GLINT_SIMULATOR 9
  101. #define GLINT_GET_SOFT_ENGINE_INFO 6009
  102. #define IOCTL_REGISTER_TEXTURE_HANDLER 0x20
  103. #define IOCTL_REMOVE_TEXTURE_HANDLER 0x21
  104. typedef struct {
  105. unsigned long dwDevNode;
  106. unsigned long Ring0EventHandle; // Ring zero event handle to signal. Free'd by IOCTL on failure
  107. } REGISTERTEXTUREHANDLERIN, *PREGISTERTEXTUREHANDLERIN;
  108. typedef struct {
  109. unsigned long Handle; // Returned handle
  110. unsigned long Index;
  111. } REGISTERTEXTUREHANDLEROUT, *PREGISTERTEXTUREHANDLEROUT;
  112. typedef struct {
  113. unsigned long dwDevNode;
  114. unsigned long Handle; // Handle returned from IOCTL_REGISTER_TEXTURE_HANDLER
  115. } REMOVETEXTUREHANDLERIN, *PREMOVETEXTUREHANDLERIN;
  116. typedef struct {
  117. unsigned long Unused;
  118. } REMOVETEXTUREHANDLEROUT, *PREMOVETEXTUREHANDLEROUT;
  119. // What is this request for?
  120. #define GLINT_MEMORY_ALLOCATE 1
  121. #define GLINT_MEMORY_FREE 2
  122. typedef struct tagALLOCREQUEST
  123. {
  124. unsigned long dwSize;
  125. unsigned long dwDevNode;
  126. unsigned long dwFlags;
  127. unsigned long dwBytes;
  128. unsigned long ptr16; // in/out
  129. unsigned long ptr32; // in/out
  130. } ALLOCREQUEST, *LPALLOCREQUEST;
  131. #define GLINT_I2C_READ 0
  132. #define GLINT_I2C_WRITE 1
  133. #define GLINT_I2C_RESET 2
  134. #define GLINT_I2C_DEVICE_PRESENT 3
  135. #define GLINT_I2C_DETECT_DATA_LOW 4
  136. #define GLINT_I2C_READ_NOBASEADDR 5
  137. typedef struct tagI2CREQUEST
  138. {
  139. unsigned long dwSize;
  140. unsigned long dwDevNode;
  141. unsigned long dwOperation; // What do we want to do
  142. unsigned short wSlaveAddress; // Slave we are talking to
  143. unsigned char NumItems; // Number of items to send/receive
  144. unsigned char Data[256]; // Data to send/receive
  145. unsigned long dwReserved1; // A reserved DWORD
  146. unsigned long dwReserved2; // A reserved DWORD
  147. unsigned long dwReserved3; // A reserved DWORD
  148. unsigned long dwReserved4; // A reserved DWORD
  149. } I2CREQUEST, *LPI2CREQUEST;
  150. #define GLINT_VMI_READ 0
  151. #define GLINT_VMI_WRITE 1
  152. #define GLINT_VMI_GETMUTEX_A 2
  153. #define GLINT_VMI_RELEASEMUTEX_A 3
  154. typedef struct tagVMIREQUEST
  155. {
  156. unsigned long dwSize;
  157. unsigned long dwDevNode;
  158. unsigned long dwOperation; // What do we want to do
  159. unsigned long dwRegister; // Register to talk to
  160. unsigned long dwCommand; // Command to send
  161. unsigned long dwMutex; // A reserved DWORD
  162. unsigned long dwReserved2; // A reserved DWORD
  163. unsigned long dwReserved3; // A reserved DWORD
  164. unsigned long dwReserved4; // A reserved DWORD
  165. } VMIREQUEST, *LPVMIREQUEST;
  166. #define _UNKNOWN_STREAM_CARD 0
  167. #define _3DLBROOKTREE_DAUGHTER_INRESET 1
  168. #define _3DLBROOKTREE_DAUGHTER 2
  169. #define _3DLRESERVED 3
  170. #define _GENERIC_BROOKTREE868_DAUGHTER_8BITS 4
  171. #define _GENERIC_BROOKTREE868_DAUGHTER_16BITS 5
  172. #define _3DLCHRONTEL_BROOKTREE_DAUGHTER 6
  173. #define _3DLCHRONTEL_SAMSUNG_DAUGHTER 7
  174. #define _GENERIC_CHRONTEL_DAUGHTER_8BITS 8
  175. #define _GENERIC_CHRONTEL_DAUGHTER_16BITS 9
  176. #define GLINT_TVOUT_ENABLED 0
  177. #define GLINT_TVOUT_UPDATE_QUALITY 1
  178. #define GLINT_TVOUT_UPDATE_MODE 2
  179. #define GLINT_TVOUT_UPDATE_POSITION 3
  180. typedef struct tagTVOUTREQUEST
  181. {
  182. unsigned long dwSize;
  183. unsigned long dwDevNode;
  184. unsigned long dwOperation; // What do we want to do
  185. unsigned long dwReturnVal; // Returned value
  186. unsigned long dwSendVal; // A sent value
  187. unsigned long dwReserved1; // A reserved DWORD
  188. unsigned long dwReserved2; // A reserved DWORD
  189. unsigned long dwReserved3; // A reserved DWORD
  190. unsigned long dwReserved4; // A reserved DWORD
  191. } TVOUTREQUEST, *LPTVOUTREQUEST;
  192. // Initialize VFW (turn off DisplayDriver heap, enable DDRAW, etc)
  193. #define GLINT_VFW_INIT 1
  194. // De-Initialize VFW (re-enable DisplayDriver heap, etc)
  195. #define GLINT_VFW_CLOSE 2
  196. // Setup the Streaming capture buffers
  197. // Takes a width and height, returns the stride and locations of the buffers
  198. #define GLINT_VFW_BUFFER_SETUP 3
  199. // Capture the current buffer
  200. // Takes src and dest rects and a bitmap to upload to.
  201. // Returns the time at which it was captured relative to the clock reset
  202. #define GLINT_VFW_BUFFER_CAPTURE 4
  203. // No longer used
  204. #define GLINT_VFW_RESERVED1 5
  205. #define GLINT_VFW_RESERVED2 6
  206. // Starts the streaming capture by initializing interrupts
  207. #define GLINT_VFW_STREAM_START 7
  208. // Stops the streaming capture by stopping interrupts
  209. #define GLINT_VFW_STREAM_STOP 8
  210. // Resets the clock. This is used at the start of the streaming.
  211. // Takes a flag to say wether the clock is timed on PAL or NTSC
  212. #define GLINT_VFW_RESETCLOCK 9
  213. // Gets the current elapsed time
  214. #define GLINT_VFW_GETTIME 10
  215. // Sets up the stretch buffer - this doesn't have to succeed for the capture
  216. // to work. Performance is helped if is does succeed.
  217. #define GLINT_VFW_STRETCHBUFFER_SETUP 11
  218. // Starts and stops the video run (will cause interrupts to be turned on/off)
  219. #define GLINT_VFW_START_VIDEO 12
  220. #define GLINT_VFW_STOP_VIDEO 13
  221. // Gets the IRQ that the VFW driver should use
  222. #define GLINT_VFW_GET_IRQ 14
  223. typedef struct tagVFWREQUEST
  224. {
  225. // Sent values
  226. unsigned long dwSize;
  227. unsigned long dwDevNode;
  228. unsigned long dwOperation; // What do we want to do
  229. // For buffer allocations
  230. unsigned long dwWidth; // Width of the requested buffer
  231. unsigned long dwHeight; // Height of the requested buffer
  232. // For the upload operations
  233. unsigned long dwBitmapWidth; // Width of the bitmap used when uploading
  234. unsigned long fpBuffer; // Buffer to copy into
  235. unsigned long dwSrcLeft; // Source Rect for the operation
  236. unsigned long dwSrcRight;
  237. unsigned long dwSrcTop;
  238. unsigned long dwSrcBottom;
  239. unsigned long dwDestLeft; // Dest Rect for the operation
  240. unsigned long dwDestRight;
  241. unsigned long dwDestTop;
  242. unsigned long dwDestBottom;
  243. unsigned long dwSrcBPP; // Source BPP
  244. unsigned long dwDestBPP; // Destination BPP
  245. unsigned long bSrcYUV; // Source is YUV? No need for dest as VFW only know YVU9
  246. // and we don't do that format
  247. // Various config settings
  248. unsigned long bEurope; // Is this PAL or NTSC?
  249. unsigned long bFilterVideo; // Should we filter the video?
  250. unsigned long bBobVideo; // Should we try to bob on the upload?
  251. // Return values
  252. unsigned long dwStride; // Stride of the setup buffers
  253. unsigned long dwAddress0; // Address of buffer 0
  254. unsigned long dwAddress1; // Address of buffer 0
  255. unsigned long dwAddress2; // Address of buffer 0
  256. unsigned long dwCurrentTime; // The current time in milliseconds (0 based) from the reset of the clock
  257. unsigned long dwIRQ; // The current IRQ to use
  258. unsigned long dwVFWCallback; // Callback function for interrupt
  259. } VFWREQUEST, *LPVFWREQUEST;
  260. // File IO VxD requests
  261. #define GLINT_FIO_OPEN 0
  262. #define GLINT_FIO_READ 1
  263. #define GLINT_FIO_WRITE 2
  264. #define GLINT_FIO_SIZE 3
  265. #define GLINT_FIO_CLOSE 4
  266. typedef struct tagFIOREQUEST
  267. {
  268. unsigned long dwSize;
  269. unsigned long dwDevNode;
  270. unsigned long dwOperation; // What do we want to do
  271. unsigned long dwHandle;
  272. unsigned long dwBuff;
  273. unsigned long dwBuffLen;
  274. unsigned long dwOffset;
  275. } FIOREQUEST, *LPFIOREQUEST;
  276. // P3 Csim requests
  277. #define GLINT_SSD_STARTDMA 0
  278. #define GLINT_SSD_READBACK 1
  279. #define GLINT_SSD_GETOUTPUTDWORDS 2
  280. #define GLINT_SSD_SETOUTPUTFIFO 3
  281. #define GLINT_SSD_SETLOGFILENAME 4
  282. #define GLINT_SSD_WRITETOLOGFILE 5
  283. #define GLINT_SSD_WRITEFIFO 6
  284. #define GLINT_SSD_OPENLOGFILE 7
  285. #define GLINT_SSD_CLOSELOGFILE 8
  286. #define GLINT_SSD_WRITETOLOGFILEMULTIPLE 9
  287. typedef struct tagSIMREQUEST
  288. {
  289. unsigned long dwSize;
  290. unsigned long dwOperation; // What do we want to do
  291. unsigned long dwAddr;
  292. unsigned long dwTagCount;
  293. unsigned long dwData;
  294. } SIMREQUEST, *LPSIMREQUEST;
  295. // Defines for texture semaphore signalling.
  296. // Usage: Semaphore index = ((Logical Address) >> TEXTURE_SEMAPHORE_SHIFT) & TEXTURE_SEMAPHORE_MASK
  297. // Currently 6 bits of semaphore, 14 bits of texture handle
  298. #define MAX_TEXTUREHANDLERS 64
  299. #define TEXTURE_HANDLER_SHIFT 26
  300. #define TEXTURE_HANDLER_MASK 0x3f
  301. typedef struct {
  302. unsigned long ThreadHandle;
  303. unsigned long ThreadEvent;
  304. unsigned long ThreadFlags;
  305. unsigned long ThreadTime;
  306. } TEXTUREHANDLER, *PTEXTUREHANDLER;
  307. #define CONTEXT_GENERIC 0
  308. #define CONTEXT_GLINT300SX 1
  309. #define CONTEXT_GLINT500TX 2
  310. #define CONTEXT_DELTA 3
  311. #define CONTEXT_PERMEDIA 4
  312. #define CONTEXT_GLINTMX 6
  313. #define CONTEXT_PERMEDIA2 7
  314. #define CONTEXT_PERMEDIA3 8
  315. #define CONTEXT_GLINT_FAMILY 0x4000
  316. #define CONTEXT_PERMEDIA_FAMILY 0x4001
  317. #define CONTEXT_GIGI 0x8000
  318. #define CONTEXT_ENDOFBLOCK 0xffff
  319. // Some well known context and template handles.
  320. #define CONTEXT_TEMPLATE_DISPLAY_HANDLE 0
  321. #define CONTEXT_TEMPLATE_DIRECTDRAW_HANDLE 1
  322. #define CONTEXT_TEMPLATE_ALLREADABLE_HANDLE 2
  323. #define CONTEXT_TEMPLATE_DIRECT3D_HANDLE 3
  324. #define CONTEXT_DISPLAY_HANDLE 4
  325. #define CONTEXT_DIRECTX_HANDLE 5
  326. #define CONTEXT_NONE 0xffff
  327. #define P3RX_CONTEXT_MASK 0xfffeffff // Everything except TextureManagement
  328. #define P3_CONTEXTDUMP_SIZE 744 // 744 regisiters for above mask.
  329. // #define P3RX_CONTEXT_MASK 0xffffffff // Everything except TextureManagement
  330. // #define P3_CONTEXTDUMP_SIZE 753 // 744 regisiters for above mask.
  331. #define INVALID_D3D_HANDLE 0
  332. #define MAX_CONTEXTS_IN_BLOCK 32
  333. #define NPAGES_IN_CONTEXT_BLOCK 6
  334. #define SIZE_OF_CONTEXT_BLOCK (NPAGES_IN_CONTEXT_BLOCK * PAGESIZE)
  335. #define SIZE_CONFIGURATIONBASE 32
  336. #define MAX_QUEUE_SIZE (MAX_SUBBUFFERS + 2)
  337. // commands to the interrupt controller on the next VBLANK
  338. typedef enum {
  339. NO_COMMAND = 0,
  340. COLOR_SPACE_BUFFER_0,
  341. COLOR_SPACE_BUFFER_1,
  342. GLINT_RACER_BUFFER_0,
  343. GLINT_RACER_BUFFER_1
  344. } VBLANK_CONTROL_COMMAND;
  345. // interrupt status bits
  346. typedef enum {
  347. DMA_INTERRUPT_AVAILABLE = 0x1, // can use DMA interrupts
  348. VBLANK_INTERRUPT_AVAILABLE = 0x02, // can use VBLANK interrupts
  349. SUSPEND_DMA_TILL_VBLANK = 0x04, // Stop doing DMA till after next VBLANK
  350. } INTERRUPT_CONTROL;
  351. typedef enum {
  352. DIRECTX_LASTOP_UNKNOWN = 0,
  353. DIRECTX_LASTOP_2D,
  354. } DIRECTX_STATE;
  355. // bit definitions for the status words in GlintBoardStatus[]:
  356. // Currently used to indicate sync and DMA status. We have the following rules:
  357. // synced means no outstanding DMA as well as synced. DMA_COMPLETE means n
  358. // outstanding DMA but not necessarily synced. Thus when we do a wait on DMA
  359. // complete we turn off the synced bit.
  360. // XXX for the moment we don't use the synced bit as it's awkward to see where
  361. // to unset it - doing so for every access to the chip is too expensive. We
  362. // probably need a "I'm about to start downloading to the FIFO" macro which
  363. // gets put at the start of any routine which writes to the FIFO.
  364. //
  365. #define GLINT_SYNCED 0x01
  366. #define GLINT_DMA_COMPLETE 0x02 // set when there is no outstanding DMA
  367. #define GLINT_INTR_COMPLETE 0x04
  368. #define GLINT_INTR_CONTEXT 0x08 // set if the current context is interrupt enabled
  369. #define GLINT_2D_CHANGING 0x10 // set if 2D context is modifying pending fields
  370. typedef struct __ContextTable {
  371. unsigned long pNextContext;
  372. unsigned short pNextContext16;
  373. unsigned short nInBlock;
  374. unsigned short nUsed;
  375. unsigned short FirstFree;
  376. unsigned short nFree;
  377. unsigned short COffset[MAX_CONTEXTS_IN_BLOCK];
  378. signed short CSize[MAX_CONTEXTS_IN_BLOCK];
  379. unsigned short CTemplate[MAX_CONTEXTS_IN_BLOCK];
  380. unsigned short CEndIndex[MAX_CONTEXTS_IN_BLOCK];
  381. unsigned short CType[MAX_CONTEXTS_IN_BLOCK];
  382. unsigned short CD3DHandle[MAX_CONTEXTS_IN_BLOCK];
  383. } CONTEXTTABLE, *PCONTEXTTABLE;
  384. // For holding information about a single DMA Buffer
  385. typedef struct tagDMAPartition
  386. {
  387. unsigned long PhysAddr; // Physical ddress of this sub-buffer
  388. #ifndef WIN32
  389. //int pad1;
  390. #endif
  391. ULONG * VirtAddr; // Virtual address of this sub-buffer
  392. #ifndef WIN32
  393. //int pad2;
  394. #endif
  395. ULONG_PTR MaxAddress; // Maximum address of this sub-buffer
  396. #ifndef WIN32
  397. //int pad3;
  398. #endif
  399. unsigned short Locked;
  400. unsigned short bStampedDMA; // Has the VXD Stamped the DMA buffer?
  401. } P3_DMAPartition;
  402. typedef struct _att21505off
  403. {
  404. unsigned char WriteAddr1; // 0000
  405. unsigned char PixelColRam; // 0001
  406. unsigned char PixelRdMask; // 0010
  407. unsigned char ReadAdd1; // 0011
  408. unsigned char WriteAddr2; // 0100
  409. unsigned char CursorColRam; // 0101
  410. unsigned char Ctrl0; // 0110
  411. unsigned char ReadAdd2; // 0111
  412. unsigned char Ctrl1; // 1000
  413. unsigned char Ctrl2; // 1001
  414. unsigned char Status; // 1010
  415. unsigned char CursorPattern; // 1011
  416. unsigned char CursorXLow; // 1100
  417. unsigned char CursorXHigh; // 1101
  418. unsigned char CursorYLow; // 1110
  419. unsigned char CursorYHigh; // 1111
  420. } ATT21505OFF;
  421. typedef struct _DMAQueue
  422. {
  423. unsigned long dwContext; // context for fragment
  424. unsigned long dwSize; // size of it (DWORDs)
  425. unsigned long dwPhys; // physical address
  426. unsigned long dwEvent; // event if required
  427. } DMAQUEUE;
  428. typedef struct _ContextRegs
  429. {
  430. unsigned short wNumRegs;
  431. unsigned short wFirstReg[1];
  432. } CONTEXTREGS;
  433. typedef struct _VDDDISPLAYINFO {
  434. unsigned short ddiHdrSize;
  435. unsigned short ddiInfoFlags;
  436. unsigned long ddiDevNodeHandle;
  437. unsigned char ddiDriverName[16];
  438. unsigned short ddiXRes;
  439. unsigned short ddiYRes;
  440. unsigned short ddiDPI;
  441. unsigned char ddiPlanes;
  442. unsigned char ddiBpp;
  443. unsigned short ddiRefreshRateMax;
  444. unsigned short ddiRefreshRateMin;
  445. unsigned short ddiLowHorz;
  446. unsigned short ddiHighHorz;
  447. unsigned short ddiLowVert;
  448. unsigned short ddiHighVert;
  449. unsigned long ddiMonitorDevNodeHandle;
  450. unsigned char ddiHorzSyncPolarity;
  451. unsigned char ddiVertSyncPolarity;
  452. //
  453. // new 4.1 stuff
  454. //
  455. unsigned long diUnitNumber; // device unit number
  456. unsigned long diDisplayFlags; // mode specific flags
  457. unsigned long diXDesktopPos; // position of desktop
  458. unsigned long diYDesktopPos; // ...
  459. unsigned long diXDesktopSize; // size of desktop (for panning)
  460. unsigned long diYDesktopSize; // ...
  461. } VDDDISPLAYINFO;
  462. typedef struct _GlintInfo
  463. {
  464. #ifndef WNT_DDRAW
  465. unsigned long dwDevNode; // The VXD's DevNode
  466. // Pointers
  467. unsigned long dwDSBase; // 32 bit base of data seg
  468. unsigned long dwpRegisters;
  469. unsigned long dwpFrameBuffer;
  470. unsigned long dwpLocalBuffer;
  471. // Chip Information
  472. unsigned long dwRamDacType;
  473. #endif // WNT_DDRAW
  474. volatile unsigned long dwFlags;
  475. unsigned long ddFBSize; // frame buffer size
  476. unsigned long dwScreenBase; // Screen base value for the screen
  477. unsigned long dwOffscreenBase; // Start of Offscreen heap
  478. // TV Out support
  479. unsigned long bTVEnabled;
  480. unsigned long bTVPresent;
  481. unsigned long dwStreamCardType;
  482. unsigned long dwVSBLastAddressIndex;
  483. unsigned long dwBaseOffset;
  484. unsigned long dwMacroVision;
  485. // Driver information
  486. #ifndef WNT_DDRAW
  487. unsigned long dwVideoMemorySize;
  488. #endif // WNT_DDRAW
  489. unsigned long dwScreenWidth;
  490. unsigned long dwScreenHeight;
  491. unsigned long dwVideoWidth;
  492. unsigned long dwVideoHeight;
  493. unsigned long dwBpp;
  494. unsigned long dwScreenWidthBytes;
  495. unsigned char bPixelToBytesShift;
  496. #ifdef W95_DDRAW
  497. unsigned char bPad1[3];
  498. #endif
  499. ULONG_PTR pRegs;
  500. unsigned long PixelClockFrequency;
  501. unsigned long MClkFrequency;
  502. // Chip information. This should be filled out as much as
  503. // possible. We may not know all the information though.
  504. unsigned long dwRenderChipID;
  505. unsigned long dwRenderChipRev;
  506. unsigned long dwRenderFamily;
  507. unsigned long dwGammaRev;
  508. unsigned long dwTLChipID;
  509. unsigned long dwTLFamily;
  510. #ifndef WNT_DDRAW
  511. unsigned long dwSupportChipID;
  512. unsigned long dwSupportChipRev;
  513. unsigned long dwBoardID;
  514. unsigned long dwBoardRev;
  515. #endif // WNT_DDRAW
  516. unsigned short DisabledByGLDD;
  517. #ifdef W95_DDRAW
  518. unsigned short wPad2;
  519. #endif
  520. unsigned long bDXDriverEnabled;
  521. unsigned long bDRAMBoard;
  522. // DirectDraw and Direct3D DMA state
  523. unsigned long InterfaceType;
  524. unsigned long CurrentPartition;
  525. unsigned long NumberOfSubBuffers;
  526. P3_DMAPartition DMAPartition[MAX_SUBBUFFERS];
  527. ULONG * volatile CurrentBuffer; // Current BufferPointer
  528. ULONG_PTR dwDirectXState;
  529. unsigned long dwDMAFlushCount;
  530. // DMA information
  531. unsigned long dw3DDMABufferSize; // size of dma buffer
  532. unsigned long dw3DDMABufferPhys; // physical addresses of buffer
  533. ULONG_PTR dw3DDMABufferVirt; // virtual ring 0 address
  534. // index offsets into the queue for the front, back and end. Using separate
  535. // front and back offsets allows the display driver to add and the interrupt
  536. // controller to remove entries without a need for locking code.
  537. volatile unsigned long frontIndex;
  538. volatile unsigned long backIndex;
  539. unsigned long endIndex;
  540. unsigned long maximumIndex;
  541. // Debugging info. Spots possible memory leaks.
  542. unsigned long iSurfaceInfoBlocksAllocated;
  543. #ifndef WNT_DDRAW
  544. unsigned long dwVideoControl;
  545. unsigned long dwDeviceHandle;
  546. char szDeviceName[16];
  547. unsigned long dwCurrentContext;
  548. unsigned long GlintBoardStatus;
  549. //
  550. // Some overlay related variable which should be shared with mini port
  551. //
  552. volatile ULONG bOverlayEnabled; // TRUE if the overlay is on at all
  553. volatile ULONG bVBLANKUpdateOverlay; // TRUE if the overlay needs to be updated by the VBLANK routine.
  554. volatile ULONG VBLANKUpdateOverlayWidth; // overlay width (updated in vblank)
  555. volatile ULONG VBLANKUpdateOverlayHeight; // overlay height (updated in vblank)
  556. #endif // WNT_DDRAW
  557. } GlintInfo, *LPGLINTINFO;
  558. // Config register
  559. #define PM_CHIPCONFIG_AGPSIDEBAND (1 << 8)
  560. #define PM_CHIPCONFIG_AGP1XCAPABLE (1 << 9)
  561. #define PM_CHIPCONFIG_AGP2XCAPABLE (1 << 10)
  562. #define PM_CHIPCONFIG_AGP4XCAPABLE (1 << 11)
  563. // Gamma config
  564. #define G1_CHIPCONFIG_AGPSIDEBAND (1 << 1)
  565. #define G1_CHIPCONFIG_AGP1XCAPABLE (1 << 0)
  566. // DAC types
  567. #define RamDacRGB525 1 // value for RGB525
  568. #define RamDacATT 2 // value for AT&T 21505
  569. #define RamDacTVP3026 3 // TI TVP 3026 (Accel board)
  570. // Board types
  571. #define BID_MONTSERRAT 0
  572. #define BID_RACER 1
  573. #define BID_ACCEL 2
  574. // definitions for dwFlags
  575. // Glint Interrupt Control Bits
  576. //
  577. // InterruptEnable register
  578. #define INTR_DISABLE_ALL 0x00
  579. #define INTR_ENABLE_DMA 0x01
  580. #define INTR_ENABLE_SYNC 0x02
  581. #define INTR_ENABLE_EXTERNAL 0x04
  582. #define INTR_ENABLE_ERROR 0x08
  583. #define INTR_ENABLE_VBLANK 0x10
  584. #define INTR_ENABLE_SCANLINE 0x20
  585. #define INTR_TEXTURE_DOWNLOAD 0x40
  586. #define INTR_ENABLE_BYDMA 0x80
  587. #define INTR_ENABLE_VIDSTREAM_B 0x100
  588. #define INTR_ENABLE_VIDSTREAM_A 0x200
  589. // InterruptFlags register
  590. #define INTR_DMA_SET 0x01
  591. #define INTR_SYNC_SET 0x02
  592. #define INTR_EXTERNAL_SET 0x04
  593. #define INTR_ERROR_SET 0x08
  594. #define INTR_VBLANK_SET 0x10
  595. #define INTR_SCANLINE_SET 0x20
  596. #define INTR_BYDMA_SET 0x80
  597. #define INTR_VIDSTREAM_B_SET 0x100
  598. #define INTR_VIDSTREAM_A_SET 0x200
  599. #define INTR_CLEAR_ALL 0x1f
  600. #define INTR_CLEAR_DMA 0x01
  601. #define INTR_CLEAR_SYNC 0x02
  602. #define INTR_CLEAR_EXTERNAL 0x04
  603. #define INTR_CLEAR_ERROR 0x08
  604. #define INTR_CLEAR_VBLANK 0x10
  605. #define INTR_CLEAR_SCANLINE 0x20
  606. #define INTR_CLEAR_BYDMA 0x80
  607. #define INTR_CLEAR_VIDSTREAM_B 0x100
  608. #define INTR_CLEAR_VIDSTREAM_A 0x200
  609. #define GMVF_REV2 0x00000001 // chip is rev 2
  610. #define GMVF_FFON 0x00000002 // fast fill enabled
  611. #define GMVF_NOIRQ 0x00000004 // IRQ disabled
  612. #define GMVF_SETUP 0x00000008 // primitive setup in progress
  613. #define GMVF_GCOP 0x00000010 // something is using 4K area (affects mouse)
  614. #define GMVF_DMAIP 0x00000020 // DMA started
  615. #define GMVF_565 0x00000080 // Run in 565 mode
  616. #define GMVF_DELTA 0x00000100 // using delta
  617. #define GMVF_8BPPRGB 0x00000200 // use 322 RGB at 8bpp
  618. #define GMVF_DISABLE_OVERLAY 0x00000400 // Disable overlay on P4
  619. #define GMVF_SWCURSOR 0x00000800 // Never use a hardware cursor
  620. #define GMVF_INTCPTGDI 0x00001000 // Intercept GDI mode
  621. #define GMVF_OFFSCRNBM 0x00002000 // Offscreen BitMaps mode
  622. #define GMVF_HWWRITEMASK 0x00004000 // Offscreen BitMaps mode
  623. #define GMVF_ALLOWP2VLUT 0x00008000 // Driver says P2V LUTs will work
  624. #define GMVF_VBLANK_OCCURED 0x00010000 // VBlank has occured
  625. #define GMVF_VBLANK_ENABLED 0x00020000 // VBlank interrupt is enabled
  626. #define GMVF_VSA_INTERRUPT_OCCURED 0x00040000 // VPort interrupt has occured
  627. #define GMVF_FRAME_BUFFER_IS_WC 0x00080000 // Frame buffer is write-combined
  628. #define GMVF_CAN_USE_AGP_DMA 0x00100000 // DMA buffers allocated with WC
  629. #define GMVF_32BIT_SPANS_ALIGNED 0x00200000 // Must align 32bpp spans.
  630. #define GMVF_DFP_DISPLAY 0x00400000 // DFP is connected
  631. #define GMVF_QDMA 0x00800000 // 2D using QDMA system
  632. #define GMVF_GAMMA 0x01000000 // using gamma chip
  633. #define GMVF_NODMA 0x02000000 // DMA disabled
  634. #define GMVF_COLORTRANSLATE 0x04000000 // Set if Chip can translate colors
  635. #define GMVF_MMX_AVAILABLE 0x08000000 // Set if processor has MMX
  636. #define GMVF_EXPORT24BPP 0x10000000 // Set if we should export 24bpp modes
  637. #define GMVF_DONOTRESET 0x20000000
  638. #define GMVF_TRYTOVIRTUALISE4PLANEVGA 0x40000000 // Set if we should try to virtualise 4 plane VGA
  639. #define GMVF_VIRTUALISE4PLANEVGA 0x80000000 // Set if we are virtualising 4 plane VGA modes.
  640. // Cap for the maximum FIFO entries read back on a P3/R3 chip
  641. #define MAX_P3_FIFO_ENTRIES 120
  642. #ifndef MINIVDD
  643. extern unsigned long CreateContext(struct tagThunkedData* pThisDisplay,
  644. LPGLINTINFO, unsigned long, unsigned short, unsigned short );
  645. extern void _cdecl ChangeContext(struct tagThunkedData* pThisDisplay, LPGLINTINFO, unsigned long);
  646. extern void DeleteContext(struct tagThunkedData* pThisDisplay, LPGLINTINFO, unsigned long);
  647. extern void _cdecl SetEndIndex(LPGLINTINFO, unsigned long, unsigned short);
  648. extern void StartDMAProper( struct tagThunkedData*, LPGLINTINFO, unsigned long, unsigned long, unsigned long );
  649. #endif
  650. #define MINIVDD_REGISTERDISPLAYDRIVER_BASE 0x1000
  651. // Definitions for RegisterDisplayDriver options
  652. #define MINIVDD_SHAREGLINFO MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x00
  653. #define MINIVDD_INITIALISEMODE MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x01
  654. #define MINIVDD_GETGLINFO MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x02
  655. #define MINIVDD_ALLOCATEMEMORY MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x10
  656. #define MINIVDD_FREEMEMORY MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x11
  657. #define MINIVDD_GETREGISTRYKEY MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x20
  658. // For free and allocating memory and selectors for use on the
  659. // 16 bit side.
  660. #define MINIVDD_MEMORYREQUEST MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x30
  661. // For sending I2C data across the bus
  662. #define MINIVDD_I2CREQUEST MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x40
  663. // For sending VMI data to the VideoPort
  664. #define MINIVDD_VMIREQUEST MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x41
  665. // For talking to the video demon
  666. #define MINIVDD_DEMONREQUEST MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x42
  667. // For sending Video For Windows commands
  668. #define MINIVDD_VFWREQUEST MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x43
  669. // For Multi-monitor support
  670. #define MINIVDD_ENABLEINTERRUPTS MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x50
  671. #define MINIVDD_DISABLEINTERRUPTS MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x51
  672. #define MINIVDD_TVOUTREQUEST MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x60
  673. //#ifdef P3_CSIMULATOR
  674. #define MINIVDD_SENDDMABUFFER MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x100
  675. #define MINIVDD_SETDMABUFFEROUT MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x101
  676. #define MINIVDD_GETOUTDMACOUNT MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x102
  677. #define MINIVDD_SETTESTNAME MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x103
  678. #define MINIVDD_WRITETAGDATATOFIFO MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x104
  679. #define MINIVDD_READBACKDMAADDR MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x105
  680. #define MINIVDD_SETDMAADDR MINIVDD_REGISTERDISPLAYDRIVER_BASE+0x106
  681. //#endif
  682. #define REG_HKLM_PREFIX 0x01
  683. #define REG_HKU_PREFIX 0x02
  684. #define REG_HKCU_PREFIX 0x03
  685. #define REG_HKCR_PREFIX 0x04
  686. #define REG_HKCC_PREFIX 0x05
  687. #define REG_HKDD_PREFIX 0x06
  688. #define REG_DEVNODEDEFAULTPREFIX 0x07
  689. #define REG_DEVNODEPREFIX 0x08
  690. #define REGTYPE_STRING 0x100
  691. #define REGTYPE_BINARY 0x300
  692. #define REGTYPE_DWORD 0x400
  693. // Defines for the offsets of regions within the Data Segment:
  694. #define DATA_SEGMENT_OFFSET 0x0
  695. #define GLINT_REGISTERS_OFFSET 0x10000
  696. #define DMA_UPLOAD_2D 0x30000
  697. #define DMA_BUFFER_3D 0x38000
  698. #define FONT_CACHE_OFFSET 0x180000
  699. #define FINAL_DATA_SEGMENT_SIZE 0x280000
  700. // Defines the maximum size of the regions
  701. #define DATA_SEGMENT_SIZE GLINT_REGISTERS_OFFSET - DATA_SEGMENT_OFFSET
  702. #define GLINT_REGISTERS_SIZE DMA_UPLOAD_2D - GLINT_REGISTERS_OFFSET
  703. #define DMA_UPLOAD_2D_SIZE DMA_BUFFER_3D - DMA_UPLOAD_2D
  704. #define DMA_BUFFER_3D_SIZE FONT_CACHE_OFFSET - DMA_BUFFER_3D
  705. #define FONT_CACHE_SIZE FINAL_DATA_SEGMENT_SIZE - FONT_CACHE_OFFSET
  706. // How much will we allow for 2D when it's using the 3D DMA buffer? And
  707. // how much can we send in one DMA? Increasing this gives a small
  708. // performance improvement on a P2.
  709. #define MAX_2D_DMA_USE DMA_BUFFER_3D_SIZE
  710. #define MAX_DMA_COUNT 0xffff
  711. #define MIN_2D_DMA_BUFFER_SIZE 0x10000
  712. #define MAX_2D_DMA_BUFFER_SIZE 0x60000
  713. // Various independant things that can disable the offscreen bitmap heap.
  714. #define D3D_DISABLED 1
  715. #define DRIVER_DISABLED 2