FreeBSD/Linux Kernel Cross Reference
sys/chips/bt431.c
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: bt431.c,v $
29 * Revision 2.2 91/08/24 11:50:13 af
30 * Created, from Brooktree specs:
31 * "Product Databook 1989"
32 * "Bt431 Monolithic CMOS 64x64 Pixel Cursor Generator"
33 * Brooktree Corp. San Diego, CA
34 * LA59001 Rev. J
35 * [91/07/25 af]
36 *
37 */
38 /*
39 * File: bt431.c
40 * Author: Alessandro Forin, Carnegie Mellon University
41 * Date: 8/91
42 *
43 * Routines for the bt431 Cursor
44 */
45
46 #include <platforms.h>
47
48 #include <chips/bt431.h>
49 #include <chips/screen.h>
50
51 #ifdef DECSTATION
52 /*
53 * This configuration uses two twin 431s
54 */
55 #define set_value(x) (((x)<<8)|((x)&0xff))
56 #define get_value(x) ((x)&0xff)
57
58 typedef struct {
59 volatile unsigned short addr_lo;
60 short pad0;
61 volatile unsigned short addr_hi;
62 short pad1;
63 volatile unsigned short addr_cmap;
64 short pad2;
65 volatile unsigned short addr_reg;
66 short pad3;
67 } bt431_padded_regmap_t;
68
69 #else /*DECSTATION*/
70
71 #define set_value(x) x
72 #define get_value(x) x
73 typedef bt431_regmap_t bt431_padded_regmap_t;
74 #define wbflush()
75
76 #endif /*DECSTATION*/
77
78 /*
79 * Generic register access
80 */
81 void
82 bt431_select_reg( regs, regno)
83 bt431_padded_regmap_t *regs;
84 {
85 regs->addr_lo = set_value(regno&0xff);
86 regs->addr_hi = set_value((regno >> 8) & 0xff);
87 wbflush();
88 }
89
90 void
91 bt431_write_reg( regs, regno, val)
92 bt431_padded_regmap_t *regs;
93 {
94 bt431_select_reg( regs, regno );
95 regs->addr_reg = set_value(val);
96 wbflush();
97 }
98
99 unsigned char
100 bt431_read_reg( regs, regno)
101 bt431_padded_regmap_t *regs;
102 {
103 bt431_select_reg( regs, regno );
104 return get_value(regs->addr_reg);
105 }
106
107 /* when using autoincrement */
108 #define bt431_write_reg_autoi( regs, regno, val) \
109 { \
110 (regs)->addr_reg = set_value(val); \
111 wbflush(); \
112 }
113 #define bt431_read_reg_autoi( regs, regno) \
114 get_value(((regs)->addr_reg))
115
116 #define bt431_write_cmap_autoi( regs, regno, val) \
117 { \
118 (regs)->addr_cmap = (val); \
119 wbflush(); \
120 }
121 #define bt431_read_cmap_autoi( regs, regno) \
122 ((regs)->addr_cmap)
123
124
125 /*
126 * Cursor ops
127 */
128 bt431_cursor_on(regs)
129 bt431_padded_regmap_t *regs;
130 {
131 bt431_write_reg( regs, BT431_REG_CMD,
132 BT431_CMD_CURS_ENABLE|BT431_CMD_OR_CURSORS|
133 BT431_CMD_4_1_MUX|BT431_CMD_THICK_1);
134 }
135
136 bt431_cursor_off(regs)
137 bt431_padded_regmap_t *regs;
138 {
139 bt431_write_reg( regs, BT431_REG_CMD, BT431_CMD_4_1_MUX);
140 }
141
142 bt431_pos_cursor(regs,x,y)
143 bt431_padded_regmap_t *regs;
144 register int x,y;
145 {
146 #define lo(v) ((v)&0xff)
147 #define hi(v) (((v)&0xf00)>>8)
148
149 /*
150 * Cx = x + D + H - P
151 * P = 37 if 1:1, 52 if 4:1, 57 if 5:1
152 * D = pixel skew between outdata and external data
153 * H = pixels between HSYNCH falling and active video
154 *
155 * Cy = y + V - 32
156 * V = scanlines between HSYNCH falling, two or more
157 * clocks after VSYNCH falling, and active video
158 */
159
160 bt431_write_reg( regs, BT431_REG_CXLO, lo(x + 360));
161 /* use autoincr feature */
162 bt431_write_reg_autoi( regs, BT431_REG_CXHI, hi(x + 360));
163 bt431_write_reg_autoi( regs, BT431_REG_CYLO, lo(y + 36));
164 bt431_write_reg_autoi( regs, BT431_REG_CYHI, hi(y + 36));
165 }
166
167
168 bt431_cursor_sprite( regs, cursor)
169 bt431_padded_regmap_t *regs;
170 register unsigned short *cursor;
171 {
172 register int i;
173
174 bt431_select_reg( regs, BT431_REG_CRAM_BASE+0);
175 for (i = 0; i < 512; i++)
176 bt431_write_cmap_autoi( regs, BT431_REG_CRAM_BASE+i, *cursor++);
177 }
178
179 #if 1
180 bt431_print_cursor(regs)
181 bt431_padded_regmap_t *regs;
182 {
183 unsigned short curs[512];
184 register int i;
185
186 bt431_select_reg( regs, BT431_REG_CRAM_BASE+0);
187 for (i = 0; i < 512; i++) {
188 curs[i] = bt431_read_cmap_autoi( regs, BT431_REG_CRAM_BASE+i);
189 }
190 for (i = 0; i < 512; i += 16)
191 printf("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n",
192 curs[i], curs[i+1], curs[i+2], curs[i+3],
193 curs[i+4], curs[i+5], curs[i+6], curs[i+7],
194 curs[i+8], curs[i+9], curs[i+10], curs[i+11],
195 curs[i+12], curs[i+13], curs[i+14], curs[i+15]);
196 }
197
198 #endif
199
200 /*
201 * Initialization
202 */
203 unsigned /*char*/short bt431_default_cursor[64*8] = {
204 0xffff, 0, 0, 0, 0, 0, 0, 0,
205 0xffff, 0, 0, 0, 0, 0, 0, 0,
206 0xffff, 0, 0, 0, 0, 0, 0, 0,
207 0xffff, 0, 0, 0, 0, 0, 0, 0,
208 0xffff, 0, 0, 0, 0, 0, 0, 0,
209 0xffff, 0, 0, 0, 0, 0, 0, 0,
210 0xffff, 0, 0, 0, 0, 0, 0, 0,
211 0xffff, 0, 0, 0, 0, 0, 0, 0,
212 0xffff, 0, 0, 0, 0, 0, 0, 0,
213 0xffff, 0, 0, 0, 0, 0, 0, 0,
214 0xffff, 0, 0, 0, 0, 0, 0, 0,
215 0xffff, 0, 0, 0, 0, 0, 0, 0,
216 0xffff, 0, 0, 0, 0, 0, 0, 0,
217 0xffff, 0, 0, 0, 0, 0, 0, 0,
218 0xffff, 0, 0, 0, 0, 0, 0, 0,
219 0xffff, 0, 0, 0, 0, 0, 0, 0,
220 0,
221 };
222
223 bt431_init(regs)
224 bt431_padded_regmap_t *regs;
225 {
226 register int i;
227
228 /* use 4:1 input mux */
229 bt431_write_reg( regs, BT431_REG_CMD,
230 BT431_CMD_CURS_ENABLE|BT431_CMD_OR_CURSORS|
231 BT431_CMD_4_1_MUX|BT431_CMD_THICK_1);
232
233 /* home cursor */
234 bt431_write_reg_autoi( regs, BT431_REG_CXLO, 0x00);
235 bt431_write_reg_autoi( regs, BT431_REG_CXHI, 0x00);
236 bt431_write_reg_autoi( regs, BT431_REG_CYLO, 0x00);
237 bt431_write_reg_autoi( regs, BT431_REG_CYHI, 0x00);
238
239 /* no crosshair window */
240 bt431_write_reg_autoi( regs, BT431_REG_WXLO, 0x00);
241 bt431_write_reg_autoi( regs, BT431_REG_WXHI, 0x00);
242 bt431_write_reg_autoi( regs, BT431_REG_WYLO, 0x00);
243 bt431_write_reg_autoi( regs, BT431_REG_WYHI, 0x00);
244 bt431_write_reg_autoi( regs, BT431_REG_WWLO, 0x00);
245 bt431_write_reg_autoi( regs, BT431_REG_WWHI, 0x00);
246 bt431_write_reg_autoi( regs, BT431_REG_WHLO, 0x00);
247 bt431_write_reg_autoi( regs, BT431_REG_WHHI, 0x00);
248
249 /* load default cursor */
250 bt431_cursor_sprite( regs, bt431_default_cursor);
251 }
Cache object: ea61addb19dae91bdb9aeffeecca52ad
|