xref: /haiku/headers/private/graphics/neomagic/nm_macros.h (revision 0252982ab0aa6d36edd80a098ac75c862734b9a5)
1*0252982aSshatty /* NM registers definitions and macros for access to */
2*0252982aSshatty 
3*0252982aSshatty /* PCI_config_space */
4*0252982aSshatty #define NMCFG_DEVID        0x00
5*0252982aSshatty #define NMCFG_DEVCTRL      0x04
6*0252982aSshatty #define NMCFG_CLASS        0x08
7*0252982aSshatty #define NMCFG_HEADER       0x0c
8*0252982aSshatty #define NMCFG_NMBASE2     0x10
9*0252982aSshatty #define NMCFG_NMBASE1     0x14
10*0252982aSshatty #define NMCFG_NMBASE3     0x18 // >= MYST
11*0252982aSshatty #define NMCFG_SUBSYSIDR    0x2c // >= MYST
12*0252982aSshatty #define NMCFG_ROMBASE      0x30
13*0252982aSshatty #define NMCFG_CAP_PTR      0x34 // >= MIL2
14*0252982aSshatty #define NMCFG_INTCTRL      0x3c
15*0252982aSshatty #define NMCFG_OPTION       0x40
16*0252982aSshatty #define NMCFG_NM_INDEX    0x44
17*0252982aSshatty #define NMCFG_NM_DATA     0x48
18*0252982aSshatty #define NMCFG_SUBSYSIDW    0x4c // >= MYST
19*0252982aSshatty #define NMCFG_OPTION2      0x50 // >= G100
20*0252982aSshatty #define NMCFG_OPTION3      0x54 // >= G400
21*0252982aSshatty #define NMCFG_OPTION4      0x58 // >= G450
22*0252982aSshatty #define NMCFG_PM_IDENT     0xdc // >= G100
23*0252982aSshatty #define NMCFG_PM_CSR       0xe0 // >= G100
24*0252982aSshatty #define NMCFG_AGP_IDENT    0xf0 // >= MIL2
25*0252982aSshatty #define NMCFG_AGP_STS      0xf4 // >= MIL2
26*0252982aSshatty #define NMCFG_AGP_CMD      0xf8 // >= MIL2
27*0252982aSshatty 
28*0252982aSshatty //new:
29*0252982aSshatty /* neomagic ISA direct registers */
30*0252982aSshatty /* VGA standard registers: */
31*0252982aSshatty #define NMISA8_ATTRINDW		0x03c0
32*0252982aSshatty #define NMISA8_ATTRINDR		0x03c1
33*0252982aSshatty #define NMISA8_ATTRDATW		0x03c0
34*0252982aSshatty #define NMISA8_ATTRDATR		0x03c1
35*0252982aSshatty #define NMISA8_SEQIND		0x03c4
36*0252982aSshatty #define NMISA8_SEQDAT		0x03c5
37*0252982aSshatty #define NMISA16_SEQIND		0x03c4
38*0252982aSshatty #define NMISA8_CRTCIND		0x03d4
39*0252982aSshatty #define NMISA8_CRTCDAT		0x03d5
40*0252982aSshatty #define NMISA16_CRTCIND		0x03d4
41*0252982aSshatty #define NMISA8_GRPHIND		0x03ce
42*0252982aSshatty #define NMISA8_GRPHDAT		0x03cf
43*0252982aSshatty #define NMISA16_GRPHIND		0x03ce
44*0252982aSshatty 
45*0252982aSshatty /* neomagic ISA GENERAL direct registers */
46*0252982aSshatty /* VGA standard registers: */
47*0252982aSshatty #define NMISA8_MISCW 		0x03c2
48*0252982aSshatty #define NMISA8_MISCR 		0x03cc
49*0252982aSshatty #define NMISA8_INSTAT1 		0x03da
50*0252982aSshatty 
51*0252982aSshatty /* neomagic ISA (DAC) COLOR direct registers (VGA palette RAM) */
52*0252982aSshatty /* VGA standard registers: */
53*0252982aSshatty #define NMISA8_PALMASK		0x03c6
54*0252982aSshatty #define NMISA8_PALINDR		0x03c7
55*0252982aSshatty #define NMISA8_PALINDW		0x03c8
56*0252982aSshatty #define NMISA8_PALDATA		0x03c9
57*0252982aSshatty 
58*0252982aSshatty /* neomagic ISA CRTC indexed registers */
59*0252982aSshatty /* VGA standard registers: */
60*0252982aSshatty #define NMCRTCX_HTOTAL		0x00
61*0252982aSshatty #define NMCRTCX_HDISPE		0x01
62*0252982aSshatty #define NMCRTCX_HBLANKS		0x02
63*0252982aSshatty #define NMCRTCX_HBLANKE		0x03
64*0252982aSshatty #define NMCRTCX_HSYNCS		0x04
65*0252982aSshatty #define NMCRTCX_HSYNCE		0x05
66*0252982aSshatty #define NMCRTCX_VTOTAL		0x06
67*0252982aSshatty #define NMCRTCX_OVERFLOW	0x07
68*0252982aSshatty #define NMCRTCX_PRROWSCN	0x08
69*0252982aSshatty #define NMCRTCX_MAXSCLIN	0x09
70*0252982aSshatty #define NMCRTCX_VGACURCTRL	0x0a
71*0252982aSshatty #define NMCRTCX_FBSTADDH	0x0c
72*0252982aSshatty #define NMCRTCX_FBSTADDL	0x0d
73*0252982aSshatty #define NMCRTCX_VSYNCS		0x10
74*0252982aSshatty #define NMCRTCX_VSYNCE		0x11
75*0252982aSshatty #define NMCRTCX_VDISPE		0x12
76*0252982aSshatty #define NMCRTCX_PITCHL		0x13
77*0252982aSshatty #define NMCRTCX_VBLANKS		0x15
78*0252982aSshatty #define NMCRTCX_VBLANKE		0x16
79*0252982aSshatty #define NMCRTCX_MODECTL		0x17
80*0252982aSshatty #define NMCRTCX_LINECOMP	0x18
81*0252982aSshatty /* NeoMagic specific registers: */
82*0252982aSshatty #define NMCRTCX_VEXT		0x70 /* >= NM2200 */
83*0252982aSshatty 
84*0252982aSshatty /* neomagic ISA SEQUENCER indexed registers */
85*0252982aSshatty /* VGA standard registers: */
86*0252982aSshatty #define NMSEQX_RESET		0x00
87*0252982aSshatty #define NMSEQX_CLKMODE		0x01
88*0252982aSshatty #define NMSEQX_MEMMODE		0x04
89*0252982aSshatty 
90*0252982aSshatty /* neomagic ISA ATTRIBUTE indexed registers */
91*0252982aSshatty /* VGA standard registers: */
92*0252982aSshatty #define NMATBX_MODECTL		0x10
93*0252982aSshatty #define NMATBX_OSCANCOLOR	0x11
94*0252982aSshatty #define NMATBX_COLPLANE_EN	0x12
95*0252982aSshatty #define NMATBX_HORPIXPAN	0x13
96*0252982aSshatty #define NMATBX_COLSEL		0x14
97*0252982aSshatty 
98*0252982aSshatty /* neomagic ISA GRAPHICS indexed registers */
99*0252982aSshatty /* VGA standard registers: */
100*0252982aSshatty #define NMGRPHX_ENSETRESET	0x01
101*0252982aSshatty #define NMGRPHX_DATAROTATE	0x03
102*0252982aSshatty #define NMGRPHX_READMAPSEL	0x04
103*0252982aSshatty #define NMGRPHX_MODE		0x05
104*0252982aSshatty #define NMGRPHX_MISC		0x06
105*0252982aSshatty #define NMGRPHX_BITMASK		0x08
106*0252982aSshatty /* NeoMagic specific registers: */
107*0252982aSshatty #define NMGRPHX_GRPHXLOCK	0x09
108*0252982aSshatty #define NMGRPHX_GENLOCK		0x0a
109*0252982aSshatty #define NMGRPHX_FBSTADDE	0x0e
110*0252982aSshatty #define NMGRPHX_CRTC_PITCHE	0x0f
111*0252982aSshatty #define NMGRPHX_IFACECTRL	0x11
112*0252982aSshatty #define NMGRPHX_PANELCTRL1	0x20
113*0252982aSshatty #define NMGRPHX_PANELTYPE	0x21
114*0252982aSshatty #define NMGRPHX_PANELCTRL2	0x25
115*0252982aSshatty #define NMGRPHX_PANELVCENT1	0x28
116*0252982aSshatty #define NMGRPHX_PANELVCENT2	0x29
117*0252982aSshatty #define NMGRPHX_PANELVCENT3	0x2a
118*0252982aSshatty #define NMGRPHX_PANELCTRL3	0x30 /* > NM2070 */
119*0252982aSshatty #define NMGRPHX_PANELVCENT4	0x32 /* > NM2070 */
120*0252982aSshatty #define NMGRPHX_PANELHCENT1	0x33 /* > NM2070 */
121*0252982aSshatty #define NMGRPHX_PANELHCENT2	0x34 /* > NM2070 */
122*0252982aSshatty #define NMGRPHX_PANELHCENT3	0x35 /* > NM2070 */
123*0252982aSshatty #define NMGRPHX_PANELHCENT4	0x36 /* >= NM2160 */
124*0252982aSshatty #define NMGRPHX_PANELVCENT5	0x37 /* >= NM2200 */
125*0252982aSshatty #define NMGRPHX_PANELHCENT5	0x38 /* >= NM2200 */
126*0252982aSshatty #define NMGRPHX_CURCTRL		0x82
127*0252982aSshatty #define NMGRPHX_COLDEPTH	0x90
128*0252982aSshatty /* (NeoMagic pixelPLL set C registers) */
129*0252982aSshatty #define NMGRPHX_PLLC_NL		0x9b
130*0252982aSshatty #define NMGRPHX_PLLC_NH		0x8f /* >= NM2200 */
131*0252982aSshatty #define NMGRPHX_PLLC_M		0x9f
132*0252982aSshatty 
133*0252982aSshatty /* NeoMagic specific PCI cursor registers < NM2200 */
134*0252982aSshatty #define NMCR1_CURCTRL    		0x0100
135*0252982aSshatty #define NMCR1_CURX       		0x0104
136*0252982aSshatty #define NMCR1_CURY       		0x0108
137*0252982aSshatty #define NMCR1_CURBGCOLOR		0x010c
138*0252982aSshatty #define NMCR1_CURFGCOLOR 		0x0110
139*0252982aSshatty #define NMCR1_CURADDRESS		0x0114
140*0252982aSshatty /* NeoMagic specific PCI cursor registers >= NM2200 */
141*0252982aSshatty #define NMCR1_22CURCTRL   		0x1000
142*0252982aSshatty #define NMCR1_22CURX      		0x1004
143*0252982aSshatty #define NMCR1_22CURY      		0x1008
144*0252982aSshatty #define NMCR1_22CURBGCOLOR		0x100c
145*0252982aSshatty #define NMCR1_22CURFGCOLOR   	0x1010
146*0252982aSshatty #define NMCR1_22CURADDRESS		0x1014
147*0252982aSshatty //end new.
148*0252982aSshatty 
149*0252982aSshatty /* NM ACCeleration registers */
150*0252982aSshatty #define NMACC_DWGCTL          0x1C00
151*0252982aSshatty #define NMACC_MACCESS         0x1C04
152*0252982aSshatty #define NMACC_MCTLWTST        0x1C08
153*0252982aSshatty #define NMACC_ZORG            0x1C0C
154*0252982aSshatty #define NMACC_PLNWT           0x1C1C
155*0252982aSshatty #define NMACC_BCOL            0x1C20
156*0252982aSshatty #define NMACC_FCOL            0x1C24
157*0252982aSshatty #define NMACC_XYSTRT          0x1C40
158*0252982aSshatty #define NMACC_XYEND           0x1C44
159*0252982aSshatty #define NMACC_SGN             0x1C58
160*0252982aSshatty #define NMACC_LEN             0x1C5C
161*0252982aSshatty #define NMACC_AR0             0x1C60
162*0252982aSshatty #define NMACC_AR3             0x1C6C
163*0252982aSshatty #define NMACC_AR5             0x1C74
164*0252982aSshatty #define NMACC_CXBNDRY         0x1C80
165*0252982aSshatty #define NMACC_FXBNDRY         0x1C84
166*0252982aSshatty #define NMACC_YDSTLEN         0x1C88
167*0252982aSshatty #define NMACC_PITCH           0x1C8C
168*0252982aSshatty #define NMACC_YDST            0x1C90
169*0252982aSshatty #define NMACC_YDSTORG         0x1C94
170*0252982aSshatty #define NMACC_YTOP            0x1C98
171*0252982aSshatty #define NMACC_YBOT            0x1C9C
172*0252982aSshatty #define NMACC_CXLEFT          0x1CA0
173*0252982aSshatty #define NMACC_CXRIGHT         0x1CA4
174*0252982aSshatty #define NMACC_FXLEFT          0x1CA8
175*0252982aSshatty #define NMACC_FXRIGHT         0x1CAC
176*0252982aSshatty #define NMACC_STATUS          0x1E14
177*0252982aSshatty #define NMACC_ICLEAR          0x1E18 /* required for interrupt stuff */
178*0252982aSshatty #define NMACC_IEN             0x1E1C /* required for interrupt stuff */
179*0252982aSshatty #define NMACC_RST             0x1E40
180*0252982aSshatty #define NMACC_MEMRDBK         0x1E44
181*0252982aSshatty #define NMACC_OPMODE          0x1E54
182*0252982aSshatty #define NMACC_PRIMADDRESS     0x1E58
183*0252982aSshatty #define NMACC_PRIMEND         0x1E5C
184*0252982aSshatty #define NMACC_TEXORG          0x2C24 // >= G100
185*0252982aSshatty #define NMACC_DWGSYNC         0x2C4C // >= G200
186*0252982aSshatty #define NMACC_TEXORG1         0x2CA4 // >= G200
187*0252982aSshatty #define NMACC_TEXORG2         0x2CA8 // >= G200
188*0252982aSshatty #define NMACC_TEXORG3         0x2CAC // >= G200
189*0252982aSshatty #define NMACC_TEXORG4         0x2CB0 // >= G200
190*0252982aSshatty #define NMACC_SRCORG          0x2CB4 // >= G200
191*0252982aSshatty #define NMACC_DSTORG          0x2CB8 // >= G200
192*0252982aSshatty 
193*0252982aSshatty /*NM BES (Back End Scaler) registers (>= G200) */
194*0252982aSshatty #define NMBES_A1ORG           0x3D00
195*0252982aSshatty #define NMBES_A2ORG           0x3D04
196*0252982aSshatty #define NMBES_B1ORG           0x3D08
197*0252982aSshatty #define NMBES_B2ORG           0x3D0C
198*0252982aSshatty #define NMBES_A1CORG          0x3D10
199*0252982aSshatty #define NMBES_A2CORG          0x3D14
200*0252982aSshatty #define NMBES_B1CORG          0x3D18
201*0252982aSshatty #define NMBES_B2CORG          0x3D1C
202*0252982aSshatty #define NMBES_CTL             0x3D20
203*0252982aSshatty #define NMBES_PITCH           0x3D24
204*0252982aSshatty #define NMBES_HCOORD          0x3D28
205*0252982aSshatty #define NMBES_VCOORD          0x3D2C
206*0252982aSshatty #define NMBES_HISCAL          0x3D30
207*0252982aSshatty #define NMBES_VISCAL          0x3D34
208*0252982aSshatty #define NMBES_HSRCST          0x3D38
209*0252982aSshatty #define NMBES_HSRCEND         0x3D3C
210*0252982aSshatty #define NMBES_LUMACTL         0x3D40
211*0252982aSshatty #define NMBES_V1WGHT          0x3D48
212*0252982aSshatty #define NMBES_V2WGHT          0x3D4C
213*0252982aSshatty #define NMBES_HSRCLST         0x3D50
214*0252982aSshatty #define NMBES_V1SRCLST        0x3D54
215*0252982aSshatty #define NMBES_V2SRCLST        0x3D58
216*0252982aSshatty #define NMBES_A1C3ORG         0x3D60
217*0252982aSshatty #define NMBES_A2C3ORG         0x3D64
218*0252982aSshatty #define NMBES_B1C3ORG         0x3D68
219*0252982aSshatty #define NMBES_B2C3ORG         0x3D6C
220*0252982aSshatty #define NMBES_GLOBCTL         0x3DC0
221*0252982aSshatty #define NMBES_STATUS          0x3DC4
222*0252982aSshatty 
223*0252982aSshatty /* Macros for convenient accesses to the NM chips */
224*0252982aSshatty 
225*0252982aSshatty #define NM_REG8(r_)  ((vuint8  *)regs)[(r_)]
226*0252982aSshatty #define NM_REG32(r_) ((vuint32 *)regs)[(r_) >> 2]
227*0252982aSshatty 
228*0252982aSshatty /* read and write to PCI config space */
229*0252982aSshatty #define CFGR(A)   (mn_pci_access.offset=NMCFG_##A, ioctl(fd,MN_GET_PCI, &mn_pci_access,sizeof(mn_pci_access)), mn_pci_access.value)
230*0252982aSshatty #define CFGW(A,B) (mn_pci_access.offset=NMCFG_##A, mn_pci_access.value = B, ioctl(fd,MN_SET_PCI,&mn_pci_access,sizeof(mn_pci_access)))
231*0252982aSshatty 
232*0252982aSshatty /* read and write from the powergraphics registers */
233*0252982aSshatty #define ACCR(A)    (NM_REG32(NMACC_##A))
234*0252982aSshatty #define ACCW(A,B)  (NM_REG32(NMACC_##A)=B)
235*0252982aSshatty #define ACCGO(A,B) (NM_REG32(NMACC_##A + 0x0100)=B)
236*0252982aSshatty 
237*0252982aSshatty /* read and write from the backend scaler registers */
238*0252982aSshatty #define BESR(A)   (NM_REG32(NMBES_##A))
239*0252982aSshatty #define BESW(A,B) (NM_REG32(NMBES_##A)=B)
240*0252982aSshatty 
241*0252982aSshatty //new:
242*0252982aSshatty /* read and write from first CRTC (mapped) */
243*0252982aSshatty #define CR1R(A)   (NM_REG32(NMCR1_##A))
244*0252982aSshatty #define CR1W(A,B) (NM_REG32(NMCR1_##A) = (B))
245*0252982aSshatty 
246*0252982aSshatty /* read and write from ISA I/O space */
247*0252982aSshatty #define ISAWB(A,B)(mn_isa_access.adress=NMISA8_##A, mn_isa_access.data = (uint8)B, mn_isa_access.size = 1, ioctl(fd,MN_ISA_OUT, &mn_isa_access,sizeof(mn_isa_access)))
248*0252982aSshatty #define ISAWW(A,B)(mn_isa_access.adress=NMISA16_##A, mn_isa_access.data = B, mn_isa_access.size = 2, ioctl(fd,MN_ISA_OUT, &mn_isa_access,sizeof(mn_isa_access)))
249*0252982aSshatty #define ISARB(A)  (mn_isa_access.adress=NMISA8_##A, ioctl(fd,MN_ISA_IN, &mn_isa_access,sizeof(mn_isa_access)), (uint8)mn_isa_access.data)
250*0252982aSshatty #define ISARW(A)  (mn_isa_access.adress=NMISA16_##A, ioctl(fd,MN_ISA_IN, &mn_isa_access,sizeof(mn_isa_access)), mn_isa_access.data)
251*0252982aSshatty 
252*0252982aSshatty /* read and write from ISA CRTC indexed registers */
253*0252982aSshatty #define ISACRTCW(A,B)(ISAWW(CRTCIND, ((NMCRTCX_##A) | ((B) << 8))))
254*0252982aSshatty #define ISACRTCR(A)  (ISAWB(CRTCIND, (NMCRTCX_##A)), ISARB(CRTCDAT))
255*0252982aSshatty 
256*0252982aSshatty /* read and write from ISA GRAPHICS indexed registers */
257*0252982aSshatty #define ISAGRPHW(A,B)(ISAWW(GRPHIND, ((NMGRPHX_##A) | ((B) << 8))))
258*0252982aSshatty #define ISAGRPHR(A)  (ISAWB(GRPHIND, (NMGRPHX_##A)), ISARB(GRPHDAT))
259*0252982aSshatty 
260*0252982aSshatty /* read and write from ISA SEQUENCER indexed registers */
261*0252982aSshatty #define ISASEQW(A,B)(ISAWW(SEQIND, ((NMSEQX_##A) | ((B) << 8))))
262*0252982aSshatty #define ISASEQR(A)  (ISAWB(SEQIND, (NMSEQX_##A)), ISARB(SEQDAT))
263*0252982aSshatty 
264*0252982aSshatty /* read and write from ISA ATTRIBUTE indexed registers */
265*0252982aSshatty /* define DUMMY to prevent compiler warnings */
266*0252982aSshatty #define static uint8 DUMMY;
267*0252982aSshatty #define ISAATBW(A,B)(DUMMY = ISARB(INSTAT1), ISAWB(ATTRINDW, ((NMATBX_##A) | 0x20)), ISAWB(ATTRDATW, (B)))
268*0252982aSshatty #define ISAATBR(A)  (DUMMY = ISARB(INSTAT1), ISAWB(ATTRINDW, ((NMATBX_##A) | 0x20)), ISARB(ATTRDATR))
269