Changeset 3267 in vbox
- Timestamp:
- Jun 25, 2007 9:22:21 AM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 22329
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/xgraphics/vboxvideo.c
r3247 r3267 55 55 #define DEBUG_VERB 2 56 56 57 #ifdef XORG_7X 58 # ifdef XFree86LOADER 59 # include "xorg-server.h" 60 # else 61 # ifdef HAVE_CONFIG_H 62 # include "config.h" 63 # endif 57 #ifdef XFree86LOADER 58 # include "xorg-server.h" 59 #else 60 # ifdef HAVE_CONFIG_H 61 # include "config.h" 64 62 # endif 65 63 #endif … … 126 124 */ 127 125 128 #ifdef XORG_7X129 126 _X_EXPORT DriverRec VBOXDRV = { 130 #else131 DriverRec VBOXDRV = {132 #endif133 127 VBOX_VERSION, 134 128 VBOX_DRIVER_NAME, … … 137 131 VBOXAvailableOptions, 138 132 NULL, 139 #ifdef XORG_7X140 133 0, 141 134 NULL 142 #else143 0144 #endif145 135 }; 146 136 … … 158 148 159 149 typedef enum { 160 OPTION_SHADOW_FB 161 #ifdef XORG_7X 162 , 150 OPTION_SHADOW_FB, 163 151 OPTION_DFLT_REFRESH, 164 152 OPTION_MODESET_CLEAR_SCREEN 165 #endif166 153 } VBOXOpts; 167 154 … … 191 178 192 179 static const char *vbeSymbols[] = { 193 #ifdef XORG_7X194 180 "VBEExtendedInit", 195 181 "VBEFindSupportedDepths", 196 #else /* !XORG_7X */197 "VBEFreeModeInfo",198 #endif /* XORG_7X */199 182 "VBEGetModeInfo", 200 183 "VBEGetVBEInfo", 201 184 "VBEGetVBEMode", 202 #ifdef XORG_7X203 185 "VBEPrintModes", 204 #else /* !XORG_7X */205 "VBEInit",206 #endif /* XORG_7X */207 186 "VBESaveRestore", 208 187 "VBESetDisplayStart", … … 210 189 "VBESetGetLogicalScanlineLength", 211 190 "VBESetGetPaletteData", 212 #ifdef XORG_7X213 191 "VBESetModeNames", 214 192 "VBESetModeParameters", 215 #endif216 193 "VBESetVBEMode", 217 #ifdef XORG_7X218 194 "VBEValidateModes", 219 #endif220 195 "vbeDoEDID", 221 196 "vbeFree", … … 239 214 MODINFOSTRING1, 240 215 MODINFOSTRING2, 241 #ifdef XORG_7X242 216 XORG_VERSION_CURRENT, 243 #else /* !XORG_7X */244 XF86_VERSION_CURRENT,245 #endif /* XORG_7X */246 217 1, /* Module major version. Xorg-specific */ 247 218 0, /* Module minor version. Xorg-specific */ 248 #ifdef XORG_7X249 219 1, /* Module patchlevel. Xorg-specific */ 250 #else251 0, /* Module patchlevel. Xorg-specific */252 #endif253 220 ABI_CLASS_VIDEODRV, /* This is a video driver */ 254 221 ABI_VIDEODRV_VERSION, … … 261 228 * followed by "ModuleData". 262 229 */ 263 #ifdef XORG_7X264 230 _X_EXPORT XF86ModuleData vboxvideoModuleData = { &vboxVersionRec, vboxSetup, NULL }; 265 #else /* !XORG_7X */266 XF86ModuleData vboxvideoModuleData = { &vboxVersionRec, vboxSetup, NULL };267 #endif /* XORG_7X */268 231 269 232 static pointer … … 576 539 /* VBox does only support screen widths which are a multiple of 8 */ 577 540 m->HDisplay = (x + 7) & ~7; 541 m->HSyncStart = m->HDisplay + 2; 542 m->HSyncEnd = m->HDisplay + 4; 543 m->HTotal = m->HDisplay + 6; 578 544 m->VDisplay = y; 545 m->VSyncStart = m->VDisplay + 2; 546 m->VSyncEnd = m->VDisplay + 4; 547 m->VTotal = m->VDisplay + 6; 548 m->Clock = m->HTotal * m->VTotal * 60 / 1000000; 579 549 m->name = strdup(pScrn->display->modes[i]); 580 550 if (!m_prev) … … 651 621 /* We make use of the X11 VBE code to save and restore text mode, in 652 622 order to keep our code simple. */ 653 #ifdef XORG_7X654 623 if ((pVBox->pVbe = VBEExtendedInit(NULL, pVBox->pEnt->index, 655 624 SET_BIOS_SCRATCH 656 625 | RESTORE_BIOS_SCRATCH)) == NULL) 657 #else658 if ((pVBox->pVbe = VBEInit(NULL, pVBox->pEnt->index)) == NULL)659 #endif660 626 return (FALSE); 661 627 … … 681 647 return FALSE; 682 648 683 #ifdef XORG_7X684 649 /* set the viewport */ 685 650 VBOXAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); … … 687 652 /* Blank the screen for aesthetic reasons. */ 688 653 VBOXSaveScreen(pScreen, SCREEN_SAVER_ON); 689 #endif690 654 691 655 /* mi layer - reset the visual list (?)*/ … … 775 739 if (!VBOXSetMode(pScrn, pScrn->currentMode)) 776 740 return FALSE; 777 #ifdef XORG_7X778 741 VBOXAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); 779 #endif /* XORG_7X defined */780 742 if (pVBox->useVbva == TRUE) 781 743 vboxEnableVbva(pScrn); … … 804 766 if (pScrn->vtSema) { 805 767 VBOXSaveRestore(xf86Screens[scrnIndex], MODE_RESTORE); 806 #ifdef XORG_7X807 768 if (pVBox->savedPal) 808 769 VBESetGetPaletteData(pVBox->pVbe, TRUE, 0, 256, 809 770 pVBox->savedPal, FALSE, TRUE); 810 #else811 VBESetGetPaletteData(pVBox->pVbe, TRUE, 0, 256,812 pVBox->savedPal, FALSE, TRUE);813 #endif814 771 VBOXUnmapVidMem(pScrn); 815 772 } … … 828 785 * Quoted from "How to add an (S)VGA driver to XFree86" 829 786 * (http://www.xfree86.org/3.3.6/VGADriver.html): 830 * 787 * 831 788 * The ValidMode() function is required. It is used to check for any 832 789 * chipset-dependent reasons why a graphics mode might not be valid. It gets … … 834 791 * no special checking will be required and this function will simply return 835 792 * TRUE always. 793 * 794 * Note: we check here that our generated video modes fulfil the X server's 795 * criteria for the monitor, since this can otherwise cause problems in 796 * randr 1.2. 836 797 */ 837 798 static ModeStatus … … 841 802 ScrnInfoPtr pScrn = xf86Screens[scrn]; 842 803 MonPtr mon = pScrn->monitor; 843 ModeStatus ret ;804 ModeStatus ret = MODE_BAD; 844 805 DisplayModePtr mode; 845 806 float v; … … 871 832 } 872 833 834 if (ret != MODE_OK) 835 { 836 xf86DrvMsg(scrn, X_WARNING, "Graphics mode %s rejected by the X server\n", p->name); 837 } 873 838 return ret; 874 839 } … … 977 942 if (pVBox->base) { 978 943 pScrn->memPhysBase = pVBox->mapPhys; 979 # ifdef XORG_7X980 944 pVBox->VGAbase = xf86MapDomainMemory(pScrn->scrnIndex, 0, 981 945 pVBox->pciTag, 982 946 0xa0000, 0x10000); 983 # else 984 pVBox->VGAbase = xf86MapVidMem(pScrn->scrnIndex, 0, 985 0xa0000, 0x10000); 986 # endif 987 } 988 #ifdef XORG_7X 947 } 989 948 /* We need this for saving/restoring textmode */ 990 949 pVBox->ioBase = pScrn->domainIOBase; 991 #endif992 950 993 951 return (pVBox->base != NULL); … … 1012 970 LOCO *colors, VisualPtr pVisual) 1013 971 { 1014 #ifdef XORG_7X1015 972 VBOXPtr pVBox = VBOXGetRec(pScrn); 1016 973 int i, idx; 1017 #endif1018 #ifdef XORG_7X1019 974 #define VBOXDACDelay() \ 1020 975 do { \ … … 1022 977 (void)inb(pVBox->ioBase + VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); \ 1023 978 } while (0) 1024 #else1025 #define WriteDacWriteAddr(value) outb(VGA_DAC_WRITE_ADDR, value)1026 #define WriteDacData(value) outb(VGA_DAC_DATA, value);1027 #undef DACDelay1028 #define DACDelay() \1029 do { \1030 unsigned char temp = inb(VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); \1031 temp = inb(VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); \1032 } while (0)1033 int i, idx;1034 #endif1035 979 1036 980 for (i = 0; i < numColors; i++) { 1037 981 idx = indices[i]; 1038 #ifdef XORG_7X1039 982 outb(pVBox->ioBase + VGA_DAC_WRITE_ADDR, idx); 1040 983 VBOXDACDelay(); … … 1045 988 outb(pVBox->ioBase + VGA_DAC_DATA, colors[idx].blue); 1046 989 VBOXDACDelay(); 1047 #else1048 WriteDacWriteAddr(idx);1049 DACDelay();1050 WriteDacData(colors[idx].red);1051 DACDelay();1052 WriteDacData(colors[idx].green);1053 DACDelay();1054 WriteDacData(colors[idx].blue);1055 DACDelay();1056 #endif1057 990 } 1058 991 } … … 1062 995 */ 1063 996 static void 1064 #ifdef XORG_7X1065 997 WriteAttr(VBOXPtr pVBox, int index, int value) 1066 998 { … … 1070 1002 outb(pVBox->ioBase + VGA_ATTR_INDEX, index); 1071 1003 outb(pVBox->ioBase + VGA_ATTR_DATA_W, value); 1072 #else1073 WriteAttr(int index, int value)1074 {1075 CARD8 tmp;1076 1077 tmp = inb(VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET);1078 1079 index |= 0x20;1080 outb(VGA_ATTR_INDEX, index);1081 outb(VGA_ATTR_DATA_W, value);1082 #endif1083 1004 } 1084 1005 1085 1006 static int 1086 #ifdef XORG_7X1087 1007 ReadAttr(VBOXPtr pVBox, int index) 1088 1008 { … … 1092 1012 outb(pVBox->ioBase + VGA_ATTR_INDEX, index); 1093 1013 return (inb(pVBox->ioBase + VGA_ATTR_DATA_R)); 1094 #else 1095 ReadAttr(int index) 1096 { 1097 CARD8 tmp; 1098 1099 tmp = inb(VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); 1100 1101 index |= 0x20; 1102 outb(VGA_ATTR_INDEX, index); 1103 return (inb(VGA_ATTR_DATA_R)); 1104 #endif 1105 } 1106 1107 #ifdef XORG_7X 1014 } 1015 1108 1016 #define WriteMiscOut(value) outb(pVBox->ioBase + VGA_MISC_OUT_W, value) 1109 1017 #define ReadMiscOut() inb(pVBox->ioBase + VGA_MISC_OUT_R) … … 1111 1019 outb(pVBox->ioBase + VGA_SEQ_INDEX, (index));\ 1112 1020 outb(pVBox->ioBase + VGA_SEQ_DATA, value) 1113 #else1114 #define WriteMiscOut(value) outb(VGA_MISC_OUT_W, value)1115 #define ReadMiscOut() inb(VGA_MISC_OUT_R)1116 #define WriteSeq(index, value) \1117 outb(VGA_SEQ_INDEX, (index));\1118 outb(VGA_SEQ_DATA, value)1119 #endif1120 1021 1121 1022 static int 1122 #ifdef XORG_7X1123 1023 ReadSeq(VBOXPtr pVBox, int index) 1124 1024 { … … 1126 1026 1127 1027 return (inb(pVBox->ioBase + VGA_SEQ_DATA)); 1128 #else 1129 ReadSeq(int index) 1130 { 1131 outb(VGA_SEQ_INDEX, index); 1132 1133 return (inb(VGA_SEQ_DATA)); 1134 #endif 1135 } 1136 1137 #ifdef XORG_7X 1028 } 1029 1138 1030 #define WriteGr(index, value) \ 1139 1031 outb(pVBox->ioBase + VGA_GRAPH_INDEX, index); \ 1140 1032 outb(pVBox->ioBase + VGA_GRAPH_DATA, value) 1141 #else1142 #define WriteGr(index, value) outb(VGA_GRAPH_INDEX, index);\1143 outb(VGA_GRAPH_DATA, value)1144 #endif1145 1033 1146 1034 static int 1147 #ifdef XORG_7X1148 1035 ReadGr(VBOXPtr pVBox, int index) 1149 1036 { … … 1151 1038 1152 1039 return (inb(pVBox->ioBase + VGA_GRAPH_DATA)); 1153 #else 1154 ReadGr(int index) 1155 { 1156 outb(VGA_GRAPH_INDEX, index); 1157 1158 return (inb(VGA_GRAPH_DATA)); 1159 #endif 1160 } 1161 1162 #ifdef XORG_7X 1040 } 1041 1163 1042 #define WriteCrtc(index, value) \ 1164 1043 outb(pVBox->ioBase + (VGA_IOBASE_COLOR + VGA_CRTC_INDEX_OFFSET), index); \ 1165 1044 outb(pVBox->ioBase + (VGA_IOBASE_COLOR + VGA_CRTC_DATA_OFFSET), value) 1166 #else1167 #define WriteCrtc(index, value) outb(VGA_CRTC_INDEX_OFFSET, index);\1168 outb(VGA_CRTC_DATA_OFFSET, value)1169 #endif1170 1045 1171 1046 static void 1172 #ifdef XORG_7X1173 1047 SeqReset(VBOXPtr pVBox, Bool start) 1174 1048 { … … 1179 1053 WriteSeq(0x00, 0x03); /* End Reset */ 1180 1054 } 1181 #else1182 SeqReset(Bool start)1183 {1184 if (start) {1185 WriteSeq(0x00, 0x01); /* Synchronous Reset */1186 }1187 else {1188 WriteSeq(0x00, 0x03); /* End Reset */1189 }1190 #endif1191 1055 } 1192 1056 … … 1201 1065 1202 1066 /* If in graphics mode, don't save anything */ 1203 #ifdef XORG_7X1204 1067 attr10 = ReadAttr(pVBox, 0x10); 1205 #else1206 attr10 = ReadAttr(0x10);1207 #endif1208 1068 if (attr10 & 0x01) 1209 1069 return; … … 1213 1073 /* save the registers that are needed here */ 1214 1074 miscOut = ReadMiscOut(); 1215 #ifdef XORG_7X1216 1075 gr4 = ReadGr(pVBox, 0x04); 1217 1076 gr5 = ReadGr(pVBox, 0x05); … … 1219 1078 seq2 = ReadSeq(pVBox, 0x02); 1220 1079 seq4 = ReadSeq(pVBox, 0x04); 1221 #else1222 gr4 = ReadGr(0x04);1223 gr5 = ReadGr(0x05);1224 gr6 = ReadGr(0x06);1225 seq2 = ReadSeq(0x02);1226 seq4 = ReadSeq(0x04);1227 #endif1228 1080 1229 1081 /* Force into colour mode */ 1230 1082 WriteMiscOut(miscOut | 0x01); 1231 1083 1232 #ifdef XORG_7X1233 1084 scrn = ReadSeq(pVBox, 0x01) | 0x20; 1234 1085 SeqReset(pVBox, TRUE); 1235 #else1236 scrn = ReadSeq(0x01) | 0x20;1237 SeqReset(TRUE);1238 #endif1239 1086 WriteSeq(0x01, scrn); 1240 #ifdef XORG_7X1241 1087 SeqReset(pVBox, FALSE); 1242 #else 1243 SeqReset(FALSE); 1244 #endif 1245 1246 #ifdef XORG_7X 1088 1247 1089 WriteAttr(pVBox, 0x10, 0x01); /* graphics mode */ 1248 #else1249 WriteAttr(0x10, 0x01); /* graphics mode */1250 #endif1251 1090 1252 1091 /*font1 */ … … 1266 1105 slowbcopy_frombus(pVBox->VGAbase, pVBox->fonts + 8192, 8192); 1267 1106 1268 #ifdef XORG_7X1269 1107 scrn = ReadSeq(pVBox, 0x01) & ~0x20; 1270 1108 SeqReset(pVBox, TRUE); 1271 #else1272 scrn = ReadSeq(0x01) & ~0x20;1273 SeqReset(TRUE);1274 #endif1275 1109 WriteSeq(0x01, scrn); 1276 #ifdef XORG_7X1277 1110 SeqReset(pVBox, FALSE); 1278 #else1279 SeqReset(FALSE);1280 #endif1281 1111 1282 1112 /* Restore clobbered registers */ 1283 #ifdef XORG_7X1284 1113 WriteAttr(pVBox, 0x10, attr10); 1285 #else1286 WriteAttr(0x10, attr10);1287 #endif1288 1114 WriteSeq(0x02, seq2); 1289 1115 WriteSeq(0x04, seq4); … … 1305 1131 /* save the registers that are needed here */ 1306 1132 miscOut = ReadMiscOut(); 1307 #ifdef XORG_7X1308 1133 attr10 = ReadAttr(pVBox, 0x10); 1309 1134 gr1 = ReadGr(pVBox, 0x01); … … 1315 1140 seq2 = ReadSeq(pVBox, 0x02); 1316 1141 seq4 = ReadSeq(pVBox, 0x04); 1317 #else1318 attr10 = ReadAttr(0x10);1319 gr1 = ReadGr(0x01);1320 gr3 = ReadGr(0x03);1321 gr4 = ReadGr(0x04);1322 gr5 = ReadGr(0x05);1323 gr6 = ReadGr(0x06);1324 gr8 = ReadGr(0x08);1325 seq2 = ReadSeq(0x02);1326 seq4 = ReadSeq(0x04);1327 #endif1328 1142 1329 1143 /* Force into colour mode */ 1330 1144 WriteMiscOut(miscOut | 0x01); 1331 1145 1332 #ifdef XORG_7X1333 1146 scrn = ReadSeq(pVBox, 0x01) & ~0x20; 1334 1147 SeqReset(pVBox, TRUE); 1335 #else1336 scrn = ReadSeq(0x01) | 0x20;1337 SeqReset(TRUE);1338 #endif1339 1148 WriteSeq(0x01, scrn); 1340 #ifdef XORG_7X1341 1149 SeqReset(pVBox, FALSE); 1342 #else 1343 SeqReset(FALSE); 1344 #endif 1345 1346 #ifdef XORG_7X 1150 1347 1151 WriteAttr(pVBox, 0x10, 0x01); /* graphics mode */ 1348 #else1349 WriteAttr(0x10, 0x01); /* graphics mode */1350 #endif1351 1152 if (pScrn->depth == 4) { 1352 1153 /* GJA */ … … 1370 1171 slowbcopy_tobus(pVBox->fonts + 8192, pVBox->VGAbase, 8192); 1371 1172 1372 #ifdef XORG_7X1373 1173 scrn = ReadSeq(pVBox, 0x01) & ~0x20; 1374 1174 SeqReset(pVBox, TRUE); 1375 #else1376 scrn = ReadSeq(0x01) & ~0x20;1377 SeqReset(TRUE);1378 #endif1379 1175 WriteSeq(0x01, scrn); 1380 #ifdef XORG_7X1381 1176 SeqReset(pVBox, FALSE); 1382 #else1383 SeqReset(FALSE);1384 #endif1385 1177 1386 1178 /* restore the registers that were changed */ 1387 1179 WriteMiscOut(miscOut); 1388 #ifdef XORG_7X1389 1180 WriteAttr(pVBox, 0x10, attr10); 1390 #else1391 WriteAttr(0x10, attr10);1392 #endif1393 1181 WriteGr(0x01, gr1); 1394 1182 WriteGr(0x03, gr3); … … 1405 1193 { 1406 1194 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; 1407 #ifdef XORG_7X1408 1195 VBOXPtr pVBox = VBOXGetRec(pScrn); 1409 #endif1410 1196 Bool on = xf86IsUnblank(mode); 1411 1197 … … 1414 1200 1415 1201 if (pScrn->vtSema) { 1416 #ifdef XORG_7X1417 1202 unsigned char scrn = ReadSeq(pVBox, 0x01); 1418 #else1419 unsigned char scrn = ReadSeq(0x01);1420 #endif1421 1203 1422 1204 if (on) … … 1424 1206 else 1425 1207 scrn |= 0x20; 1426 #ifdef XORG_7X1427 1208 SeqReset(pVBox, TRUE); 1428 1209 WriteSeq(0x01, scrn); 1429 1210 SeqReset(pVBox, FALSE); 1430 #else1431 SeqReset(TRUE);1432 WriteSeq(0x01, scrn);1433 SeqReset(FALSE);1434 #endif1435 1211 } 1436 1212
Note:
See TracChangeset
for help on using the changeset viewer.