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.

2519 lines
97 KiB

  1. /******************************Module*Header**********************************\
  2. *
  3. * *******************
  4. * * GDI SAMPLE CODE *
  5. * *******************
  6. *
  7. * Module Name: glint.h
  8. *
  9. * Content: Defines and macros for interfacing to the GLINT hardware.
  10. *
  11. * Copyright (c) 1994-1999 3Dlabs Inc. Ltd. All rights reserved.
  12. * Copyright (c) 1995-2003 Microsoft Corporation. All rights reserved.
  13. \*****************************************************************************/
  14. #ifndef _GLINT_H_
  15. #define _GLINT_H_
  16. #include <gtag.h>
  17. //#include "glintmsg.h"
  18. #include <glintdef.h>
  19. // USE_SYNC_FUNCTION must be set at the moment for error free builds. The macro
  20. // version requires #including <pxrx.h> which would make re-builds a nightmare.
  21. // On more important issues, there is nomeasurable loss of speed but the driver
  22. // is a fair bit smaller.
  23. #define USE_SYNC_FUNCTION 1
  24. // when enabled, most of the DDI entrypoints in THUNK.C check whether the base viewable scanline
  25. // variables in DEBUG4.C have been modified, allowing the scanline view to be updated
  26. #define SET_VIEW_MEMORY_ENABLED 0
  27. #if DBG && SET_VIEW_MEMORY_ENABLED
  28. extern void DebugCheckMemoryView(PPDEV ppdev);
  29. #define CHECK_MEMORY_VIEW(ppdev)
  30. #else
  31. #define CHECK_MEMORY_VIEW(ppdev)
  32. #endif
  33. #define COLLECT_TEXT_STATS 0
  34. #if COLLECT_TEXT_STATS
  35. struct TextStats
  36. {
  37. ULONG aGlyphWidthBytesCached[9]; // [0] = 1 byte, [1] = 2 bytes, ... [7] = 8 bytes, [8] > 8 bytes
  38. ULONG cCacheableStrings;
  39. ULONG cUncacheableStrings;
  40. ULONG cGlyphsCached;
  41. ULONG cGlyphTotalBytesCached;
  42. ULONG meanGlyphBytesCached;
  43. ULONG cProportionalGlyphs;
  44. ULONG cProportionalStrings;
  45. ULONG meanProportionalGlyphsPerString;
  46. ULONG cFixedGlyphs;
  47. ULONG cFixedStrings;
  48. ULONG meanFixedGlyphsPerString;
  49. ULONG cClippedGlyphs;
  50. ULONG cClippedStrings;
  51. ULONG meanClippedGlyphsPerString;
  52. ULONG cAllocedFonts;
  53. ULONG cFreedFonts;
  54. ULONG cBlownCaches;
  55. };
  56. extern struct TextStats gts;
  57. #define STAT_CACHEABLE_STRING ++gts.cCacheableStrings
  58. #define STAT_UNCACHEABLE_STRING ++gts.cUncacheableStrings
  59. #define STAT_CACHING_GLYPH(cxGlyphAligned, cyGlyph) \
  60. do \
  61. { \
  62. ++gts.cGlyphsCached; \
  63. gts.cGlyphTotalBytesCached += (cxGlyphAligned >> 3) * cyGlyph; \
  64. gts.meanGlyphBytesCached = gts.cGlyphTotalBytesCached / gts.cGlyphsCached; \
  65. ++gts.aGlyphWidthBytesCached[(cxGlyphAligned >> 3) > 8 ? 8 : (cxGlyphAligned >> 3) - 1]; \
  66. } \
  67. while(0)
  68. #define STAT_PROPORTIONAL_TEXT(cGlyph) \
  69. do \
  70. { \
  71. gts.cProportionalGlyphs += cGlyph; \
  72. ++gts.cProportionalStrings; \
  73. gts.meanProportionalGlyphsPerString = gts.cProportionalGlyphs / gts.cProportionalStrings; \
  74. } \
  75. while(0)
  76. #define STAT_FIXED_TEXT(cGlyph) \
  77. do \
  78. { \
  79. gts.cFixedGlyphs += cGlyph; \
  80. ++gts.cFixedStrings; \
  81. gts.meanFixedGlyphsPerString = gts.cFixedGlyphs / gts.cFixedStrings; \
  82. } \
  83. while(0)
  84. #define STAT_CLIPPED_TEXT(cGlyph) \
  85. do \
  86. { \
  87. gts.cClippedGlyphs += cGlyph; \
  88. ++gts.cClippedStrings; \
  89. gts.meanClippedGlyphsPerString = gts.cClippedGlyphs / gts.cClippedStrings; \
  90. } \
  91. while(0)
  92. #define STAT_ALLOC_FONT ++gts.cAllocedFonts
  93. #define STAT_FREE_FONT ++gts.cFreedFonts
  94. #define STAT_BLOW_CACHE ++gts.cBlownCaches
  95. #else
  96. #define STAT_CACHEABLE_STRING
  97. #define STAT_UNCACHEABLE_STRING
  98. #define STAT_CACHING_GLYPH(cxGlyphAligned, cyGlyph)
  99. #define STAT_PROPORTIONAL_TEXT(cGlyph)
  100. #define STAT_FIXED_TEXT(cGlyph)
  101. #define STAT_CLIPPED_TEXT(cGlyph)
  102. #define STAT_ALLOC_FONT
  103. #define STAT_FREE_FONT
  104. #define STAT_BLOW_CACHE
  105. #endif
  106. #define DMA_DRIVEN_2D 0
  107. #define GLINT_LOCKUP_TIMEOUT 0
  108. #define GAMMA_CORRECTION 1
  109. #define COLORIFIC_GAMMA_CORRECTION 1
  110. /*
  111. * USE_PCI_DISC_PERM
  112. * -----------------
  113. *
  114. * Set USE_PCI_DISC_PERM to 1 for PCI disconnect on permanently or set to 0 for
  115. * disconnect off permanently. ( Set to 1 to try and speed things up , set to 0
  116. * on Alphas which are sensitive ).
  117. */
  118. #if defined(_X86_)
  119. #define USE_PCI_DISC_PERM 1
  120. #else // _X86_
  121. #define USE_PCI_DISC_PERM 0
  122. #endif // _X86_
  123. // DMA text rendering gives me a 1 winmark improvement on my P6 200 at 8 & 15bpp, but gives
  124. // no improvement at these depths on a Pentium II 300 and might actually be 1 winmark slower
  125. // at 32bpp
  126. #define ENABLE_DMA_TEXT_RENDERING 0
  127. /********************************************************************************/
  128. // Texture memory allocation macros and structures are in 3DPrivTx.h
  129. // definition of handle to a memory region
  130. typedef LONG HMEMREGION;
  131. typedef LONG HMEMCACHE;
  132. typedef enum {RESIDENCY_NOTLOADED, RESIDENCY_PERMANENT, RESIDENCY_TRANSIENT, RESIDENCY_HOST, RESIDENCY_PERMANENT2} MEM_MGR_RESIDENCY;
  133. /********************************************************************************/
  134. /*** DrvEscape commands ***/
  135. #define GLINT_SET_SCANLINE 6000 // Temporary define for setting the displayed scanline (Permedia specific)
  136. #define GLINT_GET_RAMDAC_LUT 6001 // Temporary define for getting the RAMDACs LUT
  137. #define GLINT_SET_RAMDAC_LUT 6002 // Temporary define for getting the RAMDACs LUT
  138. #define GLINT_SET_SAME_VIDEO_MODE 6003 // Temporary define for getting the RAMDACs LUT
  139. // Monitor DDC support:
  140. #define GLINT_QUERY_MONITOR_INFO 6004
  141. #define GLINT_MULTIMON_CMD 6007
  142. #define GLINT_GET_SOFT_ENGINE_INFO 6009
  143. // Debug only escapes:
  144. #define GLINT_DBG_GET_FRAMEBUFFER 6008
  145. #define GLINT_DBG_TEST_PXRX_DMA 6010
  146. /*** DrvDrawEscape commands ***/
  147. #define GLINT_DBG_SEND_TAGS 10238
  148. #define GLINT_DBG_SET_DEBUG 10239
  149. //
  150. // various GLINT devices and revisions
  151. //
  152. #define VENDOR_ID_3DLABS 0x3D3D
  153. #define VENDOR_ID_TI 0x104C
  154. #define GLINT_300SX_ID 0x0001
  155. #define GLINT_500TX_ID 0x0002
  156. #define GLINT_DELTA_ID 0x0003
  157. #define PERMEDIA_ID 0x0004
  158. #define PERMEDIA_P1_ID 0x3D04
  159. #define GLINT_MX_ID 0x0006
  160. #define PERMEDIA2_ID 0x0007 // 3Dlabs Permedia 2
  161. #define PERMEDIA_P2_ID 0x3D07 // TI Permedia 2
  162. #define GLINT_GAMMA_ID 0x0008
  163. #define PERMEDIA_P2S_ID 0x0009 // 3Dlabs Permedia 2ST
  164. #define PERMEDIA3_ID 0x000A
  165. #define GLINT_R3_ID 0x000B
  166. #define PERMEDIA4_ID 0x000C
  167. #define GLINT_R4_ID 0x000D
  168. #define DEVICE_FAMILY_ID(id) ((id) & 0xff)
  169. #define GLINT_DEVICE_SX GLINT_300SX_ID
  170. #define GLINT_DEVICE_TX GLINT_500TX_ID
  171. #define GLINT_DEVICE_MX GLINT_MX_ID
  172. #define GLINT_DEVICE_FX PERMEDIA_ID
  173. #define GLINT_DEVICE_P2 PERMEDIA2_ID
  174. #define GLINT_DEVICE_P2S PERMEDIA_P2S_ID
  175. #define GLINT_DEVICE_P3 PERMEDIA3_ID
  176. #define GLINT_DEVICE_P4 PERMEDIA4_ID
  177. #define GLINT_DEVICE_R3 GLINT_R3_ID
  178. #define GLINT_DEVICE_R4 GLINT_R4_ID
  179. #define GLINT_300SX_REV_1 0x0000
  180. #define GLINT_300SX_REV_2 0x0002
  181. #define GLINT_500TX_REV_1 0x0001
  182. #define GLINT_DELTA_REV_1 0x0001
  183. #define GLINT_PERMEDIA_REV_1 0x0001
  184. #define GLINT_REVISION_SX_1 GLINT_300SX_REV_1
  185. #define GLINT_REVISION_SX_2 GLINT_300SX_REV_2
  186. #define GLINT_REVISION_TX_1 GLINT_500TX_REV_1
  187. #define GLINT_REVISION_1 GLINT_REVISION_SX_1
  188. #define GLINT_REVISION_2 GLINT_REVISION_SX_2
  189. //
  190. // Supported board definitions. Must be the same as in the miniport
  191. //
  192. typedef enum _GLINT_BOARDS {
  193. GLINT_MONTSERRAT = 0,
  194. GLINT_RACER,
  195. DENSAN_300SX,
  196. ACCELR8_BOARD,
  197. ACCELPRO_BOARD,
  198. OMNICOMP_SX88,
  199. PERMEDIA_BOARD,
  200. PERMEDIA_NT_BOARD,
  201. PERMEDIA_LC_BOARD,
  202. DUALTX_MENTOR_BOARD,
  203. DUALTX_SYMMETRIC_BOARD,
  204. ELSA_GLORIA,
  205. PERMEDIA2_BOARD,
  206. OMNICOMP_3DEMONPRO,
  207. GEO_TWIN_BOARD,
  208. GLINT_RACER_PRO,
  209. ELSA_GLORIA_XL,
  210. PERMEDIA3_BOARD,
  211. MAX_GLINT_BOARD
  212. } GLINT_BOARDS;
  213. //
  214. // Supported RAMDAC definitions. Must be the same as in the miniport
  215. //
  216. typedef enum _GLINT_RAMDACS {
  217. RGB525_RAMDAC = 0,
  218. RGB526_RAMDAC,
  219. RGB526DB_RAMDAC,
  220. RGB528_RAMDAC,
  221. RGB528A_RAMDAC,
  222. RGB624_RAMDAC,
  223. RGB624DB_RAMDAC,
  224. RGB640_RAMDAC,
  225. TVP3026_RAMDAC,
  226. TVP3030_RAMDAC,
  227. RGB524_RAMDAC,
  228. RGB524A_RAMDAC,
  229. TVP4020_RAMDAC,
  230. P2RD_RAMDAC,
  231. P3RD_RAMDAC,
  232. MAX_GLINT_RAMDAC
  233. } GLINT_RAMDACS;
  234. // extern declarations
  235. extern DWORD GlintLogicOpsFromR2[]; // translates GDI rop2 to GLINT logic op mode word
  236. extern DWORD LogicopReadDest[]; // indicates which logic ops need dest read turned on
  237. // values for flags in GlintDataRec
  238. //
  239. typedef enum {
  240. GLICAP_NT_CONFORMANT_LINES = 0x00000001, // draw NT conformant lines
  241. GLICAP_HW_WRITE_MASK = 0x00000002, // hardware planemasking
  242. GLICAP_COLOR_SPACE_DBL_BUF = 0x00000004, // interleaved nibbles
  243. GLICAP_BITBLT_DBL_BUF = 0x00000008, // dbl buf by bitblt
  244. GLICAP_FULL_SCREEN_DBL_BUF = 0x00000010, // hardware can dbl buf
  245. GLICAP_FIX_FAST_FILLS = 0x00000020, // workaround fast fill bug
  246. GLICAP_INTERRUPT_DMA = 0x00000080, // interrupt driven DMA
  247. GLICAP_RACER_BANK_SELECT = 0x00000100, // FS dbl buf uses Racer h/w
  248. GLICAP_FIX_4MB_FAST_FILLS = 0x00000200, // fix blk fill above 4MB
  249. GLICAP_RACER_DOUBLE_WRITE = 0x00000400, // Can double write
  250. GLICAP_ENHANCED_TX_BANK_SELECT = 0x00000800, // Enhanced TX FS dbl buf
  251. GLICAP_HW_WRITE_MASK_BYTES = 0x00001000, // hardware planemasking is bytewise only
  252. GLICAP_STEREO_BUFFERS = 0x00002000, // stereo buffers allocated
  253. } GLINT_CAPS;
  254. //@@BEGIN_DDKSPLIT
  255. // TMM: In the good old days we used to leave the screen scissor enabled
  256. // as a safety-net, however, the screen scissor doesn't work when uploading
  257. // data at 1280 or 1170 screen widths, so I've disabled it.
  258. //@@END_DDKSPLIT
  259. #define SCREEN_SCISSOR_DEFAULT (0 << 1)
  260. // Currently we support the main display and up to 3 off-screen buffers.
  261. //
  262. #define GLINT_NUM_SCREEN_BUFFERS 4
  263. // currently we support software cursors up to this width and height. This is
  264. // to ensure that we have enough off-screen memory to save the shapes and save
  265. // unders.
  266. //
  267. #define SOFTWARE_POINTER_SIZE 32
  268. // this structure contains the addresses of all the GLINT registers that we
  269. // want to write to. It is used by any macro/functions which needs to talk to
  270. // the GLINT chip. We precompute these addresses so that we get faster access
  271. // on DEC Alpha machines.
  272. //
  273. typedef struct _glint_reg_addrs {
  274. // Most commonly used non-FIFO registers
  275. ULONG * InFIFOSpace;
  276. ULONG * OutFIFOWords;
  277. ULONG * OutFIFOWordsOdd;
  278. ULONG * DMAControl;
  279. ULONG * OutDMAAddress; // P2 only
  280. ULONG * OutDMACount; // P2 only
  281. ULONG * ByDMAAddress; // P2 only
  282. ULONG * ByDMAStride; // P2 only
  283. ULONG * ByDMAMemAddr; // P2 only
  284. ULONG * ByDMASize; // P2 only
  285. ULONG * ByDMAByteMask; // P2 only
  286. ULONG * ByDMAControl; // P2 only
  287. ULONG * ByDMAComplete; // P2 only
  288. ULONG * DMAAddress;
  289. ULONG * DMACount;
  290. ULONG * InFIFOInterface;
  291. ULONG * OutFIFOInterface;
  292. ULONG * OutFIFOInterfaceOdd;
  293. ULONG * FBModeSel;
  294. ULONG * FBModeSelOdd;
  295. ULONG * IntFlags;
  296. ULONG * DeltaIntFlags;
  297. // PERMEDIA
  298. ULONG * ScreenBase;
  299. ULONG * ScreenBaseRight;
  300. ULONG * LineCount;
  301. ULONG * VbEnd;
  302. ULONG * VideoControl;
  303. ULONG * MemControl;
  304. // GAMMA
  305. ULONG * GammaChipConfig;
  306. ULONG * GammaCommandMode;
  307. ULONG * GammaCommandIntEnable;
  308. ULONG * GammaCommandIntFlags;
  309. ULONG * GammaCommandErrorFlags;
  310. ULONG * GammaCommandStatus;
  311. ULONG * GammaFeedbackSelectCount;
  312. ULONG * GammaProcessorMode;
  313. ULONG * GammaMultiGLINTAperture;
  314. // Core FIFO registers
  315. ULONG * tagwr[__MaximumGlintTagValue+1];
  316. ULONG * tagrd[__MaximumGlintTagValue+1];
  317. // Other control registers
  318. ULONG * VTGHLimit;
  319. ULONG * VTGHSyncStart;
  320. ULONG * VTGHSyncEnd;
  321. ULONG * VTGHBlankEnd;
  322. ULONG * VTGHGateStart;
  323. ULONG * VTGHGateEnd;
  324. ULONG * VTGVLimit;
  325. ULONG * VTGVSyncStart;
  326. ULONG * VTGVSyncEnd;
  327. ULONG * VTGVBlankEnd;
  328. ULONG * VTGVGateStart;
  329. ULONG * VTGVGateEnd;
  330. ULONG * VTGPolarity;
  331. ULONG * VTGVLineNumber;
  332. ULONG * VTGFrameRowAddr;
  333. ULONG * VTGFrameRowAddrOdd;
  334. ULONG * LBMemoryCtl;
  335. ULONG * LBMemoryEDO;
  336. ULONG * FBMemoryCtl;
  337. ULONG * IntEnable;
  338. ULONG * DeltaIntEnable;
  339. ULONG * ResetStatus;
  340. ULONG * DisconnectControl;
  341. ULONG * ErrorFlags;
  342. ULONG * DeltaErrorFlags;
  343. ULONG * VTGSerialClk;
  344. ULONG * VTGSerialClkOdd;
  345. ULONG * VClkCtl;
  346. // Racer board has these extra registers external to GLINT
  347. ULONG * RacerDoubleWrite;
  348. ULONG * RacerBankSelect;
  349. ULONG * VSConfiguration; // P2 only
  350. // Omnicomp 3demonPro16 board has these extra registers external to GLINT
  351. ULONG * DemonProDWAndStatus; // Pro 5000
  352. ULONG * DemonProUBufB; // Pro 7000
  353. // split framebuffer needs scanline ownership, FBWindowBase and LBWindowBase
  354. // to be context switched.
  355. ULONG * OddGlintScanlineOwnRd;
  356. ULONG * OddGlintFBWindowBaseRd;
  357. ULONG * OddGlintLBWindowBaseRd;
  358. // Dual-TX needs area stipple to be different on both chips
  359. ULONG * OddTXAreaStippleRd[32];
  360. // PXRX
  361. ULONG * TextureDownloadControl;
  362. ULONG * AGPControl;
  363. ULONG *LocalMemCaps;
  364. ULONG *MemScratch;
  365. ULONG *LocalMemProfileMask0;
  366. ULONG *LocalMemProfileMask1;
  367. ULONG *LocalMemProfileCount0;
  368. ULONG *LocalMemProfileCount1;
  369. ULONG *PXRXByAperture1Mode; // 0300h
  370. ULONG *PXRXByAperture1Stride; // 0308h
  371. // ULONG *PXRXByAperture1YStart; // 0310h
  372. // ULONG *PXRXByAperture1UStart; // 0318h
  373. // ULONG *PXRXByAperture1VStart; // 0320h
  374. ULONG *PXRXByAperture2Mode; // 0328h
  375. ULONG *PXRXByAperture2Stride; // 0330h
  376. // ULONG *PXRXByAperture2YStart; // 0338h
  377. // ULONG *PXRXByAperture2UStart; // 0340h
  378. // ULONG *PXRXByAperture2VStart; // 0348h
  379. ULONG *PXRXByDMAReadMode; // 0350h
  380. ULONG *PXRXByDMAReadStride; // 0358h
  381. // ULONG *PXRXByDMAReadYStart; // 0360h
  382. // ULONG *PXRXByDMAReadUStart; // 0368h
  383. // ULONG *PXRXByDMAReadVStart; // 0370h
  384. ULONG *PXRXByDMAReadCommandBase; // 0378h
  385. ULONG *PXRXByDMAReadCommandCount; // 0380h
  386. // ULONG *PXRXByDMAWriteMode; // 0388h
  387. // ULONG *PXRXByDMAWriteStride; // 0390h
  388. // ULONG *PXRXByDMAWriteYStart; // 0398h
  389. // ULONG *PXRXByDMAWriteUStart; // 03A0h
  390. // ULONG *PXRXByDMAWriteVStart; // 03A8h
  391. // ULONG *PXRXByDMAWriteCommandBase; // 03B0h
  392. // ULONG *PXRXByDMAWriteCommandCount; // 03B8h
  393. // Used for P3 for debug purposes, to examine fifo stages.
  394. ULONG *TestOutputRdy;
  395. ULONG *TestInputRdy;
  396. } GlintRegAddrRec;
  397. typedef struct _glint_packing_str {
  398. DWORD readMode;
  399. DWORD modeSel;
  400. DWORD dxOffset;
  401. } GlintPackingRec;
  402. // Framebuffer Aperture Information: currently only of interest to GeoTwin
  403. // boards to allow for upload DMA directly from FB0 to FB1 and vice versa
  404. typedef struct FrameBuffer_Aperture_Info
  405. {
  406. LARGE_INTEGER pphysBaseAddr;
  407. ULONG cjLength;
  408. }
  409. FBAPI;
  410. // PCI device information. Used in an IOCTL return. Ensure this is the same
  411. // as in the miniport drivers glint.h
  412. typedef struct _Glint_Device_Info {
  413. ULONG SubsystemId;
  414. ULONG SubsystemVendorId;
  415. ULONG VendorId;
  416. ULONG DeviceId;
  417. ULONG RevisionId;
  418. ULONG DeltaRevId;
  419. ULONG GammaRevId;
  420. ULONG BoardId;
  421. ULONG LocalbufferLength;
  422. LONG LocalbufferWidth;
  423. ULONG ActualDacId;
  424. FBAPI FBAperture[2]; // Physical addresses for geo twin framebuffers
  425. PVOID FBApertureVirtual [2]; // Virtual addresses for geo twin framebuffers
  426. PVOID FBApertureMapped [2]; // Mapped physical/logical addresses for geo twin framebuffers
  427. PUCHAR pCNB20;
  428. LARGE_INTEGER pphysFrameBuffer; // physical address of the framebuffer (use FBAperture instead for geo twins)
  429. } Glint_Device_Info;
  430. #define GLINT_DELTA_PRESENT (glintInfo->deviceInfo.DeltaRevId != 0)
  431. #define GLINT_GAMMA_PRESENT (glintInfo->deviceInfo.GammaRevId != 0)
  432. // before we get Gamma we won't be able to test all the fancy new features,
  433. // after Gamma arrives we'll enable them one at a time; this define allows us
  434. // to do just that
  435. #define USE_MINIMAL_GAMMA_FEATURES 1
  436. typedef struct _Glint_SwPointer_Info {
  437. LONG xOff[5], yOff[5]; // offsets into screen of the caches.
  438. LONG PixelOffset; // pixel offsets into screen of the caches.
  439. LONG x, y; // x, y position
  440. LONG xHot, yHot; // Hotspot position
  441. LONG width, height;
  442. BOOL onScreen; // True if pointer is on screen
  443. LONG saveCache; // The current saveunder cache
  444. BOOL duplicateSaveCache; // Flag to indicate that save cache should be duplicated.
  445. ULONG writeMask; // The write mask to use when saving and restoring.
  446. DWORD *pDMA; // Pointer to a DMA buffer
  447. ULONG windowBase; // Window base
  448. DSURF* pdsurf; // Surface descriptors for caches
  449. HSURF hsurf;
  450. // Cached position of the pointer on the screen
  451. ULONG scrXDom, scrXSub, scrY, scrCnt;
  452. // Cached position of the save under cache
  453. LONG cacheXDom[5], cacheXSub[5], cacheY[5], cacheCnt[5];
  454. // Cached position of the visible pars of the save caches
  455. LONG scrToCacheXDom[2], scrToCacheXSub[2], scrToCacheY[2], scrToCacheCnt[2];
  456. // Cached offsets from the various caches.
  457. LONG saveOffset[2], constructOffset, maskOffset, shapeOffset;
  458. } Glint_SwPointer_Info;
  459. // Definition of the IOCTL_VIDEO_QUERY_DMA_BUFFER
  460. #define MAX_LINE_SIZE 8192 // No of bytes required to hold 1 complete scanline (i.e.,
  461. // 6400 for 1600x1200x32).
  462. #define DMA_LINEBUF_SIZE (MAX_LINE_SIZE * 2) // Size in bytes of 'pvTmpBuffer'.
  463. // This has to be big enough to store 2 entire
  464. // scan lines. I have increased the size from 1 line
  465. // to 2 lines so that P2 can double buffer
  466. // it's line uploads.
  467. typedef struct GENERAL_DMA_BUFFER {
  468. LARGE_INTEGER physAddr; // physical address of DMA buffer
  469. PVOID virtAddr; // mapped virtual address
  470. ULONG size; // size in bytes
  471. BOOL cacheEnabled; // Whether buffer is cached
  472. } GENERAL_DMA_BUFFER, *PGENERAL_DMA_BUFFER;
  473. /*** NB: The PXRXdmaInfo structure is shared with the Miniport ***/
  474. typedef struct PXRXdmaInfo_Tag {
  475. ULONG scheme; // Used by the interrupt handler only
  476. volatile ULONG hostInId; // Current internal HostIn id, used by the HIid DMA scheme
  477. volatile ULONG fifoCount; // Current internal FIFO count, used by various DMA schemes
  478. ULONG NTbuff; // Current buffer number (0 or 1)
  479. ULONG *NTptr; // 32/64 bit ptr Last address written to by NT (but not necesserily the end of a completed buffer)
  480. ULONG *NTdone; // 32/64 bit ptr Last address NT has finished with (end of a buffer, but not necessarily sent to P3 yet)
  481. volatile ULONG *P3at; // 32/64 bit ptr Last address sent to the P3
  482. volatile BOOL bFlushRequired; // Is a flush required to empty the FBwrite unit's cache?
  483. ULONG *DMAaddrL[2]; // 32/64 bit ptr Linear address of the start of each DMA buffer
  484. ULONG *DMAaddrEndL[2]; // 32/64 bit ptr Linear address of the end of each DMA buffer
  485. ULONG DMAaddrP[2]; // 32 bit ptr Physical address of the start of each DMA buffer
  486. ULONG DMAaddrEndP[2]; // 32 bit ptr Physical address of the end of each DMA buffer
  487. } PXRXdmaInfo;
  488. /*** NB: The PXRXdmaInfo structure is shared with the Miniport ***/
  489. typedef struct _glint_data {
  490. DWORD renderBits; // saved render bits set by setup routines
  491. DWORD FBReadMode; // software copy of FBReadMode register
  492. DWORD FBWriteMode; // software copy of FBWriteMode register
  493. DWORD RasterizerMode; // software copy of the rasterizer mode
  494. DWORD FBPacking; // software copy of FBModeSel
  495. DWORD FBBlockColor; // software copy of FBBlockColor (P1 only)
  496. DWORD TextureAddressMode; // software copy of TextureAddressMode (P2 only)
  497. DWORD TextureReadMode; // software copy of TextureReadMode (P2 & MX only)
  498. DWORD dSdx; // software copy of dSdx (MX only)
  499. DWORD dTdyDom; // software copy of dTdyDom (MX only)
  500. BOOL bGlintCoreBusy; // 2D flag: TRUE if core not synced
  501. LONG currentPelSize; // Currently loaded frame store depth
  502. ULONG currentCSbuffer;// color space buffer being displayed
  503. GLINT_CAPS flags; // various flags
  504. GlintRegAddrRec regs; // precomputed register addresses
  505. GlintPackingRec packing[5]; // values to load for 4 packing formats (plus one unused)
  506. LONG ddCtxtId; // id of the display drivers context
  507. LONG fastFillBlockSz;// number of pixels per fast fill block
  508. DWORD fastFillSupport;// render bits for rev 1 fast fill
  509. DWORD renderFastFill; // render bits for rev 2+ fast fill
  510. LONG PixelOffset; // last DFB pixel offset
  511. ULONG MaxInFifoEntries;// maximum reported free entries FIFO download
  512. ULONG CheckFIFO; // Non-zero if the FIFO has to be checked before loading it
  513. ULONG PCIDiscEnabled; // Non-zero if PCI disconnect is enabled
  514. ULONG BroadcastMask2D;// Primary chip broadcast mask
  515. ULONG BroadcastMask3D;// broadcast mask to use for 3D contexts
  516. LONG vtgvLimit; // copy of VTGVLimit register
  517. LONG scanFudge; // how much to add onto VTGVLineNumber to
  518. // get the current video scanline
  519. OH * backBufferPoh; // heap handle for allocated back-buffer
  520. OH * savedPoh; // handle to saved off-screen heap
  521. ULONG GMX2KLastLine; // Last+1 line to be allocated
  522. BOOLEAN offscreenEnabledOK; // Set to TRUE if off-screen enabled
  523. ULONG bufferOffset[GLINT_NUM_SCREEN_BUFFERS];
  524. // offset in pixels to the supported bufs
  525. ULONG bufferRow[GLINT_NUM_SCREEN_BUFFERS];
  526. // VTGFrameRowAddr for supported buffers
  527. ULONG PerfScaleShift;
  528. //ContextDumpData GammaContextMask;
  529. ULONG HostOutBroadcastMask; // for Gamma output DMA
  530. ULONG HostOutChipNumber; // for Gamma output DMA
  531. #if GAMMA_CORRECTION
  532. union {
  533. UCHAR _clutBuffer[MAX_CLUT_SIZE];
  534. VIDEO_CLUT gammaLUT; // saved gamma LUT contents
  535. };
  536. #endif
  537. // interrupt command block.
  538. struct _glint_interrupt_control *pInterruptCommandBlock;
  539. // maximum number of sub buffers per DMA buffer.
  540. ULONG MaxDMASubBuffers;
  541. // Overlay support: WriteMask can be set around primitives so that
  542. // they temporarily render thru this mask. Normally it must be set to -1.
  543. // DefaultWriteMask is the write mask that should be used by the DD
  544. // context by default, it takes into account overlay planes.
  545. //
  546. ULONG OverlayMode;
  547. ULONG WriteMask;
  548. ULONG TransparentColor; // pre-shifted so color is in top 8 bits
  549. ULONG DefaultWriteMask;
  550. // Indicates whether GDI is allowed to access the frame buffer. Always true
  551. // on MIPS and ALPHA and true on all architectures in overlay mode.
  552. ULONG GdiCantAccessFramebuffer;
  553. ULONG OGLOverlaySavedGCAF;
  554. // Configuration for texture and Z buffers
  555. ULONG ZBufferWidth; // bits per pel
  556. ULONG ZBufferOffset; // offset in pels
  557. ULONG ZBufferSize; // size in pels
  558. ULONG FontMemoryOffset; // offset in dwords
  559. ULONG FontMemorySize; // size in dwords
  560. ULONG TextureMemoryOffset; // offset in dwords
  561. ULONG TextureMemorySize; // size in dwords
  562. // On P3 due to patching restrictions the Z width
  563. // may not match the framebuffer screen width.
  564. ULONG P3RXLocalBufferWidth;
  565. // PCI configuration id information
  566. Glint_Device_Info deviceInfo;
  567. // Software cursor information
  568. Glint_SwPointer_Info swPointer;
  569. // Line DMA buffer information
  570. GENERAL_DMA_BUFFER LineDMABuffer;
  571. GENERAL_DMA_BUFFER PXRXDMABuffer;
  572. // Current input FIFO count from 0 to 1023
  573. ULONG FifoCnt;
  574. // PXRX specific stuff:
  575. ULONG foregroundColour; // Software copies of various registers
  576. ULONG backgroundColour; // Ditto
  577. ULONG config2D; // Ditto
  578. ULONG fbDestMode; // Ditto
  579. ULONG fbDestAddr[4]; // Ditto
  580. ULONG fbDestOffset[4]; // Ditto
  581. ULONG fbDestWidth[4]; // Ditto
  582. ULONG fbWriteMode; // Ditto
  583. ULONG fbWriteAddr[4]; // Ditto
  584. ULONG fbWriteWidth[4]; // ottiD
  585. ULONG fbWriteOffset[4]; // Ditto
  586. ULONG fbSourceAddr; // Ditto
  587. ULONG fbSourceWidth; // ottiD
  588. ULONG fbSourceOffset; // Ditto
  589. ULONG lutMode; // Ditto
  590. ULONG pxrxByDMAReadMode; // Ditto
  591. ULONG lastLine; // Delta LineCoord0/1
  592. ULONG savedConfig2D; // Config2D value that we use for integer lines
  593. ULONG savedLOP; // LogicOp value that we use for lines
  594. ULONG savedCol; // Colour value that we use for lines
  595. RECTL * savedClip; // Clip rectangle that we use for lines
  596. ULONG pxrxFlags; // General flags, see below
  597. ULONG backBufferXY; // Offset to add to front buffer to get to the back buffer (for FBWriteBufferOffsetX)
  598. ULONG frontRightBufferXY; // Offset to the stereo front buffer
  599. ULONG backRightBufferXY; // Offset to the stereo back buffer
  600. ULONG fbWriteModeDualWrite; // FBWriteMode for single writes
  601. ULONG fbWriteModeSingleWrite; // FBWriteMode for dual writes
  602. ULONG fbWriteModeDualWriteStereo; // FBWriteMode for stereo mode single writes
  603. ULONG fbWriteModeSingleWriteStereo;// FBWriteMode for stereo mode dual writes
  604. ULONG render2Dpatching; // Value to stuff into Render2D to set the required patch mode
  605. ULONG usePXRXdma;
  606. PXRXdmaInfo *pxrxDMA;
  607. PXRXdmaInfo pxrxDMAnonInterrupt;
  608. //#if PXRX_DMA_BUFFER_CHECK
  609. // These should be '#if PXRX_DMA_BUFFER_CHECK' really but the
  610. // hassle with include dependancies and such like means it ain't
  611. // worth it.
  612. ULONG *pxrxDMA_bufferBase; // Start of the allocated DMA buffer (inc. guard bands)
  613. ULONG *pxrxDMA_bufferTop; // End of the allocated DMA buffer (inc. guard bands)
  614. ULONG *NTwait; // Last address up to which NT did a wait for space
  615. //#endif
  616. } GlintDataRec, *GlintDataPtr;
  617. #define PXRX_FLAGS_DUAL_WRITE (1 << 0) /* Are we in dual write mode */
  618. #define PXRX_FLAGS_DUAL_WRITING (1 << 1) /* Are dual writes currently active */
  619. #define PXRX_FLAGS_PATCHING_FRONT (1 << 2) /* Is the front buffer running patched */
  620. #define PXRX_FLAGS_PATCHING_BACK (1 << 3) /* Is the back buffer running patched */
  621. #define PXRX_FLAGS_READ_BACK_BUFFER (1 << 4) /* Do we want to read from the back buffer */
  622. #define PXRX_FLAGS_STEREO_WRITE (1 << 5) /* Are we in OpenGL stereo mode */
  623. #define PXRX_FLAGS_STEREO_WRITING (1 << 6) /* Are stereo writes currently active */
  624. #if defined(_PPC_)
  625. // on PPC need this even if not using PERFMON
  626. ULONG GetCycleCount(VOID);
  627. #endif
  628. // bit definitions for the status words in ppdev->g_GlintBoardStatus[]:
  629. // Currently used to indicate sync and DMA status. We have the following rules:
  630. // synced means no outstanding DMA as well as synced. DMA_COMPLETE means n
  631. // outstanding DMA but not necessarily synced. Thus when we do a wait on DMA
  632. // complete we turn off the synced bit.
  633. // XXX for the moment we don't use the synced bit as it's awkward to see where
  634. // to unset it - doing so for every access to the chip is too expensive. We
  635. // probably need a "I'm about to start downloading to the FIFO" macro which
  636. // gets put at the start of any routine which writes to the FIFO.
  637. //
  638. #define GLINT_SYNCED 0x01
  639. #define GLINT_DMA_COMPLETE 0x02 // set when there is no outstanding DMA
  640. #define GLINT_INTR_COMPLETE 0x04
  641. #define GLINT_INTR_CONTEXT 0x08 // set if the current context is interrupt enabled
  642. #define GLINT_DUAL_CONTEXT 0x10 // set if the current context uses both TXs
  643. // these macros were taken out on NT 4 so define them
  644. #define READ_FAST_ULONG(a) READ_REGISTER_ULONG((PULONG)(a))
  645. #define WRITE_FAST_ULONG(a, d) WRITE_REGISTER_ULONG((PULONG)(a), (d))
  646. #define TRANSLATE_ADDR(a) ((ULONG *)a)
  647. //azn #define INVALID_HANDLE_VALUE NULL
  648. #define DebugBreak EngDebugBreak
  649. typedef PVOID PGLINT_COUNTER_DATA;
  650. // This will pause the processor whilst using as little
  651. // system bandwidth (either memory or DMA) as possible
  652. #if defined(_X86_)
  653. # define BUSY_WAIT(c) \
  654. do { \
  655. __asm nop \
  656. } while( c-- >= 0 )
  657. #else
  658. # define BUSY_WAIT(c) \
  659. do { \
  660. _temp_volatile_i = c; \
  661. do { \
  662. ; \
  663. } while( _temp_volatile_i-- >= 0 ); \
  664. } while(0)
  665. #endif
  666. // If we have a sparsely mapped framebuffer then we use the xx_REGISTER_ULONG()
  667. // macros, otherwise we just access the framebuffer.
  668. #define READ_SCREEN_ULONG(a) ((ppdev->flCaps & CAPS_SPARSE_SPACE) ? (READ_REGISTER_ULONG(a)) : *((volatile PULONG)(a)))
  669. #define WRITE_SCREEN_ULONG(a,d) \
  670. { \
  671. if(ppdev->flCaps & CAPS_SPARSE_SPACE) \
  672. { \
  673. WRITE_REGISTER_ULONG((a),d); \
  674. } \
  675. else \
  676. { \
  677. *(volatile PULONG)(a) = d; \
  678. } \
  679. }
  680. // generic macros to access GLINT FIFO and non-FIFO control registers.
  681. // We do nothing sophisticated for the Alpha (yet). We just MEMORY_BARRIER
  682. // everything.
  683. //
  684. #define READ_GLINT_CTRL_REG(r, d) \
  685. ((d) = READ_FAST_ULONG(glintInfo->regs. r))
  686. #define WRITE_GLINT_CTRL_REG(r, v) \
  687. { \
  688. MEMORY_BARRIER(); \
  689. WRITE_FAST_ULONG(glintInfo->regs. r, (ULONG)(v)); \
  690. DISPDBG((150, "WRITE_GLINT_CTRL_REG(%-20s:0x%08X) <-- 0x%08X", #r, glintInfo->regs.r, v)); \
  691. MEMORY_BARRIER(); \
  692. }
  693. #define READ_GLINT_FIFO_REG_CHIP(r, d) \
  694. ((d) = READ_FAST_ULONG(glintInfo->regs.tagrd[r]))
  695. #define READ_GLINT_FIFO_REG(r, d) READ_GLINT_FIFO_REG_CHIP(r, d)
  696. #define WRITE_GLINT_FIFO_REG(r, v) \
  697. { \
  698. MEMORY_BARRIER(); \
  699. WRITE_FAST_ULONG(glintInfo->regs.tagwr[r], (ULONG)(v)); \
  700. MEMORY_BARRIER(); \
  701. }
  702. #define READ_ODD_TX_AREA_STIPPLE(r, d) \
  703. ((d) = READ_FAST_ULONG(glintInfo->regs.OddTXAreaStippleRd[r]))
  704. #define READ_ODD_GLINT_SCANLINE_OWNERSHIP(d) \
  705. ((d) = READ_FAST_ULONG(glintInfo->regs.OddGlintScanlineOwnRd))
  706. #define READ_ODD_GLINT_FBWINDOWBASE(d) \
  707. ((d) = READ_FAST_ULONG(glintInfo->regs.OddGlintFBWindowBaseRd))
  708. #define READ_ODD_GLINT_LBWINDOWBASE(d) \
  709. ((d) = READ_FAST_ULONG(glintInfo->regs.OddGlintLBWindowBaseRd))
  710. //
  711. // macros to access the output FIFO
  712. //
  713. #define READ_OUTPUT_FIFO(d) \
  714. READ_GLINT_CTRL_REG(OutFIFOInterface, d)
  715. #define READ_OUTPUT_FIFO_ODD(d) \
  716. READ_GLINT_CTRL_REG(OutFIFOInterfaceOdd, d)
  717. #define OUTPUT_FIFO_COUNT(n) \
  718. READ_GLINT_CTRL_REG(OutFIFOWords, n)
  719. #define OUTPUT_FIFO_COUNT_ODD(n) \
  720. READ_GLINT_CTRL_REG(OutFIFOWordsOdd, n)
  721. #define WAIT_OUTPUT_FIFO_COUNT(n) \
  722. { \
  723. int i; \
  724. do \
  725. { \
  726. OUTPUT_FIFO_COUNT(i); \
  727. } \
  728. while(i < (int)n); \
  729. }
  730. #define DUAL_GLINT_WAIT_OUTPUT_FIFO_NOT_EMPTY(nGlint, cWordsOutFifo) \
  731. { \
  732. if(nGlint) \
  733. { \
  734. WAIT_OUTPUT_FIFO_NOT_EMPTY_ODD(cWordsOutFifo); \
  735. } \
  736. else \
  737. { \
  738. WAIT_OUTPUT_FIFO_NOT_EMPTY(cWordsOutFifo); \
  739. } \
  740. }
  741. #define DUAL_GLINT_READ_OUTPUT_FIFO(nGlint, ul) \
  742. { \
  743. if(nGlint) \
  744. { \
  745. READ_OUTPUT_FIFO_ODD(ul); \
  746. } \
  747. else \
  748. { \
  749. READ_OUTPUT_FIFO(ul); \
  750. } \
  751. }
  752. #define DUAL_GLINT_OUTPUT_FIFO_COUNT(nGlint, ul) \
  753. { \
  754. if(nGlint) \
  755. { \
  756. OUTPUT_FIFO_COUNT_ODD(ul); \
  757. } \
  758. else \
  759. { \
  760. OUTPUT_FIFO_COUNT(ul); \
  761. } \
  762. }
  763. //
  764. // macros to access specific GLINT control registers
  765. //
  766. // We decrease the value of InFIFOSpace by 1 because of a bug in Gamma chip
  767. #define GET_INPUT_FIFO_SPACE(n) ( READ_GLINT_CTRL_REG(InFIFOSpace, n) > 120 ? (n=120) : (n>0? n=n-1:n) )
  768. #define GET_DMA_COUNT(c) READ_GLINT_CTRL_REG(DMACount, c)
  769. #define GET_OUTDMA_COUNT(c) READ_GLINT_CTRL_REG(OutDMACount, c)
  770. #define SET_DMA_ADDRESS(aPhys, aVirt) { \
  771. WRITE_GLINT_CTRL_REG(DMAAddress, aPhys); \
  772. }
  773. #define SET_DMA_COUNT(c) { \
  774. WRITE_GLINT_CTRL_REG(DMACount, c); \
  775. }
  776. #define SET_OUTDMA_ADDRESS(aPhys, aVirt) { \
  777. WAIT_GLINT_FIFO(2); \
  778. LD_GLINT_FIFO(GammaTagDMAOutputAddress, aPhys);
  779. #define SET_OUTDMA_COUNT(c) { \
  780. LD_GLINT_FIFO(GammaTagDMAOutputCount, c);
  781. // Macros to perform logical DMA on a Gamma
  782. //
  783. #define START_QUEUED_DMA(P, C) { \
  784. WAIT_GLINT_FIFO(2); \
  785. LD_GLINT_FIFO(GammaTagDMAAddr, P); \
  786. LD_GLINT_FIFO(GammaTagDMACount, C); \
  787. }
  788. #define WAIT_QUEUED_DMA_COMPLETE { \
  789. READ_GLINT_CTRL_REG(GammaCommandIntFlags, _temp_volatile_ul); \
  790. READ_GLINT_CTRL_REG(GammaCommandStatus, _temp_volatile_ul); \
  791. if (_temp_volatile_ul & GAMMA_STATUS_COMMAND_DMA_BUSY) { \
  792. do { \
  793. for (_temp_volatile_ul = 10; _temp_volatile_ul > 0; --_temp_volatile_ul); \
  794. READ_GLINT_CTRL_REG(GammaCommandStatus, _temp_volatile_ul); \
  795. } while (_temp_volatile_ul & GAMMA_STATUS_COMMAND_DMA_BUSY); \
  796. } \
  797. }
  798. #define VERT_RETRACE_FLAG (0x10)
  799. #define P2_BYPASS_FLAG (1 << 7)
  800. #define P2_BUFSWAPCTL_FLAG (3 << 9)
  801. #define RESET_VERT_RETRACE WRITE_GLINT_CTRL_REG(IntFlags, VERT_RETRACE_FLAG)
  802. #define LD_GLINT_FIFO_DBG(tag, d) \
  803. { \
  804. DISPDBG((100, "tag 0x%03x <-- 0x%08x [%s]", tag, d, GET_TAG_STR(tag))); \
  805. \
  806. WRITE_GLINT_FIFO_REG(tag, d); \
  807. READ_GLINT_CTRL_REG(ErrorFlags, _temp_ul); \
  808. if (GLINT_DELTA_PRESENT) { \
  809. READ_GLINT_CTRL_REG(DeltaErrorFlags, _temp_ul2); \
  810. _temp_ul |= _temp_ul2; \
  811. } \
  812. _temp_ul &= ~0x2; /* we're not interested in output fifo errors */ \
  813. _temp_ul &= ~0x10; /* ingore any Video FIFO underrun errors on P2 */ \
  814. _temp_ul &= ~0x2000; /* ingore any HostIn DMA errors on P3 */ \
  815. if (_temp_ul != 0) { \
  816. DISPDBG((-1000, "LD_GLINT_FIFO(%s, 0x%X) error 0x%X", GET_TAG_STR(tag), d, _temp_ul)); \
  817. /*if( _temp_ul & ~0x2000 ) /* ignore, but report, HostIn DMA errors */ \
  818. /*DebugBreak();*/ \
  819. WRITE_GLINT_CTRL_REG(ErrorFlags, _temp_ul); \
  820. if (GLINT_DELTA_PRESENT) \
  821. WRITE_GLINT_CTRL_REG(DeltaErrorFlags, _temp_ul); \
  822. } \
  823. }
  824. #define LD_GLINT_FIFO_FREE(tag, d) WRITE_GLINT_FIFO_REG(tag, d)
  825. #if DBG
  826. #define LD_GLINT_FIFO(tag, d) LD_GLINT_FIFO_DBG(tag,d)
  827. #else //DBG
  828. #define LD_GLINT_FIFO(tag, d) LD_GLINT_FIFO_FREE(tag,d)
  829. #endif //DBG
  830. #define LD_FIFO_INTERFACE_DBG(d) \
  831. { \
  832. WRITE_GLINT_CTRL_REG(InFIFOInterface, d); \
  833. READ_GLINT_CTRL_REG(ErrorFlags, _temp_ul); \
  834. if (GLINT_DELTA_PRESENT) { \
  835. READ_GLINT_CTRL_REG(DeltaErrorFlags, _temp_ul2); \
  836. _temp_ul |= _temp_ul2; \
  837. } \
  838. _temp_ul &= ~0x2; /* we're not interested in output fifo errors */ \
  839. _temp_ul &= ~0x10; /* ingore any Video FIFO underrun errors on P2 */ \
  840. if (_temp_ul != 0) { \
  841. DISPDBG((-1000, "LD_FIFO_INTERFACE(0x%x) error 0x%x", d, _temp_ul)); \
  842. DebugBreak(); \
  843. WRITE_GLINT_CTRL_REG(ErrorFlags, _temp_ul); \
  844. if (GLINT_DELTA_PRESENT) \
  845. WRITE_GLINT_CTRL_REG(DeltaErrorFlags, _temp_ul); \
  846. } \
  847. }
  848. #define LD_FIFO_INTERFACE_FREE(d) WRITE_GLINT_CTRL_REG(InFIFOInterface, d)
  849. #if DBG
  850. #define LD_FIFO_INTERFACE(d) LD_FIFO_INTERFACE_DBG(d)
  851. #else //DBG
  852. #define LD_FIFO_INTERFACE(d) LD_FIFO_INTERFACE_FREE(d)
  853. #endif //DBG
  854. // local variables for all functions that access GLINT. Generally we use GLINT_DECL. Sometimes we have to split it
  855. // up if ppdev isn't passed into the routine.
  856. // NB. Temporary variables:-
  857. // These are necessary because VC5 doesn't account for the scope of variables within macros, i.e. each
  858. // time a macro with (a variable declaration within it's statement block) is used, the stack of the function
  859. // referencing the macro grows
  860. #define TEMP_MACRO_VARS \
  861. ULONG _temp_ul; \
  862. ULONG _temp_ul2; \
  863. LONG _temp_i; \
  864. volatile int _temp_volatile_i; \
  865. volatile ULONG _temp_volatile_ul; \
  866. volatile PULONG _temp_volatile_pul
  867. #define GLINT_DECL_VARS \
  868. TEMP_MACRO_VARS; \
  869. GlintDataPtr glintInfo
  870. #define GLINT_DECL_INIT \
  871. glintInfo = (GlintDataPtr)(ppdev->glintInfo)
  872. #define GLINT_DECL \
  873. GLINT_DECL_VARS; \
  874. GLINT_DECL_INIT
  875. //@@BEGIN_DDKSPLIT
  876. // Macro that determines whether the chipset supports RAMDAC overlays
  877. //#define RAMDAC_OVERLAYS_AVAILABLE (ppdev->pgfnRamdacSetOverlayMode != NULL)
  878. //@@END_DDKSPLIT
  879. #if(_X86_)
  880. #define SYNCHRONOUS_WRITE_ULONG(var, value) \
  881. { \
  882. ULONG *pul = (ULONG *)&var; \
  883. ULONG ul = (ULONG)value; \
  884. __asm push ecx \
  885. __asm mov ecx, ul \
  886. __asm mov edx, pul \
  887. __asm xchg ecx, [edx] \
  888. __asm pop ecx \
  889. }
  890. #define SYNCHRONOUS_WRITE_INDIRECT_ULONG(pvar, value) \
  891. { \
  892. ULONG *pul = (ULONG *)pvar; \
  893. ULONG ul = (ULONG)value; \
  894. __asm push ecx \
  895. __asm mov ecx, ul \
  896. __asm mov edx, pul \
  897. __asm xchg ecx, [edx] \
  898. __asm pop ecx \
  899. }
  900. #else
  901. // to be defined properly
  902. #define SYNCHRONOUS_WRITE_ULONG(memory, value) {(*(PULONG) &memory) = value;}
  903. #endif
  904. #define GET_INTR_CMD_BLOCK_MUTEX(pBlock)\
  905. do { \
  906. if(glintInfo->pInterruptCommandBlock) \
  907. { \
  908. DISPDBG((20, "display driver waiting for interrupt command block mutex")); \
  909. ASSERTDD(!(pBlock)->bDisplayDriverHasAccess, "Aquiring mutex when it is already aquired!"); \
  910. SYNCHRONOUS_WRITE_ULONG((pBlock)->bDisplayDriverHasAccess, TRUE); \
  911. while((pBlock)->bMiniportHasAccess); \
  912. } \
  913. } while(0)
  914. #define RELEASE_INTR_CMD_BLOCK_MUTEX(pBlock) \
  915. do { \
  916. if(glintInfo->pInterruptCommandBlock) \
  917. { \
  918. DISPDBG((20, "display driver releasing interrupt command block mutex")); \
  919. SYNCHRONOUS_WRITE_ULONG((pBlock)->bDisplayDriverHasAccess, FALSE); \
  920. } \
  921. } while(0)
  922. //
  923. // FIFO functions
  924. //
  925. #define MAX_GLINT_FIFO_ENTRIES 16
  926. #define MAX_PERMEDIA_FIFO_ENTRIES 32
  927. #define MAX_P2_FIFO_ENTRIES 258
  928. #define MAX_GAMMA_FIFO_ENTRIES 32
  929. #define MAX_P3_FIFO_ENTRIES 120
  930. #if DBG
  931. // wait for n entries to become free in the input FIFO
  932. #define WAIT_GLINT_FIFO(n) \
  933. { \
  934. if (glintInfo->CheckFIFO) \
  935. { \
  936. GET_DMA_COUNT(_temp_volatile_ul); \
  937. if (_temp_volatile_ul != 0) { \
  938. DISPDBG((-999, "WAIT_GLINT_FIFO: DMACount = %d, glintInfo = 0x%x", _temp_volatile_ul, glintInfo)); \
  939. ASSERTDD(_temp_volatile_ul == 0, "Break."); \
  940. } \
  941. while ((GET_INPUT_FIFO_SPACE(_temp_volatile_ul)) < (ULONG)(n)); \
  942. } \
  943. }
  944. #else
  945. // WAIT_GLINT_FIFO() - wait for n entries to become free in the input FIFO.
  946. // If PCI disconnect is on permanently then this function is a no-op.
  947. #define WAIT_GLINT_FIFO(n) /* Do the wait */ \
  948. { \
  949. if (glintInfo->CheckFIFO) \
  950. { \
  951. while ((GET_INPUT_FIFO_SPACE(_temp_volatile_ul)) < (ULONG)(n)); \
  952. } \
  953. }
  954. #endif
  955. // WAIT_FIFO_NOT_FULL() waits for any entries to become free in
  956. // the input FIFO and returns this number. If PCI disconnect is switched
  957. // on then we simply return 16 free entries (an empty FIFO).
  958. #define WAIT_FIFO_NOT_FULL(nFifo) /* Return FIFO state */ \
  959. { \
  960. ASSERTDD(GET_DMA_COUNT(nFifo) == 0, "WAIT_FIFO_NOT_FULL: DMACount != 0"); \
  961. nFifo = glintInfo->MaxInFifoEntries; \
  962. if (glintInfo->CheckFIFO) \
  963. { \
  964. while ((GET_INPUT_FIFO_SPACE(nFifo)) == 0); \
  965. } \
  966. }
  967. // Wait for DMA to complete (DMACount becomes zero). So as not to kill the
  968. // PCI bus bandwidth for the DMA put in a backoff based on the amount of data
  969. // still left to DMA. Also set the timer going if at any time, the count we
  970. // read is the same as the previous count.
  971. // New for Gamma: if queued DMA is configured then wait till the CommandStatus
  972. // indicates DMA is not busy and the FIFO empty. We do this test twice
  973. // because there is a possibility that the input FIFO will become empty one
  974. // clock before the DMA busy flag is set.
  975. //
  976. #define WAIT_DMA_COMPLETE \
  977. { \
  978. if (!(ppdev->g_GlintBoardStatus & GLINT_DMA_COMPLETE)) { \
  979. { \
  980. if (ppdev->g_GlintBoardStatus & GLINT_INTR_CONTEXT) { \
  981. /* do any VBLANK wait, wait Q to empty and last DMA to complete */ \
  982. PINTERRUPT_CONTROL_BLOCK pBlock = glintInfo->pInterruptCommandBlock; \
  983. while (pBlock->Control & SUSPEND_DMA_TILL_VBLANK); \
  984. while (pBlock->frontIndex != pBlock->backIndex); \
  985. } \
  986. if ((GET_DMA_COUNT(_temp_volatile_i)) > 0) { \
  987. do { \
  988. while (--_temp_volatile_i > 0); \
  989. } while ((GET_DMA_COUNT(_temp_volatile_i)) > 0); \
  990. } \
  991. } \
  992. ppdev->g_GlintBoardStatus |= GLINT_DMA_COMPLETE; \
  993. } \
  994. if (ppdev->currentCtxt == glintInfo->ddCtxtId) \
  995. SEND_PXRX_DMA; \
  996. }
  997. // Simple version which explicitly waits for the DMA to finish ignoring
  998. // interrupt driven DMA and overriding the DMA_COMPLETE flag. This is used
  999. // where code kicks off a DMA but wants to immediately wait for it to
  1000. // finish.
  1001. //
  1002. #define WAIT_IMMEDIATE_DMA_COMPLETE \
  1003. { \
  1004. if ((GET_DMA_COUNT(_temp_volatile_i)) > 0) { \
  1005. do { \
  1006. while (--_temp_volatile_i > 0); \
  1007. } while ((GET_DMA_COUNT(_temp_volatile_i)) > 0); \
  1008. } \
  1009. }
  1010. #define WAIT_OUTDMA_COMPLETE \
  1011. { \
  1012. if ((GET_OUTDMA_COUNT(_temp_volatile_i)) > 0) { \
  1013. do { \
  1014. while (--_temp_volatile_i > 0); \
  1015. } while ((GET_OUTDMA_COUNT(_temp_volatile_i)) > 0); \
  1016. } \
  1017. }
  1018. // IS_FIFO_EMPTY() XX
  1019. #define IS_FIFO_EMPTY(c) ((glintInfo->CheckFIFO) ? TRUE : \
  1020. (GET_INPUT_FIFO_SPACE(c) == glintInfo->MaxInFifoEntries))
  1021. // wait for the input FIFO to become empty
  1022. #define WAIT_INPUT_FIFO_EMPTY \
  1023. { \
  1024. WAIT_GLINT_FIFO(glintInfo->MaxInFifoEntries); \
  1025. }
  1026. #define WAIT_GLINT_FIFO_AND_DMA(n) \
  1027. { \
  1028. WAIT_DMA_COMPLETE; \
  1029. WAIT_GLINT_FIFO(n); \
  1030. }
  1031. // wait till the ouput FIFO has some data to be read and return the count
  1032. #define WAIT_OUTPUT_FIFO_NOT_EMPTY(n) \
  1033. { \
  1034. do \
  1035. { \
  1036. OUTPUT_FIFO_COUNT(n); \
  1037. } \
  1038. while (n == 0); \
  1039. }
  1040. #define WAIT_OUTPUT_FIFO_NOT_EMPTY_ODD(n) \
  1041. { \
  1042. do \
  1043. { \
  1044. OUTPUT_FIFO_COUNT_ODD(n); \
  1045. } \
  1046. while (n == 0); \
  1047. }
  1048. // wait for any data to appear in the output FIFO
  1049. #define WAIT_OUTPUT_FIFO_READY \
  1050. { \
  1051. WAIT_OUTPUT_FIFO_NOT_EMPTY(_temp_ul); \
  1052. }
  1053. #define WAIT_OUTPUT_FIFO_READY_ODD \
  1054. { \
  1055. WAIT_OUTPUT_FIFO_NOT_EMPTY_ODD(_temp_ul); \
  1056. }
  1057. #define SYNC_WITH_GLINT SYNC_WITH_GLINT_CHIP
  1058. #define CTXT_SYNC_WITH_GLINT SYNC_WITH_GLINT
  1059. #define GLINT_CORE_BUSY glintInfo->bGlintCoreBusy = TRUE
  1060. #define GLINT_CORE_IDLE glintInfo->bGlintCoreBusy = FALSE
  1061. #define TEST_GLINT_CORE_BUSY (glintInfo->bGlintCoreBusy)
  1062. #define SYNC_IF_CORE_BUSY \
  1063. { \
  1064. if(glintInfo->bGlintCoreBusy) \
  1065. { \
  1066. SYNC_WITH_GLINT; \
  1067. } \
  1068. }
  1069. //
  1070. // PCI Disconnect enable, disable and sync macros
  1071. //
  1072. // PCI_DISCONNECT_FASTSYNC()
  1073. // turn on disconnect for the input FIFO. We could do a SYNC here but it's quite
  1074. // expensive. Instead, add RasterizerMode(0) into the FIFO and when the register
  1075. // is set we know the FIFO is empty so turn on disconnect and reset RasterizerMode
  1076. // to a sensible value. PCI disconnect means we don't wait for FIFO space.
  1077. #define P2_BUSY (1 << 31)
  1078. #define PCI_DISCONNECT_FASTSYNC() \
  1079. { \
  1080. WAIT_GLINT_FIFO(1); \
  1081. LD_GLINT_FIFO(__GlintTagRasterizerMode, 0); \
  1082. /* when we see RasterizerMode set to zero */ \
  1083. /*we know we've flushed the FIFO and can enable disconnect */ \
  1084. do { \
  1085. READ_GLINT_FIFO_REG(__GlintTagRasterizerMode, _temp_volatile_ul); \
  1086. } while(_temp_volatile_ul); \
  1087. LD_GLINT_FIFO(__GlintTagRasterizerMode, glintInfo->RasterizerMode); \
  1088. // PCI_DISCONNECT_ENABLE()
  1089. // If disconnect is not already enabled then enable it and optionally do a fast
  1090. // sync.
  1091. #define PCI_DISCONNECT_ENABLE(prevDiscState,quickEnable) \
  1092. { \
  1093. prevDiscState = glintInfo->PCIDiscEnabled; \
  1094. if (!glintInfo->PCIDiscEnabled) \
  1095. { \
  1096. DISPDBG((7, "PCI_DISCONNECT_ENABLE()")); \
  1097. if (!quickEnable) \
  1098. { \
  1099. PCI_DISCONNECT_FASTSYNC(); \
  1100. } \
  1101. WRITE_GLINT_CTRL_REG(DisconnectControl, DISCONNECT_INPUT_FIFO_ENABLE); \
  1102. glintInfo->CheckFIFO = FALSE; \
  1103. glintInfo->PCIDiscEnabled = TRUE; \
  1104. } \
  1105. }
  1106. // PCI_DISCONNECT_DISABLE()
  1107. // If disconnect is not already disabled then disable it and optionally do a fast
  1108. // sync.
  1109. #define PCI_DISCONNECT_DISABLE(prevDiscState, quickDisable) \
  1110. { \
  1111. prevDiscState = glintInfo->PCIDiscEnabled; \
  1112. if (glintInfo->PCIDiscEnabled) \
  1113. { \
  1114. DISPDBG((7, "PCI_DISCONNECT_DISABLE()")); \
  1115. if (!quickDisable) \
  1116. { \
  1117. PCI_DISCONNECT_FASTSYNC(); \
  1118. } \
  1119. WRITE_GLINT_CTRL_REG(DisconnectControl, DISCONNECT_INOUT_DISABLE); \
  1120. glintInfo->CheckFIFO = TRUE; \
  1121. glintInfo->PCIDiscEnabled = FALSE; \
  1122. } \
  1123. }
  1124. // macros to set and get the framebuffer packing mode
  1125. //
  1126. #define GLINT_GET_PACKING_MODE(mode) \
  1127. READ_GLINT_CTRL_REG (FBModeSel, mode)
  1128. #define GLINT_SET_PACKING_MODE(mode) { \
  1129. DISPDBG((7, "setting FBModeSel to 0x%x", mode)); \
  1130. WRITE_GLINT_CTRL_REG(FBModeSel, mode); \
  1131. /* READ_GLINT_CTRL_REG (FBModeSel, mode); */ \
  1132. }
  1133. //
  1134. // macro to change the framebuffer packing.
  1135. //
  1136. #define GLINT_SET_FB_DEPTH(cps) \
  1137. { \
  1138. if (glintInfo->currentPelSize != cps) \
  1139. vGlintChangeFBDepth(ppdev, cps); \
  1140. }
  1141. #define GLINT_DEFAULT_FB_DEPTH GLINT_SET_FB_DEPTH(ppdev->cPelSize)
  1142. #define GLINTDEPTH8 0
  1143. #define GLINTDEPTH16 1
  1144. #define GLINTDEPTH32 2
  1145. #define GLINTDEPTH24 4
  1146. // macro to check and reload FBWindowBase if the target DFB changes
  1147. //
  1148. #define CHECK_PIXEL_ORIGIN(PixOrg) \
  1149. { \
  1150. if ((LONG)(PixOrg) != glintInfo->PixelOffset) \
  1151. { \
  1152. glintInfo->PixelOffset = (PixOrg); \
  1153. WAIT_GLINT_FIFO(1); \
  1154. LD_GLINT_FIFO(__GlintTagFBWindowBase, glintInfo->PixelOffset); \
  1155. DISPDBG((7, "New bitmap origin at offset %d", glintInfo->PixelOffset)); \
  1156. } \
  1157. }
  1158. #define GET_GAMMA_FEEDBACK_COMPLETED_COUNT(cEntriesWritten) \
  1159. { \
  1160. READ_GLINT_CTRL_REG(GammaFeedbackSelectCount, cEntriesWritten); \
  1161. }
  1162. #define PREPARE_GAMMA_OUTPUT_DMA \
  1163. { \
  1164. WRITE_GLINT_CTRL_REG(GammaCommandIntFlags, INTR_CLEAR_GAMMA_OUTPUT_DMA); \
  1165. }
  1166. #define WAIT_GAMMA_OUTPUT_DMA_COMPLETED \
  1167. { \
  1168. READ_GLINT_CTRL_REG(GammaCommandIntFlags, _temp_ul); \
  1169. if (!(_temp_ul & INTR_GAMMA_OUTPUT_DMA_SET)) \
  1170. { \
  1171. do \
  1172. { \
  1173. for(_temp_volatile_i = 100; --_temp_volatile_i;); \
  1174. READ_GLINT_CTRL_REG(GammaCommandIntFlags, _temp_ul); \
  1175. } \
  1176. while(!(_temp_ul & INTR_GAMMA_OUTPUT_DMA_SET)); \
  1177. } \
  1178. }
  1179. // Bitfield definition for IntFlags register
  1180. #define PXRX_HOSTIN_COMMAND_DMA_BIT 0x4000
  1181. #define PREPARE_PXRX_OUTPUT_DMA \
  1182. { \
  1183. WRITE_GLINT_CTRL_REG(IntFlags, PXRX_HOSTIN_COMMAND_DMA_BIT); \
  1184. }
  1185. #define SEND_PXRX_COMMAND_INTERRUPT \
  1186. { \
  1187. WAIT_GLINT_FIFO(1); \
  1188. LD_GLINT_FIFO( CommandInterrupt_Tag, 1); \
  1189. }
  1190. #define WAIT_PXRX_OUTPUT_DMA_COMPLETED \
  1191. { \
  1192. READ_GLINT_CTRL_REG(IntFlags, _temp_ul); \
  1193. if (!(_temp_ul & PXRX_HOSTIN_COMMAND_DMA_BIT)) \
  1194. { \
  1195. do \
  1196. { \
  1197. for(_temp_volatile_i = 100; --_temp_volatile_i;); \
  1198. READ_GLINT_CTRL_REG(IntFlags, _temp_ul); \
  1199. } \
  1200. while(!(_temp_ul & PXRX_HOSTIN_COMMAND_DMA_BIT)); \
  1201. } \
  1202. }
  1203. #define WAIT_GAMMA_INPUT_DMA_COMPLETED \
  1204. { \
  1205. CommandStatusData CmdSts; \
  1206. READ_GLINT_CTRL_REG(GammaCommandStatus, _temp_ul); \
  1207. CmdSts = *(CommandStatusData *)&_temp_ul; \
  1208. if(CmdSts.CommandDMABusy) \
  1209. { \
  1210. do \
  1211. { \
  1212. for(_temp_volatile_i = 100; --_temp_volatile_i;); \
  1213. READ_GLINT_CTRL_REG(GammaCommandStatus, _temp_ul); \
  1214. CmdSts = *(CommandStatusData *)&_temp_ul; \
  1215. } \
  1216. while(CmdSts.CommandDMABusy); \
  1217. } \
  1218. }
  1219. // Macro to set the delta unit broadcast mask.
  1220. // We sync when changing the mask to a anything other than both chips
  1221. // in order to avoid hitting a problem on some Gamma boards.
  1222. #define SET_BROADCAST_MASK(m) \
  1223. { \
  1224. WAIT_GLINT_FIFO(1); \
  1225. LD_GLINT_FIFO(__DeltaTagBroadcastMask, m); \
  1226. }
  1227. // Macros for the different types of double buffering supported and buffer
  1228. // offsets (in pixels). These are mostly required by 3D extension.
  1229. //
  1230. #define GLINT_CS_DBL_BUF (glintInfo->flags & GLICAP_COLOR_SPACE_DBL_BUF)
  1231. #define GLINT_FS_DBL_BUF (glintInfo->flags & GLICAP_FULL_SCREEN_DBL_BUF)
  1232. #define GLINT_BLT_DBL_BUF (glintInfo->flags & GLICAP_BITBLT_DBL_BUF)
  1233. #define GLINT_FIX_FAST_FILL (glintInfo->flags & GLICAP_FIX_FAST_FILLS)
  1234. #define GLINT_HW_WRITE_MASK (glintInfo->flags & GLICAP_HW_WRITE_MASK)
  1235. #define GLINT_HW_WRITE_MASK_BYTES (glintInfo->flags & GLICAP_HW_WRITE_MASK_BYTES)
  1236. #define GLINT_INTERRUPT_DMA (glintInfo->flags & GLICAP_INTERRUPT_DMA)
  1237. #define GLINT_FAST_FILL_SIZE (glintInfo->fastFillBlockSz)
  1238. #define GLINT_BUFFER_OFFSET(n) (glintInfo->bufferOffset[n])
  1239. // these are generic for both GLINT and PERMEDIA
  1240. #define LOCALBUFFER_PIXEL_WIDTH (glintInfo->ZBufferWidth)
  1241. #define LOCALBUFFER_PIXEL_OFFSET (glintInfo->ZBufferOffset)
  1242. #define LOCALBUFFER_PIXEL_COUNT (glintInfo->ZBufferSize)
  1243. #define FONT_MEMORY_OFFSET (glintInfo->FontMemoryOffset)
  1244. #define FONT_MEMORY_SIZE (glintInfo->FontMemorySize)
  1245. #define TEXTURE_MEMORY_OFFSET (glintInfo->TextureMemoryOffset)
  1246. #define TEXTURE_MEMORY_SIZE (glintInfo->TextureMemorySize)
  1247. // Minimum height of off-screen surface we need to allocate for texture map.
  1248. // Use this to work out whether we have enough room to allocate permanent
  1249. // things like the brush cache and software cursor caches.
  1250. //
  1251. #define TEXTURE_OH_MIN_HEIGHT \
  1252. ((((2*4*64*64) >> ppdev->cPelSize) + (ppdev->cxMemory-1)) / ppdev->cxMemory)
  1253. // macro to poll for VBLANK. Can be called by any routine which defines
  1254. // glintInfo (i.e. use GLINT_DECL at the start of a routine if ppdev
  1255. // is available). Technically, VBLANK starts at line 1, but we consider
  1256. // any line <= VBLANK_LINE_NUMBER as a valid start.
  1257. //
  1258. #define VBLANK_LINE_NUMBER 2
  1259. #define GLINT_WAIT_FOR_VBLANK \
  1260. { \
  1261. ULONG lineNo; \
  1262. do { \
  1263. READ_GLINT_CTRL_REG (VTGVLineNumber, lineNo); \
  1264. } while (lineNo > VBLANK_LINE_NUMBER); \
  1265. }
  1266. // macro to return the current video scanline. This can be used to better time
  1267. // when to perform bitblt'ed double buffering.
  1268. //
  1269. #define GLINT_GET_VIDEO_SCANLINE(lineNo) \
  1270. { \
  1271. READ_GLINT_CTRL_REG (VTGVLineNumber, lineNo); \
  1272. if (((lineNo) -= glintInfo->scanFudge) < 0) \
  1273. (lineNo) += glintInfo->vtgvLimit; \
  1274. }
  1275. //
  1276. // external interface to the context switching code. The caller can allocate and
  1277. // free a context or ask for a switch to a new context. vGlintSwitchContext
  1278. // should not be called except through the given macro. The macro assumes
  1279. // that ppdev has been defined.
  1280. //
  1281. typedef enum ContextType_Tag {
  1282. ContextType_None, // No context information to save for this context
  1283. ContextType_Fixed, // Restore sets the chip into a fixed state
  1284. ContextType_RegisterList, // Save/restore a given set of registers
  1285. } ContextType;
  1286. typedef void (* ContextFixedFunc)(PPDEV ppdev, BOOL switchingIn);
  1287. /*
  1288. To create a new context:
  1289. id = GlintAllocateNewContext(ppdev, pTags, nTags, NumSubBuffs, Private, ContextType_RegisterList );
  1290. id = GlintAllocateNewContext(ppdev, (ULONG *) ContextRestoreFunction, 0, 0, NULL, ContextType_Fixed );
  1291. */
  1292. extern LONG GlintAllocateNewContext(PPDEV, DWORD *, LONG, ULONG, PVOID, ContextType);
  1293. extern VOID vGlintFreeContext(PPDEV, LONG);
  1294. extern VOID vGlintSwitchContext(PPDEV, LONG);
  1295. #define NON_GLINT_CONTEXT_ID 0x7fffffff
  1296. #define GLINT_VALIDATE_CONTEXT(id) \
  1297. if (((ppdev)->currentCtxt) != (id)) \
  1298. vGlintSwitchContext(ppdev, (id))
  1299. #define GLINT_VALIDATE_CONTEXT_AND_SYNC(id) { \
  1300. if (((ppdev)->currentCtxt) != (id)) \
  1301. vGlintSwitchContext(ppdev, (id)); \
  1302. else \
  1303. SYNC_WITH_GLINT; \
  1304. }
  1305. #define USE_INTERRUPTS_FOR_2D_DMA 1
  1306. #if USE_INTERRUPTS_FOR_2D_DMA
  1307. #define INTERRUPTS_ENABLED ((ppdev->flCaps & CAPS_INTERRUPTS) && glintInfo->pInterruptCommandBlock)
  1308. #else // USE_INTERRUPTS_FOR_2D_DMA
  1309. #define INTERRUPTS_ENABLED (FALSE)
  1310. #endif // USE_INTERRUPTS_FOR_2D_DMA
  1311. // macro used by display driver to validate its context
  1312. #if ENABLE_DMA_TEXT_RENDERING
  1313. #define VALIDATE_DD_CONTEXT \
  1314. { \
  1315. if(DD_DMA_XFER_IN_PROGRESS) \
  1316. { \
  1317. DISPDBG((9, "######## Waiting for DMA to complete ########")); \
  1318. WAIT_DD_DMA_COMPLETE; \
  1319. } \
  1320. else \
  1321. { \
  1322. DISPDBG((9, "######## No DMA in progress ########")); \
  1323. } \
  1324. GLINT_VALIDATE_CONTEXT(glintInfo->ddCtxtId); \
  1325. }
  1326. #else //ENABLE_DMA_TEXT_RENDERING
  1327. #define VALIDATE_DD_CONTEXT \
  1328. { \
  1329. GLINT_VALIDATE_CONTEXT(glintInfo->ddCtxtId); \
  1330. }
  1331. #endif //ENABLE_DMA_TEXT_RENDERING
  1332. //
  1333. // useful macros not defined in standard GLINT header files. Generally, for
  1334. // speed we don't want to use the bitfield structures so we define the bit
  1335. // shifts to get at the various fields.
  1336. //
  1337. #define INTtoFIXED(i) ((i) << 16) // int to 16.16 fixed format
  1338. #define FIXEDtoINT(i) ((i) >> 16) // 16.16 fixed format to int
  1339. #define INTofFIXED(i) ((i) & 0xffff0000) // int part of 16.16
  1340. #define FRACTofFIXED(i) ((i) & 0xffff) // fractional part of 16.16
  1341. #define FIXtoFIXED(i) ((i) << 12) // 12.4 to 16.16
  1342. #define FIXtoINT(i) ((i) >> 4) // 28.4 to 28
  1343. #define INT16(i) ((i) & 0xFFFF)
  1344. #define __GLINT_CONSTANT_FB_WRITE (1 << (4+1))
  1345. #define __COLOR_DDA_FLAT_SHADE (__PERMEDIA_ENABLE | \
  1346. (__GLINT_FLAT_SHADE_MODE << 1))
  1347. #define __COLOR_DDA_GOURAUD_SHADE (__PERMEDIA_ENABLE | \
  1348. (__GLINT_GOURAUD_SHADE_MODE << 1))
  1349. #define MIRROR_BITMASK (1 << 0)
  1350. #define INVERT_BITMASK_BITS (1 << 1)
  1351. #define BYTESWAP_BITMASK (3 << 7)
  1352. #define FORCE_BACKGROUND_COLOR (1 << 6) // Permedia only
  1353. #define MULTI_GLINT (1 << 17)
  1354. // bits in the Render command
  1355. #define __RENDER_INCREASE_Y (1 << 22)
  1356. #define __RENDER_INCREASE_X (1 << 21)
  1357. #define __RENDER_VARIABLE_SPANS (1 << 18)
  1358. #define __RENDER_REUSE_BIT_MASK (1 << 17)
  1359. #define __RENDER_TEXTURE_ENABLE (1 << 13)
  1360. #define __RENDER_SYNC_ON_HOST_DATA (1 << 12)
  1361. #define __RENDER_SYNC_ON_BIT_MASK (1 << 11)
  1362. #define __RENDER_TRAPEZOID_PRIMITIVE (__GLINT_TRAPEZOID_PRIMITIVE << 6)
  1363. #define __RENDER_LINE_PRIMITIVE (__GLINT_LINE_PRIMITIVE << 6)
  1364. #define __RENDER_POINT_PRIMITIVE (__GLINT_POINT_PRIMITIVE << 6)
  1365. #define __RENDER_FAST_FILL_INC(n) (((n) >> 4) << 4) // n = 8, 16 or 32
  1366. #define __RENDER_FAST_FILL_ENABLE (1 << 3)
  1367. #define __RENDER_RESET_LINE_STIPPLE (1 << 2)
  1368. #define __RENDER_LINE_STIPPLE_ENABLE (1 << 1)
  1369. #define __RENDER_AREA_STIPPLE_ENABLE (1 << 0)
  1370. // bits in the ScissorMode register
  1371. #define USER_SCISSOR_ENABLE (1 << 0)
  1372. #define SCREEN_SCISSOR_ENABLE (1 << 1)
  1373. #define SCISSOR_XOFFSET 0
  1374. #define SCISSOR_YOFFSET 16
  1375. // bits in the FBReadMode register
  1376. #define __FB_READ_SOURCE (1 << 9)
  1377. #define __FB_READ_DESTINATION (1 << 10)
  1378. #define __FB_COLOR (1 << 15)
  1379. #define __FB_WINDOW_ORIGIN (1 << 16)
  1380. #define __FB_PACKED_DATA (1 << 19)
  1381. #define __FB_SCAN_INTERVAL_2 (1 << 23)
  1382. // extra bits in PERMEDIA FBReadMode
  1383. #define __FB_RELATIVE_OFFSET 20
  1384. // P2 also provides a version of Relative Offset in the PackedDataLimits register
  1385. #define __PDL_RELATIVE_OFFSET 29
  1386. // bits in the LBReadMode register
  1387. #define __LB_READ_SOURCE (1 << 9)
  1388. #define __LB_READ_DESTINATION (1 << 10)
  1389. #define __LB_STENCIL (1 << 16)
  1390. #define __LB_DEPTH (1 << 17)
  1391. #define __LB_WINDOW_ORIGIN (1 << 18)
  1392. #define __LB_READMODE_PATCH (1 << 19)
  1393. #define __LB_SCAN_INTERVAL_2 (1 << 20)
  1394. // bits in the DepthMode register
  1395. #define __DEPTH_ENABLE 1
  1396. #define __DEPTH_WRITE_ENABLE (1<<1)
  1397. #define __DEPTH_REGISTER_SOURCE (2<<2)
  1398. #define __DEPTH_MSG_SOURCE (3<<2)
  1399. #define __DEPTH_ALWAYS (7<<4)
  1400. // bits in the LBReadFormat/LBWriteFormat registers
  1401. #define __LB_FORMAT_DEPTH32 2
  1402. // macros to load indexed tags more efficiently than using __GlintDMATag struct
  1403. #define GLINT_TAG_MAJOR(x) ((x) & 0xff0)
  1404. #define GLINT_TAG_MINOR(x) ((x) & 0x00f)
  1405. // macro to take a GLINT logical op and return the enabled LogcialOpMode bits
  1406. #define GLINT_ENABLED_LOGICALOP(op) (((op) << 1) | __PERMEDIA_ENABLE)
  1407. #define RECTORIGIN_YX(y,x) (((y) << 16) | ((x) & 0xFFFF))
  1408. #define MAKEDWORD_XY(x, y) (INT16(x) | (INT16(y) << 16))
  1409. // area stipple shifts and bit defines
  1410. #define AREA_STIPPLE_XSEL(x) ((x) << 1)
  1411. #define AREA_STIPPLE_YSEL(y) ((y) << 4)
  1412. #define AREA_STIPPLE_XOFF(x) ((x) << 7)
  1413. #define AREA_STIPPLE_YOFF(y) ((y) << 12)
  1414. #define AREA_STIPPLE_INVERT_PAT (1 << 17)
  1415. #define AREA_STIPPLE_MIRROR_X (1 << 18)
  1416. #define AREA_STIPPLE_MIRROR_Y (1 << 19)
  1417. // Some constants
  1418. #define ONE 0x00010000
  1419. #define MINUS_ONE 0xFFFF0000
  1420. #define PLUS_ONE ONE
  1421. #define NEARLY_ONE 0x0000FFFF
  1422. #define HALF 0x00008000
  1423. #define NEARLY_HALF 0x00007FFF
  1424. // max length of GIQ conformant lines that GLINT can draw
  1425. //
  1426. #if 0
  1427. #define MAX_LENGTH_CONFORMANT_NONINTEGER_LINES 16
  1428. #define MAX_LENGTH_CONFORMANT_INTEGER_LINES 194
  1429. #else
  1430. // Permedia has only 15 bits of fraction so reduce the lengths.
  1431. #define MAX_LENGTH_CONFORMANT_NONINTEGER_LINES (16/2)
  1432. #define MAX_LENGTH_CONFORMANT_INTEGER_LINES (194/2)
  1433. #endif
  1434. #define MAX_LENGTH_CONFORMANT_P3_INTEGER_LINES_P 194
  1435. #define MAX_LENGTH_CONFORMANT_P3_INTEGER_LINES_N 175
  1436. #define P3_LINES_BIAS_P 0x3EFFFFFF
  1437. #define P3_LINES_BIAS_N 0x3EFEB600
  1438. //
  1439. // GLINT DMA definitions
  1440. //
  1441. #define IOCTL_VIDEO_QUERY_NUM_DMA_BUFFERS \
  1442. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD0, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1443. #define IOCTL_VIDEO_QUERY_DMA_BUFFERS \
  1444. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD1, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1445. #define IOCTL_VIDEO_QUERY_DEVICE_INFO \
  1446. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD2, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1447. #define IOCTL_VIDEO_MAP_INTERRUPT_CMD_BUF \
  1448. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD3, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1449. #define IOCTL_VIDEO_QUERY_REGISTRY_DWORD \
  1450. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD5, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1451. #define IOCTL_VIDEO_REG_SAVE_GAMMA_LUT \
  1452. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1453. #define IOCTL_VIDEO_REG_RETRIEVE_GAMMA_LUT \
  1454. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1455. #define IOCTL_VIDEO_QUERY_GENERAL_DMA_BUFFER \
  1456. CTL_CODE(FILE_DEVICE_VIDEO, 0x3DD9, METHOD_BUFFERED, FILE_ANY_ACCESS)
  1457. // structure definitions passed in by the application for mapping and
  1458. // unmapping DMA buffers.
  1459. //
  1460. typedef struct _DMA_NUM_BUFFERS {
  1461. ULONG NumBuffers;
  1462. ULONG BufferInformationLength;
  1463. } DMA_NUM_BUFFERS, *PDMA_NUM_BUFFERS;
  1464. typedef struct _QUERY_DMA_BUFFERS {
  1465. LARGE_INTEGER physAddr; // physical address of DMA buffer
  1466. PVOID virtAddr; // mapped virtual address
  1467. ULONG size; // size in bytes
  1468. ULONG flags;
  1469. } QUERY_DMA_BUFFERS, *PQUERY_DMA_BUFFERS;
  1470. // values for flags word
  1471. #define DMA_BUFFER_INUSE 0x1
  1472. // functions to get and free DMA buffers
  1473. VOID FreeDMABuffer(PVOID physAddr);
  1474. LONG GetFreeDMABuffer(PQUERY_DMA_BUFFERS dmaBuf);
  1475. // Generic locling structure/interface that enables arbitrary buffers
  1476. // to be locked/unlocked for accessing.
  1477. typedef struct _glint_lockedmem_ {
  1478. struct _MDL *pMdl;
  1479. ULONG sizeBytes;
  1480. PVOID bufferPtr;
  1481. ULONG accessType;
  1482. ULONG physicalAddress;
  1483. ULONG result;
  1484. } GLINT_LOCKMEM_REC, *PGLINT_LOCKMEM_PTR;
  1485. // Routine to support the obtaining of a physical address from a virtual
  1486. // address
  1487. typedef struct _glint_physaddr_ {
  1488. PVOID virtualAddress;
  1489. ULONG physicalAddress;
  1490. } GLINT_PHYSADDR_REC, *PGLINT_PHYSADDR_PTR;
  1491. // definitions for DMA transfers
  1492. #define INPUT_DMA 0
  1493. #define OUTPUT_DMA 1
  1494. typedef struct DMA_Transfer_Buffer
  1495. {
  1496. VOID *pv;
  1497. ULONG cb;
  1498. ULONG DmaDirection;
  1499. }
  1500. DMAXFERBFRINFO;
  1501. // structure definitions for the file handle mapping ioctl
  1502. //
  1503. typedef struct _GLINT_MAP_FILE_HANDLE {
  1504. ULONG Size;
  1505. HANDLE fHandle;
  1506. } GLINT_MAP_FILE_HANDLE, *PGLINT_MAP_FILE_HANDLE;
  1507. typedef struct _GLINT_UNMAP_FILE_HANDLE {
  1508. HANDLE fHandle;
  1509. PVOID pv;
  1510. } GLINT_UNMAP_FILE_HANDLE, *PGLINT_UNMAP_FILE_HANDLE;
  1511. // structure for the user memory locking ioctls
  1512. typedef struct
  1513. {
  1514. void *pvBfr;
  1515. ULONG cbBfr;
  1516. ULONG hMem;
  1517. }
  1518. LOCKEDUSERMEM;
  1519. //
  1520. // registry variable names
  1521. //
  1522. #define REG_NUMBER_OF_SCREEN_BUFFERS L"DoubleBuffer.NumberOfBuffers"
  1523. extern GFNXCOPYD vGlintCopyBltBypassDownloadXlate8bpp;
  1524. // function declarations
  1525. //
  1526. extern BOOL bInitializeGlint(PPDEV);
  1527. extern BOOL bAllocateGlintInfo(PPDEV ppdev);
  1528. extern VOID vDisableGlint(PPDEV);
  1529. extern VOID vAssertModeGlint(PPDEV, BOOL);
  1530. extern BOOL bGlintQueryRegistryValueUlong(PPDEV, LPWSTR, PULONG);
  1531. extern VOID vGlintChangeFBDepth(PPDEV, ULONG);
  1532. extern VOID vGlintInitializeDMA(PPDEV);
  1533. extern VOID vSetNewGammaValue(PPDEV ppdev, ULONG ulgvFIX16_16, BOOL waitVBlank);
  1534. extern BOOL bInstallGammaLUT(PPDEV ppdev, PVIDEO_CLUT pScreenClut, BOOL waitVBlank);
  1535. #define GLINT_ENABLE_OVERLAY 1
  1536. #define GLINT_DISABLE_OVERLAY 0
  1537. //
  1538. // Externs/Defines from Pointer.c
  1539. // ==============================
  1540. //
  1541. // Hardware pointer caching functions/macros.
  1542. //
  1543. extern VOID HWPointerCacheInit (HWPointerCache * ptrCache);
  1544. extern VOID HWPointerCacheInvalidate (HWPointerCache * ptrCache);
  1545. #define HWPointerCacheInvalidate(ptrCache) (ptrCache)->ptrCacheInUseCount = 0
  1546. extern LONG HWPointerCacheCheckAndAdd (HWPointerCache * ptrCache, ULONG cx,
  1547. ULONG cy, LONG lDelta, BYTE * scan0, BOOL * isCached);
  1548. extern BYTE gajMask[];
  1549. //
  1550. // The following structures and macros define the memory map for the GLINT
  1551. // control registers. We don't use this memory map to access GLINT registers
  1552. // since on Alpha machines we want to precompute the addresses. So we do
  1553. // a TRANSLATE_ADDR_ULONG on all the addresses here and save them into a
  1554. // GlintRegAddrRec. We use that to obtain the addresses for the different
  1555. // registers.
  1556. typedef struct {
  1557. ULONG reg;
  1558. ULONG pad;
  1559. } RAMDAC_REG;
  1560. // macros to add padding words to the structures. For the core registers we use
  1561. // the tag ids when specifying the pad. So we must multiply by 8 to get a byte
  1562. // pad. We need to add an id to make each pad field in the struct unique. The id
  1563. // is irrelevant as long as it's different from every other id used in the same
  1564. // struct. It's a pity pad##__LINE__ doesn't work.
  1565. //
  1566. #define PAD(id, n) UCHAR pad##id[n]
  1567. #define PADRANGE(id, n) PAD(id, (n)-sizeof(GLINT_REG))
  1568. #define PADCORERANGE(id, n) PADRANGE(id, (n)<<3)
  1569. // GLINT registers are 32 bits wide and live on 64-bit boundaries.
  1570. typedef struct {
  1571. ULONG reg;
  1572. ULONG pad;
  1573. } GLINT_REG;
  1574. //
  1575. // Map of the Core FIFO registers.
  1576. //
  1577. typedef struct _glint_core_regs {
  1578. // Major Group 0
  1579. GLINT_REG tag[__MaximumGlintTagValue+1];
  1580. } GlintCoreRegMap, *pGlintCoreRegMap;
  1581. //
  1582. // GLINT PCI Region 0 Address MAP:
  1583. //
  1584. // All registers are on 64-bit boundaries so we have to define a number of
  1585. // padding words. The number given in the coments are offsets from the start
  1586. // of the PCI region.
  1587. //
  1588. typedef struct _glint_region0_map {
  1589. // Control Status Registers:
  1590. GLINT_REG ResetStatus; // 0000h
  1591. GLINT_REG IntEnable; // 0008h
  1592. GLINT_REG IntFlags; // 0010h
  1593. GLINT_REG InFIFOSpace; // 0018h
  1594. GLINT_REG OutFIFOWords; // 0020h
  1595. GLINT_REG DMAAddress; // 0028h
  1596. GLINT_REG DMACount; // 0030h
  1597. GLINT_REG ErrorFlags; // 0038h
  1598. GLINT_REG VClkCtl; // 0040h
  1599. GLINT_REG TestRegister; // 0048h
  1600. union a0 {
  1601. // GLINT
  1602. struct b0 {
  1603. GLINT_REG Aperture0; // 0050h
  1604. GLINT_REG Aperture1; // 0058h
  1605. };
  1606. // PERMEDIA
  1607. struct b1 {
  1608. GLINT_REG ApertureOne; // 0050h
  1609. GLINT_REG ApertureTwo; // 0058h
  1610. };
  1611. };
  1612. GLINT_REG DMAControl; // 0060h
  1613. GLINT_REG DisconnectControl; // 0068h
  1614. // PERMEDIA only
  1615. GLINT_REG ChipConfig; // 0070h
  1616. // P2 only
  1617. GLINT_REG AGPControl; // 0078h
  1618. GLINT_REG OutDMAAddress; // 0080h
  1619. GLINT_REG OutDMACount; // 0088h // P3: FeedbackCount
  1620. PADRANGE(2, 0xA0-0x88);
  1621. GLINT_REG ByDMAAddress; // 00A0h
  1622. PADRANGE(201, 0xB8-0xA0);
  1623. GLINT_REG ByDMAStride; // 00B8h
  1624. GLINT_REG ByDMAMemAddr; // 00C0h
  1625. GLINT_REG ByDMASize; // 00C8h
  1626. GLINT_REG ByDMAByteMask; // 00D0h
  1627. GLINT_REG ByDMAControl; // 00D8h
  1628. PADRANGE(202, 0xE8-0xD8);
  1629. GLINT_REG ByDMAComplete; // 00E8h
  1630. PADRANGE(203, 0x108-0xE8);
  1631. GLINT_REG TextureDownloadControl; // 0108h
  1632. PADRANGE(204, 0x200-0x108);
  1633. GLINT_REG TestInputControl; // 0200h
  1634. GLINT_REG TestInputRdy; // 0208h
  1635. GLINT_REG TestOutputControl; // 0210h
  1636. GLINT_REG TestOutputRdy; // 0218h
  1637. PADRANGE(205, 0x300-0x218);
  1638. GLINT_REG PXRXByAperture1Mode; // 0300h
  1639. GLINT_REG PXRXByAperture1Stride; // 0308h
  1640. GLINT_REG PXRXByAperture1YStart; // 0310h
  1641. GLINT_REG PXRXByAperture1UStart; // 0318h
  1642. GLINT_REG PXRXByAperture1VStart; // 0320h
  1643. GLINT_REG PXRXByAperture2Mode; // 0328h
  1644. GLINT_REG PXRXByAperture2Stride; // 0330h
  1645. GLINT_REG PXRXByAperture2YStart; // 0338h
  1646. GLINT_REG PXRXByAperture2UStart; // 0340h
  1647. GLINT_REG PXRXByAperture2VStart; // 0348h
  1648. GLINT_REG PXRXByDMAReadMode; // 0350h
  1649. GLINT_REG PXRXByDMAReadStride; // 0358h
  1650. GLINT_REG PXRXByDMAReadYStart; // 0360h
  1651. GLINT_REG PXRXByDMAReadUStart; // 0368h
  1652. GLINT_REG PXRXByDMAReadVStart; // 0370h
  1653. GLINT_REG PXRXByDMAReadCommandBase; // 0378h
  1654. GLINT_REG PXRXByDMAReadCommandCount; // 0380h
  1655. GLINT_REG PXRXByDMAWriteMode; // 0388h
  1656. GLINT_REG PXRXByDMAWriteStride; // 0390h
  1657. GLINT_REG PXRXByDMAWriteYStart; // 0398h
  1658. GLINT_REG PXRXByDMAWriteUStart; // 03A0h
  1659. GLINT_REG PXRXByDMAWriteVStart; // 03A8h
  1660. GLINT_REG PXRXByDMAWriteCommandBase; // 03B0h
  1661. GLINT_REG PXRXByDMAWriteCommandCount; // 03B8h
  1662. PADRANGE(206, 0x800-0x3B8);
  1663. // GLINTdelta registers. Registers with the same functionality as on GLINT
  1664. // are at the same offset. XXX are not real registers.
  1665. // NB. all non-XXX registers are also Gamma registers
  1666. //
  1667. GLINT_REG DeltaReset; // 0800h
  1668. GLINT_REG DeltaIntEnable; // 0808h
  1669. GLINT_REG DeltaIntFlags; // 0810h
  1670. GLINT_REG DeltaInFIFOSpaceXXX; // 0818h
  1671. GLINT_REG DeltaOutFIFOWordsXXX; // 0820h
  1672. GLINT_REG DeltaDMAAddressXXX; // 0828h
  1673. GLINT_REG DeltaDMACountXXX; // 0830h
  1674. GLINT_REG DeltaErrorFlags; // 0838h
  1675. GLINT_REG DeltaVClkCtlXXX; // 0840h
  1676. GLINT_REG DeltaTestRegister; // 0848h
  1677. GLINT_REG DeltaAperture0XXX; // 0850h
  1678. GLINT_REG DeltaAperture1XXX; // 0858h
  1679. GLINT_REG DeltaDMAControlXXX; // 0860h
  1680. GLINT_REG DeltaDisconnectControl; // 0868h
  1681. // GLINTgamma registers
  1682. //
  1683. GLINT_REG GammaChipConfig; // 0870h
  1684. GLINT_REG GammaCSRAperture; // 0878h
  1685. PADRANGE(3, 0x0c00-0x878);
  1686. GLINT_REG GammaPageTableAddr; // 0c00h
  1687. GLINT_REG GammaPageTableLength; // 0c08h
  1688. PADRANGE(301, 0x0c38-0x0c08);
  1689. GLINT_REG GammaDelayTimer; // 0c38h
  1690. GLINT_REG GammaCommandMode; // 0c40h
  1691. GLINT_REG GammaCommandIntEnable; // 0c48h
  1692. GLINT_REG GammaCommandIntFlags; // 0c50h
  1693. GLINT_REG GammaCommandErrorFlags; // 0c58h
  1694. GLINT_REG GammaCommandStatus; // 0c60h
  1695. GLINT_REG GammaCommandFaultingAddr; // 0c68h
  1696. GLINT_REG GammaVertexFaultingAddr; // 0c70h
  1697. PADRANGE(302, 0x0c88-0x0c70);
  1698. GLINT_REG GammaWriteFaultingAddr; // 0c88h
  1699. PADRANGE(303, 0x0c98-0x0c88);
  1700. GLINT_REG GammaFeedbackSelectCount; // 0c98h
  1701. PADRANGE(304, 0x0cb8-0x0c98);
  1702. GLINT_REG GammaProcessorMode; // 0cb8h
  1703. PADRANGE(305, 0x0d00-0x0cb8);
  1704. GLINT_REG GammaVGAShadow; // 0d00h
  1705. GLINT_REG GammaMultiGLINTAperture; // 0d08h
  1706. GLINT_REG GammaMultiGLINT1; // 0d10h
  1707. GLINT_REG GammaMultiGLINT2; // 0d18h
  1708. PADRANGE(306, 0x0f00-0x0d18);
  1709. GLINT_REG GammaSerialAccess; // 0f00h
  1710. PADRANGE(307, 0x1000-0x0f00);
  1711. // Localbuffer Registers
  1712. union x0 { // 1000h
  1713. GLINT_REG LBMemoryCtl; // GLINT
  1714. GLINT_REG Reboot; // PERMEDIA
  1715. };
  1716. GLINT_REG LBMemoryEDO; // 1008h
  1717. // PXRX Memory control registers
  1718. GLINT_REG MemScratch; // 1010h
  1719. GLINT_REG LocalMemCaps; // 1018h
  1720. GLINT_REG LocalMemTiming; // 1020h
  1721. GLINT_REG LocalMemControl; // 1028h
  1722. GLINT_REG LocalMemRefresh; // 1030h
  1723. GLINT_REG LocalMemPowerDown; // 1038h
  1724. // PERMEDIA only
  1725. GLINT_REG MemControl; // 1040h
  1726. PADRANGE(5, 0x1068-0x1040);
  1727. GLINT_REG LocalMemProfileMask0; // 1068h
  1728. GLINT_REG LocalMemProfileCount0; // 1070h
  1729. GLINT_REG LocalMemProfileMask1; // 1078h
  1730. GLINT_REG BootAddress; // 1080h // [= LocalMemProfileCount1 on PxRx]
  1731. PADRANGE(6, 0x10C0-0x1080);
  1732. GLINT_REG MemConfig; // 10C0h
  1733. PADRANGE(7, 0x1100-0x10C0);
  1734. GLINT_REG BypassWriteMask; // 1100h
  1735. PADRANGE(8, 0x1140-0x1100);
  1736. GLINT_REG FramebufferWriteMask; // 1140h
  1737. PADRANGE(9, 0x1180-0x1140);
  1738. GLINT_REG Count; // 1180h
  1739. PADRANGE(10, 0x1800-0x1180);
  1740. // Framebuffer Registers
  1741. GLINT_REG FBMemoryCtl; // 1800h
  1742. GLINT_REG FBModeSel; // 1808h
  1743. GLINT_REG FBGCWrMask; // 1810h
  1744. GLINT_REG FBGCColorMask; // 1818h
  1745. PADRANGE(11, 0x2000-0x1818);
  1746. // Graphics Core FIFO Interface
  1747. GLINT_REG FIFOInterface; // 2000h
  1748. PADRANGE(12, 0x3000-0x2000);
  1749. // Internal Video Registers
  1750. union x1 {
  1751. // GLINT
  1752. struct s1 {
  1753. GLINT_REG VTGHLimit; // 3000h
  1754. GLINT_REG VTGHSyncStart; // 3008h
  1755. GLINT_REG VTGHSyncEnd; // 3010h
  1756. GLINT_REG VTGHBlankEnd; // 3018h
  1757. GLINT_REG VTGVLimit; // 3020h
  1758. GLINT_REG VTGVSyncStart; // 3028h
  1759. GLINT_REG VTGVSyncEnd; // 3030h
  1760. GLINT_REG VTGVBlankEnd; // 3038h
  1761. GLINT_REG VTGHGateStart; // 3040h
  1762. GLINT_REG VTGHGateEnd; // 3048h
  1763. GLINT_REG VTGVGateStart; // 3050h
  1764. GLINT_REG VTGVGateEnd; // 3058h
  1765. GLINT_REG VTGPolarity; // 3060h
  1766. GLINT_REG VTGFrameRowAddr; // 3068h
  1767. GLINT_REG VTGVLineNumber; // 3070h
  1768. GLINT_REG VTGSerialClk; // 3078h
  1769. GLINT_REG VTGModeCtl; // 3080h
  1770. };
  1771. // PERMEDIA
  1772. struct s2 {
  1773. GLINT_REG ScreenBase; // 3000h
  1774. GLINT_REG ScreenStride; // 3008h
  1775. GLINT_REG HTotal; // 3010h
  1776. GLINT_REG HgEnd; // 3018h
  1777. GLINT_REG HbEnd; // 3020h
  1778. GLINT_REG HsStart; // 3028h
  1779. GLINT_REG HsEnd; // 3030h
  1780. GLINT_REG VTotal; // 3038h
  1781. GLINT_REG VbEnd; // 3040h
  1782. GLINT_REG VsStart; // 3048h
  1783. GLINT_REG VsEnd; // 3050h
  1784. GLINT_REG VideoControl; // 3058h
  1785. GLINT_REG InterruptLine; // 3060h
  1786. GLINT_REG DDCData; // 3068h
  1787. GLINT_REG LineCount; // 3070h
  1788. GLINT_REG FifoControl ; // 3078h
  1789. GLINT_REG ScreenBaseRight; // 3080h
  1790. };
  1791. };
  1792. PADRANGE(13, 0x4000-0x3080);
  1793. // External Video Control Registers
  1794. // Need to cast this to a struct for a particular video generator
  1795. GLINT_REG ExternalVideo; // 4000h
  1796. PADRANGE(14, 0x5000-0x4000);
  1797. // P2 specific registers
  1798. union x11 {
  1799. GLINT_REG ExternalP2Ramdac; // 5000h
  1800. GLINT_REG DemonProDWAndStatus; // 5000h - Pro
  1801. };
  1802. PADRANGE(15, 0x5800-0x5000);
  1803. GLINT_REG VSConfiguration; // 5800h
  1804. PADRANGE(16, 0x6000-0x5800);
  1805. union x2 {
  1806. struct s3 {
  1807. GLINT_REG RacerDoubleWrite; // 6000h
  1808. GLINT_REG RacerBankSelect; // 6008h
  1809. };
  1810. struct s4 {
  1811. // the following array is actually 1024 bytes long
  1812. UCHAR PermediaVgaCtrl[2*sizeof(GLINT_REG)];
  1813. };
  1814. };
  1815. PADRANGE(17, 0x7000-0x6008);
  1816. GLINT_REG DemonProUBufB; // 7000h - Pro
  1817. PADRANGE(18, 0x8000-0x7000);
  1818. // Graphics Core Registers
  1819. GlintCoreRegMap coreRegs; // 8000h
  1820. } GlintControlRegMap, *pGlintControlRegMap;
  1821. //
  1822. // DisconnectControl bits
  1823. //
  1824. #define DISCONNECT_INPUT_FIFO_ENABLE 0x1
  1825. #define DISCONNECT_OUTPUT_FIFO_ENABLE 0x2
  1826. #define DISCONNECT_INOUT_ENABLE (DISCONNECT_INPUT_FIFO_ENABLE | \
  1827. DISCONNECT_OUTPUT_FIFO_ENABLE)
  1828. #define DISCONNECT_INOUT_DISABLE 0x0
  1829. //
  1830. // Delta bit definitions
  1831. //
  1832. #define DELTA_BROADCAST_TO_CHIP(n) (1 << (n))
  1833. #define DELTA_BROADCAST_TO_BOTH_CHIPS (DELTA_BROADCAST_TO_CHIP(0) | \
  1834. DELTA_BROADCAST_TO_CHIP(1))
  1835. //
  1836. // Multi TX
  1837. //
  1838. #define GLINT_OWN_SCANLINE_0 (0 << 2)
  1839. #define GLINT_OWN_SCANLINE_1 (1 << 2)
  1840. #define GLINT_OWN_SCANLINE_2 (2 << 2)
  1841. #define GLINT_OWN_SCANLINE_3 (3 << 2)
  1842. #define GLINT_SCANLINE_INTERVAL_1 (0 << 0)
  1843. #define GLINT_SCANLINE_INTERVAL_2 (1 << 0)
  1844. #define GLINT_SCANLINE_INTERVAL_4 (2 << 0)
  1845. #define GLINT_SCANLINE_INTERVAL_8 (3 << 0)
  1846. #define SCANLINE_OWNERSHIP_EVEN_SCANLINES (GLINT_OWN_SCANLINE_0 | GLINT_SCANLINE_INTERVAL_2)
  1847. #define SCANLINE_OWNERSHIP_ODD_SCANLINES (GLINT_OWN_SCANLINE_1 | GLINT_SCANLINE_INTERVAL_2)
  1848. // Glint Interrupt Control Bits
  1849. //
  1850. // InterruptEnable register
  1851. #define INTR_DISABLE_ALL 0x00
  1852. #define INTR_ENABLE_DMA 0x01
  1853. #define INTR_ENABLE_SYNC 0x02
  1854. #define INTR_ENABLE_EXTERNAL 0x04
  1855. #define INTR_ENABLE_ERROR 0x08
  1856. #define INTR_ENABLE_VBLANK 0x10
  1857. #define INTR_ENABLE_TEXTURE_FAULT (1 << 6)
  1858. // InterruptFlags register
  1859. #define INTR_DMA_SET 0x01
  1860. #define INTR_SYNC_SET 0x02
  1861. #define INTR_EXTERNAL_SET 0x04
  1862. #define INTR_ERROR_SET 0x08
  1863. #define INTR_VBLANK_SET 0x10
  1864. #define INTR_TEXTURE_FAULT_SET (1 << 6)
  1865. #define INTR_CLEAR_ALL 0x1f
  1866. #define INTR_CLEAR_DMA 0x01
  1867. #define INTR_CLEAR_SYNC 0x02
  1868. #define INTR_CLEAR_EXTERNAL 0x04
  1869. #define INTR_CLEAR_ERROR 0x08
  1870. #define INTR_CLEAR_VBLANK 0x10
  1871. // Gamma Interrupt Control Bits
  1872. //
  1873. // CommandIntEnable register
  1874. #define GAMMA_INTR_DISABLE_ALL 0x0000
  1875. #define GAMMA_INTR_QUEUED_DMA 0x0001
  1876. #define GAMMA_INTR_OUTPUT_DMA 0x0002
  1877. #define GAMMA_INTR_COMMAND 0x0004
  1878. #define GAMMA_INTR_TIMER 0x0008
  1879. #define GAMMA_INTR_ERROR 0x0010
  1880. #define GAMMA_INTR_CBFR_TIMEOUT 0x0020
  1881. #define GAMMA_INTR_CBFR_SUSPEND 0x0040
  1882. #define GAMMA_INTR_TEXDOWNLD 0x0080
  1883. #define GAMMA_INTR_PF_COMMAND 0x0100
  1884. #define GAMMA_INTR_PF_VERTEX 0x0200
  1885. #define GAMMA_INTR_PF_FACENORM 0x0400
  1886. #define GAMMA_INTR_PF_INDEX 0x0800
  1887. #define GAMMA_INTR_PF_WRITE 0x1000
  1888. #define GAMMA_INTR_PF_TEXTURE 0x2000
  1889. // CommandIntFlags register - uses the same defines as CommandIntEnable
  1890. #define GAMMA_INTR_CLEAR_ALL 0x3fff
  1891. // Gamma Command Interrupts
  1892. #define INTR_DISABLE_GAMMA_ALL 0
  1893. #define INTR_ENABLE_GAMMA_QUEUED_DMA (1 << 0)
  1894. #define INTR_ENABLE_GAMMA_OUTPUT_DMA (1 << 1)
  1895. #define INTR_ENABLE_GAMMA_COMMAND (1 << 2)
  1896. #define INTR_ENABLE_GAMMA_TIMER (1 << 3)
  1897. #define INTR_ENABLE_GAMMA_COMMAND_ERROR (1 << 4)
  1898. #define INTR_ENABLE_GAMMA_PAGE_FAULT (1 << 8)
  1899. #define INTR_ENABLE_GAMMA_VERTEX_FAULT (1 << 9)
  1900. #define INTR_ENABLE_GAMMA_WRITE_FAULT (1 << 12)
  1901. #define INTR_GAMMA_QUEUED_DMA_SET (1 << 0)
  1902. #define INTR_GAMMA_OUTPUT_DMA_SET (1 << 1)
  1903. #define INTR_GAMMA_COMMAND_SET (1 << 2)
  1904. #define INTR_GAMMA_TIMER_SET (1 << 3)
  1905. #define INTR_GAMMA_COMMAND_ERROR_SET (1 << 4)
  1906. #define INTR_GAMMA_PAGE_FAULT_SET (1 << 8)
  1907. #define INTR_GAMMA_VERTEX_FAULT_SET (1 << 9)
  1908. #define INTR_GAMMA_WRITE_FAULT_SET (1 << 12)
  1909. #define INTR_CLEAR_GAMMA_QUEUED_DMA (1 << 0)
  1910. #define INTR_CLEAR_GAMMA_OUTPUT_DMA (1 << 1)
  1911. #define INTR_CLEAR_GAMMA_COMMAND (1 << 2)
  1912. #define INTR_CLEAR_GAMMA_TIMER (1 << 3)
  1913. #define INTR_CLEAR_GAMMA_COMMAND_ERROR (1 << 4)
  1914. #define INTR_CLEAR_GAMMA_PAGE_FAULT (1 << 8)
  1915. #define INTR_CLEAR_GAMMA_VERTEX_FAULT (1 << 9)
  1916. #define INTR_CLEAR_GAMMA_WRITE_FAULT (1 << 12)
  1917. // Gamma Command Status
  1918. #define GAMMA_STATUS_COMMAND_DMA_BUSY (1 << 0)
  1919. #define GAMMA_STATUS_OUTPUT_DMA_BUSY (1 << 1)
  1920. #define GAMMA_STATUS_INPUT_FIFO_EMPTY (1 << 2)
  1921. // Gamma Command Mode
  1922. #define GAMMA_COMMAND_MODE_QUEUED_DMA (1 << 0)
  1923. #define GAMMA_COMMAND_MODE_LOGICAL_ADDRESSING (1 << 2)
  1924. #define GAMMA_COMMAND_MODE_ABORT_OUTPUT_DMA (1 << 3)
  1925. #define GAMMA_COMMAND_MODE_ABORT_INPUT_DMA (1 << 6)
  1926. // interrupt status bits
  1927. typedef enum {
  1928. DMA_INTERRUPT_AVAILABLE = 0x01, // can use DMA interrupts
  1929. VBLANK_INTERRUPT_AVAILABLE = 0x02, // can use VBLANK interrupts
  1930. SUSPEND_DMA_TILL_VBLANK = 0x04, // Stop doing DMA till after next VBLANK
  1931. DIRECTDRAW_VBLANK_ENABLED = 0x08, // Set flag for DirectDraw on VBLANK
  1932. PXRX_SEND_ON_VBLANK_ENABLED = 0x10, // Set flag for PXRX DMA on VBLANK
  1933. PXRX_CHECK_VFIFO_IN_VBLANK = 0x20, // Set flag to check VFIFO underruns in VBLANK (vblanks must be permanently enabled)
  1934. } INTERRUPT_CONTROL;
  1935. // commands to the interrupt controller on the next VBLANK
  1936. typedef enum {
  1937. NO_COMMAND = 0,
  1938. COLOR_SPACE_BUFFER_0,
  1939. COLOR_SPACE_BUFFER_1,
  1940. GLINT_RACER_BUFFER_0,
  1941. GLINT_RACER_BUFFER_1
  1942. } VBLANK_CONTROL_COMMAND;
  1943. // we manage a queue of DMA buffers that are to be loaded under interrupt control
  1944. // each entry has a physical address and a count to be loaded into GLINT.
  1945. //
  1946. typedef struct _glint_dma_queue {
  1947. ULONG command;
  1948. ULONG address;
  1949. ULONG count;
  1950. } DMABufferQueue;
  1951. // Display driver structure for 'general use'.
  1952. typedef struct _pointer_interrupt_control
  1953. {
  1954. volatile ULONG bDisplayDriverHasAccess;
  1955. volatile ULONG bMiniportHasAccess;
  1956. volatile ULONG bInterruptPending;
  1957. volatile ULONG bHidden;
  1958. volatile ULONG CursorMode;
  1959. volatile ULONG x, y;
  1960. } PTR_INTR_CTL;
  1961. // Display driver structure for 'pointer use'.
  1962. typedef struct _general_interrupt_control
  1963. {
  1964. volatile ULONG bDisplayDriverHasAccess;
  1965. volatile ULONG bMiniportHasAccess;
  1966. } GEN_INTR_CTL;
  1967. //
  1968. // The volatile fields are the ones that the interrupt handler can change
  1969. // under our feet. But, for example, note that the frontIndex is not
  1970. // volatile since the ISR can only read this.
  1971. //
  1972. typedef struct _glint_interrupt_control {
  1973. // contains various status bits. ** MUST BE THE FIRST FIELD **
  1974. volatile INTERRUPT_CONTROL Control;
  1975. // profiling counters for GLINT busy time
  1976. ULONG PerfCounterShift;
  1977. ULONG BusyTime; // at DMA interrupt add (TimeNow-StartTime) to this
  1978. ULONG StartTime; // set this when DMACount is loaded
  1979. ULONG IdleTime;
  1980. ULONG IdleStart;
  1981. // commands to perform on the next VBLANK
  1982. volatile VBLANK_CONTROL_COMMAND VBCommand;
  1983. // flag to indicate whether we expect another DMA interrupt
  1984. volatile ULONG InterruptPending;
  1985. volatile ULONG DDRAW_VBLANK; // flag for DirectDraw to indicate that a VBLANK occured.
  1986. volatile ULONG bOverlayEnabled; // TRUE if the overlay is on at all
  1987. volatile ULONG bVBLANKUpdateOverlay; // TRUE if the overlay needs to be updated by the VBLANK routine.
  1988. volatile ULONG VBLANKUpdateOverlayWidth; // overlay width (updated in vblank)
  1989. volatile ULONG VBLANKUpdateOverlayHeight; // overlay height (updated in vblank)
  1990. // Volatile structures are required to enforce single-threading
  1991. // We need 1 for general display use and 1 for pointer use, because
  1992. // the pointer is synchronous.
  1993. volatile PTR_INTR_CTL Pointer;
  1994. volatile GEN_INTR_CTL General;
  1995. // dummy DMA buffer to cause an interrupt but transfer no data
  1996. ULONG dummyDMAAddress;
  1997. ULONG dummyDMACount;
  1998. // index offsets into the queue for the front, back and end. Using separate
  1999. // front and back offsets allows the display driver to add and the interrupt
  2000. // controller to remove entries without a need for locking code.
  2001. ULONG frontIndex;
  2002. volatile ULONG backIndex;
  2003. ULONG endIndex;
  2004. ULONG maximumIndex;
  2005. // For PXRX 2D DMA:
  2006. volatile ULONG lastAddr;
  2007. PXRXdmaInfo pxrxDMA;
  2008. // array to contain the DMA queue
  2009. DMABufferQueue dmaQueue[1];
  2010. // DO NOT PUT ANYTHING AFTER THIS
  2011. } INTERRUPT_CONTROL_BLOCK, *PINTERRUPT_CONTROL_BLOCK;
  2012. /***** RACER FULL SCREEN DOUBLE BUFFERING MACROS ***********
  2013. *
  2014. * These macros were invented because some boards, such as
  2015. * Omnicomp ones, have their bank-switch registers in different places.
  2016. *
  2017. * The macros are:
  2018. *
  2019. * SET_RACER_BANKSELECT() - Sets the bank select register to be bank 0 or 1.
  2020. * GET_RACER_DOUBLEWRITE() - Returns 1 if double writes are enabled, else returns 0.
  2021. * SET_RACER_DOUBLEWRITE() - Sets the double write register to 0 or 1.
  2022. * IS_RACER_VARIANT_PRO16() - Returns TRUE if the board is an Omnicomp 3DemonPro16, RevC board.
  2023. */
  2024. // We define an Omnicomp 3Demon Pro 16 to be a card that has a 16MB framebuffer.
  2025. #define SIXTEEN_MEG (16*1024*1024)
  2026. #define IS_RACER_VARIANT_PRO16(ppdev) (glintInfo->deviceInfo.BoardId == OMNICOMP_3DEMONPRO)
  2027. //
  2028. // the following defines the offset to the External Video register which allows
  2029. // switching of the memory banks on a Glint Racer card.
  2030. //
  2031. #ifndef FIELD_OFFSET
  2032. #define FIELD_OFFSET(a, b) ((LONG)&(((a *)0)->b))
  2033. #endif
  2034. // The Omnicomp 3Demon Pro 16 board uses different registers to do it's bank switching.
  2035. #define DEMON_BANK_SELECT_OFFSET \
  2036. ((FIELD_OFFSET (GlintControlRegMap, DemonProUBufB)) - \
  2037. (FIELD_OFFSET (GlintControlRegMap, ExternalVideo)))
  2038. #define REAL_RACER_BANK_SELECT_OFFSET \
  2039. ((FIELD_OFFSET (GlintControlRegMap, RacerBankSelect)) - \
  2040. (FIELD_OFFSET (GlintControlRegMap, ExternalVideo)))
  2041. #define RACER_BANK_SELECT_OFFSET \
  2042. (IS_RACER_VARIANT_PRO16(ppdev) ? (DEMON_BANK_SELECT_OFFSET) : (REAL_RACER_BANK_SELECT_OFFSET))
  2043. #define SET_RACER_BANKSELECT(bufNo) { \
  2044. if (IS_RACER_VARIANT_PRO16(ppdev)) \
  2045. {WRITE_GLINT_CTRL_REG (DemonProUBufB, bufNo);} \
  2046. else \
  2047. {WRITE_GLINT_CTRL_REG (RacerBankSelect, bufNo);}\
  2048. }
  2049. #define GET_RACER_DOUBLEWRITE(onOffVal) { \
  2050. if (IS_RACER_VARIANT_PRO16(ppdev)) { \
  2051. READ_GLINT_CTRL_REG (DemonProDWAndStatus, onOffVal); \
  2052. } \
  2053. else \
  2054. {READ_GLINT_CTRL_REG (RacerDoubleWrite, onOffVal);} \
  2055. onOffVal &= 1 ; \
  2056. }
  2057. #define SET_RACER_DOUBLEWRITE(onOffVal) { \
  2058. if (IS_RACER_VARIANT_PRO16(ppdev)) \
  2059. {WRITE_GLINT_CTRL_REG (DemonProDWAndStatus, (onOffVal & 1));} \
  2060. else \
  2061. {WRITE_GLINT_CTRL_REG (RacerDoubleWrite, (onOffVal & 1));} \
  2062. }
  2063. /***** END OF RACER MACROS ***********/
  2064. #define MX_EXTRA_WAIT 1
  2065. #define GLINT_MX_SYNC \
  2066. { \
  2067. if (GLINT_MX) \
  2068. /*LD_GLINT_FIFO(__GlintTagFBBlockColor, glintInfo->FBBlockColor); */\
  2069. LD_GLINT_FIFO(__GlintTagSync, 0); \
  2070. }
  2071. // DMAControl register setup, when using AGP DMA (p32 of Gamma HRM).
  2072. #define DMA_CONTROL_USE_AGP 0xE
  2073. #define DMA_CONTROL_USE_PCI 0x0
  2074. #if USE_LD_GLINT_FIFO_FUNCTION
  2075. # undef LD_GLINT_FIFO
  2076. # define LD_GLINT_FIFO(t, d) do { loadGlintFIFO( glintInfo, (ULONG) t, (ULONG) d ); } while(0)
  2077. typedef void (* LoadGlintFIFO)( GlintDataPtr, ULONG, ULONG );
  2078. extern LoadGlintFIFO loadGlintFIFO;
  2079. #endif
  2080. #if USE_SYNC_FUNCTION
  2081. # undef SYNC_WITH_GLINT_CHIP
  2082. # undef WAIT_DMA_COMPLETE
  2083. # define SYNC_WITH_GLINT_CHIP do { syncWithGlint(ppdev, glintInfo); } while(0)
  2084. # define WAIT_DMA_COMPLETE do { waitDMAcomplete(ppdev, glintInfo); } while(0)
  2085. void syncWithGlint( PPDEV ppdev, GlintDataPtr glintInfo );
  2086. void waitDMAcomplete( PPDEV ppdev, GlintDataPtr glintInfo );
  2087. #endif
  2088. #define SETUP_PPDEV_OFFSETS(ppdev, pdsurf) \
  2089. do \
  2090. { \
  2091. ppdev->DstPixelOrigin = pdsurf->poh->pixOffset; \
  2092. ppdev->DstPixelDelta = pdsurf->poh->lPixDelta; \
  2093. ppdev->xyOffsetDst = MAKEDWORD_XY(pdsurf->poh->x, pdsurf->poh->y); \
  2094. ppdev->xOffset = (pdsurf->poh->bDXManaged) ? 0 : pdsurf->poh->x; \
  2095. ppdev->bDstOffScreen = pdsurf->bOffScreen; \
  2096. \
  2097. if (glintInfo->currentCSbuffer != 0) { \
  2098. ULONG xAdjust = GLINT_BUFFER_OFFSET(1) % ppdev->cxMemory; \
  2099. ppdev->DstPixelOrigin += GLINT_BUFFER_OFFSET(1) - xAdjust; \
  2100. ppdev->xOffset += xAdjust; \
  2101. } \
  2102. } while(0);
  2103. #define SETUP_PPDEV_SRC_OFFSETS(ppdev, pdsurfSrc) \
  2104. do \
  2105. { \
  2106. ppdev->SrcPixelOrigin = pdsurfSrc->poh->pixOffset; \
  2107. ppdev->SrcPixelDelta = pdsurfSrc->poh->lPixDelta; \
  2108. ppdev->xyOffsetSrc = MAKEDWORD_XY(pdsurfSrc->poh->x, pdsurfSrc->poh->y); \
  2109. \
  2110. if (glintInfo->currentCSbuffer != 0) { \
  2111. ULONG xAdjust = GLINT_BUFFER_OFFSET(1) % ppdev->cxMemory; \
  2112. ppdev->SrcPixelOrigin += GLINT_BUFFER_OFFSET(1) - xAdjust; \
  2113. } \
  2114. } while(0)
  2115. #define SETUP_PPDEV_SRC_AND_DST_OFFSETS(ppdev, pdsurfSrc, pdsurfDst) \
  2116. do \
  2117. { \
  2118. ppdev->SrcPixelOrigin = pdsurfSrc->poh->pixOffset; \
  2119. ppdev->SrcPixelDelta = pdsurfSrc->poh->lPixDelta; \
  2120. ppdev->xyOffsetSrc = MAKEDWORD_XY(pdsurfSrc->poh->x, pdsurfSrc->poh->y); \
  2121. \
  2122. ppdev->DstPixelOrigin = pdsurfDst->poh->pixOffset; \
  2123. ppdev->DstPixelDelta = pdsurfDst->poh->lPixDelta; \
  2124. ppdev->xyOffsetDst = MAKEDWORD_XY(pdsurfDst->poh->x, pdsurfDst->poh->y); \
  2125. ppdev->xOffset = (pdsurfDst->poh->bDXManaged) ? 0 : pdsurfDst->poh->x; \
  2126. ppdev->bDstOffScreen = pdsurfDst->bOffScreen; \
  2127. \
  2128. if (glintInfo->currentCSbuffer != 0) { \
  2129. ULONG xAdjust = GLINT_BUFFER_OFFSET(1) % ppdev->cxMemory; \
  2130. ppdev->DstPixelOrigin += GLINT_BUFFER_OFFSET(1) - xAdjust; \
  2131. ppdev->SrcPixelOrigin += GLINT_BUFFER_OFFSET(1) - xAdjust; \
  2132. ppdev->xOffset += xAdjust; \
  2133. } \
  2134. } while(0)
  2135. #define GET_PPDEV_DST_OFFSETS(ppdev, PixOrigin, PixDelta, xyOffset, xOff, bOffScreen) \
  2136. do \
  2137. { \
  2138. PixOrigin = ppdev->DstPixelOrigin; \
  2139. PixDelta = ppdev->DstPixelDelta; \
  2140. xyOffset = ppdev->xyOffsetDst; \
  2141. xOff = ppdev->xOffset; \
  2142. bOffScreen = ppdev->bDstOffScreen; \
  2143. } while(0)
  2144. #define SET_PPDEV_DST_OFFSETS(ppdev, PixOrigin, PixDelta, xyOffset, xOff, bOffScreen) \
  2145. do \
  2146. { \
  2147. ppdev->DstPixelOrigin = PixOrigin; \
  2148. ppdev->DstPixelDelta = PixDelta; \
  2149. ppdev->xyOffsetDst = xyOffset; \
  2150. ppdev->xOffset = xOff; \
  2151. ppdev->bDstOffScreen = bOffScreen; \
  2152. } while(0)
  2153. #endif // _GLINT_H_