comparison vidix/s3_regs.h @ 26096:e6a565ec1a3b

New S3 VIDIX driver. Provides support for S3 Trio and S3 Virge chipsets. This deprecates the old Savage driver that worked with latest chips only. (synchronized with vidix.sf.net r326 and r327)
author ben
date Fri, 29 Feb 2008 20:01:28 +0000
parents
children 74106358c073
comparison
equal deleted inserted replaced
26095:7470a625bbdd 26096:e6a565ec1a3b
1 #ifndef _SAVAGE_REGS_H
2 #define _SAVAGE_REGS_H
3
4 #define S3_SAVAGE3D_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX))
5 #define S3_SAVAGE4_SERIES(chip) ((chip==S3_SAVAGE4) || (chip==S3_PROSAVAGE))
6 #define S3_SAVAGE_MOBILE_SERIES(chip) ((chip==S3_SAVAGE_MX) || (chip==S3_SUPERSAVAGE))
7 #define S3_SAVAGE_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE2000))
8
9 /*
10 * Chip tags. These are used to group the adapters into
11 * related families.
12 */
13 enum S3CHIPTAGS {
14 S3_UNKNOWN = 0,
15 S3_TRIO64V,
16 S3_VIRGE,
17 S3_SAVAGE3D,
18 S3_SAVAGE_MX,
19 S3_SAVAGE4,
20 S3_PROSAVAGE,
21 S3_SUPERSAVAGE,
22 S3_SAVAGE2000,
23 S3_LAST
24 };
25
26 #define BIOS_BSIZE 1024
27 #define BIOS_BASE 0xc0000
28
29 #define S3_NEWMMIO_REGBASE 0x1000000 /* 16MB */
30 #define S3_NEWMMIO_REGSIZE 0x0010000 /* 64KB */
31 #define S3_NEWMMIO_REGSIZE_SAVAGE 0x0080000 /* 512KB */
32
33 #define BASE_FREQ 14.31818
34
35 /*
36 * There are two different streams engines used in the S3 line.
37 * The old engine is in the Trio64, Virge,
38 * Savage3D, Savage4, SavagePro, and SavageTwister.
39 * The new engine is in the Savage2000, SavageMX,
40 * SavageIX, and SuperSavage.
41 */
42
43 /* Old engine registers */
44 #define PSTREAM_CONTROL_REG 0x8180
45 #define COL_CHROMA_KEY_CONTROL_REG 0x8184
46 #define SSTREAM_CONTROL_REG 0x8190
47 #define CHROMA_KEY_UPPER_BOUND_REG 0x8194
48 #define SSTREAM_STRETCH_REG 0x8198
49 #define COLOR_ADJUSTMENT_REG 0x819C
50 #define BLEND_CONTROL_REG 0x81A0
51 #define PSTREAM_FBADDR0_REG 0x81C0
52 #define PSTREAM_FBADDR1_REG 0x81C4
53 #define PSTREAM_STRIDE_REG 0x81C8
54 #define DOUBLE_BUFFER_REG 0x81CC
55 #define SSTREAM_FBADDR0_REG 0x81D0
56 #define SSTREAM_FBADDR1_REG 0x81D4
57 #define SSTREAM_STRIDE_REG 0x81D8
58 #define OPAQUE_OVERLAY_CONTROL_REG 0x81DC
59 #define K1_VSCALE_REG 0x81E0
60 #define SSTREAM_VSCALE_REG 0x81E0
61 #define K2_VSCALE_REG 0x81E4
62 #define SSTREAM_VINITIAL_REG 0x81E4
63 #define DDA_VERT_REG 0x81E8
64 #define SSTREAM_LINES_REG 0x81E8
65 #define STREAMS_FIFO_REG 0x81EC
66 #define PSTREAM_WINDOW_START_REG 0x81F0
67 #define PSTREAM_WINDOW_SIZE_REG 0x81F4
68 #define SSTREAM_WINDOW_START_REG 0x81F8
69 #define SSTREAM_WINDOW_SIZE_REG 0x81FC
70 #define FIFO_CONTROL 0x8200
71 #define PSTREAM_FBSIZE_REG 0x8300
72 #define SSTREAM_FBSIZE_REG 0x8304
73 #define SSTREAM_FBADDR2_REG 0x8308
74
75 /* New engine registers */
76 #define PRI_STREAM_FBUF_ADDR0 0x81c0
77 #define PRI_STREAM_FBUF_ADDR1 0x81c4
78 #define PRI_STREAM_STRIDE 0x81c8
79 #define PRI_STREAM_BUFFERSIZE 0x8214
80 #define SEC_STREAM_CKEY_LOW 0x8184
81 #define SEC_STREAM_CKEY_UPPER 0x8194
82 #define BLEND_CONTROL 0x8190
83 #define SEC_STREAM_COLOR_CONVERT1 0x8198
84 #define SEC_STREAM_COLOR_CONVERT2 0x819c
85 #define SEC_STREAM_COLOR_CONVERT3 0x81e4
86 #define SEC_STREAM_HSCALING 0x81a0
87 #define SEC_STREAM_BUFFERSIZE 0x81a8
88 #define SEC_STREAM_HSCALE_NORMALIZE 0x81ac
89 #define SEC_STREAM_VSCALING 0x81e8
90 #define SEC_STREAM_FBUF_ADDR0 0x81d0
91 #define SEC_STREAM_FBUF_ADDR1 0x81d4
92 #define SEC_STREAM_FBUF_ADDR2 0x81ec
93 #define SEC_STREAM_STRIDE 0x81d8
94 #define SEC_STREAM_WINDOW_START 0x81f8
95 #define SEC_STREAM_WINDOW_SZ 0x81fc
96 #define SEC_STREAM_TILE_OFF 0x821c
97 #define SEC_STREAM_OPAQUE_OVERLAY 0x81dc
98
99 /* Savage 2000 registers */
100 #define SEC_STREAM_COLOR_CONVERT0_2000 0x8198
101 #define SEC_STREAM_COLOR_CONVERT1_2000 0x819c
102 #define SEC_STREAM_COLOR_CONVERT2_2000 0x81e0
103 #define SEC_STREAM_COLOR_CONVERT3_2000 0x81e4
104
105 /* Virge+ registers */
106 #define FIFO_CONTROL_REG 0x8200
107 #define MIU_CONTROL_REG 0x8204
108 #define STREAMS_TIMEOUT_REG 0x8208
109 #define MISC_TIMEOUT_REG 0x820c
110
111 /* VGA stuff */
112 #define vgaCRIndex 0x3d4
113 #define vgaCRReg 0x3d5
114
115 /* CRT Control registers */
116 #define EXT_MEM_CTRL1 0x53
117 #define LIN_ADDR_CTRL 0x58
118 #define EXT_MISC_CTRL2 0x67
119
120 /* Old engine constants */
121 #define ENABLE_NEWMMIO 0x08
122 #define ENABLE_LFB 0x10
123 #define ENABLE_STREAMS_OLD 0x0c
124 #define NO_STREAMS_OLD 0xf3
125
126 /* New engine constants */
127 #define ENABLE_STREAM1 0x04
128 #define NO_STREAMS 0xF9
129
130 #define VerticalRetraceWait() \
131 do { \
132 VGAIN8(0x3d4); \
133 VGAOUT8(0x3d4, 0x17); \
134 if (VGAIN8(0x3d5) & 0x80) { \
135 int i = 0x10000; \
136 while ((VGAIN8(0x3da) & 0x08) == 0x08 && i--) ; \
137 i = 0x10000; \
138 while ((VGAIN8(0x3da) & 0x08) == 0x00 && i--) ; \
139 } \
140 } while (0)
141
142 /* Scaling operations */
143 #define HSCALING_Shift 0
144 #define HSCALING_Mask (((1L << 16)-1) << HSCALING_Shift)
145 #define HSCALING(w0,w1) ((((unsigned int)(((double)w0/(double)w1) * (1 << 15))) << HSCALING_Shift) & HSCALING_Mask)
146
147 #define VSCALING_Shift 0
148 #define VSCALING_Mask (((1L << 20)-1) << VSCALING_Shift)
149 #define VSCALING(h0,h1) ((((unsigned int) (((double)h0/(double)h1) * (1 << 15))) << VSCALING_Shift) & VSCALING_Mask)
150
151 /* Scaling factors */
152 #define HDM_SHIFT 16
153 #define HDSCALE_4 (2 << HDM_SHIFT)
154 #define HDSCALE_8 (3 << HDM_SHIFT)
155 #define HDSCALE_16 (4 << HDM_SHIFT)
156 #define HDSCALE_32 (5 << HDM_SHIFT)
157 #define HDSCALE_64 (6 << HDM_SHIFT)
158
159 /* Window parameters */
160 #define OS_XY(x,y) (((x+1)<<16)|(y+1))
161 #define OS_WH(x,y) (((x-1)<<16)|(y))
162
163 /* PCI stuff */
164
165 /* PCI-Memory IO access macros. */
166 #define VID_WR08(p,i,val) (((uint8_t *)(p))[(i)]=(val))
167 #define VID_RD08(p,i) (((uint8_t *)(p))[(i)])
168
169 #define VID_WR32(p,i,val) (((uint32_t *)(p))[(i)/4]=(val))
170 #define VID_RD32(p,i) (((uint32_t *)(p))[(i)/4])
171
172 #ifndef USE_RMW_CYCLES
173
174 /* Can be used to inhibit READ-MODIFY-WRITE cycles. On by default. */
175 #define MEM_BARRIER() __asm__ __volatile__ ("" : : : "memory")
176
177 #undef VID_WR08
178 #define VID_WR08(p,i,val) ({ MEM_BARRIER(); ((uint8_t *)(p))[(i)]=(val); })
179 #undef VID_RD08
180 #define VID_RD08(p,i) ({ MEM_BARRIER(); ((uint8_t *)(p))[(i)]; })
181
182 #undef VID_WR16
183 #define VID_WR16(p,i,val) ({ MEM_BARRIER(); ((uint16_t *)(p))[(i)/2]=(val); })
184 #undef VID_RD16
185 #define VID_RD16(p,i) ({ MEM_BARRIER(); ((uint16_t *)(p))[(i)/2]; })
186
187 #undef VID_WR32
188 #define VID_WR32(p,i,val) ({ MEM_BARRIER(); ((uint32_t *)(p))[(i)/4]=(val); })
189 #undef VID_RD32
190 #define VID_RD32(p,i) ({ MEM_BARRIER(); ((uint32_t *)(p))[(i)/4]; })
191 #endif /* USE_RMW_CYCLES */
192
193 #define VID_AND32(p,i,val) VID_WR32(p,i,VID_RD32(p,i)&(val))
194 #define VID_OR32(p,i,val) VID_WR32(p,i,VID_RD32(p,i)|(val))
195 #define VID_XOR32(p,i,val) VID_WR32(p,i,VID_RD32(p,i)^(val))
196
197 #define VGAIN8(addr) VID_RD08(info->control_base+0x8000, addr)
198 #define VGAIN16(addr) VID_RD16(info->control_base+0x8000, addr)
199 #define VGAIN(addr) VID_RD32(info->control_base+0x8000, addr)
200
201 #define VGAOUT8(addr,val) VID_WR08(info->control_base+0x8000, addr, val)
202 #define VGAOUT16(addr,val) VID_WR16(info->control_base+0x8000, addr, val)
203 #define VGAOUT(addr,val) VID_WR32(info->control_base+0x8000, addr, val)
204
205 #define INREG(addr) VID_RD32(info->control_base, addr)
206 #define OUTREG(addr,val) VID_WR32(info->control_base, addr, val)
207 #define INREG8(addr) VID_RD08(info->control_base, addr)
208 #define OUTREG8(addr,val) VID_WR08(info->control_base, addr, val)
209 #define INREG16(addr) VID_RD16(info->control_base, addr)
210 #define OUTREG16(addr,val) VID_WR16(info->control_base, addr, val)
211
212 #define ALIGN_TO(v, n) (((v) + (n-1)) & ~(n-1))
213
214 #endif /* _S3_REGS_H */