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

« back to all changes in this revision

Viewing changes to src/savage_accel.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:
20
20
#include "config.h"
21
21
#endif
22
22
 
23
 
#include <X11/Xarch.h>
24
 
#include "xaalocal.h"
25
 
#include "xaarop.h"
26
 
#include "miline.h"
27
 
 
28
23
#include "savage_driver.h"
29
24
#include "savage_regs.h"
30
25
#include "savage_bci.h"
39
34
 
40
35
/* Forward declaration of functions used in the driver */
41
36
 
42
 
static void SavageSetupForScreenToScreenCopy(
43
 
    ScrnInfoPtr pScrn,
44
 
    int xdir, 
45
 
    int ydir,
46
 
    int rop,
47
 
    unsigned planemask,
48
 
    int transparency_color);
49
 
 
50
 
static void SavageSubsequentScreenToScreenCopy(
51
 
    ScrnInfoPtr pScrn,
52
 
    int x1,
53
 
    int y1,
54
 
    int x2,
55
 
    int y2,
56
 
    int w,
57
 
    int h);
58
 
 
59
 
static void SavageSetupForSolidFill(
60
 
    ScrnInfoPtr pScrn,
61
 
    int color, 
62
 
    int rop,
63
 
    unsigned int planemask);
64
 
 
65
 
static void SavageSubsequentSolidFillRect(
66
 
    ScrnInfoPtr pScrn,
67
 
    int x,
68
 
    int y,
69
 
    int w,
70
 
    int h);
71
 
 
72
 
static void SavageSubsequentSolidBresenhamLine(
73
 
    ScrnInfoPtr pScrn,
74
 
    int x1,
75
 
    int y1,
76
 
    int e1,
77
 
    int e2,
78
 
    int err,
79
 
    int length,
80
 
    int octant);
81
 
 
82
 
#if 0
83
 
static void SavageSubsequentSolidTwoPointLine(
84
 
    ScrnInfoPtr pScrn,
85
 
    int x1,
86
 
    int y1,
87
 
    int x2,
88
 
    int y2,
89
 
    int bias);
90
 
#endif
91
 
 
92
 
#if 0
93
 
static void SavageSetupForScreenToScreenColorExpand(
94
 
    ScrnInfoPtr pScrn,
95
 
    int bg,
96
 
    int fg,
97
 
    int rop,
98
 
    unsigned int planemask);
99
 
 
100
 
static void SavageSubsequentScreenToScreenColorExpand(
101
 
    ScrnInfoPtr pScrn,
102
 
    int x,
103
 
    int y,
104
 
    int w,
105
 
    int h,
106
 
    int skipleft);
107
 
#endif
108
 
 
109
 
static void SavageSetupForCPUToScreenColorExpandFill(
110
 
    ScrnInfoPtr pScrn,
111
 
    int fg,
112
 
    int bg,
113
 
    int rop,
114
 
    unsigned int planemask);
115
 
 
116
 
static void SavageSubsequentScanlineCPUToScreenColorExpandFill(
117
 
    ScrnInfoPtr pScrn,
118
 
    int x,
119
 
    int y,
120
 
    int w,
121
 
    int h,
122
 
    int skipleft);
123
 
 
124
 
static void SavageSubsequentColorExpandScanline(
125
 
    ScrnInfoPtr pScrn,
126
 
    int buffer_no);
127
 
 
128
 
static void SavageSetupForMono8x8PatternFill(
129
 
    ScrnInfoPtr pScrn,
130
 
    int patternx,
131
 
    int patterny,
132
 
    int fg, 
133
 
    int bg,
134
 
    int rop,
135
 
    unsigned int planemask);
136
 
 
137
 
static void SavageSubsequentMono8x8PatternFillRect(
138
 
    ScrnInfoPtr pScrn,
139
 
    int pattern0,
140
 
    int pattern1,
141
 
    int x,
142
 
    int y,
143
 
    int w,
144
 
    int h);
145
 
 
146
 
#if 0
147
 
static void SavageSetupForColor8x8PatternFill(
148
 
    ScrnInfoPtr pScrn,
149
 
    int patternx,
150
 
    int patterny,
151
 
    int rop,
152
 
    unsigned planemask,
153
 
    int trans_col);
154
 
 
155
 
static void SavageSubsequentColor8x8PatternFillRect(
156
 
    ScrnInfoPtr pScrn,
157
 
    int pattern0,
158
 
    int pattern1,
159
 
    int x,
160
 
    int y,
161
 
    int w,
162
 
    int h);
163
 
#endif
164
 
 
165
 
static void SavageSetClippingRectangle(
166
 
    ScrnInfoPtr pScrn,
167
 
    int x1,
168
 
    int y1,
169
 
    int x2,
170
 
    int y2);
171
 
 
172
 
static void SavageDisableClipping( ScrnInfoPtr );
173
 
 
174
 
#if 0
175
 
static void SavageSubsequentSolidFillTrap(
176
 
    ScrnInfoPtr pScrn,
177
 
    int y,
178
 
    int h,
179
 
    int left,
180
 
    int dxl,
181
 
    int dyl,
182
 
    int el,
183
 
    int right,
184
 
    int dxr,
185
 
    int dyr,
186
 
    int er);
187
 
#endif
188
 
 
189
 
/* from savage_image.c: */
190
 
 
191
 
void SavageSetupForImageWrite(
192
 
    ScrnInfoPtr pScrn,
193
 
    int rop,
194
 
    unsigned int planemask,
195
 
    int transparency_color,
196
 
    int bpp,
197
 
    int depth);
198
 
 
199
 
void SavageSubsequentImageWriteRect(
200
 
    ScrnInfoPtr pScrn,
201
 
    int x,
202
 
    int y,
203
 
    int w,
204
 
    int h,
205
 
    int skipleft);
206
 
 
207
 
void SavageWriteBitmapCPUToScreenColorExpand (
208
 
    ScrnInfoPtr pScrn,
209
 
    int x, int y, int w, int h,
210
 
    unsigned char * src,
211
 
    int srcwidth,
212
 
    int skipleft,
213
 
    int fg, int bg,
214
 
    int rop,
215
 
    unsigned int planemask
216
 
);
217
 
 
218
37
unsigned long writedw( unsigned long addr, unsigned long value );
219
38
unsigned long readdw( unsigned long addr );
220
39
unsigned long readfb( unsigned long addr );
1034
853
    else if (pScrn->bitsPerPixel == 16) {
1035
854
        psav->GlobalBD.bd1.HighPart.ResBWTile = tile16;/* 16 bit */
1036
855
 
1037
 
            ulTmp =  ((psav->lDelta / 2) >> 6) << 24;
 
856
        ulTmp =  ((psav->lDelta / 2) >> 6) << 24;
1038
857
        if (psav->IsSecondary)
1039
858
            OUTREG32(TILED_SURFACE_REGISTER_1,ulTmp | TILED_SURF_BPP16 | pScrn->fbOffset);
1040
859
        else 
1043
862
    else if (pScrn->bitsPerPixel == 32) {
1044
863
        psav->GlobalBD.bd1.HighPart.ResBWTile = tile32;/* 32 bit */
1045
864
     
1046
 
            ulTmp =  ((psav->lDelta / 4) >> 5) << 24;        
 
865
        ulTmp =  ((psav->lDelta / 4) >> 5) << 24;
1047
866
        if (psav->IsSecondary)
1048
867
            OUTREG32(TILED_SURFACE_REGISTER_1,ulTmp | TILED_SURF_BPP32 | pScrn->fbOffset);
1049
868
        else 
1289
1108
        /* program the GBD and SBDs */
1290
1109
        OUTREG32(S3_GLB_BD_LOW,psav->GlobalBD.bd2.LoPart );
1291
1110
        OUTREG32(S3_GLB_BD_HIGH,(psav->GlobalBD.bd2.HiPart 
1292
 
                             | bci_enable | S3_LITTLE_ENDIAN | 0x10000000 | S3_BD64));
 
1111
                             | bci_enable | S3_LITTLE_ENDIAN | S3_BD64));
1293
1112
        OUTREG32(S3_PRI_BD_LOW,psav->GlobalBD.bd2.LoPart);
1294
1113
        OUTREG32(S3_PRI_BD_HIGH,psav->GlobalBD.bd2.HiPart);
1295
1114
        OUTREG32(S3_SEC_BD_LOW,psav->GlobalBD.bd2.LoPart);
1427
1246
    /* program the GBD and SBDs */
1428
1247
    OUTREG32(S3_GLB_BD_LOW,psav->GlobalBD.bd2.LoPart );
1429
1248
    OUTREG32(S3_GLB_BD_HIGH,(psav->GlobalBD.bd2.HiPart 
1430
 
                             | bci_enable | S3_LITTLE_ENDIAN | 0x10000000 | S3_BD64));
 
1249
                             | bci_enable | S3_LITTLE_ENDIAN | S3_BD64));
1431
1250
    OUTREG32(S3_PRI_BD_LOW,psav->GlobalBD.bd2.LoPart);
1432
1251
    OUTREG32(S3_PRI_BD_HIGH,psav->GlobalBD.bd2.HiPart);
1433
1252
    OUTREG32(S3_SEC_BD_LOW,psav->GlobalBD.bd2.LoPart);
1456
1275
{
1457
1276
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
1458
1277
    SavagePtr psav = SAVPTR(pScrn);
1459
 
    XAAInfoRecPtr xaaptr;
1460
 
    BoxRec AvailFBArea;
1461
 
 
1462
 
    /* Set-up our GE command primitive */
1463
 
    
1464
 
    if (pScrn->depth == 8) {
1465
 
        psav->PlaneMask = 0xFF;
1466
 
    }
1467
 
    else if (pScrn->depth == 15) {
1468
 
        psav->PlaneMask = 0x7FFF;
1469
 
    }
1470
 
    else if (pScrn->depth == 16) {
1471
 
        psav->PlaneMask = 0xFFFF;
1472
 
    }
1473
 
    else if (pScrn->depth == 24) {
1474
 
        psav->PlaneMask = 0xFFFFFF;
1475
 
    }
1476
 
 
1477
 
    /* General acceleration flags */
1478
 
 
1479
 
    if (!(xaaptr = psav->AccelInfoRec = XAACreateInfoRec()))
1480
 
        return FALSE;
1481
 
 
1482
 
    xaaptr->Flags = 0
1483
 
        | PIXMAP_CACHE
1484
 
        | OFFSCREEN_PIXMAPS
1485
 
        | LINEAR_FRAMEBUFFER
1486
 
        ;
1487
 
 
1488
 
    /* Clipping */
1489
 
 
1490
 
    xaaptr->SetClippingRectangle = SavageSetClippingRectangle;
1491
 
    xaaptr->DisableClipping = SavageDisableClipping;
1492
 
    xaaptr->ClippingFlags = 0
1493
 
#if 0
1494
 
        | HARDWARE_CLIP_SOLID_FILL 
1495
 
        | HARDWARE_CLIP_SOLID_LINE
1496
 
        | HARDWARE_CLIP_DASHED_LINE
1497
 
#endif
1498
 
        | HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY
1499
 
        | HARDWARE_CLIP_MONO_8x8_FILL
1500
 
        | HARDWARE_CLIP_COLOR_8x8_FILL
1501
 
        ;
1502
 
 
1503
 
    xaaptr->Sync = SavageAccelSync;
1504
 
 
1505
 
    if(xf86IsEntityShared(pScrn->entityList[0]))
1506
 
    {
1507
 
        DevUnion* pPriv;
1508
 
        SavageEntPtr pEnt;
1509
 
        pPriv = xf86GetEntityPrivate(pScrn->entityList[0],
1510
 
                gSavageEntityIndex);
1511
 
        pEnt = pPriv->ptr;
1512
 
        
1513
 
        /*if there are more than one devices sharing this entity, we
1514
 
          have to assign this call back, otherwise the XAA will be
1515
 
          disabled */
1516
 
        if(pEnt->HasSecondary)
1517
 
           xaaptr->RestoreAccelState           = SavageRestoreAccelState;
1518
 
    }
1519
 
 
1520
 
    /* ScreenToScreen copies */
1521
 
 
1522
 
#if 1
1523
 
 
1524
 
    xaaptr->SetupForScreenToScreenCopy = SavageSetupForScreenToScreenCopy;
1525
 
    xaaptr->SubsequentScreenToScreenCopy = SavageSubsequentScreenToScreenCopy;
1526
 
    xaaptr->ScreenToScreenCopyFlags = 0
1527
 
        | NO_TRANSPARENCY
1528
 
        | NO_PLANEMASK
1529
 
        | ROP_NEEDS_SOURCE;
1530
 
 
1531
 
#endif
1532
 
 
1533
 
 
1534
 
    /* Solid filled rectangles */
1535
 
 
1536
 
#if 1
1537
 
    xaaptr->SetupForSolidFill = SavageSetupForSolidFill;
1538
 
    xaaptr->SubsequentSolidFillRect = SavageSubsequentSolidFillRect;
1539
 
    xaaptr->SolidFillFlags = NO_PLANEMASK | ROP_NEEDS_SOURCE;
1540
 
#endif
1541
 
 
1542
 
    /* Mono 8x8 pattern fills */
1543
 
 
1544
 
#if 1
1545
 
    xaaptr->SetupForMono8x8PatternFill = SavageSetupForMono8x8PatternFill;
1546
 
    xaaptr->SubsequentMono8x8PatternFillRect 
1547
 
        = SavageSubsequentMono8x8PatternFillRect;
1548
 
    xaaptr->Mono8x8PatternFillFlags = 0
1549
 
        | HARDWARE_PATTERN_PROGRAMMED_BITS 
1550
 
        | HARDWARE_PATTERN_SCREEN_ORIGIN
1551
 
        | BIT_ORDER_IN_BYTE_MSBFIRST
1552
 
        | ROP_NEEDS_SOURCE
1553
 
        ;
1554
 
    if( psav->Chipset == S3_SAVAGE4 )
1555
 
        xaaptr->Mono8x8PatternFillFlags |= NO_TRANSPARENCY;
1556
 
#endif
1557
 
 
1558
 
    /* Color 8x8 pattern fills */
1559
 
 
1560
 
    /*
1561
 
     * With the exception of the Savage3D and Savage4, all of the Savage
1562
 
     * chips require that bitmap descriptors have a stride that is a
1563
 
     * multiple of 16 pixels.  This includes any descriptor used for
1564
 
     * color pattern fills, which COMPLETELY screws the XAA 8x8 color 
1565
 
     * pattern support.
1566
 
     *
1567
 
     * We could double the width ourselves into a reserved frame buffer
1568
 
     * section, but since I went 18 months with only ONE report of this
1569
 
     * error, it seems hardly worth the trouble.
1570
 
     */
1571
 
 
1572
 
#if 0
1573
 
    if( (psav->Chipset == S3_SAVAGE3D) || (psav->Chipset == S3_SAVAGE4) )
1574
 
    {
1575
 
        xaaptr->SetupForColor8x8PatternFill =
1576
 
                SavageSetupForColor8x8PatternFill;
1577
 
        xaaptr->SubsequentColor8x8PatternFillRect =
1578
 
                SavageSubsequentColor8x8PatternFillRect;
1579
 
        xaaptr->Color8x8PatternFillFlags = 0
1580
 
            | NO_TRANSPARENCY
1581
 
            | HARDWARE_PATTERN_PROGRAMMED_BITS
1582
 
            | HARDWARE_PATTERN_PROGRAMMED_ORIGIN
1583
 
            ;
1584
 
    }
1585
 
#endif
1586
 
 
1587
 
    /* Solid lines */
1588
 
 
1589
 
#if 1
1590
 
    xaaptr->SolidLineFlags = NO_PLANEMASK;
1591
 
    xaaptr->SetupForSolidLine = SavageSetupForSolidFill;
1592
 
    xaaptr->SubsequentSolidBresenhamLine = SavageSubsequentSolidBresenhamLine;
1593
 
#if 0
1594
 
    xaaptr->SubsequentSolidFillTrap = SavageSubsequentSolidFillTrap; 
1595
 
#endif
1596
 
 
1597
 
    xaaptr->SolidBresenhamLineErrorTermBits = 13;
1598
 
#endif
1599
 
 
1600
 
    /* ImageWrite */
1601
 
 
1602
 
    xaaptr->ImageWriteFlags = 0
1603
 
        | NO_PLANEMASK
1604
 
        | CPU_TRANSFER_PAD_DWORD
1605
 
        | SCANLINE_PAD_DWORD
1606
 
        | BIT_ORDER_IN_BYTE_MSBFIRST
1607
 
        | LEFT_EDGE_CLIPPING
1608
 
        ;
1609
 
    xaaptr->SetupForImageWrite = SavageSetupForImageWrite;
1610
 
    xaaptr->SubsequentImageWriteRect = SavageSubsequentImageWriteRect;
1611
 
    xaaptr->NumScanlineImageWriteBuffers = 1;
1612
 
    xaaptr->ImageWriteBase = psav->BciMem;
1613
 
    xaaptr->ImageWriteRange = 120 * 1024;
1614
 
 
1615
 
    /* WriteBitmap color expand */
1616
 
 
1617
 
#if 0
1618
 
    xaaptr->WriteBitmapFlags = NO_PLANEMASK;
1619
 
    xaaptr->WriteBitmap = SavageWriteBitmapCPUToScreenColorExpand;
1620
 
#endif
1621
 
 
1622
 
    /* Screen to Screen color expansion.  Not implemented. */
1623
 
 
1624
 
#if 0
1625
 
    xaaptr->SetupForScreenToScreenColorExpand =
1626
 
             SavageSetupForScreenToScreenColorExpand;
1627
 
    xaaptr->SubsequentScreenToScreenColorExpand =
1628
 
             SavageSubsequentCPUToScreenColorExpand;
1629
 
#endif
1630
 
 
1631
 
    /* CPU to Screen color expansion */
1632
 
 
1633
 
    xaaptr->ScanlineCPUToScreenColorExpandFillFlags = 0
1634
 
        | NO_PLANEMASK
1635
 
        | CPU_TRANSFER_PAD_DWORD
1636
 
        | SCANLINE_PAD_DWORD
1637
 
        | BIT_ORDER_IN_BYTE_MSBFIRST
1638
 
        | LEFT_EDGE_CLIPPING
1639
 
        | ROP_NEEDS_SOURCE
1640
 
        ;
1641
 
 
1642
 
    xaaptr->SetupForScanlineCPUToScreenColorExpandFill =
1643
 
            SavageSetupForCPUToScreenColorExpandFill;
1644
 
    xaaptr->SubsequentScanlineCPUToScreenColorExpandFill =
1645
 
            SavageSubsequentScanlineCPUToScreenColorExpandFill;
1646
 
    xaaptr->SubsequentColorExpandScanline =
1647
 
            SavageSubsequentColorExpandScanline;
1648
 
    xaaptr->ColorExpandBase = psav->BciMem;
1649
 
    xaaptr->ScanlineColorExpandBuffers = &xaaptr->ColorExpandBase;
1650
 
    xaaptr->NumScanlineColorExpandBuffers = 1;
1651
 
 
1652
 
    /* Set up screen parameters. */
1653
 
 
1654
 
    psav->Bpp = pScrn->bitsPerPixel / 8;
1655
 
    psav->Bpl = pScrn->displayWidth * psav->Bpp;
1656
 
    psav->ScissB = (psav->CursorKByte << 10) / psav->Bpl;
1657
 
    if (psav->ScissB > 2047)
1658
 
        psav->ScissB = 2047;
1659
 
 
1660
 
    /*
1661
 
     * Finally, we set up the video memory space available to the pixmap
1662
 
     * cache. In this case, all memory from the end of the virtual screen
1663
 
     * to the end of the command overflow buffer can be used. If you haven't
1664
 
     * enabled the PIXMAP_CACHE flag, then these lines can be omitted.
1665
 
     */
1666
1278
 
1667
1279
#ifdef XF86DRI
1668
1280
    if (psav->directRenderingEnabled) {
1882
1494
            psav->cyMemory = 0x7FFF;
1883
1495
        }
1884
1496
 
1885
 
        MemBox.x1 = 0;
1886
 
        MemBox.y1 = 0;
1887
 
        MemBox.x2 = psav->cxMemory;
1888
 
        MemBox.y2 = psav->cyMemory;
1889
 
        
1890
 
        if (!xf86InitFBManager(pScreen, &MemBox)) {
1891
 
            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
1892
 
                       "Memory manager initialization to (%d,%d) (%d,%d) failed\n",
1893
 
                       MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2 );
1894
 
            return FALSE;
1895
 
        } else {
1896
 
            int tmp,width, height;
1897
 
            
1898
 
            xf86DrvMsg( pScrn->scrnIndex, X_INFO,
1899
 
                        "Memory manager initialized to (%d,%d) (%d,%d)\n",
1900
 
                        MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2 );
1901
 
            /*
1902
 
             * because the alignment requirement,the on-screen need more memory
1903
 
             * than (0,0,virtualX,virtualY), but xf86InitFBManager only subtract
1904
 
             * (pScrn->virtualX * pScrn->virtualY from (0,0,cxMemory,cyMemory),so
1905
 
             * here,we should reserve some memory for on-screen
1906
 
             */
1907
 
            tmp = ((psav->cxMemory * pScrn->virtualY - pScrn->virtualX * pScrn->virtualY)
1908
 
                   + psav->cxMemory -1) / (psav->cxMemory);
1909
 
            if (tmp)
1910
 
                xf86AllocateOffscreenArea(pScreen, psav->cxMemory,tmp, 0, NULL, NULL, NULL);
1911
 
            
1912
 
            if (xf86QueryLargestOffscreenArea(pScreen, &width,
1913
 
                                              &height, 0, 0, 0 ) ) {
1914
 
                xf86DrvMsg( pScrn->scrnIndex, X_INFO,
1915
 
                            "Largest offscreen area available: %d x %d\n",
1916
 
                            width, height );
1917
 
            }
1918
 
        }
1919
 
        psav->reserved = 0;
1920
 
 
1921
 
        if(tiledBufferSize > bufferSize)
1922
 
        {
1923
 
            psav->reserved = xf86AllocateOffscreenLinear(pScreen,
1924
 
                                                         (tiledBufferSize - bufferSize),1,0,0,0);
1925
 
 
1926
 
        }
1927
 
        if(psav->reserved)
1928
 
            xf86DrvMsg( pScrn->scrnIndex, X_INFO,
1929
 
                        "Reserved for tiled front buffer at offset 0x%08x ,size:0x%08x\n",
1930
 
                        psav->reserved->offset, psav->reserved->size);
 
1497
        psav->EXAendfb = pSAVAGEDRIServer->backOffset & ~SAVAGE_BUFFER_ALIGN;
1931
1498
 
1932
1499
        xf86DrvMsg( pScrn->scrnIndex, X_INFO,
1933
1500
                    "Reserved back buffer at offset 0x%x\n",
1943
1510
    else
1944
1511
#endif
1945
1512
    {
1946
 
        int tmp;
1947
1513
 
1948
1514
        /*
1949
1515
         * why this code? because BoxRec members are  short int
1952
1518
        if (psav->cyMemory > 0x7FFF) {
1953
1519
            psav->cyMemory = 0x7FFF;
1954
1520
        }
 
1521
 
 
1522
        if (psav->IsPrimary) {
 
1523
            psav->EXAendfb = psav->videoRambytes -
 
1524
                             4096 - /* hw cursor*/
 
1525
                             0x200000;
 
1526
        } else {
 
1527
            psav->EXAendfb = psav->videoRambytes -
 
1528
                             4096 - /* hw cursor*/
 
1529
                             psav->cobSize - /*COB*/
 
1530
                             0x200000;
 
1531
        }
1955
1532
            
1956
 
        AvailFBArea.x1 = 0;
1957
 
        AvailFBArea.y1 = 0;
1958
 
        AvailFBArea.x2 = psav->cxMemory;
1959
 
        AvailFBArea.y2 = psav->cyMemory;
1960
 
        xf86InitFBManager(pScreen, &AvailFBArea);
1961
 
        /*
1962
 
         * because the alignment requirement,the on-screen need more memory
1963
 
         * than (0,0,virtualX,virtualY), but xf86InitFBManager only subtract
1964
 
         * (pScrn->virtualX * pScrn->virtualY from (0,0,cxMemory,cyMemory),so
1965
 
         * here,we should reserver some memory for on-screen
1966
 
         */
1967
 
        tmp = ((psav->cxMemory * pScrn->virtualY - pScrn->virtualX * pScrn->virtualY)
1968
 
               + psav->cxMemory -1) / (psav->cxMemory);
1969
 
        if (tmp)
1970
 
            xf86AllocateOffscreenArea(pScreen, psav->cxMemory,tmp, 0, NULL, NULL, NULL);
1971
 
        
1972
 
        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
1973
 
                   "Using %d lines for offscreen memory.\n",
1974
 
                   psav->cyMemory - pScrn->virtualY );
1975
 
    }
1976
 
 
1977
 
#if 0
1978
 
    AvailFBArea.x1 = 0;
1979
 
    AvailFBArea.y1 = 0;
1980
 
    AvailFBArea.x2 = pScrn->displayWidth;
1981
 
    AvailFBArea.y2 = psav->ScissB;
1982
 
    xf86InitFBManager(pScreen, &AvailFBArea);
1983
 
    xf86DrvMsg( pScrn->scrnIndex, X_INFO,
1984
 
                "Using %d lines for offscreen memory.\n",
1985
 
                psav->ScissB - pScrn->virtualY );
1986
 
#endif
1987
 
 
1988
 
 
1989
 
    return XAAInit(pScreen, xaaptr);
1990
 
}
1991
 
 
1992
 
 
1993
 
 
1994
 
 
1995
 
/* The sync function for the GE */
1996
 
void
1997
 
SavageAccelSync(ScrnInfoPtr pScrn)
1998
 
{
1999
 
    SavagePtr psav = SAVPTR(pScrn);
2000
 
    psav->WaitIdleEmpty(psav);
2001
 
}
2002
 
 
2003
 
 
2004
 
/*
2005
 
 * The XAA ROP helper routines all assume that a solid color is a 
2006
 
 * "pattern".  The Savage chips, however, apply a non-stippled solid
2007
 
 * color as "source".  Thus, we use a slightly customized version.
2008
 
 */
2009
 
 
2010
 
static int
2011
 
SavageHelpPatternROP(ScrnInfoPtr pScrn, int *fg, int *bg, unsigned int pm, int *rop)
2012
 
{
2013
 
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
2014
 
    int ret = 0;
2015
 
    
2016
 
    pm &= infoRec->FullPlanemask;
2017
 
 
2018
 
    if(pm == infoRec->FullPlanemask) {
2019
 
        if(!NO_SRC_ROP(*rop)) 
2020
 
           ret |= ROP_PAT;
2021
 
        *rop = XAAGetCopyROP(*rop);
2022
 
    } else {    
2023
 
        switch(*rop) {
2024
 
        case GXnoop:
2025
 
            break;
2026
 
        case GXset:
2027
 
        case GXclear:
2028
 
        case GXinvert:
2029
 
            ret |= ROP_PAT;
2030
 
            *fg = pm;
2031
 
            if(*bg != -1)
2032
 
                *bg = pm;
2033
 
            break;
2034
 
        default:
2035
 
            ret |= ROP_PAT | ROP_SRC;
2036
 
            break;
2037
 
        }
2038
 
        *rop = XAAGetCopyROP_PM(*rop);
2039
 
    }
2040
 
 
2041
 
    return ret;
2042
 
}
2043
 
 
2044
 
 
2045
 
static int
2046
 
SavageHelpSolidROP(ScrnInfoPtr pScrn, int *fg, unsigned int pm, int *rop)
2047
 
{
2048
 
    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
2049
 
    int ret = 0;
2050
 
    
2051
 
    pm &= infoRec->FullPlanemask;
2052
 
 
2053
 
    if(pm == infoRec->FullPlanemask) {
2054
 
        if(!NO_SRC_ROP(*rop)) 
2055
 
           ret |= ROP_PAT;
2056
 
        *rop = XAAGetCopyROP(*rop);
2057
 
    } else {    
2058
 
        switch(*rop) {
2059
 
        case GXnoop:
2060
 
            break;
2061
 
        case GXset:
2062
 
        case GXclear:
2063
 
        case GXinvert:
2064
 
            ret |= ROP_PAT;
2065
 
            *fg = pm;
2066
 
            break;
2067
 
        default:
2068
 
            ret |= ROP_PAT | ROP_SRC;
2069
 
            break;
2070
 
        }
2071
 
        *rop = XAAGetCopyROP_PM(*rop);
2072
 
    }
2073
 
 
2074
 
    return ret;
2075
 
}
2076
 
 
2077
 
 
2078
 
 
2079
 
/* These are the ScreenToScreen bitblt functions. We support all ROPs, all
2080
 
 * directions, and a planemask by adjusting the ROP and using the mono pattern
2081
 
 * registers.
2082
 
 *
2083
 
 * (That's a lie; we don't really support planemask.)
2084
 
 */
2085
 
 
2086
 
static void 
2087
 
SavageSetupForScreenToScreenCopy(
2088
 
    ScrnInfoPtr pScrn,
2089
 
    int xdir, 
2090
 
    int ydir,
2091
 
    int rop,
2092
 
    unsigned planemask,
2093
 
    int transparency_color)
2094
 
{
2095
 
    SavagePtr psav = SAVPTR(pScrn);
2096
 
    int cmd;
2097
 
 
2098
 
    cmd = BCI_CMD_RECT | BCI_CMD_DEST_PBD_NEW | BCI_CMD_SRC_SBD_COLOR_NEW;
2099
 
 
2100
 
    BCI_CMD_SET_ROP( cmd, XAAGetCopyROP(rop) );
2101
 
    if (transparency_color != -1)
2102
 
        cmd |= BCI_CMD_SEND_COLOR | BCI_CMD_SRC_TRANSPARENT;
2103
 
 
2104
 
    if (xdir == 1 ) cmd |= BCI_CMD_RECT_XP;
2105
 
    if (ydir == 1 ) cmd |= BCI_CMD_RECT_YP;
2106
 
 
2107
 
    psav->SavedBciCmd = cmd;
2108
 
    psav->SavedBgColor = transparency_color;
2109
 
}
2110
 
 
2111
 
static void 
2112
 
SavageSubsequentScreenToScreenCopy(
2113
 
    ScrnInfoPtr pScrn,
2114
 
    int x1,
2115
 
    int y1,
2116
 
    int x2,
2117
 
    int y2,
2118
 
    int w,
2119
 
    int h)
2120
 
{
2121
 
    SavagePtr psav = SAVPTR(pScrn);
2122
 
 
2123
 
    BCI_GET_PTR;
2124
 
 
2125
 
    if (!w || !h) return;
2126
 
 
2127
 
    if (!(psav->SavedBciCmd & BCI_CMD_RECT_XP)) {
2128
 
        w --;
2129
 
        x1 += w;
2130
 
        x2 += w;
2131
 
        w ++;
2132
 
    }
2133
 
    if (!(psav->SavedBciCmd & BCI_CMD_RECT_YP)) {
2134
 
        h --;
2135
 
        y1 += h;
2136
 
        y2 += h;
2137
 
        h ++;
2138
 
    }
2139
 
 
2140
 
    psav->WaitQueue(psav,9);
2141
 
 
2142
 
 
2143
 
    BCI_SEND(psav->SavedBciCmd);
2144
 
 
2145
 
    BCI_SEND(psav->GlobalBD.bd2.LoPart);
2146
 
    BCI_SEND(psav->GlobalBD.bd2.HiPart);
2147
 
 
2148
 
    BCI_SEND(psav->GlobalBD.bd2.LoPart);
2149
 
    BCI_SEND(psav->GlobalBD.bd2.HiPart);
2150
 
 
2151
 
    if (psav->SavedBgColor != 0xffffffff) 
2152
 
        BCI_SEND(psav->SavedBgColor);
2153
 
    BCI_SEND(BCI_X_Y(x1, y1));
2154
 
    BCI_SEND(BCI_X_Y(x2, y2));
2155
 
    BCI_SEND(BCI_W_H(w, h));
2156
 
}
2157
 
 
2158
 
 
2159
 
/*
2160
 
 * SetupForSolidFill is also called to set up for lines.
2161
 
 */ 
2162
 
 
2163
 
static void 
2164
 
SavageSetupForSolidFill(
2165
 
    ScrnInfoPtr pScrn,
2166
 
    int color, 
2167
 
    int rop,
2168
 
    unsigned int planemask)
2169
 
{
2170
 
    SavagePtr psav = SAVPTR(pScrn);
2171
 
    XAAInfoRecPtr xaaptr = GET_XAAINFORECPTR_FROM_SCRNINFOPTR( pScrn );
2172
 
    int cmd;
2173
 
    int mix;
2174
 
 
2175
 
    cmd = BCI_CMD_RECT
2176
 
        | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP
2177
 
        | BCI_CMD_DEST_PBD_NEW | BCI_CMD_SRC_SOLID;
2178
 
 
2179
 
    /* Don't send a color if we don't have to. */
2180
 
 
2181
 
    if( rop == GXcopy )
2182
 
    {
2183
 
        if( color == 0 )
2184
 
            rop = GXclear;
2185
 
        else if( (unsigned int)color == xaaptr->FullPlanemask )
2186
 
            rop = GXset;
2187
 
    }
2188
 
 
2189
 
    mix = SavageHelpSolidROP( pScrn, &color, planemask, &rop );
2190
 
 
2191
 
    if( mix & ROP_PAT )
2192
 
        cmd |= BCI_CMD_SEND_COLOR;
2193
 
 
2194
 
    BCI_CMD_SET_ROP( cmd, rop );
2195
 
 
2196
 
    psav->SavedBciCmd = cmd;
2197
 
    psav->SavedFgColor = color;
2198
 
}
2199
 
    
2200
 
    
2201
 
static void 
2202
 
SavageSubsequentSolidFillRect(
2203
 
    ScrnInfoPtr pScrn,
2204
 
    int x,
2205
 
    int y,
2206
 
    int w,
2207
 
    int h)
2208
 
{
2209
 
    SavagePtr psav = SAVPTR(pScrn);
2210
 
    BCI_GET_PTR;
2211
 
    
2212
 
    if( !w || !h )
2213
 
        return;
2214
 
 
2215
 
    psav->WaitQueue(psav,7);
2216
 
 
2217
 
    BCI_SEND(psav->SavedBciCmd);
2218
 
 
2219
 
    BCI_SEND(psav->GlobalBD.bd2.LoPart);
2220
 
    BCI_SEND(psav->GlobalBD.bd2.HiPart);
2221
 
 
2222
 
    if( psav->SavedBciCmd & BCI_CMD_SEND_COLOR )
2223
 
        BCI_SEND(psav->SavedFgColor);
2224
 
    BCI_SEND(BCI_X_Y(x, y));
2225
 
    BCI_SEND(BCI_W_H(w, h));
2226
 
}
2227
 
 
2228
 
#if 0
2229
 
static void
2230
 
SavageSetupForScreenToScreenColorExpand(
2231
 
    ScrnInfoPtr pScrn,
2232
 
    int bg,
2233
 
    int fg,
2234
 
    int rop,
2235
 
    unsigned int planemask)
2236
 
{
2237
 
/*    SavagePtr psav = SAVPTR(pScrn); */
2238
 
}
2239
 
 
2240
 
static void
2241
 
SavageSubsequentScreenToScreenColorExpand(
2242
 
    ScrnInfoPtr pScrn,
2243
 
    int x,
2244
 
    int y,
2245
 
    int w,
2246
 
    int h,
2247
 
    int skipleft)
2248
 
{
2249
 
/*    SavagePtr psav = SAVPTR(pScrn); */
2250
 
}
2251
 
#endif
2252
 
 
2253
 
 
2254
 
static void
2255
 
SavageSetupForCPUToScreenColorExpandFill(
2256
 
    ScrnInfoPtr pScrn,
2257
 
    int fg,
2258
 
    int bg,
2259
 
    int rop,
2260
 
    unsigned int planemask)
2261
 
{
2262
 
    SavagePtr psav = SAVPTR(pScrn);
2263
 
    int cmd;
2264
 
    int mix;
2265
 
 
2266
 
    cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP
2267
 
        | BCI_CMD_CLIP_LR
2268
 
        | BCI_CMD_DEST_PBD_NEW | BCI_CMD_SRC_MONO;
2269
 
 
2270
 
    mix = SavageHelpPatternROP( pScrn, &fg, &bg, planemask, &rop );
2271
 
 
2272
 
    if( mix & ROP_PAT )
2273
 
        cmd |= BCI_CMD_SEND_COLOR;
2274
 
 
2275
 
    BCI_CMD_SET_ROP( cmd, rop );
2276
 
 
2277
 
    if (bg != -1)
2278
 
        cmd |= BCI_CMD_SEND_COLOR;
2279
 
    else 
2280
 
        cmd |= BCI_CMD_SRC_TRANSPARENT;
2281
 
 
2282
 
    psav->SavedBciCmd = cmd;
2283
 
    psav->SavedFgColor = fg;
2284
 
    psav->SavedBgColor = bg;
2285
 
}
2286
 
 
2287
 
 
2288
 
static void
2289
 
SavageSubsequentScanlineCPUToScreenColorExpandFill(
2290
 
    ScrnInfoPtr pScrn,
2291
 
    int x,
2292
 
    int y,
2293
 
    int w,
2294
 
    int h,
2295
 
    int skipleft)
2296
 
{
2297
 
    SavagePtr psav = SAVPTR(pScrn);
2298
 
    BCI_GET_PTR;
2299
 
 
2300
 
    /* XAA will be sending bitmap data next.  */
2301
 
    /* We should probably wait for empty/idle here. */
2302
 
 
2303
 
    psav->WaitQueue(psav,22);
2304
 
 
2305
 
    BCI_SEND(psav->SavedBciCmd);
2306
 
 
2307
 
    BCI_SEND(psav->GlobalBD.bd2.LoPart);
2308
 
    BCI_SEND(psav->GlobalBD.bd2.HiPart);
2309
 
 
2310
 
    BCI_SEND(BCI_CLIP_LR(x+skipleft, x+w-1));
2311
 
    w = (w + 31) & ~31;
2312
 
    if( psav->SavedBciCmd & BCI_CMD_SEND_COLOR )
2313
 
        BCI_SEND(psav->SavedFgColor);
2314
 
    if( psav->SavedBgColor != 0xffffffff )
2315
 
        BCI_SEND(psav->SavedBgColor);
2316
 
    BCI_SEND(BCI_X_Y(x, y));
2317
 
    BCI_SEND(BCI_W_H(w, 1));
2318
 
    
2319
 
    psav->Rect.x = x;
2320
 
    psav->Rect.y = y + 1;
2321
 
    psav->Rect.width = w;
2322
 
    psav->Rect.height = h - 1;
2323
 
}
2324
 
 
2325
 
static void
2326
 
SavageSubsequentColorExpandScanline(
2327
 
    ScrnInfoPtr pScrn,
2328
 
    int buffer_no)
2329
 
{
2330
 
    /* This gets call after each scanline's image data has been sent. */
2331
 
    SavagePtr psav = SAVPTR(pScrn);
2332
 
    xRectangle xr = psav->Rect;
2333
 
    BCI_GET_PTR;
2334
 
 
2335
 
    if( xr.height )
2336
 
    {
2337
 
        psav->WaitQueue(psav,20);
2338
 
        BCI_SEND(BCI_X_Y( xr.x, xr.y));
2339
 
        BCI_SEND(BCI_W_H( xr.width, 1 ));
2340
 
        psav->Rect.height--;
2341
 
        psav->Rect.y++;
2342
 
    }
2343
 
}
2344
 
 
2345
 
 
2346
 
/*
2347
 
 * The meaning of the two pattern paremeters to Setup & Subsequent for
2348
 
 * Mono8x8Patterns varies depending on the flag bits.  We specify
2349
 
 * HW_PROGRAMMED_BITS, which means our hardware can handle 8x8 patterns
2350
 
 * without caching in the frame buffer.  Thus, Setup gets the pattern bits.
2351
 
 * There is no way with BCI to rotate an 8x8 pattern, so we do NOT specify
2352
 
 * HW_PROGRAMMED_ORIGIN.  XAA wil rotate it for us and pass the rotated
2353
 
 * pattern to both Setup and Subsequent.  If we DID specify PROGRAMMED_ORIGIN,
2354
 
 * then Setup would get the unrotated pattern, and Subsequent gets the
2355
 
 * origin values.
2356
 
 */
2357
 
 
2358
 
static void
2359
 
SavageSetupForMono8x8PatternFill(
2360
 
    ScrnInfoPtr pScrn,
2361
 
    int patternx,
2362
 
    int patterny,
2363
 
    int fg, 
2364
 
    int bg,
2365
 
    int rop,
2366
 
    unsigned int planemask)
2367
 
{
2368
 
    SavagePtr psav = SAVPTR(pScrn);
2369
 
    int cmd;
2370
 
    int mix;
2371
 
 
2372
 
    mix = XAAHelpPatternROP( pScrn, &fg, &bg, planemask, &rop );
2373
 
 
2374
 
    cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP
2375
 
        | BCI_CMD_DEST_PBD_NEW;
2376
 
 
2377
 
    if( mix & ROP_PAT )
2378
 
        cmd |= BCI_CMD_SEND_COLOR | BCI_CMD_PAT_MONO;
2379
 
 
2380
 
    if (bg == -1)
2381
 
        cmd |= BCI_CMD_PAT_TRANSPARENT;
2382
 
 
2383
 
    BCI_CMD_SET_ROP(cmd, rop);
2384
 
 
2385
 
    psav->SavedBciCmd = cmd;
2386
 
    psav->SavedFgColor = fg;
2387
 
    psav->SavedBgColor = bg;
2388
 
}
2389
 
 
2390
 
 
2391
 
static void
2392
 
SavageSubsequentMono8x8PatternFillRect(
2393
 
    ScrnInfoPtr pScrn,
2394
 
    int pattern0,
2395
 
    int pattern1,
2396
 
    int x,
2397
 
    int y,
2398
 
    int w,
2399
 
    int h)
2400
 
{
2401
 
    SavagePtr psav = SAVPTR(pScrn);
2402
 
    BCI_GET_PTR;
2403
 
 
2404
 
    /*
2405
 
     * I didn't think it was my job to do trivial rejection, but 
2406
 
     * miFillGeneralPolygon definitely generates null spans, and XAA
2407
 
     * just passes them through.
2408
 
     */
2409
 
 
2410
 
    if( !w || !h )
2411
 
        return;
2412
 
 
2413
 
    psav->WaitQueue(psav,9);
2414
 
    BCI_SEND(psav->SavedBciCmd);
2415
 
 
2416
 
    BCI_SEND(psav->GlobalBD.bd2.LoPart);
2417
 
    BCI_SEND(psav->GlobalBD.bd2.HiPart);
2418
 
 
2419
 
    if( psav->SavedBciCmd & BCI_CMD_SEND_COLOR )
2420
 
        BCI_SEND(psav->SavedFgColor);
2421
 
    if( psav->SavedBgColor != 0xffffffff )
2422
 
        BCI_SEND(psav->SavedBgColor);
2423
 
    BCI_SEND(BCI_X_Y(x, y));
2424
 
    BCI_SEND(BCI_W_H(w, h));
2425
 
    if( psav->SavedBciCmd & BCI_CMD_PAT_MONO )
2426
 
    {
2427
 
        BCI_SEND(pattern0);
2428
 
        BCI_SEND(pattern1);
2429
 
    }
2430
 
}
2431
 
 
2432
 
 
2433
 
#if 0
2434
 
static void 
2435
 
SavageSetupForColor8x8PatternFill(
2436
 
    ScrnInfoPtr pScrn,
2437
 
    int patternx,
2438
 
    int patterny,
2439
 
    int rop,
2440
 
    unsigned planemask,
2441
 
    int trans_col)
2442
 
{
2443
 
    SavagePtr psav = SAVPTR(pScrn);
2444
 
 
2445
 
    int cmd;
2446
 
    unsigned int bd;
2447
 
    int pat_offset;
2448
 
    
2449
 
    /* ViRGEs and Savages do not support transparent color patterns. */
2450
 
    /* We set the NO_TRANSPARENCY bit, so we should never receive one. */
2451
 
 
2452
 
    pat_offset = (int) (patternx * psav->Bpp + patterny * psav->Bpl);
2453
 
 
2454
 
    cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP
2455
 
        | BCI_CMD_DEST_GBD | BCI_CMD_PAT_PBD_COLOR_NEW;
2456
 
        
2457
 
    (void) XAAHelpSolidROP( pScrn, &trans_col, planemask, &rop );
2458
 
 
2459
 
    BCI_CMD_SET_ROP(cmd, rop);
2460
 
    bd = BCI_BD_BW_DISABLE;
2461
 
    BCI_BD_SET_BPP(bd, pScrn->bitsPerPixel);
2462
 
    BCI_BD_SET_STRIDE(bd, 8);
2463
 
 
2464
 
    psav->SavedBciCmd = cmd;
2465
 
    psav->SavedSbdOffset = pat_offset;
2466
 
    psav->SavedSbd = bd;
2467
 
    psav->SavedBgColor = trans_col;
2468
 
}
2469
 
 
2470
 
 
2471
 
static void
2472
 
SavageSubsequentColor8x8PatternFillRect(
2473
 
    ScrnInfoPtr pScrn,
2474
 
    int patternx,
2475
 
    int patterny,
2476
 
    int x,
2477
 
    int y,
2478
 
    int w,
2479
 
    int h)
2480
 
{
2481
 
    SavagePtr psav = SAVPTR(pScrn);
2482
 
    BCI_GET_PTR;
2483
 
 
2484
 
    if( !w || !h )
2485
 
        return;
2486
 
 
2487
 
    psav->WaitQueue(psav,6);
2488
 
    BCI_SEND(psav->SavedBciCmd);
2489
 
    BCI_SEND(psav->SavedSbdOffset);
2490
 
    BCI_SEND(psav->SavedSbd);
2491
 
    BCI_SEND(BCI_X_Y(patternx,patterny));
2492
 
    BCI_SEND(BCI_X_Y(x, y));
2493
 
    BCI_SEND(BCI_W_H(w, h));
2494
 
}
2495
 
#endif
2496
 
 
2497
 
 
2498
 
static void
2499
 
SavageSubsequentSolidBresenhamLine(
2500
 
    ScrnInfoPtr pScrn,
2501
 
    int x1,
2502
 
    int y1,
2503
 
    int e1,
2504
 
    int e2,
2505
 
    int err,
2506
 
    int length,
2507
 
    int octant)
2508
 
{
2509
 
    SavagePtr psav = SAVPTR(pScrn);
2510
 
    BCI_GET_PTR;
2511
 
    int cmd;
2512
 
 
2513
 
    cmd = (psav->SavedBciCmd & 0x00ffffff);
2514
 
    cmd |= BCI_CMD_LINE_LAST_PIXEL;
2515
 
 
2516
 
#ifdef DEBUG_EXTRA
2517
 
    ErrorF("BresenhamLine, (%4d,%4d), len %4d, oct %d, err %4d,%4d,%4d clr %08x\n",
2518
 
        x1, y1, length, octant, e1, e2, err, psav->SavedFgColor );
2519
 
#endif
2520
 
 
2521
 
    psav->WaitQueue(psav, 7 );
2522
 
    BCI_SEND(cmd);
2523
 
 
2524
 
    BCI_SEND(psav->GlobalBD.bd2.LoPart);
2525
 
    BCI_SEND(psav->GlobalBD.bd2.HiPart);
2526
 
 
2527
 
    if( cmd & BCI_CMD_SEND_COLOR )
2528
 
        BCI_SEND( psav->SavedFgColor );
2529
 
    BCI_SEND(BCI_LINE_X_Y(x1, y1));
2530
 
    BCI_SEND(BCI_LINE_STEPS(e2-e1, e2));
2531
 
    BCI_SEND(BCI_LINE_MISC(length, 
2532
 
                           (octant & YMAJOR),
2533
 
                           !(octant & XDECREASING),
2534
 
                           !(octant & YDECREASING),
2535
 
                           e2+err));
2536
 
}
2537
 
 
2538
 
#if 0
2539
 
static void 
2540
 
SavageSubsequentSolidTwoPointLine(
2541
 
    ScrnInfoPtr pScrn,
2542
 
    int x1,
2543
 
    int y1,
2544
 
    int x2,
2545
 
    int y2,
2546
 
    int bias)
2547
 
{
2548
 
    SavagePtr psav = SAVPTR(pScrn);
2549
 
    BCI_GET_PTR;
2550
 
 
2551
 
    int cmd;
2552
 
    int dx, dy;
2553
 
    int min, max, xp, yp, ym;
2554
 
 
2555
 
    dx = x2 - x1;
2556
 
    dy = y2 - y1;
2557
 
 
2558
 
#ifdef DEBUG_EXTRA
2559
 
    ErrorF("TwoPointLine, (%4d,%4d)-(%4d,%4d), clr %08x, last pt %s\n",
2560
 
        x1, y1, x2, y2, psav->SavedFgColor, (bias & 0x100)?"NO ":"YES");
2561
 
#endif
2562
 
 
2563
 
    xp = (dx >= 0);
2564
 
    if( !xp ) {
2565
 
        dx = -dx;
2566
 
    }
2567
 
 
2568
 
    yp = (dy >= 0);
2569
 
    if( !yp ) {
2570
 
        dy = -dy;
2571
 
    }
2572
 
 
2573
 
    ym = (dy > dx);
2574
 
    if( ym ) {
2575
 
        max = dy;
2576
 
        min = dx;
2577
 
    }
2578
 
    else {
2579
 
        max = dx;
2580
 
        min = dy;
2581
 
    }
2582
 
 
2583
 
    if( !(bias & 0x100) ) {
2584
 
        max++;
2585
 
    }
2586
 
 
2587
 
    cmd = (psav->SavedBciCmd & 0x00ffffff);
2588
 
    cmd |= BCI_CMD_LINE_LAST_PIXEL;
2589
 
 
2590
 
    psav->WaitQueue(psav,5);
2591
 
    BCI_SEND( cmd );
2592
 
    if( cmd & BCI_CMD_SEND_COLOR )
2593
 
        BCI_SEND( psav->SavedFgColor );
2594
 
    BCI_SEND( BCI_LINE_X_Y( x1, y1 ) );
2595
 
    BCI_SEND( BCI_LINE_STEPS( 2 * (min - max), 2 * min ) );
2596
 
    BCI_SEND( BCI_LINE_MISC( max, ym, xp, yp, 2 * min - max ) );
2597
 
}
2598
 
#endif
2599
 
 
2600
 
 
2601
 
static void 
2602
 
SavageSetClippingRectangle(
2603
 
    ScrnInfoPtr pScrn,
2604
 
    int x1,
2605
 
    int y1,
2606
 
    int x2,
2607
 
    int y2)
2608
 
{
2609
 
    SavagePtr psav = SAVPTR(pScrn);
2610
 
    BCI_GET_PTR;
2611
 
    int cmd;
2612
 
 
2613
 
#ifdef DEBUG_EXTRA
2614
 
    ErrorF("ClipRect, (%4d,%4d)-(%4d,%4d) \n", x1, y1, x2, y2 );
2615
 
#endif
2616
 
 
2617
 
    cmd = BCI_CMD_NOP | BCI_CMD_CLIP_NEW;
2618
 
    psav->WaitQueue(psav,3);
2619
 
    BCI_SEND(cmd);
2620
 
    BCI_SEND(BCI_CLIP_TL(y1, x1));
2621
 
    BCI_SEND(BCI_CLIP_BR(y2, x2));
2622
 
    psav->SavedBciCmd |= BCI_CMD_CLIP_CURRENT;
2623
 
}
2624
 
 
2625
 
 
2626
 
static void SavageDisableClipping( ScrnInfoPtr pScrn )
2627
 
{
2628
 
    SavagePtr psav = SAVPTR(pScrn);
2629
 
#ifdef DEBUG_EXTRA
2630
 
    ErrorF("Kill ClipRect\n");
2631
 
#endif
2632
 
    psav->SavedBciCmd &= ~BCI_CMD_CLIP_CURRENT;
2633
 
}
2634
 
 
 
1533
    }
 
1534
 
 
1535
    if (psav->useEXA)
 
1536
        return SavageEXAInit(pScreen);
 
1537
    else
 
1538
        return SavageXAAInit(pScreen);
 
1539
}
2635
1540
 
2636
1541
/* Routines for debugging. */
2637
1542