1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
|
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c,v 1.12 2003/01/01 19:16:30 tsi Exp $ */
/*
* Copyright 1997 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation, and
* that the name of Marc Aurele La France not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. Marc Aurele La France makes no representations
* about the suitability of this software for any purpose. It is provided
* "as-is" without express or implied warranty.
*
* MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
* EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "ati.h"
#include "atibank.h"
#include "atimach64io.h"
#include "atiwonderio.h"
#ifndef AVOID_CPIO
/*
* ATI VGA Wonder V3 adapters use an ATI 18800 chip and are single-banked.
* Bank selection is done with bits 0x1E of ATI extended VGA register index
* 0xB2.
*/
/*
* ATIV3SetBank --
*
* Set an ATI 18800's bank number.
*/
void
ATIV3SetBank
(
ATIPtr pATI,
unsigned int iBank
)
{
ATIModifyExtReg(pATI, 0xB2U, -1, (CARD8)(~0x1EU), SetBits(iBank, 0x1EU));
}
/*
* ATIV3SetReadWrite --
*
* Set an ATI 18800's bank number.
*/
int
ATIV3SetReadWrite
(
ScreenPtr pScreen,
unsigned int iBank
)
{
ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen));
ATIModifyExtReg(pATI, 0xB2U, -1, (CARD8)(~0x1EU), SetBits(iBank, 0x1EU));
return 0;
}
/*
* ATI VGA Wonder V4 and V5 adapters use an ATI 18800-1 chip. Bank selection
* is done with ATI extended VGA register index 0xB2. The format is:
*
* 0xE0 - Read bank select bits 0x07
* 0x1E - Write bank select bits 0x0F
* 0x01 - Read bank select bit 0x08.
*/
/*
* ATIV4V5SetBank --
*
* Set an ATI 18800-1's read and write bank numbers.
*/
void
ATIV4V5SetBank
(
ATIPtr pATI,
unsigned int iBank
)
{
pATI->B2Reg = SetBits(iBank, 0x1EU) | SetBits(iBank, 0xE0U) |
SetBits(GetBits(iBank, 0x08U), 0x01U);
ATIPutExtReg(0xB2U, pATI->B2Reg);
}
/*
* ATIV4V5SetRead --
*
* Set an ATI 18800-1's read bank number.
*/
int
ATIV4V5SetRead
(
ScreenPtr pScreen,
unsigned int iBank
)
{
ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen));
CARD8 B2Reg = (pATI->B2Reg & 0x1EU) | SetBits(iBank, 0xE0U) |
SetBits(GetBits(iBank, 0x08U), 0x01U);
if (B2Reg != pATI->B2Reg)
{
ATIPutExtReg(0xB2U, B2Reg);
pATI->B2Reg = B2Reg;
}
return 0;
}
/*
* ATIV4V5SetWrite --
*
* Set an ATI 18800-1's write bank number.
*/
int
ATIV4V5SetWrite
(
ScreenPtr pScreen,
unsigned int iBank
)
{
ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen));
CARD8 B2Reg = (pATI->B2Reg & 0xE1U) | SetBits(iBank, 0x1EU);
if (B2Reg != pATI->B2Reg)
{
ATIPutExtReg(0xB2U, B2Reg);
pATI->B2Reg = B2Reg;
}
return 0;
}
/*
* ATIV4V5SetReadWrite --
*
* Set an ATI 18800-1's read and write bank numbers.
*/
int
ATIV4V5SetReadWrite
(
ScreenPtr pScreen,
unsigned int iBank
)
{
ATIV4V5SetBank(ATIPTR(XF86SCRNINFO(pScreen)), iBank);
return 0;
}
/*
* In addition to ATI extended register index 0xB2, 28800's, 68800's and
* 88800's define banking bits in bits 0x0F of ATI extended VGA register index
* 0xAE. These are only needed for adapters with more than 1MB of video
* memory, and it is questionable whether or not they are actually implemented
* by 28800's and 88800's. ATI extended VGA register index 0xAE is defined as
* follows:
*
* 0xF0 - reserved
* 0x0C - read bank select bits 0x30
* 0x03 - write bank select bits 0x30
*/
/*
* ATIx8800SetBank --
*
* Set an ATI 28800's, 68800's or 88800's read and write bank numbers.
*/
void
ATIx8800SetBank
(
ATIPtr pATI,
unsigned int iBank
)
{
ATIV4V5SetBank(pATI, iBank);
iBank = GetBits(iBank, 0x30U);
ATIModifyExtReg(pATI, 0xAEU, -1, (CARD8)(~0x0FU),
SetBits(iBank, 0x03U) | SetBits(iBank, 0x0CU));
}
/*
* ATIx8800SetRead --
*
* Set an ATI 28800's, 68800's or 88800's read bank numbers.
*/
int
ATIx8800SetRead
(
ScreenPtr pScreen,
unsigned int iBank
)
{
(void)ATIV4V5SetRead(pScreen, iBank);
ATIModifyExtReg(ATIPTR(XF86SCRNINFO(pScreen)), 0xAEU, -1, (CARD8)(~0x0CU),
SetBits(GetBits(iBank, 0x30U), 0x0CU));
return 0;
}
/*
* ATIx8800SetWrite --
*
* Set an ATI 28800's, 68800's or 88800's write bank numbers.
*/
int
ATIx8800SetWrite
(
ScreenPtr pScreen,
unsigned int iBank
)
{
(void)ATIV4V5SetWrite(pScreen, iBank);
ATIModifyExtReg(ATIPTR(XF86SCRNINFO(pScreen)), 0xAEU, -1, (CARD8)(~0x03U),
SetBits(GetBits(iBank, 0x30U), 0x03U));
return 0;
}
/*
* ATIx8800SetReadWrite --
*
* Set an ATI 28800's, 68800's or 88800's read and write bank numbers.
*/
int
ATIx8800SetReadWrite
(
ScreenPtr pScreen,
unsigned int iBank
)
{
ATIx8800SetBank(ATIPTR(XF86SCRNINFO(pScreen)), iBank);
return 0;
}
/*
* Functions to simulate a banked VGA aperture using a Mach64's small dual
* paged apertures. There are two sets of these: one for packed modes, the
* other for planar modes.
*/
static CARD32
ATIMach64MassagePackedBankNumber
(
CARD8 iBank
)
{
iBank <<= 1;
return ((iBank + 1) << 16) | iBank;
}
/*
* ATIMach64SetBankPacked --
*
* Set read and write bank numbers for small dual paged apertures.
*/
void
ATIMach64SetBankPacked
(
ATIPtr pATI,
unsigned int iBank
)
{
CARD32 tmp = ATIMach64MassagePackedBankNumber(iBank);
outr(MEM_VGA_RP_SEL, tmp);
outr(MEM_VGA_WP_SEL, tmp);
}
/*
* ATIMach64SetReadPacked --
*
* Set read bank number for small dual paged apertures.
*/
int
ATIMach64SetReadPacked
(
ScreenPtr pScreen,
unsigned int iBank
)
{
ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen));
outr(MEM_VGA_RP_SEL, ATIMach64MassagePackedBankNumber(iBank));
return 0;
}
/*
* ATIMach64SetWritePacked --
*
* Set write bank number for small dual paged apertures.
*/
int
ATIMach64SetWritePacked
(
ScreenPtr pScreen,
unsigned int iBank
)
{
ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen));
outr(MEM_VGA_WP_SEL, ATIMach64MassagePackedBankNumber(iBank));
return 0;
}
/*
* ATIMach64SetReadWritePacked --
*
* Set read and write bank numbers for small dual paged apertures.
*/
int
ATIMach64SetReadWritePacked
(
ScreenPtr pScreen,
unsigned int iBank
)
{
ATIMach64SetBankPacked(ATIPTR(XF86SCRNINFO(pScreen)), iBank);
return 0;
}
static CARD32
ATIMach64MassagePlanarBankNumber
(
CARD8 iBank
)
{
iBank <<= 3;
return ((iBank + 4) << 16) | iBank;
}
/*
* ATIMach64SetBankPlanar --
*
* Set read and write bank numbers for small dual paged apertures.
*/
void
ATIMach64SetBankPlanar
(
ATIPtr pATI,
unsigned int iBank
)
{
CARD32 tmp = ATIMach64MassagePlanarBankNumber(iBank);
outr(MEM_VGA_RP_SEL, tmp);
outr(MEM_VGA_WP_SEL, tmp);
}
/*
* ATIMach64SetReadPlanar --
*
* Set read bank number for small dual paged apertures.
*/
int
ATIMach64SetReadPlanar
(
ScreenPtr pScreen,
unsigned int iBank
)
{
ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen));
outr(MEM_VGA_RP_SEL, ATIMach64MassagePlanarBankNumber(iBank));
return 0;
}
/*
* ATIMach64SetWritePlanar --
*
* Set write bank number for small dual paged apertures.
*/
int
ATIMach64SetWritePlanar
(
ScreenPtr pScreen,
unsigned int iBank
)
{
ATIPtr pATI = ATIPTR(XF86SCRNINFO(pScreen));
outr(MEM_VGA_WP_SEL, ATIMach64MassagePlanarBankNumber(iBank));
return 0;
}
/*
* ATIMach64SetReadWritePlanar --
*
* Set read and write bank numbers for small dual paged apertures.
*/
int
ATIMach64SetReadWritePlanar
(
ScreenPtr pScreen,
unsigned int iBank
)
{
ATIMach64SetBankPlanar(ATIPTR(XF86SCRNINFO(pScreen)), iBank);
return 0;
}
#endif /* AVOID_CPIO */
|