cgtworeg.h revision 1.1 1 1.1 eeh /* $NetBSD: cgtworeg.h,v 1.1 1998/06/20 04:58:51 eeh Exp $ */
2 1.1 eeh
3 1.1 eeh /*
4 1.1 eeh * Copyright (c) 1994 Dennis Ferguson
5 1.1 eeh * All rights reserved.
6 1.1 eeh *
7 1.1 eeh * Redistribution and use in source and binary forms, with or without
8 1.1 eeh * modification, are permitted provided that the following conditions
9 1.1 eeh * are met:
10 1.1 eeh * 1. Redistributions of source code must retain the above copyright
11 1.1 eeh * notice, this list of conditions and the following disclaimer.
12 1.1 eeh * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 eeh * notice, this list of conditions and the following disclaimer in the
14 1.1 eeh * documentation and/or other materials provided with the distribution.
15 1.1 eeh *
16 1.1 eeh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1 eeh * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 eeh * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 eeh * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1 eeh * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 1.1 eeh * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 1.1 eeh * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 1.1 eeh * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 1.1 eeh * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 1.1 eeh * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 1.1 eeh */
27 1.1 eeh
28 1.1 eeh /* cgtworeg.h - CG2 colour frame buffer definitions
29 1.1 eeh *
30 1.1 eeh * The mapped memory looks like:
31 1.1 eeh *
32 1.1 eeh * offset contents
33 1.1 eeh * 0x000000 bit plane map - 1st (of 8) plane used by the X server in -mono mode
34 1.1 eeh * 0x100000 pixel map - used by the X server in color mode
35 1.1 eeh * 0x200000 raster op mode memory map - unused by X server
36 1.1 eeh * 0x300000 random control registers (lots of spaces in between)
37 1.1 eeh * 0x310000 shadow colour map
38 1.1 eeh */
39 1.1 eeh
40 1.1 eeh /* Frame buffer memory size and depth */
41 1.1 eeh #define CG2_FBSIZE (1024 * 1024)
42 1.1 eeh #define CG2_N_PLANE 8
43 1.1 eeh
44 1.1 eeh /* Screen dimensions */
45 1.1 eeh #define CG2_WIDTH 1152
46 1.1 eeh #define CG2_HEIGHT 900
47 1.1 eeh
48 1.1 eeh /* Colourmap size */
49 1.1 eeh #define CG2_CMSIZE 256
50 1.1 eeh
51 1.1 eeh #define CG2_BITPLANE_OFF 0
52 1.1 eeh #define CG2_BITPLANE_SIZE 0x100000
53 1.1 eeh #define CG2_PIXMAP_OFF (CG2_BITPLANE_OFF + CG2_BITPLANE_SIZE)
54 1.1 eeh #define CG2_PIXMAP_SIZE 0x100000
55 1.1 eeh #define CG2_ROPMEM_OFF (CG2_PIXMAP_OFF + CG2_PIXMAP_SIZE)
56 1.1 eeh #define CG2_ROPMEM_SIZE 0x100000
57 1.1 eeh #define CG2_CTLREG_OFF (CG2_ROPMEM_OFF + CG2_ROPMEM_SIZE)
58 1.1 eeh #define CG2_CTLREG_SIZE 0x010600
59 1.1 eeh #define CG2_MAPPED_SIZE (CG2_CTLREG_OFF + CG2_CTLREG_SIZE)
60 1.1 eeh
61 1.1 eeh
62 1.1 eeh /* arrangement of bit plane mode memory */
63 1.1 eeh union bitplane {
64 1.1 eeh u_short word[CG2_HEIGHT][CG2_WIDTH/(CG2_N_PLANE * sizeof(u_short))];
65 1.1 eeh u_short plane[CG2_FBSIZE/(CG2_N_PLANE * sizeof(u_short))];
66 1.1 eeh };
67 1.1 eeh
68 1.1 eeh /* arrangement of pixel mode memory */
69 1.1 eeh union byteplane {
70 1.1 eeh u_char pixel[CG2_HEIGHT][CG2_WIDTH];
71 1.1 eeh u_char frame[CG2_FBSIZE];
72 1.1 eeh };
73 1.1 eeh
74 1.1 eeh
75 1.1 eeh /*
76 1.1 eeh * Structure describing the first two megabytes of the frame buffer.
77 1.1 eeh * Normal memory maps in bit plane and pixel modes
78 1.1 eeh */
79 1.1 eeh struct cg2memfb {
80 1.1 eeh union bitplane memplane[CG2_N_PLANE]; /* bit plane map */
81 1.1 eeh union byteplane pixplane; /* pixel map */
82 1.1 eeh };
83 1.1 eeh
84 1.1 eeh
85 1.1 eeh /*
86 1.1 eeh * Control/status register. The X server only appears to use update_cmap
87 1.1 eeh * and video_enab.
88 1.1 eeh */
89 1.1 eeh struct cg2statusreg {
90 1.1 eeh u_int reserved : 2; /* not used */
91 1.1 eeh u_int fastread : 1; /* r/o: has some feature I don't understand */
92 1.1 eeh u_int id : 1; /* r/o: ext status and ID registers exist */
93 1.1 eeh u_int resolution : 4; /* screen resolution, 0 means 1152x900 */
94 1.1 eeh u_int retrace : 1; /* r/o: retrace in progress */
95 1.1 eeh u_int inpend : 1; /* r/o: interrupt request */
96 1.1 eeh u_int ropmode : 3; /* ?? */
97 1.1 eeh u_int inten : 1; /* interrupt enable (for end of retrace) */
98 1.1 eeh u_int update_cmap : 1; /* copy/use shadow colour map */
99 1.1 eeh u_int video_enab : 1; /* enable video */
100 1.1 eeh };
101 1.1 eeh
102 1.1 eeh
103 1.1 eeh /*
104 1.1 eeh * Extended status register. Unused by X server
105 1.1 eeh */
106 1.1 eeh struct cg2_extstatus {
107 1.1 eeh u_int gpintreq : 1; /* interrupt request */
108 1.1 eeh u_int gpintdis : 1; /* interrupt disable */
109 1.1 eeh u_int reserved : 13; /* unused */
110 1.1 eeh u_int gpbus : 1; /* bus enabled */
111 1.1 eeh };
112 1.1 eeh
113 1.1 eeh
114 1.1 eeh /*
115 1.1 eeh * Double buffer control register. It appears that (some of?) the
116 1.1 eeh * cg2 cards support a pair of memory sets, referred to as `A' and
117 1.1 eeh * `B', which can be swapped to allow atomic screen updates. This
118 1.1 eeh * controls them.
119 1.1 eeh */
120 1.1 eeh struct dblbufreg {
121 1.1 eeh u_int display_b : 1; /* display memory B (set) or A (reset) */
122 1.1 eeh u_int read_b : 1; /* accesss memory B (set) or A (reset) */
123 1.1 eeh u_int nowrite_b : 1; /* when set, writes don't update memory B */
124 1.1 eeh u_int nowrite_a : 1; /* when set, writes don't update memory A */
125 1.1 eeh u_int read_ecmap : 1; /* copy from(clear)/to(set) shadow colour map */
126 1.1 eeh u_int fast_read : 1; /* fast reads, but wrong data */
127 1.1 eeh u_int wait : 1; /* when set, remains so to end up v. retrace */
128 1.1 eeh u_int update_ecmap : 1; /* copy/use shadow colour map */
129 1.1 eeh u_int reserved : 8;
130 1.1 eeh };
131 1.1 eeh
132 1.1 eeh
133 1.1 eeh /*
134 1.1 eeh * Zoom register, apparently present on Sun-2 colour boards only. See
135 1.1 eeh * the Sun documentation, I don't know anyone who still has a Sun-2.
136 1.1 eeh */
137 1.1 eeh struct cg2_zoom {
138 1.1 eeh union {
139 1.1 eeh u_int short reg;
140 1.1 eeh u_char reg_pad[4096];
141 1.1 eeh } wordpan;
142 1.1 eeh union {
143 1.1 eeh struct {
144 1.1 eeh u_int unused : 8;
145 1.1 eeh u_int lineoff : 4;
146 1.1 eeh u_int pixzoom : 4;
147 1.1 eeh } reg;
148 1.1 eeh u_short word;
149 1.1 eeh u_char reg_pad[4096];
150 1.1 eeh } zoom;
151 1.1 eeh union {
152 1.1 eeh struct {
153 1.1 eeh u_int unused : 8;
154 1.1 eeh u_int lorigin : 4;
155 1.1 eeh u_int pixeloff : 4;
156 1.1 eeh } reg;
157 1.1 eeh u_short word;
158 1.1 eeh u_char reg_pad[4096];
159 1.1 eeh } pixpan;
160 1.1 eeh union {
161 1.1 eeh u_short reg;
162 1.1 eeh u_char reg_pad[4096];
163 1.1 eeh } varzoom;
164 1.1 eeh };
165 1.1 eeh
166 1.1 eeh
167 1.1 eeh /*
168 1.1 eeh * Miscellany. On the Sun-3 these registers exist in place of the above.
169 1.1 eeh */
170 1.1 eeh struct cg2_nozoom {
171 1.1 eeh union { /* double buffer register (see above) */
172 1.1 eeh struct dblbufreg reg;
173 1.1 eeh u_short word;
174 1.1 eeh u_char reg_pad[4096];
175 1.1 eeh } dblbuf;
176 1.1 eeh union { /* start of dma window */
177 1.1 eeh u_short reg;
178 1.1 eeh u_char reg_pad[4096];
179 1.1 eeh } dmabase;
180 1.1 eeh union { /* dma window size */
181 1.1 eeh u_short reg; /* actually 8 bits. reg*16 == size */
182 1.1 eeh u_char reg_pad[4096];
183 1.1 eeh } dmawidth;
184 1.1 eeh union { /* frame count */
185 1.1 eeh u_short reg; /* actually 8 bits only. r/o */
186 1.1 eeh u_char reg_pad[4096];
187 1.1 eeh } framecnt;
188 1.1 eeh };
189 1.1 eeh
190 1.1 eeh
191 1.1 eeh /*
192 1.1 eeh * Raster op control registers. X doesn't use this, but documented here
193 1.1 eeh * for future reference.
194 1.1 eeh */
195 1.1 eeh struct memropc {
196 1.1 eeh u_short mrc_dest;
197 1.1 eeh u_short mrc_source1;
198 1.1 eeh u_short mrc_source2;
199 1.1 eeh u_short mrc_pattern;
200 1.1 eeh u_short mrc_mask1;
201 1.1 eeh u_short mrc_mask2;
202 1.1 eeh u_short mrc_shift;
203 1.1 eeh u_short mrc_op;
204 1.1 eeh u_short mrc_width;
205 1.1 eeh u_short mrc_opcount;
206 1.1 eeh u_short mrc_decoderout;
207 1.1 eeh u_short mrc_x11;
208 1.1 eeh u_short mrc_x12;
209 1.1 eeh u_short mrc_x13;
210 1.1 eeh u_short mrc_x14;
211 1.1 eeh u_short mrc_x15;
212 1.1 eeh };
213 1.1 eeh
214 1.1 eeh
215 1.1 eeh /*
216 1.1 eeh * Last chunk of the frame buffer (i.e. from offset 0x200000 and above).
217 1.1 eeh * Exists separately from struct cg2memfb apparently because Sun software
218 1.1 eeh * avoids mapping the latter, though X uses it.
219 1.1 eeh */
220 1.1 eeh struct cg2fb {
221 1.1 eeh union { /* raster op mode frame memory */
222 1.1 eeh union bitplane ropplane[CG2_N_PLANE];
223 1.1 eeh union byteplane roppixel;
224 1.1 eeh } ropio;
225 1.1 eeh union { /* raster op control unit (1 per plane) */
226 1.1 eeh struct memropc ropregs;
227 1.1 eeh struct {
228 1.1 eeh u_char pad[2048];
229 1.1 eeh struct memropc ropregs;
230 1.1 eeh } prime;
231 1.1 eeh u_char reg_pad[4096];
232 1.1 eeh } ropcontrol[9];
233 1.1 eeh union { /* status register */
234 1.1 eeh struct cg2statusreg reg;
235 1.1 eeh u_short word;
236 1.1 eeh u_char reg_pad[4096];
237 1.1 eeh } status;
238 1.1 eeh union { /* per-plane mask register */
239 1.1 eeh u_short reg; /* 8 bit mask register - set means plane r/w */
240 1.1 eeh u_char reg_pad[4096];
241 1.1 eeh } ppmask;
242 1.1 eeh union { /* miscellaneous registers */
243 1.1 eeh struct cg2_zoom zoom;
244 1.1 eeh struct cg2_nozoom nozoom;
245 1.1 eeh } misc;
246 1.1 eeh union { /* interrupt vector */
247 1.1 eeh u_short reg;
248 1.1 eeh u_char reg_pad[32];
249 1.1 eeh } intrptvec;
250 1.1 eeh union { /* board ID */
251 1.1 eeh u_short reg;
252 1.1 eeh u_char reg_pad[16];
253 1.1 eeh } id;
254 1.1 eeh union { /* extended status */
255 1.1 eeh struct cg2_extstatus reg;
256 1.1 eeh u_short word;
257 1.1 eeh u_char reg_pad[16];
258 1.1 eeh } extstatus;
259 1.1 eeh union { /* auxiliary raster op mode register (?)*/
260 1.1 eeh u_short reg;
261 1.1 eeh u_char reg_pad[4032];
262 1.1 eeh } ropmode;
263 1.1 eeh u_short redmap[CG2_CMSIZE]; /* shadow colour maps */
264 1.1 eeh u_short greenmap[CG2_CMSIZE];
265 1.1 eeh u_short bluemap[CG2_CMSIZE];
266 1.1 eeh };
267