lg_xaa.h revision 76888252
1#ifndef __LG_XAA_H
2#define __LG_XAA_H
3
4/*
5 * XAA acceleration for CL-GD546x -- The Laugna family
6 *
7 * lg_xaa.h
8 *
9 * (c) 1996,1998 Corin Anderson.
10 *               corina@the4cs.com
11 *               Tukwila, WA
12 *
13 * This header file draws much from the file cir_blitLG.h in version 3.3.3
14 * of XFree86.
15 */
16/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_xaa.h,v 1.1 1998/11/22 10:37:21 dawes Exp $ */
17
18/* This header file defines the necessary structures, contstants, and
19   variables for using the bitBLT engine on a Laguna family graphics
20   accelerator.  */
21
22
23enum {						/* Offsets into MMIO space for bitBLT regs */
24	STATUS			= 0x0400,
25	OP0_opRDRAM		= 0x0520,
26	OP1_opRDRAM		= 0x0540,
27	OP2_opRDRAM		= 0x0560,
28	OP0_opMRDRAM	= 0x0524,
29	OP1_opMRDRAM	= 0x0544,
30	OP2_opMRDRAM	= 0x0564,
31	OP0_opSRAM		= 0x0528,
32	OP1_opSRAM		= 0x0548,
33	OP2_opSRAM		= 0x0568,
34	OP1_opMSRAM		= 0x054A,
35	OP2_opMSRAM		= 0x056A,
36	DRAWDEF			= 0x0584,
37	BLTDEF			= 0x0586,
38	BLTEXT_EX		= 0x0700,
39	MBLTEXT_EX		= 0x0720,
40	MONOQW			= 0x0588,
41	QFREE			= 0x0404,
42	PATOFF			= 0x052A,
43	HOSTDATA		= 0x0800,
44	OP_opBGCOLOR	= 0x05E4,
45	OP_opFGCOLOR	= 0x05E0,
46	bltCONTROL		= 0x0402,
47	BITMASK			= 0x05E8
48};
49
50enum { HOSTDATASIZE = 2048 };	/* The HOSTDATA port is 2048 BYTES */
51
52enum {						/* OR these together to form a bitBLT mode */
53	HOST2SCR		= 0x1120,	/* CPU/Screen transfer modes */
54	SCR2HOST		= 0x2010,
55	HOST2PAT		= 0x1102,
56	HOST2SRAM2		= 0x6020,	/* CPU to SRAM2 transfer */
57
58	SCR2SCR			= 0x1110,	/* Screen/Screen transfers */
59	COLORSRC		= 0x0000,	/* Source is color data */
60	MONOSRC			= 0x0040,	/* Source is mono data (color expansion) */
61	COLORTRANS		= 0x0001,	/* Transparent screen/screen transfer */
62	MONOTRANS		= 0x0005,	/* Transparent screen/screen color expansion */
63	COLORFILL		= 0x0070,	/* Solid color fill mode */
64	SRAM1SCR2SCR	= 0x1180,	/* Pattern fill, source from SRAM1 */
65
66	PAT2SCR			= 0x1109,	/* Pattern/Screen transfers */
67	COLORPAT		= 0x0000,	/* Pattern is color data */
68	MONOPAT			= 0x0004,	/* Pattern is mono data (color expansion) */
69	SRAM2PAT2SCR	= 0x1108,	/* SRAM2 is pattern source */
70
71  PATeqSRC   = 0x0800,      /* The Pattern and Source operands are the same */
72								/* Advice from Corey:  don't ever try to use
73								   this option!  8)  There's a documented bug
74								   with it on the '62, and, well, I have
75								   empirical evidence that either the bug's
76								   still around, even in the '64 and the '65.
77								   It's a performance option, anyway, so not
78								   using it should be okay. */
79
80
81	BLITUP			= 0x8000	/* The blit is proceeding from bottom to top */
82};
83
84enum {						/* Select transparency compare */
85	TRANSBG			= 0x0100,
86	TRANSFG			= 0x0300,
87	TRANSEQ			= 0x0100,
88	TRANSNE			= 0x0300,
89	TRANSNONE		= 0x0000
90};
91
92#define LgREADY() ((memrb(STATUS) & 0x07) == 0x00)
93
94#define LgSETROP(rop)  memww(DRAWDEF,rop);
95
96#define LgSETTRANSPARENCY(trans) \
97  memww(DRAWDEF,(trans) | (memrw(DRAWDEF) & 0x00FF));
98
99#define LgSETMODE(mode)  memww(BLTDEF,mode);
100
101#define LgSETDSTXY(X, Y)  memwl(OP0_opRDRAM, (((Y) << 16) | (X)));
102
103#define LgSETSRCXY(X, Y)  memwl(OP1_opRDRAM, (((Y) << 16) | (X)));
104
105#define LgSETPATXY(X, Y)  memwl(OP2_opRDRAM, (((Y) << 16) | (X)));
106
107#define LgSETTRANSMASK(X, Y) LgSETPATXY(X, Y)
108
109#define LgSETSRAMDST(offset)  memww(OP0_opSRAM, offset);
110
111/* was this a bug? it read OP2_opSRAM */
112#define LgSETSRAM1OFFSET(offset)  memww(OP1_opSRAM, offset);
113
114#define LgSETSRAM2OFFSET(offset)  memww(OP2_opSRAM, offset);
115
116#define LgSETMSRAM1OFFSET(offset) memww(OP1_opMSRAM, offset);
117
118#define LgSETMSRAM2OFFSET(offset) memww(OP2_opMSRAM, offset);
119
120#define LgSETMDSTXY(X, Y)  memwl(OP0_opMRDRAM, (((Y) << 16) | (X)));
121
122#define LgSETMSRCXY(X, Y)  memwl(OP1_opMRDRAM, (((Y) << 16) | (X)));
123
124#define LgSETMPATXY(X, Y)  memwl(OP2_opMRDRAM, (((Y) << 16) | (X)));
125
126#define LgSETMTRANSMASK(X, Y) LgSETMPATXY(X, Y)
127
128#define LgSETPHASE0(phase)  memwl( OP0_opRDRAM, phase);
129
130#define LgSETPHASE1(phase)  memwl(OP1_opRDRAM, phase);
131
132#define LgSETPHASE2(phase)  memwl( OP2_opRDRAM, phase);
133
134#define LgSETMPHASE0(phase)  memwl(OP0_opMRDRAM, phase);
135
136#define LgSETMPHASE1(phase)  memwl(OP1_opMRDRAM, phase);
137
138#define LgSETEXTENTS(width, height)  \
139           memwl(BLTEXT_EX, (((height) << 16)|(width)));
140
141#if 0
142#define LgSETMEXTENTS(width, height)  \
143  memwl(MBLTEXT_EX, (((height) << 16)|(width)));
144#else
145/* For monochrome (byte) blits, we need to set how many QWORDs of data
146   encompass the X extent.  Write this piece of data into MONOQW. */
147#define LgSETMEXTENTS(width, height)  \
148	{ \
149    memww(MONOQW, ((width + 7) >> 3));  \
150    memwl(MBLTEXT_EX, (((height) << 16)|(width)));  \
151	}
152
153#define LgSETMEXTENTSNOMONOQW(width, height)  \
154  memwl(MBLTEXT_EX, (((height) << 16)|(width)));
155
156/*
157    memww(MBLTEXT_EX, height);
158    memww(MBLTEXT_EX + 2, width);
159 */
160#endif
161
162#define LgHOSTDATAWRITE(data)  memwl(HOSTDATA, data);
163
164#define LgHOSTDATAREAD()   (memrl(HOSTDATA))
165
166#define LgSETBACKGROUND(color)  memwl(OP_opBGCOLOR, color);
167
168#define LgSETFOREGROUND(color)   memwl(OP_opFGCOLOR, color);
169
170#define LgSETPATOFF(xoff, yoff)  memww(PATOFF, (((yoff) << 8) | (xoff)));
171
172#define LgSETSWIZZLE() memww(bltCONTROL, memrw(bltCONTROL | 0x0400));
173
174#define LgCLEARSWIZZLE() memww(bltCONTROL, memrw(bltCONTROL & ~0x0400));
175
176#define LgSETBITMASK(m) memwl(BITMASK, m);
177
178
179
180#endif  /* __LG_XAA_H */
181