2
* Id: tridentdraw.c,v 1.1 1999/11/02 03:54:47 keithp Exp $
4
* Copyright ļæ½ 1999 Keith Packard
6
* Permission to use, copy, modify, distribute, and sell this software and its
7
* documentation for any purpose is hereby granted without fee, provided that
8
* the above copyright notice appear in all copies and that both that
9
* copyright notice and this permission notice appear in supporting
10
* documentation, and that the name of Keith Packard not be used in
11
* advertising or publicity pertaining to distribution of the software without
12
* specific, written prior permission. Keith Packard makes no
13
* representations about the suitability of this software for any purpose. It
14
* is provided "as is" without express or implied warranty.
16
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18
* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
* PERFORMANCE OF THIS SOFTWARE.
24
/* $RCSId: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c,v 1.10 2001/06/03 18:48:19 keithp Exp $ */
27
#include <kdrive-config.h>
33
#include "scrnintstr.h"
34
#include "pixmapstr.h"
35
#include "regionstr.h"
37
#include "dixfontstr.h"
43
CARD8 chipsBltRop[16] = {
44
/* GXclear */ 0x00, /* 0 */
45
/* GXand */ 0x88, /* src AND dst */
46
/* GXandReverse */ 0x44, /* src AND NOT dst */
47
/* GXcopy */ 0xcc, /* src */
48
/* GXandInverted*/ 0x22, /* NOT src AND dst */
49
/* GXnoop */ 0xaa, /* dst */
50
/* GXxor */ 0x66, /* src XOR dst */
51
/* GXor */ 0xee, /* src OR dst */
52
/* GXnor */ 0x11, /* NOT src AND NOT dst */
53
/* GXequiv */ 0x99, /* NOT src XOR dst */
54
/* GXinvert */ 0x55, /* NOT dst */
55
/* GXorReverse */ 0xdd, /* src OR NOT dst */
56
/* GXcopyInverted*/ 0x33, /* NOT src */
57
/* GXorInverted */ 0xbb, /* NOT src OR dst */
58
/* GXnand */ 0x77, /* NOT src OR NOT dst */
59
/* GXset */ 0xff, /* 1 */
62
CARD8 chipsSolidRop[16] = {
63
/* GXclear */ 0x00, /* 0 */
64
/* GXand */ 0xa0, /* src AND dst */
65
/* GXandReverse */ 0x50, /* src AND NOT dst */
66
/* GXcopy */ 0xf0, /* src */
67
/* GXandInverted*/ 0x0a, /* NOT src AND dst */
68
/* GXnoop */ 0xaa, /* dst */
69
/* GXxor */ 0x5a, /* src XOR dst */
70
/* GXor */ 0xfa, /* src OR dst */
71
/* GXnor */ 0x05, /* NOT src AND NOT dst */
72
/* GXequiv */ 0xa5, /* NOT src XOR dst */
73
/* GXinvert */ 0x55, /* NOT dst */
74
/* GXorReverse */ 0xf5, /* src OR NOT dst */
75
/* GXcopyInverted*/ 0x0f, /* NOT src */
76
/* GXorInverted */ 0xaf, /* NOT src OR dst */
77
/* GXnand */ 0x5f, /* NOT src OR NOT dst */
78
/* GXset */ 0xff, /* 1 */
81
/* Definitions for the Chips and Technology BitBLT engine communication. */
82
/* These are done using Memory Mapped IO, of the registers */
83
/* BitBLT modes for register 93D0. */
86
#define ctPATCOPY 0xF0
87
#define ctLEFT2RIGHT 0x000
88
#define ctRIGHT2LEFT 0x100
89
#define ctTOP2BOTTOM 0x000
90
#define ctBOTTOM2TOP 0x200
91
#define ctSRCSYSTEM 0x400
92
#define ctDSTSYSTEM 0x800
93
#define ctSRCMONO 0x1000
94
#define ctBGTRANSPARENT 0x22000
95
#define ctCOLORTRANSENABLE 0x4000
96
#define ctCOLORTRANSDISABLE 0x0
97
#define ctCOLORTRANSDST 0x8000
98
#define ctCOLORTRANSROP 0x0
99
#define ctCOLORTRANSEQUAL 0x10000L
100
#define ctCOLORTRANSNEQUAL 0x0
101
#define ctPATMONO 0x40000L
102
#define ctPATSOLID 0x80000L
103
#define ctPATSTART0 0x000000L
104
#define ctPATSTART1 0x100000L
105
#define ctPATSTART2 0x200000L
106
#define ctPATSTART3 0x300000L
107
#define ctPATSTART4 0x400000L
108
#define ctPATSTART5 0x500000L
109
#define ctPATSTART6 0x600000L
110
#define ctPATSTART7 0x700000L
111
#define ctSRCFG 0x000000L /* Where is this for the 65550?? */
113
#define ctPATCOPY 0xF0
114
#define ctTOP2BOTTOM 0x100
115
#define ctBOTTOM2TOP 0x000
116
#define ctLEFT2RIGHT 0x200
117
#define ctRIGHT2LEFT 0x000
118
#define ctSRCFG 0x400
119
#define ctSRCMONO 0x800
120
#define ctPATMONO 0x1000
121
#define ctBGTRANSPARENT 0x2000
122
#define ctSRCSYSTEM 0x4000
123
#define ctPATSOLID 0x80000L
124
#define ctPATSTART0 0x00000L
125
#define ctPATSTART1 0x10000L
126
#define ctPATSTART2 0x20000L
127
#define ctPATSTART3 0x30000L
128
#define ctPATSTART4 0x40000L
129
#define ctPATSTART5 0x50000L
130
#define ctPATSTART6 0x60000L
131
#define ctPATSTART7 0x70000L
134
#define chipsFillPix(bpp,pixel) {\
137
pixel = pixel & 0xff; \
139
else if (bpp == 16) \
141
pixel = pixel & 0xffff; \
146
static CARD32 byteStride;
147
static CARD32 bytesPerPixel;
148
static CARD32 pixelStride;
151
chipsSet (ScreenPtr pScreen)
153
KdScreenPriv(pScreen);
154
chipsScreenInfo(pScreenPriv);
156
mmio = chipss->mmio_base;
157
byteStride = pScreenPriv->screen->fb[0].byteStride;
158
bytesPerPixel = pScreenPriv->screen->fb[0].bitsPerPixel >> 3;
159
pixelStride = pScreenPriv->screen->fb[0].pixelStride;
163
#define CHIPS_BR0 0x00 /* offset */
164
#define CHIPS_BR1 0x04 /* bg */
165
#define CHIPS_BR2 0x08 /* fg */
166
#define CHIPS_BR3 0x0c /* monochrome */
167
#define CHIPS_BR4 0x10 /* bitblt */
168
#define CHIPS_BR5 0x14 /* pattern addr */
169
#define CHIPS_BR6 0x18 /* source addr */
170
#define CHIPS_BR7 0x1c /* dst addr */
171
#define CHIPS_BR8 0x20 /* dst w/h */
173
#define CHIPS_DR0 0x83d0
174
#define CHIPS_DR1 0x87d0
175
#define CHIPS_DR2 0x8bd0
176
#define CHIPS_DR3 0x8fd0
177
#define CHIPS_DR4 0x93d0
178
#define CHIPS_DR5 0x97d0
179
#define CHIPS_DR6 0x9bd0
180
#define CHIPS_DR7 0x9fd0
186
chipsPitch (int src, int dst)
190
p = ((dst & 0xffff) << 16) | (src & 0xffff);
191
DBG(ErrorF ("\tpitch 0x%x\n", p));
193
*(VOL32 *) (mmio + CHIPS_BR0) = p;
195
*(VOL32 *) (mmio + CHIPS_DR0) = p;
202
DBG(ErrorF ("\tbg 0x%x\n", bg));
204
*(VOL32 *) (mmio + CHIPS_BR1) = bg & 0xffff;
206
*(VOL32 *) (mmio + CHIPS_DR2) = bg;
213
DBG(ErrorF ("\tfg 0x%x\n", fg));
215
*(VOL32 *) (mmio + CHIPS_BR2) = fg;
217
*(VOL32 *) (mmio + CHIPS_DR3) = fg;
224
DBG(ErrorF ("\top 0x%x\n", op));
226
*(VOL32 *) (mmio + CHIPS_BR4) = op;
228
*(VOL32 *) (mmio + CHIPS_DR4) = op;
233
chipsRopSolid (int rop)
237
op = chipsSolidRop[rop] | ctTOP2BOTTOM | ctLEFT2RIGHT | ctPATSOLID | ctPATMONO;
244
DBG(ErrorF ("\tsrc 0x%x\n", addr));
246
*(VOL32 *) (mmio + CHIPS_BR6) = addr;
248
*(VOL32 *) (mmio + CHIPS_DR5) = addr;
255
DBG(ErrorF ("\tdst 0x%x\n", addr));
257
*(VOL32 *) (mmio + CHIPS_BR7) = addr;
259
*(VOL32 *) (mmio + CHIPS_DR6) = addr;
264
chipsWidthHeightGo (int w, int h)
266
DBG(ErrorF ("\twidth height %d/%d\n", w, h));
268
*(VOL32 *) (mmio + CHIPS_BR8) = ((h & 0xffff) << 16) | (w & 0xffff);
270
*(VOL32 *) (mmio + CHIPS_DR7) = ((h & 0xffff) << 16) | (w & 0xffff);
280
VOL32 *br4 = (VOL32 *) (mmio + CHIPS_BR4);
282
DBG(ErrorF ("\tBR4 0x%x 0x%x\n", mmio + CHIPS_BR4, *br4));
283
DBG(ErrorF ("\tXR20 0x%x\n", chipsReadXR (0, 0x20)));
286
if ((*br4 & 0x80000000) == 0)
288
tmp = chipsReadXR (0, 0x20);
291
if (++timeout > 1000000)
293
ErrorF ("timeout\n");
294
tmp = chipsReadXR (0, 0x20);
295
chipsWriteXR (0, 0x20, tmp | 2);
297
chipsWriteXR (0, 0x20, tmp);
302
while (*(VOL32 *) (mmio + CHIPS_DR4) & 0x00100000)
308
chipsWaitMarker (ScreenPtr pScreen, int marker)
315
chipsPrepareSolid (PixmapPtr pPixmap,
322
DBG(ErrorF ("PrepareSolid %d 0x%x\n", alu, fg));
323
depthMask = FbFullMask(pPixmap->drawable.depth);
324
if ((pm & depthMask) != depthMask)
328
chipsSet (pPixmap->drawable.pScreen);
330
chipsFillPix(pPixmap->drawable.bitsPerPixel,fg);
334
chipsPitch (byteStride, byteStride);
340
chipsSolid (int x1, int y1, int x2, int y2)
345
DBG(ErrorF (" Solid %dx%d %dx%d\n", x1, y1, x2, y2));
346
dst = y1 * byteStride + x1 * bytesPerPixel;
347
w = (x2 - x1) * bytesPerPixel;
351
chipsWidthHeightGo (w, h);
355
chipsDoneSolid (void)
359
static CARD32 copyOp;
362
chipsPrepareCopy (PixmapPtr pSrcPixmap,
363
PixmapPtr pDstPixmap,
371
DBG(ErrorF ("PrepareSolid %d 0x%x\n", alu, fg));
372
depthMask = FbFullMask(pDstPixmap->drawable.depth);
373
if ((pm & depthMask) != depthMask)
377
copyOp = chipsBltRop[alu];
379
copyOp |= ctTOP2BOTTOM;
381
copyOp |= ctBOTTOM2TOP;
383
copyOp |= ctLEFT2RIGHT;
385
copyOp |= ctRIGHT2LEFT;
386
chipsSet (pDstPixmap->drawable.pScreen);
389
chipsPitch (byteStride, byteStride);
403
if ((copyOp & (ctTOP2BOTTOM|ctBOTTOM2TOP)) == ctBOTTOM2TOP)
405
src = (srcY + h - 1) * byteStride;
406
dst = (dstY + h - 1) * byteStride;
410
src = srcY * byteStride;
411
dst = dstY * byteStride;
413
if ((copyOp & (ctLEFT2RIGHT|ctRIGHT2LEFT)) == ctRIGHT2LEFT)
415
src = src + (srcX + w) * bytesPerPixel - 1;
416
dst = dst + (dstX + w) * bytesPerPixel - 1;
420
src = src + srcX * bytesPerPixel;
421
dst = dst + dstX * bytesPerPixel;
426
chipsWidthHeightGo (w * bytesPerPixel, h);
435
chipsDrawInit (ScreenPtr pScreen)
437
KdScreenPriv(pScreen);
438
chipsScreenInfo(pScreenPriv);
440
switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
448
memset(&chipss->kaa, 0, sizeof(KaaScreenInfoRec));
449
chipss->kaa.waitMarker = chipsWaitMarker;
450
chipss->kaa.PrepareSolid = chipsPrepareSolid;
451
chipss->kaa.Solid = chipsSolid;
452
chipss->kaa.DoneSolid = chipsDoneSolid;
453
chipss->kaa.PrepareCopy = chipsPrepareCopy;
454
chipss->kaa.Copy = chipsCopy;
455
chipss->kaa.DoneCopy = chipsDoneCopy;
457
if (!kaaDrawInit (pScreen, &chipss->kaa))
464
chipsDrawEnable (ScreenPtr pScreen)
466
KdScreenPriv(pScreen);
467
chipsScreenInfo(pScreenPriv);
470
switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
480
chipsWriteXR (chipss, 0x20, mode);
482
kaaMarkSync (pScreen);
486
chipsDrawDisable (ScreenPtr pScreen)
491
chipsDrawFini (ScreenPtr pScreen)