xref: /haiku/headers/private/graphics/neomagic/nm_macros.h (revision 3f618e4cfd10ba00bf585a37dd73ebc5fe460d63)
10252982aSshatty /* NM registers definitions and macros for access to */
20252982aSshatty 
3ee2288b7Sshatty //old:
40252982aSshatty /* PCI_config_space */
50252982aSshatty #define NMCFG_DEVID        0x00
60252982aSshatty #define NMCFG_DEVCTRL      0x04
70252982aSshatty #define NMCFG_CLASS        0x08
80252982aSshatty #define NMCFG_HEADER       0x0c
90252982aSshatty #define NMCFG_NMBASE2     0x10
100252982aSshatty #define NMCFG_NMBASE1     0x14
110252982aSshatty #define NMCFG_NMBASE3     0x18 // >= MYST
120252982aSshatty #define NMCFG_SUBSYSIDR    0x2c // >= MYST
130252982aSshatty #define NMCFG_ROMBASE      0x30
140252982aSshatty #define NMCFG_CAP_PTR      0x34 // >= MIL2
150252982aSshatty #define NMCFG_INTCTRL      0x3c
160252982aSshatty #define NMCFG_OPTION       0x40
170252982aSshatty #define NMCFG_NM_INDEX    0x44
180252982aSshatty #define NMCFG_NM_DATA     0x48
190252982aSshatty #define NMCFG_SUBSYSIDW    0x4c // >= MYST
200252982aSshatty #define NMCFG_OPTION2      0x50 // >= G100
210252982aSshatty #define NMCFG_OPTION3      0x54 // >= G400
220252982aSshatty #define NMCFG_OPTION4      0x58 // >= G450
230252982aSshatty #define NMCFG_PM_IDENT     0xdc // >= G100
240252982aSshatty #define NMCFG_PM_CSR       0xe0 // >= G100
250252982aSshatty #define NMCFG_AGP_IDENT    0xf0 // >= MIL2
260252982aSshatty #define NMCFG_AGP_STS      0xf4 // >= MIL2
270252982aSshatty #define NMCFG_AGP_CMD      0xf8 // >= MIL2
28ee2288b7Sshatty //end old.
290252982aSshatty 
300252982aSshatty /* neomagic ISA direct registers */
310252982aSshatty /* VGA standard registers: */
320252982aSshatty #define NMISA8_ATTRINDW		0x03c0
330252982aSshatty #define NMISA8_ATTRINDR		0x03c1
340252982aSshatty #define NMISA8_ATTRDATW		0x03c0
350252982aSshatty #define NMISA8_ATTRDATR		0x03c1
360252982aSshatty #define NMISA8_SEQIND		0x03c4
370252982aSshatty #define NMISA8_SEQDAT		0x03c5
380252982aSshatty #define NMISA16_SEQIND		0x03c4
390252982aSshatty #define NMISA8_CRTCIND		0x03d4
400252982aSshatty #define NMISA8_CRTCDAT		0x03d5
410252982aSshatty #define NMISA16_CRTCIND		0x03d4
420252982aSshatty #define NMISA8_GRPHIND		0x03ce
430252982aSshatty #define NMISA8_GRPHDAT		0x03cf
440252982aSshatty #define NMISA16_GRPHIND		0x03ce
450252982aSshatty 
46ee2288b7Sshatty /* neomagic PCI direct registers */
47ee2288b7Sshatty #define NM2PCI8_SEQIND		0x03c4
48ee2288b7Sshatty #define NM2PCI8_SEQDAT		0x03c5
49ee2288b7Sshatty #define NM2PCI16_SEQIND		0x03c4
50ee2288b7Sshatty #define NM2PCI8_GRPHIND		0x03ce
51ee2288b7Sshatty #define NM2PCI8_GRPHDAT		0x03cf
52ee2288b7Sshatty #define NM2PCI16_GRPHIND	0x03ce
53ee2288b7Sshatty 
540252982aSshatty /* neomagic ISA GENERAL direct registers */
550252982aSshatty /* VGA standard registers: */
560252982aSshatty #define NMISA8_MISCW 		0x03c2
570252982aSshatty #define NMISA8_MISCR 		0x03cc
580252982aSshatty #define NMISA8_INSTAT1 		0x03da
590252982aSshatty 
600252982aSshatty /* neomagic ISA (DAC) COLOR direct registers (VGA palette RAM) */
610252982aSshatty /* VGA standard registers: */
620252982aSshatty #define NMISA8_PALMASK		0x03c6
630252982aSshatty #define NMISA8_PALINDR		0x03c7
640252982aSshatty #define NMISA8_PALINDW		0x03c8
650252982aSshatty #define NMISA8_PALDATA		0x03c9
660252982aSshatty 
670252982aSshatty /* neomagic ISA CRTC indexed registers */
680252982aSshatty /* VGA standard registers: */
690252982aSshatty #define NMCRTCX_HTOTAL		0x00
700252982aSshatty #define NMCRTCX_HDISPE		0x01
710252982aSshatty #define NMCRTCX_HBLANKS		0x02
720252982aSshatty #define NMCRTCX_HBLANKE		0x03
730252982aSshatty #define NMCRTCX_HSYNCS		0x04
740252982aSshatty #define NMCRTCX_HSYNCE		0x05
750252982aSshatty #define NMCRTCX_VTOTAL		0x06
760252982aSshatty #define NMCRTCX_OVERFLOW	0x07
770252982aSshatty #define NMCRTCX_PRROWSCN	0x08
780252982aSshatty #define NMCRTCX_MAXSCLIN	0x09
790252982aSshatty #define NMCRTCX_VGACURCTRL	0x0a
800252982aSshatty #define NMCRTCX_FBSTADDH	0x0c
810252982aSshatty #define NMCRTCX_FBSTADDL	0x0d
820252982aSshatty #define NMCRTCX_VSYNCS		0x10
830252982aSshatty #define NMCRTCX_VSYNCE		0x11
840252982aSshatty #define NMCRTCX_VDISPE		0x12
850252982aSshatty #define NMCRTCX_PITCHL		0x13
860252982aSshatty #define NMCRTCX_VBLANKS		0x15
870252982aSshatty #define NMCRTCX_VBLANKE		0x16
880252982aSshatty #define NMCRTCX_MODECTL		0x17
890252982aSshatty #define NMCRTCX_LINECOMP	0x18
900252982aSshatty /* NeoMagic specific registers: */
910252982aSshatty #define NMCRTCX_VEXT		0x70 /* >= NM2200 */
920252982aSshatty 
930252982aSshatty /* neomagic ISA SEQUENCER indexed registers */
940252982aSshatty /* VGA standard registers: */
950252982aSshatty #define NMSEQX_RESET		0x00
960252982aSshatty #define NMSEQX_CLKMODE		0x01
970252982aSshatty #define NMSEQX_MEMMODE		0x04
98ee2288b7Sshatty /* NeoMagic BES registers: (> NM2070) (accessible via mapped I/O: >= NM2097) */
99ee2288b7Sshatty #define NMSEQX_BESCTRL2		0x08
100ee2288b7Sshatty #define NMSEQX_0x09			0x09 //??
101ee2288b7Sshatty #define NMSEQX_0x0a			0x0a //??
102ee2288b7Sshatty #define NMSEQX_BUF2ORGL		0x0c
103ee2288b7Sshatty #define NMSEQX_BUF2ORGM		0x0d
104ee2288b7Sshatty #define NMSEQX_BUF2ORGH		0x0e
105ee2288b7Sshatty #define NMSEQX_VSCOORD1L	0x14 /* >= NM2200(?), so clipping done via buffer startadress instead */
106ee2288b7Sshatty #define NMSEQX_VSCOORD2L	0x15 /* >= NM2200(?), so clipping done via buffer startadress instead */
107ee2288b7Sshatty #define NMSEQX_VSCOORD21H	0x16 /* >= NM2200(?), so clipping done via buffer startadress instead */
108ee2288b7Sshatty #define NMSEQX_HSCOORD1L	0x17 /* >= NM2200(?), so clipping done via buffer startadress instead */
109ee2288b7Sshatty #define NMSEQX_HSCOORD2L	0x18 /* >= NM2200(?), so clipping done via buffer startadress instead */
110ee2288b7Sshatty #define NMSEQX_HSCOORD21H	0x19 /* >= NM2200(?), so clipping done via buffer startadress instead */
111ee2288b7Sshatty #define NMSEQX_BUF2PITCHL	0x1a
112ee2288b7Sshatty #define NMSEQX_BUF2PITCHH	0x1b
113ee2288b7Sshatty #define NMSEQX_0x1c			0x1c //??
114ee2288b7Sshatty #define NMSEQX_0x1d			0x1d //??
115ee2288b7Sshatty #define NMSEQX_0x1e			0x1e //??
116ee2288b7Sshatty #define NMSEQX_0x1f			0x1f //??
1170252982aSshatty 
1180252982aSshatty /* neomagic ISA ATTRIBUTE indexed registers */
1190252982aSshatty /* VGA standard registers: */
1200252982aSshatty #define NMATBX_MODECTL		0x10
1210252982aSshatty #define NMATBX_OSCANCOLOR	0x11
1220252982aSshatty #define NMATBX_COLPLANE_EN	0x12
1230252982aSshatty #define NMATBX_HORPIXPAN	0x13
1240252982aSshatty #define NMATBX_COLSEL		0x14
1250252982aSshatty 
1260252982aSshatty /* neomagic ISA GRAPHICS indexed registers */
1270252982aSshatty /* VGA standard registers: */
1280252982aSshatty #define NMGRPHX_ENSETRESET	0x01
1290252982aSshatty #define NMGRPHX_DATAROTATE	0x03
1300252982aSshatty #define NMGRPHX_READMAPSEL	0x04
1310252982aSshatty #define NMGRPHX_MODE		0x05
1320252982aSshatty #define NMGRPHX_MISC		0x06
1330252982aSshatty #define NMGRPHX_BITMASK		0x08
1340252982aSshatty /* NeoMagic specific registers: */
1350252982aSshatty #define NMGRPHX_GRPHXLOCK	0x09
1360252982aSshatty #define NMGRPHX_GENLOCK		0x0a
1370252982aSshatty #define NMGRPHX_FBSTADDE	0x0e
1380252982aSshatty #define NMGRPHX_CRTC_PITCHE	0x0f
1390252982aSshatty #define NMGRPHX_IFACECTRL	0x11
1400252982aSshatty #define NMGRPHX_PANELCTRL1	0x20
1410252982aSshatty #define NMGRPHX_PANELTYPE	0x21
1420252982aSshatty #define NMGRPHX_PANELCTRL2	0x25
1430252982aSshatty #define NMGRPHX_PANELVCENT1	0x28
1440252982aSshatty #define NMGRPHX_PANELVCENT2	0x29
1450252982aSshatty #define NMGRPHX_PANELVCENT3	0x2a
1460252982aSshatty #define NMGRPHX_PANELCTRL3	0x30 /* > NM2070 */
1470252982aSshatty #define NMGRPHX_PANELVCENT4	0x32 /* > NM2070 */
1480252982aSshatty #define NMGRPHX_PANELHCENT1	0x33 /* > NM2070 */
1490252982aSshatty #define NMGRPHX_PANELHCENT2	0x34 /* > NM2070 */
1500252982aSshatty #define NMGRPHX_PANELHCENT3	0x35 /* > NM2070 */
1510252982aSshatty #define NMGRPHX_PANELHCENT4	0x36 /* >= NM2160 */
1520252982aSshatty #define NMGRPHX_PANELVCENT5	0x37 /* >= NM2200 */
1530252982aSshatty #define NMGRPHX_PANELHCENT5	0x38 /* >= NM2200 */
1540252982aSshatty #define NMGRPHX_CURCTRL		0x82
1550252982aSshatty #define NMGRPHX_COLDEPTH	0x90
1560252982aSshatty /* (NeoMagic pixelPLL set C registers) */
1570252982aSshatty #define NMGRPHX_PLLC_NL		0x9b
1580252982aSshatty #define NMGRPHX_PLLC_NH		0x8f /* >= NM2200 */
1590252982aSshatty #define NMGRPHX_PLLC_M		0x9f
160ee2288b7Sshatty /* NeoMagic BES registers: (> NM2070) (accessible via mapped I/O: >= NM2097) */
161ee2288b7Sshatty #define NMGRPHX_BESCTRL1	0xb0
162ee2288b7Sshatty #define NMGRPHX_HDCOORD21H	0xb1
163ee2288b7Sshatty #define NMGRPHX_HDCOORD1L	0xb2
164ee2288b7Sshatty #define NMGRPHX_HDCOORD2L	0xb3
165ee2288b7Sshatty #define NMGRPHX_VDCOORD21H	0xb4
166ee2288b7Sshatty #define NMGRPHX_VDCOORD1L	0xb5
167ee2288b7Sshatty #define NMGRPHX_VDCOORD2L	0xb6
168ee2288b7Sshatty #define NMGRPHX_BUF1ORGH	0xb7
169ee2288b7Sshatty #define NMGRPHX_BUF1ORGM	0xb8
170ee2288b7Sshatty #define NMGRPHX_BUF1ORGL	0xb9
171ee2288b7Sshatty #define NMGRPHX_BUF1PITCHH	0xba
172ee2288b7Sshatty #define NMGRPHX_BUF1PITCHL	0xbb
173ee2288b7Sshatty #define NMGRPHX_0xbc		0xbc //??
174ee2288b7Sshatty #define NMGRPHX_0xbd		0xbd //??
175ee2288b7Sshatty #define NMGRPHX_0xbe		0xbe //??
176ee2288b7Sshatty #define NMGRPHX_0xbf		0xbf //??
177ee2288b7Sshatty #define NMGRPHX_XSCALEH		0xc0
178ee2288b7Sshatty #define NMGRPHX_XSCALEL		0xc1
179ee2288b7Sshatty #define NMGRPHX_YSCALEH		0xc2
180ee2288b7Sshatty #define NMGRPHX_YSCALEL		0xc3
181ee2288b7Sshatty #define NMGRPHX_BRIGHTNESS	0xc4
182ee2288b7Sshatty #define NMGRPHX_COLKEY_R	0xc5
183ee2288b7Sshatty #define NMGRPHX_COLKEY_G	0xc6
184ee2288b7Sshatty #define NMGRPHX_COLKEY_B	0xc7
1850252982aSshatty 
1860252982aSshatty /* NeoMagic specific PCI cursor registers < NM2200 */
1870252982aSshatty #define NMCR1_CURCTRL    		0x0100
1880252982aSshatty #define NMCR1_CURX       		0x0104
1890252982aSshatty #define NMCR1_CURY       		0x0108
1900252982aSshatty #define NMCR1_CURBGCOLOR		0x010c
1910252982aSshatty #define NMCR1_CURFGCOLOR 		0x0110
1920252982aSshatty #define NMCR1_CURADDRESS		0x0114
1930252982aSshatty /* NeoMagic specific PCI cursor registers >= NM2200 */
1940252982aSshatty #define NMCR1_22CURCTRL   		0x1000
1950252982aSshatty #define NMCR1_22CURX      		0x1004
1960252982aSshatty #define NMCR1_22CURY      		0x1008
1970252982aSshatty #define NMCR1_22CURBGCOLOR		0x100c
1980252982aSshatty #define NMCR1_22CURFGCOLOR   	0x1010
1990252982aSshatty #define NMCR1_22CURADDRESS		0x1014
2000252982aSshatty 
201*3f618e4cSRudolf Cornelissen /* NeoMagic PCI acceleration registers */
202*3f618e4cSRudolf Cornelissen #define NMACC_STATUS			0x0000
203*3f618e4cSRudolf Cornelissen #define NMACC_BLTCNTL			0x0004
204*3f618e4cSRudolf Cornelissen #define NMACC_SRCSTARTOFF		0x0024
205*3f618e4cSRudolf Cornelissen #define NMACC_DSTSTARTOFF		0x002c
206*3f618e4cSRudolf Cornelissen #define NMACC_XYEXT				0x0030
207*3f618e4cSRudolf Cornelissen 
2080252982aSshatty 
2090252982aSshatty /* Macros for convenient accesses to the NM chips */
2100252982aSshatty 
211ee2288b7Sshatty /* primary PCI register area */
2120252982aSshatty #define NM_REG8(r_)  ((vuint8  *)regs)[(r_)]
213ee2288b7Sshatty #define NM_REG16(r_) ((vuint16 *)regs)[(r_) >> 1]
2140252982aSshatty #define NM_REG32(r_) ((vuint32 *)regs)[(r_) >> 2]
215ee2288b7Sshatty /* secondary PCI register area */
216ee2288b7Sshatty #define NM_2REG8(r_)  ((vuint8  *)regs2)[(r_)]
217ee2288b7Sshatty #define NM_2REG16(r_) ((vuint16 *)regs2)[(r_) >> 1]
218ee2288b7Sshatty #define NM_2REG32(r_) ((vuint32 *)regs2)[(r_) >> 2]
2190252982aSshatty 
2200252982aSshatty /* read and write to PCI config space */
221a5130410SRudolf Cornelissen #define CFGR(A)   (nm_pci_access.offset=NMCFG_##A, ioctl(fd,NM_GET_PCI, &nm_pci_access,sizeof(nm_pci_access)), nm_pci_access.value)
222a5130410SRudolf Cornelissen #define CFGW(A,B) (nm_pci_access.offset=NMCFG_##A, nm_pci_access.value = B, ioctl(fd,NM_SET_PCI,&nm_pci_access,sizeof(nm_pci_access)))
2230252982aSshatty 
224*3f618e4cSRudolf Cornelissen /* read and write from acceleration engine */
2250252982aSshatty #define ACCR(A)   (NM_REG32(NMACC_##A))
226*3f618e4cSRudolf Cornelissen #define ACCW(A,B) (NM_REG32(NMACC_##A) = (B))
2270252982aSshatty 
2280252982aSshatty /* read and write from first CRTC (mapped) */
2290252982aSshatty #define CR1R(A)   (NM_REG32(NMCR1_##A))
2300252982aSshatty #define CR1W(A,B) (NM_REG32(NMCR1_##A) = (B))
2310252982aSshatty 
2320252982aSshatty /* read and write from ISA I/O space */
233a5130410SRudolf Cornelissen #define ISAWB(A,B)(nm_isa_access.adress=NMISA8_##A, nm_isa_access.data = (uint8)B, nm_isa_access.size = 1, ioctl(fd,NM_ISA_OUT, &nm_isa_access,sizeof(nm_isa_access)))
234a5130410SRudolf Cornelissen #define ISAWW(A,B)(nm_isa_access.adress=NMISA16_##A, nm_isa_access.data = B, nm_isa_access.size = 2, ioctl(fd,NM_ISA_OUT, &nm_isa_access,sizeof(nm_isa_access)))
235a5130410SRudolf Cornelissen #define ISARB(A)  (nm_isa_access.adress=NMISA8_##A, ioctl(fd,NM_ISA_IN, &nm_isa_access,sizeof(nm_isa_access)), (uint8)nm_isa_access.data)
236a5130410SRudolf Cornelissen #define ISARW(A)  (nm_isa_access.adress=NMISA16_##A, ioctl(fd,NM_ISA_IN, &nm_isa_access,sizeof(nm_isa_access)), nm_isa_access.data)
2370252982aSshatty 
2380252982aSshatty /* read and write from ISA CRTC indexed registers */
2390252982aSshatty #define ISACRTCW(A,B)(ISAWW(CRTCIND, ((NMCRTCX_##A) | ((B) << 8))))
2400252982aSshatty #define ISACRTCR(A)  (ISAWB(CRTCIND, (NMCRTCX_##A)), ISARB(CRTCDAT))
2410252982aSshatty 
2420252982aSshatty /* read and write from ISA GRAPHICS indexed registers */
2430252982aSshatty #define ISAGRPHW(A,B)(ISAWW(GRPHIND, ((NMGRPHX_##A) | ((B) << 8))))
2440252982aSshatty #define ISAGRPHR(A)  (ISAWB(GRPHIND, (NMGRPHX_##A)), ISARB(GRPHDAT))
2450252982aSshatty 
246ee2288b7Sshatty /* read and write from PCI GRAPHICS indexed registers (>= NM2097) */
247ee2288b7Sshatty #define PCIGRPHW(A,B)(NM_2REG16(NM2PCI16_GRPHIND) = ((NMGRPHX_##A) | ((B) << 8)))
248ee2288b7Sshatty #define PCIGRPHR(A)  (NM_2REG8(NM2PCI8_GRPHIND) = (NMGRPHX_##A), NM_2REG8(NM2PCI8_GRPHDAT))
249ee2288b7Sshatty 
2500252982aSshatty /* read and write from ISA SEQUENCER indexed registers */
2510252982aSshatty #define ISASEQW(A,B)(ISAWW(SEQIND, ((NMSEQX_##A) | ((B) << 8))))
2520252982aSshatty #define ISASEQR(A)  (ISAWB(SEQIND, (NMSEQX_##A)), ISARB(SEQDAT))
2530252982aSshatty 
254ee2288b7Sshatty /* read and write from PCI SEQUENCER indexed registers (>= NM2097) */
255ee2288b7Sshatty #define PCISEQW(A,B)(NM_2REG16(NM2PCI16_SEQIND) = ((NMSEQX_##A) | ((B) << 8)))
256ee2288b7Sshatty #define PCISEQR(A)  (NM_2REG8(NM2PCI8_SEQIND) = (NMSEQX_##A), NM_2REG8(NM2PCI8_SEQDAT))
257ee2288b7Sshatty 
2580252982aSshatty /* read and write from ISA ATTRIBUTE indexed registers */
2597d2bb07eSshatty #define ISAATBW(A,B)((void)ISARB(INSTAT1), ISAWB(ATTRINDW, ((NMATBX_##A) | 0x20)), ISAWB(ATTRDATW, (B)))
2607d2bb07eSshatty #define ISAATBR(A)  ((void)ISARB(INSTAT1), ISAWB(ATTRINDW, ((NMATBX_##A) | 0x20)), ISARB(ATTRDATR))
261