1
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.h,v 1.2 2003/01/29 15:42:16 eich Exp $ */
3
* Copyright 1998,1999 by Alan Hourihane, Wigan, England.
5
* Permission to use, copy, modify, distribute, and sell this software and its
6
* documentation for any purpose is hereby granted without fee, provided that
7
* the above copyright notice appear in all copies and that both that
8
* copyright notice and this permission notice appear in supporting
9
* documentation, and that the name of Alan Hourihane not be used in
10
* advertising or publicity pertaining to distribution of the software without
11
* specific, written prior permission. Alan Hourihane makes no representations
12
* about the suitability of this software for any purpose. It is provided
13
* "as is" without express or implied warranty.
15
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
* PERFORMANCE OF THIS SOFTWARE.
23
* Authors: Alan Hourihane, alanh@fairlite.demon.co.uk
24
* Mike Chapman <mike@paranoia.com>,
25
* Juanjo Santamarta <santamarta@ctv.es>,
26
* Mitani Hiroshi <hmitani@drl.mei.co.jp>
27
* David Thomas <davtom@dream.org.uk>
28
* Thomas Winischhofer <thomas@winischhofer.net>
31
/* Definitions for the SIS engine communication. ------------------------------------ */
33
/* For pre-530 chipsets only!!! */
35
/* Engine Registers for 1st generation engines (5597/5598/6326) */
36
const int sisReg32MMIO[] = {
37
0x8280,0x8284,0x8288,0x828C,0x8290,0x8294,
38
0x8298,0x829C,0x82A0,0x82A4,0x82A8,0x82AC
41
#define BR(x) sisReg32MMIO[x]
43
/* These are done using Memory Mapped IO, of the registers */
45
* Modified for Sis by Xavier Ducoin (xavier@rd.lectra.fr)
49
/* Command Reg 0 (0x82aa, [15:0]) */
50
#define sisSRCBG 0x0000 /* source select */
51
#define sisSRCFG 0x0001
52
#define sisSRCVIDEO 0x0002
53
#define sisSRCSYSTEM 0x0003
55
#define sisPATFG 0x0004 /* pattern select */
56
#define sisPATREG 0x0008
57
#define sisPATBG 0x0000
59
#define sisLEFT2RIGHT 0x0010 /* Direction select */
60
#define sisRIGHT2LEFT 0x0000
61
#define sisTOP2BOTTOM 0x0020
62
#define sisBOTTOM2TOP 0x0000
63
#define sisXINCREASE sisLEFT2RIGHT
64
#define sisYINCREASE sisTOP2BOTTOM
66
#define sisCLIPENABL 0x0040 /* Clipping select */
67
#define sisCLIPINTRN 0x0080
68
#define sisCLIPEXTRN 0x0000
70
#define sisCMDBLT 0x0000 /* Command select */
71
#define sisCMDBLTMSK 0x0100
72
#define sisCMDCOLEXP 0x0200
73
#define sisCMDLINE 0x0300
74
#define sisFLGECOLEXP 0x2000
75
#define sisCMDECOLEXP (sisCMDCOLEXP | sisFLGECOLEXP)
77
#define sisLASTPIX 0x0800 /* Line parameters */
78
#define sisXMAJOR 0x0400
81
/* Macros to do useful things with the SIS BitBLT engine */
84
while(MMIO_IN16(pSiS->IOBase, BR(10) + 2) & 0x4000) {}
86
/* According to SiS 6326 2D programming guide, 16 bits position at */
87
/* 0x82A8 returns queue free. But this don't work, so don't wait */
88
/* anything when turbo-queue is enabled. If there are frequent syncs */
89
/* this should work. But not for xaa_benchmark :-( */
91
/* TW: Bit 16 only applies to the hardware queue, not the software
96
if(!pSiS->TurboQueue) { \
97
while(MMIO_IN16(pSiS->IOBase, BR(10) + 2) & 0x4000) {} \
102
#define sisSETPATREG() \
103
((unsigned char *)(pSiS->IOBase + BR(11)))
105
#define sisSETPATREGL() \
106
((unsigned long *)(pSiS->IOBase + BR(11)))
108
/* trigger command */
109
#define sisSETCMD(op) \
111
unsigned long temp; \
112
MMIO_OUT16(pSiS->IOBase, BR(10) + 2, op); \
113
temp = MMIO_IN32(pSiS->IOBase, BR(10)); \
116
/* set foreground color and fg ROP */
117
#define sisSETFGROPCOL(rop, color) \
118
MMIO_OUT32(pSiS->IOBase, BR(4), ((rop << 24) | (color & 0xFFFFFF)));
120
/* set background color and bg ROP */
121
#define sisSETBGROPCOL(rop, color) \
122
MMIO_OUT32(pSiS->IOBase, BR(5), ((rop << 24) | (color & 0xFFFFFF)));
124
/* background color */
125
#define sisSETBGCOLOR(bgColor) \
126
MMIO_OUT32(pSiS->IOBase, BR(5), (bgColor));
128
*(volatile unsigned int *)(pSiS->IOBase + BR(5)) = (bgColor)
131
/* foreground color */
132
#define sisSETFGCOLOR(fgColor) \
133
MMIO_OUT32(pSiS->IOBase, BR(4), (fgcolor));
135
*(volatile unsigned int *)(pSiS->IOBase + BR(4)) = (fgColor)
139
#define sisSETROPFG(op) \
140
MMIO_OUT8(pSiS->IOBase, BR(4) + 3, op);
142
*(volatile unsigned int *)(pSiS->IOBase + BR(4)) = ((*(volatile unsigned int *)(pSiS->IOBase + BR(4)))&0xffffff) | (op<<24)
145
#define sisSETROPBG(op) \
146
MMIO_OUT8(pSiS->IOBase, BR(5) + 3, op);
148
*(volatile unsigned int *)(pSiS->IOBase + BR(5)) = ((*(volatile unsigned int *)(pSiS->IOBase + BR(5)))&0xffffff) | (op<<24)
151
#define sisSETROP(op) \
152
sisSETROPFG(op); sisSETROPBG(op);
154
/* source and dest address */
155
#define sisSETSRCADDR(srcAddr) \
156
MMIO_OUT32(pSiS->IOBase, BR(0), (srcAddr & 0x3FFFFFL));
158
*(volatile unsigned int *)(pSiS->IOBase + BR(0)) = srcAddr & 0x3FFFFFL
161
#define sisSETDSTADDR(dstAddr) \
162
MMIO_OUT32(pSiS->IOBase, BR(1), (dstAddr & 0x3FFFFFL));
164
*(volatile unsigned int *)(pSiS->IOBase + BR(1)) = dstAddr & 0x3FFFFFL
168
#define sisSETPITCH(srcPitch,dstPitch) \
169
MMIO_OUT32(pSiS->IOBase, BR(2), ((((dstPitch) & 0xFFFF) << 16) | ((srcPitch) & 0xFFFF)));
171
*(volatile unsigned int *)(pSiS->IOBase + BR(2)) = ((dstPitch&0xFFFF)<<16)| \
175
#define sisSETSRCPITCH(srcPitch) \
176
MMIO_OUT16(pSiS->IOBase, BR(2), ((srcPitch) & 0xFFFF));
178
#define sisSETDSTPITCH(dstPitch) \
179
MMIO_OUT16(pSiS->IOBase, BR(2) + 2, ((dstPitch) & 0xFFFF));
182
* According to SIS 2D Engine Programming Guide
183
* height -1, width - 1 independant of Bpp
185
#define sisSETHEIGHTWIDTH(Height, Width) \
186
MMIO_OUT32(pSiS->IOBase, BR(3), ((((Height) & 0xFFFF) << 16) | ((Width) & 0xFFFF)));
188
*(volatile unsigned int *)(pSiS->IOBase + BR(3)) = (((Height)&0xFFFF)<<16)| \
193
#define sisSETCLIPTOP(x, y) \
194
MMIO_OUT32(pSiS->IOBase, BR(8), ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF)));
196
*(volatile unsigned int *)(pSiS->IOBase + BR(8)) = (((y)&0xFFFF)<<16)| \
200
#define sisSETCLIPBOTTOM(x, y) \
201
MMIO_OUT32(pSiS->IOBase, BR(9), ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF)));
203
*(volatile unsigned int *)(pSiS->IOBase + BR(9)) = (((y)&0xFFFF)<<16)| \
208
#define sisSETXStart(XStart) \
209
MMIO_OUT32(pSiS->IOBase, BR(0), ((XStart) & 0xFFFF));
211
*(volatile unsigned int *)(pSiS->IOBase + BR(0)) = XStart&0xFFFF
214
#define sisSETYStart(YStart) \
215
MMIO_OUT32(pSiS->IOBase, BR(1), ((YStart) & 0xFFFF));
217
*(volatile unsigned int *)(pSiS->IOBase + BR(1)) = YStart&0xFFFF
220
#define sisSETLineMajorCount(MajorAxisCount) \
221
MMIO_OUT32(pSiS->IOBase, BR(3), ((MajorAxisCount) & 0xFFFF));
223
*(volatile unsigned int *)(pSiS->IOBase + BR(3)) = MajorAxisCount&0xFFFF
226
#define sisSETLineSteps(K1,K2) \
227
MMIO_OUT32(pSiS->IOBase, BR(6), ((((K1) & 0xFFFF) << 16) | ((K2) & 0xFFFF)));
229
*(volatile unsigned int *)(pSiS->IOBase + BR(6)) = (((K1)&0xFFFF)<<16)| \
233
#define sisSETLineErrorTerm(ErrorTerm) \
234
MMIO_OUT16(pSiS->IOBase, BR(7), (ErrorTerm));
236
*(volatile unsigned short *)(pSiS->IOBase + BR(7)) = ErrorTerm