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.

493 lines
13 KiB

  1. /**************************************************************************
  2. ***************************************************************************
  3. *
  4. * Copyright (c) 1997, Cirrus Logic, Inc.
  5. * All Rights Reserved
  6. *
  7. * FILE: overlay.c
  8. *
  9. * DESCRIPTION:
  10. *
  11. * REVISION HISTORY:
  12. *
  13. * $Log: //uinac/log/log/laguna/ddraw/src/overlay.c $
  14. *
  15. * Rev 1.20 Apr 07 1998 10:48:04 frido
  16. * PDR#11299. We should always handle the DDOVER_HIDE flag in
  17. * UpdateSurface32, even when the device is in background mode.
  18. * Otherwise we might end up having the overlay disabled when it is no
  19. * longer updated.
  20. *
  21. * Rev 1.19 06 Jan 1998 14:58:22 xcong
  22. * Passs lpDDHALData into SyncWithQueusManager().
  23. *
  24. * Rev 1.18 06 Jan 1998 11:53:16 xcong
  25. * Change pDriverData into local lpDDHALData for multi-monitor support.
  26. *
  27. * Rev 1.17 08 Dec 1997 14:43:40 BERSABE
  28. * used in fw162b12, fixed PDR# 10991. OverFly disappeared after switch back and
  29. * and forth to DOS full several times
  30. *
  31. * Rev 1.16.1.2 Dec 06 1997 14:45:48 bersabe
  32. * * Fixed PDR# 10991. OverFly disappered after switch back and forth to DOS ful
  33. * * several times.
  34. *
  35. * Rev 1.16.1.2 06 Dec 1997 14:35:00 chaoyi #cyl1
  36. *
  37. * Fixed PDR# 10991. OverFly disappered after switch back and forth to DOS full screen
  38. * several times.
  39. *
  40. * Rev 1.16.1.1 25 Nov 1997 16:39:32 randys
  41. *
  42. * Updated VDD API values to maintain backward compatibility
  43. *
  44. * Rev 1.16.1.0 10 Nov 1997 13:44:24 randys
  45. *
  46. * Updated hard coded Win32 overlay API function number 12 ----> 13
  47. *
  48. * Rev 1.16 23 Oct 1997 11:17:30 frido
  49. * Merged file with 161 tree.
  50. *
  51. * Rev 1.11.1.0 21 Oct 1997 17:49:10 frido
  52. * HP#75. Added call to VXD whenever we get a request to update the position
  53. * of an overlay so the VXD knows it has been updated.
  54. *
  55. * Rev 1.15 17 Oct 1997 11:31:32 bennyn
  56. *
  57. * For NT, in UpdateOverlay32 & SetOverlayPosition32, return if dwReser0
  58. *
  59. * Rev 1.14 09 Oct 1997 15:16:18 bennyn
  60. * Removed Noel's hack in QueryOverlaySupport.
  61. *
  62. * Rev 1.13 08 Oct 1997 11:15:44 RUSSL
  63. * Fix for NT40 build without overlay support
  64. *
  65. * Rev 1.12 08 Oct 1997 10:34:28 noelv
  66. * HAcked QueryOverlaySupport to always return FALSE for NT.
  67. *
  68. * Rev 1.11 19 Sep 1997 14:33:42 bennyn
  69. * Fixed the NT4.0 5462/64 build problem
  70. *
  71. * Rev 1.10 16 Sep 1997 15:10:26 bennyn
  72. * Modified for NT DD overlay
  73. *
  74. * Rev 1.9 29 Aug 1997 16:25:28 RUSSL
  75. * Added support for NT
  76. *
  77. * Rev 1.8 09 Jul 1997 14:47:58 RUSSL
  78. * For forward compatibility, assume future chips support overlay
  79. *
  80. * Rev 1.7 27 Apr 1997 22:10:38 cjl
  81. * Added DX5-related test code.
  82. * Added code, wrapped by "#ifdef TEST_DX5_AGP_HBT," that forces
  83. * overlay support off.
  84. *
  85. * Rev 1.6 01 Apr 1997 09:14:36 RUSSL
  86. * Added calls to SyncWithQueueManager in UpdateOverlay32, SetOverlayPosition32
  87. * & SetColorKey32
  88. *
  89. * Rev 1.5 12 Mar 1997 15:18:16 RUSSL
  90. * replaced a block of includes with include of precomp.h for
  91. * precompiled headers
  92. * Added check of pDriverData->bInBackground flag in UpdateOverlay32 and
  93. * SetOverlayPosition32. If this flag is set then we want to fail the
  94. * call because we are in fullscreen DOS.
  95. *
  96. * Rev 1.4 07 Mar 1997 12:57:44 RUSSL
  97. * Modified DDRAW_COMPAT usage
  98. *
  99. * Rev 1.3 31 Jan 1997 08:51:48 RUSSL
  100. * Added better chip checking to QueryOverlaySupport
  101. *
  102. * Rev 1.2 27 Jan 1997 18:36:02 RUSSL
  103. * Moved GetFormatInfo to surface.c
  104. *
  105. * Rev 1.1 21 Jan 1997 14:37:12 RUSSL
  106. * Added OverlayReInit and GetFormatInfo functions
  107. *
  108. * Rev 1.0 15 Jan 1997 10:33:36 RUSSL
  109. * Initial revision.
  110. *
  111. ***************************************************************************
  112. ***************************************************************************/
  113. /***************************************************************************
  114. * I N C L U D E S
  115. ****************************************************************************/
  116. #include "precomp.h"
  117. #if defined WINNT_VER35 // WINNT_VER35
  118. // If WinNT 3.5 skip all the source code
  119. #elif defined (NTDRIVER_546x)
  120. // If WinNT 4.0 and 5462/64 build skip all the source code
  121. #elif defined(WINNT_VER40) && !defined(OVERLAY)
  122. // if nt40 without overlay, skip all the source code
  123. #else
  124. #ifndef WINNT_VER40
  125. #include "flip.h"
  126. #include "surface.h"
  127. #include "blt.h"
  128. #include "overlay.h"
  129. #endif
  130. /***************************************************************************
  131. * D E F I N E S
  132. ****************************************************************************/
  133. // VW_CAP0 bits
  134. #define VWCAP_VW_PRESENT 0x00000001
  135. #ifdef WINNT_VER40
  136. #define lpDDHALData ((DRIVERDATA *)(&(ppdev->DriverData)))
  137. #endif
  138. /***************************************************************************
  139. * G L O B A L V A R I A B L E S
  140. ****************************************************************************/
  141. #ifndef WINNT_VER40
  142. OVERLAYTABLE OverlayTable;
  143. #endif
  144. /***************************************************************************
  145. * S T A T I C V A R I A B L E S
  146. ****************************************************************************/
  147. #ifndef WINNT_VER40
  148. ASSERTFILE("overlay.c");
  149. #endif
  150. /***************************************************************************
  151. *
  152. * FUNCTION: QueryOverlaySupport()
  153. *
  154. * DESCRIPTION:
  155. *
  156. ****************************************************************************/
  157. BOOL QueryOverlaySupport
  158. (
  159. #ifdef WINNT_VER40
  160. PDEV *ppdev,
  161. #else
  162. LPGLOBALDATA lpDDHALData,
  163. #endif
  164. DWORD dwChipType
  165. )
  166. {
  167. #ifdef TEST_DX5_AGP_HBT
  168. lpDDHALData->fOverlaySupport = FALSE;
  169. return lpDDHALData->fOverlaySupport;
  170. #endif // TEST_DX5_AGP_HBT
  171. // We should check the capabilities register on the chip
  172. // but it's busted
  173. #ifdef WINNT_VER40
  174. if (CL_GD5465 > dwChipType)
  175. lpDDHALData->fOverlaySupport = FALSE;
  176. else if (CL_GD5465 == dwChipType)
  177. lpDDHALData->fOverlaySupport = TRUE;
  178. #else
  179. if (REVID_PRE65 & lpDDHALData->bRevInfoBits)
  180. lpDDHALData->fOverlaySupport = FALSE;
  181. else if (GD5465_PCI_DEVICE_ID == dwChipType)
  182. lpDDHALData->fOverlaySupport = TRUE;
  183. #endif
  184. else
  185. {
  186. #if 1
  187. // assume overlay hw exists
  188. lpDDHALData->fOverlaySupport = TRUE;
  189. #else
  190. int i;
  191. PVGAR pREG = (PVGAR)lpDDHALData->RegsAddress;
  192. // assume no overlay hw
  193. lpDDHALData->fOverlaySupport = FALSE;
  194. // now check caps to see if any overlay hw present
  195. for (i = 0; i < MAX_VIDEO_WINDOWS; i++)
  196. {
  197. if (VWCAP_VW_PRESENT & pREG->VideoWindow[i].grVW_CAP0)
  198. lpDDHALData->fOverlaySupport = TRUE;
  199. }
  200. #endif
  201. }
  202. return lpDDHALData->fOverlaySupport;
  203. }
  204. /***************************************************************************
  205. *
  206. * FUNCTION: OverlayInit()
  207. *
  208. * DESCRIPTION:
  209. *
  210. ****************************************************************************/
  211. VOID OverlayInit
  212. (
  213. #ifdef WINNT_VER40
  214. PDEV *ppdev,
  215. DWORD dwChipType,
  216. PDD_SURFACECALLBACKS pSurfaceCallbacks,
  217. PDD_HALINFO pDDHalInfo
  218. #else
  219. DWORD dwChipType,
  220. LPDDHAL_DDSURFACECALLBACKS pSurfaceCallbacks,
  221. LPDDHALINFO pDDHalInfo,
  222. LPGLOBALDATA lpDDHALData
  223. #endif
  224. )
  225. {
  226. #ifdef WINNT_VER40
  227. #else
  228. memset(&OverlayTable,0, sizeof(OVERLAYTABLE));
  229. #endif
  230. #ifdef WINNT_VER40
  231. if (! QueryOverlaySupport(ppdev,dwChipType))
  232. #else
  233. if (! QueryOverlaySupport(lpDDHALData,dwChipType))
  234. #endif
  235. return;
  236. #ifdef WINNT_VER40
  237. // NT passes pSurfaceCallbacks as NULL from DrvGetDirectDrawInfo
  238. if (NULL != pSurfaceCallbacks)
  239. #endif
  240. {
  241. // fill in overlay callbacks
  242. pSurfaceCallbacks->UpdateOverlay = UpdateOverlay32;
  243. pSurfaceCallbacks->dwFlags |= DDHAL_SURFCB32_UPDATEOVERLAY;
  244. pSurfaceCallbacks->SetOverlayPosition = SetOverlayPosition32;
  245. pSurfaceCallbacks->dwFlags |= DDHAL_SURFCB32_SETOVERLAYPOSITION;
  246. pSurfaceCallbacks->SetColorKey = SetColorKey32;
  247. pSurfaceCallbacks->dwFlags |= DDHAL_SURFCB32_SETCOLORKEY;
  248. }
  249. #ifdef WINNT_VER40
  250. // NT passes pDDHalInfo as NULL from DrvEnableDirectDraw
  251. if ((NULL != pDDHalInfo) && (CL_GD5465 == dwChipType))
  252. Init5465Overlay(ppdev, dwChipType, pDDHalInfo, &ppdev->DriverData.OverlayTable);
  253. #else
  254. if (GD5465_PCI_DEVICE_ID == dwChipType)
  255. Init5465Overlay(dwChipType, pDDHalInfo, &OverlayTable, lpDDHALData);
  256. #endif
  257. }
  258. #ifndef WINNT_VER40
  259. /***************************************************************************
  260. *
  261. * FUNCTION: OverlayReInit()
  262. *
  263. * DESCRIPTION:
  264. *
  265. ****************************************************************************/
  266. VOID OverlayReInit
  267. (
  268. #ifdef WINNT_VER40
  269. PDEV *ppdev,
  270. DWORD dwChipType,
  271. PDD_HALINFO pDDHalInfo
  272. #else
  273. DWORD dwChipType,
  274. LPDDHALINFO pDDHalInfo,
  275. LPGLOBALDATA lpDDHALData
  276. #endif
  277. )
  278. {
  279. #ifdef WINNT_VER40
  280. if (! QueryOverlaySupport(ppdev,dwChipType))
  281. #else
  282. if (! QueryOverlaySupport(lpDDHALData, dwChipType))
  283. #endif
  284. return;
  285. #ifdef WINNT_VER40
  286. #pragma message("OverlayReInit: Is this function even needed for NT?")
  287. if (CL_GD5465 == dwChipType)
  288. Init5465Info(ppdev, pDDHalInfo);
  289. #else
  290. if (GD5465_PCI_DEVICE_ID == dwChipType)
  291. Init5465Info(pDDHalInfo, lpDDHALData);
  292. #endif
  293. }
  294. #endif // ifndef WINNT_VER40
  295. /***************************************************************************
  296. *
  297. * FUNCTION: UpdateOverlay32
  298. *
  299. * DESCRIPTION:
  300. *
  301. ****************************************************************************/
  302. DWORD __stdcall UpdateOverlay32
  303. (
  304. #ifdef WINNT_VER40
  305. PDD_UPDATEOVERLAYDATA pInput
  306. #else
  307. LPDDHAL_UPDATEOVERLAYDATA pInput
  308. #endif
  309. )
  310. {
  311. #ifdef WINNT_VER40
  312. PDEV* ppdev = (PDEV *)pInput->lpDD->dhpdev;
  313. #else
  314. DWORD cbBytesReturned;
  315. HANDLE vxd;
  316. LPGLOBALDATA lpDDHALData = GetDDHALContext(pInput->lpDD);
  317. #endif
  318. DD_LOG(("UpdateOverlay32 Entry\r\n"));
  319. #ifndef WINNT_VER40
  320. DBG_MESSAGE(("UpdateOverlay32 (lpInput = 0x%08lX)", pInput));
  321. vxd = CreateFile("\\\\.\\546X.VXD", 0, 0, 0, CREATE_NEW,
  322. FILE_FLAG_DELETE_ON_CLOSE, 0);
  323. if (vxd != INVALID_HANDLE_VALUE)
  324. {
  325. DeviceIoControl(vxd, 12, NULL, 0, NULL, 0, &cbBytesReturned, NULL);
  326. CloseHandle(vxd);
  327. }
  328. #endif
  329. #ifdef WINNT_VER40
  330. //#pragma message("UpdateOverlay32: Does NT ddraw call this function while in fullscreen DOS?")
  331. if (pInput->lpDDSrcSurface->dwReserved1 == 0)
  332. {
  333. pInput->ddRVal = DDERR_SURFACEBUSY;
  334. return DDHAL_DRIVER_HANDLED;
  335. }
  336. #else
  337. if (lpDDHALData->bInBackground
  338. #if 1 // PDR#11299. Always handle an overlaydisable call.
  339. && !(pInput->dwFlags & DDOVER_HIDE)
  340. #endif
  341. )
  342. {
  343. //#cyl1 pInput->ddRVal = DDERR_SURFACEBUSY;
  344. pInput->ddRVal = DD_OK; //#cyl1
  345. return DDHAL_DRIVER_HANDLED;
  346. }
  347. #endif
  348. #ifdef WINNT_VER40
  349. SYNC_W_3D(ppdev);
  350. return ppdev->DriverData.OverlayTable.pfnUpdateOverlay(ppdev,pInput);
  351. #else
  352. SyncWithQueueManager(lpDDHALData);
  353. return OverlayTable.pfnUpdateOverlay(pInput);
  354. #endif
  355. } /* UpdateOverlay32 */
  356. /***************************************************************************
  357. *
  358. * FUNCTION: SetOverlayPosition32
  359. *
  360. * DESCRIPTION:
  361. *
  362. ****************************************************************************/
  363. DWORD __stdcall SetOverlayPosition32
  364. (
  365. #ifdef WINNT_VER40
  366. PDD_SETOVERLAYPOSITIONDATA pInput
  367. #else
  368. LPDDHAL_SETOVERLAYPOSITIONDATA pInput
  369. #endif
  370. )
  371. {
  372. #ifdef WINNT_VER40
  373. PDEV* ppdev = (PDEV *)pInput->lpDD->dhpdev;
  374. #else
  375. LPGLOBALDATA lpDDHALData = GetDDHALContext(pInput->lpDD);
  376. #endif
  377. DD_LOG(("SetOverlayPosition32 Entry\r\n"));
  378. #ifndef WINNT_VER40
  379. DBG_MESSAGE(("SetOverlayPosition32 (lpInput = 0x%08lX)", pInput));
  380. #endif
  381. #ifdef WINNT_VER40
  382. //#pragma message("SetOverlayPosition32: Does NT ddraw call this function while in fullscreen DOS?")
  383. if (pInput->lpDDSrcSurface->dwReserved1 == 0)
  384. {
  385. pInput->ddRVal = DDERR_SURFACEBUSY;
  386. return DDHAL_DRIVER_HANDLED;
  387. }
  388. #else
  389. if (lpDDHALData->bInBackground)
  390. {
  391. pInput->ddRVal = DDERR_SURFACEBUSY;
  392. return DDHAL_DRIVER_HANDLED;
  393. }
  394. #endif
  395. #ifdef WINNT_VER40
  396. SYNC_W_3D(ppdev);
  397. return ppdev->DriverData.OverlayTable.pfnSetOverlayPos(ppdev,pInput);
  398. #else
  399. SyncWithQueueManager(lpDDHALData);
  400. return OverlayTable.pfnSetOverlayPos(pInput);
  401. #endif
  402. } /* SetOverlayPosition32 */
  403. /***************************************************************************
  404. *
  405. * FUNCTION: SetColorKey32
  406. *
  407. * DESCRIPTION:
  408. *
  409. ****************************************************************************/
  410. DWORD __stdcall SetColorKey32
  411. (
  412. #ifdef WINNT_VER40
  413. PDD_SETCOLORKEYDATA pInput
  414. #else
  415. LPDDHAL_SETCOLORKEYDATA pInput
  416. #endif
  417. )
  418. {
  419. #ifdef WINNT_VER40
  420. PDEV* ppdev = (PDEV *)pInput->lpDD->dhpdev;
  421. #else
  422. LPGLOBALDATA lpDDHALData = GetDDHALContext( pInput->lpDD);
  423. #endif
  424. DD_LOG(("SetColorKey32 Entry\r\n"));
  425. #ifndef WINNT_VER40
  426. DBG_MESSAGE(("SetColorKey32 (lpInput = 0x%08lX)", pInput));
  427. #endif
  428. // make sure it's a colorkey for an overlay surface
  429. if ((DDCKEY_DESTOVERLAY | DDCKEY_SRCOVERLAY) & pInput->dwFlags)
  430. {
  431. #ifdef WINNT_VER40
  432. SYNC_W_3D(ppdev);
  433. ppdev->DriverData.OverlayTable.pfnSetColorKey(ppdev,pInput);
  434. #else
  435. SyncWithQueueManager(lpDDHALData);
  436. OverlayTable.pfnSetColorKey(pInput);
  437. #endif
  438. }
  439. return DDHAL_DRIVER_NOTHANDLED;
  440. } /* SetColorKey32 */
  441. #endif // WINNT_VER35
  442.