|
|
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 et4000 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 "et4000.h"
29: #include "modeset.h"
30:
31: VOID
32: VgaZeroVideoMemory(
33: PHW_DEVICE_EXTENSION HwDeviceExtension
34: );
35:
36:
37: VP_STATUS
38: VgaInterpretCmdStream(
39: PHW_DEVICE_EXTENSION HwDeviceExtension,
40: PUSHORT pusCmdStream
41: )
42:
43: /*++
44:
45: Routine Description:
46:
47: Interprets the appropriate command array to set up VGA registers for the
48: requested mode. Typically used to set the VGA into a particular mode by
49: programming all of the registers
50:
51: Arguments:
52:
53: HwDeviceExtension - Pointer to the miniport driver's device extension.
54:
55: pusCmdStream - array of commands to be interpreted.
56:
57: Return Value:
58:
59: The status of the operation (can only fail on a bad command); TRUE for
60: success, FALSE for failure.
61:
62: --*/
63:
64: {
65: ULONG ulCmd;
66: ULONG ulPort;
67: UCHAR jValue;
68: USHORT usValue;
69: ULONG culCount;
70: ULONG ulIndex;
71: ULONG ulBase;
72:
73: if (pusCmdStream == NULL) {
74:
75: VideoDebugPrint((1, "VgaInterpretCmdStream - Invalid pusCmdStream\n"));
76: return TRUE;
77: }
78:
79: ulBase = (ULONG)HwDeviceExtension->IOAddress;
80:
81: //
82: // Now set the adapter to the desired mode.
83: //
84:
85: while ((ulCmd = *pusCmdStream++) != EOD) {
86:
87: //
88: // Determine major command type
89: //
90:
91: switch (ulCmd & 0xF0) {
92:
93: //
94: // Basic input/output command
95: //
96:
97: case INOUT:
98:
99: //
100: // Determine type of inout instruction
101: //
102:
103: if (!(ulCmd & IO)) {
104:
105: //
106: // Out instruction. Single or multiple outs?
107: //
108:
109: if (!(ulCmd & MULTI)) {
110:
111: //
112: // Single out. Byte or word out?
113: //
114:
115: if (!(ulCmd & BW)) {
116:
117: //
118: // Single byte out
119: //
120:
121: ulPort = *pusCmdStream++;
122: jValue = (UCHAR) *pusCmdStream++;
123: VideoPortWritePortUchar((PUCHAR)(ulBase+ulPort),
124: jValue);
125:
126: } else {
127:
128: //
129: // Single word out
130: //
131:
132: ulPort = *pusCmdStream++;
133: usValue = *pusCmdStream++;
134: VideoPortWritePortUshort((PUSHORT)(ulBase+ulPort),
135: usValue);
136:
137: }
138:
139: } else {
140:
141: //
142: // Output a string of values
143: // Byte or word outs?
144: //
145:
146: if (!(ulCmd & BW)) {
147:
148: //
149: // String byte outs. Do in a loop; can't use
150: // VideoPortWritePortBufferUchar because the data
151: // is in USHORT form
152: //
153:
154: ulPort = ulBase + *pusCmdStream++;
155: culCount = *pusCmdStream++;
156:
157: while (culCount--) {
158: jValue = (UCHAR) *pusCmdStream++;
159: VideoPortWritePortUchar((PUCHAR)ulPort,
160: jValue);
161:
162: }
163:
164: } else {
165:
166: //
167: // String word outs
168: //
169:
170: ulPort = *pusCmdStream++;
171: culCount = *pusCmdStream++;
172: VideoPortWritePortBufferUshort((PUSHORT)
173: (ulBase + ulPort), pusCmdStream, culCount);
174: pusCmdStream += culCount;
175:
176: }
177: }
178:
179: } else {
180:
181: // In instruction
182: //
183: // Currently, string in instructions aren't supported; all
184: // in instructions are handled as single-byte ins
185: //
186: // Byte or word in?
187: //
188:
189: if (!(ulCmd & BW)) {
190: //
191: // Single byte in
192: //
193:
194: ulPort = *pusCmdStream++;
195: jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort);
196:
197: } else {
198:
199: //
200: // Single word in
201: //
202:
203: ulPort = *pusCmdStream++;
204: usValue = VideoPortReadPortUshort((PUSHORT)
205: (ulBase+ulPort));
206:
207: }
208:
209: }
210:
211: break;
212:
213: //
214: // Higher-level input/output commands
215: //
216:
217: case METAOUT:
218:
219: //
220: // Determine type of metaout command, based on minor
221: // command field
222: //
223: switch (ulCmd & 0x0F) {
224:
225: //
226: // Indexed outs
227: //
228:
229: case INDXOUT:
230:
231: ulPort = ulBase + *pusCmdStream++;
232: culCount = *pusCmdStream++;
233: ulIndex = *pusCmdStream++;
234:
235: while (culCount--) {
236:
237: usValue = (USHORT) (ulIndex +
238: (((ULONG)(*pusCmdStream++)) << 8));
239: VideoPortWritePortUshort((PUSHORT)ulPort, usValue);
240:
241: ulIndex++;
242:
243: }
244:
245: break;
246:
247: //
248: // Masked out (read, AND, XOR, write)
249: //
250:
251: case MASKOUT:
252:
253: ulPort = *pusCmdStream++;
254: jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort);
255: jValue &= *pusCmdStream++;
256: jValue ^= *pusCmdStream++;
257: VideoPortWritePortUchar((PUCHAR)ulBase + ulPort,
258: jValue);
259: break;
260:
261: //
262: // Attribute Controller out
263: //
264:
265: case ATCOUT:
266:
267: ulPort = ulBase + *pusCmdStream++;
268: culCount = *pusCmdStream++;
269: ulIndex = *pusCmdStream++;
270:
271: while (culCount--) {
272:
273: // Write Attribute Controller index
274: VideoPortWritePortUchar((PUCHAR)ulPort,
275: (UCHAR)ulIndex);
276:
277: // Write Attribute Controller data
278: jValue = (UCHAR) *pusCmdStream++;
279: VideoPortWritePortUchar((PUCHAR)ulPort, jValue);
280:
281: ulIndex++;
282:
283: }
284:
285: break;
286:
287: //
288: // None of the above; error
289: //
290: default:
291:
292: return FALSE;
293:
294: }
295:
296:
297: break;
298:
299: //
300: // NOP
301: //
302:
303: case NCMD:
304:
305: break;
306:
307: //
308: // Unknown command; error
309: //
310:
311: default:
312:
313: return FALSE;
314:
315: }
316:
317: }
318:
319: return TRUE;
320:
321: } // end VgaInterpretCmdStream()
322:
323:
324: VP_STATUS
325: VgaSetMode(
326: PHW_DEVICE_EXTENSION HwDeviceExtension,
327: PVIDEO_MODE Mode,
328: ULONG ModeSize
329: )
330:
331: /*++
332:
333: Routine Description:
334:
335: This routine sets the vga into the requested mode.
336:
337: Arguments:
338:
339: HwDeviceExtension - Pointer to the miniport driver's device extension.
340:
341: Mode - Pointer to the structure containing the information about the
342: font to be set.
343:
344: ModeSize - Length of the input buffer supplied by the user.
345:
346: Return Value:
347:
348: ERROR_INSUFFICIENT_BUFFER if the input buffer was not large enough
349: for the input data.
350:
351: ERROR_INVALID_PARAMETER if the mode number is invalid.
352:
353: NO_ERROR if the operation completed successfully.
354:
355: --*/
356:
357: {
358:
359: PVIDEOMODE pRequestedMode;
360: VP_STATUS status;
361: USHORT usDataSet, usTemp, usDataClr;
362:
363: //
364: // Check if the size of the data in the input buffer is large enough.
365: //
366:
367: if (ModeSize < sizeof(VIDEO_MODE)) {
368:
369: return ERROR_INSUFFICIENT_BUFFER;
370:
371: }
372:
373: //
374: // Extract the clear memory bit.
375: //
376:
377: if (Mode->RequestedMode & VIDEO_MODE_NO_ZERO_MEMORY) {
378:
379: Mode->RequestedMode &= ~VIDEO_MODE_NO_ZERO_MEMORY;
380:
381: } else {
382:
383: VgaZeroVideoMemory(HwDeviceExtension);
384:
385: }
386:
387: //
388: // Check to see if we are requesting a valid mode
389: //
390:
391: if ( (Mode->RequestedMode >= NumVideoModes) ||
392: (!ModesVGA[Mode->RequestedMode].ValidMode) ) {
393:
394: return ERROR_INVALID_PARAMETER;
395:
396: }
397:
398: pRequestedMode = &ModesVGA[Mode->RequestedMode];
399:
400: #ifdef INT10_MODE_SET
401: {
402: PUSHORT pBios;
403: VIDEO_X86_BIOS_ARGUMENTS biosArguments;
404:
405: //
406: // If this is our first int10, then force an int10 so we can write to the
407: // "virtual" BIOS area of the server process.
408: //
409:
410: if (HwDeviceExtension->BiosArea == NULL) {
411:
412: VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS));
413: biosArguments.Eax = 0x03;
414:
415: status = VideoPortInt10(HwDeviceExtension, &biosArguments);
416:
417: }
418:
419: //
420: // Get the BiosData area value and save the original value.
421: //
422:
423: if (!HwDeviceExtension->BiosArea) {
424:
425: switch (HwDeviceExtension->BoardID) {
426:
427: case PRODESIGNERIIS:
428:
429: HwDeviceExtension->BiosArea = (PUSHORT)PRODESIGNER_BIOS_INFO;
430:
431: break;
432:
433: case SPEEDSTAR:
434: case SPEEDSTARPLUS:
435: case SPEEDSTAR24:
436: case OTHER:
437: default:
438:
439: HwDeviceExtension->BiosArea = (PUSHORT)BIOS_INFO_1;
440:
441: break;
442: }
443:
444: HwDeviceExtension->OriginalBiosData = *HwDeviceExtension->BiosArea;
445: }
446:
447: pBios = HwDeviceExtension->BiosArea;
448:
449: //
450: // Set the refresh rates for the various boards
451: //
452:
453: switch(HwDeviceExtension->BoardID) {
454:
455: case SPEEDSTAR:
456: case SPEEDSTARPLUS:
457: case SPEEDSTAR24:
458:
459: switch (pRequestedMode->hres) {
460:
461: case 640:
462: if (pRequestedMode->Frequency == 72)
463: usDataSet = 2;
464: else usDataSet = 1;
465: break;
466:
467: case 800:
468: if (pRequestedMode->Frequency == 72)
469: usDataSet = 2;
470: else if (pRequestedMode->Frequency == 56)
471: usDataSet = 1;
472: else usDataSet = 3;
473: break;
474:
475: case 1024:
476: if (pRequestedMode->Frequency == 70)
477: usDataSet = 4;
478: else if (pRequestedMode->Frequency == 45)
479: usDataSet = 1;
480: else usDataSet = 2;
481: break;
482:
483: default:
484: usDataSet = 1;
485: break;
486:
487: }
488:
489: //
490: // now we got to unlock the CRTC extension registers!?!
491: //
492:
493: UnlockET4000ExtendedRegs(HwDeviceExtension);
494:
495: if (HwDeviceExtension->BoardID == SPEEDSTAR24) {
496:
497: //
498: // SpeedSTAR 24 uses 31.0 for LSB select CRTC.31 and read it
499: //
500:
501: VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
502: CRTC_ADDRESS_PORT_COLOR, 0x31);
503:
504: usTemp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
505: CRTC_DATA_PORT_COLOR) & ~0x01;
506:
507: //
508: // CRTC.31 bit 0 is the LSB of the monitor type on SpeedSTAR 24
509: //
510:
511: usTemp |= (usDataSet&1);
512: VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
513: CRTC_DATA_PORT_COLOR, (UCHAR)usTemp);
514:
515: } else { // SpeedSTAR and SpeedSTAR Plus use 37.4 for LSB
516:
517: //
518: // select CRTC.37 and read it
519: //
520:
521: VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
522: CRTC_ADDRESS_PORT_COLOR, 0x37);
523:
524: usTemp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
525: CRTC_DATA_PORT_COLOR) & ~0x10;
526:
527: //
528: // CRTC.37 bit 4 is the LSB of the monitor type on SpeedSTAR PLUS
529: //
530:
531: usTemp |= (usDataSet&1)<<4;
532: VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
533: CRTC_DATA_PORT_COLOR, (UCHAR)usTemp);
534: }
535:
536: LockET4000ExtendedRegs(HwDeviceExtension);
537:
538: //
539: // these two bits are the rest of the monitor type...
540: //
541:
542: usTemp = *pBios & ~0x6000;
543: usTemp |= (usDataSet&6)<<12;
544: *pBios |= usTemp;
545:
546: break;
547:
548: case PRODESIGNERIIS:
549:
550: switch (pRequestedMode->hres) {
551:
552: case 640:
553:
554: //
555: // Bit 0: 1=72Hz 0=60Hz
556: //
557:
558: if (pRequestedMode->Frequency == 72) {
559:
560: usDataSet = 0x0001;
561:
562: } else { // 60 Hz
563:
564: usDataSet = 0x0000;
565:
566: }
567:
568: break;
569:
570:
571: case 800:
572:
573: //
574: // Bit 1-2: 10=72Hz 01=60Hz 00=56Hz
575: //
576:
577: if (pRequestedMode->Frequency == 72) {
578:
579: usDataSet = 0x0004;
580:
581: } else {
582:
583: if (pRequestedMode->Frequency == 56) {
584:
585: usDataSet = 0x0000;
586:
587: } else { // 60 Hz
588:
589: usDataSet = 0x0002;
590:
591: }
592: }
593:
594: break;
595:
596:
597: case 1024:
598:
599: //
600: // Bit 3-4: 10=70Hz 01=60Hz 00=45Hz
601: //
602:
603: if (pRequestedMode->Frequency == 70) {
604:
605: usDataSet = 0x0010;
606:
607: } else {
608:
609: if (pRequestedMode->Frequency == 45) {
610:
611: usDataSet = 0x0000;
612:
613: } else { // 60 Hz
614:
615: usDataSet = 0x0008;
616:
617: }
618: }
619:
620: break;
621:
622: // case 1280
623:
624: //
625: // Bit 5 1=45Hz 0=43 Hz
626: //
627:
628:
629: default:
630:
631: //
632: // Reset for DOS modes
633: //
634:
635: usDataSet = HwDeviceExtension->OriginalBiosData;
636:
637: break;
638:
639: }
640:
641: *pBios = usDataSet;
642:
643: break;
644:
645:
646: case OTHER:
647: default:
648:
649: switch (pRequestedMode->hres) {
650:
651: case 640:
652:
653: if (pRequestedMode->Frequency == 72) {
654:
655: usDataSet = 0x0040; // set bit 6
656: usDataClr = (USHORT)~0; // no bits to be cleared
657:
658: } else { // 60 Hz
659:
660: usDataSet = 0; // no bits to set
661: usDataClr = (USHORT)~0x0040; // clear bit 6
662:
663: }
664:
665: break;
666:
667:
668: case 800:
669:
670: if (pRequestedMode->Frequency == 72) {
671:
672: usDataSet = 0x4020; // set bits 5 and 14
673: usDataClr = (USHORT)~0; // no bits to clear
674:
675: } else {
676:
677: if (pRequestedMode->Frequency == 56) {
678:
679: usDataSet = 0x4000; // set bit 14
680: usDataClr = (USHORT)~0x0020; // clr bit 5
681:
682: } else { // 60 Hz
683:
684: usDataSet = 0; // no bits to set
685: usDataClr = (USHORT)~0x4020; // clr bits 5 and 14
686:
687: }
688: }
689:
690: break;
691:
692:
693: case 1024:
694:
695: if (pRequestedMode->Frequency == 70) {
696:
697: usDataSet = 0x2010; // set bits 4 and 13
698: usDataClr = (USHORT)~0; // no bits to clear
699:
700: } else {
701:
702: if (pRequestedMode->Frequency == 45) { //interlaced
703:
704: usDataSet = 0; // no bits to set
705: usDataClr = (USHORT)~0x2010; // clear bits 4 and 13
706:
707: } else { // 60 Hz
708:
709: usDataSet = 0x2000; // set bit 13
710: usDataClr = (USHORT)~0x0010; // clear bit 4
711:
712: }
713: }
714:
715: break;
716:
717: default:
718:
719: //
720: // Restore to original Value
721: //
722:
723: usDataSet = HwDeviceExtension->OriginalBiosData;
724: usDataClr = 0x0000;
725:
726: break;
727:
728: }
729:
730: *pBios &= usDataClr;
731: *pBios |= usDataSet;
732:
733: break;
734:
735: }
736:
737: VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS));
738:
739: biosArguments.Eax = pRequestedMode->Int10ModeNumber;
740:
741: status = VideoPortInt10(HwDeviceExtension, &biosArguments);
742:
743: if (status != NO_ERROR) {
744:
745: return status;
746:
747: }
748:
749: //
750: // If this is a 16bpp mode, call the bios to switch it from
751: // 8bpp to 16bpp.
752: //
753:
754: if (pRequestedMode->bitsPerPlane == 16) {
755:
756: VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS));
757:
758: biosArguments.Eax = 0x10F0;
759: biosArguments.Ebx = pRequestedMode->Int10ModeNumber;
760:
761: status = VideoPortInt10(HwDeviceExtension, &biosArguments);
762:
763: if (status != NO_ERROR) {
764:
765: return status;
766:
767: }
768: }
769:
770: if (pRequestedMode->hres >= 800) {
771: VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
772: SEGMENT_SELECT_PORT,0);
773: }
774:
775: if (pRequestedMode->CmdStrings != NULL) {
776: VgaInterpretCmdStream(HwDeviceExtension, pRequestedMode->CmdStrings);
777: }
778:
779: //
780: // Reset the Bios Value to the default so DOS modes will work.
781: //
782:
783: *pBios = HwDeviceExtension->OriginalBiosData;
784: }
785:
786: {
787: UCHAR temp;
788: UCHAR dummy;
789: UCHAR bIsColor;
790:
791: if (!(pRequestedMode->fbType & VIDEO_MODE_GRAPHICS)) {
792:
793: //
794: // Fix to make sure we always set the colors in text mode to be
795: // intensity, and not flashing
796: // For this zero out the Mode Control Regsiter bit 3 (index 0x10
797: // of the Attribute controller).
798: //
799:
800: if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
801: MISC_OUTPUT_REG_READ_PORT) & 0x01) {
802:
803: bIsColor = TRUE;
804:
805: } else {
806:
807: bIsColor = FALSE;
808:
809: }
810:
811: if (bIsColor) {
812:
813: dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
814: INPUT_STATUS_1_COLOR);
815: } else {
816:
817: dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
818: INPUT_STATUS_1_MONO);
819: }
820:
821: VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
822: ATT_ADDRESS_PORT, (0x10 | VIDEO_ENABLE));
823: temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
824: ATT_DATA_READ_PORT);
825:
826: temp &= 0xF7;
827:
828: if (bIsColor) {
829:
830: dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
831: INPUT_STATUS_1_COLOR);
832: } else {
833:
834: dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
835: INPUT_STATUS_1_MONO);
836: }
837:
838: VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
839: ATT_ADDRESS_PORT, (0x10 | VIDEO_ENABLE));
840: VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
841: ATT_DATA_WRITE_PORT, temp);
842: }
843: }
844:
845: #else
846: VgaInterpretCmdStream(HwDeviceExtension, pRequestedMode->CmdStrings);
847: #endif
848:
849: //
850: // Update the location of the physical frame buffer within video memory.
851: //
852:
853: HwDeviceExtension->PhysicalFrameLength =
854: MemoryMaps[pRequestedMode->MemMap].MaxSize;
855:
856: HwDeviceExtension->PhysicalFrameBase.LowPart =
857: MemoryMaps[pRequestedMode->MemMap].Start;
858:
859: //
860: // Store the new mode value.
861: //
862:
863: HwDeviceExtension->CurrentMode = pRequestedMode;
864: HwDeviceExtension->ModeIndex = Mode->RequestedMode;
865:
866: return NO_ERROR;
867:
868: } //end VgaSetMode()
869:
870:
871: VP_STATUS
872: VgaQueryAvailableModes(
873: PHW_DEVICE_EXTENSION HwDeviceExtension,
874: PVIDEO_MODE_INFORMATION ModeInformation,
875: ULONG ModeInformationSize,
876: PULONG OutputSize
877: )
878:
879: /*++
880:
881: Routine Description:
882:
883: This routine returns the list of all available available modes on the
884: card.
885:
886: Arguments:
887:
888: HwDeviceExtension - Pointer to the miniport driver's device extension.
889:
890: ModeInformation - Pointer to the output buffer supplied by the user.
891: This is where the list of all valid modes is stored.
892:
893: ModeInformationSize - Length of the output buffer supplied by the user.
894:
895: OutputSize - Pointer to a buffer in which to return the actual size of
896: the data in the buffer. If the buffer was not large enough, this
897: contains the minimum required buffer size.
898:
899: Return Value:
900:
901: ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
902: for the data being returned.
903:
904: NO_ERROR if the operation completed successfully.
905:
906: --*/
907:
908: {
909: PVIDEO_MODE_INFORMATION videoModes = ModeInformation;
910: ULONG i;
911:
912: //
913: // Find out the size of the data to be put in the buffer and return
914: // that in the status information (whether or not the information is
915: // there). If the buffer passed in is not large enough return an
916: // appropriate error code.
917: //
918:
919: if (ModeInformationSize < (*OutputSize =
920: HwDeviceExtension->NumAvailableModes *
921: sizeof(VIDEO_MODE_INFORMATION)) ) {
922:
923: return ERROR_INSUFFICIENT_BUFFER;
924:
925: }
926:
927: //
928: // For each mode supported by the card, store the mode characteristics
929: // in the output buffer.
930: //
931:
932: for (i = 0; i < NumVideoModes; i++) {
933:
934: if (ModesVGA[i].ValidMode) {
935:
936: videoModes->Length = sizeof(VIDEO_MODE_INFORMATION);
937: videoModes->ModeIndex = i;
938: videoModes->VisScreenWidth = ModesVGA[i].hres;
939: videoModes->ScreenStride = ModesVGA[i].wbytes;
940: videoModes->VisScreenHeight = ModesVGA[i].vres;
941: videoModes->NumberOfPlanes = ModesVGA[i].numPlanes;
942: videoModes->BitsPerPlane = ModesVGA[i].bitsPerPlane;
943: videoModes->Frequency = ModesVGA[i].Frequency;
944: videoModes->XMillimeter = 330; // temporary hardcoded constant
945: videoModes->YMillimeter = 240; // temporary hardcoded constant
946: videoModes->NumberRedBits = 6;
947: videoModes->NumberGreenBits = 6;
948: videoModes->NumberBlueBits = 6;
949: videoModes->AttributeFlags = ModesVGA[i].fbType;
950: videoModes->AttributeFlags |= ModesVGA[i].Interlaced ?
951: VIDEO_MODE_INTERLACED : 0;
952:
953: if (ModesVGA[i].bitsPerPlane == 16) {
954:
955: videoModes->RedMask = 0x7c00;
956: videoModes->GreenMask = 0x03e0;
957: videoModes->BlueMask = 0x001f;
958:
959: } else {
960:
961: videoModes->RedMask = 0;
962: videoModes->GreenMask = 0;
963: videoModes->BlueMask = 0;
964: videoModes->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN |
965: VIDEO_MODE_MANAGED_PALETTE;
966: }
967:
968: videoModes++;
969:
970: }
971: }
972:
973: return NO_ERROR;
974:
975: } // end VgaGetAvailableModes()
976:
977: VP_STATUS
978: VgaQueryNumberOfAvailableModes(
979: PHW_DEVICE_EXTENSION HwDeviceExtension,
980: PVIDEO_NUM_MODES NumModes,
981: ULONG NumModesSize,
982: PULONG OutputSize
983: )
984:
985: /*++
986:
987: Routine Description:
988:
989: This routine returns the number of available modes for this particular
990: video card.
991:
992: Arguments:
993:
994: HwDeviceExtension - Pointer to the miniport driver's device extension.
995:
996: NumModes - Pointer to the output buffer supplied by the user. This is
997: where the number of modes is stored.
998:
999: NumModesSize - Length of the output buffer supplied by the user.
1000:
1001: OutputSize - Pointer to a buffer in which to return the actual size of
1002: the data in the buffer.
1003:
1004: Return Value:
1005:
1006: ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
1007: for the data being returned.
1008:
1009: NO_ERROR if the operation completed successfully.
1010:
1011: --*/
1012:
1013: {
1014: //
1015: // Find out the size of the data to be put in the the buffer and return
1016: // that in the status information (whether or not the information is
1017: // there). If the buffer passed in is not large enough return an
1018: // appropriate error code.
1019: //
1020:
1021: if (NumModesSize < (*OutputSize = sizeof(VIDEO_NUM_MODES)) ) {
1022:
1023: return ERROR_INSUFFICIENT_BUFFER;
1024:
1025: }
1026:
1027: //
1028: // Store the number of modes into the buffer.
1029: //
1030:
1031: NumModes->NumModes = HwDeviceExtension->NumAvailableModes;
1032: NumModes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
1033:
1034: return NO_ERROR;
1035:
1036: } // end VgaGetNumberOfAvailableModes()
1037:
1038: VP_STATUS
1039: VgaQueryCurrentMode(
1040: PHW_DEVICE_EXTENSION HwDeviceExtension,
1041: PVIDEO_MODE_INFORMATION ModeInformation,
1042: ULONG ModeInformationSize,
1043: PULONG OutputSize
1044: )
1045:
1046: /*++
1047:
1048: Routine Description:
1049:
1050: This routine returns a description of the current video mode.
1051:
1052: Arguments:
1053:
1054: HwDeviceExtension - Pointer to the miniport driver's device extension.
1055:
1056: ModeInformation - Pointer to the output buffer supplied by the user.
1057: This is where the current mode information is stored.
1058:
1059: ModeInformationSize - Length of the output buffer supplied by the user.
1060:
1061: OutputSize - Pointer to a buffer in which to return the actual size of
1062: the data in the buffer. If the buffer was not large enough, this
1063: contains the minimum required buffer size.
1064:
1065: Return Value:
1066:
1067: ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
1068: for the data being returned.
1069:
1070: NO_ERROR if the operation completed successfully.
1071:
1072: --*/
1073:
1074: {
1075: //
1076: // Find out the size of the data to be put in the the buffer and return
1077: // that in the status information (whether or not the information is
1078: // there). If the buffer passed in is not large enough return an
1079: // appropriate error code.
1080: //
1081:
1082: if (ModeInformationSize < (*OutputSize = sizeof(VIDEO_MODE_INFORMATION))) {
1083:
1084: return ERROR_INSUFFICIENT_BUFFER;
1085:
1086: }
1087:
1088: //
1089: // Store the characteristics of the current mode into the buffer.
1090: //
1091:
1092: ModeInformation->Length = sizeof(VIDEO_MODE_INFORMATION);
1093: ModeInformation->ModeIndex = HwDeviceExtension->ModeIndex;
1094: ModeInformation->VisScreenWidth = HwDeviceExtension->CurrentMode->hres;
1095: ModeInformation->ScreenStride = HwDeviceExtension->CurrentMode->wbytes;
1096: ModeInformation->VisScreenHeight = HwDeviceExtension->CurrentMode->vres;
1097: ModeInformation->NumberOfPlanes = HwDeviceExtension->CurrentMode->numPlanes;
1098: ModeInformation->BitsPerPlane = HwDeviceExtension->CurrentMode->bitsPerPlane;
1099: ModeInformation->Frequency = HwDeviceExtension->CurrentMode->Frequency;
1100: ModeInformation->XMillimeter = 330; // temporary hardcoded constant
1101: ModeInformation->YMillimeter = 240; // temporary hardcoded constant
1102: ModeInformation->NumberRedBits = 6;
1103: ModeInformation->NumberGreenBits = 6;
1104: ModeInformation->NumberBlueBits = 6;
1105: ModeInformation->RedMask = 0;
1106: ModeInformation->GreenMask = 0;
1107: ModeInformation->BlueMask = 0;
1108: ModeInformation->AttributeFlags = HwDeviceExtension->CurrentMode->fbType |
1109: VIDEO_MODE_PALETTE_DRIVEN | VIDEO_MODE_MANAGED_PALETTE;
1110: ModeInformation->AttributeFlags |= HwDeviceExtension->CurrentMode->Interlaced ?
1111: VIDEO_MODE_INTERLACED : 0;
1112:
1113: return NO_ERROR;
1114:
1115: } // end VgaQueryCurrentMode()
1116:
1117:
1118: VOID
1119: VgaZeroVideoMemory(
1120: PHW_DEVICE_EXTENSION HwDeviceExtension
1121: )
1122:
1123: /*++
1124:
1125: Routine Description:
1126:
1127: This routine zeros the first 256K on the VGA.
1128:
1129: Arguments:
1130:
1131: HwDeviceExtension - Pointer to the miniport driver's device extension.
1132:
1133:
1134: Return Value:
1135:
1136: None.
1137:
1138: --*/
1139: {
1140: UCHAR temp;
1141:
1142: //
1143: // Map font buffer at A0000
1144: //
1145:
1146: VgaInterpretCmdStream(HwDeviceExtension, EnableA000Data);
1147:
1148: //
1149: // Enable all planes.
1150: //
1151: VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_ADDRESS_PORT,
1152: IND_MAP_MASK);
1153:
1154: temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
1155: SEQ_DATA_PORT) | (UCHAR)0x0F;
1156:
1157: VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_DATA_PORT,
1158: temp);
1159:
1160: //
1161: // Zero the memory.
1162: //
1163:
1164: VideoPortZeroMemory(HwDeviceExtension->VideoMemoryAddress,
1165: 0xFFFF);
1166:
1167: VgaInterpretCmdStream(HwDeviceExtension, DisableA000Color);
1168:
1169: }
1170:
1171:
1172: VOID
1173: VgaValidateModes(
1174: PHW_DEVICE_EXTENSION HwDeviceExtension
1175: )
1176:
1177: /*++
1178:
1179: Routine Description:
1180:
1181: Determines which modes are valid and which are not.
1182:
1183: Arguments:
1184:
1185: HwDeviceExtension - Pointer to the miniport driver's device extension.
1186:
1187: Return Value:
1188:
1189: None.
1190:
1191: --*/
1192: {
1193:
1194: ULONG i;
1195:
1196: HwDeviceExtension->NumAvailableModes = 0;
1197:
1198: for (i = 0; i < NumVideoModes; i++) {
1199:
1200: if (HwDeviceExtension->AdapterMemorySize >=
1201: ModesVGA[i].numPlanes * ModesVGA[i].sbytes) {
1202:
1203: ModesVGA[i].ValidMode = TRUE;
1204: HwDeviceExtension->NumAvailableModes++;
1205:
1206: }
1207: }
1208: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.