Line 0
Link Here
|
|
|
1 |
/* |
2 |
* Accelerated Driver for the SGI Indy's Newport graphics card |
3 |
* |
4 |
* (c) 2004 Dominik Behr <dominikbehr@yahoo.com> |
5 |
* this code is released under xfree 4.3.0 and xorg 6.8.0 license |
6 |
* |
7 |
*/ |
8 |
|
9 |
#include "newport.h" |
10 |
|
11 |
#ifdef NEWPORT_ACCEL |
12 |
|
13 |
#include "mi.h" |
14 |
#include "mizerarc.h" |
15 |
|
16 |
#define BARF(a) xf86DrvMsg(0, X_INFO, (a)) |
17 |
#define BARF1(a,b) xf86DrvMsg(0, X_INFO, (a), (b)) |
18 |
#define BARF2(a,b,c) xf86DrvMsg(0, X_INFO, (a), (b), (c)) |
19 |
#define BARF3(a,b,c,d) xf86DrvMsg(0, X_INFO, (a), (b), (c), (d)) |
20 |
#define BARF4(a,b,c,d,e) xf86DrvMsg(0, X_INFO, (a), (b), (c), (d), (e)) |
21 |
|
22 |
/* XAA Functions */ |
23 |
|
24 |
#define NEWPORT_PREROTATE |
25 |
/* |
26 |
there is a bug in XAA which causes it to reference NULL pointer to pattern cache when |
27 |
using HARDWARE_PROGRAMMED_PATTERN only (try x11perf -strap1) |
28 |
thus we have to also set HARDWARE_PROGRAMMED_ORIGIN and prerotate the pattern |
29 |
in the setup function |
30 |
*/ |
31 |
|
32 |
#define NEWPORT_GFIFO_ENTRIES 30 |
33 |
/* |
34 |
I dont know how many entries are in the gfx FIFO, judging by 6 bits in the GFIFO |
35 |
level status register it can be at most 63. it must be at least 32 because |
36 |
otherwise they would use less bits for status |
37 |
|
38 |
for now 16 seems to be safe value |
39 |
*/ |
40 |
#define NEWPORT_DELAY 128 |
41 |
|
42 |
/******************************************************************************* |
43 |
|
44 |
*******************************************************************************/ |
45 |
static void |
46 |
NewportWaitIdle(NewportPtr pNewport, unsigned int uEntries) |
47 |
{ |
48 |
NewportRegsPtr pNewportRegs; |
49 |
pNewportRegs = pNewport->pNewportRegs; |
50 |
/* wait for the GFIFO to drain */ |
51 |
while ((pNewportRegs->cset.stat & NPORT_STAT_GLMSK)) |
52 |
{ |
53 |
int i; |
54 |
volatile int x; |
55 |
for (x = 0, i = 0; i < NEWPORT_DELAY; i++) |
56 |
{ |
57 |
x += i; |
58 |
} |
59 |
} |
60 |
/* and then wait for the graphic to be idle */ |
61 |
while (pNewportRegs->cset.stat & NPORT_STAT_GBUSY) |
62 |
{ |
63 |
int i; |
64 |
volatile int x; |
65 |
for (x = 0, i = 0; i < NEWPORT_DELAY; i++) |
66 |
{ |
67 |
x += i; |
68 |
} |
69 |
} |
70 |
pNewport->fifoleft = NEWPORT_GFIFO_ENTRIES-uEntries; |
71 |
} |
72 |
|
73 |
|
74 |
#if 0 |
75 |
/******************************************************************************* |
76 |
|
77 |
*******************************************************************************/ |
78 |
static void |
79 |
NewportWaitGFIFO(NewportPtr pNewport, unsigned int uEntries) |
80 |
{ |
81 |
unsigned int uWaitLevel; |
82 |
|
83 |
/* NewportWaitIdle(pNewport, NEWPORT_GFIFO_ENTRIES); |
84 |
return;*/ |
85 |
|
86 |
if (uEntries >= NEWPORT_GFIFO_ENTRIES) |
87 |
{ |
88 |
uWaitLevel = 0; |
89 |
} |
90 |
else |
91 |
{ |
92 |
uWaitLevel = NEWPORT_GFIFO_ENTRIES-uEntries; |
93 |
} |
94 |
/* HACK */ |
95 |
/*uWaitLevel = 0;*/ |
96 |
while (((pNewport->pNewportRegs->cset.stat & NPORT_STAT_GLMSK) >> 7) > uWaitLevel) |
97 |
{ |
98 |
int i; |
99 |
volatile int x; |
100 |
for (x = 0, i = 0; i < NEWPORT_DELAY; i++) |
101 |
{ |
102 |
x += i; |
103 |
} |
104 |
} |
105 |
} |
106 |
#endif |
107 |
#if 1 |
108 |
/******************************************************************************* |
109 |
|
110 |
*******************************************************************************/ |
111 |
static void |
112 |
NewportWaitGFIFO(NewportPtr pNewport, unsigned int uEntries) |
113 |
{ |
114 |
if (uEntries > NEWPORT_GFIFO_ENTRIES) |
115 |
{ |
116 |
uEntries = NEWPORT_GFIFO_ENTRIES; |
117 |
} |
118 |
|
119 |
if (uEntries <= pNewport->fifoleft) |
120 |
{ |
121 |
pNewport->fifoleft -= uEntries; |
122 |
return; |
123 |
} |
124 |
|
125 |
while (1) |
126 |
{ |
127 |
unsigned int fifolevel; |
128 |
int i; |
129 |
volatile int x; |
130 |
|
131 |
fifolevel = (pNewport->pNewportRegs->cset.stat & NPORT_STAT_GLMSK) >> 7; |
132 |
if (fifolevel < NEWPORT_GFIFO_ENTRIES) |
133 |
{ |
134 |
pNewport->fifoleft = NEWPORT_GFIFO_ENTRIES - fifolevel; |
135 |
} |
136 |
else |
137 |
{ |
138 |
pNewport->fifoleft = 0; |
139 |
} |
140 |
if (uEntries <= pNewport->fifoleft) |
141 |
{ |
142 |
pNewport->fifoleft -= uEntries; |
143 |
return; |
144 |
} |
145 |
|
146 |
for (x = 0, i = 0; i < NEWPORT_DELAY; i++) |
147 |
{ |
148 |
x += i; |
149 |
} |
150 |
} |
151 |
} |
152 |
#endif |
153 |
|
154 |
|
155 |
/******************************************************************************* |
156 |
|
157 |
*******************************************************************************/ |
158 |
static void |
159 |
NewportXAASync(ScrnInfoPtr pScrn) |
160 |
{ |
161 |
NewportPtr pNewport; |
162 |
pNewport = NEWPORTPTR(pScrn); |
163 |
|
164 |
NewportWaitIdle(pNewport, 0); |
165 |
} |
166 |
|
167 |
|
168 |
/******************************************************************************* |
169 |
|
170 |
*******************************************************************************/ |
171 |
static unsigned int |
172 |
Rop2LogicOp(int rop) |
173 |
{ |
174 |
return (unsigned int)rop << 28; |
175 |
} |
176 |
|
177 |
/******************************************************************************* |
178 |
|
179 |
*******************************************************************************/ |
180 |
static void |
181 |
NewportUpdateClipping(NewportPtr pNewport) |
182 |
{ |
183 |
unsigned int smask0x, smask0y; |
184 |
|
185 |
if (pNewport->skipleft > pNewport->clipsx) |
186 |
{ |
187 |
smask0x = ((pNewport->skipleft & 0xFFFF) << 16) | (pNewport->clipex & 0xFFFF); |
188 |
} |
189 |
else |
190 |
{ |
191 |
smask0x = ((pNewport->clipsx & 0xFFFF) << 16) | (pNewport->clipex & 0xFFFF); |
192 |
} |
193 |
|
194 |
if (smask0x != pNewport->shadow_smask0x) |
195 |
{ |
196 |
NewportWaitGFIFO(pNewport, 1); |
197 |
pNewport->shadow_smask0x = smask0x; |
198 |
pNewport->pNewportRegs->set.smask0x = smask0x; |
199 |
} |
200 |
|
201 |
smask0y = ((pNewport->clipsy & 0xFFFF) << 16) | (pNewport->clipey & 0xFFFF); |
202 |
if (smask0y != pNewport->shadow_smask0y) |
203 |
{ |
204 |
NewportWaitGFIFO(pNewport, 1); |
205 |
pNewport->shadow_smask0y = smask0y; |
206 |
pNewport->pNewportRegs->set.smask0y = smask0y; |
207 |
} |
208 |
} |
209 |
|
210 |
/******************************************************************************* |
211 |
|
212 |
*******************************************************************************/ |
213 |
static unsigned int |
214 |
NewportColor2HOSTRW(unsigned int color) |
215 |
{ |
216 |
/* |
217 |
default XAA color is 0,R,G,B |
218 |
*/ |
219 |
#if 0 |
220 |
return ((color & 0x0000FF) << 16) |
221 |
| ((color & 0xFF0000) >> 16) |
222 |
| ((color & 0x00FF00)) |
223 |
; |
224 |
#endif |
225 |
/* but we changed masks to match the native format */ |
226 |
return color; |
227 |
} |
228 |
|
229 |
/******************************************************************************* |
230 |
|
231 |
*******************************************************************************/ |
232 |
static unsigned int |
233 |
NewportColor2Planes24(unsigned int color) |
234 |
{ |
235 |
unsigned int res; |
236 |
unsigned int i; |
237 |
unsigned int mr, mg, mb; |
238 |
unsigned int sr, sg, sb; |
239 |
|
240 |
/* |
241 |
XAA color is 0,R,G,B |
242 |
*/ |
243 |
|
244 |
res = 0; |
245 |
#if 0 |
246 |
mr = 0x800000; |
247 |
mg = 0x008000; |
248 |
mb = 0x000080; |
249 |
#endif |
250 |
mr = 0x000080; |
251 |
mg = 0x008000; |
252 |
mb = 0x800000; |
253 |
sr = 2; |
254 |
sg = 1; |
255 |
sb = 4; |
256 |
|
257 |
for (i = 0; i < 8; i++) |
258 |
{ |
259 |
res |= (color & mr)?sr:0; |
260 |
res |= (color & mg)?sg:0; |
261 |
res |= (color & mb)?sb:0; |
262 |
|
263 |
sr <<= 3; |
264 |
sg <<= 3; |
265 |
sb <<= 3; |
266 |
mr >>= 1; |
267 |
mg >>= 1; |
268 |
mb >>= 1; |
269 |
} |
270 |
|
271 |
return res; |
272 |
} |
273 |
|
274 |
/******************************************************************************* |
275 |
|
276 |
*******************************************************************************/ |
277 |
static unsigned int |
278 |
NewportColor2Planes8(unsigned int color) |
279 |
{ |
280 |
return color; |
281 |
} |
282 |
|
283 |
/******************************************************************************* |
284 |
|
285 |
*******************************************************************************/ |
286 |
static void |
287 |
NewportUpdateCOLORI(NewportPtr pNewport, unsigned long colori) |
288 |
{ |
289 |
if (colori != pNewport->shadow_colori) |
290 |
{ |
291 |
NewportWaitGFIFO(pNewport, 1); |
292 |
pNewport->shadow_colori = colori; |
293 |
pNewport->pNewportRegs->set.colori = colori; |
294 |
} |
295 |
} |
296 |
|
297 |
|
298 |
/******************************************************************************* |
299 |
|
300 |
*******************************************************************************/ |
301 |
static void |
302 |
NewportUpdateDRAWMODE0(NewportPtr pNewport, unsigned long drawmode0) |
303 |
{ |
304 |
if (drawmode0 != pNewport->shadow_drawmode0) |
305 |
{ |
306 |
NewportWaitGFIFO(pNewport, 1); |
307 |
pNewport->shadow_drawmode0 = drawmode0; |
308 |
pNewport->pNewportRegs->set.drawmode0 = drawmode0; |
309 |
} |
310 |
} |
311 |
|
312 |
|
313 |
/******************************************************************************* |
314 |
|
315 |
*******************************************************************************/ |
316 |
static void |
317 |
NewportUpdateDRAWMODE1(NewportPtr pNewport, unsigned long drawmode1) |
318 |
{ |
319 |
if (drawmode1 != pNewport->shadow_drawmode1) |
320 |
{ |
321 |
NewportWaitIdle(pNewport, 1); |
322 |
pNewport->shadow_drawmode1 = drawmode1; |
323 |
pNewport->pNewportRegs->set.drawmode1 = drawmode1; |
324 |
} |
325 |
} |
326 |
|
327 |
/******************************************************************************* |
328 |
|
329 |
*******************************************************************************/ |
330 |
static void |
331 |
NewportUpdateCOLORVRAM(NewportPtr pNewport, unsigned long colorvram) |
332 |
{ |
333 |
if (colorvram != pNewport->shadow_colorvram) |
334 |
{ |
335 |
NewportWaitIdle(pNewport, 1); |
336 |
pNewport->shadow_colorvram = colorvram; |
337 |
pNewport->pNewportRegs->set.colorvram = colorvram; |
338 |
} |
339 |
} |
340 |
|
341 |
/******************************************************************************* |
342 |
|
343 |
*******************************************************************************/ |
344 |
static void |
345 |
NewportUpdateCOLORBACK(NewportPtr pNewport, unsigned long colorback) |
346 |
{ |
347 |
if (colorback != pNewport->shadow_colorback) |
348 |
{ |
349 |
NewportWaitIdle(pNewport, 1); |
350 |
pNewport->shadow_colorback = colorback; |
351 |
pNewport->pNewportRegs->set.colorback = colorback; |
352 |
} |
353 |
} |
354 |
|
355 |
/******************************************************************************* |
356 |
|
357 |
*******************************************************************************/ |
358 |
static void |
359 |
NewportUpdateWRMASK(NewportPtr pNewport, unsigned long wrmask) |
360 |
{ |
361 |
if (wrmask != pNewport->shadow_wrmask) |
362 |
{ |
363 |
NewportWaitIdle(pNewport, 1); |
364 |
pNewport->shadow_wrmask = wrmask; |
365 |
pNewport->pNewportRegs->set.wrmask = wrmask; |
366 |
} |
367 |
} |
368 |
|
369 |
/******************************************************************************* |
370 |
|
371 |
*******************************************************************************/ |
372 |
static void |
373 |
NewportUpdateXYMOVE(NewportPtr pNewport, unsigned long xymove) |
374 |
{ |
375 |
if (xymove != pNewport->shadow_xymove) |
376 |
{ |
377 |
NewportWaitIdle(pNewport, 1); |
378 |
pNewport->shadow_xymove = xymove; |
379 |
pNewport->pNewportRegs->set.xymove = xymove; |
380 |
} |
381 |
} |
382 |
|
383 |
|
384 |
/******************************************************************************* |
385 |
|
386 |
*******************************************************************************/ |
387 |
static void |
388 |
NewportXAASetupForScreenToScreenCopy(ScrnInfoPtr pScrn, |
389 |
int xdir, |
390 |
int ydir, |
391 |
int rop, |
392 |
unsigned int planemask, |
393 |
int trans_color) |
394 |
{ |
395 |
NewportRegsPtr pNewportRegs; |
396 |
NewportPtr pNewport; |
397 |
pNewport = NEWPORTPTR(pScrn); |
398 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
399 |
|
400 |
NewportUpdateDRAWMODE1(pNewport, pNewport->setup_drawmode1 | Rop2LogicOp(rop)); |
401 |
NewportUpdateWRMASK(pNewport, pNewport->Color2Planes(planemask)); |
402 |
pNewport->skipleft = 0; |
403 |
NewportUpdateClipping(pNewport); |
404 |
NewportUpdateDRAWMODE0(pNewport, |
405 |
0 |
406 |
| NPORT_DMODE0_S2S |
407 |
| NPORT_DMODE0_BLOCK |
408 |
| NPORT_DMODE0_DOSETUP |
409 |
| NPORT_DMODE0_STOPX |
410 |
| NPORT_DMODE0_STOPY |
411 |
); |
412 |
|
413 |
|
414 |
} |
415 |
|
416 |
/******************************************************************************* |
417 |
|
418 |
*******************************************************************************/ |
419 |
static void |
420 |
NewportXAASubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, |
421 |
int x1, int y1, |
422 |
int x2, int y2, |
423 |
int width, int height) |
424 |
{ |
425 |
int dx, dy; |
426 |
unsigned int sx, sy, ex, ey; |
427 |
NewportRegsPtr pNewportRegs; |
428 |
NewportPtr pNewport; |
429 |
pNewport = NEWPORTPTR(pScrn); |
430 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
431 |
|
432 |
dx = x2 - x1; |
433 |
dy = y2 - y1; |
434 |
if (!dx && !dy) |
435 |
return; |
436 |
|
437 |
if (width) |
438 |
x2 = x1 + width - 1; |
439 |
else |
440 |
x2 = x1; |
441 |
|
442 |
if (height) |
443 |
y2 = y1 + height - 1; |
444 |
else |
445 |
y2 = y1; |
446 |
|
447 |
if (dx < 0) |
448 |
{ |
449 |
sx = x1 & 0xFFFF; |
450 |
ex = x2 & 0xFFFF; |
451 |
} |
452 |
else |
453 |
{ |
454 |
sx = x2 & 0xFFFF; |
455 |
ex = x1 & 0xFFFF; |
456 |
} |
457 |
|
458 |
if (dy < 0) |
459 |
{ |
460 |
sy = y1 & 0xFFFF; |
461 |
ey = y2 & 0xFFFF; |
462 |
} |
463 |
else |
464 |
{ |
465 |
sy = y2 & 0xFFFF; |
466 |
ey = y1 & 0xFFFF; |
467 |
} |
468 |
|
469 |
dx &= 0xFFFF; |
470 |
dy &= 0xFFFF; |
471 |
|
472 |
NewportUpdateXYMOVE(pNewport, (dx << 16) | dy); /* this is bad because it stalls the pipeline but nothing can be done about it */ |
473 |
NewportWaitGFIFO(pNewport, 2); |
474 |
pNewportRegs->set.xystarti = (sx << 16) | sy; |
475 |
pNewportRegs->go.xyendi = (ex << 16) | ey; |
476 |
} |
477 |
|
478 |
/******************************************************************************* |
479 |
|
480 |
*******************************************************************************/ |
481 |
static void |
482 |
NewportXAASetupForSolidFill(ScrnInfoPtr pScrn, |
483 |
int Color, |
484 |
int rop, |
485 |
unsigned int planemask) |
486 |
{ |
487 |
NewportRegsPtr pNewportRegs; |
488 |
NewportPtr pNewport; |
489 |
pNewport = NEWPORTPTR(pScrn); |
490 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
491 |
|
492 |
if (rop == GXcopy |
493 |
|| rop == GXclear |
494 |
|| rop == GXset) |
495 |
{ |
496 |
/* if possible try to set up a fast clear which is 4x faster */ |
497 |
NewportUpdateDRAWMODE1(pNewport, pNewport->setup_drawmode1 | NPORT_DMODE1_FCLR | Rop2LogicOp(GXcopy)); |
498 |
if (rop == GXclear) |
499 |
NewportUpdateCOLORVRAM(pNewport, 0); |
500 |
else |
501 |
if (rop == GXset) |
502 |
NewportUpdateCOLORVRAM(pNewport, 0xFFFFFF); |
503 |
else |
504 |
NewportUpdateCOLORVRAM(pNewport, pNewport->Color2Planes((unsigned int)Color)); |
505 |
} |
506 |
else |
507 |
{ |
508 |
NewportUpdateDRAWMODE1(pNewport, pNewport->setup_drawmode1 | Rop2LogicOp(rop)); |
509 |
NewportUpdateCOLORI(pNewport, NewportColor2HOSTRW(Color)); |
510 |
} |
511 |
|
512 |
NewportUpdateWRMASK(pNewport, pNewport->Color2Planes(planemask)); |
513 |
pNewport->skipleft = 0; |
514 |
NewportUpdateClipping(pNewport); |
515 |
NewportUpdateDRAWMODE0(pNewport, |
516 |
0 |
517 |
| NPORT_DMODE0_DRAW |
518 |
| NPORT_DMODE0_BLOCK |
519 |
| NPORT_DMODE0_DOSETUP |
520 |
| NPORT_DMODE0_STOPX |
521 |
| NPORT_DMODE0_STOPY |
522 |
); |
523 |
} |
524 |
|
525 |
/******************************************************************************* |
526 |
|
527 |
*******************************************************************************/ |
528 |
static void |
529 |
NewportXAASubsequentSolidFillRect(ScrnInfoPtr pScrn, |
530 |
int x, |
531 |
int y, |
532 |
int w, |
533 |
int h) |
534 |
{ |
535 |
int ex, ey; |
536 |
NewportRegsPtr pNewportRegs; |
537 |
NewportPtr pNewport; |
538 |
pNewport = NEWPORTPTR(pScrn); |
539 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
540 |
|
541 |
if (w == 0) w = 1; |
542 |
if (h == 0) h = 1; |
543 |
ex = x + w - 1; |
544 |
ey = y + h - 1; |
545 |
|
546 |
NewportWaitGFIFO(pNewport, 2); |
547 |
pNewportRegs->set.xystarti = ((x & 0xFFFF) << 16) | (y & 0xFFFF); |
548 |
pNewportRegs->go.xyendi = ((ex & 0xFFFF) << 16) | (ey & 0xFFFF); |
549 |
} |
550 |
|
551 |
/******************************************************************************* |
552 |
|
553 |
*******************************************************************************/ |
554 |
static void |
555 |
NewportXAASetupForSolidLine(ScrnInfoPtr pScrn, |
556 |
int Color, |
557 |
int rop, |
558 |
unsigned int planemask) |
559 |
{ |
560 |
NewportRegsPtr pNewportRegs; |
561 |
NewportPtr pNewport; |
562 |
pNewport = NEWPORTPTR(pScrn); |
563 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
564 |
|
565 |
NewportUpdateDRAWMODE1(pNewport, pNewport->setup_drawmode1 | Rop2LogicOp(rop)); |
566 |
NewportUpdateWRMASK(pNewport, pNewport->Color2Planes(planemask)); |
567 |
NewportUpdateCOLORI(pNewport, NewportColor2HOSTRW(Color)); |
568 |
|
569 |
pNewport->skipleft = 0; |
570 |
NewportUpdateClipping(pNewport); |
571 |
pNewport->setup_drawmode0 = (0 |
572 |
| NPORT_DMODE0_DRAW |
573 |
| NPORT_DMODE0_ILINE |
574 |
| NPORT_DMODE0_DOSETUP |
575 |
| NPORT_DMODE0_STOPX |
576 |
| NPORT_DMODE0_STOPY |
577 |
); |
578 |
} |
579 |
|
580 |
/******************************************************************************* |
581 |
|
582 |
*******************************************************************************/ |
583 |
static void |
584 |
NewportXAASubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, |
585 |
int x1, |
586 |
int y1, |
587 |
int x2, |
588 |
int y2, |
589 |
int flags) |
590 |
{ |
591 |
NewportRegsPtr pNewportRegs; |
592 |
NewportPtr pNewport; |
593 |
pNewport = NEWPORTPTR(pScrn); |
594 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
595 |
|
596 |
NewportUpdateDRAWMODE0(pNewport, |
597 |
pNewport->setup_drawmode0 |
598 |
| ((flags & OMIT_LAST) ? NPORT_DMODE0_SKLST : 0) |
599 |
); |
600 |
NewportWaitGFIFO(pNewport, 2); |
601 |
pNewportRegs->set.xystarti = ((x1 & 0xFFFF) << 16) | (y1 & 0xFFFF); |
602 |
pNewportRegs->go.xyendi = ((x2 & 0xFFFF) << 16) | (y2 & 0xFFFF); |
603 |
} |
604 |
|
605 |
|
606 |
/******************************************************************************* |
607 |
|
608 |
*******************************************************************************/ |
609 |
static void |
610 |
NewportXAASetupForDashedLine(ScrnInfoPtr pScrn, |
611 |
int fg, |
612 |
int bg, |
613 |
int rop, |
614 |
unsigned int planemask, |
615 |
int length, |
616 |
unsigned char *pattern) |
617 |
{ |
618 |
NewportRegsPtr pNewportRegs; |
619 |
NewportPtr pNewport; |
620 |
int i; |
621 |
|
622 |
pNewport = NEWPORTPTR(pScrn); |
623 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
624 |
|
625 |
pNewport->dashline_patlen = length; |
626 |
for (i = 0; i < (length+7)>>3; i++) |
627 |
pNewport->dashline_pat[i] = pattern[i]; |
628 |
|
629 |
NewportUpdateDRAWMODE1(pNewport, pNewport->setup_drawmode1 | Rop2LogicOp(rop)); |
630 |
NewportUpdateWRMASK(pNewport, pNewport->Color2Planes(planemask)); |
631 |
if (bg != -1) |
632 |
NewportUpdateCOLORBACK(pNewport, NewportColor2HOSTRW(bg)); |
633 |
NewportUpdateCOLORI(pNewport, NewportColor2HOSTRW(fg)); |
634 |
pNewport->skipleft = 0; |
635 |
NewportUpdateClipping(pNewport); |
636 |
pNewport->setup_drawmode0 = (0 |
637 |
| NPORT_DMODE0_DRAW |
638 |
| NPORT_DMODE0_ILINE |
639 |
| NPORT_DMODE0_DOSETUP |
640 |
| NPORT_DMODE0_STOPX |
641 |
| NPORT_DMODE0_STOPY |
642 |
| NPORT_DMODE0_L32 |
643 |
| NPORT_DMODE0_ZPENAB |
644 |
| ((bg == -1) ? 0 : NPORT_DMODE0_ZOPQ) |
645 |
); |
646 |
} |
647 |
|
648 |
/******************************************************************************* |
649 |
|
650 |
*******************************************************************************/ |
651 |
static void |
652 |
NewportXAASubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, |
653 |
int x1, |
654 |
int y1, |
655 |
int x2, |
656 |
int y2, |
657 |
int flags, |
658 |
int phase) |
659 |
{ |
660 |
NewportRegsPtr pNewportRegs; |
661 |
NewportPtr pNewport; |
662 |
int dx, dy; |
663 |
unsigned int linelen; |
664 |
unsigned int dwords; |
665 |
|
666 |
pNewport = NEWPORTPTR(pScrn); |
667 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
668 |
|
669 |
dx = x2 - x1; if (dx < 0) dx = -dx; dx++; |
670 |
dy = y2 - y1; if (dy < 0) dy = -dy; dy++; |
671 |
if (dx > dy) |
672 |
linelen = dx; |
673 |
else |
674 |
linelen = dy; |
675 |
dwords = (linelen + 31) >> 5; |
676 |
|
677 |
NewportUpdateDRAWMODE0(pNewport, |
678 |
pNewport->setup_drawmode0 |
679 |
| ((flags & OMIT_LAST) ? NPORT_DMODE0_SKLST : 0) |
680 |
); |
681 |
|
682 |
NewportWaitGFIFO(pNewport, 3); |
683 |
pNewportRegs->set.xystarti = ((x1 & 0xFFFF) << 16) | (y1 & 0xFFFF); |
684 |
pNewportRegs->set.xyendi = ((x2 & 0xFFFF) << 16) | (y2 & 0xFFFF); |
685 |
pNewportRegs->set._setup = 1; |
686 |
|
687 |
phase %= pNewport->dashline_patlen; |
688 |
while (dwords--) { |
689 |
unsigned int bit; |
690 |
unsigned int pat; |
691 |
unsigned int mask; |
692 |
pat = 0; |
693 |
mask = 0x80000000; |
694 |
for (bit = 0; bit < 32; bit++) |
695 |
{ |
696 |
if (pNewport->dashline_pat[phase >> 3] & (0x80 >> (phase & 7))) |
697 |
pat |= mask; |
698 |
phase = (phase + 1) % pNewport->dashline_patlen; |
699 |
mask >>= 1; |
700 |
} |
701 |
NewportWaitGFIFO(pNewport, 1); |
702 |
pNewportRegs->go.zpattern = pat; |
703 |
} |
704 |
|
705 |
} |
706 |
|
707 |
/******************************************************************************* |
708 |
|
709 |
*******************************************************************************/ |
710 |
static void |
711 |
NewportXAASetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, |
712 |
int fg, |
713 |
int bg, |
714 |
int rop, |
715 |
unsigned int planemask) |
716 |
{ |
717 |
NewportRegsPtr pNewportRegs; |
718 |
NewportPtr pNewport; |
719 |
pNewport = NEWPORTPTR(pScrn); |
720 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
721 |
|
722 |
NewportUpdateDRAWMODE1(pNewport, pNewport->setup_drawmode1 | Rop2LogicOp(rop)); |
723 |
NewportUpdateWRMASK(pNewport, pNewport->Color2Planes(planemask)); |
724 |
if (bg != -1) |
725 |
NewportUpdateCOLORBACK(pNewport, NewportColor2HOSTRW(bg)); |
726 |
NewportUpdateCOLORI(pNewport, NewportColor2HOSTRW(fg)); |
727 |
NewportUpdateDRAWMODE0(pNewport, |
728 |
0 |
729 |
| NPORT_DMODE0_DRAW |
730 |
| NPORT_DMODE0_BLOCK |
731 |
| NPORT_DMODE0_DOSETUP |
732 |
| NPORT_DMODE0_STOPX |
733 |
| NPORT_DMODE0_ZPENAB |
734 |
| ((bg == -1) ? 0 : NPORT_DMODE0_ZOPQ) |
735 |
| NPORT_DMODE0_L32 |
736 |
); |
737 |
} |
738 |
|
739 |
/******************************************************************************* |
740 |
|
741 |
*******************************************************************************/ |
742 |
static void |
743 |
NewportXAASubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, |
744 |
int x, |
745 |
int y, |
746 |
int w, |
747 |
int h, |
748 |
int skipleft) |
749 |
{ |
750 |
int ex, ey; |
751 |
NewportRegsPtr pNewportRegs; |
752 |
NewportPtr pNewport; |
753 |
pNewport = NEWPORTPTR(pScrn); |
754 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
755 |
|
756 |
if (w == 0) w = 1; |
757 |
if (h == 0) h = 1; |
758 |
ex = x + w - 1; |
759 |
ey = y + h - 1; |
760 |
|
761 |
if (skipleft) |
762 |
{ |
763 |
pNewport->skipleft = x + skipleft; |
764 |
} |
765 |
else |
766 |
{ |
767 |
pNewport->skipleft = 0; |
768 |
} |
769 |
NewportUpdateClipping(pNewport); |
770 |
|
771 |
NewportWaitGFIFO(pNewport, 3); |
772 |
pNewportRegs->set.xystarti = ((x & 0xFFFF) << 16) | (y & 0xFFFF); |
773 |
pNewportRegs->set.xyendi = ((ex & 0xFFFF) << 16) | (ey & 0xFFFF); |
774 |
pNewportRegs->set._setup = 1; |
775 |
|
776 |
/* after return XAA will start blasting the pattern to go.zpattern register */ |
777 |
/* we have to wait here for idle because if there is something in the pipeline that will take |
778 |
long time to complete and if following cpu transfers will overflow the FIFO causing GIO bus |
779 |
stall it will end up in bus error */ |
780 |
NewportWaitIdle(pNewport, NEWPORT_GFIFO_ENTRIES); |
781 |
|
782 |
} |
783 |
|
784 |
/******************************************************************************* |
785 |
|
786 |
*******************************************************************************/ |
787 |
static void |
788 |
NewportXAASetupForImageWrite(ScrnInfoPtr pScrn, |
789 |
int rop, |
790 |
unsigned int planemask, |
791 |
int trans_color, |
792 |
int bpp, |
793 |
int depth) |
794 |
{ |
795 |
NewportRegsPtr pNewportRegs; |
796 |
NewportPtr pNewport; |
797 |
pNewport = NEWPORTPTR(pScrn); |
798 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
799 |
|
800 |
NewportUpdateDRAWMODE1(pNewport, pNewport->setup_drawmode1 | Rop2LogicOp(rop)); |
801 |
NewportUpdateWRMASK(pNewport, pNewport->Color2Planes(planemask)); |
802 |
NewportUpdateDRAWMODE0(pNewport, |
803 |
0 |
804 |
| NPORT_DMODE0_DRAW |
805 |
| NPORT_DMODE0_BLOCK |
806 |
| NPORT_DMODE0_CHOST |
807 |
| NPORT_DMODE0_DOSETUP |
808 |
); |
809 |
|
810 |
} |
811 |
|
812 |
/******************************************************************************* |
813 |
|
814 |
*******************************************************************************/ |
815 |
static void |
816 |
NewportXAASubsequentImageWriteRect(ScrnInfoPtr pScrn, |
817 |
int x, |
818 |
int y, |
819 |
int w, |
820 |
int h, |
821 |
int skipleft) |
822 |
{ |
823 |
int ex, ey; |
824 |
NewportRegsPtr pNewportRegs; |
825 |
NewportPtr pNewport; |
826 |
pNewport = NEWPORTPTR(pScrn); |
827 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
828 |
|
829 |
if (w == 0) w = 1; |
830 |
if (h == 0) h = 1; |
831 |
|
832 |
ex = x + w - 1; |
833 |
ey = y + h - 1; |
834 |
|
835 |
if (skipleft) |
836 |
{ |
837 |
pNewport->skipleft = x + skipleft; |
838 |
} |
839 |
else |
840 |
{ |
841 |
pNewport->skipleft = 0; |
842 |
} |
843 |
NewportUpdateClipping(pNewport); |
844 |
|
845 |
NewportWaitGFIFO(pNewport, 3); |
846 |
pNewportRegs->set.xystarti = ((x & 0xFFFF) << 16) | (y & 0xFFFF); |
847 |
pNewportRegs->set.xyendi = ((ex & 0xFFFF) << 16) | (ey & 0xFFFF); |
848 |
pNewportRegs->set._setup = 1; |
849 |
|
850 |
/* after return XAA will start blasting the image to go.hostrw0 register */ |
851 |
/* we have to wait here for idle because if there is something in the pipeline that will take |
852 |
long time to complete and if following cpu transfers will overflow the FIFO causing GIO bus |
853 |
stall it will end up in bus error */ |
854 |
NewportWaitIdle(pNewport, NEWPORT_GFIFO_ENTRIES); |
855 |
} |
856 |
|
857 |
static unsigned int |
858 |
repbyte(unsigned int b) |
859 |
{ |
860 |
b &= 0xFF; |
861 |
return b | (b << 8) | (b << 16) | (b << 24); |
862 |
} |
863 |
|
864 |
static void |
865 |
prerotatebyte(unsigned int b, unsigned int *p) |
866 |
{ |
867 |
int i; |
868 |
|
869 |
b &= 0xFF; |
870 |
|
871 |
for (i = 0; i < 8; i++) |
872 |
{ |
873 |
p[i] = repbyte(b); |
874 |
if (b & 1) |
875 |
b = (b >> 1) | 0x80; |
876 |
else |
877 |
b = b >> 1; |
878 |
} |
879 |
} |
880 |
|
881 |
/******************************************************************************* |
882 |
|
883 |
*******************************************************************************/ |
884 |
static void |
885 |
NewportXAASetupForMono8x8PatternFill(ScrnInfoPtr pScrn, |
886 |
int patx, |
887 |
int paty, |
888 |
int fg, |
889 |
int bg, |
890 |
int rop, |
891 |
unsigned int planemask) |
892 |
{ |
893 |
NewportRegsPtr pNewportRegs; |
894 |
NewportPtr pNewport; |
895 |
pNewport = NEWPORTPTR(pScrn); |
896 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
897 |
|
898 |
#ifdef NEWPORT_PREROTATE |
899 |
/* prerotate the pattern */ |
900 |
prerotatebyte((unsigned int)patx >> 24, pNewport->pat8x8[0]); |
901 |
prerotatebyte((unsigned int)patx >> 16, pNewport->pat8x8[1]); |
902 |
prerotatebyte((unsigned int)patx >> 8, pNewport->pat8x8[2]); |
903 |
prerotatebyte((unsigned int)patx, pNewport->pat8x8[3]); |
904 |
prerotatebyte((unsigned int)paty >> 24, pNewport->pat8x8[4]); |
905 |
prerotatebyte((unsigned int)paty >> 16, pNewport->pat8x8[5]); |
906 |
prerotatebyte((unsigned int)paty >> 8, pNewport->pat8x8[6]); |
907 |
prerotatebyte((unsigned int)paty, pNewport->pat8x8[7]); |
908 |
#endif |
909 |
NewportUpdateDRAWMODE1(pNewport, pNewport->setup_drawmode1 | Rop2LogicOp(rop)); |
910 |
NewportUpdateWRMASK(pNewport, pNewport->Color2Planes(planemask)); |
911 |
if (bg != -1) |
912 |
NewportUpdateCOLORBACK(pNewport, NewportColor2HOSTRW(bg)); |
913 |
NewportUpdateCOLORI(pNewport, NewportColor2HOSTRW(fg)); |
914 |
pNewport->skipleft = 0; |
915 |
NewportUpdateClipping(pNewport); |
916 |
NewportUpdateDRAWMODE0(pNewport, |
917 |
0 |
918 |
| NPORT_DMODE0_DRAW |
919 |
| NPORT_DMODE0_BLOCK |
920 |
| NPORT_DMODE0_DOSETUP |
921 |
| NPORT_DMODE0_STOPX |
922 |
| NPORT_DMODE0_ZPENAB |
923 |
| ((bg == -1) ? 0 : NPORT_DMODE0_ZOPQ) |
924 |
| NPORT_DMODE0_L32 |
925 |
); |
926 |
} |
927 |
|
928 |
|
929 |
|
930 |
/******************************************************************************* |
931 |
|
932 |
*******************************************************************************/ |
933 |
static void |
934 |
NewportXAASubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, |
935 |
int patx, |
936 |
int paty, |
937 |
int x, |
938 |
int y, |
939 |
int w, |
940 |
int h) |
941 |
{ |
942 |
int ex, ey; |
943 |
unsigned int d; |
944 |
#ifndef NEWPORT_PREROTATE |
945 |
unsigned int p; |
946 |
unsigned int epat[8]; |
947 |
#endif |
948 |
|
949 |
NewportRegsPtr pNewportRegs; |
950 |
NewportPtr pNewport; |
951 |
pNewport = NEWPORTPTR(pScrn); |
952 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
953 |
|
954 |
if (w == 0) w = 1; |
955 |
if (h == 0) h = 1; |
956 |
ex = x + w - 1; |
957 |
ey = y + h - 1; |
958 |
|
959 |
NewportWaitGFIFO(pNewport, 3); |
960 |
pNewportRegs->set.xystarti = ((x & 0xFFFF) << 16) | (y & 0xFFFF); |
961 |
pNewportRegs->set.xyendi = ((ex & 0xFFFF) << 16) | (ey & 0xFFFF); |
962 |
pNewportRegs->set._setup = 1; |
963 |
|
964 |
#ifdef NEWPORT_PREROTATE |
965 |
patx &= 7; |
966 |
paty &= 7; |
967 |
while (h--) |
968 |
{ |
969 |
for (d = (w + 31) >> 5; d; d--) |
970 |
{ |
971 |
NewportWaitGFIFO(pNewport, 1); |
972 |
pNewportRegs->go.zpattern = pNewport->pat8x8[paty][patx]; |
973 |
} |
974 |
paty = (paty + 1) & 7; |
975 |
} |
976 |
#else |
977 |
epat[0] = repbyte(patx >> 24); |
978 |
epat[1] = repbyte(patx >> 16); |
979 |
epat[2] = repbyte(patx >> 8); |
980 |
epat[3] = repbyte(patx); |
981 |
epat[4] = repbyte(paty >> 24); |
982 |
epat[5] = repbyte(paty >> 16); |
983 |
epat[6] = repbyte(paty >> 8); |
984 |
epat[7] = repbyte(paty); |
985 |
|
986 |
p = 0; |
987 |
while (h--) |
988 |
{ |
989 |
for (d = (w + 31) >> 5; d; d--) |
990 |
{ |
991 |
NewportWaitGFIFO(pNewport, 1); |
992 |
pNewportRegs->go.zpattern = epat[p]; |
993 |
} |
994 |
p = (p + 1) ^ 7; |
995 |
} |
996 |
#endif |
997 |
} |
998 |
|
999 |
/******************************************************************************* |
1000 |
|
1001 |
*******************************************************************************/ |
1002 |
static void |
1003 |
NewportXAAReadPixmap(ScrnInfoPtr pScrn, |
1004 |
int x, |
1005 |
int y, |
1006 |
int w, |
1007 |
int h, |
1008 |
unsigned char *dst, |
1009 |
int dstwidth, |
1010 |
int bpp, |
1011 |
int depth) |
1012 |
{ |
1013 |
int ex, ey; |
1014 |
NewportRegsPtr pNewportRegs; |
1015 |
NewportPtr pNewport; |
1016 |
pNewport = NEWPORTPTR(pScrn); |
1017 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
1018 |
|
1019 |
if (w == 0) w = 1; |
1020 |
if (h == 0) h = 1; |
1021 |
ex = x + w - 1; |
1022 |
ey = y + h - 1; |
1023 |
|
1024 |
NewportWaitIdle(pNewport, 0); |
1025 |
NewportUpdateDRAWMODE1(pNewport, pNewport->setup_drawmode1 | Rop2LogicOp(GXcopy) | NPORT_DMODE1_PFENAB); |
1026 |
NewportUpdateWRMASK(pNewport, pNewport->Color2Planes(0xFFFFFFFF)); |
1027 |
NewportUpdateDRAWMODE0(pNewport, |
1028 |
0 |
1029 |
| NPORT_DMODE0_RD |
1030 |
| NPORT_DMODE0_BLOCK |
1031 |
| NPORT_DMODE0_CHOST |
1032 |
| NPORT_DMODE0_DOSETUP |
1033 |
); |
1034 |
|
1035 |
NewportWaitGFIFO(pNewport, 3); |
1036 |
pNewportRegs->set.xystarti = ((x & 0xFFFF) << 16) | (y & 0xFFFF); |
1037 |
pNewportRegs->set.xyendi = ((ex & 0xFFFF) << 16) | (ey & 0xFFFF); |
1038 |
/* with prefetch enabled go has to be issued before we start reading */ |
1039 |
pNewportRegs->go._setup = 1; |
1040 |
|
1041 |
|
1042 |
if (pScrn->bitsPerPixel == 8) |
1043 |
{ |
1044 |
unsigned int d; |
1045 |
while (h--) |
1046 |
{ |
1047 |
unsigned char *p; |
1048 |
p = (unsigned char *)dst; |
1049 |
for (x = 0; x < w; x += 4) |
1050 |
{ |
1051 |
if (!h && x+4 >= w) |
1052 |
{ /* the last dword does not need go */ |
1053 |
d = pNewportRegs->set.hostrw0; |
1054 |
} |
1055 |
else |
1056 |
{ |
1057 |
d = pNewportRegs->go.hostrw0; |
1058 |
} |
1059 |
|
1060 |
*p++ = (d & 0xFF000000) >> 24; |
1061 |
if (x+1 < w) |
1062 |
{ |
1063 |
*p++ = (d & 0x00FF0000) >> 16; |
1064 |
} |
1065 |
if (x+2 < w) |
1066 |
{ |
1067 |
*p++ = (d & 0x0000FF00) >> 8; |
1068 |
} |
1069 |
if (x+3 < w) |
1070 |
{ |
1071 |
*p++ = d & 0x000000FF; |
1072 |
} |
1073 |
} |
1074 |
dst += dstwidth; |
1075 |
} |
1076 |
} |
1077 |
else |
1078 |
{ |
1079 |
while (h--) |
1080 |
{ |
1081 |
unsigned int *p; |
1082 |
p = (unsigned int *)dst; |
1083 |
for (x = 0; x < w; x++) |
1084 |
{ |
1085 |
if (!h && x+1 == w) |
1086 |
{ /* the last dword does not need go */ |
1087 |
*p++ = pNewportRegs->set.hostrw0; |
1088 |
} |
1089 |
else |
1090 |
{ |
1091 |
*p++ = pNewportRegs->go.hostrw0; |
1092 |
} |
1093 |
} |
1094 |
dst += dstwidth; |
1095 |
} |
1096 |
} |
1097 |
} |
1098 |
|
1099 |
/******************************************************************************* |
1100 |
|
1101 |
*******************************************************************************/ |
1102 |
static void |
1103 |
NewportXAASetClippingRectangle(ScrnInfoPtr pScrn, |
1104 |
int left, |
1105 |
int top, |
1106 |
int right, |
1107 |
int bottom) |
1108 |
{ |
1109 |
NewportPtr pNewport; |
1110 |
pNewport = NEWPORTPTR(pScrn); |
1111 |
|
1112 |
if (left < 0) left = 0; |
1113 |
if (right > pScrn->virtualX-1) right = pScrn->virtualX-1; |
1114 |
|
1115 |
if (top < 0) top = 0; |
1116 |
if (bottom > pScrn->virtualY-1) bottom = pScrn->virtualY-1; |
1117 |
|
1118 |
pNewport->clipsx = left; |
1119 |
pNewport->clipex = right; |
1120 |
pNewport->clipsy = top; |
1121 |
pNewport->clipey = bottom; |
1122 |
|
1123 |
NewportUpdateClipping(pNewport); |
1124 |
} |
1125 |
|
1126 |
/******************************************************************************* |
1127 |
|
1128 |
*******************************************************************************/ |
1129 |
static void |
1130 |
NewportXAADisableClipping(ScrnInfoPtr pScrn) |
1131 |
{ |
1132 |
NewportPtr pNewport; |
1133 |
pNewport = NEWPORTPTR(pScrn); |
1134 |
|
1135 |
pNewport->clipsx = 0; |
1136 |
pNewport->clipex = pScrn->virtualX-1; |
1137 |
pNewport->clipsy = 0; |
1138 |
pNewport->clipey = pScrn->virtualY-1; |
1139 |
NewportUpdateClipping(pNewport); |
1140 |
} |
1141 |
|
1142 |
/******************************************************************************* |
1143 |
|
1144 |
*******************************************************************************/ |
1145 |
static void |
1146 |
NewportPolyPoint(DrawablePtr pDraw, |
1147 |
GCPtr pGC, |
1148 |
int mode, |
1149 |
int npt, |
1150 |
xPoint *ppt) |
1151 |
{ |
1152 |
ScrnInfoPtr pScrn; |
1153 |
int numRects = REGION_NUM_RECTS(pGC->pCompositeClip); |
1154 |
int rect; |
1155 |
XAAInfoRecPtr infoRec; |
1156 |
BoxPtr pbox; |
1157 |
int x, y; |
1158 |
int rop; |
1159 |
|
1160 |
NewportRegsPtr pNewportRegs; |
1161 |
NewportPtr pNewport; |
1162 |
|
1163 |
infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); |
1164 |
pScrn = infoRec->pScrn; |
1165 |
|
1166 |
if (!numRects) |
1167 |
return; |
1168 |
|
1169 |
pNewport = NEWPORTPTR(pScrn); |
1170 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
1171 |
|
1172 |
x = pDraw->x; |
1173 |
y = pDraw->y; |
1174 |
|
1175 |
rop = pGC->alu; |
1176 |
|
1177 |
NewportUpdateWRMASK(pNewport, pNewport->Color2Planes(pGC->planemask)); |
1178 |
if (rop == GXcopy |
1179 |
|| rop == GXclear |
1180 |
|| rop == GXset) |
1181 |
{ |
1182 |
/* if possible try to set up a fast clear which is 4x faster */ |
1183 |
NewportUpdateDRAWMODE1(pNewport, pNewport->setup_drawmode1 | NPORT_DMODE1_FCLR | Rop2LogicOp(GXcopy)); |
1184 |
if (rop == GXclear) |
1185 |
NewportUpdateCOLORVRAM(pNewport, 0); |
1186 |
else |
1187 |
if (rop == GXset) |
1188 |
NewportUpdateCOLORVRAM(pNewport, 0xFFFFFF); |
1189 |
else |
1190 |
NewportUpdateCOLORVRAM(pNewport, pNewport->Color2Planes((unsigned int)(pGC->fgPixel))); |
1191 |
} |
1192 |
else |
1193 |
{ |
1194 |
NewportUpdateDRAWMODE1(pNewport, pNewport->setup_drawmode1 | Rop2LogicOp(rop)); |
1195 |
NewportUpdateCOLORI(pNewport, NewportColor2HOSTRW(pGC->fgPixel)); |
1196 |
} |
1197 |
|
1198 |
pNewport->skipleft = 0; |
1199 |
NewportUpdateClipping(pNewport); |
1200 |
NewportUpdateDRAWMODE0(pNewport, |
1201 |
0 |
1202 |
| NPORT_DMODE0_DRAW |
1203 |
| NPORT_DMODE0_BLOCK |
1204 |
| NPORT_DMODE0_DOSETUP |
1205 |
); |
1206 |
|
1207 |
pbox = REGION_RECTS(pGC->pCompositeClip); |
1208 |
|
1209 |
while (npt--) { |
1210 |
if (mode == CoordModePrevious) |
1211 |
{ |
1212 |
x += ppt->x; |
1213 |
y += ppt->y; |
1214 |
} |
1215 |
else |
1216 |
{ |
1217 |
x = pDraw->x + ppt->x; |
1218 |
y = pDraw->y + ppt->y; |
1219 |
} |
1220 |
for (rect = 0; rect < numRects; rect++) |
1221 |
if (x >= pbox[rect].x1 && x < pbox[rect].x2 |
1222 |
&& y >= pbox[rect].y1 && y < pbox[rect].y2) |
1223 |
{ /* draw point */ |
1224 |
unsigned int xy; |
1225 |
xy = ((x & 0xFFFF) << 16) | (y & 0xFFFF); |
1226 |
NewportWaitGFIFO(pNewport, 2); |
1227 |
pNewportRegs->set.xystarti = xy; |
1228 |
pNewportRegs->go.xyendi = xy; |
1229 |
break; |
1230 |
} |
1231 |
ppt++; |
1232 |
} |
1233 |
} |
1234 |
|
1235 |
/******************************************************************************* |
1236 |
|
1237 |
*******************************************************************************/ |
1238 |
static void |
1239 |
NewportValidatePolyPoint(GCPtr pGC, |
1240 |
unsigned long changes, |
1241 |
DrawablePtr pDraw) |
1242 |
{ |
1243 |
|
1244 |
if (pDraw->type == DRAWABLE_WINDOW) |
1245 |
{ |
1246 |
pGC->ops->PolyPoint = NewportPolyPoint; |
1247 |
} |
1248 |
else |
1249 |
{ |
1250 |
pGC->ops->PolyPoint = XAAFallbackOps.PolyPoint; |
1251 |
} |
1252 |
} |
1253 |
|
1254 |
#if 1 |
1255 |
/******************************************************************************* |
1256 |
|
1257 |
*******************************************************************************/ |
1258 |
static void |
1259 |
NewportPolyArc(DrawablePtr pDraw, |
1260 |
GCPtr pGC, |
1261 |
int narcs, |
1262 |
xArc *parcs) |
1263 |
{ |
1264 |
xArc *arc; |
1265 |
BoxRec box; |
1266 |
int i, x2, y2; |
1267 |
RegionPtr cclip; |
1268 |
|
1269 |
cclip = pGC->pCompositeClip; |
1270 |
|
1271 |
if(!REGION_NUM_RECTS(cclip)) |
1272 |
return; |
1273 |
|
1274 |
for (arc = parcs, i = narcs; --i >= 0; arc++) { |
1275 |
if (miCanZeroArc(arc)) { |
1276 |
box.x1 = arc->x + pDraw->x; |
1277 |
box.y1 = arc->y + pDraw->y; |
1278 |
x2 = box.x1 + (int)arc->width + 1; |
1279 |
box.x2 = x2; |
1280 |
y2 = box.y1 + (int)arc->height + 1; |
1281 |
box.y2 = y2; |
1282 |
if ( (x2 <= MAXSHORT) && (y2 <= MAXSHORT) && |
1283 |
(RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) ) |
1284 |
miZeroPolyArc(pDraw, pGC, 1, arc); |
1285 |
} |
1286 |
else |
1287 |
miPolyArc(pDraw, pGC, 1, arc); |
1288 |
} |
1289 |
} |
1290 |
#endif |
1291 |
|
1292 |
/******************************************************************************* |
1293 |
|
1294 |
*******************************************************************************/ |
1295 |
static void |
1296 |
NewportValidatePolyArc(GCPtr pGC, |
1297 |
unsigned long changes, |
1298 |
DrawablePtr pDraw) |
1299 |
{ |
1300 |
if (pDraw->type == DRAWABLE_WINDOW) |
1301 |
{ |
1302 |
pGC->ops->PolyPoint = NewportPolyPoint; |
1303 |
/*pGC->ops->PolyArc = miPolyArc;*/ |
1304 |
pGC->ops->PolyArc = NewportPolyArc; |
1305 |
|
1306 |
} |
1307 |
else |
1308 |
{ |
1309 |
pGC->ops->PolyPoint = XAAFallbackOps.PolyPoint; |
1310 |
pGC->ops->PolyArc = XAAFallbackOps.PolyArc; |
1311 |
} |
1312 |
} |
1313 |
|
1314 |
|
1315 |
#ifdef RENDER |
1316 |
/******************************************************************************* |
1317 |
|
1318 |
*******************************************************************************/ |
1319 |
static Bool |
1320 |
NewportXAASetupForCPUToScreenAlphaTexture( |
1321 |
ScrnInfoPtr pScrn, |
1322 |
int op, |
1323 |
CARD16 red, |
1324 |
CARD16 green, |
1325 |
CARD16 blue, |
1326 |
CARD16 alpha, |
1327 |
CARD32 maskFormat, |
1328 |
CARD32 dstFormat, |
1329 |
CARD8 *alphaPtr, |
1330 |
int alphaPitch, |
1331 |
int width, |
1332 |
int height, |
1333 |
int flags) |
1334 |
{ |
1335 |
unsigned int col, a; |
1336 |
unsigned char *pSrc; |
1337 |
unsigned int *pDst; |
1338 |
unsigned int w; |
1339 |
NewportRegsPtr pNewportRegs; |
1340 |
NewportPtr pNewport; |
1341 |
pNewport = NEWPORTPTR(pScrn); |
1342 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
1343 |
|
1344 |
if (width * height * sizeof(unsigned int) > pNewport->uTextureSize) |
1345 |
{ |
1346 |
free(pNewport->pTexture); |
1347 |
pNewport->pTexture = xnfalloc(pNewport->uTextureSize = width * height * sizeof(unsigned int)); |
1348 |
} |
1349 |
col = (((unsigned int)red & 0xFF00) << 8) |
1350 |
| ((unsigned int)green & 0xFF00) |
1351 |
| ((unsigned int)blue >> 8); |
1352 |
|
1353 |
pNewport->uTextureWidth = width; |
1354 |
pNewport->uTextureHeight = height; |
1355 |
pNewport->uTextureFlags = flags; |
1356 |
|
1357 |
/* copy texture */ |
1358 |
pDst = pNewport->pTexture; |
1359 |
while (height--) { |
1360 |
pSrc = (unsigned char *)alphaPtr; |
1361 |
|
1362 |
for (w = width; w; w--) |
1363 |
{ |
1364 |
/* premultiply alpha */ |
1365 |
a = *pSrc++; |
1366 |
a *= alpha; |
1367 |
a /= 0xFFFF; |
1368 |
a <<= 24; |
1369 |
*pDst++ = col | a; |
1370 |
} |
1371 |
alphaPtr += alphaPitch; |
1372 |
} |
1373 |
#define SFACTOR (4 << 19) |
1374 |
#define DFACTOR (5 << 22) |
1375 |
NewportUpdateDRAWMODE1(pNewport, pNewport->setup_drawmode1 | Rop2LogicOp(GXcopy) | NPORT_DMODE1_BENAB | SFACTOR | DFACTOR ); |
1376 |
#undef SFACTOR |
1377 |
#undef DFACTOR |
1378 |
NewportUpdateWRMASK(pNewport, pNewport->Color2Planes(0xFFFFFFFF)); |
1379 |
|
1380 |
pNewport->skipleft = 0; |
1381 |
NewportUpdateClipping(pNewport); |
1382 |
NewportUpdateDRAWMODE0(pNewport, |
1383 |
0 |
1384 |
| NPORT_DMODE0_DRAW |
1385 |
| NPORT_DMODE0_BLOCK |
1386 |
| NPORT_DMODE0_CHOST |
1387 |
| NPORT_DMODE0_AHOST |
1388 |
| NPORT_DMODE0_DOSETUP |
1389 |
); |
1390 |
return TRUE; |
1391 |
} |
1392 |
|
1393 |
/******************************************************************************* |
1394 |
|
1395 |
*******************************************************************************/ |
1396 |
static Bool |
1397 |
NewportXAASetupForCPUToScreenTexture( |
1398 |
ScrnInfoPtr pScrn, |
1399 |
int op, |
1400 |
CARD32 srcFormat, |
1401 |
CARD32 dstFormat, |
1402 |
CARD8 *texPtr, |
1403 |
int texPitch, |
1404 |
int width, |
1405 |
int height, |
1406 |
int flags) |
1407 |
{ |
1408 |
unsigned int *pSrc, *pDst; |
1409 |
unsigned int w; |
1410 |
NewportRegsPtr pNewportRegs; |
1411 |
NewportPtr pNewport; |
1412 |
pNewport = NEWPORTPTR(pScrn); |
1413 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
1414 |
|
1415 |
if (width * height * sizeof(unsigned int) > pNewport->uTextureSize) |
1416 |
{ |
1417 |
free(pNewport->pTexture); |
1418 |
pNewport->pTexture = xnfalloc(pNewport->uTextureSize = width * height * sizeof(unsigned int)); |
1419 |
} |
1420 |
|
1421 |
pNewport->uTextureWidth = width; |
1422 |
pNewport->uTextureHeight = height; |
1423 |
pNewport->uTextureFlags = flags; |
1424 |
|
1425 |
/* copy texture */ |
1426 |
pDst = pNewport->pTexture; |
1427 |
|
1428 |
if (srcFormat == PICT_a8r8g8b8) |
1429 |
{ |
1430 |
while (height--) { |
1431 |
pSrc = (unsigned int *)texPtr; |
1432 |
|
1433 |
for (w = width; w; w--) |
1434 |
{ |
1435 |
unsigned int v; |
1436 |
v = *pSrc++; |
1437 |
*pDst++ = (v & 0xFF00FF00) | ((v & 0x00FF0000) >> 16) | ((v & 0x000000FF) << 16); |
1438 |
} |
1439 |
texPtr += texPitch; |
1440 |
} |
1441 |
} |
1442 |
else |
1443 |
if (srcFormat == PICT_a8b8g8r8) |
1444 |
{ |
1445 |
while (height--) { |
1446 |
pSrc = (unsigned int *)texPtr; |
1447 |
|
1448 |
for (w = width; w; w--) |
1449 |
*pDst++ = *pSrc++; |
1450 |
texPtr += texPitch; |
1451 |
} |
1452 |
} |
1453 |
else |
1454 |
{ |
1455 |
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Unknown texture format\n"); |
1456 |
} |
1457 |
|
1458 |
#define SFACTOR (4 << 19) |
1459 |
#define DFACTOR (5 << 22) |
1460 |
NewportUpdateDRAWMODE1(pNewport, pNewport->setup_drawmode1 | Rop2LogicOp(GXcopy) | NPORT_DMODE1_BENAB | SFACTOR | DFACTOR ); |
1461 |
#undef SFACTOR |
1462 |
#undef DFACTOR |
1463 |
NewportUpdateWRMASK(pNewport, pNewport->Color2Planes(0xFFFFFFFF)); |
1464 |
|
1465 |
pNewport->skipleft = 0; |
1466 |
NewportUpdateClipping(pNewport); |
1467 |
NewportUpdateDRAWMODE0(pNewport, |
1468 |
0 |
1469 |
| NPORT_DMODE0_DRAW |
1470 |
| NPORT_DMODE0_BLOCK |
1471 |
| NPORT_DMODE0_CHOST |
1472 |
| NPORT_DMODE0_AHOST |
1473 |
| NPORT_DMODE0_DOSETUP |
1474 |
); |
1475 |
|
1476 |
return TRUE; |
1477 |
} |
1478 |
|
1479 |
/******************************************************************************* |
1480 |
|
1481 |
*******************************************************************************/ |
1482 |
static void |
1483 |
NewportRenderTexture1to1(NewportPtr pNewport, int srcx, int srcy, int w, int h) |
1484 |
{ |
1485 |
unsigned int *p; |
1486 |
unsigned int add, d; |
1487 |
NewportRegsPtr pNewportRegs; |
1488 |
pNewportRegs = pNewport->pNewportRegs; |
1489 |
|
1490 |
p = pNewport->pTexture + srcx + (srcy * pNewport->uTextureWidth); |
1491 |
add = pNewport->uTextureWidth - srcx; |
1492 |
while (h--) |
1493 |
{ |
1494 |
for (d = w; d; d--) |
1495 |
{ |
1496 |
/*NewportWaitGFIFO(pNewport, 1);*/ |
1497 |
/* hopefully we cannot write faster than XL24 can blend */ |
1498 |
pNewportRegs->go.hostrw0 = *p++; |
1499 |
} |
1500 |
p += add; |
1501 |
} |
1502 |
} |
1503 |
|
1504 |
/******************************************************************************* |
1505 |
|
1506 |
*******************************************************************************/ |
1507 |
static void |
1508 |
NewportRenderTextureScale(NewportPtr pNewport, int srcx, int srcy, int w, int h) |
1509 |
{ |
1510 |
int d; |
1511 |
int dx, dy; |
1512 |
int curx, cury; |
1513 |
unsigned int *pLine; |
1514 |
int l, p; |
1515 |
NewportRegsPtr pNewportRegs; |
1516 |
pNewportRegs = pNewport->pNewportRegs; |
1517 |
|
1518 |
dx = ((pNewport->uTextureWidth - srcx) << 16) / w; |
1519 |
dy = ((pNewport->uTextureHeight - srcy) << 16) / h; |
1520 |
|
1521 |
cury = srcy << 16; |
1522 |
while (h--) |
1523 |
{ |
1524 |
l = (cury + 0x7FFF) >> 16; |
1525 |
if (l >= pNewport->uTextureHeight) |
1526 |
l = pNewport->uTextureHeight-1; |
1527 |
pLine = pNewport->pTexture + l * pNewport->uTextureWidth; |
1528 |
|
1529 |
curx = srcx << 16; |
1530 |
for (d = w; d; d--) |
1531 |
{ |
1532 |
p = (curx + 0x7FFF) >> 16; |
1533 |
if (p >= pNewport->uTextureWidth) |
1534 |
p = pNewport->uTextureWidth-1; |
1535 |
pNewportRegs->go.hostrw0 = pLine[p]; |
1536 |
curx += dx; |
1537 |
} |
1538 |
cury += dy; |
1539 |
} |
1540 |
} |
1541 |
|
1542 |
/******************************************************************************* |
1543 |
|
1544 |
*******************************************************************************/ |
1545 |
static void |
1546 |
NewportRenderTextureRepeat(NewportPtr pNewport, int srcx, int srcy, int w, int h) |
1547 |
{ |
1548 |
int d; |
1549 |
unsigned int *pLine; |
1550 |
NewportRegsPtr pNewportRegs; |
1551 |
pNewportRegs = pNewport->pNewportRegs; |
1552 |
|
1553 |
srcx %= pNewport->uTextureWidth; |
1554 |
srcy %= pNewport->uTextureHeight; |
1555 |
|
1556 |
while (h--) |
1557 |
{ |
1558 |
pLine = pNewport->pTexture + pNewport->uTextureWidth * srcy; |
1559 |
for (d = w; d; d--) |
1560 |
{ |
1561 |
pNewportRegs->go.hostrw0 = pLine[srcx]; |
1562 |
srcx++; |
1563 |
if (srcx >= pNewport->uTextureWidth) |
1564 |
srcx = 0; |
1565 |
} |
1566 |
srcy++; |
1567 |
if (srcy >= pNewport->uTextureHeight) |
1568 |
srcy = 0; |
1569 |
} |
1570 |
|
1571 |
} |
1572 |
|
1573 |
|
1574 |
/******************************************************************************* |
1575 |
|
1576 |
*******************************************************************************/ |
1577 |
static void |
1578 |
NewportXAASubsequentCPUToScreenTexture( |
1579 |
ScrnInfoPtr pScrn, |
1580 |
int x, |
1581 |
int y, |
1582 |
int srcx, |
1583 |
int srcy, |
1584 |
int w, |
1585 |
int h) |
1586 |
{ |
1587 |
int ex, ey; |
1588 |
NewportRegsPtr pNewportRegs; |
1589 |
NewportPtr pNewport; |
1590 |
pNewport = NEWPORTPTR(pScrn); |
1591 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
1592 |
|
1593 |
if (w == 0) w = 1; |
1594 |
if (h == 0) h = 1; |
1595 |
ex = x + w - 1; |
1596 |
ey = y + h - 1; |
1597 |
|
1598 |
NewportWaitGFIFO(pNewport, 3); |
1599 |
pNewportRegs->set.xystarti = ((x & 0xFFFF) << 16) | (y & 0xFFFF); |
1600 |
pNewportRegs->set.xyendi = ((ex & 0xFFFF) << 16) | (ey & 0xFFFF); |
1601 |
pNewportRegs->set._setup = 1; |
1602 |
|
1603 |
NewportWaitIdle(pNewport, NEWPORT_GFIFO_ENTRIES); |
1604 |
|
1605 |
if (srcx + w == pNewport->uTextureWidth |
1606 |
&& srcy + h == pNewport->uTextureHeight) |
1607 |
NewportRenderTexture1to1(pNewport, srcx, srcy, w, h); |
1608 |
else |
1609 |
if (pNewport->uTextureFlags & XAA_RENDER_REPEAT) |
1610 |
NewportRenderTextureRepeat(pNewport, srcx, srcy, w, h); |
1611 |
else |
1612 |
NewportRenderTextureScale(pNewport, srcx, srcy, w, h); |
1613 |
|
1614 |
NewportWaitIdle(pNewport, NEWPORT_GFIFO_ENTRIES); |
1615 |
|
1616 |
} |
1617 |
|
1618 |
CARD32 NewportAlphaTextureFormats[2] = {PICT_a8, 0}; |
1619 |
CARD32 NewportTextureFormats[3] = {PICT_a8r8g8b8, PICT_a8b8g8r8, 0}; |
1620 |
/*CARD32 NewportTextureFormats[2] = {PICT_a8r8g8b8, 0};*/ |
1621 |
|
1622 |
#endif |
1623 |
|
1624 |
/******************************************************************************* |
1625 |
|
1626 |
*******************************************************************************/ |
1627 |
Bool |
1628 |
NewportXAAScreenInit(ScreenPtr pScreen) |
1629 |
{ |
1630 |
ScrnInfoPtr pScrn; |
1631 |
NewportPtr pNewport; |
1632 |
NewportRegsPtr pNewportRegs; |
1633 |
XAAInfoRecPtr pXAAInfoRec; |
1634 |
|
1635 |
/* First get a pointer to our private info */ |
1636 |
pScrn = xf86Screens[pScreen->myNum]; |
1637 |
pNewport = NEWPORTPTR(pScrn); |
1638 |
pNewportRegs = NEWPORTREGSPTR(pScrn); |
1639 |
|
1640 |
pXAAInfoRec = |
1641 |
pNewport->pXAAInfoRec = XAACreateInfoRec(); |
1642 |
/* initialize accelerated functions */ |
1643 |
pXAAInfoRec->Sync = NewportXAASync; |
1644 |
|
1645 |
pXAAInfoRec->Flags = 0 |
1646 |
/*| LINEAR_FRAMEBUFFER*/ |
1647 |
; |
1648 |
/* screen to screen copy */ |
1649 |
pXAAInfoRec->ScreenToScreenCopyFlags = 0 |
1650 |
| NO_TRANSPARENCY |
1651 |
; |
1652 |
pXAAInfoRec->SetupForScreenToScreenCopy = NewportXAASetupForScreenToScreenCopy; |
1653 |
pXAAInfoRec->SubsequentScreenToScreenCopy = NewportXAASubsequentScreenToScreenCopy; |
1654 |
|
1655 |
/* solid fills */ |
1656 |
pXAAInfoRec->SolidFillFlags = 0 |
1657 |
; |
1658 |
pXAAInfoRec->SetupForSolidFill = NewportXAASetupForSolidFill; |
1659 |
pXAAInfoRec->SubsequentSolidFillRect = NewportXAASubsequentSolidFillRect; |
1660 |
|
1661 |
/* solid lines */ |
1662 |
pXAAInfoRec->SolidLineFlags = 0 |
1663 |
; |
1664 |
pXAAInfoRec->SetupForSolidLine = NewportXAASetupForSolidLine; |
1665 |
pXAAInfoRec->SubsequentSolidTwoPointLine = NewportXAASubsequentSolidTwoPointLine; |
1666 |
|
1667 |
/* dashed lines */ |
1668 |
pXAAInfoRec->DashedLineFlags = 0 |
1669 |
| LINE_PATTERN_MSBFIRST_MSBJUSTIFIED |
1670 |
; |
1671 |
pXAAInfoRec->DashPatternMaxLength = 2048; |
1672 |
pXAAInfoRec->SetupForDashedLine = NewportXAASetupForDashedLine; |
1673 |
pXAAInfoRec->SubsequentDashedTwoPointLine = NewportXAASubsequentDashedTwoPointLine; |
1674 |
|
1675 |
/* cpu to screen expand color fill */ |
1676 |
pXAAInfoRec->CPUToScreenColorExpandFillFlags = 0 |
1677 |
| BIT_ORDER_IN_BYTE_LSBFIRST |
1678 |
| SCANLINE_PAD_DWORD |
1679 |
| CPU_TRANSFER_PAD_DWORD |
1680 |
| CPU_TRANSFER_BASE_FIXED |
1681 |
| LEFT_EDGE_CLIPPING |
1682 |
| LEFT_EDGE_CLIPPING_NEGATIVE_X |
1683 |
/*| SYNC_AFTER_COLOR_EXPAND*/ |
1684 |
; |
1685 |
|
1686 |
pXAAInfoRec->SetupForCPUToScreenColorExpandFill = NewportXAASetupForCPUToScreenColorExpandFill; |
1687 |
pXAAInfoRec->SubsequentCPUToScreenColorExpandFill = NewportXAASubsequentCPUToScreenColorExpandFill; |
1688 |
pXAAInfoRec->ColorExpandRange = 4; |
1689 |
pXAAInfoRec->ColorExpandBase = (unsigned char *)&(pNewportRegs->go.zpattern); |
1690 |
|
1691 |
|
1692 |
/* mono 8x8 pattern fill */ |
1693 |
pXAAInfoRec->Mono8x8PatternFillFlags = 0 |
1694 |
| BIT_ORDER_IN_BYTE_LSBFIRST |
1695 |
| HARDWARE_PATTERN_PROGRAMMED_BITS |
1696 |
#ifdef NEWPORT_PREROTATE |
1697 |
| HARDWARE_PATTERN_PROGRAMMED_ORIGIN |
1698 |
#endif |
1699 |
; |
1700 |
|
1701 |
pXAAInfoRec->SetupForMono8x8PatternFill = NewportXAASetupForMono8x8PatternFill; |
1702 |
pXAAInfoRec->SubsequentMono8x8PatternFillRect = NewportXAASubsequentMono8x8PatternFillRect; |
1703 |
|
1704 |
/* Image write */ |
1705 |
pXAAInfoRec->ImageWriteFlags = 0 |
1706 |
| NO_TRANSPARENCY |
1707 |
| CPU_TRANSFER_BASE_FIXED |
1708 |
| CPU_TRANSFER_PAD_DWORD |
1709 |
| SCANLINE_PAD_DWORD |
1710 |
| LEFT_EDGE_CLIPPING |
1711 |
| LEFT_EDGE_CLIPPING_NEGATIVE_X |
1712 |
/*| SYNC_AFTER_IMAGE_WRITE*/ |
1713 |
; |
1714 |
pXAAInfoRec->SetupForImageWrite = NewportXAASetupForImageWrite; |
1715 |
pXAAInfoRec->SubsequentImageWriteRect = NewportXAASubsequentImageWriteRect; |
1716 |
pXAAInfoRec->ImageWriteRange = 4; |
1717 |
pXAAInfoRec->ImageWriteBase = (unsigned char *)&(pNewportRegs->go.hostrw0); |
1718 |
|
1719 |
/* read pixmap */ |
1720 |
pXAAInfoRec->ReadPixmapFlags = 0 |
1721 |
| CPU_TRANSFER_PAD_DWORD |
1722 |
; |
1723 |
pXAAInfoRec->ReadPixmap = NewportXAAReadPixmap; |
1724 |
|
1725 |
/* clipping */ |
1726 |
pXAAInfoRec->ClippingFlags = 0 |
1727 |
/*| HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND*/ |
1728 |
| HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY |
1729 |
| HARDWARE_CLIP_MONO_8x8_FILL |
1730 |
/*| HARDWARE_CLIP_COLOR_8x8_FILL*/ |
1731 |
| HARDWARE_CLIP_SOLID_FILL |
1732 |
| HARDWARE_CLIP_DASHED_LINE |
1733 |
| HARDWARE_CLIP_SOLID_LINE |
1734 |
; |
1735 |
pXAAInfoRec->SetClippingRectangle = NewportXAASetClippingRectangle; |
1736 |
pXAAInfoRec->DisableClipping = NewportXAADisableClipping; |
1737 |
|
1738 |
/* make it draw points using our function */ |
1739 |
pXAAInfoRec->ValidatePolyPoint = NewportValidatePolyPoint; |
1740 |
pXAAInfoRec->PolyPointMask = GCFunction | GCPlaneMask; |
1741 |
/*pXAAInfoRec->PolyPointMask = 0xFFFFFFFF;*/ |
1742 |
|
1743 |
pXAAInfoRec->ValidatePolyArc = NewportValidatePolyArc; |
1744 |
pXAAInfoRec->PolyArcMask = GCFunction | GCLineWidth; |
1745 |
#ifdef RENDER |
1746 |
if (pScrn->bitsPerPixel > 8) { |
1747 |
pXAAInfoRec->CPUToScreenTextureFlags = 0 |
1748 |
; |
1749 |
pXAAInfoRec->CPUToScreenTextureFormats = NewportTextureFormats; |
1750 |
pXAAInfoRec->CPUToScreenTextureDstFormats = NewportTextureFormats; |
1751 |
pXAAInfoRec->SetupForCPUToScreenTexture2 = NewportXAASetupForCPUToScreenTexture; |
1752 |
pXAAInfoRec->SubsequentCPUToScreenTexture = NewportXAASubsequentCPUToScreenTexture; |
1753 |
|
1754 |
pXAAInfoRec->CPUToScreenAlphaTextureFlags = 0 |
1755 |
; |
1756 |
pXAAInfoRec->CPUToScreenAlphaTextureFormats = NewportAlphaTextureFormats; |
1757 |
pXAAInfoRec->CPUToScreenAlphaTextureDstFormats = NewportAlphaTextureFormats; |
1758 |
pXAAInfoRec->SetupForCPUToScreenAlphaTexture2 = NewportXAASetupForCPUToScreenAlphaTexture; |
1759 |
pXAAInfoRec->SubsequentCPUToScreenAlphaTexture = NewportXAASubsequentCPUToScreenTexture; /* this is the same for both */ |
1760 |
pNewport->pTexture = (unsigned int *)xnfalloc(pNewport->uTextureSize = 16*16*sizeof(unsigned int)); |
1761 |
} |
1762 |
#endif |
1763 |
|
1764 |
pNewport->Color2Planes = NewportColor2Planes24; |
1765 |
if (pScrn->bitsPerPixel == 8) |
1766 |
{ |
1767 |
pNewport->Color2Planes = NewportColor2Planes8; |
1768 |
} |
1769 |
|
1770 |
if (!XAAInit(pScreen, pXAAInfoRec)) |
1771 |
{ |
1772 |
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "XAAInit Failed!\n"); |
1773 |
return FALSE; |
1774 |
} |
1775 |
|
1776 |
pNewport->fifoleft = 0; |
1777 |
/* init bunch of registers */ |
1778 |
|
1779 |
pNewport->shadow_drawmode0 = pNewportRegs->set.drawmode0; |
1780 |
pNewport->shadow_colori = pNewportRegs->set.colori; |
1781 |
pNewport->shadow_smask0x = pNewportRegs->set.smask0x; |
1782 |
pNewport->shadow_smask0y = pNewportRegs->set.smask0y; |
1783 |
|
1784 |
pNewport->shadow_drawmode1 = pNewport->drawmode1; |
1785 |
pNewportRegs->set.drawmode1 = pNewport->drawmode1; |
1786 |
pNewport->setup_drawmode1 = pNewport->drawmode1 & ~NPORT_DMODE1_LOMASK; |
1787 |
|
1788 |
pNewport->shadow_xymove = 0; |
1789 |
pNewportRegs->set.xymove = 0; |
1790 |
|
1791 |
pNewport->shadow_wrmask = 0xFFFFFF; |
1792 |
pNewportRegs->set.wrmask = 0xFFFFFF; |
1793 |
|
1794 |
pNewport->shadow_colorvram = 0; |
1795 |
pNewportRegs->set.colorvram = 0; |
1796 |
|
1797 |
pNewport->shadow_colorback = 0; |
1798 |
pNewportRegs->set.colorback = 0; |
1799 |
|
1800 |
pNewport->clipsx = 0; |
1801 |
pNewport->clipex = pScrn->virtualX-1; |
1802 |
pNewport->clipsy = 0; |
1803 |
pNewport->clipey = pScrn->virtualY-1; |
1804 |
pNewport->skipleft = 0; |
1805 |
|
1806 |
BARF1("CLIPMODE %08X\n", pNewportRegs->cset.clipmode); |
1807 |
BARF1("XYWIN %08X\n", pNewportRegs->cset.xywin); |
1808 |
BARF1("CONFIG %08X\n", pNewportRegs->cset.config); |
1809 |
BARF1("SMASK0X %08X\n", pNewportRegs->set.smask0x); |
1810 |
BARF1("SMASK0Y %08X\n", pNewportRegs->set.smask0y); |
1811 |
|
1812 |
/* |
1813 |
set GIO bus timeout to highest possible value 4.32us |
1814 |
this will allow for longer bus stalls without bus error |
1815 |
*/ |
1816 |
{ |
1817 |
unsigned int conf; |
1818 |
conf = pNewportRegs->cset.config; |
1819 |
conf &= ~NPORT_CFG_TOMSK; |
1820 |
conf |= NPORT_CFG_TOMSK; |
1821 |
|
1822 |
conf &= ~NPORT_CFG_GDMSK; |
1823 |
conf |= NPORT_CFG_GDMSK; |
1824 |
|
1825 |
pNewportRegs->cset.config = conf; |
1826 |
} |
1827 |
|
1828 |
BARF1("CONFIG %08X\n", pNewportRegs->cset.config); |
1829 |
|
1830 |
pNewport->shadow_clipmode = pNewportRegs->cset.clipmode; |
1831 |
pNewportRegs->cset.clipmode |= 1; /* enable clipping mask 0 */ |
1832 |
NewportUpdateClipping(pNewport); |
1833 |
|
1834 |
return TRUE; |
1835 |
} |
1836 |
|
1837 |
#endif |
1838 |
/* NEWPORT_ACCEL */ |