- Update to r53061
[reactos.git] / drivers / video / miniport / vga_new / modeset.c
1 /*
2 * PROJECT: ReactOS VGA Miniport Driver
3 * LICENSE: Microsoft NT4 DDK Sample Code License
4 * FILE: boot/drivers/video/miniport/vga/modeset.c
5 * PURPOSE: Handles switching to Standard VGA Modes for compatible cards
6 * PROGRAMMERS: Copyright (c) 1992 Microsoft Corporation
7 * ReactOS Portable Systems Group
8 */
9
10 #include "vga.h"
11
12 VP_STATUS
13 VgaInterpretCmdStream(
14 PHW_DEVICE_EXTENSION HwDeviceExtension,
15 PUSHORT pusCmdStream
16 );
17
18 VP_STATUS
19 VgaSetMode(
20 PHW_DEVICE_EXTENSION HwDeviceExtension,
21 PVIDEO_MODE Mode,
22 ULONG ModeSize,
23 // eVb: 2.1 [SET MODE] - Add new output parameter for framebuffer update functionality
24 PULONG PhysPtrChange
25 // eVb: 2.1 [END]
26 );
27
28 VP_STATUS
29 VgaQueryAvailableModes(
30 PHW_DEVICE_EXTENSION HwDeviceExtension,
31 PVIDEO_MODE_INFORMATION ModeInformation,
32 ULONG ModeInformationSize,
33 PULONG OutputSize
34 );
35
36 VP_STATUS
37 VgaQueryNumberOfAvailableModes(
38 PHW_DEVICE_EXTENSION HwDeviceExtension,
39 PVIDEO_NUM_MODES NumModes,
40 ULONG NumModesSize,
41 PULONG OutputSize
42 );
43
44 VP_STATUS
45 VgaQueryCurrentMode(
46 PHW_DEVICE_EXTENSION HwDeviceExtension,
47 PVIDEO_MODE_INFORMATION ModeInformation,
48 ULONG ModeInformationSize,
49 PULONG OutputSize
50 );
51
52 VOID
53 VgaZeroVideoMemory(
54 PHW_DEVICE_EXTENSION HwDeviceExtension
55 );
56
57 #if defined(ALLOC_PRAGMA)
58 #pragma alloc_text(PAGE,VgaInterpretCmdStream)
59 #pragma alloc_text(PAGE,VgaSetMode)
60 #pragma alloc_text(PAGE,VgaQueryAvailableModes)
61 #pragma alloc_text(PAGE,VgaQueryNumberOfAvailableModes)
62 #pragma alloc_text(PAGE,VgaZeroVideoMemory)
63 #endif
64
65 //---------------------------------------------------------------------------
66 VP_STATUS
67 VgaInterpretCmdStream(
68 PHW_DEVICE_EXTENSION HwDeviceExtension,
69 PUSHORT pusCmdStream
70 )
71
72 /*++
73
74 Routine Description:
75
76 Interprets the appropriate command array to set up VGA registers for the
77 requested mode. Typically used to set the VGA into a particular mode by
78 programming all of the registers
79
80 Arguments:
81
82 HwDeviceExtension - Pointer to the miniport driver's device extension.
83
84 pusCmdStream - array of commands to be interpreted.
85
86 Return Value:
87
88 The status of the operation (can only fail on a bad command); TRUE for
89 success, FALSE for failure.
90
91 --*/
92
93 {
94 ULONG ulCmd;
95 ULONG ulPort;
96 UCHAR jValue;
97 USHORT usValue;
98 ULONG culCount;
99 ULONG ulIndex;
100 ULONG ulBase;
101
102 if (pusCmdStream == NULL) {
103
104 VideoDebugPrint((1, "VgaInterpretCmdStream - Invalid pusCmdStream\n"));
105 return TRUE;
106 }
107
108 ulBase = (ULONG)HwDeviceExtension->IOAddress;
109
110 //
111 // Now set the adapter to the desired mode.
112 //
113
114 while ((ulCmd = *pusCmdStream++) != EOD) {
115
116 //
117 // Determine major command type
118 //
119
120 switch (ulCmd & 0xF0) {
121
122 //
123 // Basic input/output command
124 //
125
126 case INOUT:
127
128 //
129 // Determine type of inout instruction
130 //
131
132 if (!(ulCmd & IO)) {
133
134 //
135 // Out instruction. Single or multiple outs?
136 //
137
138 if (!(ulCmd & MULTI)) {
139
140 //
141 // Single out. Byte or word out?
142 //
143
144 if (!(ulCmd & BW)) {
145
146 //
147 // Single byte out
148 //
149
150 ulPort = *pusCmdStream++;
151 jValue = (UCHAR) *pusCmdStream++;
152 VideoPortWritePortUchar((PUCHAR)(ulBase+ulPort),
153 jValue);
154
155 } else {
156
157 //
158 // Single word out
159 //
160
161 ulPort = *pusCmdStream++;
162 usValue = *pusCmdStream++;
163 VideoPortWritePortUshort((PUSHORT)(ulBase+ulPort),
164 usValue);
165
166 }
167
168 } else {
169
170 //
171 // Output a string of values
172 // Byte or word outs?
173 //
174
175 if (!(ulCmd & BW)) {
176
177 //
178 // String byte outs. Do in a loop; can't use
179 // VideoPortWritePortBufferUchar because the data
180 // is in USHORT form
181 //
182
183 ulPort = ulBase + *pusCmdStream++;
184 culCount = *pusCmdStream++;
185
186 while (culCount--) {
187 jValue = (UCHAR) *pusCmdStream++;
188 VideoPortWritePortUchar((PUCHAR)ulPort,
189 jValue);
190
191 }
192
193 } else {
194
195 //
196 // String word outs
197 //
198
199 ulPort = *pusCmdStream++;
200 culCount = *pusCmdStream++;
201 VideoPortWritePortBufferUshort((PUSHORT)
202 (ulBase + ulPort), pusCmdStream, culCount);
203 pusCmdStream += culCount;
204
205 }
206 }
207
208 } else {
209
210 // In instruction
211 //
212 // Currently, string in instructions aren't supported; all
213 // in instructions are handled as single-byte ins
214 //
215 // Byte or word in?
216 //
217
218 if (!(ulCmd & BW)) {
219 //
220 // Single byte in
221 //
222
223 ulPort = *pusCmdStream++;
224 jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort);
225
226 } else {
227
228 //
229 // Single word in
230 //
231
232 ulPort = *pusCmdStream++;
233 usValue = VideoPortReadPortUshort((PUSHORT)
234 (ulBase+ulPort));
235
236 }
237
238 }
239
240 break;
241
242 //
243 // Higher-level input/output commands
244 //
245
246 case METAOUT:
247
248 //
249 // Determine type of metaout command, based on minor
250 // command field
251 //
252 switch (ulCmd & 0x0F) {
253
254 //
255 // Indexed outs
256 //
257
258 case INDXOUT:
259
260 ulPort = ulBase + *pusCmdStream++;
261 culCount = *pusCmdStream++;
262 ulIndex = *pusCmdStream++;
263
264 while (culCount--) {
265
266 usValue = (USHORT) (ulIndex +
267 (((ULONG)(*pusCmdStream++)) << 8));
268 VideoPortWritePortUshort((PUSHORT)ulPort, usValue);
269
270 ulIndex++;
271
272 }
273
274 break;
275
276 //
277 // Masked out (read, AND, XOR, write)
278 //
279
280 case MASKOUT:
281
282 ulPort = *pusCmdStream++;
283 jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort);
284 jValue &= *pusCmdStream++;
285 jValue ^= *pusCmdStream++;
286 VideoPortWritePortUchar((PUCHAR)ulBase + ulPort,
287 jValue);
288 break;
289
290 //
291 // Attribute Controller out
292 //
293
294 case ATCOUT:
295
296 ulPort = ulBase + *pusCmdStream++;
297 culCount = *pusCmdStream++;
298 ulIndex = *pusCmdStream++;
299
300 while (culCount--) {
301
302 // Write Attribute Controller index
303 VideoPortWritePortUchar((PUCHAR)ulPort,
304 (UCHAR)ulIndex);
305
306 // Write Attribute Controller data
307 jValue = (UCHAR) *pusCmdStream++;
308 VideoPortWritePortUchar((PUCHAR)ulPort, jValue);
309
310 ulIndex++;
311
312 }
313
314 break;
315
316 //
317 // None of the above; error
318 //
319 default:
320
321 return FALSE;
322
323 }
324
325
326 break;
327
328 //
329 // NOP
330 //
331
332 case NCMD:
333
334 break;
335
336 //
337 // Unknown command; error
338 //
339
340 default:
341
342 return FALSE;
343
344 }
345
346 }
347
348 return TRUE;
349
350 } // end VgaInterpretCmdStream()
351
352 \f
353 VP_STATUS
354 VgaSetMode(
355 PHW_DEVICE_EXTENSION HwDeviceExtension,
356 PVIDEO_MODE Mode,
357 ULONG ModeSize,
358 // eVb: 2.2 [SET MODE] - Add new output parameter for framebuffer update functionality
359 PULONG PhysPtrChange
360 // eVb: 2.2 [END]
361 )
362
363 /*++
364
365 Routine Description:
366
367 This routine sets the vga into the requested mode.
368
369 Arguments:
370
371 HwDeviceExtension - Pointer to the miniport driver's device extension.
372
373 Mode - Pointer to the structure containing the information about the
374 font to be set.
375
376 ModeSize - Length of the input buffer supplied by the user.
377
378 Return Value:
379
380 ERROR_INSUFFICIENT_BUFFER if the input buffer was not large enough
381 for the input data.
382
383 ERROR_INVALID_PARAMETER if the mode number is invalid.
384
385 NO_ERROR if the operation completed successfully.
386
387 --*/
388
389 {
390 PVIDEOMODE pRequestedMode;
391 VP_STATUS status;
392 ULONG RequestedModeNum;
393 // eVb: 2.3 [SET MODE] - Add new output parameter for framebuffer update functionality
394 *PhysPtrChange = FALSE;
395 // eVb: 2.3 [END]
396 //
397 // Check if the size of the data in the input buffer is large enough.
398 //
399
400 if (ModeSize < sizeof(VIDEO_MODE))
401 {
402 return ERROR_INSUFFICIENT_BUFFER;
403 }
404
405 //
406 // Extract the clear memory, and map linear bits.
407 //
408
409 RequestedModeNum = Mode->RequestedMode &
410 ~(VIDEO_MODE_NO_ZERO_MEMORY | VIDEO_MODE_MAP_MEM_LINEAR);
411
412
413 if (!(Mode->RequestedMode & VIDEO_MODE_NO_ZERO_MEMORY))
414 {
415 #if defined(_X86_)
416 VgaZeroVideoMemory(HwDeviceExtension);
417 #endif
418 }
419
420 //
421 // Check to see if we are requesting a valid mode
422 //
423 // eVb: 2.4 [CIRRUS] - Remove Cirrus-specific check for valid mode
424 if ( (RequestedModeNum >= NumVideoModes) )
425 // eVb: 2.4 [END]
426 {
427 VideoDebugPrint((0, "Invalide Mode Number = %d!\n", RequestedModeNum));
428
429 return ERROR_INVALID_PARAMETER;
430 }
431
432 VideoDebugPrint((2, "Attempting to set mode %d\n",
433 RequestedModeNum));
434 // eVb: 2.5 [VBE] - Use dynamic VBE mode list instead of hard-coded VGA list
435 pRequestedMode = &VgaModeList[RequestedModeNum];
436 // eVb: 2.5 [END]
437 VideoDebugPrint((2, "Info on Requested Mode:\n"
438 "\tResolution: %dx%d\n",
439 pRequestedMode->hres,
440 pRequestedMode->vres ));
441
442 //
443 // VESA BIOS mode switch
444 //
445 // eVb: 2.6 [VBE] - VBE Mode Switch Support
446 status = VbeSetMode(HwDeviceExtension, pRequestedMode, PhysPtrChange);
447 if (status == ERROR_INVALID_FUNCTION)
448 {
449 //
450 // VGA mode switch
451 //
452
453 if (!pRequestedMode->CmdStream) return ERROR_INVALID_FUNCTION;
454 if (!VgaInterpretCmdStream(HwDeviceExtension, pRequestedMode->CmdStream)) return ERROR_INVALID_FUNCTION;
455 goto Cleanup;
456 }
457 else if (status != NO_ERROR) return status;
458 // eVb: 2.6 [END]
459 // eVb: 2.7 [MODE-X] - Windows VGA Miniport Supports Mode-X, we should too
460 //
461 // ModeX check
462 //
463
464 if (pRequestedMode->hres == 320)
465 {
466 VideoPortDebugPrint(0, "ModeX not support!!!\n");
467 return ERROR_INVALID_PARAMETER;
468 }
469 // eVb: 2.7 [END]
470 //
471 // Text mode check
472 //
473
474 if (!(pRequestedMode->fbType & VIDEO_MODE_GRAPHICS))
475 {
476 // eVb: 2.8 [TODO] - This code path is not implemented yet
477 VideoPortDebugPrint(0, "Text-mode not support!!!\n");
478 return ERROR_INVALID_PARAMETER;
479 // eVb: 2.8 [END]
480 }
481
482 Cleanup:
483 //
484 // Update the location of the physical frame buffer within video memory.
485 //
486 // eVb: 2.9 [VBE] - Linear and banked support is unified in VGA, unlike Cirrus
487 HwDeviceExtension->PhysicalVideoMemoryBase.LowPart = pRequestedMode->PhysBase;
488 HwDeviceExtension->PhysicalVideoMemoryLength = pRequestedMode->PhysSize;
489
490 HwDeviceExtension->PhysicalFrameLength =
491 pRequestedMode->FrameBufferSize;
492
493 HwDeviceExtension->PhysicalFrameOffset.LowPart =
494 pRequestedMode->FrameBufferBase;
495 // eVb: 2.9 [END]
496
497 //
498 // Store the new mode value.
499 //
500
501 HwDeviceExtension->CurrentMode = pRequestedMode;
502 HwDeviceExtension->ModeIndex = Mode->RequestedMode;
503
504 return NO_ERROR;
505
506 } //end VgaSetMode()
507 \f
508 VP_STATUS
509 VgaQueryAvailableModes(
510 PHW_DEVICE_EXTENSION HwDeviceExtension,
511 PVIDEO_MODE_INFORMATION ModeInformation,
512 ULONG ModeInformationSize,
513 PULONG OutputSize
514 )
515
516 /*++
517
518 Routine Description:
519
520 This routine returns the list of all available available modes on the
521 card.
522
523 Arguments:
524
525 HwDeviceExtension - Pointer to the miniport driver's device extension.
526
527 ModeInformation - Pointer to the output buffer supplied by the user.
528 This is where the list of all valid modes is stored.
529
530 ModeInformationSize - Length of the output buffer supplied by the user.
531
532 OutputSize - Pointer to a buffer in which to return the actual size of
533 the data in the buffer. If the buffer was not large enough, this
534 contains the minimum required buffer size.
535
536 Return Value:
537
538 ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
539 for the data being returned.
540
541 NO_ERROR if the operation completed successfully.
542
543 --*/
544
545 {
546 PVIDEO_MODE_INFORMATION videoModes = ModeInformation;
547 ULONG i;
548
549 //
550 // Find out the size of the data to be put in the buffer and return
551 // that in the status information (whether or not the information is
552 // there). If the buffer passed in is not large enough return an
553 // appropriate error code.
554 //
555
556 if (ModeInformationSize < (*OutputSize =
557 // eVb: 2.10 [VBE] - We store VBE/VGA mode count in this global, not in DevExt like Cirrus
558 NumVideoModes *
559 // eVb: 2.10 [END]
560 sizeof(VIDEO_MODE_INFORMATION)) ) {
561
562 return ERROR_INSUFFICIENT_BUFFER;
563
564 }
565
566 //
567 // For each mode supported by the card, store the mode characteristics
568 // in the output buffer.
569 //
570
571 for (i = 0; i < NumVideoModes; i++)
572 {
573 videoModes->Length = sizeof(VIDEO_MODE_INFORMATION);
574 videoModes->ModeIndex = i;
575 // eVb: 2.11 [VBE] - Use dynamic VBE mode list instead of hard-coded VGA list
576 videoModes->VisScreenWidth = VgaModeList[i].hres;
577 videoModes->ScreenStride = VgaModeList[i].wbytes;
578 videoModes->VisScreenHeight = VgaModeList[i].vres;
579 videoModes->NumberOfPlanes = VgaModeList[i].numPlanes;
580 videoModes->BitsPerPlane = VgaModeList[i].bitsPerPlane;
581 videoModes->Frequency = VgaModeList[i].Frequency;
582 videoModes->XMillimeter = 320; // temporary hardcoded constant
583 videoModes->YMillimeter = 240; // temporary hardcoded constant
584 videoModes->AttributeFlags = VgaModeList[i].fbType;
585 // eVb: 2.11 [END]
586
587 if ((VgaModeList[i].bitsPerPlane == 32) ||
588 (VgaModeList[i].bitsPerPlane == 24))
589 {
590
591 videoModes->NumberRedBits = 8;
592 videoModes->NumberGreenBits = 8;
593 videoModes->NumberBlueBits = 8;
594 videoModes->RedMask = 0xff0000;
595 videoModes->GreenMask = 0x00ff00;
596 videoModes->BlueMask = 0x0000ff;
597
598 }
599 else if (VgaModeList[i].bitsPerPlane == 16)
600 {
601
602 videoModes->NumberRedBits = 6;
603 videoModes->NumberGreenBits = 6;
604 videoModes->NumberBlueBits = 6;
605 videoModes->RedMask = 0x1F << 11;
606 videoModes->GreenMask = 0x3F << 5;
607 videoModes->BlueMask = 0x1F;
608
609 }
610 // eVb: 2.12 [VGA] - Add support for 15bpp modes, which Cirrus doesn't support
611 else if (VgaModeList[i].bitsPerPlane == 15)
612 {
613
614 videoModes->NumberRedBits = 6;
615 videoModes->NumberGreenBits = 6;
616 videoModes->NumberBlueBits = 6;
617 videoModes->RedMask = 0x3E << 9;
618 videoModes->GreenMask = 0x1F << 5;
619 videoModes->BlueMask = 0x1F;
620 }
621 // eVb: 2.12 [END]
622 else
623 {
624
625 videoModes->NumberRedBits = 6;
626 videoModes->NumberGreenBits = 6;
627 videoModes->NumberBlueBits = 6;
628 videoModes->RedMask = 0;
629 videoModes->GreenMask = 0;
630 videoModes->BlueMask = 0;
631 }
632
633 // eVb: 2.13 [VGA] - All modes are palette managed/driven, unlike Cirrus
634 videoModes->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN |
635 VIDEO_MODE_MANAGED_PALETTE;
636 // eVb: 2.13 [END]
637 videoModes++;
638
639 }
640
641 return NO_ERROR;
642
643 } // end VgaGetAvailableModes()
644 \f
645 VP_STATUS
646 VgaQueryNumberOfAvailableModes(
647 PHW_DEVICE_EXTENSION HwDeviceExtension,
648 PVIDEO_NUM_MODES NumModes,
649 ULONG NumModesSize,
650 PULONG OutputSize
651 )
652
653 /*++
654
655 Routine Description:
656
657 This routine returns the number of available modes for this particular
658 video card.
659
660 Arguments:
661
662 HwDeviceExtension - Pointer to the miniport driver's device extension.
663
664 NumModes - Pointer to the output buffer supplied by the user. This is
665 where the number of modes is stored.
666
667 NumModesSize - Length of the output buffer supplied by the user.
668
669 OutputSize - Pointer to a buffer in which to return the actual size of
670 the data in the buffer.
671
672 Return Value:
673
674 ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
675 for the data being returned.
676
677 NO_ERROR if the operation completed successfully.
678
679 --*/
680
681 {
682 //
683 // Find out the size of the data to be put in the the buffer and return
684 // that in the status information (whether or not the information is
685 // there). If the buffer passed in is not large enough return an
686 // appropriate error code.
687 //
688
689 if (NumModesSize < (*OutputSize = sizeof(VIDEO_NUM_MODES)) ) {
690
691 return ERROR_INSUFFICIENT_BUFFER;
692
693 }
694
695 //
696 // Store the number of modes into the buffer.
697 //
698
699 // eVb: 2.14 [VBE] - We store VBE/VGA mode count in this global, not in DevExt like Cirrus
700 NumModes->NumModes = NumVideoModes;
701 // eVb: 2.14 [END]
702 NumModes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
703
704 return NO_ERROR;
705
706 } // end VgaGetNumberOfAvailableModes()
707 \f
708 VP_STATUS
709 VgaQueryCurrentMode(
710 PHW_DEVICE_EXTENSION HwDeviceExtension,
711 PVIDEO_MODE_INFORMATION ModeInformation,
712 ULONG ModeInformationSize,
713 PULONG OutputSize
714 )
715
716 /*++
717
718 Routine Description:
719
720 This routine returns a description of the current video mode.
721
722 Arguments:
723
724 HwDeviceExtension - Pointer to the miniport driver's device extension.
725
726 ModeInformation - Pointer to the output buffer supplied by the user.
727 This is where the current mode information is stored.
728
729 ModeInformationSize - Length of the output buffer supplied by the user.
730
731 OutputSize - Pointer to a buffer in which to return the actual size of
732 the data in the buffer. If the buffer was not large enough, this
733 contains the minimum required buffer size.
734
735 Return Value:
736
737 ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
738 for the data being returned.
739
740 NO_ERROR if the operation completed successfully.
741
742 --*/
743
744 {
745 //
746 // check if a mode has been set
747 //
748
749 if (HwDeviceExtension->CurrentMode == NULL ) {
750
751 return ERROR_INVALID_FUNCTION;
752
753 }
754
755 //
756 // Find out the size of the data to be put in the the buffer and return
757 // that in the status information (whether or not the information is
758 // there). If the buffer passed in is not large enough return an
759 // appropriate error code.
760 //
761
762 if (ModeInformationSize < (*OutputSize = sizeof(VIDEO_MODE_INFORMATION))) {
763
764 return ERROR_INSUFFICIENT_BUFFER;
765
766 }
767
768 //
769 // Store the characteristics of the current mode into the buffer.
770 //
771
772 ModeInformation->Length = sizeof(VIDEO_MODE_INFORMATION);
773 ModeInformation->ModeIndex = HwDeviceExtension->ModeIndex;
774 ModeInformation->VisScreenWidth = HwDeviceExtension->CurrentMode->hres;
775 ModeInformation->ScreenStride = HwDeviceExtension->CurrentMode->wbytes;
776 ModeInformation->VisScreenHeight = HwDeviceExtension->CurrentMode->vres;
777 ModeInformation->NumberOfPlanes = HwDeviceExtension->CurrentMode->numPlanes;
778 ModeInformation->BitsPerPlane = HwDeviceExtension->CurrentMode->bitsPerPlane;
779 ModeInformation->Frequency = HwDeviceExtension->CurrentMode->Frequency;
780 ModeInformation->XMillimeter = 320; // temporary hardcoded constant
781 ModeInformation->YMillimeter = 240; // temporary hardcoded constant
782
783 ModeInformation->AttributeFlags = HwDeviceExtension->CurrentMode->fbType;
784
785 if ((ModeInformation->BitsPerPlane == 32) ||
786 (ModeInformation->BitsPerPlane == 24))
787 {
788
789 ModeInformation->NumberRedBits = 8;
790 ModeInformation->NumberGreenBits = 8;
791 ModeInformation->NumberBlueBits = 8;
792 ModeInformation->RedMask = 0xff0000;
793 ModeInformation->GreenMask = 0x00ff00;
794 ModeInformation->BlueMask = 0x0000ff;
795
796 }
797 else if (ModeInformation->BitsPerPlane == 16)
798 {
799
800 ModeInformation->NumberRedBits = 6;
801 ModeInformation->NumberGreenBits = 6;
802 ModeInformation->NumberBlueBits = 6;
803 ModeInformation->RedMask = 0x1F << 11;
804 ModeInformation->GreenMask = 0x3F << 5;
805 ModeInformation->BlueMask = 0x1F;
806
807 }
808 // eVb: 2.12 [VGA] - Add support for 15bpp modes, which Cirrus doesn't support
809 else if (ModeInformation->BitsPerPlane == 15)
810 {
811
812 ModeInformation->NumberRedBits = 6;
813 ModeInformation->NumberGreenBits = 6;
814 ModeInformation->NumberBlueBits = 6;
815 ModeInformation->RedMask = 0x3E << 9;
816 ModeInformation->GreenMask = 0x1F << 5;
817 ModeInformation->BlueMask = 0x1F;
818 }
819 // eVb: 2.12 [END]
820 else
821 {
822
823 ModeInformation->NumberRedBits = 6;
824 ModeInformation->NumberGreenBits = 6;
825 ModeInformation->NumberBlueBits = 6;
826 ModeInformation->RedMask = 0;
827 ModeInformation->GreenMask = 0;
828 ModeInformation->BlueMask = 0;
829 }
830
831 // eVb: 2.13 [VGA] - All modes are palette managed/driven, unlike Cirrus
832 ModeInformation->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN |
833 VIDEO_MODE_MANAGED_PALETTE;
834 // eVb: 2.13 [END]
835
836 return NO_ERROR;
837
838 } // end VgaQueryCurrentMode()
839
840 \f
841 VOID
842 VgaZeroVideoMemory(
843 PHW_DEVICE_EXTENSION HwDeviceExtension
844 )
845
846 /*++
847
848 Routine Description:
849
850 This routine zeros the first 256K on the VGA.
851
852 Arguments:
853
854 HwDeviceExtension - Pointer to the miniport driver's device extension.
855
856
857 Return Value:
858
859 None.
860
861 --*/
862 {
863 UCHAR temp;
864
865 //
866 // Map font buffer at A0000
867 //
868
869 VgaInterpretCmdStream(HwDeviceExtension, EnableA000Data);
870
871 //
872 // Enable all planes.
873 //
874
875 VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_ADDRESS_PORT,
876 IND_MAP_MASK);
877
878 temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
879 SEQ_DATA_PORT) | (UCHAR)0x0F;
880
881 VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_DATA_PORT,
882 temp);
883
884 VideoPortZeroDeviceMemory(HwDeviceExtension->VideoMemoryAddress, 0xFFFF);
885
886 VgaInterpretCmdStream(HwDeviceExtension, DisableA000Color);
887
888 }