Source code of Windows XP (NT5)
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.

894 lines
38 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: driver.h
  3. *
  4. * Contains prototypes for the display driver.
  5. *
  6. * Copyright (c) 1992-1996 Microsoft Corporation
  7. \**************************************************************************/
  8. //////////////////////////////////////////////////////////////////////
  9. // Warning: The following define is for private use only. It should
  10. // only be used in such a fashion that when defined as 0,
  11. // all code specific to punting is optimized out completely.
  12. //
  13. // ### Not sure if this should go in or not.
  14. #define DRIVER_PUNT_ALL 0
  15. //////////////////////////////////////////////////////////////////////
  16. //////////////////////////////////////////////////////////////////////
  17. // Put all the conditional-compile constants here. There had better
  18. // not be many!
  19. // Set this bit when GDI's HOOK_SYNCHRONIZEACCESS works so that we don't
  20. // have to worry about synchronizing device-bitmap access. Note that
  21. // this wasn't an option in the first release of NT:
  22. #define SYNCHRONIZEACCESS_WORKS 1
  23. #define DIRECT_ACCESS(ppdev) 1
  24. // When running on an x86, we can make banked call-backs to GDI where
  25. // GDI can write directly on the frame buffer. The Alpha has a weird
  26. // bus scheme, and can't do that:
  27. #if !defined(_ALPHA_)
  28. #define GDI_BANKING 1
  29. #else
  30. #define GDI_BANKING 1 // was 0
  31. #endif
  32. // Both fast and slow patterns are enabled by default:
  33. #define FASTFILL_PATTERNS 1
  34. #define SLOWFILL_PATTERNS 1
  35. // Useful for visualizing the 2-d heap:
  36. #define DEBUG_HEAP 0
  37. //////////////////////////////////////////////////////////////////////
  38. // Miscellaneous shared stuff
  39. #define DLL_NAME L"w32" // Name of the DLL in UNICODE
  40. #define STANDARD_DEBUG_PREFIX "W32: " // All debug output is prefixed
  41. // by this string
  42. #define ALLOC_TAG '23WD' // Four byte tag (characters in
  43. // reverse order) used for memory
  44. // allocations
  45. #define CLIP_LIMIT 50 // We'll be taking 800 bytes of stack space
  46. #define DRIVER_EXTRA_SIZE 0 // Size of the DriverExtra information in the
  47. // DEVMODE structure
  48. #define TMP_BUFFER_SIZE 8192 // Size in bytes of 'pvTmpBuffer'. Has to
  49. // be at least enough to store an entire
  50. // scan line (i.e., 6400 for 1600x1200x32).
  51. #if defined(ALPHA)
  52. #define XFER_BUFFERS 16 // Defines the maximum number of write buffers
  53. // possible on any Alpha. Must be a power
  54. #else // of two.
  55. #define XFER_BUFFERS 1 // On non-alpha systems, we don't have to
  56. // worry about the chip caching our bus
  57. #endif // writes.
  58. #define XFER_MASK (XFER_BUFFERS - 1)
  59. typedef struct _CLIPENUM {
  60. LONG c;
  61. RECTL arcl[CLIP_LIMIT]; // Space for enumerating complex clipping
  62. } CLIPENUM; /* ce, pce */
  63. typedef struct _PDEV PDEV; // Handy forward declaration
  64. VOID vSetClipping(PDEV*, RECTL*);
  65. VOID vResetClipping(PDEV*);
  66. //////////////////////////////////////////////////////////////////////
  67. // Text stuff
  68. typedef struct _XLATECOLORS { // Specifies foreground and background
  69. ULONG iBackColor; // colours for faking a 1bpp XLATEOBJ
  70. ULONG iForeColor;
  71. } XLATECOLORS; /* xlc, pxlc */
  72. BOOL bEnableText(PDEV*);
  73. VOID vDisableText(PDEV*);
  74. VOID vAssertModeText(PDEV*, BOOL);
  75. VOID vFastText(GLYPHPOS*, ULONG, BYTE*, ULONG, ULONG, RECTL*, RECTL*,
  76. FLONG, RECTL*, RECTL*);
  77. VOID vClearMemDword(ULONG*, ULONG);
  78. //////////////////////////////////////////////////////////////////////
  79. // Dither stuff
  80. // Describes a single colour tetrahedron vertex for dithering:
  81. typedef struct _VERTEX_DATA {
  82. ULONG ulCount; // Number of pixels in this vertex
  83. ULONG ulVertex; // Vertex number
  84. } VERTEX_DATA; /* vd, pv */
  85. VERTEX_DATA* vComputeSubspaces(ULONG, VERTEX_DATA*);
  86. VOID vDitherColor(ULONG*, VERTEX_DATA*, VERTEX_DATA*, ULONG);
  87. //////////////////////////////////////////////////////////////////////
  88. // Brush stuff
  89. // 'Slow' brushes are used when we don't have hardware pattern capability,
  90. // and we have to handle patterns using screen-to-screen blts:
  91. #define SLOW_BRUSH_CACHE_DIM 3 // Controls the number of brushes cached
  92. // in off-screen memory, when we don't
  93. // have the W32 hardware pattern support.
  94. // We allocate 3 x 3 brushes, so we can
  95. // cache a total of 9 brushes:
  96. #define SLOW_BRUSH_COUNT (SLOW_BRUSH_CACHE_DIM * SLOW_BRUSH_CACHE_DIM)
  97. #define SLOW_BRUSH_DIMENSION 64 // After alignment is taken care of,
  98. // every off-screen brush cache entry
  99. // will be 64 pels in both dimensions
  100. #define SLOW_BRUSH_ALLOCATION (SLOW_BRUSH_DIMENSION + 8)
  101. // Actually allocate 72x72 pels for each
  102. // pattern, using the 8 extra for brush
  103. // alignment
  104. // 'Fast' brushes are used when we have hardware pattern capability:
  105. #define FAST_BRUSH_COUNT 16 // Total number of non-hardware brushes
  106. // cached off-screen
  107. #define FAST_BRUSH_DIMENSION 8 // Every off-screen brush cache entry
  108. // is 8 pels in both dimensions
  109. #define FAST_BRUSH_ALLOCATION 8 // We have to align ourselves, so this is
  110. // the dimension of each brush allocation
  111. // Common to both implementations:
  112. #define RBRUSH_2COLOR 1 // For RBRUSH flags
  113. #define TOTAL_BRUSH_COUNT max(FAST_BRUSH_COUNT, SLOW_BRUSH_COUNT)
  114. // This is the maximum number of brushes
  115. // we can possibly have cached off-screen
  116. #define TOTAL_BRUSH_SIZE 64 // We'll only ever handle 8x8 patterns,
  117. // and this is the number of pels
  118. typedef struct _BRUSHENTRY BRUSHENTRY;
  119. // NOTE: Changes to the RBRUSH or BRUSHENTRY structures must be reflected
  120. // in strucs.inc!
  121. typedef struct _RBRUSH {
  122. FLONG fl; // Type flags
  123. BOOL bTransparent; // TRUE if brush was realized for a transparent
  124. // blt (meaning colours are white and black),
  125. // FALSE if not (meaning it's already been
  126. // colour-expanded to the correct colours).
  127. // Value is undefined if the brush isn't
  128. // 2 colour.
  129. ULONG ulForeColor; // Foreground colour if 1bpp
  130. ULONG ulBackColor; // Background colour if 1bpp
  131. POINTL ptlBrushOrg; // Brush origin of cached pattern. Initial
  132. // value should be -1
  133. BRUSHENTRY* pbe; // Points to brush-entry that keeps track
  134. // of the cached off-screen brush bits
  135. ULONG aulPattern[1]; // Open-ended array for keeping copy of the
  136. // Don't put anything // actual pattern bits in case the brush
  137. // after here, or // origin changes, or someone else steals
  138. // you'll be sorry! // our brush entry (declared as a ULONG
  139. // for proper dword alignment)
  140. } RBRUSH; /* rb, prb */
  141. typedef struct _BRUSHENTRY {
  142. RBRUSH* prbVerify; // We never dereference this pointer to
  143. // find a brush realization; it is only
  144. // ever used in a compare to verify
  145. // that for a given realized brush, our
  146. // off-screen brush entry is still valid.
  147. LONG x; // x-position of cached pattern
  148. LONG y; // y-position of cached pattern
  149. } BRUSHENTRY; /* be, pbe */
  150. typedef union _RBRUSH_COLOR {
  151. RBRUSH* prb;
  152. ULONG iSolidColor;
  153. } RBRUSH_COLOR; /* rbc, prbc */
  154. BOOL bEnableBrushCache(PDEV*);
  155. VOID vDisableBrushCache(PDEV*);
  156. VOID vAssertModeBrushCache(PDEV*, BOOL);
  157. //////////////////////////////////////////////////////////////////////
  158. // Stretch stuff
  159. typedef struct _STR_BLT {
  160. PDEV* ppdev;
  161. PBYTE pjSrcScan;
  162. LONG lDeltaSrc;
  163. LONG XSrcStart;
  164. PBYTE pjDstScan;
  165. LONG lDeltaDst;
  166. LONG XDstStart;
  167. LONG XDstEnd;
  168. LONG YDstStart;
  169. LONG YDstCount;
  170. ULONG ulXDstToSrcIntCeil;
  171. ULONG ulXDstToSrcFracCeil;
  172. ULONG ulYDstToSrcIntCeil;
  173. ULONG ulYDstToSrcFracCeil;
  174. ULONG ulXFracAccumulator;
  175. ULONG ulYFracAccumulator;
  176. } STR_BLT;
  177. typedef VOID (*PFN_DIRSTRETCH)(STR_BLT*);
  178. VOID vDirectStretch8Narrow(STR_BLT*);
  179. VOID vDirectStretch8(STR_BLT*);
  180. VOID vDirectStretch16(STR_BLT*);
  181. VOID vDirectStretch32(STR_BLT*);
  182. /////////////////////////////////////////////////////////////////////////
  183. // Heap stuff
  184. typedef enum {
  185. OH_FREE = 0, // The off-screen allocation is available for use
  186. OH_DISCARDABLE, // The allocation is occupied by a discardable bitmap
  187. // that may be moved out of off-screen memory
  188. OH_PERMANENT, // The allocation is occupied by a permanent bitmap
  189. // that cannot be moved out of off-screen memory
  190. } OHSTATE;
  191. typedef struct _DSURF DSURF;
  192. typedef struct _OH OH;
  193. typedef struct _OH
  194. {
  195. OHSTATE ohState; // State of off-screen allocation
  196. LONG x; // x-coordinate of left edge of allocation
  197. LONG y; // y-coordinate of top edge of allocation
  198. LONG xy; // y-coordinate of top edge of allocation
  199. LONG cx; // Width in pixels of allocation
  200. LONG cy; // Height in pixels of allocation
  201. LONG cxReserved; // Dimensions of original reserved rectangle;
  202. LONG cyReserved; // zero if rectangle is not 'reserved'
  203. OH* pohNext; // When OH_FREE or OH_RESERVE, points to the next
  204. // free node, in ascending cxcy value. This is
  205. // kept as a circular doubly-linked list with a
  206. // sentinel at the end.
  207. // When OH_DISCARDABLE, points to the next most
  208. // recently created allocation. This is kept as
  209. // a circular doubly-linked list.
  210. OH* pohPrev; // Opposite of 'pohNext'
  211. ULONG cxcy; // Width and height in a dword for searching
  212. OH* pohLeft; // Adjacent allocation when in-use or available
  213. OH* pohUp;
  214. OH* pohRight;
  215. OH* pohDown;
  216. DSURF* pdsurf; // Points to our DSURF structure
  217. VOID* pvScan0; // Points to start of first scan-line
  218. }; /* oh, poh */
  219. // This is the smallest structure used for memory allocations:
  220. typedef struct _OHALLOC OHALLOC;
  221. typedef struct _OHALLOC
  222. {
  223. OHALLOC* pohaNext;
  224. OH aoh[1];
  225. } OHALLOC; /* oha, poha */
  226. typedef struct _HEAP
  227. {
  228. LONG cxMax; // Largest possible free space by area
  229. LONG cyMax;
  230. OH ohFree; // Head of the free list, containing those
  231. // rectangles in off-screen memory that are
  232. // available for use. pohNext points to
  233. // hte smallest available rectangle, and pohPrev
  234. // points to the largest available rectangle,
  235. // sorted by cxcy.
  236. OH ohDiscardable; // Head of the discardable list that contains all
  237. // bitmaps located in offscreen memory that
  238. // are eligible to be tossed out of the heap.
  239. // It is kept in order of creation: pohNext
  240. // points to the most recently created; pohPrev
  241. // points to the least recently created.
  242. OH ohPermanent; // List of permanently allocated rectangles
  243. OH* pohFreeList; // List of OH node data structures available
  244. OHALLOC* pohaChain; // Chain of allocations
  245. } HEAP; /* heap, pheap */
  246. typedef enum {
  247. DT_SCREEN, // Surface is kept in screen memory
  248. DT_DIB // Surface is kept as a DIB
  249. } DSURFTYPE; /* dt, pdt */
  250. typedef struct _DSURF
  251. {
  252. DSURFTYPE dt; // DSURF status (whether off-screen or in a DIB)
  253. SIZEL sizl; // Size of the original bitmap (could be smaller
  254. // than poh->sizl)
  255. PDEV* ppdev; // Need this for deleting the bitmap
  256. union {
  257. OH* poh; // If DT_SCREEN, points to off-screen heap node
  258. SURFOBJ* pso; // If DT_DIB, points to locked GDI surface
  259. };
  260. // The following are used for DT_DIB only...
  261. ULONG cBlt; // Counts down the number of blts necessary at
  262. // the current uniqueness before we'll consider
  263. // putting the DIB back into off-screen memory
  264. ULONG iUniq; // Tells us whether there have been any heap
  265. // 'free's since the last time we looked at
  266. // this DIB
  267. } DSURF; /* dsurf, pdsurf */
  268. // GDI expects dword alignment for any bitmaps on which it is expected
  269. // to draw. Since we occasionally ask GDI to draw directly on our off-
  270. // screen bitmaps, this means that any off-screen bitmaps must be dword
  271. // aligned in the frame buffer. We enforce this merely by ensuring that
  272. // all off-screen bitmaps are four-pel aligned (we may waste a couple of
  273. // pixels at the higher colour depths):
  274. #define HEAP_X_ALIGNMENT 4
  275. // Number of blts necessary before we'll consider putting a DIB DFB back
  276. // into off-screen memory:
  277. #define HEAP_COUNT_DOWN 6
  278. // Flags for 'pohAllocate':
  279. typedef enum {
  280. FLOH_ONLY_IF_ROOM = 0x0001, // Don't kick stuff out of off-
  281. // screen memory to make room
  282. FLOH_MAKE_PERMANENT = 0x0002, // Allocate a permanent entry
  283. FLOH_RESERVE = 0x0004, // Allocate an off-screen entry,
  284. // but let it be used by discardable
  285. // bitmaps until it's needed
  286. } FLOH;
  287. // Publicly callable heap APIs:
  288. OH* pohAllocate(PDEV*, POINTL*, LONG, LONG, FLOH);
  289. BOOL bOhCommit(PDEV*, OH*, BOOL);
  290. OH* pohFree(PDEV*, OH*);
  291. OH* pohMoveOffscreenDfbToDib(PDEV*, OH*);
  292. BOOL bMoveDibToOffscreenDfbIfRoom(PDEV*, DSURF*);
  293. BOOL bMoveAllDfbsFromOffscreenToDibs(PDEV* ppdev);
  294. BOOL bEnableOffscreenHeap(PDEV*);
  295. VOID vDisableOffscreenHeap(PDEV*);
  296. BOOL bAssertModeOffscreenHeap(PDEV*, BOOL);
  297. /////////////////////////////////////////////////////////////////////////
  298. // Bank manager stuff
  299. #define BANK_DATA_SIZE 80 // Number of bytes to allocate for the
  300. // miniport down-loaded bank code working
  301. // space
  302. typedef struct _BANK
  303. {
  304. // Private data:
  305. RECTL rclDraw; // Rectangle describing the remaining undrawn
  306. // portion of the drawing operation
  307. RECTL rclSaveBounds; // Saved from original CLIPOBJ for restoration
  308. BYTE iSaveDComplexity; // Saved from original CLIPOBJ for restoration
  309. BYTE fjSaveOptions; // Saved from original CLIPOBJ for restoration
  310. LONG iBank; // Current bank
  311. PDEV* ppdev; // Saved copy
  312. // Public data:
  313. SURFOBJ* pso; // Surface wrapped around the bank. Has to be
  314. // passed as the surface in any banked call-
  315. // back.
  316. CLIPOBJ* pco; // Clip object that is the intersection of the
  317. // original clip object with the bounds of the
  318. // current bank. Has to be passed as the clip
  319. // object in any banked call-back.
  320. } BANK; /* bnk, pbnk */
  321. typedef enum {
  322. BANK_OFF = 0, // We've finished using the memory aperture
  323. BANK_ON, // We're about to use the memory aperture
  324. BANK_DISABLE, // We're about to enter full-screen; shut down banking
  325. BANK_ENABLE, // We've exited full-screen; re-enable banking
  326. } BANK_MODE; /* bankm, pbankm */
  327. typedef VOID (FNBANKMAP)(PDEV*, LONG);
  328. typedef VOID (FNBANKSELECTMODE)(PDEV*, BANK_MODE);
  329. typedef VOID (FNBANKINITIALIZE)(PDEV*, BOOL);
  330. typedef BOOL (FNBANKCOMPUTE)(PDEV*, RECTL*, RECTL*, LONG*, LONG*);
  331. VOID vBankStart(PDEV*, RECTL*, CLIPOBJ*, BANK*);
  332. BOOL bBankEnum(BANK*);
  333. FNBANKCOMPUTE bBankComputeNonPower2;
  334. FNBANKCOMPUTE bBankComputePower2;
  335. BOOL bEnableBanking(PDEV*);
  336. VOID vDisableBanking(PDEV*);
  337. VOID vAssertModeBanking(PDEV*, BOOL);
  338. /////////////////////////////////////////////////////////////////////////
  339. // Pointer stuff
  340. #define POINTER_DATA_SIZE 40 // Number of bytes to allocate for the
  341. // miniport down-loaded pointer code
  342. // working space
  343. #define HW_INVISIBLE_OFFSET 2 // Offset from 'ppdev->yPointerBuffer'
  344. // to the invisible pointer
  345. #define HW_POINTER_DIMENSION 64 // Maximum dimension of default
  346. // (built-in) hardware pointer
  347. #define HW_POINTER_HIDE 63 // Hardware pointer start pixel
  348. // position used to hide the pointer
  349. typedef VOID (FNSHOWPOINTER)(VOID*, BOOL);
  350. typedef VOID (FNMOVEPOINTER)(VOID*, LONG, LONG);
  351. typedef BOOL (FNSETPOINTERSHAPE)(VOID*, LONG, LONG, LONG, LONG, LONG, LONG,
  352. BYTE*);
  353. typedef VOID (FNENABLEPOINTER)(VOID*, BOOL);
  354. BOOL bEnablePointer(PDEV*);
  355. VOID vDisablePointer(PDEV*);
  356. VOID vAssertModePointer(PDEV*, BOOL);
  357. /////////////////////////////////////////////////////////////////////////
  358. // Palette stuff
  359. BOOL bEnablePalette(PDEV*);
  360. VOID vDisablePalette(PDEV*);
  361. VOID vAssertModePalette(PDEV*, BOOL);
  362. BOOL bInitializePalette(PDEV*, DEVINFO*);
  363. VOID vUninitializePalette(PDEV*);
  364. #define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
  365. /////////////////////////////////////////////////////////////////////////
  366. // DirectDraw stuff
  367. // There's a 64K granularity that applies to the mapping of the frame
  368. // buffer into the application's address space:
  369. #define ROUND_UP_TO_64K(x) (((ULONG)(x) + 0x10000 - 1) & ~(0x10000 - 1))
  370. typedef struct _FLIPRECORD
  371. {
  372. FLATPTR fpFlipFrom; // Surface we last flipped from
  373. LONGLONG liFlipTime; // Time at which last flip
  374. // occured
  375. LONGLONG liFlipDuration; // Precise amount of time it
  376. // takes from vblank to vblank
  377. BOOL bHaveEverCrossedVBlank; // True if we noticed that we
  378. // switched from inactive to
  379. // vblank
  380. BOOL bWasEverInDisplay; // True if we ever noticed that
  381. // we were inactive
  382. BOOL bFlipFlag; // True if we think a flip is
  383. // still pending
  384. } FLIPRECORD;
  385. BOOL bEnableDirectDraw(PDEV*);
  386. VOID vDisableDirectDraw(PDEV*);
  387. VOID vAssertModeDirectDraw(PDEV*, BOOL);
  388. //////////////////////////////////////////////////////////////////////
  389. // Low-level blt function prototypes
  390. typedef VOID (FNFILL)(PDEV*, LONG, RECTL*, ROP4, RBRUSH_COLOR, POINTL*);
  391. typedef VOID (FNXFER)(PDEV*, LONG, RECTL*, ROP4, SURFOBJ*, POINTL*,
  392. RECTL*, XLATEOBJ*);
  393. typedef VOID (FNCOPY)(PDEV*, LONG, RECTL*, ROP4, POINTL*, RECTL*);
  394. typedef VOID (FNFASTPATREALIZE)(PDEV*, RBRUSH*, POINTL*, BOOL);
  395. typedef VOID (FNBITS)(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  396. typedef VOID (FNLOWXFER)(PDEV*, BYTE*, LONG, LONG, LONG);
  397. FNFILL vPatternFillScr;
  398. FNFILL vSolidFillScr;
  399. FNFILL vSolidFillScr24;
  400. FNXFER vSlowXfer1bpp;
  401. FNCOPY vScrToScr;
  402. FNFASTPATREALIZE vFastPatRealize;
  403. FNXFER vXferNativeSrccopy;
  404. FNXFER vXferBlt8i;
  405. FNXFER vXferBlt16i;
  406. FNXFER vXferBlt24i;
  407. FNXFER vXferBlt8p;
  408. FNXFER vXferBlt16p;
  409. FNXFER vXferBlt24p;
  410. FNXFER vXferScreenTo1bpp;
  411. FNBITS vPutBits;
  412. FNBITS vGetBits;
  413. FNBITS vPutBitsLinear;
  414. FNBITS vGetBitsLinear;
  415. FNXFER vET6000SlowXfer1bpp;
  416. FNXFER vXferET6000;
  417. FNLOWXFER vXfer_BYTES;
  418. FNLOWXFER vXfer_DWORDS;
  419. FNLOWXFER vXferI_1_Byte;
  420. FNLOWXFER vXferI_2_Bytes;
  421. FNLOWXFER vXferI_3_Bytes;
  422. FNLOWXFER vXferP_1_Byte;
  423. FNLOWXFER vXferP_2_Bytes;
  424. FNLOWXFER vXferP_3_Bytes;
  425. VOID vPutBits(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  426. VOID vGetBits(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  427. VOID vGetBitsLinear(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  428. VOID vIoSlowPatRealize(PDEV*, RBRUSH*, BOOL);
  429. ////////////////////////////////////////////////////////////////////////
  430. // Capabilities flags
  431. //
  432. // These are private flags passed to us from the W32 miniport. They
  433. // come from the high word of the 'AttributeFlags' field of the
  434. // 'VIDEO_MODE_INFORMATION' structure (found in 'ntddvdeo.h') passed
  435. // to us via an 'VIDEO_QUERY_AVAIL_MODES' or 'VIDEO_QUERY_CURRENT_MODE'
  436. // IOCTL.
  437. //
  438. // NOTE: These definitions must match those in the W32 miniport's 'W32.h'!
  439. typedef enum {
  440. CAPS_HW_PATTERNS = 0x00010000, // 8x8 hardware pattern support
  441. CAPS_MM_TRANSFER = 0x00020000, // Memory-mapped image transfers
  442. CAPS_MM_IO = 0x00040000, // Memory-mapped I/O
  443. CAPS_MM_32BIT_TRANSFER = 0x00080000, // Can do 32bit bus size transfers
  444. CAPS_16_ENTRY_FIFO = 0x00100000, // At least 16 entries in FIFO
  445. CAPS_SW_POINTER = 0x00200000, // No hardware pointer; use software
  446. // simulation
  447. CAPS_BT485_POINTER = 0x00400000, // Use Brooktree 485 pointer
  448. CAPS_MASKBLT_CAPABLE = 0x00800000, // Hardware can handle masked blts
  449. CAPS_NEW_BANK_CONTROL = 0x01000000, // Set if 801/805/928 style banking
  450. CAPS_NEWER_BANK_CONTROL = 0x02000000, // Set if 864/964 style banking
  451. CAPS_RE_REALIZE_PATTERN = 0x04000000, // Set if we have to work around the
  452. // 864/964 hardware pattern bug
  453. CAPS_SLOW_MONO_EXPANDS = 0x08000000, // Set if we have to slow down
  454. // monochrome expansions
  455. CAPS_MM_GLYPH_EXPAND = 0x10000000, // Use memory-mapped I/O glyph-
  456. // expand method of drawing text
  457. // (always implied for non-x86)
  458. CAPS_SCALE_POINTER = 0x20000000, // Set if the W32 hardware pointer
  459. // x position has to be scaled by
  460. // two
  461. CAPS_TI025_POINTER = 0x40000000, // Use TI TVP3025 pointer
  462. } CAPS;
  463. #define CAPS_DAC_POINTER (CAPS_BT485_POINTER | CAPS_TI025_POINTER)
  464. ////////////////////////////////////////////////////////////////////////
  465. // Miniport stuff
  466. typedef struct {
  467. ULONG ulPhysicalAddress;
  468. ULONG ulLength;
  469. ULONG ulInIoSpace;
  470. PVOID pvVirtualAddress;
  471. } W32_ADDRESS_MAPPING_INFORMATION, *PW32_ADDRESS_MAPPING_INFORMATION;
  472. ////////////////////////////////////////////////////////////////////////
  473. // Status flags
  474. typedef enum {
  475. STAT_GLYPH_CACHE = 0x0001, // Glyph cache successfully allocated
  476. STAT_BRUSH_CACHE = 0x0002, // Brush cache successfully allocated
  477. STAT_DIRECTDRAW = 0x0004, // DirectDraw is enabled
  478. } STATUS;
  479. ////////////////////////////////////////////////////////////////////////
  480. // The Physical Device data structure
  481. typedef struct _PDEV
  482. {
  483. LONG xOffset;
  484. LONG yOffset;
  485. LONG xyOffset;
  486. BYTE* pjBase; // Video coprocessor base
  487. BYTE* pjScreen; // Points to base screen address
  488. LONG iBoard; // Logical multi-board identifier
  489. // (zero by default)
  490. ULONG iBitmapFormat; // BMF_8BPP or BMF_16BPP or BMF_24BPP
  491. // (our current colour depth)
  492. ULONG ulChipID;
  493. ULONG ulRevLevel;
  494. // Precomputed values for the three aperatures in linear memory.
  495. BYTE* pjMmu0;
  496. BYTE* pjMmu1;
  497. BYTE* pjMmu2;
  498. // -------------------------------------------------------------------
  499. // NOTE: Changes up to here in the PDEV structure must be reflected in
  500. // i386\strucs.inc (assuming you're on an x86, of course)!
  501. CAPS flCaps; // Capabilities flags
  502. STATUS flStatus; // Status flags
  503. BOOL bEnabled; // In graphics mode (not full-screen)
  504. HANDLE hDriver; // Handle to \Device\Screen
  505. HDEV hdevEng; // Engine's handle to PDEV
  506. HSURF hsurfScreen; // Engine's handle to screen surface
  507. DSURF* pdsurfScreen; // Our private DSURF for the screen
  508. LONG cxScreen; // Visible screen width
  509. LONG cyScreen; // Visible screen height
  510. LONG cxMemory; // Width of Video RAM
  511. LONG cyMemory; // Height of Video RAM
  512. ULONG ulMode; // Mode the mini-port driver is in.
  513. LONG lDelta; // Distance from one scan to the next.
  514. FLONG flHooks; // What we're hooking from GDI
  515. LONG cPelSize; // 0 if 8bpp, 1 if 16bpp, 2 if 32bpp
  516. LONG cBpp; // 1 if 8bpp, 2 if 16bpp, 3 if 32bpp
  517. ULONG ulWhite; // 0xff if 8bpp, 0xffff if 16bpp,
  518. // 0xffffffff if 32bpp
  519. UCHAR* pucCsrBase; // Mapped IO port base for this PDEV
  520. VOID* pvTmpBuffer; // General purpose temporary buffer,
  521. // TMP_BUFFER_SIZE bytes in size
  522. // (Remember to synchronize if you
  523. // use this for device bitmaps or
  524. // async pointers)
  525. UCHAR* apjMmXfer[XFER_BUFFERS];// Pre-computed array of unique
  526. USHORT* apwMmXfer[XFER_BUFFERS];// addresses for doing memory-mapped
  527. ULONG* apdMmXfer[XFER_BUFFERS];// transfers without memory barriers
  528. ////////// Low-level blt function pointers:
  529. FNFILL* pfnFillSolid;
  530. FNFILL* pfnFillPat;
  531. FNXFER* pfnXfer1bpp;
  532. FNXFER* pfnXferNative;
  533. FNCOPY* pfnCopyBlt;
  534. FNFASTPATREALIZE* pfnFastPatRealize;
  535. FNBITS* pfnGetBits;
  536. FNBITS* pfnPutBits;
  537. ////////// Palette stuff:
  538. PALETTEENTRY* pPal; // The palette if palette managed
  539. HPALETTE hpalDefault; // GDI handle to the default palette.
  540. FLONG flRed; // Red mask for 16/32bpp bitfields
  541. FLONG flGreen; // Green mask for 16/32bpp bitfields
  542. FLONG flBlue; // Blue mask for 16/32bpp bitfields
  543. ////////// Heap stuff:
  544. HEAP heap; // All our off-screen heap data
  545. ULONG iHeapUniq; // Incremented every time room is freed
  546. // in the off-screen heap
  547. SURFOBJ* psoPunt; // Wrapper surface for having GDI draw
  548. // on off-screen bitmaps
  549. SURFOBJ* psoPunt2; // Another one for off-screen to off-
  550. // screen blts
  551. OH* pohScreen; // Allocation structure for the screen
  552. ////////// Banking stuff:
  553. BOOL bAutoBanking; // True if the system is set up to have
  554. // the memory manager do the banking
  555. LONG cjBank; // Size of a bank, in bytes
  556. LONG cPower2ScansPerBank; // Used by 'bBankComputePower2'
  557. LONG cPower2BankSizeInBytes; // Used by 'bBankComputePower2'
  558. CLIPOBJ* pcoBank; // Clip object for banked call backs
  559. SURFOBJ* psoBank; // Surface object for banked call backs
  560. SURFOBJ* psoFrameBuffer; // Surface object for non-banked call backs
  561. VOID* pvBankData; // Points to aulBankData[0]
  562. ULONG aulBankData[BANK_DATA_SIZE / 4];
  563. // Private work area for downloaded
  564. // miniport banking code
  565. FNBANKMAP* pfnBankMap;
  566. FNBANKSELECTMODE* pfnBankSelectMode;
  567. FNBANKCOMPUTE* pfnBankCompute;
  568. ////////// Pointer stuff:
  569. LONG xPointerHot; // xHot of current hardware pointer
  570. LONG yPointerHot; // yHot of current hardware pointer
  571. LONG cjPointerOffset; // Byte offset from start of frame
  572. // buffer to off-screen memory where
  573. // we stored the pointer shape
  574. LONG xPointerShape; // x-coordinate
  575. LONG yPointerShape; // y-coordinate
  576. LONG iPointerBank; // Bank containing pointer shape
  577. VOID* pvPointerShape; // Points to pointer shape when bank
  578. // is mapped in
  579. LONG dyPointer; // Start y-pixel position for the
  580. // current pointer
  581. LONG cPointerShift; // Horizontal scaling factor for
  582. // hardware pointer position
  583. ULONG ulHwGraphicsCursorModeRegister_45;
  584. // Default value for index 45
  585. VOID* pvPointerData; // Points to ajPointerData[0]
  586. BYTE ajPointerData[POINTER_DATA_SIZE];
  587. // Private work area for downloaded
  588. // miniport pointer code
  589. FNSHOWPOINTER* pfnShowPointer;
  590. FNMOVEPOINTER* pfnMovePointer;
  591. FNSETPOINTERSHAPE* pfnSetPointerShape;
  592. FNENABLEPOINTER* pfnEnablePointer;
  593. ////////// Brush stuff:
  594. BOOL bRealizeTransparent; // Hint to DrvRealizeBrush for whether
  595. // the brush should be realized as
  596. // transparent or not
  597. LONG iBrushCache; // Index for next brush to be allocated
  598. LONG cBrushCache; // Total number of brushes cached
  599. BRUSHENTRY abe[TOTAL_BRUSH_COUNT]; // Keeps track of brush cache
  600. // W32 specific stuff
  601. BYTE* pjPorts; // Video port base
  602. ULONG w32PatternWrap; // Value for the Pattern Wrap register
  603. // 8x8 pixels (varies with pel depth)
  604. W32MMUINFO w32MmuInfo;
  605. ULONG ulSolidColorOffset;
  606. W32SPRITEDATA W32SpriteData;
  607. // Rendering extensions colour information.
  608. UCHAR rDepth; // Number of red bits
  609. UCHAR gDepth; // Number of green bits
  610. UCHAR bDepth; // Number of blue bits
  611. UCHAR aDepth; // Number of alpha bits
  612. UCHAR rBitShift; // Left bit-shift for red component
  613. UCHAR gBitShift; // Left bit-shift for green component
  614. UCHAR bBitShift; // Left bit-shift for blue component
  615. UCHAR aBitShift; // Left bit-shift for alpha component
  616. #if 0
  617. ////////// DCI stuff:
  618. BOOL bSupportDCI; // True if miniport supports DCI
  619. ////////// 3D DDI Rendering Extension stuff:
  620. VOID* pvOut; // Points to current output buffer
  621. VOID* pvOutMax; // Points to end of current output buffer
  622. VOID* pvInMax; // Points to end of current input buffer
  623. OH* pohFrontBuffer; // Allocation structure for the screen
  624. OH* pohBackBuffer; // Allocation structure for optional
  625. // off-screen back buffer
  626. LONG cDoubleBufferRef; // Reference count for current number
  627. // of RC's that have active double-
  628. // buffers
  629. POINTL ptlDoubleBuffer[2]; // (x, y) positions of front and back
  630. // buffers in video memory
  631. // 0 -- RX_BACK_LEFT
  632. // 1 -- RX_FRONT_LEFT
  633. // Note: Make sure that the index
  634. // is in the range [0, 1]!
  635. #endif
  636. // Extensions added for the ET6000
  637. LONG lBltBufferPitch; // Pitch of our blt buffer.
  638. OH* pohBltBuffer; // Pointer to offscreen memory used for
  639. // double buffering blts and stretches.
  640. ULONG PCIConfigSpaceAddr; // The Offset into IO space for PCI Cfg data
  641. /////////// DirectDraw stuff:
  642. FLIPRECORD flipRecord; // Used to track VBlank status
  643. DWORD dwLinearCnt; // Reference count of active
  644. // DirectDraw Locks
  645. OH* pohDirectDraw; // Off-screen heap allocation for use
  646. // by DirectDraw
  647. } PDEV, *PPDEV;
  648. /////////////////////////////////////////////////////////////////////////
  649. // Miscellaneous prototypes:
  650. BOOL bIntersect(RECTL*, RECTL*, RECTL*);
  651. LONG cIntersect(RECTL*, RECTL*, LONG);
  652. BOOL bFastFill(PDEV*, LONG, POINTFIX*, ULONG, ULONG, ULONG, RBRUSH*);
  653. DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION*, DWORD*);
  654. BOOL bInitializeModeFields(PDEV*, GDIINFO*, DEVINFO*, DEVMODEW*);
  655. BOOL bEnableHardware(PDEV*);
  656. VOID vDisableHardware(PDEV*);
  657. BOOL bAssertModeHardware(PDEV*, BOOL);
  658. extern BYTE aMixToRop3[];
  659. /////////////////////////////////////////////////////////////////////////
  660. // The x86 C compiler insists on making a divide and modulus operation
  661. // into two DIVs, when it can in fact be done in one. So we use this
  662. // macro.
  663. //
  664. // Note: QUOTIENT_REMAINDER implicitly takes unsigned arguments.
  665. #if defined(i386)
  666. #define QUOTIENT_REMAINDER(ulNumerator, ulDenominator, ulQuotient, ulRemainder) \
  667. { \
  668. __asm mov eax, ulNumerator \
  669. __asm sub edx, edx \
  670. __asm div ulDenominator \
  671. __asm mov ulQuotient, eax \
  672. __asm mov ulRemainder, edx \
  673. }
  674. #else
  675. #define QUOTIENT_REMAINDER(ulNumerator, ulDenominator, ulQuotient, ulRemainder) \
  676. { \
  677. ulQuotient = (ULONG) ulNumerator / (ULONG) ulDenominator; \
  678. ulRemainder = (ULONG) ulNumerator % (ULONG) ulDenominator; \
  679. }
  680. #endif
  681. /////////////////////////////////////////////////////////////////////////
  682. // OVERLAP - Returns TRUE if the same-size lower-right exclusive
  683. // rectangles defined by 'pptl' and 'prcl' overlap:
  684. #define OVERLAP(prcl, pptl) \
  685. (((prcl)->right > (pptl)->x) && \
  686. ((prcl)->bottom > (pptl)->y) && \
  687. ((prcl)->left < ((pptl)->x + (prcl)->right - (prcl)->left)) && \
  688. ((prcl)->top < ((pptl)->y + (prcl)->bottom - (prcl)->top)))
  689. /////////////////////////////////////////////////////////////////////////
  690. // SWAP - Swaps the value of two variables, using a temporary variable
  691. #define SWAP32(a, b) \
  692. { \
  693. register ULONG tmp; \
  694. tmp = (ULONG)(a); \
  695. (ULONG)(a) = (ULONG)(b); \
  696. (ULONG)(b) = tmp; \
  697. }
  698. #define SWAP(a, b, tmp) { (tmp) = (a); (a) = (b); (b) = (tmp); }
  699. //////////////////////////////////////////////////////////
  700. _inline ULONG COLOR_REPLICATE(PDEV* ppdev, ULONG x)
  701. {
  702. ULONG ulResult = x;
  703. if (ppdev->cBpp == 1)
  704. {
  705. ulResult |= (ulResult << 8);
  706. }
  707. if (ppdev->cBpp <= 2)
  708. {
  709. ulResult |= (ulResult << 16);
  710. }
  711. return(ulResult);
  712. }
  713. /////////////////////////////////////////////////////////////////////////
  714. // DUMPVAR - Dumps a variable name and value to the debugger.
  715. // usage -> DUMPVAR(ppdev->cjPointerOffset,"%xh");
  716. #define DUMPVAR(x,format_str) DISPDBG((0,#x" = "format_str,x));