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.

1199 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. ULONG ulMode; // Mode the mini-port driver is in.
  668. ULONG ulFreq; // Frequency
  669. LONG lDeltaScreen; // Distance from one scan to the next.
  670. FLONG flRed; // For bitfields device, Red Mask
  671. FLONG flGreen; // For bitfields device, Green Mask
  672. FLONG flBlue; // For bitfields device, Blue Mask
  673. ULONG cPaletteShift; // number of bits the 8-8-8 palette must
  674. // be shifted by to fit in the hardware
  675. // palette.
  676. POINTL ptlHotSpot; // adjustment for pointer hot spot
  677. ULONG cPatterns; // Count of bitmap patterns created
  678. HBITMAP ahbmPat[HS_DDI_MAX]; // Engine handles to standard patterns
  679. PALETTEENTRY *pPal; // If this is pal managed, this is the pal
  680. PBYTE pjOffScreen; // This is pointer to start of off screen memory
  681. ULONG iBitmapFormat;
  682. ULONG ulBitCount; // # of bits per pel 8,16,24,32 are only supported.
  683. ULONG iBytesPerPixel;
  684. autoblt_regs PtrABlt[3]; // auto BLT tables
  685. #ifdef WINNT_VER40
  686. HSEMAPHORE CShsem; // Critical Section Handle to Semaphore
  687. #else
  688. CRITICAL_SECTION PtrCritSec; // Pointer critical section
  689. #endif
  690. RECTL prcl; // Cursor rectange
  691. BOOL PtrBusy;
  692. BOOL fHwCursorActive; // Are we currently using the hw cursor
  693. BOOL CursorHidden; // Indicate the cursor is hidden
  694. POFMHDL PtrMaskHandle; // Pointer mask handle.
  695. POFMHDL PtrImageHandle; // Pointer image save area handle.
  696. POFMHDL PtrABltHandle; // Pointer auto BLT handle.
  697. ULONG PtrXHotSpot; // X & Y position of the pointer hot spot
  698. ULONG PtrYHotSpot;
  699. ULONG PtrX; // X & Y position of the pointer
  700. ULONG PtrY;
  701. ULONG PtrSzX; // Pointer dimensions
  702. ULONG PtrSzY;
  703. LONG PointerUsage; // DEF_CURSOR - GDI support cursor.
  704. // HW_CURSOR - Use HW cursor.
  705. // SW_CURSOR - Use SW cursor.
  706. DWORD grCONTROL;
  707. DWORD grFORMAT;
  708. DWORD grVS_CONTROL;
  709. // For offscreen memory manager
  710. LONG lOffset_2D; // Offset-2D register value.
  711. LONG lTileSize; // Selected tile size.
  712. LONG lTotalMem; // Installed memory.
  713. BOOL OFM_init; // TRUE InitOffScnMem() has been called.
  714. #ifdef WINNT_VER40
  715. HSEMAPHORE MMhsem; // Memory Manager Handle to Semaphore
  716. #else
  717. HANDLE MutexHdl; // Mutex handle
  718. #endif
  719. BOOL bDirectDrawInUse; // DirectDraw InUse flag.
  720. POFMHDL ScrnHandle; // Active screen handle.
  721. POFMHDL OFM_UsedQ; // Off screen memory queues.
  722. POFMHDL OFM_FreeQ;
  723. POFMHDL OFM_SubFreeQ1;
  724. POFMHDL OFM_SubFreeQ2;
  725. FONTCACHE* pfcChain; // Pointer to chain of FONTCACHE
  726. POFMHDL Bcache; // This is the offscreen memory used to
  727. // cache the brush bits in.
  728. MC_ENTRY Mtable[NUM_MONO_BRUSHES]; // Table to manage mono brush cache.
  729. XC_ENTRY Xtable[NUM_4BPP_BRUSHES]; // Table to manage 4-bpp brush cache.
  730. DC_ENTRY Dtable[NUM_DITHER_BRUSHES]; // Table to manage dither brush cache.
  731. BC_ENTRY Ctable[NUM_COLOR_BRUSHES]; // Table to manage color brush cache.
  732. DC_ENTRY Stable[NUM_SOLID_BRUSHES];
  733. ULONG SNext;
  734. ULONG CLast; // Last usable index in color cache table.
  735. ULONG MNext; // Where next mono brush will be cached.
  736. ULONG XNext; // Where next 4-bpp brush will be cached.
  737. ULONG DNext; // Where next dither brush will be cached.
  738. ULONG CNext; // Where next color brush will be cached.
  739. ULONG ulFontCount; // Font cache counter.
  740. ULONG UseFontCache; // Flag to turn on and off.
  741. POINTL ptlOffset; // x,y offset (for device bitmaps).
  742. BOOL bEnable; // Hardware enabled flag.
  743. COPYFN *pfnHostToScreen; // HostToScreen routine.
  744. COPYFN *pfnScreenToHost; // ScreenToHost routine.
  745. // Here we have the pointer to the memory mapped registers. For
  746. // analysis reasons we sometimes want to 'null' out the hardware
  747. // by aiming the register pointer at blank memory. We keep two
  748. // pointers to registers. pLgREGS_real and pLgREGS usually both point
  749. // to the registers, but we can set flags in LAGUNA.H to cause pLgREGS
  750. // to point to 'buffer' instead. This is useful for testing which
  751. // parts of the driver are software bound and which are hardware bound.
  752. volatile GAR *pLgREGS_real; // Always points to the memory mapped registers.
  753. volatile GAR *pLgREGS; // May point registers, may point to buffer.
  754. WORD dcTileWidth; // Number of Pixels in Current Tile Size
  755. WORD dcSRAMWidth; // Number of Pixels that will fit into SRAM
  756. // These were added to support stroke and fill with the least amount of
  757. // changes.
  758. ULONG uBLTDEF;
  759. ULONG uRop;
  760. PVOID pvTmpBuffer; // General purpose temporary buffer, TMP_BUFFER_SIZE in
  761. // size (Remember to synchronize if you use this for
  762. // device bitmaps or async pointers)
  763. #if ENABLE_LOG_FILE
  764. void *pmfile;
  765. char TxtBuff[0x1000];
  766. DWORD TxtBuffIndex;
  767. #endif
  768. #if NULL_HW
  769. char *buffer[0x8000]; // Empty memory used to "null" the registers.
  770. #endif
  771. //
  772. // Reserve a little space for device bitmaps.
  773. //
  774. #if WINBENCH96
  775. POFMHDL pofmMagic;
  776. ULONG bMagicUsed;
  777. #endif
  778. // SWAT1 changes.
  779. BOOL fPreAllocate;
  780. int nPages;
  781. // SWAT3 changes.
  782. #define FONTCELL_COUNT 64 // Number of font cells
  783. #define FONTCELL_X 128 // Width in bytes of a font cell
  784. #define FONTCELL_Y 16 // Height of a font cell
  785. POFMHDL pofmFontCache; // Font cache allocation heap
  786. FONTCELL fcGrid[FONTCELL_COUNT]; // Array of font cache cells
  787. #if MEMMGR
  788. // MEMMGR changes.
  789. IIMEMMGR mmMemMgr;
  790. LONG must_have_width;
  791. BOOL fBitmapFilter;
  792. SIZEL szlBitmapMin;
  793. SIZEL szlBitmapMax;
  794. #endif
  795. //
  796. // For DirectDraw
  797. //
  798. BOOL bPrevModeDDOutOfVideoMem;
  799. POFMHDL DirectDrawHandle; // DirectDraw handle.
  800. FLIPRECORD flipRecord;
  801. DRIVERDATA DriverData;
  802. OFFSCR_YUV offscr_YUV;
  803. DWORD dwDDLinearCnt; // Ref count of active DD locks
  804. PBYTE pPtrMaskHost;
  805. BOOL bYUVuseSWPtr;
  806. DWORD dwLgVenID; // PCI Vendor ID
  807. DWORD dwLgDevID; // PCI Device ID
  808. DWORD dwLgDevRev; // PCI Device Revision
  809. BOOL bYUVSurfaceOn;
  810. WORD InitBPP;
  811. LONG lRegVals[2][MAX_REGS];
  812. LONG sShrinkInc;
  813. ULONG usLnCntl;
  814. ULONG usStretchCtrl;
  815. #ifdef WINNT_VER40
  816. // DirectDraw display list pointer
  817. PFN_DELAY9BLT pfnDelay9BitBlt;
  818. PFN_EDGEFILLBLT pfnEdgeFillBlt;
  819. PFN_MEDGEFILLBLT pfnMEdgeFillBlt;
  820. PFN_DRVDSTBLT pfnDrvDstBlt;
  821. PFN_DRVDSTBLT pfnDrvDstMBlt;
  822. PFN_DRVSRCBLT pfnDrvSrcBlt;
  823. PFN_DRVSRCMBLT pfnDrvSrcMBlt;
  824. PFN_DRVSTRBLT pfnDrvStrBlt;
  825. PFN_DRVSTRMBLT pfnDrvStrMBlt;
  826. PFN_DRVSTRMBLTY pfnDrvStrMBltY;
  827. PFN_DRVSTRMBLTX pfnDrvStrMBltX;
  828. PFN_DRVSTRBLTY pfnDrvStrBltY;
  829. PFN_DRVSTRBLTX pfnDrvStrBltX;
  830. #endif
  831. POFMHDL DDScratchBufHandle; // DirectDraw scratch buffer handle.
  832. PDDOFM DDOffScnMemQ; // DirectDraw offscreen mem queue.
  833. #ifdef BUS_MASTER
  834. BYTE* Buf1VirtAddr;
  835. BYTE* Buf2VirtAddr;
  836. BYTE* Buf1PhysAddr;
  837. BYTE* Buf2PhysAddr;
  838. ULONG BufLength;
  839. #endif
  840. #ifndef WINNT_VER35
  841. // START OpenGL MCD additions (based on MGA driver in NT4.0 DDK)
  842. HANDLE hMCD; // Handle to MCD engine dll
  843. MCDENGESCFILTERFUNC pMCDFilterFunc; // MCD engine filter function
  844. LONG cDoubleBufferRef; // Reference count for current number
  845. // of RC's that have active double-
  846. LONG cZBufferRef; // Reference count for current number
  847. // of RC's that have active z-buffers
  848. POFMHDL pohBackBuffer; // ofscreen pools
  849. POFMHDL pohZBuffer;
  850. DWORD temp_DL_chunk[SIZE_TEMP_DL]; // temporary mem for display lists
  851. TSystem LL_State;
  852. ALLOCOFFSCNMEMFUNC pAllocOffScnMem;
  853. FREEOFFSCNMEMFUNC pFreeOffScnMem;
  854. ASSERTMODEMCDFUNC pAssertModeMCD;
  855. // recip table to support up to 2K x 2K resolution
  856. #define LAST_FRECIP 2048
  857. float frecips[LAST_FRECIP+1];
  858. ULONG pLastDevRC;
  859. DWORD NumMCDContexts;
  860. ULONG iUniqueness;
  861. // pointer to first and last entries in linked list of texture control blocks
  862. LL_Texture *pFirstTexture;
  863. LL_Texture *pLastTexture;
  864. // END OpenGL MCD additions
  865. #endif
  866. // Translation table cache.
  867. POFMHDL XlateCache;
  868. ULONG XlateCacheId;
  869. WORD CachedChromaCtrl;
  870. WORD CachedStretchCtrl;
  871. DWORD signature; // Expected value: 0x12345678;
  872. #if DATASTREAMING
  873. DWORD dwDataStreaming;
  874. DWORD shadowFGCOLOR;
  875. DWORD shadowBGCOLOR;
  876. DWORD shadowDRAWBLTDEF;
  877. BYTE shadowQFREE;
  878. #endif
  879. } PDEV, *PPDEV;
  880. // MCD Prototypes (MCD_TEMP??)
  881. #ifndef WINNT_VER35
  882. BOOL MCDrvGetEntryPoints(MCDSURFACE *pMCDSurface, MCDDRIVER *pMCDDriver);
  883. #endif
  884. DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *);
  885. BOOL bInitPDEV(PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *);
  886. BOOL bInitSURF(PPDEV, BOOL);
  887. BOOL bInitPaletteInfo(PPDEV, DEVINFO *);
  888. VOID InitPointer(PPDEV);
  889. BOOL bInit256ColorPalette(PPDEV);
  890. BOOL bInitPatterns(PPDEV, ULONG);
  891. VOID vDisablePalette(PPDEV);
  892. VOID vDisablePatterns(PPDEV);
  893. VOID vDisableSURF(PPDEV);
  894. BOOL LgMatchDriverToChip(PPDEV ppdev);
  895. #define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
  896. //
  897. // Pointer routines
  898. //
  899. VOID RestoreSaveShowCursor(PPDEV ppdev, LONG x, LONG y);
  900. ULONG ConvertMaskBufToLinearAddr(PPDEV ppdev);
  901. #ifdef WINNT_VER40
  902. // GrabVideoFormat will set & test the VIDEO_FORMAT bit of
  903. // pDriverData->VideoSemaphore if the bit was already set it
  904. // will loop until the bit wasn't set at that point nobody else
  905. // is modifying pDriverData->CurrentVideoFormat and/or
  906. // pDriverData->NumVideoSurfaces so the caller is free to make
  907. // their changes
  908. void __inline GRAB_VIDEO_FORMAT_SEMAPHORE (WORD *pVideoSemaphore )
  909. {
  910. _asm
  911. {
  912. mov edi,pVideoSemaphore
  913. waitloop:
  914. bts word PTR [edi],0
  915. jc waitloop
  916. }
  917. }
  918. void __inline UNGRAB_VIDEO_FORMAT_SEMAPHORE (WORD *pVideoSemaphore)
  919. {
  920. _asm
  921. {
  922. mov edi,pVideoSemaphore
  923. btr word PTR [edi],0
  924. }
  925. }
  926. /*
  927. * DrawEngineBusy should be replaced by a test to see the bltter is still
  928. * busy drawing
  929. */
  930. static __inline BOOL DrawEngineBusy(DRIVERDATA* pDriverData)
  931. {
  932. PVGAR pREG = (PVGAR) pDriverData->RegsAddress;
  933. return ( pREG->grSTATUS != 0 );
  934. }
  935. // Convert offset into X, Y coordinate
  936. static __inline DWORD cvlxy(LONG pitch, DWORD dwOffset, unsigned nBytesPixel)
  937. {
  938. // Convert a linear frame buffer offset into a XY DWORD.
  939. // Offset mod pitch div bytes/pixel = X
  940. // Offset div pitch = Y
  941. return (MAKELONG((dwOffset % pitch) / nBytesPixel, (dwOffset / pitch)));
  942. }
  943. //
  944. // DirectDraw function prototypes
  945. //
  946. void BltInit (PDEV* ppdev, BOOL bEnableDisplayListBlts );
  947. VOID vGetDisplayDuration(PFLIPRECORD pflipRecord);
  948. HRESULT vUpdateFlipStatus(PFLIPRECORD pflipRecord, FLATPTR fpVidMem);
  949. DWORD DdBlt(PDD_BLTDATA lpBlt);
  950. DWORD Blt65(PDD_BLTDATA pbd);
  951. DWORD DdFlip(PDD_FLIPDATA lpFlip);
  952. DWORD DdLock(PDD_LOCKDATA lpLock);
  953. DWORD DdUnlock(PDD_UNLOCKDATA lpUnlock);
  954. DWORD DdGetBltStatus(PDD_GETBLTSTATUSDATA lpGetBltStatus);
  955. DWORD DdGetFlipStatus(PDD_GETFLIPSTATUSDATA lpGetFlipStatus);
  956. DWORD DdWaitForVerticalBlank(PDD_WAITFORVERTICALBLANKDATA lpWaitForVerticalBlank);
  957. void SetGamma(PDEV* ppdev, DRIVERDATA* pDriverData);
  958. DWORD CanCreateSurface (PDD_CANCREATESURFACEDATA lpInput);
  959. DWORD CreateSurface (PDD_CREATESURFACEDATA lpInput);
  960. DWORD DestroySurface (PDD_DESTROYSURFACEDATA lpInput);
  961. //#ifdef DDDRV_GETSCANLINE
  962. DWORD GetScanLine(PDD_GETSCANLINEDATA lpGetScanLine);
  963. //#endif
  964. #endif // WINNT_VER40 DirectDraw
  965. //
  966. // Determines the size of the DriverExtra information in the DEVMODE
  967. // structure passed to and from the display driver.
  968. //
  969. #define DRIVER_EXTRA_SIZE 0
  970. //
  971. // Clipping Control Stuff
  972. // Holds a list of clipping rectangles. We give this structure to GDI, and
  973. // GDI fills it in.
  974. //
  975. typedef struct {
  976. ULONG c;
  977. RECTL arcl[8];
  978. } ENUMRECTS8;
  979. typedef ENUMRECTS8 *PENUMRECTS8;
  980. #define MIN(a, b) ((a) < (b) ? (a) : (b))
  981. #define MAX(a, b) ((a) > (b) ? (a) : (b))
  982. //
  983. //////////////////////////////////////////////////////////////////////
  984. // Text stuff
  985. //
  986. // DRAWBLTDEF values
  987. #define TEXT_EXPAND_XPAR 0x106601F0
  988. #define TEXT_EXPAND_OPAQUE 0x100600F0
  989. #define SOLID_COLOR_FILL 0x100700F0
  990. typedef struct _XLATECOLORS { // Specifies foreground and background
  991. ULONG iBackColor; // colours for faking a 1bpp XLATEOBJ
  992. ULONG iForeColor;
  993. } XLATECOLORS; /* xlc, pxlc */
  994. BOOL bEnableText(PDEV*);
  995. VOID vDisableText(PDEV*);
  996. VOID vAssertModeText(PDEV*, BOOL);
  997. /*
  998. Function prototypes for device bitmap saving/restoring.
  999. */
  1000. BOOL bCreateDibFromScreen(PPDEV ppdev, PDSURF pdsurf);
  1001. BOOL bCreateScreenFromDib(PPDEV ppdev, PDSURF pdsurf);
  1002. #if ENABLE_LOG_FILE
  1003. // Function prototypes for logging information to disk
  1004. HANDLE CreateLogFile(
  1005. HANDLE hDriver,
  1006. PDWORD Index);
  1007. BOOL WriteLogFile(
  1008. HANDLE hDriver,
  1009. LPVOID lpBuffer,
  1010. DWORD BytesToWrite,
  1011. PCHAR TextBuffer,
  1012. PDWORD Index);
  1013. BOOL CloseLogFile(
  1014. HANDLE hDriver,
  1015. PCHAR TextBuffer,
  1016. PDWORD Index);
  1017. void DDFormatLogFile(
  1018. LPSTR szFormat, ...);
  1019. #else
  1020. #define CreateLogFile(a, b)
  1021. #define WriteLogFile(a, b, c, d, e)
  1022. #define CloseLogFile(a)
  1023. #define DDFormatLogFile // turn it into a comment
  1024. #endif
  1025. // restore default structure alignment
  1026. #pragma pack()
  1027. 
  1028.