Changeset 22054 in vbox for trunk/src/VBox
- Timestamp:
- Aug 7, 2009 10:51:14 AM (15 years ago)
- Location:
- trunk/src/VBox/Additions/x11/vboxvideo
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.h
r21867 r22054 198 198 CARD32 *savedPal; 199 199 CARD8 *fonts; 200 vgaRegRec vgaRegs; /* Space for saving VGA information */ 200 201 /* DGA info */ 201 202 DGAModePtr pDGAMode; -
trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo_15.c
r22047 r22054 70 70 /* #define DPMS_SERVER 71 71 #include "extensions/dpms.h" */ 72 73 /* VGA hardware functions for setting and restoring text mode */ 74 #include "vgaHW.h" 72 75 73 76 /* X.org 1.3+ mode setting */ … … 101 104 static Bool VBOXMapVidMem(ScrnInfoPtr pScrn); 102 105 static void VBOXUnmapVidMem(ScrnInfoPtr pScrn); 103 static void VBOXLoadPalette(ScrnInfoPtr pScrn, int numColors,104 int *indices,105 LOCO *colors, VisualPtr pVisual);106 static void SaveFonts(ScrnInfoPtr pScrn);107 static void RestoreFonts(ScrnInfoPtr pScrn);108 106 static Bool VBOXSaveRestore(ScrnInfoPtr pScrn, 109 107 vbeSaveRestoreFunction function); … … 515 513 "xf86InitCursor", 516 514 "xf86CreateCursorInfoRec", 515 NULL 516 }; 517 518 static const char *vgahwSymbols[] = { 519 "vgaHWGetHWRec", 520 "vgaHWHandleColormaps", 521 "vgaHWFreeHWRec", 522 "vgaHWMapMem", 523 "vgaHWUnmapMem", 524 "vgaHWSaveFonts", 525 "vgaHWRestoreFonts", 517 526 NULL 518 527 }; … … 797 806 xf86LoaderReqSymLists(shadowfbSymbols, NULL); 798 807 808 if (!xf86LoadSubModule(pScrn, "vgahw")) 809 return FALSE; 810 xf86LoaderReqSymLists(vgahwSymbols, NULL); 811 799 812 /* Set up our ScrnInfoRec structure to describe our virtual 800 813 capabilities to X. */ … … 883 896 pScrn->bitmapBitOrder = BITMAP_BIT_ORDER; 884 897 898 /* VGA hardware initialisation */ 899 if (!vgaHWGetHWRec(pScrn)) 900 return FALSE; 901 885 902 #ifdef VBOX_DRI 886 903 /* Load the dri module. */ … … 1028 1045 flags = CMAP_RELOAD_ON_MODE_SWITCH; 1029 1046 1030 if(!xf86HandleColormaps(pScreen, 256, 1031 8 /* DAC is switchable to 8 bits per primary color */, 1032 VBOXLoadPalette, NULL, flags)) 1047 if(!vgaHWHandleColormaps(pScreen)) 1033 1048 return (FALSE); 1034 1049 … … 1135 1150 } 1136 1151 pScrn->vtSema = FALSE; 1152 1153 /* Destroy the VGA hardware record */ 1154 vgaHWFreeHWRec(pScrn); 1137 1155 1138 1156 /* Remove our observer functions from the X server call chains. */ … … 1319 1337 1320 1338 TRACE_ENTRY(); 1321 if ( NULL ==pVBox->base)1339 if (!pVBox->base) 1322 1340 { 1323 1341 pScrn->memPhysBase = pVBox->mapPhys; … … 1330 1348 PCI_DEV_MAP_FLAG_WRITABLE, 1331 1349 & pVBox->base); 1332 1333 if (pVBox->base) {1334 pScrn->memPhysBase = pVBox->mapPhys;1335 pVBox->VGAbase = xf86MapDomainMemory(pScrn->scrnIndex, 0,1336 pVBox->pciInfo,1337 0xa0000, 0x10000);1338 }1339 1350 #else 1340 1351 pVBox->base = xf86MapPciMem(pScrn->scrnIndex, … … 1342 1353 pVBox->pciTag, pVBox->mapPhys, 1343 1354 (unsigned) pVBox->mapSize); 1344 1345 if (pVBox->base) {1346 pScrn->memPhysBase = pVBox->mapPhys;1347 pVBox->VGAbase = xf86MapDomainMemory(pScrn->scrnIndex, 0,1348 pVBox->pciTag,1349 0xa0000, 0x10000);1355 #endif 1356 if (pVBox->base) 1357 { 1358 /* We need this for saving/restoring textmode */ 1359 VGAHWPTR(pScrn)->IOBase = pScrn->domainIOBase; 1360 rc = vgaHWMapMem(pScrn); 1350 1361 } 1351 #endif 1352 /* We need this for saving/restoring textmode */ 1353 pVBox->ioBase = pScrn->domainIOBase; 1354 1355 rc = pVBox->base != NULL; 1362 else 1363 rc = FALSE; 1356 1364 } 1357 1365 TRACE_LOG("returning %s\n", rc ? "TRUE" : "FALSE"); … … 1372 1380 pVBox->base, 1373 1381 pVBox->mapSize); 1374 xf86UnMapVidMem(pScrn->scrnIndex, pVBox->VGAbase, 0x10000);1375 1382 #else 1376 1383 xf86UnMapVidMem(pScrn->scrnIndex, pVBox->base, 1377 1384 (unsigned) pVBox->mapSize); 1378 xf86UnMapVidMem(pScrn->scrnIndex, pVBox->VGAbase, 0x10000); 1379 #endif 1385 #endif 1386 vgaHWUnmapMem(pScrn); 1380 1387 pVBox->base = NULL; 1381 1388 TRACE_EXIT(); 1382 1389 } 1383 1390 1384 static void1385 VBOXLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,1386 LOCO *colors, VisualPtr pVisual)1387 {1388 VBOXPtr pVBox = VBOXGetRec(pScrn);1389 int i, idx;1390 #define VBOXDACDelay() \1391 do { \1392 (void)inb(pVBox->ioBase + VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); \1393 (void)inb(pVBox->ioBase + VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); \1394 } while (0)1395 1396 TRACE_ENTRY();1397 for (i = 0; i < numColors; i++) {1398 idx = indices[i];1399 outb(pVBox->ioBase + VGA_DAC_WRITE_ADDR, idx);1400 VBOXDACDelay();1401 outb(pVBox->ioBase + VGA_DAC_DATA, colors[idx].red);1402 VBOXDACDelay();1403 outb(pVBox->ioBase + VGA_DAC_DATA, colors[idx].green);1404 VBOXDACDelay();1405 outb(pVBox->ioBase + VGA_DAC_DATA, colors[idx].blue);1406 VBOXDACDelay();1407 }1408 TRACE_EXIT();1409 }1410 1411 /*1412 * Just adapted from the std* functions in vgaHW.c1413 */1414 static void1415 WriteAttr(VBOXPtr pVBox, int index, int value)1416 {1417 (void) inb(pVBox->ioBase + VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET);1418 1419 index |= 0x20;1420 outb(pVBox->ioBase + VGA_ATTR_INDEX, index);1421 outb(pVBox->ioBase + VGA_ATTR_DATA_W, value);1422 }1423 1424 static int1425 ReadAttr(VBOXPtr pVBox, int index)1426 {1427 (void) inb(pVBox->ioBase + VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET);1428 1429 index |= 0x20;1430 outb(pVBox->ioBase + VGA_ATTR_INDEX, index);1431 return (inb(pVBox->ioBase + VGA_ATTR_DATA_R));1432 }1433 1434 #define WriteMiscOut(value) outb(pVBox->ioBase + VGA_MISC_OUT_W, value)1435 #define ReadMiscOut() inb(pVBox->ioBase + VGA_MISC_OUT_R)1436 #define WriteSeq(index, value) \1437 outb(pVBox->ioBase + VGA_SEQ_INDEX, (index));\1438 outb(pVBox->ioBase + VGA_SEQ_DATA, value)1439 1440 static int1441 ReadSeq(VBOXPtr pVBox, int index)1442 {1443 outb(pVBox->ioBase + VGA_SEQ_INDEX, index);1444 1445 return (inb(pVBox->ioBase + VGA_SEQ_DATA));1446 }1447 1448 #define WriteGr(index, value) \1449 outb(pVBox->ioBase + VGA_GRAPH_INDEX, index); \1450 outb(pVBox->ioBase + VGA_GRAPH_DATA, value)1451 1452 static int1453 ReadGr(VBOXPtr pVBox, int index)1454 {1455 outb(pVBox->ioBase + VGA_GRAPH_INDEX, index);1456 1457 return (inb(pVBox->ioBase + VGA_GRAPH_DATA));1458 }1459 1460 #define WriteCrtc(index, value) \1461 outb(pVBox->ioBase + (VGA_IOBASE_COLOR + VGA_CRTC_INDEX_OFFSET), index); \1462 outb(pVBox->ioBase + (VGA_IOBASE_COLOR + VGA_CRTC_DATA_OFFSET), value)1463 1464 static void1465 SeqReset(VBOXPtr pVBox, Bool start)1466 {1467 if (start) {1468 WriteSeq(0x00, 0x01); /* Synchronous Reset */1469 }1470 else {1471 WriteSeq(0x00, 0x03); /* End Reset */1472 }1473 }1474 1475 static void1476 SaveFonts(ScrnInfoPtr pScrn)1477 {1478 VBOXPtr pVBox = VBOXGetRec(pScrn);1479 unsigned char miscOut, attr10, gr4, gr5, gr6, seq2, seq4, scrn;1480 Bool cont = TRUE;1481 1482 TRACE_ENTRY();1483 if (pVBox->fonts != NULL)1484 cont = FALSE;1485 1486 if (cont)1487 {1488 /* If in graphics mode, don't save anything */1489 attr10 = ReadAttr(pVBox, 0x10);1490 if (attr10 & 0x01)1491 cont = FALSE;1492 }1493 1494 if (cont)1495 {1496 pVBox->fonts = xalloc(16384);1497 1498 /* save the registers that are needed here */1499 miscOut = ReadMiscOut();1500 gr4 = ReadGr(pVBox, 0x04);1501 gr5 = ReadGr(pVBox, 0x05);1502 gr6 = ReadGr(pVBox, 0x06);1503 seq2 = ReadSeq(pVBox, 0x02);1504 seq4 = ReadSeq(pVBox, 0x04);1505 1506 /* Force into colour mode */1507 WriteMiscOut(miscOut | 0x01);1508 1509 scrn = ReadSeq(pVBox, 0x01) | 0x20;1510 SeqReset(pVBox, TRUE);1511 WriteSeq(0x01, scrn);1512 SeqReset(pVBox, FALSE);1513 1514 WriteAttr(pVBox, 0x10, 0x01); /* graphics mode */1515 1516 /*font1 */1517 WriteSeq(0x02, 0x04); /* write to plane 2 */1518 WriteSeq(0x04, 0x06); /* enable plane graphics */1519 WriteGr(0x04, 0x02); /* read plane 2 */1520 WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */1521 WriteGr(0x06, 0x05); /* set graphics */1522 slowbcopy_frombus(pVBox->VGAbase, pVBox->fonts, 8192);1523 1524 /* font2 */1525 WriteSeq(0x02, 0x08); /* write to plane 3 */1526 WriteSeq(0x04, 0x06); /* enable plane graphics */1527 WriteGr(0x04, 0x03); /* read plane 3 */1528 WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */1529 WriteGr(0x06, 0x05); /* set graphics */1530 slowbcopy_frombus(pVBox->VGAbase, pVBox->fonts + 8192, 8192);1531 1532 scrn = ReadSeq(pVBox, 0x01) & ~0x20;1533 SeqReset(pVBox, TRUE);1534 WriteSeq(0x01, scrn);1535 SeqReset(pVBox, FALSE);1536 1537 /* Restore clobbered registers */1538 WriteAttr(pVBox, 0x10, attr10);1539 WriteSeq(0x02, seq2);1540 WriteSeq(0x04, seq4);1541 WriteGr(0x04, gr4);1542 WriteGr(0x05, gr5);1543 WriteGr(0x06, gr6);1544 WriteMiscOut(miscOut);1545 }1546 TRACE_EXIT();1547 }1548 1549 static void1550 RestoreFonts(ScrnInfoPtr pScrn)1551 {1552 VBOXPtr pVBox = VBOXGetRec(pScrn);1553 unsigned char miscOut, attr10, gr1, gr3, gr4, gr5, gr6, gr8, seq2, seq4, scrn;1554 1555 TRACE_ENTRY();1556 if (pVBox->fonts != NULL)1557 {1558 /* save the registers that are needed here */1559 miscOut = ReadMiscOut();1560 attr10 = ReadAttr(pVBox, 0x10);1561 gr1 = ReadGr(pVBox, 0x01);1562 gr3 = ReadGr(pVBox, 0x03);1563 gr4 = ReadGr(pVBox, 0x04);1564 gr5 = ReadGr(pVBox, 0x05);1565 gr6 = ReadGr(pVBox, 0x06);1566 gr8 = ReadGr(pVBox, 0x08);1567 seq2 = ReadSeq(pVBox, 0x02);1568 seq4 = ReadSeq(pVBox, 0x04);1569 1570 /* Force into colour mode */1571 WriteMiscOut(miscOut | 0x01);1572 1573 scrn = ReadSeq(pVBox, 0x01) & ~0x20;1574 SeqReset(pVBox, TRUE);1575 WriteSeq(0x01, scrn);1576 SeqReset(pVBox, FALSE);1577 1578 WriteAttr(pVBox, 0x10, 0x01); /* graphics mode */1579 if (pScrn->depth == 4) {1580 /* GJA */1581 WriteGr(0x03, 0x00); /* don't rotate, write unmodified */1582 WriteGr(0x08, 0xFF); /* write all bits in a byte */1583 WriteGr(0x01, 0x00); /* all planes come from CPU */1584 }1585 1586 WriteSeq(0x02, 0x04); /* write to plane 2 */1587 WriteSeq(0x04, 0x06); /* enable plane graphics */1588 WriteGr(0x04, 0x02); /* read plane 2 */1589 WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */1590 WriteGr(0x06, 0x05); /* set graphics */1591 slowbcopy_tobus(pVBox->fonts, pVBox->VGAbase, 8192);1592 1593 WriteSeq(0x02, 0x08); /* write to plane 3 */1594 WriteSeq(0x04, 0x06); /* enable plane graphics */1595 WriteGr(0x04, 0x03); /* read plane 3 */1596 WriteGr(0x05, 0x00); /* write mode 0, read mode 0 */1597 WriteGr(0x06, 0x05); /* set graphics */1598 slowbcopy_tobus(pVBox->fonts + 8192, pVBox->VGAbase, 8192);1599 1600 scrn = ReadSeq(pVBox, 0x01) & ~0x20;1601 SeqReset(pVBox, TRUE);1602 WriteSeq(0x01, scrn);1603 SeqReset(pVBox, FALSE);1604 1605 /* restore the registers that were changed */1606 WriteMiscOut(miscOut);1607 WriteAttr(pVBox, 0x10, attr10);1608 WriteGr(0x01, gr1);1609 WriteGr(0x03, gr3);1610 WriteGr(0x04, gr4);1611 WriteGr(0x05, gr5);1612 WriteGr(0x06, gr6);1613 WriteGr(0x08, gr8);1614 WriteSeq(0x02, seq2);1615 WriteSeq(0x04, seq4);1616 }1617 TRACE_EXIT();1618 }1619 1391 1620 1392 Bool … … 1639 1411 /* Make sure we save at least this information in case of failure */ 1640 1412 (void)VBEGetVBEMode(pVBox->pVbe, &pVBox->stateMode); 1641 SaveFonts(pScrn);1413 vgaHWSaveFonts(pScrn, &pVBox->vgaRegs); 1642 1414 1643 1415 if (!VBESaveRestore(pVBox->pVbe,function,(pointer)&pVBox->state, … … 1673 1445 { 1674 1446 VBESetVBEMode(pVBox->pVbe, pVBox->stateMode, NULL); 1675 RestoreFonts(pScrn);1447 vgaHWRestoreFonts(pScrn, &pVBox->vgaRegs); 1676 1448 } 1677 1449 }
Note:
See TracChangeset
for help on using the changeset viewer.