~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/kdrive/neomagic/neo_draw.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
Import upstream version 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 * Copyright © 2004 Franco Catrin
 
4
 *
 
5
 * Permission to use, copy, modify, distribute, and sell this software and its
 
6
 * documentation for any purpose is hereby granted without fee, provided that
 
7
 * the above copyright notice appear in all copies and that both that
 
8
 * copyright notice and this permission notice appear in supporting
 
9
 * documentation, and that the name of Franco Catrin not be used in
 
10
 * advertising or publicity pertaining to distribution of the software without
 
11
 * specific, written prior permission.  Franco Catrin makes no
 
12
 * representations about the suitability of this software for any purpose.  It
 
13
 * is provided "as is" without express or implied warranty.
 
14
 *
 
15
 * FRANCO CATRIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
16
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
17
 * EVENT SHALL FRANCO CATRIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
18
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
19
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
20
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
21
 * PERFORMANCE OF THIS SOFTWARE.
 
22
 */
 
23
 
 
24
#ifdef HAVE_CONFIG_H
 
25
#include <kdrive-config.h>
 
26
#endif
 
27
#include "neomagic.h"
 
28
 
 
29
#include <X11/Xmd.h>
 
30
#include "gcstruct.h"
 
31
#include "scrnintstr.h"
 
32
#include "pixmapstr.h"
 
33
#include "regionstr.h"
 
34
#include "mistruct.h"
 
35
#include "dixfontstr.h"
 
36
#include "fb.h"
 
37
#include "migc.h"
 
38
#include "miline.h"
 
39
#include "picturestr.h"
 
40
 
 
41
NeoMMIO *mmio;
 
42
NeoScreenInfo *screen;
 
43
NeoCardInfo   *card;
 
44
CARD32 fgColor;
 
45
CARD32 rop;
 
46
 
 
47
CARD32 neoRop[16] = {
 
48
    0x000000,    /* GXclear */
 
49
    0x080000,    /* GXand */
 
50
    0x040000,    /* GXandReverse */
 
51
    0x0c0000,    /* GXcopy */
 
52
    0x020000,    /* GXandInvert */
 
53
    0x0a0000,    /* GXnoop */
 
54
    0x060000,    /* GXxor */
 
55
    0x0e0000,    /* GXor */
 
56
    0x010000,    /* GXnor */
 
57
    0x090000,    /* GXequiv */
 
58
    0x050000,    /* GXinvert */
 
59
    0x0d0000,    /* GXorReverse */
 
60
    0x030000,    /* GXcopyInvert */
 
61
    0x0b0000,    /* GXorInverted */
 
62
    0x070000,    /* GXnand */
 
63
    0x0f0000     /* GXset */
 
64
};
 
65
 
 
66
static  void neoWaitIdle(NeoCardInfo *neoc)
 
67
{
 
68
    // if MMIO is not working it may halt the machine
 
69
    unsigned int i = 0;
 
70
    while ((mmio->bltStat & 1) && ++i<100000);
 
71
}
 
72
 
 
73
static void neoWaitMarker (ScreenPtr pScreen, int marker)
 
74
{
 
75
    KdScreenPriv(pScreen);
 
76
    neoCardInfo(pScreenPriv);
 
77
 
 
78
    neoWaitIdle(neoc);
 
79
}
 
80
 
 
81
 
 
82
static Bool neoPrepareSolid(PixmapPtr pPixmap,
 
83
                            int alu,
 
84
                            Pixel pm,
 
85
                            Pixel fg)
 
86
{
 
87
    FbBits depthMask = FbFullMask(pPixmap->drawable.depth);
 
88
    if ((pm & depthMask) != depthMask) {
 
89
        return FALSE;
 
90
    } else {
 
91
        fgColor = fg;
 
92
                if (alu!=3) DBGOUT("used ROP %i\n", alu);
 
93
                rop = neoRop[alu];
 
94
        return TRUE;
 
95
    }
 
96
}
 
97
 
 
98
static void neoSolid (int x1, int y1, int x2, int y2)
 
99
{
 
100
    int x, y, w, h;
 
101
    x = x1;
 
102
    y = y1;
 
103
    w = x2-x1;
 
104
    h = y2-y1;
 
105
        neoWaitIdle(card);
 
106
        mmio->fgColor = fgColor;
 
107
        mmio->bltCntl =
 
108
                        NEO_BC3_FIFO_EN      |
 
109
                        NEO_BC0_SRC_IS_FG    |
 
110
                        NEO_BC3_SKIP_MAPPING | rop;             
 
111
    mmio->dstStart = y * screen->pitch + x * screen->depth;
 
112
 
 
113
    mmio->xyExt    = (unsigned long)(h << 16) | (w & 0xffff);
 
114
        
 
115
}
 
116
 
 
117
 
 
118
static void neoDoneSolid(void)
 
119
{
 
120
}
 
121
 
 
122
static Bool neoPrepareCopy (PixmapPtr pSrcPixpam, PixmapPtr pDstPixmap,
 
123
                     int dx, int dy, int alu, Pixel pm)
 
124
{
 
125
        rop = neoRop[alu];
 
126
    return TRUE;
 
127
}
 
128
 
 
129
static void neoCopy (int srcX, int srcY, int dstX, int dstY, int w, int h)
 
130
{
 
131
        neoWaitIdle(card);
 
132
        
 
133
    if ((dstY < srcY) || ((dstY == srcY) && (dstX < srcX))) {
 
134
                mmio->bltCntl  = 
 
135
                                        NEO_BC3_FIFO_EN |
 
136
                                        NEO_BC3_SKIP_MAPPING |  rop;
 
137
                mmio->srcStart = srcY * screen->pitch + srcX * screen->depth;
 
138
                mmio->dstStart = dstY * screen->pitch + dstX * screen->depth;
 
139
                
 
140
                mmio->xyExt    = (unsigned long)(h << 16) | (w & 0xffff);
 
141
        } else {
 
142
                mmio->bltCntl  = NEO_BC0_X_DEC |
 
143
                                        NEO_BC0_DST_Y_DEC |
 
144
                                        NEO_BC0_SRC_Y_DEC |
 
145
                                        NEO_BC3_FIFO_EN |
 
146
                                        NEO_BC3_SKIP_MAPPING |  rop;
 
147
                srcX+=w-1;
 
148
                dstX+=w-1;
 
149
                srcY+=h-1;
 
150
                dstY+=h-1;
 
151
                mmio->srcStart = srcY * screen->pitch + srcX * screen->depth;
 
152
                mmio->dstStart = dstY * screen->pitch + dstX * screen->depth;
 
153
                mmio->xyExt    = (unsigned long)(h << 16) | (w & 0xffff);
 
154
        }       
 
155
 
 
156
}
 
157
 
 
158
static void neoDoneCopy (void)
 
159
{
 
160
}
 
161
 
 
162
 
 
163
Bool neoDrawInit (ScreenPtr pScreen)
 
164
{
 
165
    KdScreenPriv(pScreen);
 
166
    neoScreenInfo(pScreenPriv);
 
167
 
 
168
    ENTER();
 
169
 
 
170
    memset(&neos->kaa, 0, sizeof(KaaScreenInfoRec));
 
171
    neos->kaa.waitMarker        = neoWaitMarker;
 
172
    neos->kaa.PrepareSolid      = neoPrepareSolid;
 
173
    neos->kaa.Solid             = neoSolid;
 
174
    neos->kaa.DoneSolid         = neoDoneSolid;
 
175
    neos->kaa.PrepareCopy       = neoPrepareCopy;
 
176
    neos->kaa.Copy              = neoCopy;
 
177
    neos->kaa.DoneCopy          = neoDoneCopy;
 
178
 
 
179
    if (!kaaDrawInit (pScreen, &neos->kaa)) {
 
180
        return FALSE;
 
181
    }
 
182
    LEAVE();
 
183
    return TRUE;
 
184
}
 
185
 
 
186
void neoDrawEnable (ScreenPtr pScreen)
 
187
{
 
188
    ENTER();
 
189
    SetupNeo(pScreen);
 
190
    screen = neos;
 
191
    card = neoc;
 
192
    mmio = neoc->mmio;
 
193
    screen->depth = (screen->backendScreen.mode.BitsPerPixel+7)/8;
 
194
    screen->pitch = screen->backendScreen.mode.BytesPerScanLine;
 
195
    DBGOUT("NEO depth=%x, pitch=%x\n", screen->depth, screen->pitch);
 
196
    LEAVE();
 
197
}
 
198
 
 
199
void neoDrawDisable (ScreenPtr pScreen)
 
200
{
 
201
    ENTER();
 
202
    LEAVE();
 
203
}
 
204
 
 
205
void neoDrawFini (ScreenPtr pScreen)
 
206
{
 
207
    ENTER();
 
208
    LEAVE();
 
209
}
 
210