|
|
1.1 ! root 1: /*++ ! 2: ! 3: Copyright (c) 1992 Microsoft Corporation ! 4: ! 5: Module Name: ! 6: ! 7: modeset.c ! 8: ! 9: Abstract: ! 10: ! 11: This is the modeset code for the CL6410/20 miniport driver. ! 12: ! 13: Environment: ! 14: ! 15: kernel mode only ! 16: ! 17: Notes: ! 18: ! 19: Revision History: ! 20: ! 21: --*/ ! 22: #include "dderror.h" ! 23: #include "devioctl.h" ! 24: #include "miniport.h" ! 25: ! 26: #include "ntddvdeo.h" ! 27: #include "video.h" ! 28: #include "cirrus.h" ! 29: #include "modeset.h" ! 30: ! 31: VOID ! 32: VgaZeroVideoMemory( ! 33: PHW_DEVICE_EXTENSION HwDeviceExtension ! 34: ); ! 35: ! 36: ! 37: // the following is defined in cirrus.c ! 38: VOID ! 39: SetCirrusBanking( ! 40: PHW_DEVICE_EXTENSION HwDeviceExtension, ! 41: ULONG BankNumber ! 42: ); ! 43: ! 44: //--------------------------------------------------------------------------- ! 45: VP_STATUS ! 46: VgaInterpretCmdStream( ! 47: PHW_DEVICE_EXTENSION HwDeviceExtension, ! 48: PUSHORT pusCmdStream ! 49: ) ! 50: ! 51: /*++ ! 52: ! 53: Routine Description: ! 54: ! 55: Interprets the appropriate command array to set up VGA registers for the ! 56: requested mode. Typically used to set the VGA into a particular mode by ! 57: programming all of the registers ! 58: ! 59: Arguments: ! 60: ! 61: HwDeviceExtension - Pointer to the miniport driver's device extension. ! 62: ! 63: pusCmdStream - array of commands to be interpreted. ! 64: ! 65: Return Value: ! 66: ! 67: The status of the operation (can only fail on a bad command); TRUE for ! 68: success, FALSE for failure. ! 69: ! 70: --*/ ! 71: ! 72: { ! 73: ULONG ulCmd; ! 74: ULONG ulPort; ! 75: UCHAR jValue; ! 76: USHORT usValue; ! 77: ULONG culCount; ! 78: ULONG ulIndex; ! 79: ULONG ulBase; ! 80: ! 81: if (pusCmdStream == NULL) { ! 82: ! 83: VideoDebugPrint((1, "VgaInterpretCmdStream - Invalid pusCmdStream\n")); ! 84: return TRUE; ! 85: } ! 86: ! 87: ulBase = (ULONG)HwDeviceExtension->IOAddress; ! 88: ! 89: // ! 90: // Now set the adapter to the desired mode. ! 91: // ! 92: ! 93: while ((ulCmd = *pusCmdStream++) != EOD) { ! 94: ! 95: // ! 96: // Determine major command type ! 97: // ! 98: ! 99: switch (ulCmd & 0xF0) { ! 100: ! 101: // ! 102: // Basic input/output command ! 103: // ! 104: ! 105: case INOUT: ! 106: ! 107: // ! 108: // Determine type of inout instruction ! 109: // ! 110: ! 111: if (!(ulCmd & IO)) { ! 112: ! 113: // ! 114: // Out instruction. Single or multiple outs? ! 115: // ! 116: ! 117: if (!(ulCmd & MULTI)) { ! 118: ! 119: // ! 120: // Single out. Byte or word out? ! 121: // ! 122: ! 123: if (!(ulCmd & BW)) { ! 124: ! 125: // ! 126: // Single byte out ! 127: // ! 128: ! 129: ulPort = *pusCmdStream++; ! 130: jValue = (UCHAR) *pusCmdStream++; ! 131: VideoPortWritePortUchar((PUCHAR)(ulBase+ulPort), ! 132: jValue); ! 133: ! 134: } else { ! 135: ! 136: // ! 137: // Single word out ! 138: // ! 139: ! 140: ulPort = *pusCmdStream++; ! 141: usValue = *pusCmdStream++; ! 142: VideoPortWritePortUshort((PUSHORT)(ulBase+ulPort), ! 143: usValue); ! 144: ! 145: } ! 146: ! 147: } else { ! 148: ! 149: // ! 150: // Output a string of values ! 151: // Byte or word outs? ! 152: // ! 153: ! 154: if (!(ulCmd & BW)) { ! 155: ! 156: // ! 157: // String byte outs. Do in a loop; can't use ! 158: // VideoPortWritePortBufferUchar because the data ! 159: // is in USHORT form ! 160: // ! 161: ! 162: ulPort = ulBase + *pusCmdStream++; ! 163: culCount = *pusCmdStream++; ! 164: ! 165: while (culCount--) { ! 166: jValue = (UCHAR) *pusCmdStream++; ! 167: VideoPortWritePortUchar((PUCHAR)ulPort, ! 168: jValue); ! 169: ! 170: } ! 171: ! 172: } else { ! 173: ! 174: // ! 175: // String word outs ! 176: // ! 177: ! 178: ulPort = *pusCmdStream++; ! 179: culCount = *pusCmdStream++; ! 180: VideoPortWritePortBufferUshort((PUSHORT) ! 181: (ulBase + ulPort), pusCmdStream, culCount); ! 182: pusCmdStream += culCount; ! 183: ! 184: } ! 185: } ! 186: ! 187: } else { ! 188: ! 189: // In instruction ! 190: // ! 191: // Currently, string in instructions aren't supported; all ! 192: // in instructions are handled as single-byte ins ! 193: // ! 194: // Byte or word in? ! 195: // ! 196: ! 197: if (!(ulCmd & BW)) { ! 198: // ! 199: // Single byte in ! 200: // ! 201: ! 202: ulPort = *pusCmdStream++; ! 203: jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort); ! 204: ! 205: } else { ! 206: ! 207: // ! 208: // Single word in ! 209: // ! 210: ! 211: ulPort = *pusCmdStream++; ! 212: usValue = VideoPortReadPortUshort((PUSHORT) ! 213: (ulBase+ulPort)); ! 214: ! 215: } ! 216: ! 217: } ! 218: ! 219: break; ! 220: ! 221: // ! 222: // Higher-level input/output commands ! 223: // ! 224: ! 225: case METAOUT: ! 226: ! 227: // ! 228: // Determine type of metaout command, based on minor ! 229: // command field ! 230: // ! 231: switch (ulCmd & 0x0F) { ! 232: ! 233: // ! 234: // Indexed outs ! 235: // ! 236: ! 237: case INDXOUT: ! 238: ! 239: ulPort = ulBase + *pusCmdStream++; ! 240: culCount = *pusCmdStream++; ! 241: ulIndex = *pusCmdStream++; ! 242: ! 243: while (culCount--) { ! 244: ! 245: usValue = (USHORT) (ulIndex + ! 246: (((ULONG)(*pusCmdStream++)) << 8)); ! 247: VideoPortWritePortUshort((PUSHORT)ulPort, usValue); ! 248: ! 249: ulIndex++; ! 250: ! 251: } ! 252: ! 253: break; ! 254: ! 255: // ! 256: // Masked out (read, AND, XOR, write) ! 257: // ! 258: ! 259: case MASKOUT: ! 260: ! 261: ulPort = *pusCmdStream++; ! 262: jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort); ! 263: jValue &= *pusCmdStream++; ! 264: jValue ^= *pusCmdStream++; ! 265: VideoPortWritePortUchar((PUCHAR)ulBase + ulPort, ! 266: jValue); ! 267: break; ! 268: ! 269: // ! 270: // Attribute Controller out ! 271: // ! 272: ! 273: case ATCOUT: ! 274: ! 275: ulPort = ulBase + *pusCmdStream++; ! 276: culCount = *pusCmdStream++; ! 277: ulIndex = *pusCmdStream++; ! 278: ! 279: while (culCount--) { ! 280: ! 281: // Write Attribute Controller index ! 282: VideoPortWritePortUchar((PUCHAR)ulPort, ! 283: (UCHAR)ulIndex); ! 284: ! 285: // Write Attribute Controller data ! 286: jValue = (UCHAR) *pusCmdStream++; ! 287: VideoPortWritePortUchar((PUCHAR)ulPort, jValue); ! 288: ! 289: ulIndex++; ! 290: ! 291: } ! 292: ! 293: break; ! 294: ! 295: // ! 296: // None of the above; error ! 297: // ! 298: default: ! 299: ! 300: return FALSE; ! 301: ! 302: } ! 303: ! 304: ! 305: break; ! 306: ! 307: // ! 308: // NOP ! 309: // ! 310: ! 311: case NCMD: ! 312: ! 313: break; ! 314: ! 315: // ! 316: // Unknown command; error ! 317: // ! 318: ! 319: default: ! 320: ! 321: return FALSE; ! 322: ! 323: } ! 324: ! 325: } ! 326: ! 327: return TRUE; ! 328: ! 329: } // end VgaInterpretCmdStream() ! 330: ! 331: ! 332: VP_STATUS ! 333: VgaSetMode( ! 334: PHW_DEVICE_EXTENSION HwDeviceExtension, ! 335: PVIDEO_MODE Mode, ! 336: ULONG ModeSize ! 337: ) ! 338: ! 339: /*++ ! 340: ! 341: Routine Description: ! 342: ! 343: This routine sets the vga into the requested mode. ! 344: ! 345: Arguments: ! 346: ! 347: HwDeviceExtension - Pointer to the miniport driver's device extension. ! 348: ! 349: Mode - Pointer to the structure containing the information about the ! 350: font to be set. ! 351: ! 352: ModeSize - Length of the input buffer supplied by the user. ! 353: ! 354: Return Value: ! 355: ! 356: ERROR_INSUFFICIENT_BUFFER if the input buffer was not large enough ! 357: for the input data. ! 358: ! 359: ERROR_INVALID_PARAMETER if the mode number is invalid. ! 360: ! 361: NO_ERROR if the operation completed successfully. ! 362: ! 363: --*/ ! 364: ! 365: { ! 366: ! 367: PVIDEOMODE pRequestedMode; ! 368: PUSHORT pusCmdStream; ! 369: VP_STATUS status; ! 370: #ifdef INT10_MODE_SET ! 371: VIDEO_X86_BIOS_ARGUMENTS biosArguments; ! 372: #endif ! 373: ! 374: ! 375: // ! 376: // Check if the size of the data in the input buffer is large enough. ! 377: // ! 378: ! 379: if (ModeSize < sizeof(VIDEO_MODE)) { ! 380: ! 381: return ERROR_INSUFFICIENT_BUFFER; ! 382: ! 383: } ! 384: ! 385: // ! 386: // Extract the clear memory bit. ! 387: // ! 388: ! 389: if (Mode->RequestedMode & VIDEO_MODE_NO_ZERO_MEMORY) { ! 390: ! 391: Mode->RequestedMode &= ~VIDEO_MODE_NO_ZERO_MEMORY; ! 392: ! 393: } else { ! 394: ! 395: VgaZeroVideoMemory(HwDeviceExtension); ! 396: ! 397: } ! 398: ! 399: // ! 400: // Check to see if we are requesting a valid mode ! 401: // ! 402: ! 403: if ( (Mode->RequestedMode >= NumVideoModes) || ! 404: (!ModesVGA[Mode->RequestedMode].ValidMode) ) { ! 405: ! 406: return ERROR_INVALID_PARAMETER; ! 407: ! 408: } ! 409: ! 410: pRequestedMode = &ModesVGA[Mode->RequestedMode]; ! 411: ! 412: #ifdef INT10_MODE_SET ! 413: ! 414: VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS)); ! 415: ! 416: // ! 417: // first, set the montype, if valid ! 418: // ! 419: ! 420: if (pRequestedMode->MonitorType) { ! 421: ! 422: biosArguments.Eax = 0x1200 | pRequestedMode->MonitorType; ! 423: biosArguments.Ebx = 0xA2; // set monitor type command ! 424: status = VideoPortInt10(HwDeviceExtension, &biosArguments); ! 425: ! 426: if (status != NO_ERROR) { ! 427: ! 428: return status; ! 429: ! 430: } ! 431: ! 432: // ! 433: // for 640x480 modes, determine the refresh type ! 434: // ! 435: ! 436: if (pRequestedMode->hres == 640) { ! 437: ! 438: if (pRequestedMode->Frequency == 72) { // 72 hz refresh ! 439: ! 440: // this high refresh setup only takes effect in 640x480 ! 441: ! 442: biosArguments.Eax = 0x1201; // enable HIGH refresh ! 443: biosArguments.Ebx = 0xA3; // set refresh type ! 444: ! 445: status = VideoPortInt10(HwDeviceExtension, &biosArguments); ! 446: ! 447: } else { ! 448: ! 449: // set low refresh rate ! 450: ! 451: biosArguments.Eax = 0x1200; // enable LOW refresh, 640x480 only ! 452: biosArguments.Ebx = 0xA3; // set refresh type ! 453: ! 454: status = VideoPortInt10(HwDeviceExtension, &biosArguments); ! 455: ! 456: } // endif Monitor == 4 ! 457: ! 458: } ! 459: ! 460: if (status != NO_ERROR) { ! 461: ! 462: return status; ! 463: ! 464: } ! 465: ! 466: } ! 467: ! 468: VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS)); ! 469: ! 470: // ! 471: // then, set the mode ! 472: // ! 473: ! 474: switch (HwDeviceExtension->ChipType) { ! 475: ! 476: case CL6410: ! 477: ! 478: biosArguments.Eax = pRequestedMode->BiosModes.BiosModeCL6410; ! 479: break; ! 480: ! 481: case CL6420: ! 482: ! 483: biosArguments.Eax = pRequestedMode->BiosModes.BiosModeCL6420; ! 484: break; ! 485: ! 486: case CL542x: ! 487: ! 488: biosArguments.Eax = pRequestedMode->BiosModes.BiosModeCL542x; ! 489: break; ! 490: ! 491: } ! 492: ! 493: status = VideoPortInt10(HwDeviceExtension, &biosArguments); ! 494: ! 495: // ! 496: // thhis code fixes a bug for color TFT panels only ! 497: // when on the 6420 and in 640x480 8bpp only ! 498: // ! 499: ! 500: if ( (HwDeviceExtension->ChipType == CL6420) && ! 501: (pRequestedMode->bitsPerPlane == 8) && ! 502: (pRequestedMode->hres == 640) ) { ! 503: ! 504: VideoPortWritePortUchar(HwDeviceExtension->IOAddress + ! 505: GRAPH_ADDRESS_PORT, 0xDC); // color LCD config reg. ! 506: ! 507: if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress + ! 508: GRAPH_DATA_PORT) & 01) { // if TFT panel ! 509: ! 510: VideoPortWritePortUchar(HwDeviceExtension->IOAddress + ! 511: GRAPH_ADDRESS_PORT, 0xD6); // greyscale offset LCD reg. ! 512: ! 513: VideoPortWritePortUchar(HwDeviceExtension->IOAddress + ! 514: GRAPH_DATA_PORT, ! 515: ! 516: (UCHAR)((VideoPortReadPortUchar(HwDeviceExtension->IOAddress + ! 517: GRAPH_DATA_PORT) & 0x3f) | 0x40)); ! 518: ! 519: } ! 520: } ! 521: ! 522: #endif ! 523: ! 524: // ! 525: // Select proper command array for adapter type ! 526: // ! 527: ! 528: switch (HwDeviceExtension->ChipType) { ! 529: ! 530: case CL6410: ! 531: ! 532: VideoDebugPrint((1, "VgaSetMode - Setting mode for 6410\n")); ! 533: if (HwDeviceExtension->DisplayType == crt) ! 534: pusCmdStream = pRequestedMode->CmdStrings.pCL6410_crt; ! 535: else ! 536: pusCmdStream = pRequestedMode->CmdStrings.pCL6410_panel; ! 537: break; ! 538: ! 539: case CL6420: ! 540: VideoDebugPrint((1, "VgaSetMode - Setting mode for 6420\n")); ! 541: if (HwDeviceExtension->DisplayType == crt) ! 542: pusCmdStream = pRequestedMode->CmdStrings.pCL6420_crt; ! 543: else ! 544: pusCmdStream = pRequestedMode->CmdStrings.pCL6420_panel; ! 545: break; ! 546: ! 547: case CL542x: ! 548: VideoDebugPrint((1, "VgaSetMode - Setting mode for 542x\n")); ! 549: pusCmdStream = pRequestedMode->CmdStrings.pCL542x; ! 550: break; ! 551: ! 552: default: ! 553: return ERROR_INVALID_PARAMETER; ! 554: } ! 555: ! 556: VgaInterpretCmdStream(HwDeviceExtension, pusCmdStream); ! 557: ! 558: // ! 559: // Support 256 color modes by stretching the scan lines. ! 560: // ! 561: ! 562: if (pRequestedMode->CmdStrings.pStretchScan) { ! 563: ! 564: VgaInterpretCmdStream(HwDeviceExtension, ! 565: pRequestedMode->CmdStrings.pStretchScan); ! 566: ! 567: } ! 568: ! 569: #ifdef INT10_MODE_SET ! 570: { ! 571: UCHAR temp; ! 572: UCHAR dummy; ! 573: UCHAR bIsColor; ! 574: ! 575: if (!(pRequestedMode->fbType & VIDEO_MODE_GRAPHICS)) { ! 576: ! 577: // ! 578: // Fix to make sure we always set the colors in text mode to be ! 579: // intensity, and not flashing ! 580: // For this zero out the Mode Control Regsiter bit 3 (index 0x10 ! 581: // of the Attribute controller). ! 582: // ! 583: ! 584: if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress + ! 585: MISC_OUTPUT_REG_READ_PORT) & 0x01) { ! 586: ! 587: bIsColor = TRUE; ! 588: ! 589: } else { ! 590: ! 591: bIsColor = FALSE; ! 592: ! 593: } ! 594: ! 595: if (bIsColor) { ! 596: ! 597: dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + ! 598: INPUT_STATUS_1_COLOR); ! 599: } else { ! 600: ! 601: dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + ! 602: INPUT_STATUS_1_MONO); ! 603: } ! 604: ! 605: VideoPortWritePortUchar(HwDeviceExtension->IOAddress + ! 606: ATT_ADDRESS_PORT, (0x10 | VIDEO_ENABLE)); ! 607: temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + ! 608: ATT_DATA_READ_PORT); ! 609: ! 610: temp &= 0xF7; ! 611: ! 612: if (bIsColor) { ! 613: ! 614: dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + ! 615: INPUT_STATUS_1_COLOR); ! 616: } else { ! 617: ! 618: dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + ! 619: INPUT_STATUS_1_MONO); ! 620: } ! 621: ! 622: VideoPortWritePortUchar(HwDeviceExtension->IOAddress + ! 623: ATT_ADDRESS_PORT, (0x10 | VIDEO_ENABLE)); ! 624: VideoPortWritePortUchar(HwDeviceExtension->IOAddress + ! 625: ATT_DATA_WRITE_PORT, temp); ! 626: } ! 627: } ! 628: #else ! 629: ! 630: // ! 631: // if 6410 rev. AB, then fix CR13 in hires mode ! 632: // ! 633: ! 634: if ( (HwDeviceExtension->ChipType == CL6420) && ! 635: (HwDeviceExtension->ChipRevision >= 0x7e) && ! 636: (HwDeviceExtension->DisplayType == crt) && ! 637: (pRequestedMode->hres == 1024) ) { ! 638: ! 639: VideoPortWritePortUchar(HwDeviceExtension->IOAddress + ! 640: CRTC_ADDRESS_PORT_COLOR, 0x13); ! 641: VideoPortWritePortUchar(HwDeviceExtension->IOAddress + ! 642: CRTC_DATA_PORT_COLOR, ! 643: (UCHAR)(VideoPortReadPortUchar(HwDeviceExtension->IOAddress + ! 644: CRTC_DATA_PORT_COLOR) + 0x01)); ! 645: ! 646: } ! 647: ! 648: #endif ! 649: ! 650: // ! 651: // Update the location of the physical frame buffer within video memory. ! 652: // ! 653: ! 654: HwDeviceExtension->PhysicalFrameLength = ! 655: MemoryMaps[pRequestedMode->MemMap].MaxSize; ! 656: ! 657: HwDeviceExtension->PhysicalFrameBase.LowPart = ! 658: MemoryMaps[pRequestedMode->MemMap].Start; ! 659: ! 660: // ! 661: // Store the new mode value. ! 662: // ! 663: ! 664: HwDeviceExtension->CurrentMode = pRequestedMode; ! 665: HwDeviceExtension->ModeIndex = Mode->RequestedMode; ! 666: ! 667: return NO_ERROR; ! 668: ! 669: } //end VgaSetMode() ! 670: ! 671: VP_STATUS ! 672: VgaQueryAvailableModes( ! 673: PHW_DEVICE_EXTENSION HwDeviceExtension, ! 674: PVIDEO_MODE_INFORMATION ModeInformation, ! 675: ULONG ModeInformationSize, ! 676: PULONG OutputSize ! 677: ) ! 678: ! 679: /*++ ! 680: ! 681: Routine Description: ! 682: ! 683: This routine returns the list of all available available modes on the ! 684: card. ! 685: ! 686: Arguments: ! 687: ! 688: HwDeviceExtension - Pointer to the miniport driver's device extension. ! 689: ! 690: ModeInformation - Pointer to the output buffer supplied by the user. ! 691: This is where the list of all valid modes is stored. ! 692: ! 693: ModeInformationSize - Length of the output buffer supplied by the user. ! 694: ! 695: OutputSize - Pointer to a buffer in which to return the actual size of ! 696: the data in the buffer. If the buffer was not large enough, this ! 697: contains the minimum required buffer size. ! 698: ! 699: Return Value: ! 700: ! 701: ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough ! 702: for the data being returned. ! 703: ! 704: NO_ERROR if the operation completed successfully. ! 705: ! 706: --*/ ! 707: ! 708: { ! 709: PVIDEO_MODE_INFORMATION videoModes = ModeInformation; ! 710: ULONG i; ! 711: ! 712: // ! 713: // Find out the size of the data to be put in the buffer and return ! 714: // that in the status information (whether or not the information is ! 715: // there). If the buffer passed in is not large enough return an ! 716: // appropriate error code. ! 717: // ! 718: ! 719: if (ModeInformationSize < (*OutputSize = ! 720: HwDeviceExtension->NumAvailableModes * ! 721: sizeof(VIDEO_MODE_INFORMATION)) ) { ! 722: ! 723: return ERROR_INSUFFICIENT_BUFFER; ! 724: ! 725: } ! 726: ! 727: // ! 728: // For each mode supported by the card, store the mode characteristics ! 729: // in the output buffer. ! 730: // ! 731: ! 732: for (i = 0; i < NumVideoModes; i++) { ! 733: ! 734: if (ModesVGA[i].ValidMode) { ! 735: ! 736: videoModes->Length = sizeof(VIDEO_MODE_INFORMATION); ! 737: videoModes->ModeIndex = i; ! 738: videoModes->VisScreenWidth = ModesVGA[i].hres; ! 739: videoModes->ScreenStride = ModesVGA[i].wbytes; ! 740: videoModes->VisScreenHeight = ModesVGA[i].vres; ! 741: videoModes->NumberOfPlanes = ModesVGA[i].numPlanes; ! 742: videoModes->BitsPerPlane = ModesVGA[i].bitsPerPlane; ! 743: videoModes->Frequency = ModesVGA[i].Frequency; ! 744: videoModes->XMillimeter = 330; // temporary hardcoded constant ! 745: videoModes->YMillimeter = 240; // temporary hardcoded constant ! 746: videoModes->NumberRedBits = 6; ! 747: videoModes->NumberGreenBits = 6; ! 748: videoModes->NumberBlueBits = 6; ! 749: videoModes->AttributeFlags = ModesVGA[i].fbType; ! 750: videoModes->AttributeFlags |= ModesVGA[i].Interlaced ? ! 751: VIDEO_MODE_INTERLACED : 0; ! 752: ! 753: videoModes->RedMask = 0; ! 754: videoModes->GreenMask = 0; ! 755: videoModes->BlueMask = 0; ! 756: videoModes->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN | ! 757: VIDEO_MODE_MANAGED_PALETTE; ! 758: ! 759: videoModes++; ! 760: ! 761: } ! 762: } ! 763: ! 764: return NO_ERROR; ! 765: ! 766: } // end VgaGetAvailableModes() ! 767: ! 768: VP_STATUS ! 769: VgaQueryNumberOfAvailableModes( ! 770: PHW_DEVICE_EXTENSION HwDeviceExtension, ! 771: PVIDEO_NUM_MODES NumModes, ! 772: ULONG NumModesSize, ! 773: PULONG OutputSize ! 774: ) ! 775: ! 776: /*++ ! 777: ! 778: Routine Description: ! 779: ! 780: This routine returns the number of available modes for this particular ! 781: video card. ! 782: ! 783: Arguments: ! 784: ! 785: HwDeviceExtension - Pointer to the miniport driver's device extension. ! 786: ! 787: NumModes - Pointer to the output buffer supplied by the user. This is ! 788: where the number of modes is stored. ! 789: ! 790: NumModesSize - Length of the output buffer supplied by the user. ! 791: ! 792: OutputSize - Pointer to a buffer in which to return the actual size of ! 793: the data in the buffer. ! 794: ! 795: Return Value: ! 796: ! 797: ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough ! 798: for the data being returned. ! 799: ! 800: NO_ERROR if the operation completed successfully. ! 801: ! 802: --*/ ! 803: ! 804: { ! 805: // ! 806: // Find out the size of the data to be put in the the buffer and return ! 807: // that in the status information (whether or not the information is ! 808: // there). If the buffer passed in is not large enough return an ! 809: // appropriate error code. ! 810: // ! 811: ! 812: if (NumModesSize < (*OutputSize = sizeof(VIDEO_NUM_MODES)) ) { ! 813: ! 814: return ERROR_INSUFFICIENT_BUFFER; ! 815: ! 816: } ! 817: ! 818: // ! 819: // Store the number of modes into the buffer. ! 820: // ! 821: ! 822: NumModes->NumModes = HwDeviceExtension->NumAvailableModes; ! 823: NumModes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION); ! 824: ! 825: return NO_ERROR; ! 826: ! 827: } // end VgaGetNumberOfAvailableModes() ! 828: ! 829: VP_STATUS ! 830: VgaQueryCurrentMode( ! 831: PHW_DEVICE_EXTENSION HwDeviceExtension, ! 832: PVIDEO_MODE_INFORMATION ModeInformation, ! 833: ULONG ModeInformationSize, ! 834: PULONG OutputSize ! 835: ) ! 836: ! 837: /*++ ! 838: ! 839: Routine Description: ! 840: ! 841: This routine returns a description of the current video mode. ! 842: ! 843: Arguments: ! 844: ! 845: HwDeviceExtension - Pointer to the miniport driver's device extension. ! 846: ! 847: ModeInformation - Pointer to the output buffer supplied by the user. ! 848: This is where the current mode information is stored. ! 849: ! 850: ModeInformationSize - Length of the output buffer supplied by the user. ! 851: ! 852: OutputSize - Pointer to a buffer in which to return the actual size of ! 853: the data in the buffer. If the buffer was not large enough, this ! 854: contains the minimum required buffer size. ! 855: ! 856: Return Value: ! 857: ! 858: ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough ! 859: for the data being returned. ! 860: ! 861: NO_ERROR if the operation completed successfully. ! 862: ! 863: --*/ ! 864: ! 865: { ! 866: // ! 867: // Find out the size of the data to be put in the the buffer and return ! 868: // that in the status information (whether or not the information is ! 869: // there). If the buffer passed in is not large enough return an ! 870: // appropriate error code. ! 871: // ! 872: ! 873: if (ModeInformationSize < (*OutputSize = sizeof(VIDEO_MODE_INFORMATION))) { ! 874: ! 875: return ERROR_INSUFFICIENT_BUFFER; ! 876: ! 877: } ! 878: ! 879: // ! 880: // Store the characteristics of the current mode into the buffer. ! 881: // ! 882: ! 883: ModeInformation->Length = sizeof(VIDEO_MODE_INFORMATION); ! 884: ModeInformation->ModeIndex = HwDeviceExtension->ModeIndex; ! 885: ModeInformation->VisScreenWidth = HwDeviceExtension->CurrentMode->hres; ! 886: ModeInformation->ScreenStride = HwDeviceExtension->CurrentMode->wbytes; ! 887: ModeInformation->VisScreenHeight = HwDeviceExtension->CurrentMode->vres; ! 888: ModeInformation->NumberOfPlanes = HwDeviceExtension->CurrentMode->numPlanes; ! 889: ModeInformation->BitsPerPlane = HwDeviceExtension->CurrentMode->bitsPerPlane; ! 890: ModeInformation->Frequency = HwDeviceExtension->CurrentMode->Frequency; ! 891: ModeInformation->XMillimeter = 330; // temporary hardcoded constant ! 892: ModeInformation->YMillimeter = 240; // temporary hardcoded constant ! 893: ModeInformation->NumberRedBits = 6; ! 894: ModeInformation->NumberGreenBits = 6; ! 895: ModeInformation->NumberBlueBits = 6; ! 896: ModeInformation->RedMask = 0; ! 897: ModeInformation->GreenMask = 0; ! 898: ModeInformation->BlueMask = 0; ! 899: ModeInformation->AttributeFlags = HwDeviceExtension->CurrentMode->fbType | ! 900: VIDEO_MODE_PALETTE_DRIVEN | VIDEO_MODE_MANAGED_PALETTE; ! 901: ModeInformation->AttributeFlags |= HwDeviceExtension->CurrentMode->Interlaced ? ! 902: VIDEO_MODE_INTERLACED : 0; ! 903: ! 904: ! 905: return NO_ERROR; ! 906: ! 907: } // end VgaQueryCurrentMode() ! 908: ! 909: ! 910: VOID ! 911: VgaZeroVideoMemory( ! 912: PHW_DEVICE_EXTENSION HwDeviceExtension ! 913: ) ! 914: ! 915: /*++ ! 916: ! 917: Routine Description: ! 918: ! 919: This routine zeros the first 256K on the VGA. ! 920: ! 921: Arguments: ! 922: ! 923: HwDeviceExtension - Pointer to the miniport driver's device extension. ! 924: ! 925: ! 926: Return Value: ! 927: ! 928: None. ! 929: ! 930: --*/ ! 931: { ! 932: UCHAR temp; ! 933: ULONG i; ! 934: ULONG max; ! 935: ! 936: // ! 937: // Map font buffer at A0000 ! 938: // ! 939: ! 940: VgaInterpretCmdStream(HwDeviceExtension, EnableA000Data); ! 941: ! 942: // ! 943: // Enable all planes. ! 944: // ! 945: ! 946: VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_ADDRESS_PORT, ! 947: IND_MAP_MASK); ! 948: ! 949: temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress + ! 950: SEQ_DATA_PORT) | (UCHAR)0x0F; ! 951: ! 952: VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_DATA_PORT, ! 953: temp); ! 954: ! 955: #ifndef INT10_MODE_SET ! 956: ! 957: // ! 958: // Zero the memory for all pages. ! 959: // ! 960: ! 961: switch (HwDeviceExtension->ChipType) { ! 962: ! 963: case CL6410: ! 964: ! 965: max = 1; // 6410 max memory is 256k ! 966: break; ! 967: ! 968: case CL6420: ! 969: ! 970: max = 4; // 6410 max memory is 1meg. ! 971: break; ! 972: ! 973: case CL542x: ! 974: ! 975: max = 8; // 6410 max memory is 2meg. ! 976: break; ! 977: ! 978: } ! 979: ! 980: for (i = 0; i < max; i++) { ! 981: ! 982: SetCirrusBanking(HwDeviceExtension,i); // setup next 256k bank ! 983: VideoPortZeroMemory(HwDeviceExtension->VideoMemoryAddress, 0xFFFF); ! 984: ! 985: } ! 986: ! 987: SetCirrusBanking(HwDeviceExtension,0); // reset the banks ! 988: ! 989: #else ! 990: ! 991: VideoPortZeroMemory(HwDeviceExtension->VideoMemoryAddress, 0xFFFF); ! 992: ! 993: #endif ! 994: ! 995: VgaInterpretCmdStream(HwDeviceExtension, DisableA000Color); ! 996: ! 997: } ! 998: ! 999: ! 1000: VOID ! 1001: CirrusValidateModes( ! 1002: PHW_DEVICE_EXTENSION HwDeviceExtension ! 1003: ) ! 1004: ! 1005: /*++ ! 1006: ! 1007: Routine Description: ! 1008: ! 1009: Determines which modes are valid and which are not. ! 1010: ! 1011: Arguments: ! 1012: ! 1013: HwDeviceExtension - Pointer to the miniport driver's device extension. ! 1014: ! 1015: Return Value: ! 1016: ! 1017: None. ! 1018: ! 1019: --*/ ! 1020: { ! 1021: ! 1022: ULONG i; ! 1023: ! 1024: HwDeviceExtension->NumAvailableModes = 0; ! 1025: ! 1026: for (i = 0; i < NumVideoModes; i++) { ! 1027: ! 1028: if ( (HwDeviceExtension->AdapterMemorySize >= ! 1029: ModesVGA[i].numPlanes * ModesVGA[i].sbytes) && ! 1030: (HwDeviceExtension->ChipType & ModesVGA[i].ChipType) && ! 1031: (HwDeviceExtension->DisplayType & ModesVGA[i].DisplayType)) { ! 1032: ! 1033: ModesVGA[i].ValidMode = TRUE; ! 1034: HwDeviceExtension->NumAvailableModes++; ! 1035: ! 1036: } ! 1037: } ! 1038: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.