Hint added.
[AROS.git] / workbench / hidds / radeon / radeon_macros.h
blob6ed8832d6b02218d55fe212b59641fb1c4a25ed5
1 /* Greetings text left due to code "borrowed" from XFree86 project */
3 /*
4 * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
5 * VA Linux Systems Inc., Fremont, California.
7 * All Rights Reserved.
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.
32 * Authors:
33 * Kevin E. Martin <martin@xfree86.org>
34 * Rickard E. Faith <faith@valinux.com>
35 * Alan Hourihane <alanh@fairlite.demon.co.uk>
37 * References:
39 * !!!! FIXME !!!!
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
42 * 1999.
44 * !!!! FIXME !!!!
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) \
78 do { \
79 ULONG tmp = INREG(addr); \
80 tmp &= (mask); \
81 tmp |= (val); \
82 OUTREG(addr, tmp); \
83 } while (0)
85 #define INPLL(sd, addr) RADEONINPLL(sd, addr)
87 #define OUTPLL(addr, val) \
88 do { \
89 OUTREG8(RADEON_CLOCK_CNTL_INDEX, (((addr) & 0x3f) | \
90 RADEON_PLL_WR_EN)); \
91 OUTREG(RADEON_CLOCK_CNTL_DATA, val); \
92 } while (0)
94 #define OUTPLLP(sd, addr, val, mask) \
95 do { \
96 ULONG tmp_ = INPLL(sd, addr); \
97 tmp_ &= (mask); \
98 tmp_ |= (val); \
99 OUTPLL(addr, tmp_); \
100 } while (0)
102 #define OUTPAL_START(idx) \
103 do { \
104 OUTREG8(RADEON_PALETTE_INDEX, (idx)); \
105 } while (0)
107 #define OUTPAL_NEXT(r, g, b) \
108 do { \
109 OUTREG(RADEON_PALETTE_DATA, ((r) << 16) | ((g) << 8) | (b)); \
110 } while (0)
112 #define OUTPAL_NEXT_CARD32(v) \
113 do { \
114 OUTREG(RADEON_PALETTE_DATA, (v & 0x00ffffff)); \
115 } while (0)
117 #define OUTPAL(idx, r, g, b) \
118 do { \
119 OUTPAL_START((idx)); \
120 OUTPAL_NEXT((r), (g), (b)); \
121 } while (0)
123 #define INPAL_START(idx) \
124 do { \
125 OUTREG(RADEON_PALETTE_INDEX, (idx) << 16); \
126 } while (0)
128 #define INPAL_NEXT() INREG(RADEON_PALETTE_DATA)
130 #define PAL_SELECT(idx) \
131 do { \
132 if (!idx) { \
133 OUTREG(RADEON_DAC_CNTL2, INREG(RADEON_DAC_CNTL2) & \
134 (ULONG)~RADEON_DAC2_PALETTE_ACC_CTL); \
135 } else { \
136 OUTREG(RADEON_DAC_CNTL2, INREG(RADEON_DAC_CNTL2) | \
137 RADEON_DAC2_PALETTE_ACC_CTL); \
139 } while (0)
142 #endif