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.

1312 lines
50 KiB

  1. /******************************************************************************\
  2. *
  3. * $Workfile: driver.h $
  4. *
  5. * Contains prototypes for the display driver.
  6. *
  7. * Copyright (c) 1992-1995 Microsoft Corporation
  8. * Copyright (c) 1996 Cirrus Logic, Inc.
  9. *
  10. *
  11. * $Log: S:/projects/drivers/ntsrc/display/driver.h_v $
  12. *
  13. * Rev 1.7 Apr 03 1997 15:38:48 unknown
  14. *
  15. *
  16. * Rev 1.6 28 Mar 1997 16:08:38 PLCHU
  17. *
  18. *
  19. * Rev 1.5 18 Dec 1996 13:44:08 PLCHU
  20. *
  21. *
  22. * Rev 1.4 Dec 13 1996 12:16:18 unknown
  23. *
  24. *
  25. * Rev 1.3 Nov 07 1996 16:43:40 unknown
  26. * Clean up CAPS flags
  27. *
  28. * Rev 1.1 Oct 10 1996 15:36:36 unknown
  29. *
  30. *
  31. * Rev 1.13 12 Aug 1996 16:47:58 frido
  32. * Added NT 3.5x/4.0 auto detection.
  33. *
  34. * Rev 1.12 08 Aug 1996 16:20:06 frido
  35. * Added vMmCopyBlt36.
  36. *
  37. * Rev 1.11 31 Jul 1996 15:43:42 frido
  38. * Added new brush caches.
  39. *
  40. * Rev 1.10 24 Jul 1996 14:38:24 frido
  41. * Added ulFontCacheID for font cache cleanup.
  42. *
  43. * Rev 1.9 24 Jul 1996 14:30:26 frido
  44. * Changed some structures for a new FONTCACHE chain.
  45. *
  46. * Rev 1.8 22 Jul 1996 20:45:48 frido
  47. * Added font cache.
  48. *
  49. * Rev 1.7 19 Jul 1996 01:00:00 frido
  50. * Added Dbg... declarations.
  51. *
  52. * Rev 1.6 15 Jul 1996 10:58:58 frido
  53. * Changed back to old DirectDraw structures.
  54. *
  55. * Rev 1.5 12 Jul 1996 17:45:38 frido
  56. * Change DirectDraw structures.
  57. *
  58. * Rev 1.4 10 Jul 1996 13:07:34 frido
  59. * Changed LineTo function.
  60. *
  61. * Rev 1.3 09 Jul 1996 17:58:30 frido
  62. * Added LineTo code.
  63. *
  64. * Rev 1.2 03 Jul 1996 13:44:36 frido
  65. * Fixed a typo.
  66. *
  67. * Rev 1.1 03 Jul 1996 13:38:54 frido
  68. * Added DirectDraw support.
  69. *
  70. * sge01 10-23-96 Add 5446BE flag
  71. *
  72. * chu01 12-16-96 Enable color correction
  73. *
  74. * myf0 : 08-19-96 added 85hz supported
  75. * myf1 : 08-20-96 supported panning scrolling
  76. * myf2 : 08-20-96 : fixed hardware save/restore state bug for matterhorn
  77. * myf3 : 09-01-96 : Added IOCTL_CIRRUS_PRIVATE_BIOS_CALL for TV supported
  78. * myf4 : 09-01-96 : patch Viking BIOS bug, PDR #4287, begin
  79. * myf5 : 09-01-96 : Fixed PDR #4365 keep all default refresh rate
  80. * myf6 : 09-17-96 : Merged Desktop SRC1001 & MINI102
  81. * myf7 : 09-19-96 : Fixed exclude 60Hz refresh rate selected
  82. * myf8 :*09-21-96*: May be need change CheckandUpdateDDC2BMonitor --keystring[]
  83. * myf9 : 09-21-96 : 8x6 panel in 6x4x256 mode, cursor can't move to bottom scrn
  84. * ms0809:09-25-96 : fixed dstn panel icon corrupted
  85. * ms923 :09-25-96 : merge MS-923 Disp.zip code
  86. * myf10 :09-26-96 : Fixed DSTN reserved half-frame buffer bug.
  87. * myf11 :09-26-96 : Fixed 755x CE chip HW bug, access ramdac before disable HW
  88. * icons and cursor
  89. * myf12 :10-01-96 : Supported Hot Key switch display
  90. * myf13 :10-05-96 : Fixed /w panning scrolling, vertical expension on bug
  91. * myf14 :10-15-96 : Fixed PDR#6917, 6x4 panel can't panning scrolling for 754x
  92. * myf15 :10-16-96 : Fixed disable memory mapped IO for 754x, 755x
  93. * myf16 :10-22-96 : Fixed PDR #6933,panel type set different demo board setting
  94. * tao1 : 10-21-96 : added direct draw support for 7555.
  95. * pat04: 12-20-96 : Supported NT3.51 software cursor with panning scrolling
  96. * myf33 :03-21-97 : Support TV ON/OFF
  97. *
  98. \******************************************************************************/
  99. //////////////////////////////////////////////////////////////////////
  100. // Warning: The following defines are for private use only. They
  101. // should only be used in such a fashion that when defined as 0,
  102. // all code specific to punting is optimized out completely.
  103. #define DRIVER_PUNT_ALL 0
  104. #define DRIVER_PUNT_LINES 0
  105. #define DRIVER_PUNT_BLT 0
  106. #define DRIVER_PUNT_STRETCH 0
  107. #define DRIVER_PUNT_PTR 1
  108. #define DRIVER_PUNT_BRUSH 0
  109. // myf1 09-01-96
  110. //myf17 #define PANNING_SCROLL //myf1
  111. //////////////////////////////////////////////////////////////////////
  112. //////////////////////////////////////////////////////////////////////
  113. // Put all the conditional-compile constants here. There had better
  114. // not be many!
  115. // Some Mips machines have bus problems that prevent GDI from being able
  116. // to draw on the frame buffer. The DIRECT_ACCESS() macro is used to
  117. // determine if we are running on one of these machines. Also, we map
  118. // video memory as sparse on the ALPHA, so we need to control access to
  119. // the framebuffer through the READ/WRITE_REGISTER macros.
  120. #if defined(_ALPHA_)
  121. #define DIRECT_ACCESS(ppdev) FALSE
  122. #else
  123. #define DIRECT_ACCESS(ppdev) TRUE
  124. #endif
  125. #define BANKING TRUE //ms923
  126. #define HOST_XFERS_DISABLED(ppdev) (ppdev->pulXfer == NULL)
  127. // Useful for visualizing the 2-d heap:
  128. #define DEBUG_HEAP FALSE
  129. //////////////////////////////////////////////////////////////////////
  130. // Miscellaneous shared stuff
  131. #if (_WIN32_WINNT < 0x0400)
  132. // NT 3.51
  133. #define DLL_NAME L"cirrus35" // Name of the DLL in UNICODE
  134. #define NT_VERSION 0x0351
  135. #define ALLOC(c) LocalAlloc(LPTR, c)
  136. #define FREE(ptr) LocalFree(ptr)
  137. #define IOCONTROL(h, ctrl, in, cin, out, cout, c) \
  138. (DeviceIoControl(h, ctrl, in, cin, out, cout, c, NULL) == TRUE)
  139. #else
  140. // NT 4.0
  141. #define DLL_NAME L"cirrus" // Name of the DLL in UNICODE
  142. #define NT_VERSION 0x0400
  143. #define ALLOC(c) EngAllocMem(FL_ZERO_MEMORY, c, ALLOC_TAG)
  144. #define FREE(ptr) EngFreeMem(ptr)
  145. #define IOCONTROL(h, ctrl, in, cin, out, cout, c) \
  146. (EngDeviceIoControl(h, ctrl, in, cin, out, cout, c) == ERROR_SUCCESS)
  147. #endif
  148. // Default values if not yet defined.
  149. #ifndef GDI_DRIVER_VERSION
  150. #define GDI_DRIVER_VERSION 0x3500
  151. #endif
  152. #ifndef VIDEO_MODE_MAP_MEM_LINEAR
  153. #define VIDEO_MODE_MAP_MEM_LINEAR 0x40000000
  154. #endif
  155. #define STANDARD_PERF_PREFIX "Cirrus [perf]: " // All perf output is prefixed
  156. // by this string
  157. #define STANDARD_DEBUG_PREFIX "Cirrus: " // All debug output is prefixed
  158. // by this string
  159. #define ALLOC_TAG ' lcD' // Dcl
  160. // Four byte tag (characters in
  161. // reverse order) used for memory
  162. // allocations
  163. #define CLIP_LIMIT 50 // We'll be taking 800 bytes of stack space
  164. #define DRIVER_EXTRA_SIZE 0 // Size of the DriverExtra information in the
  165. // DEVMODE structure
  166. #define TMP_BUFFER_SIZE 8192 // Size in bytes of 'pvTmpBuffer'. Has to
  167. // be at least enough to store an entire
  168. // scan line (i.e., 6400 for 1600x1200x32).
  169. typedef struct _CLIPENUM {
  170. LONG c;
  171. RECTL arcl[CLIP_LIMIT]; // Space for enumerating complex clipping
  172. } CLIPENUM; /* ce, pce */
  173. ////////////////////////////////////////////////////////////////////////////////
  174. // D R I V E R C A P A B I L I T I E S //
  175. ////////////////////////////////////////////////////////////////////////////////
  176. #if (NT_VERSION < 0x0400)
  177. #define DIRECTDRAW 0 // DirectDraw not supported in NT 3.5x
  178. #define LINETO 0 // DrvLineTo not supported in NT 3.5x
  179. #else
  180. #define DIRECTDRAW 1 // DirectDraw supported in NT 4.0
  181. #define LINETO 0 // DrvLineTo not supported in NT 4.0
  182. #endif
  183. typedef struct _PDEV PDEV; // Handy forward declaration
  184. //////////////////////////////////////////////////////////////////////
  185. // Text stuff
  186. #if 1 // Font cache.
  187. #define MAX_GLYPHS 256 // Maximum number of glyphs per font.
  188. #define FONT_ALLOC_X 128 // X allocation per font block in bytes.
  189. #define FONT_ALLOC_Y 32 // Maximum height of font.
  190. typedef struct _OH OH;
  191. typedef struct _FONTMEMORY FONTMEMORY;
  192. typedef struct _FONTCACHE FONTCACHE;
  193. typedef struct _FONTMEMORY {
  194. OH* poh; // Pointer to allocated memory block.
  195. LONG x; // Last x of allocation.
  196. LONG cx, cy; // Size of allocation in bytes.
  197. LONG xy; // Linear address of current line.
  198. FONTMEMORY* pfmNext; // Pointer to next allocated memory block.
  199. } FONTMEMORY;
  200. #define GLYPH_UNCACHEABLE -1
  201. #define GLYPH_EMPTY -2
  202. typedef struct _GLYPHCACHE {
  203. BYTE* pjGlyph; // Linear address of glyph.
  204. // If pjPos == NULL then glyph has not yet been cached.
  205. POINTL ptlOrigin; // Origin of glyph.
  206. SIZEL sizlBytes; // Adjusted size of glyph.
  207. SIZEL sizlPixels; // Size of glyph.
  208. // If sizlSize.cy == -1 then glyph if uncacheable.
  209. // If sizlSize.cy == -2 then glyph is empty.
  210. LONG lDelta; // Width of glyph on bytes.
  211. } GLYPHCACHE;
  212. typedef struct _FONTCACHE {
  213. PDEV* ppdev; // Pointer to PDEV structure.
  214. FONTMEMORY* pfm; // Pointer to first FONTMEMORY structure.
  215. LONG cWidth; // Width of allocation in pixels.
  216. LONG cHeight; // Height of allocation in pixels.
  217. ULONG ulFontCacheID; // Font cache ID.
  218. FONTOBJ* pfo; // Pointer to FONT object for this cache.
  219. FONTCACHE* pfcPrev; // Pointer to previous FONTCACHE structure.
  220. FONTCACHE* pfcNext; // Pointer to next FONTCACHE structure.
  221. GLYPHCACHE aGlyphs[MAX_GLYPHS]; // Array of cached glyphs.
  222. } FONTCACHE;
  223. typedef struct _XLATECOLORS { // Specifies foreground and background
  224. ULONG iBackColor; // colours for faking a 1bpp XLATEOBJ
  225. ULONG iForeColor;
  226. } XLATECOLORS; /* xlc, pxlc */
  227. BOOL bEnableText(PDEV*);
  228. VOID vDisableText(PDEV*);
  229. VOID vAssertModeText(PDEV*, BOOL);
  230. VOID vClearMemDword(ULONG*, ULONG);
  231. LONG cGetGlyphSize(GLYPHBITS*, POINTL*, SIZEL*);
  232. LONG lAllocateGlyph(FONTCACHE*, GLYPHBITS*, GLYPHCACHE*);
  233. BYTE* pjAllocateFontCache(FONTCACHE*, LONG);
  234. BOOL bFontCache(PDEV*, STROBJ*, FONTOBJ*, CLIPOBJ*, RECTL*, BRUSHOBJ*,
  235. BRUSHOBJ*);
  236. VOID vDrawGlyph(PDEV*, GLYPHBITS*, POINTL);
  237. VOID vClipGlyph(PDEV*, GLYPHBITS*, POINTL, RECTL*, ULONG);
  238. #if 1 // D5480
  239. VOID vMmGlyphOut(PDEV*, FONTCACHE*, STROBJ*, ULONG);
  240. VOID vMmGlyphOutClip(PDEV*, FONTCACHE*, STROBJ*, RECTL*, ULONG);
  241. VOID vMmGlyphOut80(PDEV*, FONTCACHE*, STROBJ*, ULONG);
  242. VOID vMmGlyphOutClip80(PDEV*, FONTCACHE*, STROBJ*, RECTL*, ULONG);
  243. #endif // endif D5480
  244. #endif
  245. //////////////////////////////////////////////////////////////////////
  246. // Dither stuff
  247. // Describes a single colour tetrahedron vertex for dithering:
  248. typedef struct _VERTEX_DATA {
  249. ULONG ulCount; // Number of pixels in this vertex
  250. ULONG ulVertex; // Vertex number
  251. } VERTEX_DATA; /* vd, pv */
  252. VERTEX_DATA* vComputeSubspaces(ULONG, VERTEX_DATA*);
  253. VOID vDitherColor(ULONG*, VERTEX_DATA*, VERTEX_DATA*, ULONG);
  254. VOID vDitherColorToVideoMemory(ULONG*, VERTEX_DATA*, VERTEX_DATA*, ULONG);
  255. //////////////////////////////////////////////////////////////////////
  256. // Brush stuff
  257. // 'Fast' brushes are used when we have hardware pattern capability:
  258. #define FAST_BRUSH_COUNT 16 // Total number of non-hardware brushes
  259. // cached off-screen
  260. #define FAST_BRUSH_DIMENSION 8 // Every off-screen brush cache entry
  261. // is 8 pels in both dimensions
  262. #define FAST_BRUSH_ALLOCATION 8 // We have to align ourselves, so this is
  263. // the dimension of each brush allocation
  264. // Common to both implementations:
  265. #define RBRUSH_2COLOR 1 // For RBRUSH flags
  266. #if 1 // New brush cache.
  267. #define RBRUSH_PATTERN 0 // Colored brush.
  268. #define RBRUSH_MONOCHROME 1 // Monochrome brush.
  269. #define RBRUSH_DITHER 2 // Dithered brush.
  270. #define RBRUSH_XLATE 3 // 16-color translated brush.
  271. #endif
  272. #define TOTAL_BRUSH_COUNT FAST_BRUSH_COUNT
  273. // This is the maximum number of brushes
  274. // we can possibly have cached off-screen
  275. #define TOTAL_BRUSH_SIZE 64 // We'll only ever handle 8x8 patterns,
  276. // and this is the number of pels
  277. #define BRUSH_TILE_FACTOR 4 // 2x2 tiled patterns require 4x the space
  278. typedef struct _BRUSHENTRY BRUSHENTRY;
  279. // NOTE: Changes to the RBRUSH or BRUSHENTRY structures must be reflected
  280. // in strucs.inc!
  281. typedef struct _RBRUSH {
  282. FLONG fl; // Type flags
  283. ULONG ulForeColor; // Foreground colour if 1bpp
  284. ULONG ulBackColor; // Background colour if 1bpp
  285. POINTL ptlBrushOrg; // Brush origin of cached pattern. Initial
  286. // value should be -1
  287. BRUSHENTRY* pbe; // Points to brush-entry that keeps track
  288. // of the cached off-screen brush bits
  289. #if 1 // New brush cache.
  290. ULONG ulUniq; // Unique value for cached brushes.
  291. ULONG ulSlot; // Offset to cache slot (PDEV relative).
  292. ULONG ulBrush; // Offset to off-screen brush.
  293. LONG cjBytes; // Number of bytes in pattern.
  294. #endif
  295. ULONG aulPattern[0]; // Open-ended array for keeping copy of the
  296. // Don't put anything // actual pattern bits in case the brush
  297. // after here, or // origin changes, or someone else steals
  298. // you'll be sorry! // our brush entry (declared as a ULONG
  299. // for proper dword alignment)
  300. } RBRUSH; /* rb, prb */
  301. typedef struct _BRUSHENTRY {
  302. RBRUSH* prbVerify; // We never dereference this pointer to
  303. // find a brush realization; it is only
  304. // ever used in a compare to verify
  305. // that for a given realized brush, our
  306. // off-screen brush entry is still valid.
  307. LONG x; // x-position of cached pattern
  308. LONG y; // y-position of cached pattern
  309. LONG xy; // offset of cached pattern
  310. } BRUSHENTRY; /* be, pbe */
  311. typedef union _RBRUSH_COLOR {
  312. RBRUSH* prb;
  313. ULONG iSolidColor;
  314. } RBRUSH_COLOR; /* rbc, prbc */
  315. BOOL bEnableBrushCache(PDEV*);
  316. VOID vDisableBrushCache(PDEV*);
  317. VOID vAssertModeBrushCache(PDEV*, BOOL);
  318. #if 1 // New brush cache.
  319. #define NUM_DITHERS 8
  320. #define NUM_PATTERNS 8
  321. #define NUM_MONOCHROMES 20
  322. typedef struct _DITHERCACHE {
  323. ULONG ulBrush; // Offset to off-screen brush.
  324. ULONG ulColor; // Logical color.
  325. } DITHERCACHE;
  326. typedef struct _PATTERNCACHE {
  327. ULONG ulBrush; // Offset to off-screen brush.
  328. RBRUSH* prbUniq; // Pointer to realized brush.
  329. } PATTERNCACHE;
  330. typedef struct _MONOCACHE {
  331. ULONG ulBrush; // Offset to off-screen brush cache.
  332. ULONG ulUniq; // Unique counter for brush.
  333. ULONG ulBackColor; // Background color for 24-bpp.
  334. ULONG ulForeColor; // Foreground color for 24-bpp.
  335. ULONG aulPattern[2]; // Monochrome pattern.
  336. } MONOCACHE;
  337. BOOL bCacheDither(PDEV*, RBRUSH*);
  338. BOOL bCachePattern(PDEV*, RBRUSH*);
  339. BOOL bCacheMonochrome(PDEV*, RBRUSH*);
  340. #endif
  341. //////////////////////////////////////////////////////////////////////
  342. // Stretch stuff
  343. typedef struct _STR_BLT {
  344. PDEV* ppdev;
  345. PBYTE pjSrcScan;
  346. LONG lDeltaSrc;
  347. LONG XSrcStart;
  348. PBYTE pjDstScan;
  349. LONG lDeltaDst;
  350. LONG XDstStart;
  351. LONG XDstEnd;
  352. LONG YDstStart;
  353. LONG YDstCount;
  354. ULONG ulXDstToSrcIntCeil;
  355. ULONG ulXDstToSrcFracCeil;
  356. ULONG ulYDstToSrcIntCeil;
  357. ULONG ulYDstToSrcFracCeil;
  358. ULONG ulXFracAccumulator;
  359. ULONG ulYFracAccumulator;
  360. } STR_BLT;
  361. typedef VOID (*PFN_DIRSTRETCH)(STR_BLT*);
  362. VOID vDirectStretch8Narrow(STR_BLT*);
  363. VOID vDirectStretch8(STR_BLT*);
  364. VOID vDirectStretch16(STR_BLT*);
  365. VOID vDirectStretch24(STR_BLT*);
  366. VOID vDirectStretch32(STR_BLT*);
  367. #if 1 // D5480 chu01
  368. VOID vDirectStretch8_80(STR_BLT*) ;
  369. VOID vDirectStretch16_80(STR_BLT*) ;
  370. VOID vDirectStretch24_80(STR_BLT*) ;
  371. #endif // D5480 chu01
  372. /////////////////////////////////////////////////////////////////////////
  373. // Heap stuff
  374. typedef enum {
  375. OFL_INUSE = 1, // The device bitmap is no longer located in
  376. // off-screen memory; it's been converted to
  377. // a DIB
  378. OFL_AVAILABLE = 2, // Space is in-use
  379. OFL_PERMANENT = 4 // Space is available
  380. } OHFLAGS; // Space is permanently allocated; never free it
  381. typedef struct _DSURF DSURF;
  382. typedef struct _OH OH;
  383. typedef struct _OH
  384. {
  385. OHFLAGS ofl; // OH_ flags
  386. LONG x; // x-coordinate of left edge of allocation
  387. LONG y; // y-coordinate of top edge of allocation
  388. LONG xy; // offset to top left corner of allocation
  389. LONG cx; // Width in pixels of allocation
  390. LONG cy; // Height in pixels of allocation
  391. OH* pohNext; // When OFL_AVAILABLE, points to the next free node,
  392. // in ascending cxcy value. This is kept as a
  393. // circular doubly-linked list with a sentinel
  394. // at the end.
  395. // When OFL_INUSE, points to the next most recently
  396. // blitted allocation. This is kept as a circular
  397. // doubly-linked list so that the list can be
  398. // quickly be updated on every blt.
  399. OH* pohPrev; // Opposite of 'pohNext'
  400. ULONG cxcy; // Width and height in a dword for searching
  401. OH* pohLeft; // Adjacent allocation when in-use or available
  402. OH* pohUp;
  403. OH* pohRight;
  404. OH* pohDown;
  405. DSURF* pdsurf; // Points to our DSURF structure
  406. VOID* pvScan0; // Points to start of first scan-line
  407. }; /* oh, poh */
  408. // This is the smallest structure used for memory allocations:
  409. typedef struct _OHALLOC OHALLOC;
  410. typedef struct _OHALLOC
  411. {
  412. OHALLOC* pohaNext;
  413. OH aoh[1];
  414. } OHALLOC; /* oha, poha */
  415. typedef struct _HEAP
  416. {
  417. LONG cxMax; // Largest possible free space by area
  418. LONG cyMax;
  419. OH ohAvailable; // Head of available list (pohNext points to
  420. // smallest available rectangle, pohPrev
  421. // points to largest available rectangle,
  422. // sorted by cxcy)
  423. OH ohDfb; // Head of the list of all DFBs currently in
  424. // offscreen memory that are eligible to be
  425. // tossed out of the heap (pohNext points to
  426. // the most recently blitted; pohPrev points
  427. // to least recently blitted)
  428. OH* pohFreeList; // List of OH node data structures available
  429. OHALLOC* pohaChain; // Chain of allocations
  430. } HEAP; /* heap, pheap */
  431. typedef enum {
  432. DT_SCREEN, // Surface is kept in screen memory
  433. DT_DIB // Surface is kept as a DIB
  434. } DSURFTYPE; /* dt, pdt */
  435. typedef struct _DSURF
  436. {
  437. DSURFTYPE dt; // DSURF status (whether off-screen or in a DIB)
  438. SIZEL sizl; // Size of the original bitmap (could be smaller
  439. // than poh->sizl)
  440. PDEV* ppdev; // Need this for deleting the bitmap
  441. union {
  442. OH* poh; // If DT_SCREEN, points to off-screen heap node
  443. SURFOBJ* pso; // If DT_DIB, points to locked GDI surface
  444. };
  445. // The following are used for DT_DIB only...
  446. ULONG cBlt; // Counts down the number of blts necessary at
  447. // the current uniqueness before we'll consider
  448. // putting the DIB back into off-screen memory
  449. ULONG iUniq; // Tells us whether there have been any heap
  450. // 'free's since the last time we looked at
  451. // this DIB
  452. } DSURF; /* dsurf, pdsurf */
  453. // GDI expects dword alignment for any bitmaps on which it is expected
  454. // to draw. Since we occasionally ask GDI to draw directly on our off-
  455. // screen bitmaps, this means that any off-screen bitmaps must be dword
  456. // aligned in the frame buffer. We enforce this merely by ensuring that
  457. // all off-screen bitmaps are four-pel aligned (we may waste a couple of
  458. // pixels at the higher colour depths):
  459. #define HEAP_X_ALIGNMENT 8
  460. // Number of blts necessary before we'll consider putting a DIB DFB back
  461. // into off-screen memory:
  462. #define HEAP_COUNT_DOWN 6
  463. // Flags for 'pohAllocate':
  464. typedef enum {
  465. FLOH_ONLY_IF_ROOM = 0x00000001, // Don't kick stuff out of off-
  466. // screen memory to make room
  467. } FLOH;
  468. BOOL bEnableOffscreenHeap(PDEV*);
  469. VOID vDisableOffscreenHeap(PDEV*);
  470. BOOL bAssertModeOffscreenHeap(PDEV*, BOOL);
  471. OH* pohMoveOffscreenDfbToDib(PDEV*, OH*);
  472. BOOL bMoveDibToOffscreenDfbIfRoom(PDEV*, DSURF*);
  473. OH* pohAllocatePermanent(PDEV*, LONG, LONG);
  474. BOOL bMoveAllDfbsFromOffscreenToDibs(PDEV* ppdev);
  475. OH* pohAllocate(PDEV*, LONG, LONG, FLOH);
  476. OH* pohFree(PDEV*, OH*);
  477. VOID vCalculateMaximum(PDEV*);
  478. /////////////////////////////////////////////////////////////////////////
  479. // Bank manager stuff
  480. #define BANK_DATA_SIZE 80 // Number of bytes to allocate for the
  481. // miniport down-loaded bank code working
  482. // space
  483. typedef struct _BANK
  484. {
  485. // Private data:
  486. RECTL rclDraw; // Rectangle describing the remaining undrawn
  487. // portion of the drawing operation
  488. RECTL rclSaveBounds; // Saved from original CLIPOBJ for restoration
  489. BYTE iSaveDComplexity; // Saved from original CLIPOBJ for restoration
  490. BYTE fjSaveOptions; // Saved from original CLIPOBJ for restoration
  491. LONG iBank; // Current bank
  492. PDEV* ppdev; // Saved copy
  493. // Public data:
  494. SURFOBJ* pso; // Surface wrapped around the bank. Has to be
  495. // passed as the surface in any banked call-
  496. // back.
  497. CLIPOBJ* pco; // Clip object that is the intersection of the
  498. // original clip object with the bounds of the
  499. // current bank. Has to be passed as the clip
  500. // object in any banked call-back.
  501. } BANK; /* bnk, pbnk */
  502. typedef enum {
  503. BANK_OFF = 0, // We've finished using the memory aperture
  504. BANK_ON, // We're about to use the memory aperture
  505. BANK_DISABLE, // We're about to enter full-screen; shut down banking
  506. BANK_ENABLE, // We've exited full-screen; re-enable banking
  507. } BANK_MODE; /* bankm, pbankm */
  508. typedef VOID (FNBANKMAP)(PDEV*, LONG);
  509. typedef VOID (FNBANKSELECTMODE)(PDEV*, BANK_MODE);
  510. typedef VOID (FNBANKINITIALIZE)(PDEV*, BOOL);
  511. typedef BOOL (FNBANKCOMPUTE)(PDEV*, RECTL*, RECTL*, LONG*, LONG*);
  512. VOID vBankStart(PDEV*, RECTL*, CLIPOBJ*, BANK*);
  513. BOOL bBankEnum(BANK*);
  514. FNBANKCOMPUTE bBankComputeNonPower2;
  515. FNBANKCOMPUTE bBankComputePower2;
  516. BOOL bEnableBanking(PDEV*);
  517. VOID vDisableBanking(PDEV*);
  518. VOID vAssertModeBanking(PDEV*, BOOL);
  519. /////////////////////////////////////////////////////////////////////////
  520. // Pointer stuff
  521. typedef VOID (FNSHOWPOINTER)(VOID*, BOOL);
  522. typedef VOID (FNMOVEPOINTER)(VOID*, LONG, LONG);
  523. typedef BOOL (FNSETPOINTERSHAPE)(VOID*, LONG, LONG, LONG, LONG, LONG, LONG, BYTE*);
  524. typedef VOID (FNENABLEPOINTER)(VOID*, BOOL);
  525. BOOL bEnablePointer(PDEV*);
  526. VOID vDisablePointer(PDEV*);
  527. VOID vAssertModePointer(PDEV*, BOOL);
  528. VOID vAssertHWiconcursor(PDEV*, BOOL); //myf11
  529. UCHAR HWcur, HWicon0, HWicon1, HWicon2, HWicon3; //myf11
  530. /////////////////////////////////////////////////////////////////////////
  531. // Palette stuff
  532. BOOL bEnablePalette(PDEV*);
  533. VOID vDisablePalette(PDEV*);
  534. VOID vAssertModePalette(PDEV*, BOOL);
  535. BOOL bInitializePalette(PDEV*, DEVINFO*);
  536. VOID vUninitializePalette(PDEV*);
  537. #define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
  538. #if DIRECTDRAW
  539. //////////////////////////////////////////////////////////////////////
  540. // DirectDraw stuff
  541. #define ROUND_UP_TO_64K(x) (((ULONG)(x) + 0xFFFF) & ~0xFFFF)
  542. typedef struct _FLIPRECORD
  543. {
  544. FLATPTR fpFlipFrom; // Surface we last flipped from
  545. LONGLONG liFlipTime; // Time at which last flip occured
  546. LONGLONG liFlipDuration; // Precise amount of time it takes from
  547. // vblank to vblank
  548. BOOL bFlipFlag; // True if we think a flip is still
  549. // pending
  550. BOOL bHaveEverCrossedVBlank; // True if we noticed that we switched
  551. // from inactive to vblank
  552. BOOL bWasEverInDisplay; // True is we ever noticed that we were
  553. // inactive
  554. // crus
  555. DWORD dwFlipScanLine;
  556. } FLIPRECORD;
  557. BOOL bEnableDirectDraw(PDEV*);
  558. VOID vDisableDirectDraw(PDEV*);
  559. VOID vAssertModeDirectDraw(PDEV*, BOOL);
  560. #endif
  561. //////////////////////////////////////////////////////////////////////
  562. // Low-level blt function prototypes
  563. typedef VOID (FNFILL)(PDEV*, LONG, RECTL*, ROP4, RBRUSH_COLOR, POINTL*);
  564. typedef VOID (FNXFER)(PDEV*, LONG, RECTL*, ROP4, SURFOBJ*, POINTL*,
  565. RECTL*, XLATEOBJ*);
  566. typedef VOID (FNCOPY)(PDEV*, LONG, RECTL*, ROP4, POINTL*, RECTL*);
  567. typedef VOID (FNFASTPATREALIZE)(PDEV*, RBRUSH*);
  568. typedef VOID (FNBITS)(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  569. typedef BOOL (FNFASTFILL)(PDEV*, LONG, POINTFIX*, ULONG, ULONG, RBRUSH*,
  570. POINTL*, RECTL*);
  571. #if LINETO
  572. typedef BOOL (FNLINETO)(PDEV*, LONG, LONG, LONG, LONG, ULONG, MIX, ULONG);
  573. #endif
  574. #if 1 // D5480
  575. typedef VOID (FNGLYPHOUT)(PDEV*, FONTCACHE*, STROBJ*, ULONG);
  576. typedef VOID (FNGLYPHOUTCLIP)(PDEV*, FONTCACHE*, STROBJ*, RECTL*, ULONG);
  577. #endif // endif D5480
  578. #if 1 // OVERLAY #sge
  579. #if (_WIN32_WINNT >= 0x0400) //myf33
  580. typedef VOID (FNREGINITVIDEO)(PDEV* ppdev, PDD_SURFACE_LOCAL lpSurface);
  581. typedef VOID (FNREGMOVEVIDEO)(PDEV* ppdev, PDD_SURFACE_LOCAL lpSurface);
  582. typedef BOOL (FNBANDWIDTHEQ)(PDEV* ppdev, WORD wVideoDepth, LPRECTL lpSrc, LPRECTL lpDest, DWORD dwFlags);
  583. typedef VOID (FNDISABLEOVERLAY)(PDEV* ppdev);
  584. typedef VOID (FNCLEARALTFIFO)(PDEV* ppdev);
  585. #endif
  586. #endif
  587. FNFILL vIoFillPat;
  588. FNFILL vIoFillSolid;
  589. FNXFER vIoXfer1bpp;
  590. FNXFER vIoXfer4bpp;
  591. FNXFER vIoXferNative;
  592. FNCOPY vIoCopyBlt;
  593. FNFASTPATREALIZE vIoFastPatRealize;
  594. #if LINETO
  595. FNLINETO bIoLineTo;
  596. #endif
  597. FNFILL vMmFillPat;
  598. FNFILL vMmFillSolid;
  599. #if 1 // New pattern blt routines.
  600. FNFILL vMmFillPat36;
  601. FNFILL vMmFillSolid36;
  602. FNCOPY vMmCopyBlt36;
  603. #endif
  604. FNXFER vMmXfer1bpp;
  605. FNXFER vMmXfer4bpp;
  606. FNXFER vMmXferNative;
  607. FNCOPY vMmCopyBlt;
  608. FNFASTPATREALIZE vMmFastPatRealize;
  609. #if LINETO
  610. FNLINETO bMmLineTo;
  611. #endif
  612. FNFASTFILL bFastFill;
  613. FNXFER vXferNativeSrccopy;
  614. FNXFER vXferScreenTo1bpp;
  615. FNBITS vPutBits;
  616. FNBITS vGetBits;
  617. FNBITS vPutBitsLinear;
  618. FNBITS vGetBitsLinear;
  619. #if 1 // D5480
  620. FNGLYPHOUT vMmGlyphOut;
  621. FNGLYPHOUT vMmGlyphOut80;
  622. FNGLYPHOUTCLIP vMmGlyphOutClip;
  623. FNGLYPHOUTCLIP vMmGlyphOutClip80;
  624. FNFILL vMmFillSolid80;
  625. FNFILL vMmFillPat80;
  626. FNCOPY vMmCopyBlt80;
  627. FNXFER vMmXfer1bpp80;
  628. FNXFER vMmXferNative80;
  629. #endif // endif D5480
  630. VOID vPutBits(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  631. VOID vGetBits(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  632. VOID vGetBitsLinear(PDEV*, SURFOBJ*, RECTL*, POINTL*);
  633. VOID vIoSlowPatRealize(PDEV*, RBRUSH*, BOOL);
  634. ////////////////////////////////////////////////////////////////////////
  635. // Capabilities flags
  636. //
  637. // These are private flags passed to us from the video miniport. They
  638. // come from the 'DriverSpecificAttributeFlags' field of the
  639. // 'VIDEO_MODE_INFORMATION' structure (found in 'ntddvdeo.h') passed
  640. // to us via an 'VIDEO_QUERY_AVAIL_MODES' or 'VIDEO_QUERY_CURRENT_MODE'
  641. // IOCTL.
  642. //
  643. // NOTE: These definitions must match those in the video miniport
  644. #define CAPS_NO_HOST_XFER 0x00000002 // Do not use host xfers to
  645. // the blt engine.
  646. #define CAPS_SW_POINTER 0x00000004 // Use software pointer.
  647. #define CAPS_TRUE_COLOR 0x00000008 // Set upper color registers.
  648. #define CAPS_MM_IO 0x00000010 // Use memory mapped IO.
  649. #define CAPS_BLT_SUPPORT 0x00000020 // BLTs are supported
  650. #define CAPS_IS_542x 0x00000040 // This is a 542x
  651. #define CAPS_AUTOSTART 0x00000080 // Autostart feature support.
  652. #define CAPS_CURSOR_VERT_EXP 0x00000100 // Flag set if 8x6 panel,
  653. #define CAPS_DSTN_PANEL 0x00000200 // DSTN panel in use, ms0809
  654. #define CAPS_VIDEO 0x00000400 // Video support.
  655. #define CAPS_SECOND_APERTURE 0x00000800 // Second aperture support.
  656. #define CAPS_COMMAND_LIST 0x00001000 // Command List support.
  657. #define CAPS_GAMMA_CORRECT 0x00002000 // Color correction.
  658. #define CAPS_VGA_PANEL 0x00004000 // use 6x4 VGA PANEL.
  659. #define CAPS_SVGA_PANEL 0x00008000 // use 8x6 SVGA PANEL.
  660. #define CAPS_XGA_PANEL 0x00010000 // use 10x7 XGA PANEL.
  661. #define CAPS_PANNING 0x00020000 // Panning scrolling supported.
  662. #define CAPS_TV_ON 0x00040000 // TV turn on supported., myf33
  663. #define CAPS_TRANSPARENCY 0x00080000 // Transparency is supported
  664. #define CAPS_ENGINEMANAGED 0x00100000 // Engine managed surface
  665. //myf16, end
  666. ////////////////////////////////////////////////////////////////////////
  667. // Status flags
  668. typedef enum {
  669. STAT_GLYPH_CACHE = 0x0001, // Glyph cache successfully allocated
  670. STAT_BRUSH_CACHE = 0x0002, // Brush cache successfully allocated
  671. #if 1 // New status flags.
  672. STAT_DIRECTDRAW = 0x0004, // DirectDraw is enabled.
  673. STAT_FONT_CACHE = 0x0008, // Font cache is available.
  674. STAT_DITHER_CACHE = 0x0010, // Dither cache is available.
  675. STAT_PATTERN_CACHE = 0x0020, // Pattern cache is available.
  676. STAT_MONOCHROME_CACHE = 0x0040, // Monochrome cache is available.
  677. // crus
  678. STAT_STREAMS_ENABLED = 0x0080 // Overlay support
  679. #endif
  680. } STATUS;
  681. // crus
  682. #if 1 // OVERLAY #sge
  683. #define MAX_STRETCH_SIZE 1024
  684. typedef struct
  685. {
  686. RECTL rDest;
  687. RECTL rSrc;
  688. DWORD dwFourcc; //overlay video format
  689. WORD wBitCount; //overlay color depth
  690. LONG lAdjustSource; //when video start address needs adjusting
  691. } OVERLAYWINDOW;
  692. #endif
  693. //
  694. // Merger port and register access
  695. //
  696. #if defined(_X86_) || defined(_IA64_) || defined(_AMD64_)
  697. typedef UCHAR (*FnREAD_PORT_UCHAR)(PVOID Port);
  698. typedef USHORT (*FnREAD_PORT_USHORT)(PVOID Port);
  699. typedef ULONG (*FnREAD_PORT_ULONG)(PVOID Port);
  700. typedef VOID (*FnWRITE_PORT_UCHAR)(PVOID Port, UCHAR Value);
  701. typedef VOID (*FnWRITE_PORT_USHORT)(PVOID Port, USHORT Value);
  702. typedef VOID (*FnWRITE_PORT_ULONG)(PVOID Port, ULONG Value);
  703. #elif defined(_ALPHA_)
  704. typedef UCHAR (*FnREAD_PORT_UCHAR)(PVOID Port);
  705. typedef USHORT (*FnREAD_PORT_USHORT)(PVOID Port);
  706. typedef ULONG (*FnREAD_PORT_ULONG)(PVOID Port);
  707. typedef VOID (*FnWRITE_PORT_UCHAR)(PVOID Port, ULONG Value);
  708. typedef VOID (*FnWRITE_PORT_USHORT)(PVOID Port, ULONG Value);
  709. typedef VOID (*FnWRITE_PORT_ULONG)(PVOID Port, ULONG Value);
  710. #endif
  711. ////////////////////////////////////////////////////////////////////////
  712. // The Physical Device data structure
  713. typedef struct _PDEV
  714. {
  715. LONG xOffset;
  716. LONG yOffset;
  717. LONG xyOffset;
  718. BYTE* pjBase; // Video coprocessor base
  719. BYTE* pjPorts; // Video port base
  720. BYTE* pjScreen; // Points to base screen address
  721. ULONG iBitmapFormat; // BMF_8BPP or BMF_16BPP or BMF_24BPP
  722. // (our current colour depth)
  723. ULONG ulChipID;
  724. ULONG ulChipNum;
  725. // -------------------------------------------------------------------
  726. // NOTE: Changes up to here in the PDEV structure must be reflected in
  727. // i386\strucs.inc (assuming you're on an x86, of course)!
  728. HBITMAP hbmTmpMono; // Handle to temporary buffer
  729. SURFOBJ* psoTmpMono; // Temporary surface
  730. ULONG flCaps; // Capabilities flags
  731. //myf1, begin
  732. // Panning Scrolling Supported for TI
  733. LONG min_Xscreen; //Visible screen boundary.
  734. LONG max_Xscreen; //Visible screen boundary.
  735. LONG min_Yscreen; //Visible screen boundary.
  736. LONG max_Yscreen; //Visible screen boundary.
  737. LONG Hres; //current mode horizontal piexl.
  738. LONG Vres; //current mode vertical piexl.
  739. //myf1, end
  740. SHORT bBlockSwitch; //display switch block flag //myf12
  741. SHORT bDisplaytype; //display type, 0:LCD, 1:CRT, 2:SIM //myf12
  742. STATUS flStatus; // Status flags
  743. BOOL bEnabled; // In graphics mode (not full-screen)
  744. HANDLE hDriver; // Handle to \Device\Screen
  745. HDEV hdevEng; // Engine's handle to PDEV
  746. HSURF hsurfScreen; // Engine's handle to screen surface
  747. DSURF* pdsurfScreen; // Our private DSURF for the screen
  748. LONG cxScreen; // Visible screen width
  749. LONG cyScreen; // Visible screen height
  750. LONG cxMemory; // Width of Video RAM
  751. LONG cyMemory; // Height of Video RAM
  752. ULONG ulMemSize; // Amount of video Memory
  753. ULONG ulMode; // Mode the mini-port driver is in.
  754. LONG lDelta; // Distance from one scan to the next.
  755. FLONG flHooks; // What we're hooking from GDI
  756. LONG cBitsPerPixel; // 8 if 8bpp, 16 if 16bpp, 32 if 32bpp
  757. LONG cBpp; // 1 if 8bpp, 2 if 16bpp, 3 if 24bpp, etc.
  758. //
  759. // The compiler should maintain DWORD alignment for the values following
  760. // the BYTE jModeColor. There will be an ASSERT to guarentee this.
  761. //
  762. BYTE jModeColor; // HW flag for current color depth
  763. ULONG ulWhite; // 0xff if 8bpp, 0xffff if 16bpp,
  764. // 0xffffffff if 32bpp
  765. VOID* pvTmpBuffer; // General purpose temporary buffer,
  766. // TMP_BUFFER_SIZE bytes in size
  767. // (Remember to synchronize if you
  768. // use this for device bitmaps or
  769. // async pointers)
  770. LONG lXferBank;
  771. ULONG* pulXfer;
  772. ////////// Low-level blt function pointers:
  773. FNFILL* pfnFillSolid;
  774. FNFILL* pfnFillPat;
  775. FNXFER* pfnXfer1bpp;
  776. FNXFER* pfnXfer4bpp;
  777. FNXFER* pfnXferNative;
  778. FNCOPY* pfnCopyBlt;
  779. FNFASTPATREALIZE* pfnFastPatRealize;
  780. FNBITS* pfnGetBits;
  781. FNBITS* pfnPutBits;
  782. #if LINETO
  783. FNLINETO* pfnLineTo;
  784. #endif
  785. ////////// Palette stuff:
  786. PALETTEENTRY* pPal; // The palette if palette managed
  787. //
  788. // chu01 : GAMMACORRECT
  789. //
  790. PALETTEENTRY* pCurrentPalette ; // The global palette for gamma
  791. // correction.
  792. HPALETTE hpalDefault; // GDI handle to the default palette.
  793. FLONG flRed; // Red mask for 16/32bpp bitfields
  794. FLONG flGreen; // Green mask for 16/32bpp bitfields
  795. FLONG flBlue; // Blue mask for 16/32bpp bitfields
  796. ////////// Heap stuff:
  797. HEAP heap; // All our off-screen heap data
  798. ULONG iHeapUniq; // Incremented every time room is freed
  799. // in the off-screen heap
  800. SURFOBJ* psoPunt; // Wrapper surface for having GDI draw
  801. // on off-screen bitmaps
  802. SURFOBJ* psoPunt2; // Another one for off-screen to off-
  803. // screen blts
  804. OH* pohScreen; // Allocation structure for the screen
  805. ////////// Banking stuff:
  806. ULONG ulBankShiftFactor;
  807. BOOL bLinearMode; // True if the framebuffer is linear
  808. LONG cjBank; // Size of a bank, in bytes
  809. LONG cPower2ScansPerBank; // Used by 'bBankComputePower2'
  810. LONG cPower2BankSizeInBytes; // Used by 'bBankComputePower2'
  811. CLIPOBJ* pcoBank; // Clip object for banked call backs
  812. SURFOBJ* psoBank; // Surface object for banked call backs
  813. SURFOBJ* psoFrameBuffer; // Surface object for non-banked call backs
  814. VOID* pvBankData; // Points to aulBankData[0]
  815. ULONG aulBankData[BANK_DATA_SIZE / 4];
  816. // Private work area for downloaded
  817. // miniport banking code
  818. FNBANKMAP* pfnBankMap;
  819. FNBANKSELECTMODE* pfnBankSelectMode;
  820. FNBANKCOMPUTE* pfnBankCompute;
  821. ////////// Pointer stuff:
  822. LONG xPointerHot; // xHot of current hardware pointer
  823. LONG yPointerHot; // yHot of current hardware pointer
  824. LONG xPointerShape; // xPos of current hardware pointer
  825. LONG yPointerShape; // yPos of current hardware pointer
  826. SIZEL sizlPointer; // Size of current hardware pointer
  827. //ms923 LONG lDeltaPointer; // Row offset for hardware pointer
  828. FLONG flPointer; // Flags reflecting pointer state
  829. PBYTE pjPointerAndMask;
  830. PBYTE pjPointerXorMask;
  831. LONG iPointerBank; // Bank containing pointer shape
  832. VOID* pvPointerShape; // Points to pointer shape when bank
  833. // is mapped in
  834. LONG cjPointerOffset; // Byte offset from start of frame
  835. // buffer to off-screen memory where
  836. // we stored the pointer shape
  837. //pat04, for NT 3.51 software cursor, begin
  838. #if (_WIN32_WINNT < 0x0400)
  839. #ifdef PANNING_SCROLL
  840. OH* pjCBackground;
  841. OH* pjPointerAndCMask;
  842. OH* pjPointerCBitmap ;
  843. LONG xcount;
  844. LONG ppScanLine;
  845. LONG oldx; // old x cordinate
  846. LONG oldy; // old y cordinate
  847. LONG globdat;
  848. #endif
  849. #endif
  850. //pat04, for NT 3.51 software cursor, end
  851. FNSHOWPOINTER* pfnShowPointer;
  852. FNMOVEPOINTER* pfnMovePointer;
  853. FNSETPOINTERSHAPE* pfnSetPointerShape;
  854. FNENABLEPOINTER* pfnEnablePointer;
  855. ////////// Brush stuff:
  856. LONG iBrushCache; // Index for next brush to be allocated
  857. LONG cBrushCache; // Total number of brushes cached
  858. BRUSHENTRY abe[TOTAL_BRUSH_COUNT]; // Keeps track of brush cache
  859. ULONG ulSolidColorOffset;
  860. ULONG ulAlignedPatternOffset;
  861. #if 1 // New brush caches.
  862. LONG iDitherCache; // Index to next dither cache entry.
  863. DITHERCACHE aDithers[NUM_DITHERS]; // Dither cache.
  864. LONG iPatternCache; // Index to next pattern cache entry.
  865. PATTERNCACHE aPatterns[NUM_PATTERNS];
  866. // Pattern cache.
  867. LONG iMonochromeCache; // Index to next monochrome cache entry.
  868. MONOCACHE aMonochromes[NUM_MONOCHROMES];
  869. // Monochrome cache.
  870. #endif
  871. ////////// DCI stuff:
  872. BOOL bSupportDCI; // True if miniport supports DCI
  873. #if DIRECTDRAW
  874. ////////// DirectDraw stuff:
  875. FLIPRECORD flipRecord; // Used to track VBlank status
  876. OH* pohDirectDraw; // Off-screen heap allocation for use by
  877. // DirectDraw
  878. ULONG ulCR1B; // Contents of CR1B register.
  879. ULONG ulCR1D; // Contents of CR1D register.
  880. DWORD dwLinearCnt; // Number of locks on surface.
  881. // crus
  882. #if 1 // OVERLAY #sge
  883. PDD_SURFACE_LOCAL lpHardwareOwner;
  884. PDD_SURFACE_LOCAL lpColorSurface;
  885. PDD_SURFACE_LOCAL lpSrcColorSurface;
  886. OVERLAYWINDOW sOverlay1;
  887. DWORD dwPanningFlag;
  888. WORD wColorKey;
  889. DWORD dwSrcColorKeyLow;
  890. DWORD dwSrcColorKeyHigh;
  891. RECTL rOverlaySrc;
  892. RECTL rOverlayDest;
  893. BOOL bDoubleClock;
  894. LONG lFifoThresh;
  895. BYTE VertStretchCode[MAX_STRETCH_SIZE];
  896. BYTE HorStretchCode[MAX_STRETCH_SIZE];
  897. FLATPTR fpVisibleOverlay;
  898. FLATPTR fpBaseOverlay;
  899. LONG lBusWidth;
  900. LONG lMCLKPeriod;
  901. LONG lRandom;
  902. LONG lPageMiss;
  903. LONG OvlyCnt;
  904. LONG PlanarCnt;
  905. DWORD dwVsyncLine;
  906. FLATPTR fpVidMem_gbls; // ptr to video memory, myf33
  907. LONG lPitch_gbls; //pitch of surface, myf33
  908. FNREGINITVIDEO* pfnRegInitVideo;
  909. FNREGMOVEVIDEO* pfnRegMoveVideo;
  910. FNBANDWIDTHEQ* pfnIsSufficientBandwidth;
  911. FNDISABLEOVERLAY* pfnDisableOverlay;
  912. FNCLEARALTFIFO* pfnClearAltFIFOThreshold;
  913. #endif // OVERLAY
  914. #endif
  915. #if 1 // Font cache.
  916. ////////// Font cache stuff:
  917. ULONG ulFontCacheID; // Font cache ID.
  918. FONTCACHE* pfcChain; // Pointer to chain of FONTCACHE
  919. // structures.
  920. #endif
  921. #if 1 // D5480
  922. FNGLYPHOUT* pfnGlyphOut;
  923. FNGLYPHOUTCLIP* pfnGlyphOutClip;
  924. // Command List Stuff:
  925. ULONG_PTR* pCommandList;
  926. ULONG_PTR* pCLFirst;
  927. ULONG_PTR* pCLSecond;
  928. #endif // endif D5480
  929. FnREAD_PORT_UCHAR pfnREAD_PORT_UCHAR;
  930. FnREAD_PORT_USHORT pfnREAD_PORT_USHORT;
  931. FnREAD_PORT_ULONG pfnREAD_PORT_ULONG;
  932. FnWRITE_PORT_UCHAR pfnWRITE_PORT_UCHAR;
  933. FnWRITE_PORT_USHORT pfnWRITE_PORT_USHORT;
  934. FnWRITE_PORT_ULONG pfnWRITE_PORT_ULONG;
  935. ULONG ulLastField; // This must remain the last field in
  936. // this structure.
  937. // Added to support GetAvailDriverMemory callback in DDraw
  938. ULONG ulTotalAvailVideoMemory;
  939. } PDEV, *PPDEV;
  940. /////////////////////////////////////////////////////////////////////////
  941. // Miscellaneous prototypes:
  942. BOOL bIntersect(RECTL*, RECTL*, RECTL*);
  943. LONG cIntersect(RECTL*, RECTL*, LONG);
  944. VOID vImageTransfer(PDEV*, BYTE*, LONG, LONG, LONG);
  945. #ifdef PANNING_SCROLL
  946. VOID CirrusLaptopViewPoint(PDEV*, PVIDEO_MODE_INFORMATION); //myf17
  947. #endif
  948. BOOL bInitializeModeFields(PDEV*, GDIINFO*, DEVINFO*, DEVMODEW*);
  949. BOOL bEnableHardware(PDEV*);
  950. VOID vDisableHardware(PDEV*);
  951. BOOL bAssertModeHardware(PDEV*, BOOL);
  952. DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION*, DWORD*);
  953. extern BYTE gajHwMixFromMix[];
  954. extern BYTE gaRop3FromMix[];
  955. extern BYTE gajHwMixFromRop2[];
  956. extern ULONG gaulLeftClipMask[];
  957. extern ULONG gaulRightClipMask[];
  958. #if 1 // D5480
  959. extern DWORD gajHwPackedMixFromRop2[];
  960. extern DWORD gajHwPackedMixFromMix[];
  961. #endif // endif D5480
  962. /////////////////////////////////////////////////////////////////////////
  963. // The x86 C compiler insists on making a divide and modulus operation
  964. // into two DIVs, when it can in fact be done in one. So we use this
  965. // macro.
  966. //
  967. // Note: QUOTIENT_REMAINDER implicitly takes unsigned arguments.
  968. #if defined(i386)
  969. #define QUOTIENT_REMAINDER(ulNumerator, ulDenominator, ulQuotient, ulRemainder) \
  970. { \
  971. __asm mov eax, ulNumerator \
  972. __asm sub edx, edx \
  973. __asm div ulDenominator \
  974. __asm mov ulQuotient, eax \
  975. __asm mov ulRemainder, edx \
  976. }
  977. #else
  978. #define QUOTIENT_REMAINDER(ulNumerator, ulDenominator, ulQuotient, ulRemainder) \
  979. { \
  980. ulQuotient = (ULONG) ulNumerator / (ULONG) ulDenominator; \
  981. ulRemainder = (ULONG) ulNumerator % (ULONG) ulDenominator; \
  982. }
  983. #endif
  984. /////////////////////////////////////////////////////////////////////////
  985. // PELS_TO_BYTES - converts a pel count to a byte count
  986. // BYTES_TO_PELS - converts a byte count to a pel count
  987. #define PELS_TO_BYTES(cPels) ((cPels) * ppdev->cBpp)
  988. #define BYTES_TO_PELS(cPels) ((cPels) / ppdev->cBpp)
  989. /////////////////////////////////////////////////////////////////////////
  990. // OVERLAP - Returns TRUE if the same-size lower-right exclusive
  991. // rectangles defined by 'pptl' and 'prcl' overlap:
  992. #define OVERLAP(prcl, pptl) \
  993. (((prcl)->right > (pptl)->x) && \
  994. ((prcl)->bottom > (pptl)->y) && \
  995. ((prcl)->left < ((pptl)->x + (prcl)->right - (prcl)->left)) && \
  996. ((prcl)->top < ((pptl)->y + (prcl)->bottom - (prcl)->top)))
  997. /////////////////////////////////////////////////////////////////////////
  998. // SWAP - Swaps the value of two variables, using a temporary variable
  999. #define SWAP32(a, b) \
  1000. { \
  1001. register ULONG tmp; \
  1002. tmp = (ULONG)(a); \
  1003. (ULONG)(a) = (ULONG)(b); \
  1004. (ULONG)(b) = tmp; \
  1005. }
  1006. #define SWAP(a, b, tmp) { (tmp) = (a); (a) = (b); (b) = (tmp); }
  1007. /////////////////////////////////////////////////////////////////////////
  1008. // BSWAP - "byte swap" reverses the bytes in a DWORD
  1009. #ifdef _X86_
  1010. #define BSWAP(ul)\
  1011. {\
  1012. _asm mov eax,ul\
  1013. _asm bswap eax\
  1014. _asm mov ul,eax\
  1015. }
  1016. #else
  1017. #define BSWAP(ul)\
  1018. {\
  1019. ul = ((ul & 0xff000000) >> 24) |\
  1020. ((ul & 0x00ff0000) >> 8) |\
  1021. ((ul & 0x0000ff00) << 8) |\
  1022. ((ul & 0x000000ff) << 24);\
  1023. }
  1024. #endif
  1025. // These Dbg prototypes are thunks for debugging:
  1026. ULONG DbgGetModes(HANDLE, ULONG, DEVMODEW*);
  1027. DHPDEV DbgEnablePDEV(DEVMODEW*, PWSTR, ULONG, HSURF*, ULONG, ULONG*,
  1028. ULONG, DEVINFO*, HDEV, PWSTR, HANDLE);
  1029. VOID DbgCompletePDEV(DHPDEV, HDEV);
  1030. HSURF DbgEnableSurface(DHPDEV);
  1031. BOOL DbgStrokePath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, XFORMOBJ*, BRUSHOBJ*,
  1032. POINTL*, LINEATTRS*, MIX);
  1033. BOOL DbgFillPath(SURFOBJ*, PATHOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*,
  1034. MIX, FLONG);
  1035. BOOL DbgBitBlt(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
  1036. RECTL*, POINTL*, POINTL*, BRUSHOBJ*, POINTL*, ROP4);
  1037. VOID DbgDisablePDEV(DHPDEV);
  1038. VOID DbgDisableSurface(DHPDEV);
  1039. #if (NT_VERSION < 0x0400) //myf19
  1040. VOID DbgAssertMode(DHPDEV, BOOL);
  1041. #else
  1042. BOOL DbgAssertMode(DHPDEV, BOOL);
  1043. #endif //myf19
  1044. VOID DbgMovePointer(SURFOBJ*, LONG, LONG, RECTL*);
  1045. ULONG DbgSetPointerShape(SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*, LONG,
  1046. LONG, LONG, LONG, RECTL*, FLONG);
  1047. ULONG DbgDitherColor(DHPDEV, ULONG, ULONG, ULONG*);
  1048. BOOL DbgSetPalette(DHPDEV, PALOBJ*, FLONG, ULONG, ULONG);
  1049. BOOL DbgCopyBits(SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*, RECTL*, POINTL*);
  1050. BOOL DbgTextOut(SURFOBJ*, STROBJ*, FONTOBJ*, CLIPOBJ*, RECTL*, RECTL*,
  1051. BRUSHOBJ*, BRUSHOBJ*, POINTL*, MIX);
  1052. VOID DbgDestroyFont(FONTOBJ*);
  1053. BOOL DbgPaint(SURFOBJ*, CLIPOBJ*, BRUSHOBJ*, POINTL*, MIX);
  1054. BOOL DbgRealizeBrush(BRUSHOBJ*, SURFOBJ*, SURFOBJ*, SURFOBJ*, XLATEOBJ*,
  1055. ULONG);
  1056. HBITMAP DbgCreateDeviceBitmap(DHPDEV, SIZEL, ULONG);
  1057. VOID DbgDeleteDeviceBitmap(DHSURF);
  1058. BOOL DbgStretchBlt(SURFOBJ*, SURFOBJ*, SURFOBJ*, CLIPOBJ*, XLATEOBJ*,
  1059. COLORADJUSTMENT*, POINTL*, RECTL*, RECTL*, POINTL*,
  1060. ULONG);
  1061. #if 1 // Font cache
  1062. VOID DbgDestroyFont(FONTOBJ* pfo);
  1063. #endif
  1064. #if LINETO
  1065. BOOL DbgLineTo(SURFOBJ*, CLIPOBJ*, BRUSHOBJ*, LONG, LONG, LONG, LONG,
  1066. RECTL*, MIX);
  1067. #endif
  1068. #if DIRECTDRAW
  1069. BOOL DbgGetDirectDrawInfo(DHPDEV, DD_HALINFO*, DWORD*, VIDEOMEMORY*, DWORD*,
  1070. DWORD*);
  1071. BOOL DbgEnableDirectDraw(DHPDEV, DD_CALLBACKS*, DD_SURFACECALLBACKS*,
  1072. DD_PALETTECALLBACKS*);
  1073. VOID DbgDisableDirectDraw(DHPDEV);
  1074. #endif
  1075. //
  1076. // chu01 : GAMMACORRECT
  1077. //
  1078. typedef struct _PGAMMA_VALUE
  1079. {
  1080. UCHAR value[4] ;
  1081. } GAMMA_VALUE, *PGAMMA_VALUE, *PCONTRAST_VALUE ;
  1082. //myf32 begin
  1083. //#define CL754x 0x1000
  1084. //#define CL755x 0x2000
  1085. #define CL7541 0x1000
  1086. #define CL7542 0x2000
  1087. #define CL7543 0x4000
  1088. #define CL7548 0x8000
  1089. #define CL754x (CL7541 | CL7542 | CL7543 | CL7548)
  1090. #define CL7555 0x10000
  1091. #define CL7556 0x20000
  1092. #define CL755x (CL7555 | CL7556)
  1093. #define CL756x 0x40000
  1094. // crus
  1095. #define CL6245 0x80000
  1096. //myf32 end
  1097. #define CL7542_ID 0x2C
  1098. #define CL7541_ID 0x34
  1099. #define CL7543_ID 0x30
  1100. #define CL7548_ID 0x38
  1101. #define CL7555_ID 0x40
  1102. #define CL7556_ID 0x4C
  1103. //#define CHIP754X
  1104. //#define CHIP755X
  1105. //myf32 end