|
|
1.1 root 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 [email protected]
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: * File: bt455.c
28: * Author: Alessandro Forin, Carnegie Mellon University
29: * Date: 7/91
30: *
31: * Routines for the bt454/bt455 RAMDAC
32: */
33:
34: #include <platforms.h>
35:
36: #include <chips/bt455.h>
37: #include <chips/screen.h>
38:
39: #ifdef DECSTATION
40:
41: typedef struct {
42: volatile unsigned char addr_cmap;
43: char pad0[3];
44: volatile unsigned char addr_cmap_data;
45: char pad1[3];
46: volatile unsigned char addr_clr;
47: char pad2[3];
48: volatile unsigned char addr_ovly;
49: char pad3[3];
50: } bt455_padded_regmap_t;
51:
52: #else /*DECSTATION*/
53:
54: typedef bt455_regmap_t bt455_padded_regmap_t;
55: #define wbflush()
56:
57: #endif /*DECSTATION*/
58:
59:
60: /*
61: * Generic register access
62: */
63: #define bt455_select_entry(regs, regno) \
64: { \
65: (regs)->addr_cmap = (regno)&0x0f; \
66: wbflush(); \
67: }
68:
69:
70: /*
71: * Color map
72: */
73: bt455_load_colormap( regs, map)
74: bt455_padded_regmap_t *regs;
75: color_map_t *map;
76: {
77: register int i;
78:
79: bt455_select_entry(regs, 0);
80:
81: for (i = 0; i < 16; i++, map++) {
82: regs->addr_cmap_data = map->red >> 4;
83: wbflush();
84: regs->addr_cmap_data = map->green >> 4;
85: wbflush();
86: regs->addr_cmap_data = map->blue >> 4;
87: wbflush();
88: }
89: }
90:
91: bt455_load_colormap_entry( regs, entry, map)
92: register bt455_padded_regmap_t *regs;
93: register color_map_t *map;
94: {
95: bt455_select_entry(regs, entry);
96:
97: regs->addr_cmap_data = map->red >> 4;
98: wbflush();
99: regs->addr_cmap_data = map->green >> 4;
100: wbflush();
101: regs->addr_cmap_data = map->blue >> 4;
102: wbflush();
103: }
104:
105: bt455_init_colormap( regs)
106: bt455_padded_regmap_t *regs;
107: {
108: register int i;
109: color_map_t m[2];
110:
111: m[0].red = m[0].green = m[0].blue = 0;
112: m[1].red = m[1].green = m[1].blue = 0xff;
113:
114: for (i = 0; i < 16; i++)
115: bt455_load_colormap_entry(regs, i, &m[0]);
116:
117: bt455_load_colormap_entry(regs, 1, &m[1]);
118:
119: bt455_cursor_color( regs, &m[0]);
120: }
121:
122: #if 1/*debug*/
123: bt455_print_colormap( regs)
124: bt455_padded_regmap_t *regs;
125: {
126: register int i;
127:
128: for (i = 0; i < 16; i++) {
129: register unsigned char red, green, blue;
130:
131: bt455_select_entry(regs, i);
132: red = regs->addr_cmap_data;
133: green = regs->addr_cmap_data;
134: blue = regs->addr_cmap_data;
135: printf("%x->[x%x x%x x%x]\n", i,
136: red, green, blue);
137:
138: }
139: }
140: #endif
141:
142: /*
143: * Video on/off
144: */
145: bt455_video_off(regs, up)
146: bt455_padded_regmap_t *regs;
147: user_info_t *up;
148: {
149: color_map_t m;
150: unsigned char *save;
151:
152: /* Yes, this is awful */
153: save = (unsigned char *)up->dev_dep_2.gx.colormap;
154:
155: bt455_select_entry( regs, 0);
156:
157: *save++ = regs->addr_cmap_data; /* entry 0 */
158: *save++ = regs->addr_cmap_data;
159: *save++ = regs->addr_cmap_data;
160:
161: *save++ = regs->addr_cmap_data; /* entry 1 */
162: *save++ = regs->addr_cmap_data;
163: *save++ = regs->addr_cmap_data;
164:
165: m.red = m.green = m.blue = 0;
166: bt455_load_colormap_entry(regs, 0, &m);
167: bt455_load_colormap_entry(regs, 1, &m);
168: }
169:
170: bt455_video_on(regs, up)
171: bt455_padded_regmap_t *regs;
172: user_info_t *up;
173: {
174: unsigned char *save;
175:
176: /* Like I said.. */
177: save = (unsigned char *)up->dev_dep_2.gx.colormap;
178:
179: bt455_select_entry( regs, 0);
180:
181: regs->addr_cmap_data = *save++; wbflush();
182: regs->addr_cmap_data = *save++; wbflush();
183: regs->addr_cmap_data = *save++; wbflush();
184:
185: regs->addr_cmap_data = *save++; wbflush();
186: regs->addr_cmap_data = *save++; wbflush();
187: regs->addr_cmap_data = *save;
188:
189: }
190:
191: /*
192: * Cursor 'color' [as used on DEC's board]
193: */
194: bt455_cursor_color( regs, color)
195: bt455_padded_regmap_t *regs;
196: color_map_t *color;
197: {
198: register int i;
199:
200: /* Bg is the first in color */
201: bt455_load_colormap_entry( regs, 8, color);
202: bt455_load_colormap_entry( regs, 9, color);
203:
204: /* Fg is overlay */
205: color++;
206: regs->addr_ovly = color->red >> 4;
207: wbflush();
208: regs->addr_ovly = color->green >> 4;
209: wbflush();
210: regs->addr_ovly = color->blue >> 4;
211: wbflush();
212: }
213:
214: /*
215: * Initialization
216: */
217: bt455_init(regs)
218: bt455_padded_regmap_t *regs;
219: {
220: /* Nothing really needed */
221: }
222:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.