2 * Copyright © 1999 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Keith Packard not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Keith Packard makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
24 #include <kdrive-config.h>
31 #include "scrnintstr.h"
32 #include "pixmapstr.h"
33 #include "regionstr.h"
35 #include "dixfontstr.h"
39 #include "picturestr.h"
42 CARD8 smiBltRop
[16] = {
43 /* GXclear */ 0x00, /* 0 */
44 /* GXand */ 0x88, /* src AND dst */
45 /* GXandReverse */ 0x44, /* src AND NOT dst */
46 /* GXcopy */ 0xcc, /* src */
47 /* GXandInverted*/ 0x22, /* NOT src AND dst */
48 /* GXnoop */ 0xaa, /* dst */
49 /* GXxor */ 0x66, /* src XOR dst */
50 /* GXor */ 0xee, /* src OR dst */
51 /* GXnor */ 0x11, /* NOT src AND NOT dst */
52 /* GXequiv */ 0x99, /* NOT src XOR dst */
53 /* GXinvert */ 0x55, /* NOT dst */
54 /* GXorReverse */ 0xdd, /* src OR NOT dst */
55 /* GXcopyInverted*/ 0x33, /* NOT src */
56 /* GXorInverted */ 0xbb, /* NOT src OR dst */
57 /* GXnand */ 0x77, /* NOT src OR NOT dst */
58 /* GXset */ 0xff, /* 1 */
61 CARD8 smiSolidRop
[16] = {
62 /* GXclear */ 0x00, /* 0 */
63 /* GXand */ 0xa0, /* src AND dst */
64 /* GXandReverse */ 0x50, /* src AND NOT dst */
65 /* GXcopy */ 0xf0, /* src */
66 /* GXandInverted*/ 0x0a, /* NOT src AND dst */
67 /* GXnoop */ 0xaa, /* dst */
68 /* GXxor */ 0x5a, /* src XOR dst */
69 /* GXor */ 0xfa, /* src OR dst */
70 /* GXnor */ 0x05, /* NOT src AND NOT dst */
71 /* GXequiv */ 0xa5, /* NOT src XOR dst */
72 /* GXinvert */ 0x55, /* NOT dst */
73 /* GXorReverse */ 0xf5, /* src OR NOT dst */
74 /* GXcopyInverted*/ 0x0f, /* NOT src */
75 /* GXorInverted */ 0xaf, /* NOT src OR dst */
76 /* GXnand */ 0x5f, /* NOT src OR NOT dst */
77 /* GXset */ 0xff, /* 1 */
81 #define GET_STATUS(smic) smiGetIndex (smic, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x16)
83 #define ENGINE_IDLE_EMPTY(smic) ((GET_STATUS(smic) & 0x18) == 0x10)
84 #define FIFO_EMPTY(smic) ((GET_STATUS(smic) & 0x10) == 0x10)
89 smiWaitAvail(SmiCardInfo
*smic
, int n
)
93 while (!FIFO_EMPTY (smic
))
95 smic
->avail
= MAX_FIFO
;
101 smiWaitIdle (SmiCardInfo
*smic
)
103 while (!ENGINE_IDLE_EMPTY (smic
))
105 smic
->avail
= MAX_FIFO
;
108 static SmiCardInfo
*smic
;
109 static SmiScreenInfo
*smis
;
111 static CARD32 accel_cmd
;
114 smiSetup (ScreenPtr pScreen
, int wait
)
116 KdScreenPriv(pScreen
);
118 smis
= getSmiScreenInfo (pScreenPriv
);
119 smic
= getSmiCardInfo(pScreenPriv
);
125 /* enable DPR/VPR registers */
126 smiSetIndex (smic
, VGA_SEQ_INDEX
, VGA_SEQ_DATA
, 0x21,
127 smis
->dpr_vpr_enable
);
129 smiWaitAvail (smic
, wait
+ 9);
130 dpr
->src_stride
= (smis
->stride
<< 16) | smis
->stride
;
131 dpr
->data_format
= smis
->data_format
;
132 dpr
->mask1
= 0xffffffff;
133 dpr
->mask2
= 0xffffffff;
134 dpr
->dst_stride
= (smis
->stride
<< 16) | smis
->stride
;
135 dpr
->unknown_40
= 0x0;
136 dpr
->unknown_44
= 0x0;
137 dpr
->scissors_ul
= 0x0;
138 dpr
->scissors_lr
= SMI_XY(4095,4095);
144 smiWaitMarker (ScreenPtr pScreen
, int marker
)
146 KdScreenPriv(pScreen
);
147 smic
= getSmiCardInfo(pScreenPriv
);
153 smiPrepareSolid (PixmapPtr pPixmap
,
158 if (~pm
& FbFullMask(pPixmap
->drawable
.depth
))
161 if (!smiSetup (pPixmap
->drawable
.pScreen
, 3))
164 accel_cmd
= smiSolidRop
[alu
] | SMI_BITBLT
| SMI_START_ENGINE
;
166 dpr
->mask3
= 0xffffffff;
167 dpr
->mask4
= 0xffffffff;
172 smiSolid (int x1
, int y1
, int x2
, int y2
)
174 smiWaitAvail(smic
,3);
175 dpr
->dst_xy
= SMI_XY(x1
,y1
);
176 dpr
->dst_wh
= SMI_XY(x2
-x1
,y2
-y1
);
177 dpr
->accel_cmd
= accel_cmd
;
189 smiPrepareCopy (PixmapPtr pSrcPixmap
,
190 PixmapPtr pDstPixmap
,
196 if (~pm
& FbFullMask(pSrcPixmap
->drawable
.depth
))
199 if (!smiSetup (pSrcPixmap
->drawable
.pScreen
, 0))
202 accel_cmd
= smiBltRop
[alu
] | SMI_BITBLT
| SMI_START_ENGINE
;
206 if (dy
< 0 || (dy
== 0 && dx
< 0))
207 accel_cmd
|= SMI_RIGHT_TO_LEFT
;
219 if (accel_cmd
& SMI_RIGHT_TO_LEFT
)
226 smiWaitAvail (smic
, 4);
227 dpr
->src_xy
= SMI_XY (srcX
, srcY
);
228 dpr
->dst_xy
= SMI_XY (dstX
, dstY
);
229 dpr
->dst_wh
= SMI_XY (w
, h
);
230 dpr
->accel_cmd
= accel_cmd
;
240 smiDrawInit (ScreenPtr pScreen
)
242 KdScreenPriv(pScreen
);
243 smiCardInfo (pScreenPriv
);
246 if (pScreenPriv
->screen
->fb
[0].depth
== 4)
258 memset(&smis
->kaa
, 0, sizeof(KaaScreenInfoRec
));
259 smis
->kaa
.PrepareSolid
= smiPrepareSolid
;
260 smis
->kaa
.Solid
= smiSolid
;
261 smis
->kaa
.DoneSolid
= smiDoneSolid
;
262 smis
->kaa
.PrepareCopy
= smiPrepareCopy
;
263 smis
->kaa
.Copy
= smiCopy
;
264 smis
->kaa
.DoneCopy
= smiDoneCopy
;
265 smis
->kaa
.waitMarker
= smiWaitMarker
;
267 if (!kaaDrawInit (pScreen
, &smis
->kaa
))
278 smiDrawEnable (ScreenPtr pScreen
)
280 KdScreenPriv(pScreen
);
282 static const int xyAddress
[] = { 320, 400, 512, 640, 800, 1024, 1280, 1600, 2048 };
285 smis
= getSmiScreenInfo (pScreenPriv
);
286 smic
= getSmiCardInfo(pScreenPriv
);
289 smis
->stride
= pScreenPriv
->screen
->fb
[0].byteStride
;
290 smis
->dpr_vpr_enable
= smiGetIndex (smic
, VGA_SEQ_INDEX
,
291 VGA_SEQ_DATA
, 0x21) & ~0x03;
293 switch (pScreenPriv
->screen
->fb
[0].depth
) {
295 smis
->data_format
= 0x00000000;
299 smis
->data_format
= 0x00100000;
303 smis
->data_format
= 0x00300000;
306 smis
->data_format
= 0x00200000;
310 for (i
= 0; i
< sizeof(xyAddress
) / sizeof(xyAddress
[0]); i
++)
312 if (xyAddress
[i
] == pScreenPriv
->screen
->fb
[0].pixelStride
)
314 smis
->data_format
|= i
<< 16;
319 smiSetup (pScreen
, 0);
320 kaaMarkSync (pScreen
);
325 smiDrawDisable (ScreenPtr pScreen
)
336 smiDrawFini (ScreenPtr pScreen
)