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