VirtualBox

Changeset 3267 in vbox


Ignore:
Timestamp:
Jun 25, 2007 9:22:21 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
22329
Message:

Restored the old X11 Additions video driver in order to preserve its SVN history

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/xgraphics/vboxvideo.c

    r3247 r3267  
    5555#define DEBUG_VERB 2
    5656
    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"
    6462# endif
    6563#endif
     
    126124 */
    127125
    128 #ifdef XORG_7X
    129126_X_EXPORT DriverRec VBOXDRV = {
    130 #else
    131 DriverRec VBOXDRV = {
    132 #endif
    133127    VBOX_VERSION,
    134128    VBOX_DRIVER_NAME,
     
    137131    VBOXAvailableOptions,
    138132    NULL,
    139 #ifdef XORG_7X
    140133    0,
    141134    NULL
    142 #else
    143     0
    144 #endif
    145135};
    146136
     
    158148
    159149typedef enum {
    160     OPTION_SHADOW_FB
    161 #ifdef XORG_7X
    162     ,
     150    OPTION_SHADOW_FB,
    163151    OPTION_DFLT_REFRESH,
    164152    OPTION_MODESET_CLEAR_SCREEN
    165 #endif
    166153} VBOXOpts;
    167154
     
    191178
    192179static const char *vbeSymbols[] = {
    193 #ifdef XORG_7X
    194180    "VBEExtendedInit",
    195181    "VBEFindSupportedDepths",
    196 #else /* !XORG_7X */
    197     "VBEFreeModeInfo",
    198 #endif /* XORG_7X */
    199182    "VBEGetModeInfo",
    200183    "VBEGetVBEInfo",
    201184    "VBEGetVBEMode",
    202 #ifdef XORG_7X
    203185    "VBEPrintModes",
    204 #else /* !XORG_7X */
    205     "VBEInit",
    206 #endif /* XORG_7X */
    207186    "VBESaveRestore",
    208187    "VBESetDisplayStart",
     
    210189    "VBESetGetLogicalScanlineLength",
    211190    "VBESetGetPaletteData",
    212 #ifdef XORG_7X
    213191    "VBESetModeNames",
    214192    "VBESetModeParameters",
    215 #endif
    216193    "VBESetVBEMode",
    217 #ifdef XORG_7X
    218194    "VBEValidateModes",
    219 #endif
    220195    "vbeDoEDID",
    221196    "vbeFree",
     
    239214    MODINFOSTRING1,
    240215    MODINFOSTRING2,
    241 #ifdef XORG_7X
    242216    XORG_VERSION_CURRENT,
    243 #else /* !XORG_7X */
    244     XF86_VERSION_CURRENT,
    245 #endif /* XORG_7X */
    246217    1,                          /* Module major version. Xorg-specific */
    247218    0,                          /* Module minor version. Xorg-specific */
    248 #ifdef XORG_7X
    249219    1,                          /* Module patchlevel. Xorg-specific */
    250 #else
    251     0,                          /* Module patchlevel. Xorg-specific */
    252 #endif
    253220    ABI_CLASS_VIDEODRV,         /* This is a video driver */
    254221    ABI_VIDEODRV_VERSION,
     
    261228 * followed by "ModuleData".
    262229 */
    263 #ifdef XORG_7X
    264230_X_EXPORT XF86ModuleData vboxvideoModuleData = { &vboxVersionRec, vboxSetup, NULL };
    265 #else /* !XORG_7X */
    266 XF86ModuleData vboxvideoModuleData = { &vboxVersionRec, vboxSetup, NULL };
    267 #endif /* XORG_7X */
    268231
    269232static pointer
     
    576539        /* VBox does only support screen widths which are a multiple of 8 */
    577540        m->HDisplay      = (x + 7) & ~7;
     541        m->HSyncStart    = m->HDisplay + 2;
     542        m->HSyncEnd      = m->HDisplay + 4;
     543        m->HTotal        = m->HDisplay + 6;
    578544        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;
    579549        m->name          = strdup(pScrn->display->modes[i]);
    580550        if (!m_prev)
     
    651621    /* We make use of the X11 VBE code to save and restore text mode, in
    652622       order to keep our code simple. */
    653 #ifdef XORG_7X
    654623    if ((pVBox->pVbe = VBEExtendedInit(NULL, pVBox->pEnt->index,
    655624                                       SET_BIOS_SCRATCH
    656625                                       | RESTORE_BIOS_SCRATCH)) == NULL)
    657 #else
    658     if ((pVBox->pVbe = VBEInit(NULL, pVBox->pEnt->index)) == NULL)
    659 #endif
    660626        return (FALSE);
    661627
     
    681647        return FALSE;
    682648
    683 #ifdef XORG_7X
    684649    /* set the viewport */
    685650    VBOXAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
     
    687652    /* Blank the screen for aesthetic reasons. */
    688653    VBOXSaveScreen(pScreen, SCREEN_SAVER_ON);
    689 #endif
    690654
    691655    /* mi layer - reset the visual list (?)*/
     
    775739    if (!VBOXSetMode(pScrn, pScrn->currentMode))
    776740        return FALSE;
    777 #ifdef XORG_7X
    778741    VBOXAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
    779 #endif  /* XORG_7X defined */
    780742    if (pVBox->useVbva == TRUE)
    781743        vboxEnableVbva(pScrn);
     
    804766    if (pScrn->vtSema) {
    805767        VBOXSaveRestore(xf86Screens[scrnIndex], MODE_RESTORE);
    806 #ifdef XORG_7X
    807768        if (pVBox->savedPal)
    808769            VBESetGetPaletteData(pVBox->pVbe, TRUE, 0, 256,
    809770                                 pVBox->savedPal, FALSE, TRUE);
    810 #else
    811         VBESetGetPaletteData(pVBox->pVbe, TRUE, 0, 256,
    812                              pVBox->savedPal, FALSE, TRUE);
    813 #endif
    814771        VBOXUnmapVidMem(pScrn);
    815772    }
     
    828785 * Quoted from "How to add an (S)VGA driver to XFree86"
    829786 * (http://www.xfree86.org/3.3.6/VGADriver.html):
    830  * 
     787 *
    831788 * The ValidMode() function is required. It is used to check for any
    832789 * chipset-dependent reasons why a graphics mode might not be valid. It gets
     
    834791 * no special checking will be required and this function will simply return
    835792 * 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.
    836797 */
    837798static ModeStatus
     
    841802    ScrnInfoPtr pScrn = xf86Screens[scrn];
    842803    MonPtr mon = pScrn->monitor;
    843     ModeStatus ret;
     804    ModeStatus ret = MODE_BAD;
    844805    DisplayModePtr mode;
    845806    float v;
     
    871832    }
    872833
     834    if (ret != MODE_OK)
     835    {
     836        xf86DrvMsg(scrn, X_WARNING, "Graphics mode %s rejected by the X server\n", p->name);
     837    }
    873838    return ret;
    874839}
     
    977942    if (pVBox->base) {
    978943        pScrn->memPhysBase = pVBox->mapPhys;
    979 # ifdef XORG_7X
    980944        pVBox->VGAbase = xf86MapDomainMemory(pScrn->scrnIndex, 0,
    981945                                             pVBox->pciTag,
    982946                                             0xa0000, 0x10000);
    983 # else
    984         pVBox->VGAbase = xf86MapVidMem(pScrn->scrnIndex, 0,
    985                                        0xa0000, 0x10000);
    986 # endif
    987     }
    988 #ifdef XORG_7X
     947    }
    989948    /* We need this for saving/restoring textmode */
    990949    pVBox->ioBase = pScrn->domainIOBase;
    991 #endif
    992950
    993951    return (pVBox->base != NULL);
     
    1012970                LOCO *colors, VisualPtr pVisual)
    1013971{
    1014 #ifdef XORG_7X
    1015972    VBOXPtr pVBox = VBOXGetRec(pScrn);
    1016973    int i, idx;
    1017 #endif
    1018 #ifdef XORG_7X
    1019974#define VBOXDACDelay()                                                      \
    1020975    do {                                                                    \
     
    1022977           (void)inb(pVBox->ioBase + VGA_IOBASE_COLOR + VGA_IN_STAT_1_OFFSET); \
    1023978    } while (0)
    1024 #else
    1025 #define WriteDacWriteAddr(value)        outb(VGA_DAC_WRITE_ADDR, value)
    1026 #define WriteDacData(value)             outb(VGA_DAC_DATA, value);
    1027 #undef DACDelay
    1028 #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 #endif
    1035979
    1036980    for (i = 0; i < numColors; i++) {
    1037981           idx = indices[i];
    1038 #ifdef XORG_7X
    1039982           outb(pVBox->ioBase + VGA_DAC_WRITE_ADDR, idx);
    1040983           VBOXDACDelay();
     
    1045988           outb(pVBox->ioBase + VGA_DAC_DATA, colors[idx].blue);
    1046989           VBOXDACDelay();
    1047 #else
    1048            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 #endif
    1057990    }
    1058991}
     
    1062995 */
    1063996static void
    1064 #ifdef XORG_7X
    1065997WriteAttr(VBOXPtr pVBox, int index, int value)
    1066998{
     
    10701002    outb(pVBox->ioBase + VGA_ATTR_INDEX, index);
    10711003    outb(pVBox->ioBase + VGA_ATTR_DATA_W, value);
    1072 #else
    1073 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 #endif
    10831004}
    10841005
    10851006static int
    1086 #ifdef XORG_7X
    10871007ReadAttr(VBOXPtr pVBox, int index)
    10881008{
     
    10921012    outb(pVBox->ioBase + VGA_ATTR_INDEX, index);
    10931013    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
    11081016#define WriteMiscOut(value)     outb(pVBox->ioBase + VGA_MISC_OUT_W, value)
    11091017#define ReadMiscOut()           inb(pVBox->ioBase + VGA_MISC_OUT_R)
     
    11111019        outb(pVBox->ioBase + VGA_SEQ_INDEX, (index));\
    11121020        outb(pVBox->ioBase + VGA_SEQ_DATA, value)
    1113 #else
    1114 #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 #endif
    11201021
    11211022static int
    1122 #ifdef XORG_7X
    11231023ReadSeq(VBOXPtr pVBox, int index)
    11241024{
     
    11261026
    11271027    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
    11381030#define WriteGr(index, value)                           \
    11391031    outb(pVBox->ioBase + VGA_GRAPH_INDEX, index);       \
    11401032    outb(pVBox->ioBase + VGA_GRAPH_DATA, value)
    1141 #else
    1142 #define WriteGr(index, value)   outb(VGA_GRAPH_INDEX, index);\
    1143                                 outb(VGA_GRAPH_DATA, value)
    1144 #endif
    11451033
    11461034static int
    1147 #ifdef XORG_7X
    11481035ReadGr(VBOXPtr pVBox, int index)
    11491036{
     
    11511038
    11521039    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
    11631042#define WriteCrtc(index, value)                                              \
    11641043    outb(pVBox->ioBase + (VGA_IOBASE_COLOR + VGA_CRTC_INDEX_OFFSET), index); \
    11651044    outb(pVBox->ioBase + (VGA_IOBASE_COLOR + VGA_CRTC_DATA_OFFSET), value)
    1166 #else
    1167 #define WriteCrtc(index, value) outb(VGA_CRTC_INDEX_OFFSET, index);\
    1168                                 outb(VGA_CRTC_DATA_OFFSET, value)
    1169 #endif
    11701045
    11711046static void
    1172 #ifdef XORG_7X
    11731047SeqReset(VBOXPtr pVBox, Bool start)
    11741048{
     
    11791053           WriteSeq(0x00, 0x03);                /* End Reset */
    11801054    }
    1181 #else
    1182 SeqReset(Bool start)
    1183 {
    1184     if (start) {
    1185            WriteSeq(0x00, 0x01);                /* Synchronous Reset */
    1186     }
    1187     else {
    1188            WriteSeq(0x00, 0x03);                /* End Reset */
    1189     }
    1190 #endif
    11911055}
    11921056
     
    12011065
    12021066    /* If in graphics mode, don't save anything */
    1203 #ifdef XORG_7X
    12041067    attr10 = ReadAttr(pVBox, 0x10);
    1205 #else
    1206     attr10 = ReadAttr(0x10);
    1207 #endif
    12081068    if (attr10 & 0x01)
    12091069        return;
     
    12131073    /* save the registers that are needed here */
    12141074    miscOut = ReadMiscOut();
    1215 #ifdef XORG_7X
    12161075    gr4 = ReadGr(pVBox, 0x04);
    12171076    gr5 = ReadGr(pVBox, 0x05);
     
    12191078    seq2 = ReadSeq(pVBox, 0x02);
    12201079    seq4 = ReadSeq(pVBox, 0x04);
    1221 #else
    1222     gr4 = ReadGr(0x04);
    1223     gr5 = ReadGr(0x05);
    1224     gr6 = ReadGr(0x06);
    1225     seq2 = ReadSeq(0x02);
    1226     seq4 = ReadSeq(0x04);
    1227 #endif
    12281080
    12291081    /* Force into colour mode */
    12301082    WriteMiscOut(miscOut | 0x01);
    12311083
    1232 #ifdef XORG_7X
    12331084    scrn = ReadSeq(pVBox, 0x01) | 0x20;
    12341085    SeqReset(pVBox, TRUE);
    1235 #else
    1236     scrn = ReadSeq(0x01) | 0x20;
    1237     SeqReset(TRUE);
    1238 #endif
    12391086    WriteSeq(0x01, scrn);
    1240 #ifdef XORG_7X
    12411087    SeqReset(pVBox, FALSE);
    1242 #else
    1243     SeqReset(FALSE);
    1244 #endif
    1245 
    1246 #ifdef XORG_7X
     1088
    12471089    WriteAttr(pVBox, 0x10, 0x01);       /* graphics mode */
    1248 #else
    1249     WriteAttr(0x10, 0x01);      /* graphics mode */
    1250 #endif
    12511090
    12521091    /*font1 */
     
    12661105    slowbcopy_frombus(pVBox->VGAbase, pVBox->fonts + 8192, 8192);
    12671106
    1268 #ifdef XORG_7X
    12691107    scrn = ReadSeq(pVBox, 0x01) & ~0x20;
    12701108    SeqReset(pVBox, TRUE);
    1271 #else
    1272     scrn = ReadSeq(0x01) & ~0x20;
    1273     SeqReset(TRUE);
    1274 #endif
    12751109    WriteSeq(0x01, scrn);
    1276 #ifdef XORG_7X
    12771110    SeqReset(pVBox, FALSE);
    1278 #else
    1279     SeqReset(FALSE);
    1280 #endif
    12811111
    12821112    /* Restore clobbered registers */
    1283 #ifdef XORG_7X
    12841113    WriteAttr(pVBox, 0x10, attr10);
    1285 #else
    1286     WriteAttr(0x10, attr10);
    1287 #endif
    12881114    WriteSeq(0x02, seq2);
    12891115    WriteSeq(0x04, seq4);
     
    13051131    /* save the registers that are needed here */
    13061132    miscOut = ReadMiscOut();
    1307 #ifdef XORG_7X
    13081133    attr10 = ReadAttr(pVBox, 0x10);
    13091134    gr1 = ReadGr(pVBox, 0x01);
     
    13151140    seq2 = ReadSeq(pVBox, 0x02);
    13161141    seq4 = ReadSeq(pVBox, 0x04);
    1317 #else
    1318     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 #endif
    13281142
    13291143    /* Force into colour mode */
    13301144    WriteMiscOut(miscOut | 0x01);
    13311145
    1332 #ifdef XORG_7X
    13331146    scrn = ReadSeq(pVBox, 0x01) & ~0x20;
    13341147    SeqReset(pVBox, TRUE);
    1335 #else
    1336     scrn = ReadSeq(0x01) | 0x20;
    1337     SeqReset(TRUE);
    1338 #endif
    13391148    WriteSeq(0x01, scrn);
    1340 #ifdef XORG_7X
    13411149    SeqReset(pVBox, FALSE);
    1342 #else
    1343     SeqReset(FALSE);
    1344 #endif
    1345 
    1346 #ifdef XORG_7X
     1150
    13471151    WriteAttr(pVBox, 0x10, 0x01);       /* graphics mode */
    1348 #else
    1349     WriteAttr(0x10, 0x01);      /* graphics mode */
    1350 #endif
    13511152    if (pScrn->depth == 4) {
    13521153        /* GJA */
     
    13701171    slowbcopy_tobus(pVBox->fonts + 8192, pVBox->VGAbase, 8192);
    13711172
    1372 #ifdef XORG_7X
    13731173    scrn = ReadSeq(pVBox, 0x01) & ~0x20;
    13741174    SeqReset(pVBox, TRUE);
    1375 #else
    1376     scrn = ReadSeq(0x01) & ~0x20;
    1377     SeqReset(TRUE);
    1378 #endif
    13791175    WriteSeq(0x01, scrn);
    1380 #ifdef XORG_7X
    13811176    SeqReset(pVBox, FALSE);
    1382 #else
    1383     SeqReset(FALSE);
    1384 #endif
    13851177
    13861178    /* restore the registers that were changed */
    13871179    WriteMiscOut(miscOut);
    1388 #ifdef XORG_7X
    13891180    WriteAttr(pVBox, 0x10, attr10);
    1390 #else
    1391     WriteAttr(0x10, attr10);
    1392 #endif
    13931181    WriteGr(0x01, gr1);
    13941182    WriteGr(0x03, gr3);
     
    14051193{
    14061194    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
    1407 #ifdef XORG_7X
    14081195    VBOXPtr pVBox = VBOXGetRec(pScrn);
    1409 #endif
    14101196    Bool on = xf86IsUnblank(mode);
    14111197
     
    14141200
    14151201    if (pScrn->vtSema) {
    1416 #ifdef XORG_7X
    14171202        unsigned char scrn = ReadSeq(pVBox, 0x01);
    1418 #else
    1419         unsigned char scrn = ReadSeq(0x01);
    1420 #endif
    14211203
    14221204        if (on)
     
    14241206        else
    14251207            scrn |= 0x20;
    1426 #ifdef XORG_7X
    14271208        SeqReset(pVBox, TRUE);
    14281209        WriteSeq(0x01, scrn);
    14291210        SeqReset(pVBox, FALSE);
    1430 #else
    1431         SeqReset(TRUE);
    1432         WriteSeq(0x01, scrn);
    1433         SeqReset(FALSE);
    1434 #endif
    14351211    }
    14361212
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette