1b9325ec5Stsutsui/*
2b9325ec5Stsutsui * $Xorg: sunGX.h,v 1.4 2001/02/09 02:04:44 xorgcvs Exp $
3b9325ec5Stsutsui *
4b9325ec5StsutsuiCopyright 1991, 1998  The Open Group
5b9325ec5Stsutsui
6b9325ec5StsutsuiPermission to use, copy, modify, distribute, and sell this software and its
7b9325ec5Stsutsuidocumentation for any purpose is hereby granted without fee, provided that
8b9325ec5Stsutsuithe above copyright notice appear in all copies and that both that
9b9325ec5Stsutsuicopyright notice and this permission notice appear in supporting
10b9325ec5Stsutsuidocumentation.
11b9325ec5Stsutsui
12b9325ec5StsutsuiThe above copyright notice and this permission notice shall be included in
13b9325ec5Stsutsuiall copies or substantial portions of the Software.
14b9325ec5Stsutsui
15b9325ec5StsutsuiTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16b9325ec5StsutsuiIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17b9325ec5StsutsuiFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
18b9325ec5StsutsuiOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19b9325ec5StsutsuiAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20b9325ec5StsutsuiCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21b9325ec5Stsutsui
22b9325ec5StsutsuiExcept as contained in this notice, the name of The Open Group shall not be
23b9325ec5Stsutsuiused in advertising or otherwise to promote the sale, use or other dealings
24b9325ec5Stsutsuiin this Software without prior written authorization from The Open Group.
25b9325ec5Stsutsui *
26b9325ec5Stsutsui * Author:  Keith Packard, MIT X Consortium
27b9325ec5Stsutsui */
28b9325ec5Stsutsui/* $XFree86: xc/programs/Xserver/hw/sun/sunGX.h,v 1.4 2001/12/14 19:59:43 dawes Exp $ */
29b9325ec5Stsutsui
30b9325ec5Stsutsuitypedef unsigned int	Uint;
31b9325ec5Stsutsuitypedef volatile Uint VUint;
32b9325ec5Stsutsui
33b9325ec5Stsutsui/* modes */
34b9325ec5Stsutsui#define GX_INDEX(n)	    ((n) << 4)
35b9325ec5Stsutsui#define GX_INDEX_ALL	    0x00000030
36b9325ec5Stsutsui#define GX_INDEX_MOD	    0x00000040
37b9325ec5Stsutsui#define GX_BDISP_0	    0x00000080
38b9325ec5Stsutsui#define GX_BDISP_1	    0x00000100
39b9325ec5Stsutsui#define GX_BDISP_ALL	    0x00000180
40b9325ec5Stsutsui#define GX_BREAD_0	    0x00000200
41b9325ec5Stsutsui#define GX_BREAD_1	    0x00000400
42b9325ec5Stsutsui#define GX_BREAD_ALL	    0x00000600
43b9325ec5Stsutsui#define GX_BWRITE1_ENABLE   0x00000800
44b9325ec5Stsutsui#define GX_BWRITE1_DISABLE  0x00001000
45b9325ec5Stsutsui#define GX_BWRITE1_ALL	    0x00001800
46b9325ec5Stsutsui#define GX_BWRITE0_ENABLE   0x00002000
47b9325ec5Stsutsui#define GX_BWRITE0_DISABLE  0x00004000
48b9325ec5Stsutsui#define GX_BWRITE0_ALL	    0x00006000
49b9325ec5Stsutsui#define GX_DRAW_RENDER	    0x00008000
50b9325ec5Stsutsui#define GX_DRAW_PICK	    0x00010000
51b9325ec5Stsutsui#define GX_DRAW_ALL	    0x00018000
52b9325ec5Stsutsui#define GX_MODE_COLOR8	    0x00020000
53b9325ec5Stsutsui#define GX_MODE_COLOR1	    0x00040000
54b9325ec5Stsutsui#define GX_MODE_HRMONO	    0x00060000
55b9325ec5Stsutsui#define GX_MODE_ALL	    0x00060000
56b9325ec5Stsutsui#define GX_VBLANK	    0x00080000
57b9325ec5Stsutsui#define GX_BLIT_NOSRC	    0x00100000
58b9325ec5Stsutsui#define GX_BLIT_SRC	    0x00200000
59b9325ec5Stsutsui#define GX_BLIT_ALL	    0x00300000
60b9325ec5Stsutsui
61b9325ec5Stsutsui/* rasterops */
62b9325ec5Stsutsui#define GX_ROP_CLEAR	    0x0
63b9325ec5Stsutsui#define GX_ROP_INVERT	    0x1
64b9325ec5Stsutsui#define GX_ROP_NOOP	    0x2
65b9325ec5Stsutsui#define GX_ROP_SET	    0x3
66b9325ec5Stsutsui
67b9325ec5Stsutsui#define GX_ROP_00_0(rop)    ((rop) << 0)
68b9325ec5Stsutsui#define GX_ROP_00_1(rop)    ((rop) << 2)
69b9325ec5Stsutsui#define GX_ROP_01_0(rop)    ((rop) << 4)
70b9325ec5Stsutsui#define GX_ROP_01_1(rop)    ((rop) << 6)
71b9325ec5Stsutsui#define GX_ROP_10_0(rop)    ((rop) << 8)
72b9325ec5Stsutsui#define GX_ROP_10_1(rop)    ((rop) << 10)
73b9325ec5Stsutsui#define GX_ROP_11_0(rop)    ((rop) << 12)
74b9325ec5Stsutsui#define GX_ROP_11_1(rop)    ((rop) << 14)
75b9325ec5Stsutsui#define GX_PLOT_PLOT	    0x00000000
76b9325ec5Stsutsui#define GX_PLOT_UNPLOT	    0x00020000
77b9325ec5Stsutsui#define GX_RAST_BOOL	    0x00000000
78b9325ec5Stsutsui#define GX_RAST_LINEAR	    0x00040000
79b9325ec5Stsutsui#define GX_ATTR_UNSUPP	    0x00400000
80b9325ec5Stsutsui#define GX_ATTR_SUPP	    0x00800000
81b9325ec5Stsutsui#define GX_POLYG_OVERLAP    0x01000000
82b9325ec5Stsutsui#define GX_POLYG_NONOVERLAP 0x02000000
83b9325ec5Stsutsui#define GX_PATTERN_ZEROS    0x04000000
84b9325ec5Stsutsui#define GX_PATTERN_ONES	    0x08000000
85b9325ec5Stsutsui#define GX_PATTERN_MASK	    0x0c000000
86b9325ec5Stsutsui#define GX_PIXEL_ZEROS	    0x10000000
87b9325ec5Stsutsui#define GX_PIXEL_ONES	    0x20000000
88b9325ec5Stsutsui#define GX_PIXEL_MASK	    0x30000000
89b9325ec5Stsutsui#define GX_PLANE_ZEROS	    0x40000000
90b9325ec5Stsutsui#define GX_PLANE_ONES	    0x80000000
91b9325ec5Stsutsui#define GX_PLANE_MASK	    0xc0000000
92b9325ec5Stsutsui
93b9325ec5Stsutsuitypedef struct _sunGX {
94b9325ec5Stsutsui	Uint	junk0[1];
95b9325ec5Stsutsui	VUint	mode;
96b9325ec5Stsutsui	VUint	clip;
97b9325ec5Stsutsui	Uint	junk1[1];
98b9325ec5Stsutsui	VUint	s;
99b9325ec5Stsutsui	VUint	draw;
100b9325ec5Stsutsui	VUint	blit;
101b9325ec5Stsutsui	VUint	font;
102b9325ec5Stsutsui	Uint	junk2[24];
103b9325ec5Stsutsui	VUint	x0, y0, z0, color0;
104b9325ec5Stsutsui	VUint	x1, y1, z1, color1;
105b9325ec5Stsutsui	VUint	x2, y2, z2, color2;
106b9325ec5Stsutsui	VUint	x3, y3, z3, color3;
107b9325ec5Stsutsui	VUint	offx, offy;
108b9325ec5Stsutsui	Uint	junk3[2];
109b9325ec5Stsutsui	VUint	incx, incy;
110b9325ec5Stsutsui	Uint	junk4[2];
111b9325ec5Stsutsui	VUint	clipminx, clipminy;
112b9325ec5Stsutsui	Uint	junk5[2];
113b9325ec5Stsutsui	VUint	clipmaxx, clipmaxy;
114b9325ec5Stsutsui	Uint	junk6[2];
115b9325ec5Stsutsui	VUint	fg;
116b9325ec5Stsutsui	VUint	bg;
117b9325ec5Stsutsui	VUint	alu;
118b9325ec5Stsutsui	VUint	pm;
119b9325ec5Stsutsui	VUint	pixelm;
120b9325ec5Stsutsui	Uint	junk7[2];
121b9325ec5Stsutsui	VUint	patalign;
122b9325ec5Stsutsui	VUint	pattern[8];
123b9325ec5Stsutsui	Uint	junk8[432];
124b9325ec5Stsutsui	VUint	apointx, apointy, apointz;
125b9325ec5Stsutsui	Uint	junk9[1];
126b9325ec5Stsutsui	VUint	rpointx, rpointy, rpointz;
127b9325ec5Stsutsui	Uint	junk10[5];
128b9325ec5Stsutsui	VUint	pointr, pointg, pointb, pointa;
129b9325ec5Stsutsui	VUint	alinex, aliney, alinez;
130b9325ec5Stsutsui	Uint	junk11[1];
131b9325ec5Stsutsui	VUint	rlinex, rliney, rlinez;
132b9325ec5Stsutsui	Uint	junk12[5];
133b9325ec5Stsutsui	VUint	liner, lineg, lineb, linea;
134b9325ec5Stsutsui	VUint	atrix, atriy, atriz;
135b9325ec5Stsutsui	Uint	junk13[1];
136b9325ec5Stsutsui	VUint	rtrix, rtriy, rtriz;
137b9325ec5Stsutsui	Uint	junk14[5];
138b9325ec5Stsutsui	VUint	trir, trig, trib, tria;
139b9325ec5Stsutsui	VUint	aquadx, aquady, aquadz;
140b9325ec5Stsutsui	Uint	junk15[1];
141b9325ec5Stsutsui	VUint	rquadx, rquady, rquadz;
142b9325ec5Stsutsui	Uint	junk16[5];
143b9325ec5Stsutsui	VUint	quadr, quadg, quadb, quada;
144b9325ec5Stsutsui	VUint	arectx, arecty, arectz;
145b9325ec5Stsutsui	Uint	junk17[1];
146b9325ec5Stsutsui	VUint	rrectx, rrecty, rrectz;
147b9325ec5Stsutsui	Uint	junk18[5];
148b9325ec5Stsutsui	VUint	rectr, rectg, rectb, recta;
149b9325ec5Stsutsui} sunGX, *sunGXPtr;
150b9325ec5Stsutsui
151b9325ec5Stsutsui/* Macros */
152b9325ec5Stsutsui
153b9325ec5Stsutsui#define GX_ROP_USE_PIXELMASK	0x30000000
154b9325ec5Stsutsui
155b9325ec5Stsutsui#define GX_BLT_INPROGRESS	0x20000000
156b9325ec5Stsutsui
157b9325ec5Stsutsui#define GX_INPROGRESS		0x10000000
158b9325ec5Stsutsui#define GX_FULL			0x20000000
159b9325ec5Stsutsui
160b9325ec5Stsutsui#define GXWait(gx,r)\
161b9325ec5Stsutsui    do\
162b9325ec5Stsutsui	(r) = (int) (gx)->s; \
163b9325ec5Stsutsui    while ((r) & GX_INPROGRESS)
164b9325ec5Stsutsui
165b9325ec5Stsutsui#define GXDrawDone(gx,r) \
166b9325ec5Stsutsui    do \
167b9325ec5Stsutsui	(r) = (int) (gx)->draw; \
168b9325ec5Stsutsui    while ((r) < 0 && ((r) & GX_FULL))
169b9325ec5Stsutsui
170b9325ec5Stsutsui#define GXBlitDone(gx,r)\
171b9325ec5Stsutsui    do\
172b9325ec5Stsutsui	(r)= (int) (gx)->blit; \
173b9325ec5Stsutsui    while ((r) < 0 && ((r) & GX_BLT_INPROGRESS))
174b9325ec5Stsutsui
175b9325ec5Stsutsui#define GXBlitInit(gx,rop,pmsk) {\
176b9325ec5Stsutsui    gx->fg = 0xff;\
177b9325ec5Stsutsui    gx->bg = 0x00;\
178b9325ec5Stsutsui    gx->pixelm = ~0;\
179b9325ec5Stsutsui    gx->s = 0;\
180b9325ec5Stsutsui    gx->alu = rop;\
181b9325ec5Stsutsui    gx->pm = pmsk;\
182b9325ec5Stsutsui    gx->clip = 0;\
183b9325ec5Stsutsui}
184b9325ec5Stsutsui
185b9325ec5Stsutsui#define GXDrawInit(gx,fore,rop,pmsk) {\
186b9325ec5Stsutsui    gx->fg = fore;\
187b9325ec5Stsutsui    gx->bg = 0x00; \
188b9325ec5Stsutsui    gx->pixelm = ~0; \
189b9325ec5Stsutsui    gx->s = 0; \
190b9325ec5Stsutsui    gx->alu = rop; \
191b9325ec5Stsutsui    gx->pm = pmsk; \
192b9325ec5Stsutsui    gx->clip = 0;\
193b9325ec5Stsutsui}
194b9325ec5Stsutsui
195b9325ec5Stsutsui#define GXStippleInit(gx,stipple) {\
196b9325ec5Stsutsui    int		_i; \
197b9325ec5Stsutsui    Uint	*sp; \
198b9325ec5Stsutsui    VUint	*dp; \
199b9325ec5Stsutsui    _i = 8;  \
200b9325ec5Stsutsui    sp = stipple->bits; \
201b9325ec5Stsutsui    dp = gx->pattern; \
202b9325ec5Stsutsui    while (_i--) {  \
203b9325ec5Stsutsui	dp[_i] =  sp[_i]; \
204b9325ec5Stsutsui    } \
205b9325ec5Stsutsui    gx->fg = stipple->fore; \
206b9325ec5Stsutsui    gx->bg = stipple->back; \
207b9325ec5Stsutsui    gx->patalign = stipple->patalign; \
208b9325ec5Stsutsui    gx->alu = stipple->alu; \
209b9325ec5Stsutsui}
210b9325ec5Stsutsui
211b9325ec5Stsutsuiextern int  sunGXScreenPrivateIndex;
212b9325ec5Stsutsuiextern int  sunGXGCPrivateIndex;
213b9325ec5Stsutsuiextern int  sunGXWindowPrivateIndex;
214b9325ec5Stsutsui
215b9325ec5Stsutsui#define sunGXGetScreenPrivate(s)    ((sunGXPtr) \
216b9325ec5Stsutsui			    (s)->devPrivates[sunGXScreenPrivateIndex].ptr)
217b9325ec5Stsutsui
218b9325ec5Stsutsuitypedef struct _sunGXStipple {
219b9325ec5Stsutsui    Uint	fore, back;
220b9325ec5Stsutsui    Uint	patalign;
221b9325ec5Stsutsui    Uint	alu;
222b9325ec5Stsutsui    Uint	bits[8];	/* actually 16 shorts */
223b9325ec5Stsutsui} sunGXStippleRec, *sunGXStipplePtr;
224b9325ec5Stsutsui
225b9325ec5Stsutsuitypedef struct _sunGXPrivGC {
226b9325ec5Stsutsui    int		    type;
227b9325ec5Stsutsui    sunGXStipplePtr stipple;
228b9325ec5Stsutsui} sunGXPrivGCRec, *sunGXPrivGCPtr;
229b9325ec5Stsutsui
230b9325ec5Stsutsui#define sunGXGetGCPrivate(g)	    ((sunGXPrivGCPtr) \
231b9325ec5Stsutsui			    (g)->devPrivates[sunGXGCPrivateIndex].ptr)
232b9325ec5Stsutsui
233b9325ec5Stsutsui#define sunGXGetWindowPrivate(w)    ((sunGXStipplePtr) \
234b9325ec5Stsutsui			    (w)->devPrivates[sunGXWindowPrivateIndex].ptr)
235b9325ec5Stsutsui
236b9325ec5Stsutsui#define sunGXSetWindowPrivate(w,p) (\
237b9325ec5Stsutsui	    (w)->devPrivates[sunGXWindowPrivateIndex].ptr = (pointer) p)
238b9325ec5Stsutsui
239