- Timestamp:
- May 20, 2008 11:40:47 AM (17 years ago)
- Location:
- trunk/src/VBox/Additions/x11/xgraphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/xgraphics/vboxutils.c
r8919 r8949 322 322 { 323 323 Bool rc = TRUE; 324 int vrc = VbglR3Init(); 324 int vrc; 325 pVBox->useVbva = FALSE; 326 vrc = VbglR3Init(); 325 327 if (RT_FAILURE(vrc)) 326 328 { … … 346 348 if (!pVBox->useDevice) 347 349 return FALSE; 348 pVBox->useVbva = FALSE;349 350 350 351 if (pVBox->reqp) -
trunk/src/VBox/Additions/x11/xgraphics/vboxvideo_13.c
r8919 r8949 52 52 */ 53 53 54 / / #define DEBUG_VIDEO 154 /* #define DEBUG_VIDEO 1 */ 55 55 #ifdef DEBUG_VIDEO 56 56 … … 73 73 #else /* DEBUG_VIDEO not defined */ 74 74 75 #define TRACE 76 #define TRACE2 77 #define TRACE3(...) 75 #define TRACE do { } while(0) 76 #define TRACE2 do { } while(0) 77 #define TRACE3(...) do { } while(0) 78 78 79 79 #endif /* DEBUG_VIDEO not defined */ … … 178 178 if (!pScrn->driverPrivate) { 179 179 pScrn->driverPrivate = xcalloc(sizeof(VBOXRec), 1); 180 #if 0181 ((VBOXPtr)pScrn->driverPrivate)->vbox_fd = -1;182 #endif183 180 } 184 181 … … 190 187 { 191 188 VBOXPtr pVBox = VBOXGetRec(pScrn); 192 #if 0193 xfree(pVBox->vbeInfo);194 #endif195 189 xfree(pVBox->savedPal); 196 190 xfree(pVBox->fonts); … … 255 249 scrn->displayWidth = width; 256 250 } 257 TRACE3("returning % d\n", rc);251 TRACE3("returning %s\n", rc ? "TRUE" : "FALSE"); 258 252 return rc; 259 253 } … … 351 345 vbox_output_mode_valid (xf86OutputPtr output, DisplayModePtr mode) 352 346 { 353 if ( vboxHostLikesVideoMode(mode->HDisplay, mode->VDisplay, 354 output->scrn->bitsPerPixel) 355 || !vbox_device_available(VBOXGetRec(output->scrn)) 347 int rc = MODE_OK; 348 TRACE3("HDisplay=%d, VDisplay=%d\n", mode->HDisplay, mode->VDisplay); 349 if ( vbox_device_available(VBOXGetRec(output->scrn)) 350 && !vboxHostLikesVideoMode(mode->HDisplay, mode->VDisplay, 351 output->scrn->bitsPerPixel) 356 352 ) 357 r eturn MODE_OK;358 else359 return MODE_BAD;353 rc = MODE_BAD; 354 TRACE3("returning %s\n", MODE_OK == rc ? "MODE_OK" : "MODE_BAD"); 355 return rc; 360 356 } 361 357 … … 415 411 416 412 TRACE; 417 rc = vboxGetDisplayChangeRequest(pScrn, &x, &y, &bpp, &display, pVBox); 418 /* @todo - check the display number once we support multiple displays. */ 419 if (rc && (0 != x) && (0 != y)) { 420 /* We prefer a slightly smaller size to a slightly larger one */ 421 x -= (x % 8); 422 vbox_output_add_mode(&pModes, NULL, x, y, TRUE); 413 if (vbox_device_available(pVBox)) 414 { 415 rc = vboxGetDisplayChangeRequest(pScrn, &x, &y, &bpp, &display, pVBox); 416 /* @todo - check the display number once we support multiple displays. */ 417 if (rc && (0 != x) && (0 != y)) { 418 /* We prefer a slightly smaller size to a slightly larger one */ 419 x -= (x % 8); 420 vbox_output_add_mode(&pModes, NULL, x, y, TRUE); 421 } 423 422 } 424 423 TRACE2; … … 717 716 uint32_t cx, cy, iDisplay, cBits = 24; 718 717 719 /* We only support 16 and 24 bits depth (i.e. 16 and 32bpp) */ 720 if ( vboxGetDisplayChangeRequest(pScrn, &cx, &cy, &cBits, &iDisplay, 721 pVBox) 722 && (cBits != 16)) 723 cBits = 24; 718 if (vbox_device_available(pVBox)) 719 { 720 /* We only support 16 and 24 bits depth (i.e. 16 and 32bpp) */ 721 if ( vboxGetDisplayChangeRequest(pScrn, &cx, &cy, &cBits, 722 &iDisplay, pVBox) 723 && (cBits != 16) 724 ) 725 cBits = 24; 726 } 724 727 if (!xf86SetDepthBpp(pScrn, cBits, 0, 0, Support32bppFb)) 725 728 return FALSE; … … 820 823 VBOXPtr pVBox = VBOXGetRec(pScrn); 821 824 825 TRACE3("enable=%s\n", enable ? "TRUE" : "FALSE"); 822 826 pVBox->accessEnabled = enable; 823 827 pVBox->EnableDisableFBAccess(scrnIndex, enable); 828 TRACE2; 824 829 } 825 830 … … 961 966 xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); 962 967 963 if (vbox_ open (pScrn, pScreen, pVBox)) {968 if (vbox_device_available(pVBox) && vbox_open (pScrn, pScreen, pVBox)) { 964 969 if (vbox_cursor_init(pScreen) != TRUE) 965 970 xf86DrvMsg(scrnIndex, X_ERROR, … … 979 984 ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; 980 985 VBOXPtr pVBox = VBOXGetRec(pScrn); 981 986 bool rc; 987 988 TRACE; 982 989 pVBox->vtSwitch = FALSE; 983 return xf86SetDesiredModes(pScrn); 990 rc = xf86SetDesiredModes(pScrn); 991 TRACE3("returning %s\n", rc ? "TRUE" : "FALSE"); 992 return rc; 984 993 } 985 994 … … 990 999 VBOXPtr pVBox = VBOXGetRec(pScrn); 991 1000 1001 TRACE; 1002 pVBox->vtSwitch = TRUE; 992 1003 VBOXSaveRestore(pScrn, MODE_RESTORE); 993 if (pVBox->useVbva == TRUE) 994 vboxDisableVbva(pScrn); 995 vboxDisableGraphicsCap(pVBox); 996 pVBox->vtSwitch = TRUE; 1004 if (vbox_device_available(pVBox)) 1005 { 1006 if (pVBox->useVbva == TRUE) 1007 vboxDisableVbva(pScrn); 1008 vboxDisableGraphicsCap(pVBox); 1009 } 1010 TRACE2; 997 1011 } 998 1012 … … 1003 1017 VBOXPtr pVBox = VBOXGetRec(pScrn); 1004 1018 1005 if (pVBox->useVbva == TRUE) 1006 vboxDisableVbva(pScrn); 1007 vboxDisableGraphicsCap(pVBox); 1019 if (vbox_device_available(pVBox)) 1020 { 1021 if (TRUE == pVBox->useVbva) 1022 vboxDisableVbva(pScrn); 1023 vboxDisableGraphicsCap(pVBox); 1024 } 1008 1025 if (pScrn->vtSema) { 1009 1026 VBOXSaveRestore(xf86Screens[scrnIndex], MODE_RESTORE); … … 1045 1062 float v; 1046 1063 1064 TRACE3("HDisplay=%d, VDisplay=%d, flag=%s, pass=%d\n", 1065 p->HDisplay, p->VDisplay, flag ? "TRUE" : "FALSE", pass); 1047 1066 if (pass != MODECHECK_FINAL) { 1048 1067 if (!warned) { … … 1077 1096 xf86DrvMsg(scrn, X_WARNING, "Graphics mode %s rejected by the X server\n", p->name); 1078 1097 } 1098 TRACE3("returning %d\n", ret); 1079 1099 return ret; 1080 1100 } … … 1087 1107 Bool rc; 1088 1108 1109 TRACE3("HDisplay=%d, VDisplay=%d\n", pMode->HDisplay, pMode->VDisplay); 1089 1110 pScrn = xf86Screens[scrnIndex]; /* Why does X have three ways of refering to the screen? */ 1090 1111 pVBox = VBOXGetRec(pScrn); … … 1096 1117 if (pVBox->accessEnabled) 1097 1118 pVBox->EnableDisableFBAccess(scrnIndex, TRUE); 1119 TRACE3("returning %s\n", rc ? "TRUE" : "FALSE"); 1098 1120 return rc; 1099 1121 } 1100 1122 1101 /* Set a graphics mode */ 1123 /* Set a graphics mode. Poke the required values into registers, enable 1124 guest-host acceleration functions and tell the host we support advanced 1125 graphics functions. */ 1102 1126 static Bool 1103 1127 VBOXSetMode(ScrnInfoPtr pScrn, DisplayModePtr pMode) 1104 1128 { 1105 1129 VBOXPtr pVBox; 1130 Bool rc = TRUE; 1106 1131 1107 1132 int bpp = pScrn->depth == 24 ? 32 : 16; 1133 TRACE3("HDisplay=%d, VDisplay=%d\n", pMode->HDisplay, pMode->VDisplay); 1108 1134 pVBox = VBOXGetRec(pScrn); 1109 1135 /* Don't fiddle with the hardware if we are switched 1110 1136 * to a virtual terminal. */ 1111 if (pVBox->vtSwitch == TRUE) 1112 return TRUE; 1113 if (pVBox->useVbva == TRUE) 1114 if (vboxDisableVbva(pScrn) != TRUE) /* This would be bad. */ 1115 return FALSE; 1116 pScrn->vtSema = TRUE; 1117 /* Disable linear framebuffer mode before making changes to the resolution. */ 1118 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ENABLE); 1119 outw(VBE_DISPI_IOPORT_DATA, 1120 VBE_DISPI_DISABLED); 1121 /* Unlike the resolution, the depth is fixed for a given screen 1122 for the lifetime of the X session. */ 1123 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP); 1124 outw(VBE_DISPI_IOPORT_DATA, bpp); 1125 /* HDisplay and VDisplay are actually monitor information about 1126 the display part of the scanlines. */ 1127 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES); 1128 outw(VBE_DISPI_IOPORT_DATA, pMode->HDisplay); 1129 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES); 1130 outw(VBE_DISPI_IOPORT_DATA, pMode->VDisplay); 1131 /* Set the virtual resolution. We are still using VESA to control 1132 the virtual offset. */ 1133 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VIRT_WIDTH); 1134 outw(VBE_DISPI_IOPORT_DATA, pScrn->displayWidth); 1135 /* Enable linear framebuffer mode. */ 1136 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ENABLE); 1137 outw(VBE_DISPI_IOPORT_DATA, 1138 VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED); 1139 if (pVBox->useVbva == TRUE) 1140 if (vboxEnableVbva(pScrn) != TRUE) /* Bad but not fatal */ 1141 pVBox->useVbva = FALSE; 1142 vboxEnableGraphicsCap(pVBox); 1143 return (TRUE); 1137 if (!pVBox->vtSwitch) 1138 { 1139 if ( vbox_device_available(pVBox) 1140 && (TRUE == pVBox->useVbva) 1141 && (vboxDisableVbva(pScrn) != TRUE) 1142 ) /* This would be bad. */ 1143 rc = FALSE; 1144 if (rc) 1145 { 1146 /* Disable linear framebuffer mode before making changes to the resolution. */ 1147 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ENABLE); 1148 outw(VBE_DISPI_IOPORT_DATA, VBE_DISPI_DISABLED); 1149 /* Unlike the resolution, the depth is fixed for a given screen 1150 for the lifetime of the X session. */ 1151 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP); 1152 outw(VBE_DISPI_IOPORT_DATA, bpp); 1153 /* HDisplay and VDisplay are actually monitor information about 1154 the display part of the scanlines. */ 1155 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES); 1156 outw(VBE_DISPI_IOPORT_DATA, pMode->HDisplay); 1157 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES); 1158 outw(VBE_DISPI_IOPORT_DATA, pMode->VDisplay); 1159 /* Set the virtual resolution. We are still using VESA to control 1160 the virtual offset. */ 1161 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VIRT_WIDTH); 1162 outw(VBE_DISPI_IOPORT_DATA, pScrn->displayWidth); 1163 /* Enable linear framebuffer mode. */ 1164 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ENABLE); 1165 outw(VBE_DISPI_IOPORT_DATA, 1166 VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED); 1167 /* Enable acceleration and tell the host we support graphics */ 1168 if (vbox_device_available(pVBox)) 1169 { 1170 if ((TRUE == pVBox->useVbva) && (vboxEnableVbva(pScrn) != TRUE)) 1171 /* Bad but not fatal */ 1172 pVBox->useVbva = FALSE; 1173 vboxEnableGraphicsCap(pVBox); 1174 } 1175 } 1176 } 1177 TRACE3("returning %s\n", rc ? "TRUE" : "FALSE"); 1178 return rc; 1144 1179 } 1145 1180 … … 1149 1184 VBOXPtr pVBox = VBOXGetRec(xf86Screens[scrnIndex]); 1150 1185 1186 TRACE; 1151 1187 /* Don't fiddle with the hardware if we are switched 1152 1188 * to a virtual terminal. */ 1153 if ( pVBox->vtSwitch == TRUE)1154 return;1155 VBESetDisplayStart(pVBox->pVbe, x, y, TRUE);1189 if (!pVBox->vtSwitch) 1190 VBESetDisplayStart(pVBox->pVbe, x, y, TRUE); 1191 TRACE2; 1156 1192 } 1157 1193 … … 1166 1202 { 1167 1203 VBOXPtr pVBox = VBOXGetRec(pScrn); 1168 1169 if (pVBox->base != NULL) 1170 return (TRUE); 1171 1172 pScrn->memPhysBase = pVBox->mapPhys; 1173 pScrn->fbOffset = pVBox->mapOff; 1174 1175 pVBox->base = xf86MapPciMem(pScrn->scrnIndex, 1176 VIDMEM_FRAMEBUFFER, 1177 pVBox->pciTag, pVBox->mapPhys, 1178 (unsigned) pVBox->mapSize); 1179 1180 if (pVBox->base) { 1204 Bool rc = TRUE; 1205 1206 TRACE; 1207 if (NULL == pVBox->base) 1208 { 1181 1209 pScrn->memPhysBase = pVBox->mapPhys; 1182 pVBox->VGAbase = xf86MapDomainMemory(pScrn->scrnIndex, 0, 1183 pVBox->pciTag, 1184 0xa0000, 0x10000); 1185 } 1186 /* We need this for saving/restoring textmode */ 1187 pVBox->ioBase = pScrn->domainIOBase; 1188 1189 return (pVBox->base != NULL); 1210 pScrn->fbOffset = pVBox->mapOff; 1211 1212 pVBox->base = xf86MapPciMem(pScrn->scrnIndex, 1213 VIDMEM_FRAMEBUFFER, 1214 pVBox->pciTag, pVBox->mapPhys, 1215 (unsigned) pVBox->mapSize); 1216 1217 if (pVBox->base) { 1218 pScrn->memPhysBase = pVBox->mapPhys; 1219 pVBox->VGAbase = xf86MapDomainMemory(pScrn->scrnIndex, 0, 1220 pVBox->pciTag, 1221 0xa0000, 0x10000); 1222 } 1223 /* We need this for saving/restoring textmode */ 1224 pVBox->ioBase = pScrn->domainIOBase; 1225 1226 rc = pVBox->base != NULL; 1227 } 1228 TRACE3("returning %s\n", rc ? "TRUE" : "FALSE"); 1229 return rc; 1190 1230 } 1191 1231 … … 1195 1235 VBOXPtr pVBox = VBOXGetRec(pScrn); 1196 1236 1237 TRACE; 1197 1238 if (pVBox->base == NULL) 1198 1239 return; … … 1202 1243 xf86UnMapVidMem(pScrn->scrnIndex, pVBox->VGAbase, 0x10000); 1203 1244 pVBox->base = NULL; 1245 TRACE2; 1204 1246 } 1205 1247 … … 1216 1258 } while (0) 1217 1259 1260 TRACE; 1218 1261 for (i = 0; i < numColors; i++) { 1219 1262 idx = indices[i]; … … 1227 1270 VBOXDACDelay(); 1228 1271 } 1272 TRACE2; 1229 1273 } 1230 1274 … … 1298 1342 VBOXPtr pVBox = VBOXGetRec(pScrn); 1299 1343 unsigned char miscOut, attr10, gr4, gr5, gr6, seq2, seq4, scrn; 1300 1344 Bool cont = TRUE; 1345 1346 TRACE; 1301 1347 if (pVBox->fonts != NULL) 1302 return; 1303 1304 /* If in graphics mode, don't save anything */ 1305 attr10 = ReadAttr(pVBox, 0x10); 1306 if (attr10 & 0x01) 1307 return; 1308 1309 pVBox->fonts = xalloc(16384); 1310 1311 /* save the registers that are needed here */ 1312 miscOut = ReadMiscOut(); 1313 gr4 = ReadGr(pVBox, 0x04); 1314 gr5 = ReadGr(pVBox, 0x05); 1315 gr6 = ReadGr(pVBox, 0x06); 1316 seq2 = ReadSeq(pVBox, 0x02); 1317 seq4 = ReadSeq(pVBox, 0x04); 1318 1319 /* Force into colour mode */ 1320 WriteMiscOut(miscOut | 0x01); 1321 1322 scrn = ReadSeq(pVBox, 0x01) | 0x20; 1323 SeqReset(pVBox, TRUE); 1324 WriteSeq(0x01, scrn); 1325 SeqReset(pVBox, FALSE); 1326 1327 WriteAttr(pVBox, 0x10, 0x01); /* graphics mode */ 1328 1329 /*font1 */ 1330 WriteSeq(0x02, 0x04); /* write to plane 2 */ 1331 WriteSeq(0x04, 0x06); /* enable plane graphics */ 1332 WriteGr(0x04, 0x02); /* read plane 2 */ 1333 WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */ 1334 WriteGr(0x06, 0x05); /* set graphics */ 1335 slowbcopy_frombus(pVBox->VGAbase, pVBox->fonts, 8192); 1336 1337 /* font2 */ 1338 WriteSeq(0x02, 0x08); /* write to plane 3 */ 1339 WriteSeq(0x04, 0x06); /* enable plane graphics */ 1340 WriteGr(0x04, 0x03); /* read plane 3 */ 1341 WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */ 1342 WriteGr(0x06, 0x05); /* set graphics */ 1343 slowbcopy_frombus(pVBox->VGAbase, pVBox->fonts + 8192, 8192); 1344 1345 scrn = ReadSeq(pVBox, 0x01) & ~0x20; 1346 SeqReset(pVBox, TRUE); 1347 WriteSeq(0x01, scrn); 1348 SeqReset(pVBox, FALSE); 1349 1350 /* Restore clobbered registers */ 1351 WriteAttr(pVBox, 0x10, attr10); 1352 WriteSeq(0x02, seq2); 1353 WriteSeq(0x04, seq4); 1354 WriteGr(0x04, gr4); 1355 WriteGr(0x05, gr5); 1356 WriteGr(0x06, gr6); 1357 WriteMiscOut(miscOut); 1348 cont = FALSE; 1349 1350 if (cont) 1351 { 1352 /* If in graphics mode, don't save anything */ 1353 attr10 = ReadAttr(pVBox, 0x10); 1354 if (attr10 & 0x01) 1355 cont = FALSE; 1356 } 1357 1358 if (cont) 1359 { 1360 pVBox->fonts = xalloc(16384); 1361 1362 /* save the registers that are needed here */ 1363 miscOut = ReadMiscOut(); 1364 gr4 = ReadGr(pVBox, 0x04); 1365 gr5 = ReadGr(pVBox, 0x05); 1366 gr6 = ReadGr(pVBox, 0x06); 1367 seq2 = ReadSeq(pVBox, 0x02); 1368 seq4 = ReadSeq(pVBox, 0x04); 1369 1370 /* Force into colour mode */ 1371 WriteMiscOut(miscOut | 0x01); 1372 1373 scrn = ReadSeq(pVBox, 0x01) | 0x20; 1374 SeqReset(pVBox, TRUE); 1375 WriteSeq(0x01, scrn); 1376 SeqReset(pVBox, FALSE); 1377 1378 WriteAttr(pVBox, 0x10, 0x01); /* graphics mode */ 1379 1380 /*font1 */ 1381 WriteSeq(0x02, 0x04); /* write to plane 2 */ 1382 WriteSeq(0x04, 0x06); /* enable plane graphics */ 1383 WriteGr(0x04, 0x02); /* read plane 2 */ 1384 WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */ 1385 WriteGr(0x06, 0x05); /* set graphics */ 1386 slowbcopy_frombus(pVBox->VGAbase, pVBox->fonts, 8192); 1387 1388 /* font2 */ 1389 WriteSeq(0x02, 0x08); /* write to plane 3 */ 1390 WriteSeq(0x04, 0x06); /* enable plane graphics */ 1391 WriteGr(0x04, 0x03); /* read plane 3 */ 1392 WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */ 1393 WriteGr(0x06, 0x05); /* set graphics */ 1394 slowbcopy_frombus(pVBox->VGAbase, pVBox->fonts + 8192, 8192); 1395 1396 scrn = ReadSeq(pVBox, 0x01) & ~0x20; 1397 SeqReset(pVBox, TRUE); 1398 WriteSeq(0x01, scrn); 1399 SeqReset(pVBox, FALSE); 1400 1401 /* Restore clobbered registers */ 1402 WriteAttr(pVBox, 0x10, attr10); 1403 WriteSeq(0x02, seq2); 1404 WriteSeq(0x04, seq4); 1405 WriteGr(0x04, gr4); 1406 WriteGr(0x05, gr5); 1407 WriteGr(0x06, gr6); 1408 WriteMiscOut(miscOut); 1409 } 1410 TRACE2; 1358 1411 } 1359 1412 … … 1364 1417 unsigned char miscOut, attr10, gr1, gr3, gr4, gr5, gr6, gr8, seq2, seq4, scrn; 1365 1418 1366 if (pVBox->fonts == NULL) 1367 return; 1368 1369 /* save the registers that are needed here */ 1370 miscOut = ReadMiscOut(); 1371 attr10 = ReadAttr(pVBox, 0x10); 1372 gr1 = ReadGr(pVBox, 0x01); 1373 gr3 = ReadGr(pVBox, 0x03); 1374 gr4 = ReadGr(pVBox, 0x04); 1375 gr5 = ReadGr(pVBox, 0x05); 1376 gr6 = ReadGr(pVBox, 0x06); 1377 gr8 = ReadGr(pVBox, 0x08); 1378 seq2 = ReadSeq(pVBox, 0x02); 1379 seq4 = ReadSeq(pVBox, 0x04); 1380 1381 /* Force into colour mode */ 1382 WriteMiscOut(miscOut | 0x01); 1383 1384 scrn = ReadSeq(pVBox, 0x01) & ~0x20; 1385 SeqReset(pVBox, TRUE); 1386 WriteSeq(0x01, scrn); 1387 SeqReset(pVBox, FALSE); 1388 1389 WriteAttr(pVBox, 0x10, 0x01); /* graphics mode */ 1390 if (pScrn->depth == 4) { 1391 /* GJA */ 1392 WriteGr(0x03, 0x00); /* don't rotate, write unmodified */ 1393 WriteGr(0x08, 0xFF); /* write all bits in a byte */ 1394 WriteGr(0x01, 0x00); /* all planes come from CPU */ 1395 } 1396 1397 WriteSeq(0x02, 0x04); /* write to plane 2 */ 1398 WriteSeq(0x04, 0x06); /* enable plane graphics */ 1399 WriteGr(0x04, 0x02); /* read plane 2 */ 1400 WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */ 1401 WriteGr(0x06, 0x05); /* set graphics */ 1402 slowbcopy_tobus(pVBox->fonts, pVBox->VGAbase, 8192); 1403 1404 WriteSeq(0x02, 0x08); /* write to plane 3 */ 1405 WriteSeq(0x04, 0x06); /* enable plane graphics */ 1406 WriteGr(0x04, 0x03); /* read plane 3 */ 1407 WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */ 1408 WriteGr(0x06, 0x05); /* set graphics */ 1409 slowbcopy_tobus(pVBox->fonts + 8192, pVBox->VGAbase, 8192); 1410 1411 scrn = ReadSeq(pVBox, 0x01) & ~0x20; 1412 SeqReset(pVBox, TRUE); 1413 WriteSeq(0x01, scrn); 1414 SeqReset(pVBox, FALSE); 1415 1416 /* restore the registers that were changed */ 1417 WriteMiscOut(miscOut); 1418 WriteAttr(pVBox, 0x10, attr10); 1419 WriteGr(0x01, gr1); 1420 WriteGr(0x03, gr3); 1421 WriteGr(0x04, gr4); 1422 WriteGr(0x05, gr5); 1423 WriteGr(0x06, gr6); 1424 WriteGr(0x08, gr8); 1425 WriteSeq(0x02, seq2); 1426 WriteSeq(0x04, seq4); 1419 TRACE; 1420 if (pVBox->fonts != NULL) 1421 { 1422 /* save the registers that are needed here */ 1423 miscOut = ReadMiscOut(); 1424 attr10 = ReadAttr(pVBox, 0x10); 1425 gr1 = ReadGr(pVBox, 0x01); 1426 gr3 = ReadGr(pVBox, 0x03); 1427 gr4 = ReadGr(pVBox, 0x04); 1428 gr5 = ReadGr(pVBox, 0x05); 1429 gr6 = ReadGr(pVBox, 0x06); 1430 gr8 = ReadGr(pVBox, 0x08); 1431 seq2 = ReadSeq(pVBox, 0x02); 1432 seq4 = ReadSeq(pVBox, 0x04); 1433 1434 /* Force into colour mode */ 1435 WriteMiscOut(miscOut | 0x01); 1436 1437 scrn = ReadSeq(pVBox, 0x01) & ~0x20; 1438 SeqReset(pVBox, TRUE); 1439 WriteSeq(0x01, scrn); 1440 SeqReset(pVBox, FALSE); 1441 1442 WriteAttr(pVBox, 0x10, 0x01); /* graphics mode */ 1443 if (pScrn->depth == 4) { 1444 /* GJA */ 1445 WriteGr(0x03, 0x00); /* don't rotate, write unmodified */ 1446 WriteGr(0x08, 0xFF); /* write all bits in a byte */ 1447 WriteGr(0x01, 0x00); /* all planes come from CPU */ 1448 } 1449 1450 WriteSeq(0x02, 0x04); /* write to plane 2 */ 1451 WriteSeq(0x04, 0x06); /* enable plane graphics */ 1452 WriteGr(0x04, 0x02); /* read plane 2 */ 1453 WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */ 1454 WriteGr(0x06, 0x05); /* set graphics */ 1455 slowbcopy_tobus(pVBox->fonts, pVBox->VGAbase, 8192); 1456 1457 WriteSeq(0x02, 0x08); /* write to plane 3 */ 1458 WriteSeq(0x04, 0x06); /* enable plane graphics */ 1459 WriteGr(0x04, 0x03); /* read plane 3 */ 1460 WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */ 1461 WriteGr(0x06, 0x05); /* set graphics */ 1462 slowbcopy_tobus(pVBox->fonts + 8192, pVBox->VGAbase, 8192); 1463 1464 scrn = ReadSeq(pVBox, 0x01) & ~0x20; 1465 SeqReset(pVBox, TRUE); 1466 WriteSeq(0x01, scrn); 1467 SeqReset(pVBox, FALSE); 1468 1469 /* restore the registers that were changed */ 1470 WriteMiscOut(miscOut); 1471 WriteAttr(pVBox, 0x10, attr10); 1472 WriteGr(0x01, gr1); 1473 WriteGr(0x03, gr3); 1474 WriteGr(0x04, gr4); 1475 WriteGr(0x05, gr5); 1476 WriteGr(0x06, gr6); 1477 WriteGr(0x08, gr8); 1478 WriteSeq(0x02, seq2); 1479 WriteSeq(0x04, seq4); 1480 } 1481 TRACE2; 1427 1482 } 1428 1483 … … 1431 1486 { 1432 1487 VBOXPtr pVBox; 1433 1488 Bool rc = TRUE; 1489 1490 TRACE; 1434 1491 if (MODE_QUERY < 0 || function > MODE_RESTORE) 1435 return (FALSE); 1436 1437 pVBox = VBOXGetRec(pScrn); 1438 1439 1440 /* Query amount of memory to save state */ 1441 if (function == MODE_QUERY || 1442 (function == MODE_SAVE && pVBox->state == NULL)) 1443 { 1444 1445 /* Make sure we save at least this information in case of failure */ 1446 (void)VBEGetVBEMode(pVBox->pVbe, &pVBox->stateMode); 1447 SaveFonts(pScrn); 1448 1449 if (!VBESaveRestore(pVBox->pVbe,function,(pointer)&pVBox->state, 1450 &pVBox->stateSize,&pVBox->statePage)) 1451 return FALSE; 1452 } 1453 1454 /* Save/Restore Super VGA state */ 1455 if (function != MODE_QUERY) { 1456 Bool retval = TRUE; 1457 1458 if (function == MODE_RESTORE) 1459 memcpy(pVBox->state, pVBox->pstate, 1460 (unsigned) pVBox->stateSize); 1461 1462 if ((retval = VBESaveRestore(pVBox->pVbe,function, 1463 (pointer)&pVBox->state, 1464 &pVBox->stateSize,&pVBox->statePage)) 1465 && function == MODE_SAVE) 1492 rc = FALSE; 1493 1494 if (rc) 1495 { 1496 pVBox = VBOXGetRec(pScrn); 1497 1498 /* Query amount of memory to save state */ 1499 if (function == MODE_QUERY || 1500 (function == MODE_SAVE && pVBox->state == NULL)) 1466 1501 { 1467 /* don't rely on the memory not being touched */ 1468 if (pVBox->pstate == NULL) 1469 pVBox->pstate = xalloc(pVBox->stateSize); 1470 memcpy(pVBox->pstate, pVBox->state, 1471 (unsigned) pVBox->stateSize); 1502 1503 /* Make sure we save at least this information in case of failure */ 1504 (void)VBEGetVBEMode(pVBox->pVbe, &pVBox->stateMode); 1505 SaveFonts(pScrn); 1506 1507 if (!VBESaveRestore(pVBox->pVbe,function,(pointer)&pVBox->state, 1508 &pVBox->stateSize,&pVBox->statePage) 1509 ) 1510 rc = FALSE; 1472 1511 } 1473 1474 if (function == MODE_RESTORE) 1475 { 1476 VBESetVBEMode(pVBox->pVbe, pVBox->stateMode, NULL); 1477 RestoreFonts(pScrn); 1512 } 1513 if (rc) 1514 { 1515 /* Save/Restore Super VGA state */ 1516 if (function != MODE_QUERY) { 1517 1518 if (function == MODE_RESTORE) 1519 memcpy(pVBox->state, pVBox->pstate, 1520 (unsigned) pVBox->stateSize); 1521 1522 if ( (rc = VBESaveRestore(pVBox->pVbe,function, 1523 (pointer)&pVBox->state, 1524 &pVBox->stateSize,&pVBox->statePage) 1525 ) 1526 && (function == MODE_SAVE) 1527 ) 1528 { 1529 /* don't rely on the memory not being touched */ 1530 if (pVBox->pstate == NULL) 1531 pVBox->pstate = xalloc(pVBox->stateSize); 1532 memcpy(pVBox->pstate, pVBox->state, 1533 (unsigned) pVBox->stateSize); 1534 } 1535 1536 if (function == MODE_RESTORE) 1537 { 1538 VBESetVBEMode(pVBox->pVbe, pVBox->stateMode, NULL); 1539 RestoreFonts(pScrn); 1540 } 1478 1541 } 1479 1480 if (!retval) 1481 return (FALSE); 1482 1483 } 1484 1485 return (TRUE); 1486 } 1542 } 1543 TRACE3("returning %s\n", rc ? "TRUE" : "FALSE"); 1544 return rc; 1545 }
Note:
See TracChangeset
for help on using the changeset viewer.