~ubuntu-branches/ubuntu/lucid/xserver-xorg-video-savage/lucid

« back to all changes in this revision

Viewing changes to src/savage_driver.c

  • Committer: Bazaar Package Importer
  • Author(s): David Nusinow
  • Date: 2006-09-30 14:31:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060930143103-a3j9c6n7mjqw01rv
Tags: 1:2.1.2-1
* New upstream release
  + Fixes DRI lock handling. Closes: #389794

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_driver.c,v 1.48tsi Exp $ */
2
1
/*
3
 
 * vim: sw=4 ts=8 ai ic:
4
 
 *
5
 
 *      XFree86 4.0 S3 Savage driver
6
 
 *
7
 
 *      Tim Roberts <timr@probo.com>
8
 
 *      Ani Joshi <ajoshi@unixbox.com>
9
 
 *
10
 
 *      TODO:  add credits for the 3.3.x authors...
11
 
 *
 
2
 * Copyright (C) 1994-2000 The XFree86 Project, Inc.  All Rights Reserved.
 
3
 * Copyright (c) 2003-2006, X.Org Foundation
 
4
 *
 
5
 * Permission is hereby granted, free of charge, to any person obtaining a
 
6
 * copy of this software and associated documentation files (the "Software"),
 
7
 * to deal in the Software without restriction, including without limitation
 
8
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
9
 * and/or sell copies of the Software, and to permit persons to whom the
 
10
 * Software is furnished to do so, subject to the following conditions:
 
11
 *
 
12
 * The above copyright notice and this permission notice shall be included in
 
13
 * all copies or substantial portions of the Software.
 
14
 *
 
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
 * FITESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
18
 * COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
20
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
21
 * DEALINGS IN THE SOFTWARE.
 
22
 *
 
23
 * Except as contained in this notice, the name of the copyright holder(s)
 
24
 * and author(s) shall not be used in advertising or otherwise to promote
 
25
 * the sale, use or other dealings in this Software without prior written
 
26
 * authorization from the copyright holder(s) and author(s).
 
27
 */
 
28
 
 
29
/**
 
30
 * \file savage_driver.c
 
31
 * 
 
32
 * \author Tim Roberts <timr@probo.com>
 
33
 * \author Ani Joshi <ajoshi@unixbox.com>
 
34
 *
 
35
 * \todo Add credits for the 3.3.x authors.
12
36
 */
13
37
 
14
38
#ifdef HAVE_CONFIG_H
64
88
                                  Bool verbose, int flags);
65
89
 
66
90
void SavageDGAInit(ScreenPtr);
67
 
static Bool SavageMapMMIO(ScrnInfoPtr pScrn);
68
 
static Bool SavageMapFB(ScrnInfoPtr pScrn);
 
91
static Bool SavageMapMem(ScrnInfoPtr pScrn);
69
92
static void SavageUnmapMem(ScrnInfoPtr pScrn, int All);
70
93
static Bool SavageModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
71
94
static Bool SavageCloseScreen(int scrnIndex, ScreenPtr pScreen);
115
138
    SavageProbe,
116
139
    SavageAvailableOptions,
117
140
    NULL,
118
 
    0
 
141
    0,
 
142
    NULL
119
143
};
120
144
 
121
145
 
193
217
     OPTION_PCI_BURST
194
218
    ,OPTION_PCI_RETRY
195
219
    ,OPTION_NOACCEL
 
220
    ,OPTION_ACCELMETHOD
196
221
    ,OPTION_LCD_CENTER
197
222
    ,OPTION_LCDCLOCK
198
223
    ,OPTION_MCLK
213
238
    ,OPTION_DISABLE_XVMC
214
239
    ,OPTION_DISABLE_TILE
215
240
    ,OPTION_DISABLE_COB
216
 
    ,OPTION_DRI
217
241
    ,OPTION_BCI_FOR_XV
218
242
    ,OPTION_DVI
219
243
    ,OPTION_BUS_TYPE
227
251
static const OptionInfoRec SavageOptions[] =
228
252
{
229
253
    { OPTION_NOACCEL,   "NoAccel",      OPTV_BOOLEAN, {0}, FALSE },
 
254
    { OPTION_ACCELMETHOD, "AccelMethod", OPTV_STRING,   {0}, FALSE },
230
255
    { OPTION_HWCURSOR,  "HWCursor",     OPTV_BOOLEAN, {0}, FALSE },
231
256
    { OPTION_SWCURSOR,  "SWCursor",     OPTV_BOOLEAN, {0}, FALSE },
232
257
    { OPTION_SHADOW_FB, "ShadowFB",     OPTV_BOOLEAN, {0}, FALSE },
244
269
    { OPTION_DISABLE_XVMC, "DisableXVMC", OPTV_BOOLEAN, {0}, FALSE },
245
270
    { OPTION_DISABLE_TILE, "DisableTile", OPTV_BOOLEAN, {0}, FALSE },
246
271
    { OPTION_DISABLE_COB,  "DisableCOB",  OPTV_BOOLEAN, {0}, FALSE },
247
 
    { OPTION_DRI,       "DRI",          OPTV_BOOLEAN, {0}, FALSE },
248
 
    { OPTION_BCI_FOR_XV,   "BCIforXv",  OPTV_BOOLEAN, {0}, FALSE },
249
 
    { OPTION_DVI,       "DVI",          OPTV_BOOLEAN, {0}, FALSE },
 
272
    { OPTION_BCI_FOR_XV,   "BCIforXv",    OPTV_BOOLEAN, {0}, FALSE },
 
273
    { OPTION_DVI,          "DVI",       OPTV_BOOLEAN, {0}, FALSE },
250
274
#ifdef XF86DRI
251
275
    { OPTION_BUS_TYPE,  "BusType",      OPTV_ANYSTR,  {0}, FALSE },
252
276
    { OPTION_DMA_TYPE,  "DmaType",      OPTV_ANYSTR,  {0}, FALSE },
405
429
    NULL
406
430
};
407
431
 
 
432
static const char *exaSymbols[] = {
 
433
    "exaDriverAlloc",
 
434
    "exaDriverInit",
 
435
    "exaDriverFini",
 
436
    "exaOffscreenAlloc",
 
437
    "exaOffscreenFree",
 
438
    "exaGetPixmapOffset",
 
439
    "exaGetPixmapPitch",
 
440
    "exaGetPixmapSize",
 
441
    NULL
 
442
};
 
443
 
408
444
static const char *shadowSymbols[] = {
409
445
    "ShadowFBInit",
410
446
    NULL
446
482
 
447
483
    if (!setupDone) {
448
484
        setupDone = TRUE;
449
 
        xf86AddDriver(&SAVAGE, module, 0);
 
485
        xf86AddDriver(&SAVAGE, module, 1);
450
486
        LoaderRefSymLists(vgaHWSymbols, fbSymbols, ramdacSymbols, 
451
 
                          xaaSymbols, shadowSymbols, vbeSymbols, vbeOptSymbols,
 
487
                          xaaSymbols,
 
488
                          exaSymbols,
 
489
                          shadowSymbols, vbeSymbols, vbeOptSymbols,
452
490
#ifdef XF86DRI
453
491
                          drmSymbols, driSymbols,
454
492
#endif
778
816
        foundScreen = TRUE;
779
817
    else
780
818
        for (i=0; i<numUsed; i++) {
781
 
            EntityInfoPtr pEnt;
782
 
            ScrnInfoPtr pScrn;
783
 
            pScrn    = NULL;
784
 
            pEnt = xf86GetEntityInfo(usedChips[i]);
785
 
            if((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
786
 
                 SavagePciChipsets, 0, 0, 0, 0, 0)))
787
 
            {
 
819
            EntityInfoPtr pEnt = xf86GetEntityInfo(usedChips[i]);;
 
820
            ScrnInfoPtr pScrn = xf86ConfigPciEntity(NULL, 0, usedChips[i],
 
821
                                                    NULL, RES_SHARED_VGA, 
 
822
                                                    NULL, NULL, NULL, NULL);
788
823
 
 
824
            if (pScrn != NULL) {
789
825
                pScrn->driverVersion = SAVAGE_VERSION;
790
826
                pScrn->driverName = SAVAGE_DRIVER_NAME;
791
827
                pScrn->name = "SAVAGE";
1156
1192
        psav->NoAccel = TRUE;
1157
1193
    }
1158
1194
 
 
1195
    if(!psav->NoAccel) {
 
1196
        from = X_DEFAULT;
 
1197
        char *strptr;
 
1198
        if((strptr = (char *)xf86GetOptValString(psav->Options, OPTION_ACCELMETHOD))) {
 
1199
            if(!xf86NameCmp(strptr,"XAA")) {
 
1200
                from = X_CONFIG;
 
1201
                psav->useEXA = FALSE;
 
1202
            } else if(!xf86NameCmp(strptr,"EXA")) {
 
1203
               from = X_CONFIG;
 
1204
               psav->useEXA = TRUE;
 
1205
            }
 
1206
       }
 
1207
       xf86DrvMsg(pScrn->scrnIndex, from, "Using %s acceleration architecture\n",
 
1208
                psav->useEXA ? "EXA" : "XAA");
 
1209
    }
 
1210
 
1159
1211
    if ((s = xf86GetOptValString(psav->Options, OPTION_OVERLAY))) {
1160
1212
        
1161
1213
        if (psav->shadowFB) {
1552
1604
        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
1553
1605
                   "Option: %s the COB\n",(psav->disableCOB?"Disable":"Enable"));
1554
1606
    }
1555
 
 
1556
 
#ifdef XF86DRI
1557
 
    psav->directRenderingEnabled =
1558
 
        !xf86ReturnOptValBool(psav->Options, OPTION_DRI, FALSE);
1559
 
 
1560
 
/* Disable DRI by default on the following Savage chipsets for the following
1561
 
 * bug reports:
1562
 
 *
1563
 
 * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=196011
1564
 
 * https://bugs.freedesktop.org/show_bug.cgi?id=6357
1565
 
 */
1566
 
 
1567
 
    if (psav->directRenderingEnabled) {
1568
 
        if (psav->ChipId == PCI_CHIP_SUPSAV_IXCSDR ||
1569
 
            psav->ChipId == PCI_CHIP_SUPSAV_IXCDDR ||
1570
 
            psav->ChipId == PCI_CHIP_PROSAVAGE_DDRK ||
1571
 
            psav->ChipId == PCI_CHIP_SAVAGE_IX_MV) {
1572
 
            xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DRI is disabled by default "
1573
 
                  "on this chipset as it is experimental and unstable.\n"
1574
 
                  "Please refer to https://bugs.freedesktop.org/show_bug.cgi?id=6357 for more\n"
1575
 
                  "details.\n");
1576
 
            psav->directRenderingEnabled=FALSE;
1577
 
        }
1578
 
    }
1579
 
#endif
1580
 
 
1581
1607
    if (psav->Chipset == S3_PROSAVAGE ||
1582
1608
        psav->Chipset == S3_TWISTER   ||
1583
1609
        psav->Chipset == S3_PROSAVAGEDDR)
1630
1656
            psav->HasCRTC2 = FALSE;
1631
1657
    }
1632
1658
 
1633
 
    if ((psav->IsSecondary || psav->IsPrimary) && !psav->UseBIOS)
 
1659
    if ((psav->IsSecondary || psav->IsPrimary) && !psav->UseBIOS) {
1634
1660
        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "BIOS currently required for Dualhead mode setting.\n");
 
1661
        return FALSE;   
 
1662
    }
 
1663
 
 
1664
    if (psav->IsSecondary &&
 
1665
        (pScrn->bitsPerPixel > 16) &&
 
1666
        !psav->NoAccel &&
 
1667
        (psav->Chipset == S3_SAVAGE_MX)) {
 
1668
        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No acceleration in Dualhead mode at depth 24\n");
 
1669
        return FALSE;
 
1670
    }
1635
1671
 
1636
1672
    /* maybe throw in some more sanity checks here */
1637
1673
 
1638
 
    if (!SavageMapMMIO(pScrn)) {
 
1674
    if (!SavageMapMem(pScrn)) {
1639
1675
        SavageFreeRec(pScrn);
1640
1676
        vbeFree(psav->pVbe);
1641
1677
        psav->pVbe = NULL;
1686
1722
    /* Compute the amount of video memory and offscreen memory. */
1687
1723
 
1688
1724
    if (!pScrn->videoRam) {
1689
 
        static unsigned char RamSavage3D[] = { 8, 4, 4, 2 };
 
1725
        static const unsigned char RamSavage3D[] = { 8, 4, 4, 2 };
1690
1726
        static unsigned char RamSavage4[] =  { 2, 4, 8, 12, 16, 32, 64, 32 };
1691
 
        static unsigned char RamSavageMX[] = { 2, 8, 4, 16, 8, 16, 4, 16 };
1692
 
        static unsigned char RamSavageNB[] = { 0, 2, 4, 8, 16, 32, 16, 2 };
 
1727
        static const unsigned char RamSavageMX[] = { 2, 8, 4, 16, 8, 16, 4, 16 };
 
1728
        static const unsigned char RamSavageNB[] = { 0, 2, 4, 8, 16, 32, 16, 2 };
1693
1729
 
1694
1730
        switch( psav->Chipset ) {
1695
1731
        case S3_SAVAGE3D:
1813
1849
        psav->videoRambytes = pScrn->videoRam * 1024;
1814
1850
        psav->CursorKByte = (psav->videoRambytes >> 10) - 4;
1815
1851
        psav->endfb = (psav->CursorKByte << 10) - 1;
 
1852
        psav->videoRambytes *= 2;
1816
1853
        xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
1817
1854
                "Using %dk of videoram for primary head\n",
1818
1855
                pScrn->videoRam);
1821
1858
    if(psav->IsSecondary)
1822
1859
    {  
1823
1860
        pScrn->videoRam /= 2;
1824
 
        psav->videoRambytes = pScrn->videoRam * 1024;
 
1861
        /*psav->videoRambytes = pScrn->videoRam * 1024;*/
1825
1862
        xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
1826
1863
                "Using %dk of videoram for secondary head\n",
1827
1864
                pScrn->videoRam);
1828
1865
    }
1829
1866
 
 
1867
    pScrn->fbOffset = (psav->IsSecondary)
 
1868
      ? pScrn->videoRam * 1024 : 0;
 
1869
 
1830
1870
    /* reset graphics engine to avoid memory corruption */
1831
1871
    VGAOUT8(vgaCRIndex, 0x66);
1832
1872
    cr66 = VGAIN8(vgaCRReg);
2008
2048
    xf86LoaderReqSymLists(fbSymbols, NULL);
2009
2049
 
2010
2050
    if( !psav->NoAccel ) {
2011
 
        if( !xf86LoadSubModule(pScrn, "xaa") ) {
2012
 
            SavageFreeRec(pScrn);
2013
 
            vbeFree(psav->pVbe);
2014
 
            psav->pVbe = NULL;
2015
 
            return FALSE;
 
2051
 
 
2052
        char *modName = NULL;
 
2053
        const char **symNames = NULL;
 
2054
 
 
2055
        if (psav->useEXA) {
 
2056
            modName = "exa";
 
2057
            symNames = exaSymbols;
 
2058
            XF86ModReqInfo req;
 
2059
            int errmaj, errmin;
 
2060
            memset(&req, 0, sizeof(req));
 
2061
            req.majorversion = 2;
 
2062
            req.minorversion = 0;
 
2063
            
 
2064
            if( !LoadSubModule(pScrn->module, modName, 
 
2065
                NULL, NULL, NULL, &req, &errmaj, &errmin) ) {
 
2066
                LoaderErrorMsg(NULL, modName, errmaj, errmin);
 
2067
                SavageFreeRec(pScrn);
 
2068
                vbeFree(psav->pVbe);
 
2069
                psav->pVbe = NULL;
 
2070
                return FALSE;
 
2071
            }
 
2072
        } else {
 
2073
            modName = "xaa";
 
2074
            symNames = xaaSymbols;
 
2075
            if( !xf86LoadSubModule(pScrn, modName) ) {
 
2076
                SavageFreeRec(pScrn);
 
2077
                vbeFree(psav->pVbe);
 
2078
                psav->pVbe = NULL;
 
2079
                return FALSE;
 
2080
            } 
2016
2081
        }
2017
 
        xf86LoaderReqSymLists(xaaSymbols, NULL );
 
2082
 
 
2083
        xf86LoaderReqSymLists(symNames, NULL );
 
2084
 
2018
2085
    }
2019
2086
 
2020
2087
    if (psav->hwcursor) {
2768
2835
}
2769
2836
 
2770
2837
 
2771
 
static Bool SavageMapMMIO(ScrnInfoPtr pScrn)
 
2838
static Bool SavageMapMem(ScrnInfoPtr pScrn)
2772
2839
{
2773
 
    SavagePtr psav;
2774
 
 
2775
 
    TRACE(("SavageMapMMIO()\n"));
2776
 
 
2777
 
    psav = SAVPTR(pScrn);
 
2840
    SavagePtr psav = SAVPTR(pScrn);
 
2841
    int mode;
 
2842
    unsigned i;
 
2843
 
 
2844
    TRACE(("SavageMapMem()\n"));
2778
2845
 
2779
2846
    if( S3_SAVAGE3D_SERIES(psav->Chipset) ) {
2780
 
        psav->MmioBase = psav->PciInfo->memBase[0] + SAVAGE_NEWMMIO_REGBASE_S3;
2781
 
        psav->FrameBufferBase = psav->PciInfo->memBase[0];
2782
 
    }
2783
 
    else {
2784
 
        psav->MmioBase = psav->PciInfo->memBase[0] + SAVAGE_NEWMMIO_REGBASE_S4;
2785
 
        psav->FrameBufferBase = psav->PciInfo->memBase[1];
2786
 
    }
2787
 
 
2788
 
    xf86DrvMsg( pScrn->scrnIndex, X_INFO,
2789
 
        "mapping MMIO @ 0x%lx with size 0x%x\n",
2790
 
        psav->MmioBase, SAVAGE_NEWMMIO_REGSIZE);
2791
 
 
2792
 
    psav->MapBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, psav->PciTag,
2793
 
                                  psav->MmioBase,
2794
 
                                  SAVAGE_NEWMMIO_REGSIZE);
2795
 
#if 0
2796
 
    psav->MapBaseDense = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT,
2797
 
                                       psav->PciTag,
2798
 
                                       psav->PciInfo->memBase[0],
2799
 
                                       0x8000);
2800
 
#endif
2801
 
    if (!psav->MapBase) {
2802
 
        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
2803
 
                   "Internal error: cound not map registers\n");
2804
 
        return FALSE;
2805
 
    }
 
2847
        psav->MmioRegion.bar = 0;
 
2848
        psav->MmioRegion.offset = SAVAGE_NEWMMIO_REGBASE_S3;
 
2849
 
 
2850
        psav->FbRegion.bar = 0;
 
2851
        psav->FbRegion.offset = 0;
 
2852
 
 
2853
        psav->last_bar = 0;
 
2854
    } else {
 
2855
        psav->MmioRegion.bar = 0;
 
2856
        psav->MmioRegion.offset = SAVAGE_NEWMMIO_REGBASE_S4;
 
2857
 
 
2858
        psav->FbRegion.bar = 1;
 
2859
        psav->FbRegion.offset = 0;
 
2860
 
 
2861
        psav->last_bar = 1;
 
2862
    }
 
2863
 
 
2864
    /* On Paramount and Savage 2000, aperture 0 is PCI base 2.  On other
 
2865
     * chipsets it's in the same BAR as the framebuffer.
 
2866
     */
 
2867
    if ((psav->Chipset == S3_SUPERSAVAGE) 
 
2868
        || (psav->Chipset == S3_SAVAGE2000)) {
 
2869
        psav->ApertureRegion.bar = 2;
 
2870
        psav->ApertureRegion.offset = 0;
 
2871
 
 
2872
        psav->last_bar = 2;
 
2873
    } else {
 
2874
        psav->ApertureRegion.bar = psav->FbRegion.bar;
 
2875
        psav->ApertureRegion.offset = 0x02000000;
 
2876
    }
 
2877
 
 
2878
 
 
2879
    psav->MmioBase = psav->PciInfo->memBase[ psav->MmioRegion.bar ]
 
2880
      + psav->MmioRegion.offset;
 
2881
 
 
2882
    psav->FrameBufferBase = psav->PciInfo->memBase[ psav->FbRegion.bar ]
 
2883
      + psav->FbRegion.offset;
 
2884
 
 
2885
    psav->ApertureBase = psav->PciInfo->memBase[ psav->FbRegion.bar ]
 
2886
      + psav->ApertureRegion.offset;
 
2887
 
 
2888
 
 
2889
    /* FIXME: This seems fine even on Savage3D where the same BAR contains the
 
2890
     * FIXME: MMIO space and the framebuffer.  Write-combining gets fixed up
 
2891
     * FIXME: later.  Someone should investigate this, though.  And kick S3
 
2892
     * FIXME: for doing something so silly.
 
2893
     */
 
2894
    mode = VIDMEM_MMIO;
 
2895
    for (i = 0; i <= psav->last_bar; i++) {
 
2896
        psav->bar_mappings[i] = xf86MapPciMem(pScrn->scrnIndex, mode,
 
2897
                                              psav->PciTag,
 
2898
                                              psav->PciInfo->memBase[i],
 
2899
                                              (1U << psav->PciInfo->size[i]));
 
2900
        if (!psav->bar_mappings[i]) {
 
2901
            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 
2902
                       "Internal error: cound not map PCI region %u, last BAR = %u\n",
 
2903
                       i, psav->last_bar);
 
2904
            return FALSE;
 
2905
        }
 
2906
 
 
2907
        mode = VIDMEM_FRAMEBUFFER;
 
2908
    }
 
2909
 
 
2910
    psav->MapBase = psav->bar_mappings[ psav->MmioRegion.bar ]
 
2911
      + psav->MmioRegion.offset;
2806
2912
 
2807
2913
    psav->BciMem = psav->MapBase + 0x10000;
2808
2914
 
2809
2915
    SavageEnableMMIO(pScrn);
2810
2916
 
2811
 
    return TRUE;
2812
 
}
2813
 
 
2814
 
#define TRANSPARENCY_KEY 0xff;
2815
 
 
2816
 
static Bool SavageMapFB(ScrnInfoPtr pScrn)
2817
 
{
2818
 
    SavagePtr psav = SAVPTR(pScrn);
2819
 
 
2820
 
    TRACE(("SavageMapFB()\n"));
2821
 
 
2822
 
    xf86DrvMsg( pScrn->scrnIndex, X_PROBED,
2823
 
        "mapping framebuffer @ 0x%lx with size 0x%x\n", 
2824
 
        psav->FrameBufferBase, psav->videoRambytes);
2825
 
 
2826
 
    if (psav->videoRambytes) {
2827
 
        psav->FBBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
2828
 
                                     psav->PciTag, psav->FrameBufferBase,
2829
 
                                     psav->videoRambytes);
2830
 
        if (!psav->FBBase) {
2831
 
            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
2832
 
                       "Internal error: could not map framebuffer\n");
2833
 
            return FALSE;
2834
 
        }
2835
 
        if (psav->IsSecondary)
2836
 
            psav->FBStart = psav->FBBase + 0x1000000;
2837
 
        else    
2838
 
            psav->FBStart = psav->FBBase;
2839
 
    }
2840
 
 
2841
 
    if ((psav->Chipset == S3_SUPERSAVAGE) || (psav->Chipset == S3_SAVAGE2000))
2842
 
        /* paramount, savage2000 aperture 0 is pci base 2 */
2843
 
        psav->ApertureBase =  psav->PciInfo->memBase[2];
2844
 
    else
2845
 
        psav->ApertureBase = psav->FrameBufferBase + 0x02000000;
 
2917
    psav->FBBase = psav->bar_mappings[ psav->FbRegion.bar ]
 
2918
      + psav->FbRegion.offset;
 
2919
 
 
2920
    psav->FBStart = (psav->IsSecondary)
 
2921
      ? psav->FBBase + 0x1000000 : psav->FBBase;
 
2922
 
 
2923
    psav->ApertureMap = psav->bar_mappings[ psav->ApertureRegion.bar ]
 
2924
      + psav->ApertureRegion.offset;
2846
2925
 
2847
2926
    if (psav->IsSecondary) {
2848
 
        psav->ApertureMap = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
2849
 
                                      psav->PciTag, psav->ApertureBase,
2850
 
                                      0x01000000 * 2);
2851
2927
        psav->ApertureMap += 0x1000000;
2852
 
    } else if (psav->IsPrimary) {
2853
 
        psav->ApertureMap = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
2854
 
                                      psav->PciTag, psav->ApertureBase,
2855
 
                                      0x01000000 * 2);
2856
 
    } else {
2857
 
        psav->ApertureMap = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
2858
 
                                      psav->PciTag, psav->ApertureBase,
2859
 
                                      0x01000000 * 5);
2860
 
    }
2861
 
 
2862
 
    if (!psav->ApertureMap) {
2863
 
        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
2864
 
                   "Internal error: could not map aperture\n");
2865
 
        return FALSE;
2866
 
    }
2867
 
    else
2868
 
    {
2869
 
        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
2870
 
                   "map aperture:%p\n",psav->ApertureMap);
2871
 
 
2872
 
    }
2873
 
 
2874
 
    if (psav->IsSecondary)
2875
 
        pScrn->fbOffset = pScrn->videoRam * 1024;
2876
 
    else
2877
 
        pScrn->fbOffset = 0;
2878
 
 
2879
 
    pScrn->memPhysBase = psav->PciInfo->memBase[0] + pScrn->fbOffset;
 
2928
    }
 
2929
 
 
2930
    pScrn->memPhysBase = psav->PciInfo->memBase[0];
2880
2931
 
2881
2932
    return TRUE;
2882
2933
}
2884
2935
 
2885
2936
static void SavageUnmapMem(ScrnInfoPtr pScrn, int All)
2886
2937
{
2887
 
    SavagePtr psav;
2888
 
 
2889
 
    psav = SAVPTR(pScrn);
 
2938
    SavagePtr psav = SAVPTR(pScrn);
 
2939
    unsigned i;
2890
2940
 
2891
2941
    TRACE(("SavageUnmapMem(%x,%x)\n", psav->MapBase, psav->FBBase));
2892
2942
 
2897
2947
 
2898
2948
    SavageDisableMMIO(pScrn);
2899
2949
 
2900
 
    if (All && psav->MapBase) {
2901
 
        xf86UnMapVidMem(pScrn->scrnIndex, (pointer)psav->MapBase,
2902
 
                        SAVAGE_NEWMMIO_REGSIZE);
 
2950
    for (i = (All) ? 0 : 1; i <= psav->last_bar; i++) {
 
2951
        if (psav->bar_mappings[i]) {
 
2952
            xf86UnMapVidMem(pScrn->scrnIndex, psav->bar_mappings[i],
 
2953
                            (1U << psav->PciInfo->size[i]));
 
2954
            psav->bar_mappings[i] = NULL;
 
2955
        }
 
2956
    }
 
2957
 
 
2958
    if (All) {
2903
2959
        psav->MapBase = 0;
2904
 
    }
2905
 
 
2906
 
    if (psav->FBBase) {
2907
 
        xf86UnMapVidMem(pScrn->scrnIndex, (pointer)psav->FBBase,
2908
 
                        psav->videoRambytes);
2909
 
        psav->FBBase = 0;
2910
 
    }
2911
 
 
2912
 
#if 0
2913
 
    xf86UnMapVidMem(pScrn->scrnIndex, (pointer)psav->MapBaseDense,
2914
 
                    0x8000);
2915
 
#endif
 
2960
        psav->BciMem = 0;
 
2961
    }
 
2962
    
 
2963
    psav->FBBase = 0;
 
2964
    psav->FBStart = 0;
 
2965
    psav->ApertureMap = 0;
2916
2966
 
2917
2967
    return;
2918
2968
}
3038
3088
 
3039
3089
    SavageEnableMMIO(pScrn);
3040
3090
 
3041
 
    if (!SavageMapFB(pScrn))
3042
 
        return FALSE;
3043
 
 
3044
3091
    psav->FBStart2nd = 0;
3045
3092
 
3046
3093
    if (psav->overlayDepth) {
3216
3263
    miInitializeBackingStore(pScreen);
3217
3264
    xf86SetBackingStore(pScreen);
3218
3265
 
3219
 
    if( !psav->shadowFB )
 
3266
    if( !psav->shadowFB && !psav->useEXA )
3220
3267
        SavageDGAInit(pScreen);
3221
3268
 
3222
3269
    miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
3780
3827
    }
3781
3828
#endif
3782
3829
 
 
3830
    if (psav->EXADriverPtr) {
 
3831
        exaDriverFini(pScreen);
 
3832
        psav->EXADriverPtr = NULL;
 
3833
    }
 
3834
 
3783
3835
    if( psav->AccelInfoRec ) {
3784
3836
        XAADestroyInfoRec( psav->AccelInfoRec );
3785
3837
        psav->AccelInfoRec = NULL;
4007
4059
 
4008
4060
    /* choose CLUT */
4009
4061
    if (psav->IsPrimary) {
 
4062
        /* enable CLUT 1 */
 
4063
        VGAOUT8(0x3c4, 0x21);
 
4064
        byte = VGAIN8(0x3c5);
 
4065
        VGAOUT8(0x3c5, (byte & ~0x01));
 
4066
        /* select CLUT 1 */
4010
4067
        VGAOUT8(0x3c4, 0x47);
4011
4068
        byte = VGAIN8(0x3c5);
4012
4069
        VGAOUT8(0x3c5, (byte & ~0x03) | 0x01); /* CLUT 1 */
4013
4070
    } else if (psav->IsSecondary) {
 
4071
        /* enable CLUT 2 */
 
4072
        VGAOUT8(0x3c4, 0x21);
 
4073
        byte = VGAIN8(0x3c5);
 
4074
        VGAOUT8(0x3c5, (byte & ~0x10));
 
4075
        /* select CLUT 2 */
4014
4076
        VGAOUT8(0x3c4, 0x47);
4015
4077
        byte = VGAIN8(0x3c5);
4016
4078
        VGAOUT8(0x3c5, (byte & ~0x03) | 0x02); /* CLUT 2 */