Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / dev / video / tga / tga_pci.h
1 /*
2  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
3  * All rights reserved.
4  *
5  * Author: Chris G. Demetriou
6  * 
7  * Permission to use, copy, modify and distribute this software and
8  * its documentation is hereby granted, provided that both the copyright
9  * notice and this permission notice appear in all copies of the
10  * software, derivative works or modified versions, and any portions
11  * thereof, and that both notices appear in supporting documentation.
12  * 
13  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 
14  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 
15  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16  * 
17  * Carnegie Mellon requests users of this software to return to
18  *
19  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
20  *  School of Computer Science
21  *  Carnegie Mellon University
22  *  Pittsburgh PA 15213-3890
23  *
24  * any improvements or extensions that they make and grant Carnegie the
25  * rights to redistribute these changes.
26  *
27  * Copyright (c) 2000 Andrew Miklic
28  *
29  * $FreeBSD: src/sys/dev/tga/tga_pci.h,v 1.1.2.1 2001/11/01 08:33:15 obrien Exp $
30  */
31
32 #ifndef _PCI_TGA_H_
33 #define _PCI_TGA_H_
34
35 /*
36  * Device-specific PCI register offsets and contents.
37  */
38 #define TGA_PCIREG_PVRR 0x40            /* PCI Address Extension Register */
39 #define TGA_PCIREG_PAER 0x44            /* PCI VGA Redirect Register */
40
41 /*
42  * TGA Memory Space offsets
43  */
44 #define TGA_MEM_ALTROM  0x0000000       /* 0MB -- Alternate ROM space */
45 #define TGA2_MEM_EXTDEV 0x0000000       /* 0MB -- External Device Access */
46 #define TGA_MEM_CREGS   0x0100000       /* 1MB -- Core Registers */
47 #define TGA_CREGS_SIZE  0x0100000       /* Core registers occupy 1MB */
48 #define TGA_CREGS_ALIAS 0x0000400       /* Register copies every 1kB */
49
50 #define TGA2_MEM_CLOCK  0x0060000       /* TGA2 Clock access */
51 #define TGA2_MEM_RAMDAC 0x0080000       /* TGA2 RAMDAC access */
52
53 /*
54  * TGA Core Space register numbers and contents.
55  */
56 #define TGA_REG_GCBR0   0x000           /* Copy buffer 0 */
57 #define TGA_REG_GCBR1   0x001           /* Copy buffer 1 */
58 #define TGA_REG_GCBR2   0x002           /* Copy buffer 2 */
59 #define TGA_REG_GCBR3   0x003           /* Copy buffer 3 */
60 #define TGA_REG_GCBR4   0x004           /* Copy buffer 4 */
61 #define TGA_REG_GCBR5   0x005           /* Copy buffer 5 */
62 #define TGA_REG_GCBR6   0x006           /* Copy buffer 6 */
63 #define TGA_REG_GCBR7   0x007           /* Copy buffer 7 */
64
65 #define TGA_REG_GFGR    0x008           /* Foreground */
66 #define TGA_REG_GBGR    0x009           /* Background */
67 #define TGA_REG_GPMR    0x00a           /* Plane Mask */
68 #define TGA_REG_GPXR_S  0x00b           /* Pixel Mask (one-shot) */
69 #define TGA_REG_GMOR    0x00c           /* Mode */
70 #define TGA_REG_GOPR    0x00d           /* Raster Operation */
71 #define TGA_REG_GPSR    0x00e           /* Pixel Shift */
72 #define TGA_REG_GADR    0x00f           /* Address */
73
74 #define TGA_REG_GB1R    0x010           /* Bresenham 1 */
75 #define TGA_REG_GB2R    0x011           /* Bresenham 2 */
76 #define TGA_REG_GB3R    0x012           /* Bresenham 3 */
77
78 #define TGA_REG_GCTR    0x013           /* Continue */
79 #define TGA_REG_GDER    0x014           /* Deep */
80 #define TGA_REG_GREV    0x015           /* Start/Version on TGA,
81                                          * Revision on TGA2 */
82 #define TGA_REG_GSMR    0x016           /* Stencil Mode */
83 #define TGA_REG_GPXR_P  0x017           /* Pixel Mask (persistent) */
84 #define TGA_REG_CCBR    0x018           /* Cursor Base Address */
85 #define TGA_REG_VHCR    0x019           /* Horizontal Control */
86 #define TGA_REG_VVCR    0x01a           /* Vertical Control */
87 #define TGA_REG_VVBR    0x01b           /* Video Base Address */
88 #define TGA_REG_VVVR    0x01c           /* Video Valid */
89 #define TGA_REG_CXYR    0x01d           /* Cursor XY */
90 #define TGA_REG_VSAR    0x01e           /* Video Shift Address */
91 #define TGA_REG_SISR    0x01f           /* Interrupt Status */
92 #define TGA_REG_GDAR    0x020           /* Data */
93 #define TGA_REG_GRIR    0x021           /* Red Increment */
94 #define TGA_REG_GGIR    0x022           /* Green Increment */
95 #define TGA_REG_GBIR    0x023           /* Blue Increment */
96 #define TGA_REG_GZIR_L  0x024           /* Z-increment Low */
97 #define TGA_REG_GZIR_H  0x025           /* Z-Increment High */
98 #define TGA_REG_GDBR    0x026           /* DMA Base Address */
99 #define TGA_REG_GBWR    0x027           /* Bresenham Width */
100 #define TGA_REG_GZVR_L  0x028           /* Z-value Low */
101 #define TGA_REG_GZVR_H  0x029           /* Z-value High */
102 #define TGA_REG_GZBR    0x02a           /* Z-base address */
103 /*      GADR alias      0x02b */
104 #define TGA_REG_GRVR    0x02c           /* Red Value */
105 #define TGA_REG_GGVR    0x02d           /* Green Value */
106 #define TGA_REG_GBVR    0x02e           /* Blue Value */
107 #define TGA_REG_GSWR    0x02f           /* Span Width */
108 #define TGA_REG_EPSR    0x030           /* Pallete and DAC Setup */
109
110 /*      reserved        0x031 - 0x3f */
111
112 #define TGA_REG_GSNR0   0x040           /* Slope-no-go 0 */
113 #define TGA_REG_GSNR1   0x041           /* Slope-no-go 1 */
114 #define TGA_REG_GSNR2   0x042           /* Slope-no-go 2 */
115 #define TGA_REG_GSNR3   0x043           /* Slope-no-go 3 */
116 #define TGA_REG_GSNR4   0x044           /* Slope-no-go 4 */
117 #define TGA_REG_GSNR5   0x045           /* Slope-no-go 5 */
118 #define TGA_REG_GSNR6   0x046           /* Slope-no-go 6 */
119 #define TGA_REG_GSNR7   0x047           /* Slope-no-go 7 */
120
121 #define TGA_REG_GSLR0   0x048           /* Slope 0 */
122 #define TGA_REG_GSLR1   0x049           /* Slope 1 */
123 #define TGA_REG_GSLR2   0x04a           /* Slope 2 */
124 #define TGA_REG_GSLR3   0x04b           /* Slope 3 */
125 #define TGA_REG_GSLR4   0x04c           /* Slope 4 */
126 #define TGA_REG_GSLR5   0x04d           /* Slope 5 */
127 #define TGA_REG_GSLR6   0x04e           /* Slope 6 */
128 #define TGA_REG_GSLR7   0x04f           /* Slope 7 */
129
130 #define TGA_REG_GBCR0   0x050           /* Block Color 0 */
131 #define TGA_REG_GBCR1   0x051           /* Block Color 1 */
132 #define TGA_REG_GBCR2   0x052           /* Block Color 2 */
133 #define TGA_REG_GBCR3   0x053           /* Block Color 3 */
134 #define TGA_REG_GBCR4   0x054           /* Block Color 4 */
135 #define TGA_REG_GBCR5   0x055           /* Block Color 5 */
136 #define TGA_REG_GBCR6   0x056           /* Block Color 6 */
137 #define TGA_REG_GBCR7   0x057           /* Block Color 7 */
138
139 #define TGA_REG_GCSR    0x058           /* Copy 64 Source */
140 #define TGA_REG_GCDR    0x059           /* Copy 64 Destination */
141 /*      GC[SD]R aliases 0x05a - 0x05f */
142
143 /*      reserved        0x060 - 0x077 */
144
145 #define TGA_REG_ERWR    0x078           /* EEPROM write */
146
147 /*      reserved        0x079 */
148
149 #define TGA_REG_ECGR    0x07a           /* Clock */
150
151 /*      reserved        0x07b */
152
153 #define TGA_REG_EPDR    0x07c           /* Pallete and DAC Data */
154
155 /*      reserved        0x07d */
156
157 #define TGA_REG_SCSR    0x07e           /* Command Status */
158
159 /*      reserved        0x07f */
160
161 /*
162  * Deep register
163  */
164 #define GDER_HSS        0x00010000      /* Horizontal sync select */
165 #define GDER_SDAC       0x00004000      /* Slow DAC */
166 #define GDER_RWE        0x00001000      /* ROM write enable */
167 #define GDER_SAMS       0x00000400      /* Serial-access memory size */
168 #define GDER_CS         0x00000200      /* Column size */
169 #define GDER_BLOCK_MASK 0x000001e0      /* eight/four column segments */
170 #define GDER_BLOCK_SHIFT        5
171 #define GDER_ADDR_MASK  0x0000001c      /* PCI address mask */
172 #define GDER_ADDR_SHIFT 2
173 #define GDER_ADDR_4MB   0x00000000      /* PCI mask <24:22> =  4MB */
174 #define GDER_ADDR_8MB   0x00000001      /* PCI mask <24:23> =  8MB */
175 #define GDER_ADDR_16MB  0x00000003      /* PCI mask bit 24  = 16MB */
176 #define GDER_ADDR_32MB  0x00000007      /* No PCI masking   = 32MB */
177 #define GDER_DEEP       0x00000001      /* 32-bpp or 8 bpp frame buffer */
178
179 /*
180  * Graphics mode register
181  */
182 #define GMOR_CE         0x00008000      /* Cap ends */
183 #define GMOR_Z16        0x00004000      /* 16 or 24 bit Z valuesx */
184 #define GMOR_GE         0x00002000      /* Win32 or X environment */
185 #define GMOR_SBY_MASK   0x00001800      /* Source byte mask for 32-bpp FB */
186 #define GMOR_SBY_0      0x00000000      /* Source byte 0 */
187 #define GMOR_SBY_1      0x00000800      /* Source byte 1 */
188 #define GMOR_SBY_2      0x00001000      /* Source byte 2 */
189 #define GMOR_SBY_3      0x00001800      /* Source byte 3 */
190 #define GMOR_SBM_MASK   0x00000700      /* Source bitmap format (32-bpp FB) */
191 #define GMOR_SBM_8P     0x00000000      /* 8-bpp packed */
192 #define GMOR_SBM_8U     0x00000100      /* 8-bpp unpacked */
193 #define GMOR_SBM_12L    0x00000200      /* 12-bpp low */
194 #define GMOR_SBM_12H    0x00000600      /* 12-bpp high */
195 #define GMOR_SBM_24     0x00000300      /* 24-bpp */
196 #define GMOR_MODE_MASK  0x0000007f      /* Graphics mode mask */
197 #define GMOR_MODE_SIMPLE        0x0000  /* Simple */
198 #define GMOR_MODE_SIMPLEZ       0x0010  /* Simple Z */
199 #define GMOR_MODE_OPQ_STPL      0x0001  /* Opaque Stipple */
200 #define GMOR_MODE_OPQ_FILL      0x0021  /* Opaque Fill */
201 #define GMOR_MODE_TRN_STPL      0x0005  /* Transparent Stipple */
202 #define GMOR_MODE_TRN_FILL      0x0025  /* Transparent Fill */
203 #define GMOR_MODE_BLK_STPL      0x000d  /* Block Stipple */
204 #define GMOR_MODE_BLK_FILL      0x002d  /* Block Fill */
205 #define GMOR_MODE_OPQ_LINE      0x0002  /* Opaque Line */
206 #define GMOR_MODE_TRN_LINE      0x0006  /* Transparent Line */
207 #define GMOR_MODE_CITNDL        0x000e  /* Color-interpolated transparent */
208                                         /* non-dithered line */
209 #define GMOR_MODE_CITDL         0x002e  /* Color-intrp. trans. dithered line */
210 #define GMOR_MODE_SITL          0x004e  /* Sequential-intrp. transp line */
211 #define GMOR_MODE_ZOPQ_LINE     0x0012  /* Z buffered Opaque Line */
212 #define GMOR_MODE_ZTRN_LINE     0x0016  /* Z buffered Trans Line */
213 #define GMOR_MODE_ZOCITNDL      0x001a  /* Z buffered Opaque CITND line */
214 #define GMOR_MODE_ZOCITDL       0x003a  /* Z buffered Opaque CITD line */
215 #define GMOR_MODE_ZOSITL        0x005a  /* Z buffered Opaque SIT line */
216 #define GMOR_MODE_ZTCITNDL      0x001e  /* Z buffered transparent CITND line */
217 #define GMOR_MODE_ZTCITDL       0x003e  /* Z buffered transparent CITD line */
218 #define GMOR_MODE_ZTSITL        0x005e  /* Z buffered transparent SIT line */
219 #define GMOR_MODE_COPY          0x0007  /* Copy */
220 #define GMOR_MODE_DRDND         0x0017  /* DMA-read copy, non-dithered */
221 #define GMOR_MODE_DRDD          0x0037  /* DMA-read copy, dithered */
222 #define GMOR_MODE_DWCOPY        0x001f  /* DMA-write copy */
223
224 /*
225  * Video Horizontal Control Register
226  */
227 #define VHCR_ODD        0x80000000      /* Enable 4-pixel line skew */
228 #define VHCR_HSP        0x40000000      /* Horizontal sync polarity */
229 #define VHCR_BPORCH_MASK 0xfe00000      /* Back porch pixels / 4 */
230 #define VHCR_BPORCH_SHIFT       21
231 #define VHCR_HSYNC_MASK 0x001fc000      /* Hsync width / 4 */
232 #define VHCR_HSYNC_SHIFT        14
233 #define VHCR_FPORCH_MASK        0x3e00  /* Front porch pixels / 4 */
234 #define VHCR_FPORCH_SHIFT       9
235 #define VHCR_ACTIVE_MASK        0x01ff  /* Active lines */
236
237 #define VHCR_REG2ACTIVE(reg)    ((((reg) >> 19) & 0x0600) | ((reg) & 0x01ff))
238 #define VHCR_ACTIVE2REG(val)    ((((val) & 0x0600) << 19) | ((val) & 0x01ff))
239
240 /*
241  * Video Vertical Control Register
242  */
243 #define VVCR_SE         0x80000000      /* Stereo Enable */
244 #define VVCR_VSP        0x40000000      /* Vertical sync polarity */
245 #define VVCR_BPORCH_MASK 0xfc00000      /* Back porch in lines */
246 #define VVCR_BPORCH_SHIFT       22
247 #define VVCR_VSYNC_MASK 0x003f0000      /* Vsync width in lines */
248 #define VVCR_VSYNC_SHIFT        16
249 #define VVCR_FPORCH_MASK        0xf800  /* Front porch in lines */
250 #define VVCR_FPORCH_SHIFT       11
251 #define VVCR_ACTIVE_MASK        0x07ff  /* Active lines */
252
253 /*
254  * Video Valid Register
255  */
256 #define VVR_VIDEOVALID  0x00000001      /* 0 VGA, 1 TGA2 (TGA2 only) */
257 #define VVR_BLANK       0x00000002      /* 0 active, 1 blank */
258 #define VVR_CURSOR      0x00000004      /* 0 disable, 1 enable (TGA2 R/O) */
259 #define VVR_INTERLACE   0x00000008      /* 0 N/Int, 1 Int. (TGA2 R/O) */
260 #define VVR_DPMS_MASK   0x00000030      /* See "DMPS mask" below */
261 #define VVR_DPMS_SHIFT  4
262 #define VVR_DDC         0x00000040      /* DDC-in pin value (R/O) */
263 #define VVR_TILED       0x00000400      /* 0 linear, 1 tiled (not on TGA2) */
264 #define VVR_LDDLY_MASK  0x01ff0000      /* load delay in quad pixel clock ticks
265                                            (not on TGA2) */
266 #define VVR_LDDLY_SHIFT 16
267
268 /* TGA PCI register values */
269
270 #define DEC_VENDORID            0x1011
271 #define DEC_DEVICEID_TGA        0x0004
272 #define DEC_DEVICEID_TGA2       0x000D /* This is 0x000C in the documentation,
273                                           but probing yields 0x000D... */
274 #define TGA_TYPE_T8_01          0       /* 8bpp, 1MB */
275 #define TGA_TYPE_T8_02          1       /* 8bpp, 2MB */
276 #define TGA_TYPE_T8_22          2       /* 8bpp, 4MB */
277 #define TGA_TYPE_T8_44          3       /* 8bpp, 8MB */
278 #define TGA_TYPE_T32_04         4       /* 32bpp, 4MB */
279 #define TGA_TYPE_T32_08         5       /* 32bpp, 8MB */
280 #define TGA_TYPE_T32_88         6       /* 32bpp, 16MB */
281 #define TGA2_TYPE_3D30          7       /* 8bpp, 8MB */
282 #define TGA2_TYPE_4D20          8       /* 32bpp, 16MB */
283 #define TGA_TYPE_UNKNOWN        9       /* unknown */
284
285 /* Possible video modes for TGA2... */
286
287 #define TGA2_VGA_MODE           0
288 #define TGA2_2DA_MODE           1
289
290 /* TGA register access macros */
291
292 #define TGA_REG_SPACE_OFFSET            0x100000
293
294 #define BASIC_READ_TGA_REGISTER(adp, reg)                       \
295         *(u_int32_t *)((adp)->va_mem_base +                     \
296                        (vm_offset_t)TGA_REG_SPACE_OFFSET +      \
297                        (((vm_offset_t)(reg) << 2L)))
298
299 #endif /* _PCI_TGA_H_ */