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)))
73 #define OUTREGN(addr, val) (*(volatile ULONG*)((UBYTE*)(RADEONMMIO)+(addr)) = (val))
75 #define ADDRREG(addr) ((volatile ULONG *)(APTR)(RADEONMMIO + (addr)))
77 #define OUTREGP(addr, val, mask) \
79 ULONG tmp = INREG(addr); \
85 #define INPLL(sd, addr) RADEONINPLL(sd, addr)
87 #define OUTPLL(addr, val) \
89 OUTREG8(RADEON_CLOCK_CNTL_INDEX, (((addr) & 0x3f) | \
91 OUTREG(RADEON_CLOCK_CNTL_DATA, val); \
94 #define OUTPLLP(sd, addr, val, mask) \
96 ULONG tmp_ = INPLL(sd, addr); \
102 #define OUTPAL_START(idx) \
104 OUTREG8(RADEON_PALETTE_INDEX, (idx)); \
107 #define OUTPAL_NEXT(r, g, b) \
109 OUTREG(RADEON_PALETTE_DATA, ((r) << 16) | ((g) << 8) | (b)); \
112 #define OUTPAL_NEXT_CARD32(v) \
114 OUTREG(RADEON_PALETTE_DATA, (v & 0x00ffffff)); \
117 #define OUTPAL(idx, r, g, b) \
119 OUTPAL_START((idx)); \
120 OUTPAL_NEXT((r), (g), (b)); \
123 #define INPAL_START(idx) \
125 OUTREG(RADEON_PALETTE_INDEX, (idx) << 16); \
128 #define INPAL_NEXT() INREG(RADEON_PALETTE_DATA)
130 #define PAL_SELECT(idx) \
133 OUTREG(RADEON_DAC_CNTL2, INREG(RADEON_DAC_CNTL2) & \
134 (ULONG)~RADEON_DAC2_PALETTE_ACC_CTL); \
136 OUTREG(RADEON_DAC_CNTL2, INREG(RADEON_DAC_CNTL2) | \
137 RADEON_DAC2_PALETTE_ACC_CTL); \