2
* Id: sisdraw.h,v 1.1 1999/11/02 08:17:24 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
/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sisdraw.h,v 1.2 2000/02/23 20:30:08 dawes Exp $ */
29
#define SetupSis(s) KdScreenPriv(s); \
30
sisCardInfo(pScreenPriv); \
31
SisPtr sis = sisc->sis
33
#define SIS_CMD_BITBLT (0)
34
#define SIS_CMD_COLOR_EXPAND (1)
35
#define SIS_CMD_ENH_COLOR_EXPAND (2)
36
#define SIS_CMD_MULTI_SCANLINE (3)
37
#define SIS_CMD_LINE (4)
38
#define SIS_CMD_TRAPEZOID (5)
39
#define SIS_CMD_TRANSPARENT_BITBLT (6)
41
#define SIS_CMD_SRC_SCREEN (0 << 4)
42
#define SIS_CMD_SRC_CPU (1 << 4)
44
#define SIS_CMD_PAT_FG (0 << 6)
45
#define SIS_CMD_PAT_PATTERN (1 << 6)
46
#define SIS_CMD_PAT_MONO (2 << 6)
50
#define SIS_CMD_DEC_X (0 << 16)
51
#define SIS_CMD_INC_X (1 << 16)
53
#define SIS_CMD_DEC_Y (0 << 17)
54
#define SIS_CMD_INC_Y (1 << 17)
56
#define SIS_CMD_RECT_CLIP_DISABLE (0 << 18)
57
#define SIS_CMD_RECT_CLIP_ENABLE (1 << 18)
59
#define SIS_CMD_OPAQUE (0 << 20)
60
#define SIS_CMD_TRANSPARENT (1 << 20)
62
#define SIS_CMD_RECT_CLIP_MERGE (0 << 26)
63
#define SIS_CMD_RECT_CLIP_DONT_MERGE (1 << 26)
65
#define SIS_STAT_2D_IDLE (1 << 31)
66
#define SIS_STAT_3D_IDLE (1 << 30)
67
#define SIS_STAT_EMPTY (1 << 29)
68
#define SIS_STAT_CPU_BITBLT (0xf << 24)
69
#define SIS_STAT_ENH_COLOR_EXPAND (1 << 23)
70
#define SIS_STAT_AVAIL (0x1fff)
72
extern CARD8 sisPatRop[16];
73
extern CARD8 sisBltRop[16];
75
#define _sisSetSolidRect(sis,pix,alu,cmd) {\
76
(sis)->u.general.pattern_fg = (pix); \
77
(cmd) = (SIS_CMD_BITBLT | \
78
SIS_CMD_SRC_SCREEN | \
80
(sisPatRop[alu] << 8) | \
83
SIS_CMD_RECT_CLIP_DISABLE | \
85
SIS_CMD_RECT_CLIP_DONT_MERGE); \
88
#define _sisClip(sis,x1,y1,x2,y2) { \
89
(sis)->u.general.clip_left = (x1); \
90
(sis)->u.general.clip_top = (y1); \
91
(sis)->u.general.clip_right = (x2); \
92
(sis)->u.general.clip_bottom = (y2); \
95
#define _sisRect(sis,x,y,w,h,cmd) { \
96
(sis)->u.general.dst_x = (x); \
97
(sis)->u.general.dst_y = (y); \
98
(sis)->u.general.rect_width = (w); \
99
(sis)->u.general.rect_height = (h); \
100
(sis)->u.general.command = (cmd); \
103
#define _sisSetTransparentPlaneBlt(sis, alu, fg, cmd) { \
104
(sis)->u.general.src_fg = (fg); \
105
(cmd) = (SIS_CMD_ENH_COLOR_EXPAND | \
108
(sisBltRop[alu] << 8) | \
111
SIS_CMD_RECT_CLIP_DISABLE | \
112
SIS_CMD_TRANSPARENT | \
113
SIS_CMD_RECT_CLIP_DONT_MERGE); \
116
#define _sisSetOpaquePlaneBlt(sis, alu, fg, bg, cmd) { \
117
(sis)->u.general.src_fg = (fg); \
118
(sis)->u.general.src_bg = (bg); \
119
(cmd) = (SIS_CMD_ENH_COLOR_EXPAND | \
122
(sisBltRop[alu] << 8) | \
125
SIS_CMD_RECT_CLIP_DISABLE | \
127
SIS_CMD_RECT_CLIP_DONT_MERGE); \
130
#define _sisPlaneBlt(sis,x,y,w,h,cmd) _sisSolidRect(sis,x,y,w,h,cmd)
132
#define _sisSetBlt(sis,alu,cmd) { \
133
(sis)->u.general.src_base = (sis)->u.general.dst_base; \
134
(sis)->u.general.src_pitch = (sis)->u.general.dst_pitch; \
135
(cmd) = (SIS_CMD_RECT_CLIP_DONT_MERGE |\
136
(sisBltRop[alu] << 8) |\
138
SIS_CMD_SRC_SCREEN |\
142
#define _sisBlt(sis,sx,sy,dx,dy,w,h,cmd) { \
143
(sis)->u.general.src_x = (sx); \
144
(sis)->u.general.src_y = (sy); \
145
(sis)->u.general.dst_x = (dx); \
146
(sis)->u.general.dst_y = (dy); \
147
(sis)->u.general.rect_width = (w); \
148
(sis)->u.general.rect_height = (h); \
149
(sis)->u.general.command = (cmd); \
152
#define SIS_IE (SIS_STAT_2D_IDLE|SIS_STAT_EMPTY)
154
#define _sisWaitIdleEmpty(sis) \
155
while (((sis)->u.general.status & SIS_IE) != SIS_IE)
158
* Ok, so the Sis530 is broken -- it expects bitmaps to come MSB bit order,
159
* but it's willing to take them in LSB byte order. These macros
160
* flip bits around without flipping bytes. Instead of using a table
161
* and burning memory bandwidth, do them in place with the CPU.
164
/* The MIPS compiler automatically places these constants in registers */
165
#define SisInvertBits32(v) { \
166
v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
167
v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
168
v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
171
#define SisInvertBits16(v) { \
172
v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \
173
v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \
174
v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \
177
#define SisInvertBits8(v) { \
178
v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \
179
v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \
180
v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \