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.

634 lines
21 KiB

  1. /******************************Module*Header***********************************\
  2. *
  3. * *******************
  4. * * GDI SAMPLE CODE *
  5. * *******************
  6. *
  7. * Module Name: hw.h
  8. *
  9. * All the hardware defines and typedefs.
  10. *
  11. * Copyright (c) 1994-1998 3Dlabs Inc. Ltd. All rights reserved.
  12. * Copyright (c) 1995-1999 Microsoft Corporation. All rights reserved.
  13. *
  14. \******************************************************************************/
  15. #ifndef _HW_H_
  16. #define _HW_H_
  17. #include "p2def.h"
  18. //
  19. // Texture memory allocation macros and structures are in 3DPrivTx.h
  20. //
  21. //
  22. // Definition of handle to a memory region
  23. //
  24. typedef LONG HMEMREGION;
  25. typedef LONG HMEMCACHE;
  26. typedef enum
  27. {
  28. RESIDENCY_NOTLOADED,
  29. RESIDENCY_PERMANENT,
  30. RESIDENCY_TRANSIENT,
  31. RESIDENCY_HOST
  32. } MEM_MGR_RESIDENCY;
  33. //
  34. // Extern declarations
  35. //
  36. extern DWORD LogicopReadDest[]; // Indicates which logic ops need dest
  37. // read turned on
  38. extern DWORD ConfigReadDest[];
  39. extern UCHAR LBWidthBits[];
  40. //
  41. // Definition of counter data area for performance counters (PERFCTR)
  42. //
  43. extern PVOID pCounterBlock;
  44. //
  45. // Values for flags in HwDataRec
  46. //
  47. typedef enum
  48. {
  49. GLICAP_NT_CONFORMANT_LINES = 0x00000001, // draw NT conformant lines
  50. GLICAP_HW_WRITE_MASK = 0x00000002, // hardware planemasking
  51. };
  52. typedef int PERMEDIA2_CAPS;
  53. //
  54. // SCISSOR stuff
  55. //
  56. #define SCREEN_SCISSOR_DEFAULT (0 << 1)
  57. #define SCISSOR_MAX 2047 // Maximum scissor size in P2
  58. //
  59. // PCI device information. Used in an IOCTL return. Ensure this is the same
  60. // as in the miniport drivers permedia.h
  61. //
  62. typedef struct _Hw_Device_Info
  63. {
  64. ULONG SubsystemId;
  65. ULONG SubsystemVendorId;
  66. ULONG VendorId;
  67. ULONG DeviceId;
  68. ULONG RevisionId;
  69. ULONG DeltaRevId;
  70. ULONG GammaRevId;
  71. ULONG BoardId;
  72. ULONG LocalbufferLength;
  73. LONG LocalbufferWidth;
  74. ULONG ActualDacId;
  75. } Hw_Device_Info;
  76. typedef struct tagP2CtxtRec *P2CtxtPtr;
  77. typedef struct _hw_data
  78. {
  79. DWORD renderBits; // Saved render bits set by setup routines
  80. DWORD FBWriteMode; // Software copy of FBWriteMode register
  81. DWORD RasterizerMode; // Software copy of the rasterizer mode
  82. DWORD FBPacking; // Software copy of FBModeSel
  83. DWORD FBBlockColor; // Software copy of FBBlockColor (P1 only)
  84. DWORD TextureAddressMode; // Software copy of TextureAddressMode
  85. // (P2 only)
  86. DWORD TextureReadMode; // Software copy of TextureReadMode
  87. // (P2 only)
  88. ULONG currentCSbuffer; // Color space buffer being displayed
  89. PERMEDIA2_CAPS flags; // Various flags
  90. P2CtxtPtr pGDICtxt; // id of the display driver's context for
  91. // this board
  92. LONG PixelOffset; // Last DFB pixel offset
  93. ULONG PerfScaleShift;
  94. PVOID ContextTable; // Array of extant contexts
  95. P2CtxtPtr pCurrentCtxt; // id of this board's current context
  96. union
  97. {
  98. UCHAR _clutBuffer[MAX_CLUT_SIZE];
  99. VIDEO_CLUT gammaLUT; // Saved gamma LUT contents
  100. };
  101. //
  102. // PCI configuration id information
  103. //
  104. Hw_Device_Info deviceInfo;
  105. } HwDataRec, *HwDataPtr;
  106. #define TRANSLATE_ADDR_ULONG(a) (a) //TODO: should be removed in pointer.c
  107. //
  108. // If we have a sparsely mapped framebuffer then we use the xx_REGISTER_ULONG()
  109. // macros, otherwise we just access the framebuffer.
  110. //
  111. #define READ_SCREEN_ULONG(a)\
  112. ((ppdev->flCaps & CAPS_SPARSE_SPACE) ?\
  113. (READ_REGISTER_ULONG(a)) : *((ULONG volatile *)(a)))
  114. #define WRITE_SCREEN_ULONG(a,d)\
  115. ((ppdev->flCaps & CAPS_SPARSE_SPACE) ?\
  116. (WRITE_REGISTER_ULONG(a,d)) : (*((ULONG volatile *)(a)) = (d)))
  117. //
  118. // Generic macros to access Permedia 2 FIFO and non-FIFO control registers.
  119. // We do nothing sophisticated for the Alpha. We just MEMORY_BARRIER
  120. // everything.
  121. //
  122. #define LD_PERMEDIA_REG(x,y) \
  123. { \
  124. WRITE_REGISTER_ULONG(&(ppdev->pCtrlBase[x/sizeof(ULONG)]),y); \
  125. MEMORY_BARRIER();\
  126. }
  127. #define READ_PERMEDIA_REG(x) \
  128. READ_REGISTER_ULONG(&(ppdev->pCtrlBase[x/sizeof(ULONG)]))
  129. #define READ_PERMEDIA_FIFO_REG(uiTag, d) \
  130. ((d) = READ_REGISTER_ULONG(&(ppdev->pCoreBase[uiTag*2])))
  131. #define READ_FIFO_REG(uiTag)\
  132. READ_REGISTER_ULONG(&ppdev->pCoreBase[uiTag*2])
  133. //
  134. // Local variables for all functions that access PERMEDIA 2. Generally we
  135. // use PERMEDIA_DECL. Sometimes we have to split it up if ppdev isn't
  136. // passed into the routine.
  137. //
  138. #define PERMEDIA_DECL_VARS \
  139. HwDataPtr permediaInfo;
  140. #define PERMEDIA_DECL_INIT \
  141. permediaInfo = (HwDataPtr)(ppdev->permediaInfo);
  142. #define PERMEDIA_DECL \
  143. PERMEDIA_DECL_VARS; \
  144. PERMEDIA_DECL_INIT
  145. // TODO: move to debug???
  146. #if DBG
  147. VOID vCheckDefaultState(P2DMA * pP2dma);
  148. #define P2_CHECK_STATE vCheckDefaultState(ppdev->pP2dma)
  149. #else
  150. #define P2_CHECK_STATE
  151. #endif
  152. //
  153. // Pointer interrupts not enabled so just provide stub definitions
  154. //
  155. #define SYNCHRONOUS_WRITE_ULONG(var, value)
  156. #define SYNCHRONOUS_WRITE_INDIRECT_ULONG(pvar, value)
  157. #define GET_INTR_CMD_BLOCK_MUTEX
  158. #define RELEASE_INTR_CMD_BLOCK_MUTEX
  159. //
  160. // FIFO functions
  161. //
  162. #define MAX_P2_FIFO_ENTRIES 256
  163. #define P2_DEFAULT_FB_DEPTH P2_SET_FB_DEPTH(ppdev->cPelSize)
  164. #define P2DEPTH8 0
  165. #define P2DEPTH16 1
  166. #define P2DEPTH32 2
  167. //
  168. // External interface to the context switching code. The caller can allocate and
  169. // free a context or ask for a switch to a new context. vSwitchContext
  170. // should not be called except through the given macro. The macro assumes
  171. // that ppdev has been defined.
  172. //
  173. typedef enum
  174. {
  175. P2CtxtReadWrite,
  176. P2CtxtWriteOnly,
  177. P2CtxtUserFunc
  178. } P2CtxtType;
  179. P2CtxtPtr P2AllocateNewContext(PPDev ppdev,
  180. DWORD *pReglist,
  181. LONG lEntries,
  182. P2CtxtType dwCtxtType=P2CtxtReadWrite
  183. );
  184. VOID P2FreeContext (PPDev, P2CtxtPtr);
  185. VOID P2SwitchContext(PPDev, P2CtxtPtr);
  186. //
  187. // Macro used by display driver to validate its context
  188. //
  189. #define VALIDATE_GDI_CONTEXT \
  190. P2_VALIDATE_CONTEXT(permediaInfo->pGDICtxt)
  191. //
  192. // Useful macros not defined in standard Permedia 2 header files. Generally, for
  193. // speed we don't want to use the bitfield structures so we define the bit
  194. // shifts to get at the various fields.
  195. //
  196. #define INTtoFIXED(i) ((i) << 16) // int to 16.16 fixed format
  197. #define FIXEDtoINT(i) ((i) >> 16) // 16.16 fixed format to int
  198. #define INTofFIXED(i) ((i) & 0xffff0000) // int part of 16.16
  199. #define FRACTofFIXED(i) ((i) & 0xffff) // fractional part of 16.16
  200. #define FIXtoFIXED(i) ((i) << 12) // 12.4 to 16.16
  201. #define FIXtoINT(i) ((i) >> 4) // 28.4 to 28
  202. #define __PERMEDIA_CONSTANT_FB_WRITE (1 << (4+1))
  203. #define __COLOR_DDA_FLAT_SHADE (__PERMEDIA_ENABLE | \
  204. (__PERMEDIA_FLAT_SHADE_MODE << 1))
  205. #define __COLOR_DDA_GOURAUD_SHADE (__PERMEDIA_ENABLE | \
  206. (__PERMEDIA_GOURAUD_SHADE_MODE << 1))
  207. #define INVERT_BITMASK_BITS (1 << 1)
  208. #define BYTESWAP_BITMASK (3 << 7)
  209. #define FORCE_BACKGROUND_COLOR (1 << 6) // Permedia only
  210. //
  211. // Bits in the Render command
  212. //
  213. #define __RENDER_INCREASE_Y (1 << 22)
  214. #define __RENDER_INCREASE_X (1 << 21)
  215. #define __RENDER_VARIABLE_SPANS (1 << 18)
  216. #define __RENDER_REUSE_BIT_MASK (1 << 17)
  217. #define __RENDER_TEXTURE_ENABLE (1 << 13)
  218. #define __RENDER_SYNC_ON_HOST_DATA (1 << 12)
  219. #define __RENDER_SYNC_ON_BIT_MASK (1 << 11)
  220. #define __RENDER_RECTANGLE_PRIMITIVE (__PERMEDIA_RECTANGLE_PRIMITIVE << 6)
  221. #define __RENDER_TRAPEZOID_PRIMITIVE (__PERMEDIA_TRAPEZOID_PRIMITIVE << 6)
  222. #define __RENDER_LINE_PRIMITIVE (__PERMEDIA_LINE_PRIMITIVE << 6)
  223. #define __RENDER_POINT_PRIMITIVE (__PERMEDIA_POINT_PRIMITIVE << 6)
  224. #define __RENDER_FAST_FILL_INC(n) (((n) >> 4) << 4) // n = 8, 16 or 32
  225. #define __RENDER_FAST_FILL_ENABLE (1 << 3)
  226. #define __RENDER_RESET_LINE_STIPPLE (1 << 2)
  227. #define __RENDER_LINE_STIPPLE_ENABLE (1 << 1)
  228. #define __RENDER_AREA_STIPPLE_ENABLE (1 << 0)
  229. //
  230. // Bits in the ScissorMode register
  231. //
  232. #define USER_SCISSOR_ENABLE (1 << 0)
  233. #define SCREEN_SCISSOR_ENABLE (1 << 1)
  234. #define SCISSOR_XOFFSET 0
  235. #define SCISSOR_YOFFSET 16
  236. //
  237. // Bits in the FBReadMode register
  238. //
  239. #define __FB_READ_SOURCE (1 << 9)
  240. #define __FB_READ_DESTINATION (1 << 10)
  241. #define __FB_COLOR (1 << 15)
  242. #define __FB_WINDOW_ORIGIN (1 << 16)
  243. #define __FB_PACKED_DATA (1 << 19)
  244. //
  245. // Extra bits in PERMEDIA FBReadMode
  246. //
  247. #define __FB_RELATIVE_OFFSET 20
  248. //
  249. // P2 also provides a version of Relative Offset in the PackedDataLimits
  250. // register
  251. //
  252. #define __PDL_RELATIVE_OFFSET 29
  253. //
  254. // Bits in the LBReadMode register
  255. //
  256. #define __LB_READ_SOURCE (1 << 9)
  257. #define __LB_READ_DESTINATION (1 << 10)
  258. #define __LB_STENCIL (1 << 16)
  259. #define __LB_DEPTH (1 << 17)
  260. #define __LB_WINDOW_ORIGIN (1 << 18)
  261. #define __LB_READMODE_PATCH (1 << 19)
  262. #define __LB_SCAN_INTERVAL_2 (1 << 20)
  263. //
  264. // Bits in the DepthMode register
  265. //
  266. #define __DEPTH_ENABLE 1
  267. #define __DEPTH_WRITE_ENABLE (1<<1)
  268. #define __DEPTH_REGISTER_SOURCE (2<<2)
  269. #define __DEPTH_MSG_SOURCE (3<<2)
  270. #define __DEPTH_ALWAYS (7<<4)
  271. //
  272. // Bits in the LBReadFormat/LBWriteFormat registers
  273. //
  274. #define __LB_FORMAT_DEPTH32 2
  275. //
  276. // Macros to load indexed tags more efficiently than using __HwDMATag struct
  277. //
  278. #define P2_TAG_MAJOR(x) ((x) & 0xff0)
  279. #define P2_TAG_MINOR(x) ((x) & 0x00f)
  280. #define P2_TAG_MAJOR_INDEXED(x) \
  281. ((__PERMEDIA_TAG_MODE_INDEXED << (5+4+1+4)) | P2_TAG_MAJOR(x))
  282. #define P2_TAG_MINOR_INDEX(x) \
  283. (1 << (P2_TAG_MINOR(x) + 16))
  284. //
  285. // Macro to take a permedia2 logical op and return the enabled LogcialOpMode bits
  286. //
  287. #define P2_ENABLED_LOGICALOP(op) (((op) << 1) | __PERMEDIA_ENABLE)
  288. #define RECTORIGIN_YX(y,x) (((y) << 16) | ((x) & 0xFFFF))
  289. //
  290. // Area stipple shifts and bit defines
  291. //
  292. #define AREA_STIPPLE_XSEL(x) ((x) << 1)
  293. #define AREA_STIPPLE_YSEL(y) ((y) << 4)
  294. #define AREA_STIPPLE_XOFF(x) ((x) << 7)
  295. #define AREA_STIPPLE_YOFF(y) ((y) << 12)
  296. #define AREA_STIPPLE_INVERT_PAT (1 << 17)
  297. #define AREA_STIPPLE_MIRROR_X (1 << 18)
  298. #define AREA_STIPPLE_MIRROR_Y (1 << 19)
  299. //
  300. // We always use 8x8 monochrome brushes.
  301. //
  302. #define AREA_STIPPLE_8x8_ENABLE \
  303. (__PERMEDIA_ENABLE | \
  304. AREA_STIPPLE_XSEL(__PERMEDIA_AREA_STIPPLE_8_PIXEL_PATTERN) | \
  305. AREA_STIPPLE_YSEL(__PERMEDIA_AREA_STIPPLE_8_PIXEL_PATTERN))
  306. //
  307. // RasteriserMode values
  308. //
  309. #define BIAS_NONE (__PERMEDIA_START_BIAS_ZERO << 4)
  310. #define BIAS_HALF (__PERMEDIA_START_BIAS_HALF << 4)
  311. #define BIAS_NEARLY_HALF (__PERMEDIA_START_BIAS_ALMOST_HALF << 4)
  312. #define FRADJ_NONE (__PERMEDIA_FRACTION_ADJUST_NONE << 2)
  313. #define FRADJ_ZERO (__PERMEDIA_FRACTION_ADJUST_TRUNC << 2)
  314. #define FRADJ_HALF (__PERMEDIA_FRACTION_ADJUST_HALF << 2)
  315. #define FRADJ_NEARLY_HALF (__PERMEDIA_FRACTION_ADJUST_ALMOST_HALF << 2)
  316. //
  317. // Some constants
  318. //
  319. #define ONE 0x00010000
  320. #define MINUS_ONE 0xFFFF0000
  321. #define PLUS_ONE ONE
  322. #define NEARLY_ONE 0x0000FFFF
  323. #define HALF 0x00008000
  324. #define NEARLY_HALF 0x00007FFF
  325. //
  326. // Max length of GIQ conformant lines that Permedia2 can draw
  327. // Permedia has only 15 bits of fraction so reduce the lengths.
  328. //
  329. #define MAX_LENGTH_CONFORMANT_NONINTEGER_LINES (16/2)
  330. #define MAX_LENGTH_CONFORMANT_INTEGER_LINES (194/2)
  331. //
  332. // We need to byte swap monochrome bitmaps. On 486 we can do this with
  333. // fast assembler.
  334. //
  335. #if defined(_X86_)
  336. //
  337. // This only works on a 486 so the driver won't run on a 386.
  338. //
  339. #define LSWAP_BYTES(dst, pSrc) \
  340. { \
  341. __asm mov eax, pSrc \
  342. __asm mov eax, [eax] \
  343. __asm bswap eax \
  344. __asm mov dst, eax \
  345. }
  346. #else
  347. #define LSWAP_BYTES(dst, pSrc) \
  348. { \
  349. ULONG _src = *(ULONG *)pSrc; \
  350. dst = ((_src) >> 24) | \
  351. ((_src) << 24) | \
  352. (((_src) >> 8) & 0x0000ff00) | \
  353. (((_src) << 8) & 0x00ff0000); \
  354. }
  355. #endif
  356. // macro to swap the Red and Blue component of a 32 bit dword
  357. //
  358. #define SWAP_BR(a) ((a & 0xff00ff00l) | \
  359. ((a&0xff0000l)>> 16) | \
  360. ((a & 0xff) << 16))
  361. //
  362. // min. and max. values for Permedia PP register
  363. #define MAX_PARTIAL_PRODUCT_P2 10
  364. #define MIN_PARTIAL_PRODUCT_P2 5
  365. //
  366. // Permedia2 DMA definitions
  367. //
  368. #include "mini.h"
  369. // structure definitions passed in by the application for mapping and
  370. // unmapping DMA buffers.
  371. //
  372. //
  373. // Registry variable names
  374. //
  375. #define REG_USE_SOFTWARE_WRITEMASK L"UseSoftwareWriteMask"
  376. //
  377. // Function declarations
  378. //
  379. VOID vDoMonoBitsDownload(PPDev, BYTE*, LONG, LONG, LONG, LONG);
  380. BOOL bInitializeHW(PPDev);
  381. VOID vDisableHW(PPDev);
  382. VOID vAssertModeHW(PPDev, BOOL);
  383. VOID vP2ChangeFBDepth(PPDev, ULONG);
  384. //
  385. // Calculate the packed partial products
  386. //
  387. VOID vCalcPackedPP(LONG width, LONG * outPitch, ULONG * outPackedPP);
  388. VOID vSetNewGammaValue(PPDev ppdev, ULONG ulgvFIX16_16);
  389. BOOL bInstallGammaLUT(PPDev ppdev, PVIDEO_CLUT pScreenClut);
  390. //
  391. // The following structures and macros define the memory map for the Permedia2
  392. // control registers. We don't use this memory map to access Permedia2 registers
  393. // since on Alpha machines we want to precompute the addresses. So we do
  394. // a TRANSLATE_ADDR_ULONG on all the addresses here and save them into a
  395. // P2RegAddrRec. We use that to obtain the addresses for the different
  396. // registers.
  397. //
  398. typedef struct
  399. {
  400. ULONG reg;
  401. ULONG pad;
  402. } RAMDAC_REG;
  403. //
  404. // Macros to add padding words to the structures. For the core registers we use
  405. // the tag ids when specifying the pad. So we must multiply by 8 to get a byte
  406. // pad. We need to add an id to make each pad field in the struct unique. The
  407. // id is irrelevant as long as it's different from every other id used in the
  408. // same struct. It's a pity pad##__LINE__ doesn't work.
  409. //
  410. //#define PAD(id, n) UCHAR pad##id[n]
  411. //
  412. // Interrupt status bits
  413. //
  414. typedef enum
  415. {
  416. DMA_INTERRUPT_AVAILABLE = 0x01, // can use DMA interrupts
  417. VBLANK_INTERRUPT_AVAILABLE = 0x02, // can use VBLANK interrupts
  418. } INTERRUPT_CONTROL;
  419. extern DWORD LogicopReadDest[]; // Indicates which logic ops need dest read
  420. // turned on
  421. #define INTtoFIXED(i) ((i) << 16) // int to 16.16 fixed format
  422. #define FIXEDtoINT(i) ((i) >> 16) // 16.16 fixed format to int
  423. #define __PERMEDIA_CONSTANT_FB_WRITE \
  424. (1 << (4+1))
  425. #define __COLOR_DDA_FLAT_SHADE \
  426. (__PERMEDIA_ENABLE | (__PERMEDIA_FLAT_SHADE_MODE << 1))
  427. #define __COLOR_DDA_GOURAUD_SHADE \
  428. (__PERMEDIA_ENABLE | (__PERMEDIA_GOURAUD_SHADE_MODE << 1))
  429. #define INVERT_BITMASK_BITS (1 << 1)
  430. //
  431. // Bits in the Render command
  432. //
  433. #define __RENDER_VARIABLE_SPANS (1 << 18)
  434. #define __RENDER_SYNC_ON_HOST_DATA (1 << 12)
  435. #define __RENDER_SYNC_ON_BIT_MASK (1 << 11)
  436. #define __RENDER_TRAPEZOID_PRIMITIVE (__PERMEDIA_TRAPEZOID_PRIMITIVE << 6)
  437. #define __RENDER_LINE_PRIMITIVE (__PERMEDIA_LINE_PRIMITIVE << 6)
  438. #define __RENDER_POINT_PRIMITIVE (__PERMEDIA_POINT_PRIMITIVE << 6)
  439. #define __RENDER_FAST_FILL_INC(n) (((n) >> 4) << 4) // n = 8, 16 or 32
  440. #define __RENDER_FAST_FILL_ENABLE (1 << 3)
  441. #define __RENDER_RESET_LINE_STIPPLE (1 << 2)
  442. #define __RENDER_LINE_STIPPLE_ENABLE (1 << 1)
  443. #define __RENDER_AREA_STIPPLE_ENABLE (1 << 0)
  444. #define __RENDER_TEXTURED_PRIMITIVE (1 << 13)
  445. //
  446. // Bits in the ScissorMode register
  447. //
  448. #define USER_SCISSOR_ENABLE (1 << 0)
  449. #define SCREEN_SCISSOR_ENABLE (1 << 1)
  450. #define SCISSOR_XOFFSET 0
  451. #define SCISSOR_YOFFSET 16
  452. //
  453. // Bits in the FBReadMode register
  454. //
  455. #define __FB_READ_SOURCE (1 << 9)
  456. #define __FB_READ_DESTINATION (1 << 10)
  457. #define __FB_COLOR (1 << 15)
  458. #define __FB_WINDOW_ORIGIN (1 << 16)
  459. #define __FB_USE_PACKED (1 << 19)
  460. //
  461. // Bits in the LBReadMode register
  462. //
  463. #define __LB_READ_SOURCE (1 << 9)
  464. #define __LB_READ_DESTINATION (1 << 10)
  465. #define __LB_STENCIL (1 << 16)
  466. #define __LB_DEPTH (1 << 17)
  467. #define __LB_WINDOW_ORIGIN (1 << 18)
  468. //
  469. // Area stipple shifts and bit defines
  470. //
  471. #define AREA_STIPPLE_XSEL(x) ((x) << 1)
  472. #define AREA_STIPPLE_YSEL(y) ((y) << 4)
  473. #define AREA_STIPPLE_XOFF(x) ((x) << 7)
  474. #define AREA_STIPPLE_YOFF(y) ((y) << 12)
  475. #define AREA_STIPPLE_INVERT_PAT (1 << 17)
  476. #define AREA_STIPPLE_MIRROR_X (1 << 18)
  477. #define AREA_STIPPLE_MIRROR_Y (1 << 19)
  478. // we always use 8x8 monochrome brushes.
  479. #define AREA_STIPPLE_8x8_ENABLE \
  480. (__PERMEDIA_ENABLE | \
  481. AREA_STIPPLE_XSEL(__PERMEDIA_AREA_STIPPLE_8_PIXEL_PATTERN) | \
  482. AREA_STIPPLE_YSEL(__PERMEDIA_AREA_STIPPLE_8_PIXEL_PATTERN))
  483. #define DEFAULTWRITEMASK 0xffffffffl
  484. // *******************************************************************
  485. // Permedia Bit Field Macros
  486. // FBReadMode
  487. #define PM_FBREADMODE_PARTIAL(a) ((a) << 0)
  488. #define PM_FBREADMODE_READSOURCE(a) ((a) << 9)
  489. #define PM_FBREADMODE_READDEST(a) ((a) << 10)
  490. #define PM_FBREADMODE_PATCHENABLE(a) ((a) << 18)
  491. #define PM_FBREADMODE_PACKEDDATA(a) ((a) << 19)
  492. #define PM_FBREADMODE_RELATIVEOFFSET(a) ((a) << 20)
  493. #define PM_FBREADMODE_PATCHMODE(a) ((a) << 25)
  494. // Texture read mode
  495. #define PM_TEXREADMODE_ENABLE(a) ((a) << 0)
  496. #define PM_TEXREADMODE_WIDTH(a) ((a) << 9)
  497. #define PM_TEXREADMODE_HEIGHT(a) ((a) << 13)
  498. #define PM_TEXREADMODE_FILTER(a) ((a) << 17)
  499. // PackedDataLimits
  500. #define PM_PACKEDDATALIMITS_OFFSET(a) ((a) << 29)
  501. #define PM_PACKEDDATALIMITS_XSTART(a) ((a) << 16)
  502. #define PM_PACKEDDATALIMITS_XEND(a) ((a) << 0)
  503. // Window Register
  504. #define PM_WINDOW_LBUPDATESOURCE(a) ((a) << 4)
  505. #define PM_WINDOW_DISABLELBUPDATE(a) ((a) << 18)
  506. // Colors
  507. #define PM_BYTE_COLOR(a) ((a) << 15)
  508. // Config register
  509. #define PM_CHIPCONFIG_AGPCAPABLE (1 << 9)
  510. static __inline int log2(int s)
  511. {
  512. int d = 1, iter = -1;
  513. do {
  514. d *= 2;
  515. iter++;
  516. } while (d <= s);
  517. return iter;
  518. }
  519. VOID
  520. P2DisableAllUnits(PPDev ppdev);
  521. #if DBG && TRACKMEMALLOC
  522. #define ENGALLOCMEM( opt, size, tag)\
  523. MEMTRACKERALLOCATEMEM( EngAllocMem( opt, size, tag), size, __FILE__, __LINE__, FALSE)
  524. #define ENGFREEMEM( obj)\
  525. { MEMTRACKERFREEMEM(obj); EngFreeMem( obj);}
  526. #else
  527. #define ENGALLOCMEM( opt, size, tag)\
  528. EngAllocMem( opt, size, tag)
  529. #define ENGFREEMEM( obj)\
  530. EngFreeMem( obj)
  531. #endif
  532. #endif // _HW_H_