1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
/*
* XAA acceleration for CL-GD546x -- The Laugna family
*
* lg_xaa.c
*
* (c) 1998 Corin Anderson.
* corina@the4cs.com
* Tukwila, WA
*
* Much of this code is inspired by the XAA acceleration from XFree86
* 3.3.3, laguna_acl.c
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "xf86.h"
#include "xf86_OSproc.h"
#include "compiler.h"
#include "xf86Pci.h"
#include "vgaHW.h"
#include "cir.h"
#define _LG_PRIVATE_
#include "lg.h"
#ifdef HAVE_XAA_H
#include "lg_xaa.h"
/* Laguna raster operations, source is OP1 and destination is OP0. */
/* The order in this array is important! */
static int lgRop[16] = {
/* Lg Op X name */
0x00, /* 0 GXclear */
0x88, /* S.D GXand */
0x44, /* S.~D GXandReverse */
0xCC, /* S GXcopy */
0x22, /* ~S.D GXandInverted */
0xAA, /* D GXnoop */
0x66, /* S~=D GXxor */
0xEE, /* S+D GXor */
0x77, /* ~S.~D GXnor */
0x99, /* S=D GXequiv */
0x55, /* ~D GXinvert */
0xDD, /* S+~D GXorReverse */
0x33, /* ~S GXcopyInverted */
0xBB, /* ~S+D GXorInverted */
0x11, /* ~S+~D GXnand */
0xFF /* 1 GXset */
};
#if 0
/* Laguna raster operations, source is OP2 and destination is OP0. */
static int lgPatRop[16] = {
/* Lg Op X name */
0x00, /* 0 GXclear */
0xA0, /* S.D GXand */
0x50, /* S.~D GXandReverse */
0xF0, /* S GXcopy */
0x0A, /* ~S.D GXandInverted */
0xAA, /* D GXnoop */
0x5A, /* S~=D GXxor */
0xFA, /* S+D GXor */
0x05, /* ~S.~D GXnor */
0xA5, /* S=D GXequiv */
0x55, /* ~D GXinvert */
0xF5, /* S+~D GXorReverse */
0x0F, /* ~S GXcopyInverted */
0xAF, /* ~S+D GXorInverted */
0x5F, /* ~S+~D GXnand */
0xFF /* 1 GXset */
};
#endif
static void LgSetBitmask(CirPtr pCir, const CARD32 m);
static void LgWaitQAvail(CirPtr pCir, int n);
static CARD32 LgExpandColor(CARD32 color, int bpp);
static void LgSync(ScrnInfoPtr pScrn);
static void LgSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
unsigned int planemask);
static void LgSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y,
int w, int h);
static void LgSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir,
int rop, unsigned int planemask,
int transparency_color);
static void LgSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1,
int x2, int y2, int w, int h);
/**************************************************** LgXAAInit *****/
Bool
LgXAAInit(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
CirPtr pCir = CIRPTR(pScrn);
XAAInfoRecPtr XAAPtr;
XAAPtr = XAACreateInfoRec();
if (!XAAPtr)
return FALSE;
/*
* Solid color fills.
*/
XAAPtr->SetupForSolidFill = LgSetupForSolidFill;
XAAPtr->SubsequentSolidFillRect = LgSubsequentSolidFillRect;
XAAPtr->SubsequentSolidFillTrap = NULL;
XAAPtr->SolidFillFlags = 0;
/*
* Screen-to-screen copies.
*/
XAAPtr->SetupForScreenToScreenCopy = LgSetupForScreenToScreenCopy;
XAAPtr->SubsequentScreenToScreenCopy = LgSubsequentScreenToScreenCopy;
/* Maybe ONLY_LEFT_TO_RIGHT_BITBLT or ONLY_TWO_BITBLT_DIRECTIONS? */
XAAPtr->ScreenToScreenCopyFlags = ONLY_LEFT_TO_RIGHT_BITBLT;
/*
* Miscellany.
*/
XAAPtr->Sync = LgSync;
pCir->AccelInfoRec = XAAPtr;
if (!XAAInit(pScreen, XAAPtr))
return FALSE;
return TRUE;
}
/******************************************** Lg XAA helper functions ***/
/*
* The bitmask is usually all 1's, so it's silly to spend a DWORD write
* to program the register with the same value each time. Bitmask is
* about the only register whose value is worth shadowing, so we special-
* case it.
*/
static void
LgSetBitmask(CirPtr pCir, const CARD32 m)
{
const LgPtr pLg = LGPTR(pCir);
if (m != pLg->oldBitmask) {
LgSETBITMASK(m);
pLg->oldBitmask = m;
}
}
/*
* Return from the function only when there's room somewhere for the
* upcoming register writes. That means that either PCI retry is enabled
* (i.e., we let the PCI bus buffer the register writes), or we wait for
* room in the Laguna's command queue explicitly.
*/
static void
LgWaitQAvail(CirPtr pCir, int n)
{
if (!0/*lgUsePCIRetry*/) {
CARD8 qfree;
/* Wait until n entries are open in the command queue */
do
qfree = *(volatile CARD8 *)(pCir->IOBase + QFREE);
while (qfree < n);
}
}
/* We might want to make this a macro at some point. */
static CARD32
LgExpandColor(CARD32 color, int bpp)
{
if (8 == bpp)
color = ((color&0xFF) << 8) | (color&0xFF);
if (8 == bpp || 16 == bpp)
color = ((color&0xFFFF) << 16) | (color&0xFFFF);
return color;
}
/*************************************************** Lg XAA functions ***/
static void
LgSync(ScrnInfoPtr pScrn)
{
const CirPtr pCir = CIRPTR(pScrn);
#if 0
LgPtr pLg = LGPTR(pScrn);
#endif
while (!LgREADY())
;
}
static void
LgSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
unsigned int planemask)
{
const CirPtr pCir = CIRPTR(pScrn);
color = LgExpandColor(color, pScrn->bitsPerPixel);
LgWaitQAvail(pCir, 4);
LgSETBACKGROUND(color);
LgSETROP(lgRop[rop]);
LgSETMODE(SCR2SCR | COLORFILL);
LgSetBitmask(pCir, planemask);
}
static void
LgSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h)
{
const CirPtr pCir = CIRPTR(pScrn);
/* Wait for room in the command queue. */
LgWaitQAvail(pCir, 2);
LgSETDSTXY(x, y);
LgSETEXTENTS(w, h);
}
static void
LgSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir,
int rop, unsigned int planemask, int transparency_color)
{
int bltmode = 0;
const CirPtr pCir = CIRPTR(pScrn);
const LgPtr pLg = LGPTR(pCir);
pLg->blitTransparent = (transparency_color != -1);
pLg->blitYDir = ydir;
LgWaitQAvail(pCir, 4);
/* We set the rop up here because the LgSETROP macro conveniently
(really -- it is convenient!) clears the transparency bits
in DRAWDEF. We'll set those bits appropriately later. */
LgSETROP(lgRop[rop]);
if (ydir < 0)
bltmode |= BLITUP;
if (pLg->blitTransparent) {
/* Gotta extend the transparency_color to the full 32-bit
size of the register. */
transparency_color = LgExpandColor(transparency_color,
pScrn->bitsPerPixel);
bltmode |= COLORTRANS;
LgSETBACKGROUND(transparency_color);
LgSETTRANSPARENCY(TRANSEQ);
} else {
LgSETTRANSPARENCY(TRANSNONE);
}
LgSETMODE(SCR2SCR | COLORSRC | bltmode);
LgSetBitmask(pCir, planemask);
}
static void
LgSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1,
int x2, int y2, int w, int h)
{
const CirPtr pCir = CIRPTR(pScrn);
const LgPtr pLg = LGPTR(pCir);
/*
* We have set the flag indicating that xdir must be one,
* so we can assume that here.
*/
if (pLg->blitYDir == -1) {
y1 += h - 1;
y2 += h - 1;
}
if (pLg->blitTransparent) {
/* We're doing a transparent blit. We'll need to point
OP2 to the color compare mask. */
LgWaitQAvail(pCir, 4);
LgSETTRANSMASK(x1, y1);
} else {
LgWaitQAvail(pCir, 3);
}
LgSETSRCXY(x1, y1);
LgSETDSTXY(x2, y2);
LgSETEXTENTS(w, h);
}
#endif
|