ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

modeset.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS VGA Miniport Driver
00003  * LICENSE:         Microsoft NT4 DDK Sample Code License
00004  * FILE:            boot/drivers/video/miniport/vga/modeset.c
00005  * PURPOSE:         Handles switching to Standard VGA Modes for compatible cards
00006  * PROGRAMMERS:     Copyright (c) 1992  Microsoft Corporation
00007  *                  ReactOS Portable Systems Group
00008  */
00009 
00010 #include "vga.h"
00011 
00012 VP_STATUS
00013 VgaInterpretCmdStream(
00014     PHW_DEVICE_EXTENSION HwDeviceExtension,
00015     PUSHORT pusCmdStream
00016     );
00017 
00018 VP_STATUS
00019 VgaSetMode(
00020     PHW_DEVICE_EXTENSION HwDeviceExtension,
00021     PVIDEO_MODE Mode,
00022     ULONG ModeSize,
00023 // eVb: 2.1 [SET MODE] - Add new output parameter for framebuffer update functionality
00024     PULONG PhysPtrChange
00025 // eVb: 2.1 [END]
00026     );
00027 
00028 VP_STATUS
00029 VgaQueryAvailableModes(
00030     PHW_DEVICE_EXTENSION HwDeviceExtension,
00031     PVIDEO_MODE_INFORMATION ModeInformation,
00032     ULONG ModeInformationSize,
00033     PULONG OutputSize
00034     );
00035 
00036 VP_STATUS
00037 VgaQueryNumberOfAvailableModes(
00038     PHW_DEVICE_EXTENSION HwDeviceExtension,
00039     PVIDEO_NUM_MODES NumModes,
00040     ULONG NumModesSize,
00041     PULONG OutputSize
00042     );
00043 
00044 VP_STATUS
00045 VgaQueryCurrentMode(
00046     PHW_DEVICE_EXTENSION HwDeviceExtension,
00047     PVIDEO_MODE_INFORMATION ModeInformation,
00048     ULONG ModeInformationSize,
00049     PULONG OutputSize
00050     );
00051 
00052 VOID
00053 VgaZeroVideoMemory(
00054     PHW_DEVICE_EXTENSION HwDeviceExtension
00055     );
00056 
00057 #if defined(ALLOC_PRAGMA)
00058 #pragma alloc_text(PAGE,VgaInterpretCmdStream)
00059 #pragma alloc_text(PAGE,VgaSetMode)
00060 #pragma alloc_text(PAGE,VgaQueryAvailableModes)
00061 #pragma alloc_text(PAGE,VgaQueryNumberOfAvailableModes)
00062 #pragma alloc_text(PAGE,VgaZeroVideoMemory)
00063 #endif
00064 
00065 //---------------------------------------------------------------------------
00066 VP_STATUS
00067 VgaInterpretCmdStream(
00068     PHW_DEVICE_EXTENSION HwDeviceExtension,
00069     PUSHORT pusCmdStream
00070     )
00071 
00072 /*++
00073 
00074 Routine Description:
00075 
00076     Interprets the appropriate command array to set up VGA registers for the
00077     requested mode. Typically used to set the VGA into a particular mode by
00078     programming all of the registers
00079 
00080 Arguments:
00081 
00082     HwDeviceExtension - Pointer to the miniport driver's device extension.
00083 
00084     pusCmdStream - array of commands to be interpreted.
00085 
00086 Return Value:
00087 
00088     The status of the operation (can only fail on a bad command); TRUE for
00089     success, FALSE for failure.
00090 
00091 --*/
00092 
00093 {
00094     ULONG ulCmd;
00095     ULONG ulPort;
00096     UCHAR jValue;
00097     USHORT usValue;
00098     ULONG culCount;
00099     ULONG ulIndex;
00100     ULONG ulBase;
00101 
00102     if (pusCmdStream == NULL) {
00103 
00104         VideoDebugPrint((1, "VgaInterpretCmdStream - Invalid pusCmdStream\n"));
00105         return TRUE;
00106     }
00107 
00108     ulBase = (ULONG)HwDeviceExtension->IOAddress;
00109 
00110     //
00111     // Now set the adapter to the desired mode.
00112     //
00113 
00114     while ((ulCmd = *pusCmdStream++) != EOD) {
00115 
00116         //
00117         // Determine major command type
00118         //
00119 
00120         switch (ulCmd & 0xF0) {
00121 
00122             //
00123             // Basic input/output command
00124             //
00125 
00126             case INOUT:
00127 
00128                 //
00129                 // Determine type of inout instruction
00130                 //
00131 
00132                 if (!(ulCmd & IO)) {
00133 
00134                     //
00135                     // Out instruction. Single or multiple outs?
00136                     //
00137 
00138                     if (!(ulCmd & MULTI)) {
00139 
00140                         //
00141                         // Single out. Byte or word out?
00142                         //
00143 
00144                         if (!(ulCmd & BW)) {
00145 
00146                             //
00147                             // Single byte out
00148                             //
00149 
00150                             ulPort = *pusCmdStream++;
00151                             jValue = (UCHAR) *pusCmdStream++;
00152                             VideoPortWritePortUchar((PUCHAR)(ulBase+ulPort),
00153                                     jValue);
00154 
00155                         } else {
00156 
00157                             //
00158                             // Single word out
00159                             //
00160 
00161                             ulPort = *pusCmdStream++;
00162                             usValue = *pusCmdStream++;
00163                             VideoPortWritePortUshort((PUSHORT)(ulBase+ulPort),
00164                                     usValue);
00165 
00166                         }
00167 
00168                     } else {
00169 
00170                         //
00171                         // Output a string of values
00172                         // Byte or word outs?
00173                         //
00174 
00175                         if (!(ulCmd & BW)) {
00176 
00177                             //
00178                             // String byte outs. Do in a loop; can't use
00179                             // VideoPortWritePortBufferUchar because the data
00180                             // is in USHORT form
00181                             //
00182 
00183                             ulPort = ulBase + *pusCmdStream++;
00184                             culCount = *pusCmdStream++;
00185 
00186                             while (culCount--) {
00187                                 jValue = (UCHAR) *pusCmdStream++;
00188                                 VideoPortWritePortUchar((PUCHAR)ulPort,
00189                                         jValue);
00190 
00191                             }
00192 
00193                         } else {
00194 
00195                             //
00196                             // String word outs
00197                             //
00198 
00199                             ulPort = *pusCmdStream++;
00200                             culCount = *pusCmdStream++;
00201                             VideoPortWritePortBufferUshort((PUSHORT)
00202                                     (ulBase + ulPort), pusCmdStream, culCount);
00203                             pusCmdStream += culCount;
00204 
00205                         }
00206                     }
00207 
00208                 } else {
00209 
00210                     // In instruction
00211                     //
00212                     // Currently, string in instructions aren't supported; all
00213                     // in instructions are handled as single-byte ins
00214                     //
00215                     // Byte or word in?
00216                     //
00217 
00218                     if (!(ulCmd & BW)) {
00219                         //
00220                         // Single byte in
00221                         //
00222 
00223                         ulPort = *pusCmdStream++;
00224                         jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort);
00225 
00226                     } else {
00227 
00228                         //
00229                         // Single word in
00230                         //
00231 
00232                         ulPort = *pusCmdStream++;
00233                         usValue = VideoPortReadPortUshort((PUSHORT)
00234                                 (ulBase+ulPort));
00235 
00236                     }
00237 
00238                 }
00239 
00240                 break;
00241 
00242             //
00243             // Higher-level input/output commands
00244             //
00245 
00246             case METAOUT:
00247 
00248                 //
00249                 // Determine type of metaout command, based on minor
00250                 // command field
00251                 //
00252                 switch (ulCmd & 0x0F) {
00253 
00254                     //
00255                     // Indexed outs
00256                     //
00257 
00258                     case INDXOUT:
00259 
00260                         ulPort = ulBase + *pusCmdStream++;
00261                         culCount = *pusCmdStream++;
00262                         ulIndex = *pusCmdStream++;
00263 
00264                         while (culCount--) {
00265 
00266                             usValue = (USHORT) (ulIndex +
00267                                       (((ULONG)(*pusCmdStream++)) << 8));
00268                             VideoPortWritePortUshort((PUSHORT)ulPort, usValue);
00269 
00270                             ulIndex++;
00271 
00272                         }
00273 
00274                         break;
00275 
00276                     //
00277                     // Masked out (read, AND, XOR, write)
00278                     //
00279 
00280                     case MASKOUT:
00281 
00282                         ulPort = *pusCmdStream++;
00283                         jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort);
00284                         jValue &= *pusCmdStream++;
00285                         jValue ^= *pusCmdStream++;
00286                         VideoPortWritePortUchar((PUCHAR)ulBase + ulPort,
00287                                 jValue);
00288                         break;
00289 
00290                     //
00291                     // Attribute Controller out
00292                     //
00293 
00294                     case ATCOUT:
00295 
00296                         ulPort = ulBase + *pusCmdStream++;
00297                         culCount = *pusCmdStream++;
00298                         ulIndex = *pusCmdStream++;
00299 
00300                         while (culCount--) {
00301 
00302                             // Write Attribute Controller index
00303                             VideoPortWritePortUchar((PUCHAR)ulPort,
00304                                     (UCHAR)ulIndex);
00305 
00306                             // Write Attribute Controller data
00307                             jValue = (UCHAR) *pusCmdStream++;
00308                             VideoPortWritePortUchar((PUCHAR)ulPort, jValue);
00309 
00310                             ulIndex++;
00311 
00312                         }
00313 
00314                         break;
00315 
00316                     //
00317                     // None of the above; error
00318                     //
00319                     default:
00320 
00321                         return FALSE;
00322 
00323                 }
00324 
00325 
00326                 break;
00327 
00328             //
00329             // NOP
00330             //
00331 
00332             case NCMD:
00333 
00334                 break;
00335 
00336             //
00337             // Unknown command; error
00338             //
00339 
00340             default:
00341 
00342                 return FALSE;
00343 
00344         }
00345 
00346     }
00347 
00348     return TRUE;
00349 
00350 } // end VgaInterpretCmdStream()
00351 
00352 
00353 VP_STATUS
00354 VgaSetMode(
00355     PHW_DEVICE_EXTENSION HwDeviceExtension,
00356     PVIDEO_MODE Mode,
00357     ULONG ModeSize,
00358 // eVb: 2.2 [SET MODE] - Add new output parameter for framebuffer update functionality
00359     PULONG PhysPtrChange
00360 // eVb: 2.2 [END]
00361     )
00362 
00363 /*++
00364 
00365 Routine Description:
00366 
00367     This routine sets the vga into the requested mode.
00368 
00369 Arguments:
00370 
00371     HwDeviceExtension - Pointer to the miniport driver's device extension.
00372 
00373     Mode - Pointer to the structure containing the information about the
00374         font to be set.
00375 
00376     ModeSize - Length of the input buffer supplied by the user.
00377 
00378 Return Value:
00379 
00380     ERROR_INSUFFICIENT_BUFFER if the input buffer was not large enough
00381         for the input data.
00382 
00383     ERROR_INVALID_PARAMETER if the mode number is invalid.
00384 
00385     NO_ERROR if the operation completed successfully.
00386 
00387 --*/
00388 
00389 {
00390     PVIDEOMODE pRequestedMode;
00391     VP_STATUS status;
00392     ULONG RequestedModeNum;
00393 // eVb: 2.3 [SET MODE] - Add new output parameter for framebuffer update functionality
00394     *PhysPtrChange = FALSE;
00395 // eVb: 2.3 [END]
00396     //
00397     // Check if the size of the data in the input buffer is large enough.
00398     //
00399 
00400     if (ModeSize < sizeof(VIDEO_MODE))
00401     {
00402         return ERROR_INSUFFICIENT_BUFFER;
00403     }
00404 
00405     //
00406     // Extract the clear memory, and map linear bits.
00407     //
00408 
00409     RequestedModeNum = Mode->RequestedMode &
00410         ~(VIDEO_MODE_NO_ZERO_MEMORY | VIDEO_MODE_MAP_MEM_LINEAR);
00411 
00412 
00413     if (!(Mode->RequestedMode & VIDEO_MODE_NO_ZERO_MEMORY))
00414     {
00415 #if defined(_X86_)
00416         VgaZeroVideoMemory(HwDeviceExtension);
00417 #endif
00418     }
00419 
00420     //
00421     // Check to see if we are requesting a valid mode
00422     //
00423 // eVb: 2.4 [CIRRUS] - Remove Cirrus-specific check for valid mode
00424     if ( (RequestedModeNum >= NumVideoModes) )
00425 // eVb: 2.4 [END]
00426     {
00427         VideoDebugPrint((0, "Invalide Mode Number = %d!\n", RequestedModeNum));
00428 
00429         return ERROR_INVALID_PARAMETER;
00430     }
00431 
00432     VideoDebugPrint((2, "Attempting to set mode %d\n",
00433                         RequestedModeNum));
00434 // eVb: 2.5 [VBE] - Use dynamic VBE mode list instead of hard-coded VGA list
00435     pRequestedMode = &VgaModeList[RequestedModeNum];
00436 // eVb: 2.5 [END]
00437     VideoDebugPrint((2, "Info on Requested Mode:\n"
00438                         "\tResolution: %dx%d\n",
00439                         pRequestedMode->hres,
00440                         pRequestedMode->vres ));
00441 
00442     //
00443     // VESA BIOS mode switch
00444     //
00445 // eVb: 2.6 [VBE] - VBE Mode Switch Support 
00446     status = VbeSetMode(HwDeviceExtension, pRequestedMode, PhysPtrChange);
00447     if (status == ERROR_INVALID_FUNCTION)
00448     {
00449         //
00450         // VGA mode switch
00451         //
00452 
00453         if (!pRequestedMode->CmdStream) return ERROR_INVALID_FUNCTION;
00454         if (!VgaInterpretCmdStream(HwDeviceExtension, pRequestedMode->CmdStream)) return ERROR_INVALID_FUNCTION;
00455         goto Cleanup;
00456     }
00457     else if (status != NO_ERROR) return status;
00458 // eVb: 2.6 [END]
00459 // eVb: 2.7 [MODE-X] - Windows VGA Miniport Supports Mode-X, we should too
00460     //
00461     // ModeX check
00462     //
00463     
00464     if (pRequestedMode->hres == 320)
00465     {
00466         VideoPortDebugPrint(0, "ModeX not support!!!\n");
00467         return ERROR_INVALID_PARAMETER;
00468     }
00469 // eVb: 2.7 [END]
00470     //
00471     // Text mode check
00472     //
00473     
00474     if (!(pRequestedMode->fbType & VIDEO_MODE_GRAPHICS))
00475     {
00476 // eVb: 2.8 [TODO] - This code path is not implemented yet
00477         VideoPortDebugPrint(0, "Text-mode not support!!!\n");
00478         return ERROR_INVALID_PARAMETER;
00479 // eVb: 2.8 [END]
00480     }
00481 
00482 Cleanup:
00483     //
00484     // Update the location of the physical frame buffer within video memory.
00485     //
00486 // eVb: 2.9 [VBE] - Linear and banked support is unified in VGA, unlike Cirrus
00487     HwDeviceExtension->PhysicalVideoMemoryBase.LowPart = pRequestedMode->PhysBase;
00488     HwDeviceExtension->PhysicalVideoMemoryLength = pRequestedMode->PhysSize;
00489 
00490     HwDeviceExtension->PhysicalFrameLength =
00491             pRequestedMode->FrameBufferSize;
00492 
00493     HwDeviceExtension->PhysicalFrameOffset.LowPart =
00494             pRequestedMode->FrameBufferBase;
00495 // eVb: 2.9 [END]
00496 
00497     //
00498     // Store the new mode value.
00499     //
00500 
00501     HwDeviceExtension->CurrentMode = pRequestedMode;
00502     HwDeviceExtension->ModeIndex = Mode->RequestedMode;
00503 
00504     return NO_ERROR;
00505 
00506 } //end VgaSetMode()
00507 
00508 VP_STATUS
00509 VgaQueryAvailableModes(
00510     PHW_DEVICE_EXTENSION HwDeviceExtension,
00511     PVIDEO_MODE_INFORMATION ModeInformation,
00512     ULONG ModeInformationSize,
00513     PULONG OutputSize
00514     )
00515 
00516 /*++
00517 
00518 Routine Description:
00519 
00520     This routine returns the list of all available available modes on the
00521     card.
00522 
00523 Arguments:
00524 
00525     HwDeviceExtension - Pointer to the miniport driver's device extension.
00526 
00527     ModeInformation - Pointer to the output buffer supplied by the user.
00528         This is where the list of all valid modes is stored.
00529 
00530     ModeInformationSize - Length of the output buffer supplied by the user.
00531 
00532     OutputSize - Pointer to a buffer in which to return the actual size of
00533         the data in the buffer. If the buffer was not large enough, this
00534         contains the minimum required buffer size.
00535 
00536 Return Value:
00537 
00538     ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
00539         for the data being returned.
00540 
00541     NO_ERROR if the operation completed successfully.
00542 
00543 --*/
00544 
00545 {
00546     PVIDEO_MODE_INFORMATION videoModes = ModeInformation;
00547     ULONG i;
00548 
00549     //
00550     // Find out the size of the data to be put in the buffer and return
00551     // that in the status information (whether or not the information is
00552     // there). If the buffer passed in is not large enough return an
00553     // appropriate error code.
00554     //
00555 
00556     if (ModeInformationSize < (*OutputSize =
00557 // eVb: 2.10 [VBE] - We store VBE/VGA mode count in this global, not in DevExt like Cirrus
00558             NumVideoModes *
00559 // eVb: 2.10 [END]
00560             sizeof(VIDEO_MODE_INFORMATION)) ) {
00561 
00562         return ERROR_INSUFFICIENT_BUFFER;
00563 
00564     }
00565 
00566     //
00567     // For each mode supported by the card, store the mode characteristics
00568     // in the output buffer.
00569     //
00570 
00571     for (i = 0; i < NumVideoModes; i++)
00572     {
00573         videoModes->Length = sizeof(VIDEO_MODE_INFORMATION);
00574         videoModes->ModeIndex  = i;
00575 // eVb: 2.11 [VBE] - Use dynamic VBE mode list instead of hard-coded VGA list
00576         videoModes->VisScreenWidth = VgaModeList[i].hres;
00577         videoModes->ScreenStride = VgaModeList[i].wbytes;
00578         videoModes->VisScreenHeight = VgaModeList[i].vres;
00579         videoModes->NumberOfPlanes = VgaModeList[i].numPlanes;
00580         videoModes->BitsPerPlane = VgaModeList[i].bitsPerPlane;
00581         videoModes->Frequency = VgaModeList[i].Frequency;
00582         videoModes->XMillimeter = 320;        // temporary hardcoded constant
00583         videoModes->YMillimeter = 240;        // temporary hardcoded constant
00584         videoModes->AttributeFlags = VgaModeList[i].fbType;
00585 // eVb: 2.11 [END]
00586 
00587         if ((VgaModeList[i].bitsPerPlane == 32) ||
00588             (VgaModeList[i].bitsPerPlane == 24))
00589         {
00590 
00591             videoModes->NumberRedBits = 8;
00592             videoModes->NumberGreenBits = 8;
00593             videoModes->NumberBlueBits = 8;
00594             videoModes->RedMask = 0xff0000;
00595             videoModes->GreenMask = 0x00ff00;
00596             videoModes->BlueMask = 0x0000ff;
00597 
00598         }
00599         else if (VgaModeList[i].bitsPerPlane == 16)
00600         {
00601 
00602             videoModes->NumberRedBits = 6;
00603             videoModes->NumberGreenBits = 6;
00604             videoModes->NumberBlueBits = 6;
00605             videoModes->RedMask = 0x1F << 11;
00606             videoModes->GreenMask = 0x3F << 5;
00607             videoModes->BlueMask = 0x1F;
00608 
00609         }
00610 // eVb: 2.12 [VGA] - Add support for 15bpp modes, which Cirrus doesn't support
00611         else if (VgaModeList[i].bitsPerPlane == 15)
00612         {
00613 
00614             videoModes->NumberRedBits = 6;
00615             videoModes->NumberGreenBits = 6;
00616             videoModes->NumberBlueBits = 6;
00617             videoModes->RedMask = 0x3E << 9;
00618             videoModes->GreenMask = 0x1F << 5;
00619             videoModes->BlueMask = 0x1F;
00620         }
00621 // eVb: 2.12 [END]
00622         else
00623         {
00624 
00625             videoModes->NumberRedBits = 6;
00626             videoModes->NumberGreenBits = 6;
00627             videoModes->NumberBlueBits = 6;
00628             videoModes->RedMask = 0;
00629             videoModes->GreenMask = 0;
00630             videoModes->BlueMask = 0;
00631         }
00632 
00633 // eVb: 2.13 [VGA] - All modes are palette managed/driven, unlike Cirrus
00634         videoModes->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN |
00635              VIDEO_MODE_MANAGED_PALETTE;
00636 // eVb: 2.13 [END]
00637         videoModes++;
00638 
00639     }
00640 
00641     return NO_ERROR;
00642 
00643 } // end VgaGetAvailableModes()
00644 
00645 VP_STATUS
00646 VgaQueryNumberOfAvailableModes(
00647     PHW_DEVICE_EXTENSION HwDeviceExtension,
00648     PVIDEO_NUM_MODES NumModes,
00649     ULONG NumModesSize,
00650     PULONG OutputSize
00651     )
00652 
00653 /*++
00654 
00655 Routine Description:
00656 
00657     This routine returns the number of available modes for this particular
00658     video card.
00659 
00660 Arguments:
00661 
00662     HwDeviceExtension - Pointer to the miniport driver's device extension.
00663 
00664     NumModes - Pointer to the output buffer supplied by the user. This is
00665         where the number of modes is stored.
00666 
00667     NumModesSize - Length of the output buffer supplied by the user.
00668 
00669     OutputSize - Pointer to a buffer in which to return the actual size of
00670         the data in the buffer.
00671 
00672 Return Value:
00673 
00674     ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
00675         for the data being returned.
00676 
00677     NO_ERROR if the operation completed successfully.
00678 
00679 --*/
00680 
00681 {
00682     //
00683     // Find out the size of the data to be put in the the buffer and return
00684     // that in the status information (whether or not the information is
00685     // there). If the buffer passed in is not large enough return an
00686     // appropriate error code.
00687     //
00688 
00689     if (NumModesSize < (*OutputSize = sizeof(VIDEO_NUM_MODES)) ) {
00690 
00691         return ERROR_INSUFFICIENT_BUFFER;
00692 
00693     }
00694 
00695     //
00696     // Store the number of modes into the buffer.
00697     //
00698 
00699 // eVb: 2.14 [VBE] - We store VBE/VGA mode count in this global, not in DevExt like Cirrus
00700     NumModes->NumModes = NumVideoModes;
00701 // eVb: 2.14 [END]
00702     NumModes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
00703 
00704     return NO_ERROR;
00705 
00706 } // end VgaGetNumberOfAvailableModes()
00707 
00708 VP_STATUS
00709 VgaQueryCurrentMode(
00710     PHW_DEVICE_EXTENSION HwDeviceExtension,
00711     PVIDEO_MODE_INFORMATION ModeInformation,
00712     ULONG ModeInformationSize,
00713     PULONG OutputSize
00714     )
00715 
00716 /*++
00717 
00718 Routine Description:
00719 
00720     This routine returns a description of the current video mode.
00721 
00722 Arguments:
00723 
00724     HwDeviceExtension - Pointer to the miniport driver's device extension.
00725 
00726     ModeInformation - Pointer to the output buffer supplied by the user.
00727         This is where the current mode information is stored.
00728 
00729     ModeInformationSize - Length of the output buffer supplied by the user.
00730 
00731     OutputSize - Pointer to a buffer in which to return the actual size of
00732         the data in the buffer. If the buffer was not large enough, this
00733         contains the minimum required buffer size.
00734 
00735 Return Value:
00736 
00737     ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
00738         for the data being returned.
00739 
00740     NO_ERROR if the operation completed successfully.
00741 
00742 --*/
00743 
00744 {
00745     //
00746     // check if a mode has been set
00747     //
00748 
00749     if (HwDeviceExtension->CurrentMode == NULL ) {
00750 
00751         return ERROR_INVALID_FUNCTION;
00752 
00753     }
00754 
00755     //
00756     // Find out the size of the data to be put in the the buffer and return
00757     // that in the status information (whether or not the information is
00758     // there). If the buffer passed in is not large enough return an
00759     // appropriate error code.
00760     //
00761 
00762     if (ModeInformationSize < (*OutputSize = sizeof(VIDEO_MODE_INFORMATION))) {
00763 
00764         return ERROR_INSUFFICIENT_BUFFER;
00765 
00766     }
00767 
00768     //
00769     // Store the characteristics of the current mode into the buffer.
00770     //
00771 
00772     ModeInformation->Length = sizeof(VIDEO_MODE_INFORMATION);
00773     ModeInformation->ModeIndex = HwDeviceExtension->ModeIndex;
00774     ModeInformation->VisScreenWidth = HwDeviceExtension->CurrentMode->hres;
00775     ModeInformation->ScreenStride = HwDeviceExtension->CurrentMode->wbytes;
00776     ModeInformation->VisScreenHeight = HwDeviceExtension->CurrentMode->vres;
00777     ModeInformation->NumberOfPlanes = HwDeviceExtension->CurrentMode->numPlanes;
00778     ModeInformation->BitsPerPlane = HwDeviceExtension->CurrentMode->bitsPerPlane;
00779     ModeInformation->Frequency = HwDeviceExtension->CurrentMode->Frequency;
00780     ModeInformation->XMillimeter = 320;        // temporary hardcoded constant
00781     ModeInformation->YMillimeter = 240;        // temporary hardcoded constant
00782 
00783     ModeInformation->AttributeFlags = HwDeviceExtension->CurrentMode->fbType;
00784 
00785     if ((ModeInformation->BitsPerPlane == 32) ||
00786         (ModeInformation->BitsPerPlane == 24))
00787     {
00788 
00789         ModeInformation->NumberRedBits = 8;
00790         ModeInformation->NumberGreenBits = 8;
00791         ModeInformation->NumberBlueBits = 8;
00792         ModeInformation->RedMask = 0xff0000;
00793         ModeInformation->GreenMask = 0x00ff00;
00794         ModeInformation->BlueMask = 0x0000ff;
00795 
00796     }
00797     else if (ModeInformation->BitsPerPlane == 16)
00798     {
00799 
00800         ModeInformation->NumberRedBits = 6;
00801         ModeInformation->NumberGreenBits = 6;
00802         ModeInformation->NumberBlueBits = 6;
00803         ModeInformation->RedMask = 0x1F << 11;
00804         ModeInformation->GreenMask = 0x3F << 5;
00805         ModeInformation->BlueMask = 0x1F;
00806 
00807     }
00808 // eVb: 2.12 [VGA] - Add support for 15bpp modes, which Cirrus doesn't support
00809     else if (ModeInformation->BitsPerPlane == 15)
00810     {
00811 
00812         ModeInformation->NumberRedBits = 6;
00813         ModeInformation->NumberGreenBits = 6;
00814         ModeInformation->NumberBlueBits = 6;
00815         ModeInformation->RedMask = 0x3E << 9;
00816         ModeInformation->GreenMask = 0x1F << 5;
00817         ModeInformation->BlueMask = 0x1F;
00818     }
00819 // eVb: 2.12 [END]
00820     else
00821     {
00822 
00823         ModeInformation->NumberRedBits = 6;
00824         ModeInformation->NumberGreenBits = 6;
00825         ModeInformation->NumberBlueBits = 6;
00826         ModeInformation->RedMask = 0;
00827         ModeInformation->GreenMask = 0;
00828         ModeInformation->BlueMask = 0;
00829     }
00830 
00831 // eVb: 2.13 [VGA] - All modes are palette managed/driven, unlike Cirrus
00832     ModeInformation->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN |
00833          VIDEO_MODE_MANAGED_PALETTE;
00834 // eVb: 2.13 [END]
00835 
00836     return NO_ERROR;
00837 
00838 } // end VgaQueryCurrentMode()
00839 
00840 
00841 VOID
00842 VgaZeroVideoMemory(
00843     PHW_DEVICE_EXTENSION HwDeviceExtension
00844     )
00845 
00846 /*++
00847 
00848 Routine Description:
00849 
00850     This routine zeros the first 256K on the VGA.
00851 
00852 Arguments:
00853 
00854     HwDeviceExtension - Pointer to the miniport driver's device extension.
00855 
00856 
00857 Return Value:
00858 
00859     None.
00860 
00861 --*/
00862 {
00863     UCHAR temp;
00864 
00865     //
00866     // Map font buffer at A0000
00867     //
00868 
00869     VgaInterpretCmdStream(HwDeviceExtension, EnableA000Data);
00870 
00871     //
00872     // Enable all planes.
00873     //
00874 
00875     VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_ADDRESS_PORT,
00876             IND_MAP_MASK);
00877 
00878     temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
00879             SEQ_DATA_PORT) | (UCHAR)0x0F;
00880 
00881     VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_DATA_PORT,
00882             temp);
00883 
00884     VideoPortZeroDeviceMemory(HwDeviceExtension->VideoMemoryAddress, 0xFFFF);
00885 
00886     VgaInterpretCmdStream(HwDeviceExtension, DisableA000Color);
00887 
00888 }

Generated on Sun May 27 2012 04:38:12 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.