|
|
1.1 ! root 1: /******************************Module*Header*******************************\ ! 2: * Module Name: enable.c ! 3: * ! 4: * Functions to enable and disable the driver ! 5: * ! 6: * Copyright (c) 1992 Microsoft Corporation ! 7: \**************************************************************************/ ! 8: ! 9: ! 10: #include "driver.h" ! 11: ! 12: ! 13: FLONG gflDrv = 0; ! 14: #ifdef FIREWALLS ! 15: LONG cPDEV = 0; // PDEV counter for checking Engine ! 16: #endif ! 17: ! 18: extern GDIINFO gaulCap; // in gdiinfo.c ! 19: extern LOGPALETTE logPalVGA; // in gdiinfo.c ! 20: extern BYTE gaajPat[19][32]; // in gdiinfo.c ! 21: extern DEVINFO devinfoVGA; // in gdiinfo.c ! 22: extern LPBYTE pPtrSave; ! 23: ! 24: BOOL SetUpBanking(PDEVSURF, PPDEV); ! 25: BOOL bInitPointer(PPDEV); ! 26: ! 27: extern ajConvertBuffer[1]; // Arbitrary sized array! ! 28: ! 29: static DRVFN gadrvfn[] = { ! 30: { INDEX_DrvEnablePDEV, (PFN) DrvEnablePDEV }, ! 31: { INDEX_DrvCompletePDEV, (PFN) DrvCompletePDEV }, ! 32: { INDEX_DrvDisablePDEV, (PFN) DrvDisablePDEV }, ! 33: { INDEX_DrvEnableSurface, (PFN) DrvEnableSurface }, ! 34: { INDEX_DrvDisableSurface, (PFN) DrvDisableSurface }, ! 35: { INDEX_DrvRealizeBrush, (PFN) DrvRealizeBrush }, ! 36: { INDEX_DrvBitBlt, (PFN) DrvBitBlt }, ! 37: { INDEX_DrvTextOut, (PFN) DrvTextOut }, ! 38: { INDEX_DrvSetPointerShape, (PFN) DrvSetPointerShape }, ! 39: { INDEX_DrvMovePointer, (PFN) DrvMovePointer }, ! 40: { INDEX_DrvStrokePath, (PFN) DrvStrokePath }, ! 41: { INDEX_DrvCopyBits, (PFN) DrvCopyBits }, ! 42: { INDEX_DrvDitherColor, (PFN) DrvDitherColor }, ! 43: { INDEX_DrvAssertMode, (PFN) DrvAssertMode }, ! 44: { INDEX_DrvSaveScreenBits, (PFN) DrvSaveScreenBits }, ! 45: { INDEX_DrvGetModes, (PFN) DrvGetModes }, ! 46: { INDEX_DrvFillPath, (PFN) DrvFillPath }, ! 47: { INDEX_DrvPaint, (PFN) DrvPaint } ! 48: }; ! 49: ! 50: /******************************Public*Routine******************************\ ! 51: * BOOL bEnableDriver(iEngineVersion, cb, pded) ! 52: * ! 53: * Enables the driver by filling the function table. This call is made by ! 54: * the Engine to fill its driver function table in the LDEV (Logical DEVice). ! 55: * This call should only be made once per driver but we can handle being ! 56: * called multiple times. ! 57: * ! 58: \**************************************************************************/ ! 59: ! 60: BOOL DrvEnableDriver ! 61: ( ! 62: ULONG iEngineVersion, ! 63: ULONG cb, ! 64: PDRVENABLEDATA pded ! 65: ) ! 66: { ! 67: DISPDBG((2, "VGA: enabling Driver\n")); ! 68: ! 69: cb /= sizeof(ULONG); ! 70: ! 71: switch(cb) ! 72: { ! 73: case 3: ! 74: pded->pdrvfn = gadrvfn; ! 75: case 2: ! 76: pded->c = sizeof(gadrvfn) / sizeof(DRVFN); ! 77: case 1: ! 78: pded->iDriverVersion = DDI_DRIVER_VERSION; ! 79: } ! 80: ! 81: return(TRUE); ! 82: } ! 83: ! 84: /******************************Public*Routine******************************\ ! 85: * VOID vDisableDriver ! 86: * ! 87: * Unload the driver and any data in may have created. ! 88: * ! 89: \**************************************************************************/ ! 90: ! 91: VOID DrvDisableDriver() ! 92: { ! 93: DISPDBG((2, "VGA: disabling Driver\n")); ! 94: } ! 95: ! 96: /******************************Public*Routine******************************\ ! 97: * BOOL bLoadResources() ! 98: * ! 99: * Load the resources used by the PDEV ! 100: * ! 101: \**************************************************************************/ ! 102: ! 103: BOOL bLoadResources(PPDEV ppdev) ! 104: { ! 105: // Load the font resources ! 106: ! 107: return(TRUE); ! 108: ! 109: UNREFERENCED_PARAMETER(ppdev); ! 110: } ! 111: ! 112: /******************************Public*Routine******************************\ ! 113: * bInitDefaultPatterns ! 114: * ! 115: * Creates the default monochrome patterns to be used on it's surface. ! 116: * ! 117: \**************************************************************************/ ! 118: ! 119: BOOL bInitDefaultPatterns(PPDEV ppdev) ! 120: { ! 121: SIZEL sizl; ! 122: INT iLoop; ! 123: PULONG pulInit; ! 124: ! 125: sizl.cx = 8; ! 126: sizl.cy = 8; ! 127: ! 128: DISPDBG((2, "VGA: initializing defailt patterns\n")); ! 129: ! 130: for (iLoop = 0; iLoop < HS_DDI_MAX; iLoop++) ! 131: { ! 132: pulInit = (PULONG) (&gaajPat[iLoop][0]); ! 133: ppdev->ahbmPat[iLoop] = EngCreateBitmap(sizl, sizl.cx / 8, BMF_1BPP, ! 134: BMF_TOPDOWN, pulInit); ! 135: ! 136: if (ppdev->ahbmPat[iLoop] == (HBITMAP)0) ! 137: { ! 138: // Release any bitmaps we have created. ! 139: ! 140: while(iLoop--) ! 141: EngDeleteSurface((HSURF) ppdev->ahbmPat[iLoop]); ! 142: ! 143: return(FALSE); ! 144: } ! 145: } ! 146: ! 147: return(TRUE); ! 148: } ! 149: ! 150: /******************************Public*Routine******************************\ ! 151: * DHPDEV DrvEnablePDEV ! 152: * ! 153: * Enable the Physical DEVice ! 154: * ! 155: * Warnings: ! 156: * The PDEV isn't complete until bCompletePDEV is called. ! 157: * ! 158: \**************************************************************************/ ! 159: ! 160: DHPDEV DrvEnablePDEV ! 161: ( ! 162: DEVMODEW *pdrivw, ! 163: PWSTR pwszLogAddress, ! 164: ULONG cPatterns, ! 165: PHSURF ahsurfPatterns, ! 166: ULONG cjGdiInfo, ! 167: ULONG *pdevcaps, ! 168: ULONG cb, ! 169: PDEVINFO pdevinfo, ! 170: PWSTR pwszDataFile, ! 171: PWSTR pwszDeviceName, ! 172: HANDLE hDriver // Handle to base driver ! 173: ) ! 174: { ! 175: FLONG fl = 0; ! 176: DHPDEV dhpdev = (DHPDEV) 0; ! 177: PPDEV ppdev; ! 178: SYSTEM_INFO SystemInfo; ! 179: ! 180: DISPDBG((2, "VGA: enabling PDEV\n")); ! 181: ! 182: // Define flag to keep track of allocation ! 183: ! 184: #define PDEV_ALLOCED 0x01 ! 185: ! 186: #ifdef DRV_ONE_PDEV ! 187: if (gflDrv & DRV_ENABLED_PDEV) ! 188: { ! 189: // SAVE_ERROR_CODE(DDI_PDEV_ALREADY_ENABLED); ! 190: goto error; ! 191: } ! 192: #endif ! 193: ! 194: dhpdev = (DHPDEV) LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, sizeof(PDEV)); ! 195: if (dhpdev == (DHPDEV) 0) ! 196: goto error; ! 197: ! 198: fl |= PDEV_ALLOCED; ! 199: ! 200: ppdev = (PPDEV) dhpdev; ! 201: ! 202: // Identifier, for debugging purposes ! 203: ppdev->ident = PDEV_IDENT; ! 204: ! 205: // Determine whether this is a 386 or a better processor ! 206: GetSystemInfo(&SystemInfo); ! 207: if (SystemInfo.dwProcessorType == PROCESSOR_INTEL_386) { ! 208: ppdev->ulIs386 = 1; ! 209: } else { ! 210: ppdev->ulIs386 = 0; ! 211: } ! 212: ! 213: // Cache the device driver handle away for later use. ! 214: ! 215: ppdev->hDriver = hDriver; ! 216: ! 217: // Initialize the cursor stuff. We can violate the atomic rule here ! 218: // since nobody can talk to the driver yet. ! 219: ! 220: ppdev->xyCursor.x = 320; // Non-atomic ! 221: ppdev->xyCursor.y = 240; // Non-atomic ! 222: ! 223: ppdev->ptlExtent.x = 0; ! 224: ppdev->ptlExtent.y = 0; ! 225: ppdev->cExtent = 0; ! 226: ! 227: ppdev->flCursor = CURSOR_DOWN; ! 228: ! 229: // ! 230: // Get the current screen mode information. Set up device caps and devinfo. ! 231: // ! 232: ! 233: if (!bInitPDEV(ppdev, pdrivw, &gaulCap, &devinfoVGA)) ! 234: { ! 235: DISPDBG((1, "DISP VGA DrvEnablePDEV failed bInitPDEV\n")); ! 236: goto error; ! 237: } ! 238: ! 239: if (!bLoadResources(ppdev)) ! 240: goto error; ! 241: ! 242: if (!bInitDefaultPatterns(ppdev)) ! 243: goto error; ! 244: ! 245: #ifdef DRV_ONE_PDEV ! 246: gflDrv |= DRV_ENABLED_PDEV; // So we're not called twice ! 247: #endif ! 248: ! 249: cPatterns=min(cPatterns, HS_DDI_MAX); ! 250: ! 251: memcpy((PVOID)ahsurfPatterns, ppdev->ahbmPat, cPatterns*sizeof(HBITMAP)); ! 252: ! 253: cjGdiInfo=min(cjGdiInfo, sizeof(GDIINFO)); ! 254: ! 255: memcpy(pdevcaps, &gaulCap, cjGdiInfo); ! 256: ! 257: // Now let's pass back the devinfo ! 258: ! 259: devinfoVGA.hpalDefault = EngCreatePalette(PAL_INDEXED, 16, ! 260: (PULONG) (logPalVGA.palPalEntry), ! 261: 0, 0, 0); ! 262: ! 263: // *pdevinfo = devinfoVGA; ! 264: memcpy((PVOID) pdevinfo, (PVOID) &devinfoVGA, (ULONG) sizeof(DEVINFO)); ! 265: ! 266: // Try to preallocate a saved screen bits buffer. If we fail, set the flag ! 267: // to indicate the buffer is in use, so that we'll never attempt to use it. ! 268: // If we succeed, mark the buffer as free. ! 269: ! 270: if ((ppdev->pjPreallocSSBBuffer = (PUCHAR) ! 271: LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, PREALLOC_SSB_SIZE)) ! 272: != NULL) { ! 273: ppdev->flPreallocSSBBufferInUse = FALSE; ! 274: ppdev->ulPreallocSSBSize = PREALLOC_SSB_SIZE; ! 275: } else { ! 276: ppdev->flPreallocSSBBufferInUse = TRUE; ! 277: } ! 278: ! 279: // Fill in the DIB4->VGA conversion tables. Allow 256 extra bytes so that ! 280: // we can always safely align the tables to a 256-byte boundary, for ! 281: // look-up reasons. There are four tables, each 256 bytes long ! 282: ! 283: ppdev->pucDIB4ToVGAConvBuffer = ! 284: (UCHAR *) LocalAlloc((LMEM_FIXED | LMEM_ZEROINIT), ! 285: ((256*4+256)*sizeof(UCHAR))); ! 286: ! 287: if (ppdev->pucDIB4ToVGAConvBuffer == NULL) { ! 288: goto error; ! 289: } ! 290: ! 291: // Round the table start up to the nearest 256 byte boundary, because the ! 292: // tables must start on 256-byte boundaries for look-up reasons ! 293: ! 294: ppdev->pucDIB4ToVGAConvTables = ! 295: (UCHAR *) ((ULONG) (ppdev->pucDIB4ToVGAConvBuffer + 0xFF) & ~0xFF); ! 296: ! 297: vSetDIB4ToVGATables(ppdev->pucDIB4ToVGAConvTables); ! 298: ! 299: return(dhpdev); ! 300: ! 301: error: ! 302: if (fl & PDEV_ALLOCED) ! 303: LocalFree(dhpdev); ! 304: ! 305: return((DHPDEV) 0); ! 306: ! 307: UNREFERENCED_PARAMETER(cb); ! 308: UNREFERENCED_PARAMETER(pwszLogAddress); ! 309: UNREFERENCED_PARAMETER(pwszDataFile); ! 310: UNREFERENCED_PARAMETER(pwszDeviceName); ! 311: } ! 312: ! 313: /******************************Public*Routine******************************\ ! 314: * BOOL bCompletePDEV(dhpdev, hpdev) ! 315: * ! 316: * Complete the initialization of the PDEV ! 317: * ! 318: \**************************************************************************/ ! 319: ! 320: VOID DrvCompletePDEV( ! 321: DHPDEV dhpdev, ! 322: HDEV hdev) ! 323: { ! 324: PPDEV ppdev; ! 325: ! 326: ppdev = (PPDEV) dhpdev; ! 327: ! 328: ppdev->hdevEng = hdev; ! 329: } ! 330: ! 331: /******************************Public*Routine******************************\ ! 332: * VOID vFreeResources(ppdev) ! 333: * ! 334: * Free the resources used by the PDEV ! 335: * ! 336: * Effects: ! 337: * ! 338: * Warnings: ! 339: * ! 340: \**************************************************************************/ ! 341: ! 342: VOID vFreeResources(PPDEV ppdev) ! 343: { ! 344: ! 345: UNREFERENCED_PARAMETER(ppdev); ! 346: } ! 347: ! 348: /******************************Public*Routine******************************\ ! 349: * VOID vKillPatterns(ppdev) ! 350: * ! 351: * Clear the standard patterns ! 352: * ! 353: \**************************************************************************/ ! 354: ! 355: VOID vKillPatterns(PPDEV ppdev) ! 356: { ! 357: INT ii; ! 358: ! 359: for (ii = 0; ii < HS_DDI_MAX; ii++) ! 360: EngDeleteSurface((HSURF) ppdev->ahbmPat[ii]); ! 361: } ! 362: ! 363: /******************************Public*Routine******************************\ ! 364: * VOID DrvDisablePDEV(dhpdev) ! 365: * ! 366: * Shutdown this physical device. ! 367: * ! 368: * Warnings: ! 369: * If a surface is still active for this PDEV it will be freed. ! 370: * ! 371: ! 372: \**************************************************************************/ ! 373: ! 374: VOID DrvDisablePDEV(DHPDEV dhpdev) ! 375: { ! 376: PPDEV ppdev; ! 377: ! 378: ppdev = (PPDEV) dhpdev; ! 379: ! 380: DISPDBG((2, "VGA:disabling PDEV\n")); ! 381: ! 382: // ASSERT(ppdev != (PPDEV) NULL, "PDEV error"); ! 383: ! 384: // Is there a deliquent surface still in the PDEV? ! 385: ! 386: if (ppdev->hsurfEng != (HSURF) 0) ! 387: DrvDisableSurface(dhpdev); ! 388: ! 389: // Check if the Engine has called us to many times. ! 390: ! 391: // ASSERT(--cPDEV >= 0, "PDEV - too many disables"); ! 392: ! 393: // Free the resources and bitmaps associated with this PDEV ! 394: ! 395: vFreeResources(ppdev); ! 396: vKillPatterns(ppdev); ! 397: ! 398: // Free the preallocated saved screen bits buffer, if there is one. ! 399: ! 400: if (ppdev->pjPreallocSSBBuffer != NULL) { ! 401: LocalFree(ppdev->pjPreallocSSBBuffer); ! 402: } ! 403: ! 404: // Free the conversion table buffer ! 405: ! 406: if (ppdev->pucDIB4ToVGAConvBuffer != NULL) { ! 407: LocalFree(ppdev->pucDIB4ToVGAConvBuffer); ! 408: } ! 409: ! 410: // Delete the PDEV ! 411: ! 412: LocalFree(dhpdev); ! 413: ! 414: DISPDBG((2, "VGA: disabled PDEV\n")); ! 415: ! 416: #ifdef DRV_ONE_PDEV ! 417: gflDrv &= ~DRV_ENABLED_PDEV; ! 418: #endif ! 419: } ! 420: ! 421: /******************************Public*Routine******************************\ ! 422: * HSURF DrvEnableSurface(dhpdev) ! 423: * ! 424: * Enable the surface for the device. This will actually intialize the ! 425: * screen on the VGA. ! 426: * ! 427: * Warnings: ! 428: * This routine should only be called ONCE per PDEV. ! 429: * ! 430: \**************************************************************************/ ! 431: ! 432: HSURF DrvEnableSurface(DHPDEV dhpdev) ! 433: { ! 434: PPDEV ppdev; ! 435: PDEVSURF pdsurf; ! 436: DHSURF dhsurf; ! 437: HSURF hsurf; ! 438: ! 439: DISPDBG((2, "VGA:enabling Surface\n")); ! 440: ! 441: ppdev = (PPDEV) dhpdev; ! 442: ! 443: // ! 444: // Initialize the VGA device into the selected mode which will also map ! 445: // the video frame buffer ! 446: // ! 447: ! 448: if (!bInitVGA(ppdev, TRUE)) ! 449: { ! 450: goto error_done; ! 451: } ! 452: ! 453: dhsurf = (DHSURF) LocalAlloc(LMEM_FIXED, (SIZE_T) sizeof(DEVSURF)); ! 454: ! 455: if (dhsurf == (DHSURF) 0) ! 456: goto error_done; ! 457: ! 458: pdsurf = (PDEVSURF) dhsurf; ! 459: ! 460: pdsurf->ident = DEVSURF_IDENT; ! 461: pdsurf->flSurf = 0; ! 462: pdsurf->iFormat = BMF_PHYSDEVICE; ! 463: pdsurf->jReserved1 = 0; ! 464: pdsurf->jReserved2 = 0; ! 465: pdsurf->ppdev = ppdev; ! 466: pdsurf->sizlSurf.cx = ppdev->sizlSurf.cx; ! 467: pdsurf->sizlSurf.cy = ppdev->sizlSurf.cy; ! 468: pdsurf->lNextPlane = 0; ! 469: pdsurf->pvScan0 = ppdev->pjScreen; ! 470: pdsurf->pvBitmapStart = ppdev->pjScreen; ! 471: pdsurf->pvStart = ppdev->pjScreen; ! 472: pdsurf->pvConv = &ajConvertBuffer[0]; ! 473: ! 474: if (!bInitPointer(ppdev)) { ! 475: DISPDBG((0, "VGA DrvEnablePDEV failed bInitPointer\n")); ! 476: goto error_clean; ! 477: } ! 478: ! 479: if (!SetUpBanking(pdsurf, ppdev)) { ! 480: DISPDBG((0, "VGA DrvEnablePDEV failed SetUpBanking\n")); ! 481: goto error_clean; ! 482: } ! 483: ! 484: // Initialize pointer information. ! 485: ! 486: if ((hsurf = EngCreateSurface(dhsurf, ppdev->sizlSurf)) == (HSURF) 0) ! 487: { ! 488: DISPDBG((0, "VGA DrvEnablePDEV failed EngCreateSurface\n")); ! 489: goto error_clean; ! 490: } ! 491: ! 492: if (EngAssociateSurface(hsurf, ppdev->hdevEng, ! 493: HOOK_BITBLT | HOOK_TEXTOUT | HOOK_STROKEPATH | ! 494: HOOK_COPYBITS | HOOK_PAINT | HOOK_FILLPATH)) ! 495: { ! 496: ppdev->hsurfEng = hsurf; ! 497: ppdev->pdsurf = pdsurf; ! 498: ! 499: // Set up an empty saved screen block list ! 500: pdsurf->ssbList = NULL; ! 501: // Initialize the offscreen adapter memory heap to currently all ! 502: // available ! 503: // Beginning of heap starts right after the displayed bitmap ends ! 504: pdsurf->pjAdapterHeapStart = ((PBYTE)pdsurf->pvBitmapStart) + ! 505: (pdsurf->lNextScan * pdsurf->sizlSurf.cy); ! 506: ! 507: // End of heap is the start of either the pointer work area or the ! 508: // hardware pointer reserved memory area, whichever comes first ! 509: pdsurf->pjAdapterHeapEnd = pPtrSave; ! 510: if (ppdev->pPointerAttributes != NULL) ! 511: { ! 512: // There's a hardware pointer, so check what display memory it ! 513: // uses, if any ! 514: if (ppdev->PointerCapabilities.HWPtrBitmapStart != -1) ! 515: { ! 516: // The hardware pointer does use display memory ! 517: if (( ((PBYTE)pdsurf->pvBitmapStart) + ! 518: ppdev->PointerCapabilities.HWPtrBitmapStart) < ! 519: pdsurf->pjAdapterHeapEnd) ! 520: { ! 521: // The hardware pointer marks the end of the heap ! 522: pdsurf->pjAdapterHeapEnd = ((PBYTE)pdsurf->pvBitmapStart) + ! 523: ppdev->PointerCapabilities.HWPtrBitmapStart; ! 524: } ! 525: } ! 526: } ! 527: ! 528: // The current top of the heap is the end of the heap, because the heap ! 529: // is empty ! 530: pdsurf->pjAdapterHeapTop = pdsurf->pjAdapterHeapEnd; ! 531: ! 532: DISPDBG((2, "VGA: enabled surface\n")); ! 533: ! 534: return(hsurf); ! 535: ! 536: } ! 537: ! 538: DISPDBG((0, "VGA DrvEnablePDEV failed EngDeleteSurface\n")); ! 539: EngDeleteSurface(hsurf); ! 540: ! 541: error_clean: ! 542: // We created the surface, so delete it ! 543: LocalFree(dhsurf); ! 544: ! 545: error_done: ! 546: return((HSURF) 0); ! 547: } ! 548: ! 549: ! 550: /******************************Public*Routine******************************\ ! 551: * DrvDisableSurface ! 552: * ! 553: * Free resources associated with this surface. ! 554: * ! 555: \**************************************************************************/ ! 556: ! 557: VOID DrvDisableSurface(DHPDEV dhpdev) ! 558: { ! 559: PPDEV ppdev = (PPDEV) dhpdev; ! 560: PDEVSURF pdsurf = ppdev->pdsurf; ! 561: PSAVED_SCREEN_BITS pSSB, pSSBNext; ! 562: ! 563: DISPDBG((2, "VGA:disabling surface\n")); ! 564: ! 565: // Free up banking-related stuff. ! 566: LocalFree(pdsurf->pBankSelectInfo); ! 567: ! 568: if (pdsurf->pbiBankInfo != NULL) { ! 569: LocalFree(pdsurf->pbiBankInfo); ! 570: } ! 571: ! 572: if (pdsurf->pbiBankInfo2RW != NULL) { ! 573: LocalFree(pdsurf->pbiBankInfo2RW); ! 574: } ! 575: ! 576: if (pdsurf->pvBankBufferPlane0 != NULL) { ! 577: LocalFree(pdsurf->pvBankBufferPlane0); ! 578: } ! 579: ! 580: if (ppdev->pPointerAttributes != NULL) { ! 581: LocalFree(ppdev->pPointerAttributes); ! 582: } ! 583: ! 584: // Free any pending saved screen bit blocks. ! 585: pSSB = pdsurf->ssbList; ! 586: while (pSSB != (PSAVED_SCREEN_BITS) NULL) { ! 587: // Point to the next saved screen bits block ! 588: pSSBNext = (PSAVED_SCREEN_BITS) pSSB->pvNextSSB; ! 589: // Free the current block ! 590: LocalFree(pSSB); ! 591: pSSB = pSSBNext; ! 592: } ! 593: ! 594: EngDeleteSurface((HSURF) ppdev->hsurfEng); ! 595: ! 596: LocalFree(pdsurf); // free the surface ! 597: ! 598: DISPDBG((2, "VGA:disabled surface\n")); ! 599: ! 600: } ! 601: ! 602: /******************************Public*Routine******************************\ ! 603: * DrvAssertMode ! 604: * ! 605: * Ping the device back into its last known mode ! 606: * ! 607: \**************************************************************************/ ! 608: ! 609: VOID DrvAssertMode(DHPDEV dhpdev, BOOL Enable) ! 610: { ! 611: PPDEV ppdev = (PPDEV) dhpdev; ! 612: ULONG returnedDataLength; ! 613: ! 614: DISPDBG((2, "VGA: DrvAssertMode\n")); ! 615: ! 616: if (Enable) { ! 617: ! 618: // ! 619: // The screen must be reenabled since we had gone to full screen. ! 620: // Re-initialize the device. ! 621: // !!! BUGBUG what happens if this fails ?? ! 622: // ! 623: ! 624: bInitVGA(ppdev, FALSE); ! 625: ! 626: vForceBank0(ppdev); ! 627: ! 628: } else { ! 629: ! 630: // ! 631: // We must give up the display. ! 632: // Call the kernel driver to reset the device to a known state. ! 633: // ! 634: ! 635: if (!DeviceIoControl(ppdev->hDriver, ! 636: IOCTL_VIDEO_RESET_DEVICE, ! 637: NULL, ! 638: 0, ! 639: NULL, ! 640: 0, ! 641: &returnedDataLength, ! 642: NULL)) { ! 643: ! 644: RIP("VGA.DLL: Reset Device Failed"); ! 645: ! 646: } ! 647: } ! 648: ! 649: return; ! 650: } ! 651: ! 652: /******************************Public*Routine******************************\ ! 653: * DrvGetModes ! 654: * ! 655: * Returns the list of available modes for the device. ! 656: * ! 657: \**************************************************************************/ ! 658: ! 659: ULONG DrvGetModes( ! 660: HANDLE hDriver, ! 661: ULONG cjSize, ! 662: DEVMODEW *pdm) ! 663: ! 664: { ! 665: ! 666: DWORD cModes; ! 667: DWORD cbOutputSize; ! 668: PVIDEO_MODE_INFORMATION pVideoModeInformation, pVideoTemp; ! 669: DWORD cOutputModes = cjSize / (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE); ! 670: DWORD cbModeSize; ! 671: ! 672: DISPDBG((2, "Vga.dll:DrvGetModes\n")); ! 673: ! 674: cModes = getAvailableModes(hDriver, ! 675: (PVIDEO_MODE_INFORMATION *) &pVideoModeInformation, ! 676: &cbModeSize); ! 677: ! 678: if (cModes == 0) ! 679: { ! 680: DISPDBG((0, "VGA DISP DrvGetModes failed to get mode information")); ! 681: return 0; ! 682: } ! 683: ! 684: if (pdm == NULL) ! 685: { ! 686: cbOutputSize = cModes * (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE); ! 687: } ! 688: else ! 689: { ! 690: // ! 691: // Now copy the information for the supported modes back into the output ! 692: // buffer ! 693: // ! 694: ! 695: cbOutputSize = 0; ! 696: ! 697: pVideoTemp = pVideoModeInformation; ! 698: ! 699: do ! 700: { ! 701: if (pVideoTemp->Length != 0) ! 702: { ! 703: if (cOutputModes == 0) ! 704: { ! 705: break; ! 706: } ! 707: ! 708: // ! 709: // Zero the entire structure to start off with. ! 710: // ! 711: ! 712: memset(pdm, 0, sizeof(DEVMODEW)); ! 713: ! 714: // ! 715: // Set the name of the device to the name of the DLL. ! 716: // ! 717: ! 718: memcpy(&(pdm->dmDeviceName), L"vga", sizeof(L"vga")); ! 719: ! 720: pdm->dmSpecVersion = DM_SPECVERSION; ! 721: pdm->dmDriverVersion = DM_SPECVERSION; ! 722: ! 723: // ! 724: // We currently do not support Extra information in the driver ! 725: // ! 726: ! 727: pdm->dmDriverExtra = DRIVER_EXTRA_SIZE; ! 728: ! 729: pdm->dmSize = sizeof(DEVMODEW); ! 730: pdm->dmBitsPerPel = pVideoTemp->NumberOfPlanes * ! 731: pVideoTemp->BitsPerPlane; ! 732: pdm->dmPelsWidth = pVideoTemp->VisScreenWidth; ! 733: pdm->dmPelsHeight = pVideoTemp->VisScreenHeight; ! 734: pdm->dmDisplayFrequency = pVideoTemp->Frequency; ! 735: ! 736: if (pVideoTemp->AttributeFlags & VIDEO_MODE_INTERLACED) ! 737: { ! 738: pdm->dmDisplayFlags |= DM_INTERLACED; ! 739: } ! 740: ! 741: // ! 742: // Go to the next DEVMODE entry in the buffer. ! 743: // ! 744: ! 745: cOutputModes--; ! 746: ! 747: pdm = (LPDEVMODEW) ( ((ULONG)pdm) + sizeof(DEVMODEW) + ! 748: DRIVER_EXTRA_SIZE); ! 749: ! 750: cbOutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE); ! 751: ! 752: } ! 753: ! 754: pVideoTemp = (PVIDEO_MODE_INFORMATION) ! 755: (((PUCHAR)pVideoTemp) + cbModeSize); ! 756: ! 757: } while (--cModes); ! 758: } ! 759: ! 760: LocalFree(pVideoModeInformation); ! 761: ! 762: return cbOutputSize; ! 763: ! 764: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.