1 /* Greetings text left due to code "borrowed" from XFree86 project */
4 * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
5 * VA Linux Systems Inc., Fremont, California.
9 * Permission is hereby granted, free of charge, to any person obtaining
10 * a copy of this software and associated documentation files (the
11 * "Software"), to deal in the Software without restriction, including
12 * without limitation on the rights to use, copy, modify, merge,
13 * publish, distribute, sublicense, and/or sell copies of the Software,
14 * and to permit persons to whom the Software is furnished to do so,
15 * subject to the following conditions:
17 * The above copyright notice and this permission notice (including the
18 * next paragraph) shall be included in all copies or substantial
19 * portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR
25 * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
33 * Kevin E. Martin <martin@xfree86.org>
34 * Rickard E. Faith <faith@valinux.com>
35 * Alan Hourihane <alanh@fairlite.demon.co.uk>
40 * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical
41 * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April
45 * RAGE 128 Software Development Manual (Technical Reference Manual P/N
46 * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999.
51 #include <aros/macros.h>
53 #ifndef _RADEON_MACROS_H_
54 #define _RADEON_MACROS_H_
56 #define RADEONMMIO (sd->Card.MMIO)
58 #define RADEON_BIOS8(v) (sd->Card.VBIOS[v])
59 #define RADEON_BIOS16(v) (sd->Card.VBIOS[v] | \
60 (sd->Card.VBIOS[(v) + 1] << 8))
61 #define RADEON_BIOS32(v) (sd->Card.VBIOS[v] | \
62 (sd->Card.VBIOS[(v) + 1] << 8) | \
63 (sd->Card.VBIOS[(v) + 2] << 16) | \
64 (sd->Card.VBIOS[(v) + 3] << 24))
66 /* Memory mapped register access macros */
67 #define INREG8(addr) (*(volatile UBYTE*)((UBYTE*)(RADEONMMIO)+(addr)))
68 #define INREG16(addr) AROS_LE2WORD((*(volatile UWORD*)((UBYTE*)(RADEONMMIO)+(addr))))
69 #define INREG(addr) AROS_LE2LONG((*(volatile ULONG*)((UBYTE*)(RADEONMMIO)+(addr))))
70 #define OUTREG8(addr, val) (*(volatile UBYTE*)((UBYTE*)(RADEONMMIO)+(addr)) = (val))
71 #define OUTREG16(addr, val) (*(volatile UWORD*)((UBYTE*)(RADEONMMIO)+(addr)) = AROS_WORD2LE((val)))
72 #define OUTREG(addr, val) (*(volatile ULONG*)((UBYTE*)(RADEONMMIO)+(addr)) = AROS_LONG2LE((val)))
74 #define ADDRREG(addr) ((volatile ULONG *)(APTR)(RADEONMMIO + (addr)))
76 #define OUTREGP(addr, val, mask) \
78 ULONG tmp = INREG(addr); \
84 #define INPLL(sd, addr) RADEONINPLL(sd, addr)
86 #define OUTPLL(addr, val) \
88 OUTREG8(RADEON_CLOCK_CNTL_INDEX, (((addr) & 0x3f) | \
90 OUTREG(RADEON_CLOCK_CNTL_DATA, val); \
93 #define OUTPLLP(sd, addr, val, mask) \
95 ULONG tmp_ = INPLL(sd, addr); \
101 #define OUTPAL_START(idx) \
103 OUTREG8(RADEON_PALETTE_INDEX, (idx)); \
106 #define OUTPAL_NEXT(r, g, b) \
108 OUTREG(RADEON_PALETTE_DATA, ((r) << 16) | ((g) << 8) | (b)); \
111 #define OUTPAL_NEXT_CARD32(v) \
113 OUTREG(RADEON_PALETTE_DATA, (v & 0x00ffffff)); \
116 #define OUTPAL(idx, r, g, b) \
118 OUTPAL_START((idx)); \
119 OUTPAL_NEXT((r), (g), (b)); \
122 #define INPAL_START(idx) \
124 OUTREG(RADEON_PALETTE_INDEX, (idx) << 16); \
127 #define INPAL_NEXT() INREG(RADEON_PALETTE_DATA)
129 #define PAL_SELECT(idx) \
132 OUTREG(RADEON_DAC_CNTL2, INREG(RADEON_DAC_CNTL2) & \
133 (ULONG)~RADEON_DAC2_PALETTE_ACC_CTL); \
135 OUTREG(RADEON_DAC_CNTL2, INREG(RADEON_DAC_CNTL2) | \
136 RADEON_DAC2_PALETTE_ACC_CTL); \