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.

1207 lines
39 KiB

  1. /******************************Module*Header*******************************\
  2. *
  3. * Module Name: driver.h
  4. *
  5. * contains prototypes for the driver.
  6. *
  7. * Copyright (c) 1992 Microsoft Corporation
  8. * Copyright (c) 1995 Cirrus Logic, Inc.
  9. *
  10. * Cirrus extensions by Noel VanHook
  11. *
  12. * $Log: X:/log/laguna/nt35/displays/cl546x/DRIVER.H $
  13. *
  14. * Rev 1.70 Mar 25 1998 16:33:54 frido
  15. * Added dwOverlayCount and dwCONTROL2Save variables.
  16. *
  17. * Rev 1.69 Mar 04 1998 14:42:26 frido
  18. * Added shadowFGCOLOR.
  19. *
  20. * Rev 1.68 Feb 27 1998 17:01:14 frido
  21. * Added shadowQFREE register.
  22. *
  23. * Rev 1.67 Jan 20 1998 11:41:52 frido
  24. * Changed fDataStreaming into dwDataStreaming.
  25. * Added shadow variables for BGCOLOR and DRAWBLTDEF registers.
  26. *
  27. * Rev 1.66 Jan 16 1998 14:07:38 frido
  28. * Changed SOLID_COLOR_FILL so it uses the pattern.
  29. *
  30. * Rev 1.65 Nov 03 1997 15:53:44 frido
  31. * Added fDataStreaming variable to PDEV structure.
  32. *
  33. * Rev 1.64 16 Oct 1997 09:47:38 bennyn
  34. * Added bPrevModeDDOutOfVideoMem to PDEV
  35. *
  36. * Rev 1.63 18 Sep 1997 16:12:02 bennyn
  37. *
  38. * Fixed NT 3.51 compile/link problem
  39. *
  40. * Rev 1.62 12 Sep 1997 12:04:14 bennyn
  41. *
  42. * Added DD overlay support
  43. *
  44. * Rev 1.61 29 Aug 1997 17:08:36 RUSSL
  45. * Added overlay support
  46. *
  47. * Rev 1.60 18 Aug 1997 09:17:50 FRIDO
  48. * Added fields for bitmap filter.
  49. *
  50. * Rev 1.59 11 Aug 1997 14:11:00 bennyn
  51. *
  52. * Enabled GetScanLine support
  53. *
  54. * Rev 1.58 08 Aug 1997 14:46:20 FRIDO
  55. * Added support for new memory manager.
  56. *
  57. * Rev 1.57 22 Jul 1997 12:31:10 bennyn
  58. * Added dwLgVenID to PDEV
  59. *
  60. * Rev 1.56 02 Jul 1997 15:13:02 noelv
  61. *
  62. * Added prototype for LgMatchDriverToChip()
  63. *
  64. * Rev 1.55 20 Jun 1997 13:27:34 bennyn
  65. *
  66. * Eliminated power manager data area from PDEV
  67. *
  68. * Rev 1.54 23 May 1997 15:40:16 noelv
  69. * Added chip revision to PDEV
  70. *
  71. * Rev 1.53 29 Apr 1997 16:26:26 noelv
  72. * Added SWAT code.
  73. * SWAT:
  74. * SWAT: Rev 1.6 24 Apr 1997 12:05:22 frido
  75. * SWAT: Fixed compiler bugs.
  76. * SWAT:
  77. * SWAT: Rev 1.5 24 Apr 1997 10:39:50 frido
  78. * SWAT: NT140b09 merge.
  79. * SWAT: Removed memory manager changes for now.
  80. *
  81. * Rev 1.52 22 Apr 1997 11:03:22 noelv
  82. * Added forward compatible chip ids.
  83. * SWAT:
  84. * SWAT: Rev 1.4 18 Apr 1997 17:21:26 frido
  85. * SWAT: Fixed a typo (OFM_HandleChain).
  86. * SWAT:
  87. * SWAT: Rev 1.3 17 Apr 1997 23:16:20 frido
  88. * SWAT: NT140b07 merge.
  89. *
  90. * Rev 1.51 16 Apr 1997 10:52:18 bennyn
  91. *
  92. * Should use PFN_DRVSRCMBLT instead of PFN_DRVSTRBLTX for pfnDrvSrcMBlt.
  93. * SWAT:
  94. * SWAT: Rev 1.2 11 Apr 1997 12:38:22 frido
  95. * SWAT: Added OFM_HandleChain.
  96. * SWAT:
  97. * SWAT: Rev 1.1 09 Apr 1997 17:34:30 frido
  98. * SWAT: Added fPreAllocate and nPages.
  99. * SWAT: Added FONTCELL structure and variables.
  100. *
  101. * Rev 1.50 08 Apr 1997 11:38:02 einkauf
  102. * pdev adds to complete mcd
  103. *
  104. * Rev 1.49 04 Apr 1997 16:51:26 noelv
  105. *
  106. * Added pointer for new Direct Draw functions.
  107. *
  108. * Rev 1.48 27 Mar 1997 14:31:54 noelv
  109. *
  110. * Added new DDRAW function.
  111. *
  112. * Rev 1.47 21 Mar 1997 13:38:40 noelv
  113. *
  114. * Synced PDEV with LAGUNA.INC
  115. *
  116. * Rev 1.46 26 Feb 1997 13:21:26 noelv
  117. * Disabel MCD code for NT 3.5x
  118. *
  119. * Rev 1.45 26 Feb 1997 10:45:38 noelv
  120. * Added OpenGL MCD code from ADC.
  121. *
  122. * Rev 1.44 19 Feb 1997 13:08:38 noelv
  123. * Added translation table cache
  124. *
  125. * Rev 1.43 06 Feb 1997 10:36:10 noelv
  126. *
  127. * Moved MEMMGR andBRUSH stuff to their own header files.
  128. *
  129. * Rev 1.42 23 Jan 1997 17:13:02 bennyn
  130. *
  131. * Modified to support 5465 DD
  132. *
  133. * Rev 1.41 20 Jan 1997 14:49:34 bennyn
  134. *
  135. * Added blt65 prototypes
  136. *
  137. * Rev 1.40 16 Jan 1997 11:35:16 bennyn
  138. *
  139. * Added power manager variables to PDEV
  140. *
  141. * Rev 1.39 17 Dec 1996 16:44:54 SueS
  142. * Changed parameters in CloseLogFile prototype.
  143. *
  144. * Rev 1.38 10 Dec 1996 13:28:08 bennyn
  145. * Added ulFreq to PDEV
  146. *
  147. * Rev 1.37 05 Dec 1996 08:51:58 SueS
  148. * Added function to help with formatting strings for DirectDraw logging.
  149. * Added defines if logging is turned off.
  150. *
  151. * Rev 1.36 27 Nov 1996 11:32:36 noelv
  152. * Disabled Magic Bitmap. Yeah!!!
  153. *
  154. * Rev 1.35 26 Nov 1996 10:22:56 SueS
  155. * Added new function parameters and variables for logging with buffering.
  156. *
  157. * Rev 1.34 18 Nov 1996 10:15:20 bennyn
  158. *
  159. * Added grFormat to PDEV
  160. *
  161. * Rev 1.33 13 Nov 1996 17:06:10 SueS
  162. * Added function prototypes for file logging functions.
  163. *
  164. * Rev 1.32 12 Nov 1996 15:18:34 bennyn
  165. *
  166. * Added handle for DD blt scratch buffer
  167. *
  168. * Rev 1.31 07 Nov 1996 16:13:40 bennyn
  169. *
  170. * Added support to alloc offscn mem in DD createsurface
  171. *
  172. * Rev 1.30 01 Nov 1996 09:20:40 BENNYN
  173. * Added support for shareable DD blt code
  174. *
  175. * Rev 1.29 31 Oct 1996 11:14:42 noelv
  176. *
  177. * Split common buffer into two buffers.
  178. *
  179. * Rev 1.28 25 Oct 1996 11:52:14 noelv
  180. * added second common buffer
  181. *
  182. * Rev 1.27 24 Oct 1996 14:27:32 noelv
  183. * Added common buffer for bus mastering.
  184. *
  185. * Rev 1.26 23 Oct 1996 14:39:04 BENNYN
  186. * Added YUV cursor variables to PDEV
  187. *
  188. * Rev 1.25 04 Oct 1996 16:50:46 bennyn
  189. *
  190. * Added DirectDraw YVU support
  191. *
  192. * Rev 1.24 18 Sep 1996 13:57:44 bennyn
  193. * Modified to support DD stretchBLT
  194. *
  195. * Rev 1.23 22 Aug 1996 18:14:48 noelv
  196. * Frido bug fix release 8-22.
  197. *
  198. * Rev 1.22 20 Aug 1996 11:04:54 noelv
  199. * Bugfix release from Frido 8-19-96
  200. *
  201. * Rev 1.2 17 Aug 1996 13:40:28 frido
  202. * New release from Bellevue.
  203. *
  204. * Rev 1.1 15 Aug 1996 11:35:08 frido
  205. * Changed to conform to the precompiled header.
  206. *
  207. * Rev 1.0 14 Aug 1996 17:16:36 frido
  208. * Initial revision.
  209. *
  210. * Rev 1.20 25 Jul 1996 15:52:56 bennyn
  211. * Modified for DirectDraw
  212. *
  213. * Rev 1.19 16 Jul 1996 14:26:04 BENNYN
  214. *
  215. * Rev 1.18 11 Jul 1996 15:53:24 bennyn
  216. *
  217. * Added DirectDraw support
  218. *
  219. * Rev 1.17 23 May 1996 16:22:16 BENNYN
  220. * Added SubFreeQ declarations
  221. *
  222. * Rev 1.16 17 May 1996 12:04:52 bennyn
  223. * Added #define DBGBREAKPOINT
  224. *
  225. * Rev 1.15 08 May 1996 17:02:04 noelv
  226. * preallocated device bitmap.
  227. *
  228. * Rev 1.14 03 May 1996 15:06:34 noelv
  229. *
  230. * Added flag to turn font cache on and off
  231. *
  232. * Rev 1.13 01 May 1996 10:58:44 bennyn
  233. *
  234. * Modified for NT4.0
  235. *
  236. * Rev 1.12 25 Apr 1996 22:42:52 noelv
  237. * Cleaned up data logging some.
  238. *
  239. * Rev 1.11 10 Apr 1996 14:15:42 NOELV
  240. *
  241. * Frido release 27
  242. *
  243. * Rev 1.20 07 Apr 1996 17:12:26 frido
  244. * Added solid brush cache.
  245. *
  246. * Rev 1.19 01 Apr 1996 13:58:18 frido
  247. * Changed layout of brush cache.
  248. *
  249. * Rev 1.18 28 Mar 1996 19:57:38 frido
  250. * New Bellevue release.
  251. *
  252. * Rev 1.8 25 Mar 1996 18:57:52 noelv
  253. * Added define for turning cursor bug fix on and off.
  254. *
  255. * Rev 1.7 14 Mar 1996 09:36:22 andys
  256. * Added dcTileWidth and dcSRAMWidth
  257. *
  258. * Rev 1.6 12 Mar 1996 15:46:42 noelv
  259. * Added support file Stroke and Fill
  260. *
  261. * Rev 1.5 11 Mar 1996 11:54:20 noelv
  262. *
  263. * Added log file pointer to PDEV
  264. *
  265. * Rev 1.4 07 Mar 1996 18:21:52 bennyn
  266. *
  267. *
  268. * Rev 1.3 05 Mar 1996 11:59:38 noelv
  269. * Frido version 19
  270. *
  271. * Rev 1.13 29 Feb 1996 19:56:40 frido
  272. * Added bEnable to PDEV structure.
  273. *
  274. * Rev 1.12 27 Feb 1996 16:38:34 frido
  275. * Changed DSURF structure.
  276. * Added device bitmap store/restore.
  277. *
  278. * Rev 1.11 26 Feb 1996 23:38:18 frido
  279. * Added function pointers for ScreenToHost and HostToScreen.
  280. *
  281. * Rev 1.10 24 Feb 1996 01:24:26 frido
  282. * Added device bitmaps.
  283. *
  284. * Rev 1.9 17 Feb 1996 21:45:30 frido
  285. *
  286. *
  287. * Rev 1.8 13 Feb 1996 16:51:10 frido
  288. * Changed the layout of the PDEV structure.
  289. * Changed the layout of all brush caches.
  290. * Changed the number of brush caches.
  291. *
  292. * Rev 1.7 10 Feb 1996 21:42:26 frido
  293. * Split monochrome and colored translation brushes.
  294. *
  295. * Rev 1.6 08 Feb 1996 00:18:38 frido
  296. * Changed number of XLATE caches to 8.
  297. *
  298. * Rev 1.5 05 Feb 1996 17:35:52 frido
  299. * Added translation cache.
  300. *
  301. * Rev 1.4 03 Feb 1996 13:38:32 frido
  302. * Use the compile switch "-Dfrido=0" to disable my extensions.
  303. *
  304. * Rev 1.3 25 Jan 1996 12:46:54 frido
  305. * Added font counter ID to PDEV structure.
  306. *
  307. * Rev 1.2 20 Jan 1996 22:13:44 frido
  308. * Added dither cache.
  309. *
  310. \**************************************************************************/
  311. #include "swat.h"
  312. #include "debug.h"
  313. #include "laguna.h"
  314. #include "optimize.h"
  315. #include "memmgr.h"
  316. #include "brush.h"
  317. #include "xlate.h"
  318. #if MEMMGR
  319. #include "mmCore.h" // new memory manager
  320. #endif
  321. #if DRIVER_5465 && defined(OVERLAY)
  322. #include "overlay.h"
  323. #include "5465bw.h"
  324. #include "bw.h"
  325. #endif
  326. #ifdef WINNT_VER40
  327. #define ALLOC_TAG 'XGLC' // Memory Tag
  328. #define DBGBREAKPOINT() EngDebugBreak()
  329. #define MEM_ALLOC(FLAGS, SIZE, TAG) EngAllocMem((FLAGS), (SIZE), (TAG))
  330. #define MEMORY_FREE(pMEM) EngFreeMem(pMEM)
  331. #define DEVICE_IO_CTRL(A, B, C, D, E, F, G, H) (EngDeviceIoControl((A), (B), (C), (D), (E), (F), (G)) == 0)
  332. #else
  333. #define DBGBREAKPOINT() DbgBreakPoint()
  334. #define MEM_ALLOC(FLAGS, SIZE) LocalAlloc((FLAGS), (SIZE))
  335. #define MEMORY_FREE(pMEM) LocalFree(pMEM)
  336. #define DEVICE_IO_CTRL(A, B, C, D, E, F, G, H) DeviceIoControl((A), (B), (C), (D), (E), (F), (G), (H))
  337. #endif
  338. #ifndef frido
  339. #define frido 1
  340. #endif
  341. #if WINBENCH96
  342. #define MAGIC_SIZEX 400
  343. #define MAGIC_SIZEY 90
  344. #endif
  345. #define S2H_USE_ENGINE 0 // ScreenToHost flag
  346. // 0 - Use direct access to screen buffer
  347. // 1 - Use hardware
  348. //
  349. // These specify how much the desktop should be shrunk to allow off screen
  350. // memory to be visible on screen.
  351. // For example: if OFFSCREEN_LINES is 100, the desktop height will be reduced
  352. // by 100 lines, and the bottom 100 screen lines will be the first 100 lines
  353. // of off screen memory. This allows us to view and debug cached brushes, etc.
  354. //
  355. #define OFFSCREEN_LINES 0
  356. #define OFFSCREEN_COLS 0
  357. typedef BOOL COPYFN(SURFOBJ *psoTrg, SURFOBJ *psoSrc, XLATEOBJ *pxlo,
  358. RECTL *prclTrg, POINTL *pptlSrc, ULONG ulDRAWBLTDEF);
  359. /*
  360. * Be sure to synchronize these structures with those in i386\Laguna.inc!
  361. */
  362. #pragma pack(1)
  363. /*****************************************************************************\
  364. * DirectDraw
  365. \*****************************************************************************/
  366. enum SSREGNAMES
  367. {
  368. ACCUM,
  369. MAJ,
  370. MIN,
  371. MAX_REGS
  372. };
  373. // Allocate offscreen memory for DD in createsurface instead of
  374. // DD enable
  375. #define ALLOC_IN_CREATESURFACE
  376. //#define DDDRV_GETSCANLINE
  377. #define RDRAM_8BIT
  378. // Stuff for tidying up access to grFormat
  379. #define FMT_VCLK_DIV2 0x4000
  380. #define FMT_GRX_MASK 0x3e00 // Mask for the Graphics depth & format fields
  381. #define FMT_GRX_GAMMA 0x0800
  382. #define FMT_VID_MASK 0x003e // Mask for the Vide depth & video format fields
  383. #define FMT_VID_GAMMA 0x0001
  384. #define FMT_8BPP 0
  385. #define FMT_16BPP 1
  386. #define FMT_24BPP 2
  387. #define FMT_32BPP 3
  388. #define FMT_VID_COLORDEPTH_SHIFT 4
  389. #define FMT_VID_8BPP (FMT_8BPP << FMT_VID_COLORDEPTH_SHIFT)
  390. #define FMT_VID_16BPP (FMT_16BPP << FMT_VID_COLORDEPTH_SHIFT)
  391. #define FMT_VID_24BPP (FMT_24BPP << FMT_VID_COLORDEPTH_SHIFT)
  392. #define FMT_VID_32BPP (FMT_32BPP << FMT_VID_COLORDEPTH_SHIFT)
  393. #define FMT_GRX_COLORDEPTH_SHIFT 12
  394. #define FMT_GRX_8BPP (FMT_8BPP << FMT_GRX_COLORDEPTH_SHIFT)
  395. #define FMT_GRX_16BPP (FMT_16BPP << FMT_GRX_COLORDEPTH_SHIFT)
  396. #define FMT_GRX_24BPP (FMT_24BPP << FMT_GRX_COLORDEPTH_SHIFT)
  397. #define FMT_GRX_32BPP (FMT_32BPP << FMT_GRX_COLORDEPTH_SHIFT)
  398. #define FMT_PALETTIZED 0
  399. #define FMT_GREYSCALE 1
  400. #define FMT_RGB 2
  401. #define FMT_ACCUPAK 4
  402. #define FMT_YUV422 5
  403. #define FMT_YUV444 6
  404. #define FMT_VID_FORMAT_SHIFT 1
  405. #define FMT_VID_PALETTIZED (FMT_PALETTIZED << FMT_VID_FORMAT_SHIFT)
  406. #define FMT_VID_GREYSCALE (FMT_GREYSCALE << FMT_VID_FORMAT_SHIFT)
  407. #define FMT_VID_RGB (FMT_RGB << FMT_VID_FORMAT_SHIFT)
  408. #define FMT_VID_ACCUPAK (FMT_ACCUPAK << FMT_VID_FORMAT_SHIFT)
  409. #define FMT_VID_YUV422 (FMT_YUV422 << FMT_VID_FORMAT_SHIFT)
  410. #define FMT_VID_YUV444 (FMT_YUV444 << FMT_VID_FORMAT_SHIFT)
  411. #define FMT_GRX_FORMAT_SHIFT 9
  412. #define FMT_GRX_PALETTIZED (FMT_PALETTIZED << FMT_GRX_FORMAT_SHIFT)
  413. #define FMT_GRX_GREYSCALE (FMT_GREYSCALE << FMT_GRX_FORMAT_SHIFT)
  414. #define FMT_GRX_RGB (FMT_RGB << FMT_GRX_FORMAT_SHIFT)
  415. #define FMT_GRX_ACCUPAK (FMT_ACCUPAK << FMT_GRX_FORMAT_SHIFT)
  416. #define FMT_GRX_YUV422 (FMT_YUV422 << FMT_GRX_FORMAT_SHIFT)
  417. #define FMT_GRX_YUV444 (FMT_YUV444 << FMT_GRX_FORMAT_SHIFT)
  418. // STOP_BLT_[1,2,3] Register Fields
  419. #define ENABLE_VIDEO_WINDOW 0x80
  420. #define ENABLE_VIDEO_FORMAT 0x40
  421. // External Overlay Control Register Fields
  422. #define ENABLE_RAMBUS_9TH_BIT 0x01
  423. #define SET_DRVSEM_YUV() (pDriverData->DrvSemaphore |= DRVSEM_YUV_ON)
  424. #define CLR_DRVSEM_YUV() (pDriverData->DrvSemaphore &= ~DRVSEM_YUV_ON)
  425. // IN_VBLANK tests to see if the hardware is currently in the vertical blank.
  426. #define IN_VBLANK (_inp(0x3da) & 8)
  427. #define IN_DISPLAY (!IN_VBLANK)
  428. // IN_DISPLAYENABLE tests to see if the display is enable
  429. #define IN_DISPLAYENABLE (_inp(0x3da) & 1)
  430. #define BITSPERPIXEL (ppdev->ulBitCount)
  431. #define BYTESPERPIXEL (BITSPERPIXEL / 8)
  432. #define BYTE1FROMDWORD(dw) ((BYTE)dw)
  433. #define BYTE2FROMDWORD(dw) ((BYTE)((DWORD)dw >> 8))
  434. #define BYTE3FROMDWORD(dw) ((BYTE)((DWORD)dw >> 16))
  435. #define BYTE4FROMDWORD(dw) ((BYTE)((DWORD)dw >> 24))
  436. // Bits defined in DrvSemaphore
  437. // Be sure to synchronize these structures with those in i386\Laguna.inc!
  438. #define DRVSEM_CURSOR_REMOVED_BIT 0
  439. #define DRVSEM_HW_CURSOR_BIT 1
  440. #define DRVSEM_IN_USE_BIT 2
  441. #define DRVSEM_NEW_CURSOR_XY_BIT 3
  442. #define DRVSEM_CHECK_CURSOR_BIT 4
  443. #define DRVSEM_CURSOR_IN_USE_BIT 5
  444. #define DRVSEM_CURSOR_CHANGED_BIT 6
  445. #define DRVSEM_3D_BUSY_BIT 7
  446. #define DRVSEM_MISSED_SET_BIT 8
  447. #define DRVSEM_YUV_ON_BIT 9
  448. #define DRVSEM_DISABLE_SETS_BIT 10
  449. #define DRVSEM_YUV_RECT_VALID_BIT 11
  450. // the corresponding mask values
  451. // Be sure to synchronize these structures with those in i386\Laguna.inc!
  452. #define DRVSEM_CHECK_CURSOR (1 << DRVSEM_CHECK_CURSOR_BIT)
  453. #define DRVSEM_NEW_CURSOR_XY (1 << DRVSEM_NEW_CURSOR_XY_BIT)
  454. #define DRVSEM_IN_USE (1 << DRVSEM_IN_USE_BIT)
  455. #define DRVSEM_CURSOR_REMOVED (1 << DRVSEM_CURSOR_REMOVED_BIT)
  456. #define DRVSEM_HW_CURSOR (1 << DRVSEM_HW_CURSOR_BIT)
  457. #define DRVSEM_CURSOR_IN_USE (1 << DRVSEM_CURSOR_IN_USE_BIT)
  458. #define DRVSEM_CURSOR_CHANGED (1 << DRVSEM_CURSOR_CHANGED_BIT)
  459. #define DRVSEM_3D_BUSY (1 << DRVSEM_3D_BUSY_BIT)
  460. #define DRVSEM_MISSED_SET (1 << DRVSEM_MISSED_SET_BIT)
  461. #define DRVSEM_YUV_ON (1 << DRVSEM_YUV_ON_BIT)
  462. #define DRVSEM_DISABLE_SETS (1 << DRVSEM_DISABLE_SETS_BIT)
  463. #define DRVSEM_YUV_RECT_VALID (1 << DRVSEM_YUV_RECT_VALID_BIT)
  464. #define ROUND_UP_TO_64K(x) (((ULONG)(x) + 0x10000 - 1) & ~(0x10000 - 1))
  465. #define mmioFOURCC( ch0, ch1, ch2, ch3 ) \
  466. ( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) | \
  467. ( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) )
  468. #define FOURCC_UYVY mmioFOURCC('U', 'Y', 'V', 'Y')
  469. typedef volatile GAR * PVGAR;
  470. typedef struct offscr_yuv {
  471. RECTL SrcRect;
  472. WORD nInUse;
  473. WORD ratio;
  474. } OFFSCR_YUV, * POFFSCR_YUV;
  475. #if DRIVER_5465 && defined(OVERLAY)
  476. #ifndef ENABLE_MIRRORING
  477. #define ENABLE_MIRRORING 0
  478. #endif
  479. #ifndef ENABLE_YUVPLANAR
  480. #define ENABLE_YUVPLANAR 0
  481. #endif
  482. // Be sure to synchronize the following structures with the one
  483. // in i386\Laguna.inc!
  484. #define MAX_FOURCCS 3
  485. #define MAX_VIDEO_WINDOWS 8
  486. #endif
  487. // This DRIVERDATA structure is similar to GLOBALDATA structure in Win95
  488. // DirectDraw and declares for compartible reason.
  489. //
  490. // Be sure to synchronize this structure with the one in i386\Laguna.inc!
  491. //
  492. typedef struct _DRIVERDATA
  493. {
  494. DWORD PTAGFooPixel; // ptag workaround pixel
  495. WORD fNineBitRDRAMS; // flag to indicate if 9bit RDRAMS present
  496. BOOL fReset;
  497. PBYTE ScreenAddress; // base of screen memory (Same as pjScreen in PDEV)
  498. PBYTE VideoBase; // base of video memory (Same as pjScreen in PDEV)
  499. volatile GAR *RegsAddress; // base address of Laguna MMIO regs
  500. WORD DrvSemaphore;
  501. WORD EdgeTrim;
  502. // Coordinate of the YUV rectange
  503. WORD YUVTop;
  504. WORD YUVLeft;
  505. WORD YUVXExt;
  506. WORD YUVYExt;
  507. // Video Format semaphores, you must set the VIDEO_FORMAT bit in
  508. // VideoSemaphore before making changes to CurrentVideoFormat and
  509. // NumVideoSurfaces. After you are done making changes, you must
  510. // clear the VIDEO_FORMAT bit in VideoSemaphore.
  511. //
  512. // Once you've SET the VIDEO_FORMAT bit, you can increment or decrement
  513. // the NumVideoSurfaces if CurrentVideoFormat is the same type. You can
  514. // only change the CurrentVideoFormat, if the NumVideoSurfaces is zero.
  515. // Therefore if the NumVideoSurfaces is not zero and CurrentVideoFormat
  516. // is not the type of surface you want to create, you MUST FAIL the surface
  517. // creation request! After changing the video format you must program the
  518. // FORMAT register with the new video format.
  519. // When you are done making changes, CLEAR the VIDEO_FORMAT bit!
  520. WORD VideoSemaphore; // semaphores to control interaction between
  521. // DCI's & VPM's use of video hardware
  522. WORD CurrentVideoFormat; // value of current video format YUV422, etc.
  523. // Same as low byte of FORMAT register
  524. WORD NumVideoSurfaces; // number of surfaces currently in use with
  525. // CurrentVideoFormat
  526. DWORD ScratchBufferOrg;
  527. #ifdef WINNT_VER40
  528. #if DRIVER_5465 && defined(OVERLAY)
  529. BOOL fOverlaySupport;
  530. OVERLAYTABLE OverlayTable;
  531. DWORD dwOverlayCount;
  532. DWORD dwCONTROL2Save;
  533. // Win95 5465over.c static vars
  534. BOOL bUseBWEqn;
  535. BOOL bNoOverlayInThisMode;
  536. PDD_SURFACE_LOCAL lpHardwareOwner[MAX_VIDEO_WINDOWS];
  537. PDD_SURFACE_LOCAL lpColorSurfaceVW[MAX_VIDEO_WINDOWS];
  538. PDD_SURFACE_LOCAL lpSrcColorSurfaceVW[MAX_VIDEO_WINDOWS];
  539. RECTL grOverlaySrc[MAX_VIDEO_WINDOWS];
  540. RECTL grOverlayDest[MAX_VIDEO_WINDOWS];
  541. DWORD gdwFourccVW[MAX_VIDEO_WINDOWS];
  542. BOOL bIsVWMirrored[MAX_VIDEO_WINDOWS];
  543. DWORD gdwAvailVW; // Next available video window
  544. DWORD gdwColorKey;
  545. DWORD gdwSrcColorKeyLow;
  546. DWORD gdwSrcColorKeyHigh;
  547. DWORD gdwDestColorKeyOwnerVW; // DstColorKey owner (NULL or FLG_VWX)
  548. DWORD gdwSrcColorKeyOwnerVW; // SrcColorKey owner (NULL or FLG_VWX)
  549. int giOvlyCnt[MAX_VIDEO_WINDOWS];
  550. int giPlanarCnt; // with other overlay surfaces
  551. BOOL bCLPLLobotomyMode;
  552. // Win95 5465over.c global vars
  553. OVERLAYFLIPRECORD gsOverlayFlip;
  554. PROGREGS gsProgRegs;
  555. VIDCONFIG gvidConfig;
  556. WORD gwNormalDTTR;
  557. DWORD dwNumVideoWindows;
  558. BOOL bEnableCLPL;
  559. // NT only data
  560. DWORD dwMaxOverlayStretch;
  561. DWORD dwMinOverlayStretch;
  562. DWORD dwFourCC[MAX_FOURCCS];
  563. #else
  564. DWORD dwFourCC;
  565. #endif // #if DRIVER_5465 && defined(OVERLAY)
  566. #endif // WINNT_VER40
  567. DWORD signature; // Expected value: 0x9abcdef0;
  568. } DRIVERDATA, *PDRIVERDATA;
  569. // FLIPRECORD structure keeps track of when the last page flip occurred
  570. typedef struct _FLIPRECORD
  571. {
  572. #ifdef WINNT_VER40
  573. FLATPTR fpFlipFrom; // Surface we last flipped from
  574. #endif // WINNT_VER40
  575. LONGLONG liFlipTime; // Time at which last flip
  576. // occured
  577. LONGLONG liFlipDuration; // Precise amount of time it
  578. // takes from vblank to vblank
  579. BOOL bFlipFlag; // True if we think a flip is
  580. BOOL bHaveEverCrossedVBlank; // True if we noticed that we
  581. // switched from inactive to
  582. // vblank
  583. BOOL bWasEverInDisplay; // True if we ever noticed that
  584. // we were inactive
  585. WORD dwFlipScanLine;
  586. } FLIPRECORD, *PFLIPRECORD;
  587. /*****************************************************************************\
  588. * DSURF structure - Device Bitmaps
  589. \*****************************************************************************/
  590. typedef struct _DSURF
  591. {
  592. struct _PDEV* ppdev; // pointer to pdev structure
  593. struct _OFMHDL* pofm; // pointer to off-screen memory handle
  594. SURFOBJ* pso; // pointer to surface object
  595. POINTL ptl; // x,y offset of bitmap
  596. SIZEL sizl; // size of device bitmap
  597. DWORD packedXY; // packed x,y offset of bitmap
  598. } DSURF, *PDSURF;
  599. #define TMP_BUFFER_SIZE 8192 // Size in bytes of 'pvTmpBuffer. Has to be
  600. // at least enough to store an entire scan
  601. // line (i.e., 6400 for 1600x1200x32).
  602. //
  603. // For cursor/pointer
  604. //
  605. #define DEF_CURSOR 0 // GDI support cursor
  606. #define HW_CURSOR 1 // Use HW cursor
  607. #define SW_CURSOR 2 // Use SW cursor
  608. #define HW_POINTER_DIMENSION 64 // Maximum dimension of default
  609. // Font structures
  610. #define MAX_GLYPHS 256 // Maximum number of glyphs per font.
  611. typedef struct _FONTMEMORY
  612. {
  613. POFMHDL pTile; // Handle to tile.
  614. ULONG ulLastX; // Last allocated column.
  615. struct _FONTMEMORY* pNext; // Hointer to next structure.
  616. } FONTMEMORY, *PFONTMEMORY;
  617. typedef struct _GLYPHCACHE
  618. {
  619. DWORD xyPos; // Off-screen x,y position of glyph.
  620. DWORD cSize; // Width and height of glyph.
  621. POINTL ptlOrigin; // Origin of glyph.
  622. // If xyPos == 0 then the glyph is not yet cached.
  623. // If cSize == 0 then the glyph is empty.
  624. // If cSize == -1 then the glyph is uncacheable.
  625. } GLYPHCACHE, *PGLYPHCACHE;
  626. // SWAT3 changes for font cache allocation scheme start here.
  627. typedef struct _FONTCELL *PFONTCELL;
  628. typedef struct _FONTCACHE *PFONTCACHE;
  629. typedef struct _PDEV *PPDEV;
  630. typedef struct _FONTCACHE
  631. {
  632. PPDEV ppdev; // Pointer to physical device.
  633. PFONTMEMORY pFontMemory; // Pointer to font cache memory.
  634. PFONTCELL pFontCell; // Pointer to first font cell.
  635. ULONG ulFontCount; // Font cache ID counter.
  636. GLYPHCACHE aGlyphs[MAX_GLYPHS]; // Array of cached glyphs.
  637. FONTOBJ* pfo; // Pointer to FONTOBJ for this cache.
  638. PFONTCACHE pfcPrev; // Pointer to previous FONTCACHE structure.
  639. PFONTCACHE pfcNext; // Pointer to next FONTCACHE structure.
  640. } FONTCACHE, *PFONTCACHE;
  641. typedef struct _FONTCELL
  642. {
  643. LONG x; // X location of this cell (in bytes).
  644. LONG y; // Y location of this cell (in bytes).
  645. PFONTCACHE pfc; // Pointer to FONTCACHE occupying this cell.
  646. ULONG ulLastX; // Last allocated column.
  647. PFONTCELL pNext; // Pointer to next font cell for this font cache.
  648. } FONTCELL, *PFONTCELL;
  649. // end SWAT3 changes.
  650. typedef POFMHDL (WINAPI *ALLOCOFFSCNMEMFUNC)();
  651. typedef BOOL (WINAPI *FREEOFFSCNMEMFUNC)();
  652. typedef VOID (WINAPI *ASSERTMODEMCDFUNC)();
  653. /*
  654. * Be sure to synchronize this structure with the one in i386\Laguna.inc!
  655. */
  656. typedef struct _PDEV
  657. {
  658. HANDLE hDriver; // Handle to \Device\Screen
  659. HDEV hdevEng; // Engine's handle to PDEV
  660. HSURF hsurfEng; // Engine's handle to surface
  661. HPALETTE hpalDefault; // Handle to the default palette for device.
  662. PBYTE pjScreen; // This is pointer to base screen address
  663. ULONG cxScreen; // Visible screen width
  664. ULONG cyScreen; // Visible screen height
  665. ULONG cxMemory; // Width of Video RAM
  666. ULONG cyMemory; // Height of Video RAM
  667. // v-normmi // this is bogus if pitch is not power of two
  668. // v-normmi
  669. ULONG cyMemoryReal; // this includes extra rectangle at
  670. // bottom left if being used
  671. ULONG ulMode; // Mode the mini-port driver is in.
  672. ULONG ulFreq; // Frequency
  673. LONG lDeltaScreen; // Distance from one scan to the next.
  674. FLONG flRed; // For bitfields device, Red Mask
  675. FLONG flGreen; // For bitfields device, Green Mask
  676. FLONG flBlue; // For bitfields device, Blue Mask
  677. ULONG cPaletteShift; // number of bits the 8-8-8 palette must
  678. // be shifted by to fit in the hardware
  679. // palette.
  680. POINTL ptlHotSpot; // adjustment for pointer hot spot
  681. ULONG cPatterns; // Count of bitmap patterns created
  682. HBITMAP ahbmPat[HS_DDI_MAX]; // Engine handles to standard patterns
  683. PALETTEENTRY *pPal; // If this is pal managed, this is the pal
  684. PBYTE pjOffScreen; // This is pointer to start of off screen memory
  685. ULONG iBitmapFormat;
  686. ULONG ulBitCount; // # of bits per pel 8,16,24,32 are only supported.
  687. ULONG iBytesPerPixel;
  688. autoblt_regs PtrABlt[3]; // auto BLT tables
  689. #ifdef WINNT_VER40
  690. HSEMAPHORE CShsem; // Critical Section Handle to Semaphore
  691. #else
  692. CRITICAL_SECTION PtrCritSec; // Pointer critical section
  693. #endif
  694. RECTL prcl; // Cursor rectange
  695. BOOL PtrBusy;
  696. BOOL fHwCursorActive; // Are we currently using the hw cursor
  697. BOOL CursorHidden; // Indicate the cursor is hidden
  698. POFMHDL PtrMaskHandle; // Pointer mask handle.
  699. POFMHDL PtrImageHandle; // Pointer image save area handle.
  700. POFMHDL PtrABltHandle; // Pointer auto BLT handle.
  701. ULONG PtrXHotSpot; // X & Y position of the pointer hot spot
  702. ULONG PtrYHotSpot;
  703. ULONG PtrX; // X & Y position of the pointer
  704. ULONG PtrY;
  705. ULONG PtrSzX; // Pointer dimensions
  706. ULONG PtrSzY;
  707. LONG PointerUsage; // DEF_CURSOR - GDI support cursor.
  708. // HW_CURSOR - Use HW cursor.
  709. // SW_CURSOR - Use SW cursor.
  710. DWORD grCONTROL;
  711. DWORD grFORMAT;
  712. DWORD grVS_CONTROL;
  713. // For offscreen memory manager
  714. LONG lOffset_2D; // Offset-2D register value.
  715. LONG lTileSize; // Selected tile size.
  716. LONG lTotalMem; // Installed memory.
  717. BOOL OFM_init; // TRUE InitOffScnMem() has been called.
  718. #ifdef WINNT_VER40
  719. HSEMAPHORE MMhsem; // Memory Manager Handle to Semaphore
  720. #else
  721. HANDLE MutexHdl; // Mutex handle
  722. #endif
  723. BOOL bDirectDrawInUse; // DirectDraw InUse flag.
  724. POFMHDL ScrnHandle; // Active screen handle.
  725. POFMHDL OFM_UsedQ; // Off screen memory queues.
  726. POFMHDL OFM_FreeQ;
  727. POFMHDL OFM_SubFreeQ1;
  728. POFMHDL OFM_SubFreeQ2;
  729. FONTCACHE* pfcChain; // Pointer to chain of FONTCACHE
  730. POFMHDL Bcache; // This is the offscreen memory used to
  731. // cache the brush bits in.
  732. MC_ENTRY Mtable[NUM_MONO_BRUSHES]; // Table to manage mono brush cache.
  733. XC_ENTRY Xtable[NUM_4BPP_BRUSHES]; // Table to manage 4-bpp brush cache.
  734. DC_ENTRY Dtable[NUM_DITHER_BRUSHES]; // Table to manage dither brush cache.
  735. BC_ENTRY Ctable[NUM_COLOR_BRUSHES]; // Table to manage color brush cache.
  736. DC_ENTRY Stable[NUM_SOLID_BRUSHES];
  737. ULONG SNext;
  738. ULONG CLast; // Last usable index in color cache table.
  739. ULONG MNext; // Where next mono brush will be cached.
  740. ULONG XNext; // Where next 4-bpp brush will be cached.
  741. ULONG DNext; // Where next dither brush will be cached.
  742. ULONG CNext; // Where next color brush will be cached.
  743. ULONG ulFontCount; // Font cache counter.
  744. ULONG UseFontCache; // Flag to turn on and off.
  745. POINTL ptlOffset; // x,y offset (for device bitmaps).
  746. BOOL bEnable; // Hardware enabled flag.
  747. COPYFN *pfnHostToScreen; // HostToScreen routine.
  748. COPYFN *pfnScreenToHost; // ScreenToHost routine.
  749. // Here we have the pointer to the memory mapped registers. For
  750. // analysis reasons we sometimes want to 'null' out the hardware
  751. // by aiming the register pointer at blank memory. We keep two
  752. // pointers to registers. pLgREGS_real and pLgREGS usually both point
  753. // to the registers, but we can set flags in LAGUNA.H to cause pLgREGS
  754. // to point to 'buffer' instead. This is useful for testing which
  755. // parts of the driver are software bound and which are hardware bound.
  756. volatile GAR *pLgREGS_real; // Always points to the memory mapped registers.
  757. volatile GAR *pLgREGS; // May point registers, may point to buffer.
  758. WORD dcTileWidth; // Number of Pixels in Current Tile Size
  759. WORD dcSRAMWidth; // Number of Pixels that will fit into SRAM
  760. // These were added to support stroke and fill with the least amount of
  761. // changes.
  762. ULONG uBLTDEF;
  763. ULONG uRop;
  764. PVOID pvTmpBuffer; // General purpose temporary buffer, TMP_BUFFER_SIZE in
  765. // size (Remember to synchronize if you use this for
  766. // device bitmaps or async pointers)
  767. #if ENABLE_LOG_FILE
  768. void *pmfile;
  769. char TxtBuff[0x1000];
  770. DWORD TxtBuffIndex;
  771. #endif
  772. #if NULL_HW
  773. char *buffer[0x8000]; // Empty memory used to "null" the registers.
  774. #endif
  775. //
  776. // Reserve a little space for device bitmaps.
  777. //
  778. #if WINBENCH96
  779. POFMHDL pofmMagic;
  780. ULONG bMagicUsed;
  781. #endif
  782. // SWAT1 changes.
  783. BOOL fPreAllocate;
  784. int nPages;
  785. // SWAT3 changes.
  786. #define FONTCELL_COUNT 64 // Number of font cells
  787. #define FONTCELL_X 128 // Width in bytes of a font cell
  788. #define FONTCELL_Y 16 // Height of a font cell
  789. POFMHDL pofmFontCache; // Font cache allocation heap
  790. FONTCELL fcGrid[FONTCELL_COUNT]; // Array of font cache cells
  791. #if MEMMGR
  792. // MEMMGR changes.
  793. IIMEMMGR mmMemMgr;
  794. LONG must_have_width;
  795. BOOL fBitmapFilter;
  796. SIZEL szlBitmapMin;
  797. SIZEL szlBitmapMax;
  798. #endif
  799. //
  800. // For DirectDraw
  801. //
  802. BOOL bPrevModeDDOutOfVideoMem;
  803. POFMHDL DirectDrawHandle; // DirectDraw handle.
  804. FLIPRECORD flipRecord;
  805. DRIVERDATA DriverData;
  806. OFFSCR_YUV offscr_YUV;
  807. DWORD dwDDLinearCnt; // Ref count of active DD locks
  808. PBYTE pPtrMaskHost;
  809. BOOL bYUVuseSWPtr;
  810. DWORD dwLgVenID; // PCI Vendor ID
  811. DWORD dwLgDevID; // PCI Device ID
  812. DWORD dwLgDevRev; // PCI Device Revision
  813. BOOL bYUVSurfaceOn;
  814. LONG lRegVals[2][MAX_REGS];
  815. LONG sShrinkInc;
  816. ULONG usLnCntl;
  817. ULONG usStretchCtrl;
  818. #ifdef WINNT_VER40
  819. // DirectDraw display list pointer
  820. PFN_DELAY9BLT pfnDelay9BitBlt;
  821. PFN_EDGEFILLBLT pfnEdgeFillBlt;
  822. PFN_MEDGEFILLBLT pfnMEdgeFillBlt;
  823. PFN_DRVDSTBLT pfnDrvDstBlt;
  824. PFN_DRVDSTBLT pfnDrvDstMBlt;
  825. PFN_DRVSRCBLT pfnDrvSrcBlt;
  826. PFN_DRVSRCMBLT pfnDrvSrcMBlt;
  827. PFN_DRVSTRBLT pfnDrvStrBlt;
  828. PFN_DRVSTRMBLT pfnDrvStrMBlt;
  829. PFN_DRVSTRMBLTY pfnDrvStrMBltY;
  830. PFN_DRVSTRMBLTX pfnDrvStrMBltX;
  831. PFN_DRVSTRBLTY pfnDrvStrBltY;
  832. PFN_DRVSTRBLTX pfnDrvStrBltX;
  833. #endif
  834. POFMHDL DDScratchBufHandle; // DirectDraw scratch buffer handle.
  835. PDDOFM DDOffScnMemQ; // DirectDraw offscreen mem queue.
  836. #ifdef BUS_MASTER
  837. BYTE* Buf1VirtAddr;
  838. BYTE* Buf2VirtAddr;
  839. BYTE* Buf1PhysAddr;
  840. BYTE* Buf2PhysAddr;
  841. ULONG BufLength;
  842. #endif
  843. #ifndef WINNT_VER35
  844. // START OpenGL MCD additions (based on MGA driver in NT4.0 DDK)
  845. HANDLE hMCD; // Handle to MCD engine dll
  846. MCDENGESCFILTERFUNC pMCDFilterFunc; // MCD engine filter function
  847. LONG cDoubleBufferRef; // Reference count for current number
  848. // of RC's that have active double-
  849. LONG cZBufferRef; // Reference count for current number
  850. // of RC's that have active z-buffers
  851. POFMHDL pohBackBuffer; // ofscreen pools
  852. POFMHDL pohZBuffer;
  853. DWORD temp_DL_chunk[SIZE_TEMP_DL]; // temporary mem for display lists
  854. TSystem LL_State;
  855. ALLOCOFFSCNMEMFUNC pAllocOffScnMem;
  856. FREEOFFSCNMEMFUNC pFreeOffScnMem;
  857. ASSERTMODEMCDFUNC pAssertModeMCD;
  858. // recip table to support up to 2K x 2K resolution
  859. #define LAST_FRECIP 2048
  860. float frecips[LAST_FRECIP+1];
  861. ULONG pLastDevRC;
  862. DWORD NumMCDContexts;
  863. ULONG iUniqueness;
  864. // pointer to first and last entries in linked list of texture control blocks
  865. LL_Texture *pFirstTexture;
  866. LL_Texture *pLastTexture;
  867. // END OpenGL MCD additions
  868. #endif
  869. // Translation table cache.
  870. POFMHDL XlateCache;
  871. ULONG XlateCacheId;
  872. WORD CachedChromaCtrl;
  873. WORD CachedStretchCtrl;
  874. DWORD signature; // Expected value: 0x12345678;
  875. #if DATASTREAMING
  876. DWORD dwDataStreaming;
  877. DWORD shadowFGCOLOR;
  878. DWORD shadowBGCOLOR;
  879. DWORD shadowDRAWBLTDEF;
  880. BYTE shadowQFREE;
  881. #endif
  882. } PDEV, *PPDEV;
  883. // MCD Prototypes (MCD_TEMP??)
  884. #ifndef WINNT_VER35
  885. BOOL MCDrvGetEntryPoints(MCDSURFACE *pMCDSurface, MCDDRIVER *pMCDDriver);
  886. #endif
  887. DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *);
  888. BOOL bInitPDEV(PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *);
  889. BOOL bInitSURF(PPDEV, BOOL);
  890. BOOL bInitPaletteInfo(PPDEV, DEVINFO *);
  891. VOID InitPointer(PPDEV);
  892. BOOL bInit256ColorPalette(PPDEV);
  893. BOOL bInitPatterns(PPDEV, ULONG);
  894. VOID vDisablePalette(PPDEV);
  895. VOID vDisablePatterns(PPDEV);
  896. VOID vDisableSURF(PPDEV);
  897. BOOL LgMatchDriverToChip(PPDEV ppdev);
  898. #define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
  899. //
  900. // Pointer routines
  901. //
  902. VOID RestoreSaveShowCursor(PPDEV ppdev, LONG x, LONG y);
  903. ULONG ConvertMaskBufToLinearAddr(PPDEV ppdev);
  904. #ifdef WINNT_VER40
  905. // GrabVideoFormat will set & test the VIDEO_FORMAT bit of
  906. // pDriverData->VideoSemaphore if the bit was already set it
  907. // will loop until the bit wasn't set at that point nobody else
  908. // is modifying pDriverData->CurrentVideoFormat and/or
  909. // pDriverData->NumVideoSurfaces so the caller is free to make
  910. // their changes
  911. void __inline GRAB_VIDEO_FORMAT_SEMAPHORE (WORD *pVideoSemaphore )
  912. {
  913. _asm
  914. {
  915. mov edi,pVideoSemaphore
  916. waitloop:
  917. bts word PTR [edi],0
  918. jc waitloop
  919. }
  920. }
  921. void __inline UNGRAB_VIDEO_FORMAT_SEMAPHORE (WORD *pVideoSemaphore)
  922. {
  923. _asm
  924. {
  925. mov edi,pVideoSemaphore
  926. btr word PTR [edi],0
  927. }
  928. }
  929. /*
  930. * DrawEngineBusy should be replaced by a test to see the bltter is still
  931. * busy drawing
  932. */
  933. static __inline BOOL DrawEngineBusy(DRIVERDATA* pDriverData)
  934. {
  935. PVGAR pREG = (PVGAR) pDriverData->RegsAddress;
  936. return ( pREG->grSTATUS != 0 );
  937. }
  938. // Convert offset into X, Y coordinate
  939. static __inline DWORD cvlxy(LONG pitch, DWORD dwOffset, unsigned nBytesPixel)
  940. {
  941. // Convert a linear frame buffer offset into a XY DWORD.
  942. // Offset mod pitch div bytes/pixel = X
  943. // Offset div pitch = Y
  944. return (MAKELONG((dwOffset % pitch) / nBytesPixel, (dwOffset / pitch)));
  945. }
  946. //
  947. // DirectDraw function prototypes
  948. //
  949. void BltInit (PDEV* ppdev, BOOL bEnableDisplayListBlts );
  950. VOID vGetDisplayDuration(PFLIPRECORD pflipRecord);
  951. HRESULT vUpdateFlipStatus(PFLIPRECORD pflipRecord, FLATPTR fpVidMem);
  952. DWORD DdBlt(PDD_BLTDATA lpBlt);
  953. DWORD Blt65(PDD_BLTDATA pbd);
  954. DWORD DdFlip(PDD_FLIPDATA lpFlip);
  955. DWORD DdLock(PDD_LOCKDATA lpLock);
  956. DWORD DdUnlock(PDD_UNLOCKDATA lpUnlock);
  957. DWORD DdGetBltStatus(PDD_GETBLTSTATUSDATA lpGetBltStatus);
  958. DWORD DdGetFlipStatus(PDD_GETFLIPSTATUSDATA lpGetFlipStatus);
  959. DWORD DdWaitForVerticalBlank(PDD_WAITFORVERTICALBLANKDATA lpWaitForVerticalBlank);
  960. void SetGamma(PDEV* ppdev, DRIVERDATA* pDriverData);
  961. DWORD CanCreateSurface (PDD_CANCREATESURFACEDATA lpInput);
  962. DWORD CreateSurface (PDD_CREATESURFACEDATA lpInput);
  963. DWORD DestroySurface (PDD_DESTROYSURFACEDATA lpInput);
  964. //#ifdef DDDRV_GETSCANLINE
  965. DWORD GetScanLine(PDD_GETSCANLINEDATA lpGetScanLine);
  966. //#endif
  967. #endif // WINNT_VER40 DirectDraw
  968. //
  969. // Determines the size of the DriverExtra information in the DEVMODE
  970. // structure passed to and from the display driver.
  971. //
  972. #define DRIVER_EXTRA_SIZE 0
  973. //
  974. // Clipping Control Stuff
  975. // Holds a list of clipping rectangles. We give this structure to GDI, and
  976. // GDI fills it in.
  977. //
  978. typedef struct {
  979. ULONG c;
  980. RECTL arcl[8];
  981. } ENUMRECTS8;
  982. typedef ENUMRECTS8 *PENUMRECTS8;
  983. #define MIN(a, b) ((a) < (b) ? (a) : (b))
  984. #define MAX(a, b) ((a) > (b) ? (a) : (b))
  985. //
  986. //////////////////////////////////////////////////////////////////////
  987. // Text stuff
  988. //
  989. // DRAWBLTDEF values
  990. #define TEXT_EXPAND_XPAR 0x106601F0
  991. #define TEXT_EXPAND_OPAQUE 0x100600F0
  992. #define SOLID_COLOR_FILL 0x100700F0
  993. typedef struct _XLATECOLORS { // Specifies foreground and background
  994. ULONG iBackColor; // colours for faking a 1bpp XLATEOBJ
  995. ULONG iForeColor;
  996. } XLATECOLORS; /* xlc, pxlc */
  997. BOOL bEnableText(PDEV*);
  998. VOID vDisableText(PDEV*);
  999. VOID vAssertModeText(PDEV*, BOOL);
  1000. /*
  1001. Function prototypes for device bitmap saving/restoring.
  1002. */
  1003. BOOL bCreateDibFromScreen(PPDEV ppdev, PDSURF pdsurf);
  1004. BOOL bCreateScreenFromDib(PPDEV ppdev, PDSURF pdsurf);
  1005. #if ENABLE_LOG_FILE
  1006. // Function prototypes for logging information to disk
  1007. HANDLE CreateLogFile(
  1008. HANDLE hDriver,
  1009. PDWORD Index);
  1010. BOOL WriteLogFile(
  1011. HANDLE hDriver,
  1012. LPVOID lpBuffer,
  1013. DWORD BytesToWrite,
  1014. PCHAR TextBuffer,
  1015. PDWORD Index);
  1016. BOOL CloseLogFile(
  1017. HANDLE hDriver,
  1018. PCHAR TextBuffer,
  1019. PDWORD Index);
  1020. void DDFormatLogFile(
  1021. LPSTR szFormat, ...);
  1022. #else
  1023. #define CreateLogFile(a, b)
  1024. #define WriteLogFile(a, b, c, d, e)
  1025. #define CloseLogFile(a)
  1026. #define DDFormatLogFile // turn it into a comment
  1027. #endif
  1028. // restore default structure alignment
  1029. #pragma pack()
  1030. 
  1031.