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.

633 lines
20 KiB

  1. /***************************************************************************
  2. *
  3. * ******************************************
  4. * * Copyright (c) 1996, Cirrus Logic, Inc. *
  5. * * All Rights Reserved *
  6. * ******************************************
  7. *
  8. * PROJECT: Laguna I (CL-GD546x) -
  9. *
  10. * FILE: ddraw.c
  11. *
  12. * AUTHOR: Benny Ng
  13. *
  14. * DESCRIPTION:
  15. * This module implements the DirectDraw components for the
  16. * Laguna NT driver.
  17. *
  18. * MODULES:
  19. * DdMapMemory()
  20. * DrvGetDirectDrawInfo()
  21. * DrvEnableDirectDraw()
  22. * DrvDisableDirectDraw()
  23. *
  24. * REVISION HISTORY:
  25. * 7/12/96 Benny Ng Initial version
  26. *
  27. * $Log: X:/log/laguna/nt35/displays/cl546x/ddraw.c $
  28. *
  29. * Rev 1.25 Apr 16 1998 15:19:50 frido
  30. * PDR#11160. The hardware is broken converting 16-bit YUV to 24-bit RGB.
  31. *
  32. * Rev 1.24 16 Sep 1997 15:01:24 bennyn
  33. *
  34. * Modified for NT DD overlay
  35. *
  36. * Rev 1.23 29 Aug 1997 17:11:54 RUSSL
  37. * Added overlay support
  38. *
  39. * Rev 1.22 12 Aug 1997 16:57:10 bennyn
  40. *
  41. * Moved the DD scratch buffer allocation to bInitSurf()
  42. *
  43. * Rev 1.21 11 Aug 1997 14:06:10 bennyn
  44. * Added DDCAPS_READSCANLINE support (For PDR 10254)
  45. *
  46. ****************************************************************************
  47. ****************************************************************************/
  48. /*----------------------------- INCLUDES ----------------------------------*/
  49. #include "precomp.h"
  50. #include "clioctl.h"
  51. //#include <driver.h>
  52. //#include "laguna.h"
  53. //
  54. // This file isn't used in NT 3.51
  55. //
  56. #ifndef WINNT_VER35
  57. /*----------------------------- DEFINES -----------------------------------*/
  58. //#define DBGBRK
  59. #define DBGLVL 1
  60. // FourCC formats are encoded in reverse because we're little endian:
  61. #define FOURCC_YUY2 '2YUY' // Encoded in reverse because we're little endian
  62. #define SQXINDEX (0x3c4)
  63. #define RDRAM_INDEX (0x0a)
  64. #define BIT_9 (0x80)
  65. /*--------------------- STATIC FUNCTION PROTOTYPES ------------------------*/
  66. /*--------------------------- ENUMERATIONS --------------------------------*/
  67. /*----------------------------- TYPEDEFS ----------------------------------*/
  68. /*-------------------------- STATIC VARIABLES -----------------------------*/
  69. /*-------------------------- GLOBAL FUNCTIONS -----------------------------*/
  70. /****************************************************************************
  71. * FUNCTION NAME: DdMapMemory
  72. *
  73. * DESCRIPTION: This is a new DDI call specific to Windows NT that is
  74. * used to map or unmap all the application modifiable
  75. * portions of the frame buffer into the specified process's
  76. * address space.
  77. ****************************************************************************/
  78. DWORD DdMapMemory(PDD_MAPMEMORYDATA lpMapMemory)
  79. {
  80. PDEV* ppdev;
  81. VIDEO_SHARE_MEMORY ShareMemory;
  82. VIDEO_SHARE_MEMORY_INFORMATION ShareMemoryInformation;
  83. DWORD ReturnedDataLength;
  84. ppdev = (PDEV*) lpMapMemory->lpDD->dhpdev;
  85. DISPDBG((DBGLVL, "DDraw - DdMapMemory\n"));
  86. #ifdef DBGBRK
  87. DBGBREAKPOINT();
  88. #endif
  89. ShareMemory.ProcessHandle = lpMapMemory->hProcess;
  90. if (lpMapMemory->bMap)
  91. {
  92. // 'RequestedVirtualAddress' isn't actually used for the SHARE IOCTL:
  93. ShareMemory.RequestedVirtualAddress = 0;
  94. // We map in starting at the top of the frame buffer:
  95. ShareMemory.ViewOffset = 0;
  96. // We map down to the end of the frame buffer.
  97. //
  98. // Note: There is a 64k granularity on the mapping (meaning that
  99. // we have to round up to 64k).
  100. //
  101. // Note: If there is any portion of the frame buffer that must
  102. // not be modified by an application, that portion of memory
  103. // MUST NOT be mapped in by this call. This would include
  104. // any data that, if modified by a malicious application,
  105. // would cause the driver to crash. This could include, for
  106. // example, any DSP code that is kept in off-screen memory.
  107. // v-normmi
  108. // ShareMemory.ViewSize = ROUND_UP_TO_64K(ppdev->cyMemory * ppdev->lDeltaScreen);
  109. ShareMemory.ViewSize = ROUND_UP_TO_64K(ppdev->cyMemoryReal * ppdev->lDeltaScreen);
  110. if (EngDeviceIoControl(ppdev->hDriver,
  111. IOCTL_VIDEO_SHARE_VIDEO_MEMORY,
  112. &ShareMemory,
  113. sizeof(VIDEO_SHARE_MEMORY),
  114. &ShareMemoryInformation,
  115. sizeof(VIDEO_SHARE_MEMORY_INFORMATION),
  116. &ReturnedDataLength))
  117. {
  118. DISPDBG((0, "DDraw - Failed IOCTL_VIDEO_SHARE_MEMORY"));
  119. lpMapMemory->ddRVal = DDERR_GENERIC;
  120. return(DDHAL_DRIVER_HANDLED);
  121. };
  122. lpMapMemory->fpProcess = (DWORD) ShareMemoryInformation.VirtualAddress;
  123. }
  124. else
  125. {
  126. ShareMemory.ViewOffset = 0;
  127. ShareMemory.ViewSize = 0;
  128. ShareMemory.RequestedVirtualAddress = (VOID*) lpMapMemory->fpProcess;
  129. if (EngDeviceIoControl(ppdev->hDriver,
  130. IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY,
  131. &ShareMemory,
  132. sizeof(VIDEO_SHARE_MEMORY),
  133. NULL,
  134. 0,
  135. &ReturnedDataLength))
  136. {
  137. DISPDBG((0, "DDraw - Failed IOCTL_VIDEO_SHARE_MEMORY"));
  138. };
  139. };
  140. lpMapMemory->ddRVal = DD_OK;
  141. return(DDHAL_DRIVER_HANDLED);
  142. }
  143. /****************************************************************************
  144. * FUNCTION NAME: DrvGetDirectDrawInfo
  145. *
  146. * DESCRIPTION: Will be called before DrvEnableDirectDraw is called.
  147. ****************************************************************************/
  148. BOOL DrvGetDirectDrawInfo(DHPDEV dhpdev,
  149. DD_HALINFO* pHalInfo,
  150. DWORD* pdwNumHeaps,
  151. VIDEOMEMORY* pvmList, // Will be NULL on 1st call
  152. DWORD* pdwNumFourCC,
  153. DWORD* pdwFourCC) // Will be NULL on 1st call
  154. {
  155. BOOL bCanFlip;
  156. PDEV* ppdev = (PDEV*) dhpdev;
  157. DRIVERDATA* pDriverData = (DRIVERDATA*) &ppdev->DriverData;
  158. POFMHDL pds = NULL;
  159. DISPDBG((DBGLVL, "DDraw - DrvGetDirectDrawInfo\n"));
  160. #ifdef DBGBRK
  161. DBGBREAKPOINT();
  162. #endif
  163. pHalInfo->dwSize = sizeof(DD_HALINFO);
  164. // Current primary surface attributes. Since HalInfo is zero-initialized
  165. // by GDI, we only have to fill in the fields which should be non-zero:
  166. pHalInfo->vmiData.pvPrimary = ppdev->pjScreen;
  167. pHalInfo->vmiData.dwDisplayWidth = ppdev->cxScreen;
  168. pHalInfo->vmiData.dwDisplayHeight = ppdev->cyScreen;
  169. pHalInfo->vmiData.lDisplayPitch = ppdev->lDeltaScreen;
  170. pHalInfo->vmiData.ddpfDisplay.dwSize = sizeof(DDPIXELFORMAT);
  171. pHalInfo->vmiData.ddpfDisplay.dwFlags = DDPF_RGB;
  172. pHalInfo->vmiData.ddpfDisplay.dwRGBBitCount = ppdev->ulBitCount;
  173. if (ppdev->iBitmapFormat == BMF_8BPP)
  174. pHalInfo->vmiData.ddpfDisplay.dwFlags |= DDPF_PALETTEINDEXED8;
  175. // These masks will be zero at 8bpp:
  176. pHalInfo->vmiData.ddpfDisplay.dwRBitMask = ppdev->flRed;
  177. pHalInfo->vmiData.ddpfDisplay.dwGBitMask = ppdev->flGreen;
  178. pHalInfo->vmiData.ddpfDisplay.dwBBitMask = ppdev->flBlue;
  179. // Set up the pointer to the first available video memory after
  180. // the primary surface:
  181. bCanFlip = FALSE;
  182. *pdwNumHeaps = 0;
  183. // Free up as much off-screen memory as possible:
  184. // Now simply reserve the biggest chunk for use by DirectDraw:
  185. if ((pds = ppdev->DirectDrawHandle) == NULL)
  186. {
  187. #if DRIVER_5465
  188. pds = DDOffScnMemAlloc(ppdev);
  189. ppdev->DirectDrawHandle = pds;
  190. #else
  191. // Because the 24 BPP transparent BLT is broken, punt it
  192. if (ppdev->iBitmapFormat != BMF_24BPP)
  193. {
  194. pds = DDOffScnMemAlloc(ppdev);
  195. ppdev->DirectDrawHandle = pds;
  196. };
  197. #endif // DRIVER_5465
  198. };
  199. if (pds != NULL)
  200. {
  201. *pdwNumHeaps = 1;
  202. // Fill in the list of off-screen rectangles if we've been asked
  203. // to do so:
  204. if (pvmList != NULL)
  205. {
  206. DISPDBG((0, "DirectDraw gets %li x %li surface at (%li, %li)\n",
  207. pds->sizex,
  208. pds->sizey,
  209. pds->x,
  210. pds->y));
  211. pvmList->dwFlags = VIDMEM_ISRECTANGULAR;
  212. pvmList->fpStart = (pds->y * ppdev->lDeltaScreen) + pds->x;
  213. pvmList->dwWidth = pds->sizex;
  214. pvmList->dwHeight = pds->sizey;
  215. pvmList->ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
  216. if ((DWORD) ppdev->cyScreen <= pvmList->dwHeight)
  217. bCanFlip = TRUE;
  218. }; // if (pvmList != NULL)
  219. //#ifdef ALLOC_IN_CREATESURFACE
  220. // }
  221. // else
  222. // {
  223. // *pdwNumHeaps = 1;
  224. //
  225. // // Fill in the list of off-screen rectangles if we've been asked
  226. // // to do so:
  227. // if (pvmList != NULL)
  228. // {
  229. // pvmList->dwFlags = VIDMEM_ISRECTANGULAR;
  230. // pvmList->fpStart = (FLATPTR) ppdev->pjScreen;
  231. //
  232. // pvmList->dwWidth = 1;
  233. // pvmList->dwHeight = ppdev->lTotalMem;
  234. // pvmList->ddsCaps.dwCaps = 0;
  235. // pvmList->ddsCapsAlt.dwCaps = 0;
  236. // }; // if (pvmList != NULL)
  237. //#endif
  238. }; // if (pds != NULL)
  239. // Capabilities supported:
  240. pHalInfo->ddCaps.dwCaps = 0
  241. | DDCAPS_BLT
  242. | DDCAPS_BLTCOLORFILL
  243. ;
  244. #if 1 // PDR#11160
  245. if (ppdev->iBitmapFormat != BMF_24BPP)
  246. pHalInfo->ddCaps.dwCaps |= DDCAPS_BLTFOURCC;
  247. #endif
  248. // ReadScanLine only support in 5464 & 5465
  249. if (ppdev->dwLgDevID >= CL_GD5464)
  250. pHalInfo->ddCaps.dwCaps |= DDCAPS_READSCANLINE;
  251. #if DRIVER_5465
  252. pHalInfo->ddCaps.dwCaps = pHalInfo->ddCaps.dwCaps
  253. | DDCAPS_BLTSTRETCH
  254. ;
  255. if (ppdev->iBitmapFormat != BMF_24BPP)
  256. {
  257. pHalInfo->ddCaps.dwCaps = pHalInfo->ddCaps.dwCaps
  258. | DDCAPS_COLORKEY // NVH turned off for 24bpp PDR #10142
  259. | DDCAPS_COLORKEYHWASSIST // NVH turned off for 24bpp PDR #10142
  260. ;
  261. }
  262. #else
  263. if (ppdev->iBitmapFormat != BMF_24BPP)
  264. {
  265. pHalInfo->ddCaps.dwCaps = pHalInfo->ddCaps.dwCaps
  266. | DDCAPS_COLORKEY
  267. | DDCAPS_COLORKEYHWASSIST;
  268. if (ppdev->iBitmapFormat != BMF_32BPP)
  269. {
  270. pHalInfo->ddCaps.dwCaps |= DDCAPS_BLTSTRETCH;
  271. };
  272. };
  273. #endif // DRIVER_5465
  274. pHalInfo->ddCaps.dwCKeyCaps = 0;
  275. if (ppdev->iBitmapFormat != BMF_24BPP)
  276. {
  277. pHalInfo->ddCaps.dwCKeyCaps = pHalInfo->ddCaps.dwCKeyCaps
  278. | DDCKEYCAPS_SRCBLT // NVH Turn off for 24bpp. PDR #10142
  279. | DDCKEYCAPS_DESTBLT // NVH Turn off for 24bpp. PDR #10142
  280. ;
  281. }
  282. pHalInfo->ddCaps.ddsCaps.dwCaps = 0
  283. | DDSCAPS_OFFSCREENPLAIN
  284. | DDSCAPS_PRIMARYSURFACE
  285. ;
  286. #ifndef ALLOC_IN_CREATESURFACE
  287. if (bCanFlip)
  288. #endif
  289. pHalInfo->ddCaps.ddsCaps.dwCaps |= DDSCAPS_FLIP;
  290. #ifdef ALLOC_IN_CREATESURFACE
  291. // Since we do our own memory allocation, we have to set dwVidMemTotal
  292. // ourselves. Note that this represents the amount of available off-
  293. // screen memory, not all of video memory:
  294. pHalInfo->ddCaps.dwVidMemFree = ppdev->lTotalMem -
  295. (ppdev->cxScreen * ppdev->cyScreen * ppdev->iBytesPerPixel);
  296. pHalInfo->ddCaps.dwVidMemTotal = pHalInfo->ddCaps.dwVidMemFree;
  297. #endif
  298. #if DRIVER_5465
  299. pHalInfo->ddCaps.dwFXCaps = 0
  300. | DDFXCAPS_BLTARITHSTRETCHY
  301. | DDFXCAPS_BLTSTRETCHX
  302. | DDFXCAPS_BLTSTRETCHXN
  303. | DDFXCAPS_BLTSTRETCHY
  304. | DDFXCAPS_BLTSTRETCHYN
  305. | DDFXCAPS_BLTSHRINKX
  306. | DDFXCAPS_BLTSHRINKY
  307. ;
  308. #else
  309. if ((ppdev->iBitmapFormat != BMF_24BPP) &&
  310. (ppdev->iBitmapFormat != BMF_32BPP))
  311. {
  312. pHalInfo->ddCaps.dwFXCaps = 0
  313. | DDFXCAPS_BLTARITHSTRETCHY
  314. | DDFXCAPS_BLTSTRETCHX
  315. | DDFXCAPS_BLTSTRETCHXN
  316. | DDFXCAPS_BLTSTRETCHY
  317. | DDFXCAPS_BLTSTRETCHYN
  318. | DDFXCAPS_BLTSHRINKX
  319. | DDFXCAPS_BLTSHRINKY
  320. ;
  321. };
  322. #endif // DRIVER_5465
  323. // FOURCCs supported
  324. #if DRIVER_5465 && defined(OVERLAY)
  325. if (! QueryOverlaySupport(ppdev, ppdev->dwLgDevID))
  326. #endif
  327. {
  328. *pdwNumFourCC = 1;
  329. #if DRIVER_5465 && defined(OVERLAY)
  330. pDriverData->dwFourCC[0] = FOURCC_UYVY;
  331. #else
  332. pDriverData->dwFourCC = FOURCC_UYVY;
  333. #endif
  334. if (pdwFourCC != NULL)
  335. {
  336. *pdwFourCC = FOURCC_YUY2;
  337. }
  338. }
  339. // We have to tell DirectDraw our preferred off-screen alignment, even
  340. // if we're doing our own off-screen memory management:
  341. pHalInfo->vmiData.dwOffscreenAlign = 4;
  342. pHalInfo->vmiData.dwOverlayAlign = 0;
  343. pHalInfo->vmiData.dwTextureAlign = 0;
  344. pHalInfo->vmiData.dwZBufferAlign = 0;
  345. pHalInfo->vmiData.dwAlphaAlign = 0;
  346. pDriverData->RegsAddress = ppdev->pLgREGS;
  347. #if DRIVER_5465 && defined(OVERLAY)
  348. if (QueryOverlaySupport(ppdev, ppdev->dwLgDevID))
  349. {
  350. // fill in overlay caps
  351. OverlayInit(ppdev, ppdev->dwLgDevID, NULL, pHalInfo);
  352. }
  353. #endif
  354. return(TRUE);
  355. } // DrvGetDirectDrawInfo
  356. /****************************************************************************
  357. * FUNCTION NAME: DrvEnableDirectDraw
  358. *
  359. * DESCRIPTION: GDI calls this function to obtain pointers to the
  360. * DirectDraw callbacks that the driver supports.
  361. ****************************************************************************/
  362. BOOL DrvEnableDirectDraw(DHPDEV dhpdev,
  363. DD_CALLBACKS* pCallBacks,
  364. DD_SURFACECALLBACKS* pSurfaceCallBacks,
  365. DD_PALETTECALLBACKS* pPaletteCallBacks)
  366. {
  367. SIZEL sizl;
  368. PDEV* ppdev = (PDEV*) dhpdev;
  369. DRIVERDATA* pDriverData = (DRIVERDATA*) &ppdev->DriverData;
  370. DISPDBG((DBGLVL, "DDraw - DrvEnableDirectDraw\n"));
  371. #ifdef DBGBRK
  372. DBGBREAKPOINT();
  373. #endif
  374. #if (VS_CONTROL_HACK && DRIVER_5465)
  375. {
  376. DWORD ReturnedDataLength;
  377. DISPDBG((0,"DrvEnableDirectDraw: Enable MMIO for PCI config regs.\n"));
  378. // Send message to miniport to enable MMIO access of PCI registers
  379. if (EngDeviceIoControl(ppdev->hDriver,
  380. IOCTL_VIDEO_ENABLE_PCI_MMIO,
  381. NULL,
  382. 0,
  383. NULL,
  384. 0,
  385. &ReturnedDataLength))
  386. {
  387. RIP("DrvEnableDirectDraw failed IOCTL_VIDEO_ENABLE_PCI_MMIO");
  388. }
  389. }
  390. #endif
  391. pDriverData->ScreenAddress = ppdev->pjScreen;
  392. pDriverData->VideoBase = ppdev->pjScreen;
  393. #if DRIVER_5465
  394. #else // for 5462 or 5464
  395. // Initialize the DRIVERDATA structure in PDEV
  396. pDriverData->PTAGFooPixel = 0;
  397. _outp(SQXINDEX, RDRAM_INDEX);
  398. pDriverData->fNineBitRDRAMS = _inp(SQXINDEX+1) & BIT_9 ? TRUE : FALSE;
  399. pDriverData->fReset = FALSE;
  400. pDriverData->DrvSemaphore = 0;
  401. pDriverData->EdgeTrim = 0;
  402. pDriverData->VideoSemaphore = 0;
  403. pDriverData->CurrentVideoFormat = 0;
  404. pDriverData->NumVideoSurfaces = 0;
  405. pDriverData->YUVTop = 0;
  406. pDriverData->YUVLeft = 0;
  407. pDriverData->YUVXExt = 0;
  408. pDriverData->YUVYExt = 0;
  409. ppdev->offscr_YUV.SrcRect.left = 0;
  410. ppdev->offscr_YUV.SrcRect.top = 0;
  411. ppdev->offscr_YUV.SrcRect.right = 0;
  412. ppdev->offscr_YUV.SrcRect.bottom = 0;
  413. ppdev->offscr_YUV.nInUse = 0;
  414. ppdev->offscr_YUV.ratio = 0;
  415. ppdev->bYUVuseSWPtr = TRUE;
  416. #endif // DRIVER_5465
  417. ppdev->bDirectDrawInUse = TRUE;
  418. // Setup DD Display list pointers
  419. BltInit (ppdev, FALSE);
  420. // Fill out the driver callback
  421. pCallBacks->dwFlags = 0;
  422. pCallBacks->MapMemory = DdMapMemory;
  423. pCallBacks->dwFlags |= DDHAL_CB32_MAPMEMORY;
  424. pCallBacks->WaitForVerticalBlank = DdWaitForVerticalBlank;
  425. pCallBacks->dwFlags |= DDHAL_CB32_WAITFORVERTICALBLANK;
  426. pCallBacks->CanCreateSurface = CanCreateSurface;
  427. pCallBacks->dwFlags |= DDHAL_CB32_CANCREATESURFACE;
  428. pCallBacks->CreateSurface = CreateSurface;
  429. pCallBacks->dwFlags |= DDHAL_CB32_CREATESURFACE;
  430. // #ifdef DDDRV_GETSCANLINE //***********
  431. // ReadScanLine only support in 5464 & 5465
  432. if (ppdev->dwLgDevID >= CL_GD5464)
  433. {
  434. pCallBacks->GetScanLine = GetScanLine;
  435. pCallBacks->dwFlags |= DDHAL_CB32_GETSCANLINE;
  436. }
  437. // #endif // DDDRV_GETSCANLINE ************
  438. // Fill out the surface callback
  439. pSurfaceCallBacks->dwFlags = 0;
  440. #if DRIVER_5465
  441. pSurfaceCallBacks->Blt = Blt65;
  442. #else
  443. pSurfaceCallBacks->Blt = DdBlt;
  444. #endif // DRIVER_5465
  445. pSurfaceCallBacks->dwFlags |= DDHAL_SURFCB32_BLT;
  446. pSurfaceCallBacks->GetBltStatus = DdGetBltStatus;
  447. pSurfaceCallBacks->dwFlags |= DDHAL_SURFCB32_GETBLTSTATUS;
  448. pSurfaceCallBacks->Flip = DdFlip;
  449. pSurfaceCallBacks->dwFlags |= DDHAL_SURFCB32_FLIP;
  450. pSurfaceCallBacks->GetFlipStatus = DdGetFlipStatus;
  451. pSurfaceCallBacks->dwFlags |= DDHAL_SURFCB32_GETFLIPSTATUS;
  452. pSurfaceCallBacks->Lock = DdLock;
  453. pSurfaceCallBacks->dwFlags |= DDHAL_SURFCB32_LOCK;
  454. pSurfaceCallBacks->Unlock = DdUnlock;
  455. pSurfaceCallBacks->dwFlags |= DDHAL_SURFCB32_UNLOCK;
  456. pSurfaceCallBacks->DestroySurface = DestroySurface;
  457. pSurfaceCallBacks->dwFlags |= DDHAL_SURFCB32_DESTROYSURFACE;
  458. #if DRIVER_5465 && defined(OVERLAY)
  459. if (QueryOverlaySupport(ppdev, ppdev->dwLgDevID))
  460. {
  461. // fill in overlay caps
  462. OverlayInit(ppdev, ppdev->dwLgDevID, pSurfaceCallBacks, NULL);
  463. }
  464. #endif
  465. // Note that we don't call 'vGetDisplayDuration' here, for a couple of
  466. // reasons:
  467. // o Because the system is already running, it would be disconcerting
  468. // to pause the graphics for a good portion of a second just to read
  469. // the refresh rate;
  470. // o More importantly, we may not be in graphics mode right now.
  471. //
  472. // For both reasons, we always measure the refresh rate when we switch
  473. // to a new mode.
  474. return(TRUE);
  475. } // DrvEnableDirectDraw
  476. /****************************************************************************
  477. * FUNCTION NAME: DrvDisableDirectDraw
  478. *
  479. * DESCRIPTION: GDI call this function when the last DirectDraw application
  480. * has finished running.
  481. ****************************************************************************/
  482. VOID DrvDisableDirectDraw(DHPDEV dhpdev)
  483. {
  484. DRIVERDATA* pDriverData;
  485. ULONG ultmp;
  486. PDEV* ppdev = (PDEV*) dhpdev;
  487. pDriverData = (DRIVERDATA*) &ppdev->DriverData;
  488. DISPDBG((DBGLVL, "DDraw - DrvDisableDirectDraw\n"));
  489. #if 0
  490. #if (VS_CONTROL_HACK && DRIVER_5465)
  491. {
  492. // Clear bit 0 to disable PCI register MMIO access
  493. DISPDBG((0,"DrvDisableDirectDraw: Disable MMIO for PCI config regs.\n"));
  494. ppdev->grVS_CONTROL &= 0xFFFFFFFE;
  495. LL32 (grVS_Control, ppdev->grVS_CONTROL);
  496. }
  497. #endif
  498. #endif
  499. #ifdef DBGBRK
  500. DBGBREAKPOINT();
  501. #endif
  502. #if DRIVER_5465
  503. #else // for 5462 or 5464
  504. if (ppdev->bYUVuseSWPtr)
  505. {
  506. // Disable the Hw cursor by clearing the hw cursor enable
  507. // bit in CURSOR_CONTROL reg
  508. ultmp = LLDR_SZ (grCursor_Control);
  509. if (ultmp & 1)
  510. {
  511. ultmp &= 0xFFFE;
  512. LL16 (grCursor_Control, ultmp);
  513. };
  514. };
  515. #endif // DRIVER_5465
  516. // DirectDraw is done with the display, so we can go back to using
  517. // all of off-screen memory ourselves:
  518. DDOffScnMemRestore(ppdev);
  519. ppdev->bYUVSurfaceOn = FALSE;
  520. ppdev->bDirectDrawInUse = FALSE;
  521. } // DrvDisableDirectDraw
  522. #endif // ! ver3.51
  523. 
  524.