|
|
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: xcfb_misc.c
28: * Author: Alessandro Forin, Carnegie Mellon University
29: * Date: 1/92
30: *
31: * Driver for the MAXine color framebuffer
32: *
33: */
34:
35: #include <xcfb.h>
36: #if (NXCFB > 0)
37:
38: /*
39: * NOTE: This driver relies heavily on the pm one.
40: */
41:
42: #include <device/device_types.h>
43:
44: #include <chips/screen_defs.h>
45:
46: #include <chips/xcfb_monitor.h>
47: #include <chips/pm_defs.h>
48: typedef pm_softc_t xcfb_softc_t;
49:
50: #include <chips/ims332.h>
51: #define ims332 cursor_registers
52:
53:
54: /*
55: * Initialize color map, for kernel use
56: */
57: xcfb_init_colormap(sc)
58: screen_softc_t sc;
59: {
60: xcfb_softc_t *xcfb = (xcfb_softc_t*)sc->hw_state;
61: user_info_t *up = sc->up;
62: color_map_t Bg_Fg[2];
63: register int i;
64:
65: ims332_init_colormap( xcfb->ims332 );
66:
67: /* init bg/fg colors */
68: for (i = 0; i < 3; i++) {
69: up->dev_dep_2.pm.Bg_color[i] = 0x00;
70: up->dev_dep_2.pm.Fg_color[i] = 0xff;
71: }
72:
73: Bg_Fg[0].red = Bg_Fg[0].green = Bg_Fg[0].blue = 0x00;
74: Bg_Fg[1].red = Bg_Fg[1].green = Bg_Fg[1].blue = 0xff;
75: ims332_cursor_color( xcfb->ims332, Bg_Fg);
76: }
77:
78: /*
79: * Large viz small cursor
80: */
81: xcfb_small_cursor_to_large(up, cursor)
82: user_info_t *up;
83: cursor_sprite_t cursor;
84: {
85: unsigned short new_cursor[32];
86: unsigned char *cursor_bytes;
87: char *sprite;
88: register int i;
89:
90: /* Clear out old cursor */
91: bzero( up->dev_dep_2.pm.cursor_sprite,
92: sizeof(up->dev_dep_2.pm.cursor_sprite));
93:
94: /* small cursor is 32x2 bytes, fg first */
95: cursor_bytes = (unsigned char *) cursor;
96:
97: /* use the upper left corner of the large cursor
98: * as a 64x1 cursor, fg&bg alternated */
99: for (i = 0; i < 32; i++) {
100: register short nc = 0;
101: register unsigned char fg, bg;
102: register int j, k;
103:
104: fg = cursor_bytes[i];
105: bg = cursor_bytes[i + 32];
106: bg &= ~fg;
107: for (j = 1, k = 0; j < 256; j <<= 1) {
108: nc |= (bg & j) << (k++);
109: nc |= (fg & j) << (k);
110: }
111: new_cursor[i] = nc;
112: }
113:
114: /* Now stick it in the proper place */
115:
116: cursor_bytes = (unsigned char *) new_cursor;
117: sprite = up->dev_dep_2.pm.cursor_sprite;
118: for (i = 0; i < 64; i += 4) {
119: *sprite++ = cursor_bytes[i + 0];
120: *sprite++ = cursor_bytes[i + 1];
121: *sprite++ = cursor_bytes[i + 2];
122: *sprite++ = cursor_bytes[i + 3];
123: sprite += 12; /* skip rest of the line */
124: }
125: }
126:
127:
128: /*
129: * Device-specific set status
130: */
131: xcfb_set_status(sc, flavor, status, status_count)
132: screen_softc_t sc;
133: int flavor;
134: dev_status_t status;
135: unsigned int status_count;
136: {
137: xcfb_softc_t *xcfb = (xcfb_softc_t*) sc->hw_state;
138:
139: switch (flavor) {
140:
141: case SCREEN_ADJ_MAPPED_INFO:
142: return pm_set_status(sc, flavor, status, status_count);
143:
144: case SCREEN_LOAD_CURSOR:
145:
146: if (status_count < sizeof(cursor_sprite_t)/sizeof(int))
147: return D_INVALID_SIZE;
148:
149: xcfb_small_cursor_to_large(sc->up, (cursor_sprite_t*) status);
150:
151: /* Fall through */
152:
153: case SCREEN_LOAD_CURSOR_LONG: /* 3max only */
154:
155: sc->flags |= SCREEN_BEING_UPDATED;
156: ims332_cursor_sprite(xcfb->ims332, sc->up->dev_dep_2.pm.cursor_sprite);
157: sc->flags &= ~SCREEN_BEING_UPDATED;
158:
159: break;
160:
161: case SCREEN_SET_CURSOR_COLOR: {
162: color_map_t c[2];
163: register cursor_color_t *cc = (cursor_color_t*) status;
164:
165: c[0].red = cc->Bg_rgb[0];
166: c[0].green = cc->Bg_rgb[1];
167: c[0].blue = cc->Bg_rgb[2];
168: c[1].red = cc->Fg_rgb[0];
169: c[1].green = cc->Fg_rgb[1];
170: c[1].blue = cc->Fg_rgb[2];
171:
172: sc->flags |= SCREEN_BEING_UPDATED;
173: ims332_cursor_color (xcfb->ims332, c );
174: sc->flags &= ~SCREEN_BEING_UPDATED;
175:
176: break;
177: }
178:
179: case SCREEN_SET_CMAP_ENTRY: {
180: color_map_entry_t *e = (color_map_entry_t*) status;
181:
182: if (e->index < 256) {
183: sc->flags |= SCREEN_BEING_UPDATED;
184: ims332_load_colormap_entry( xcfb->ims332, e->index, &e->value);
185: sc->flags &= ~SCREEN_BEING_UPDATED;
186: }
187: break;
188: }
189:
190: default:
191: return D_INVALID_OPERATION;
192: }
193: return D_SUCCESS;
194: }
195:
196: /*
197: * Hardware initialization
198: */
199: xcfb_init_screen(xcfb)
200: xcfb_softc_t *xcfb;
201: {
202: extern xcfb_monitor_type_t xcfb_get_monitor_type();
203:
204: ims332_init( xcfb->ims332, xcfb->vdac_registers, xcfb_get_monitor_type());
205: }
206:
207: /*
208: * Do what's needed when X exits
209: */
210: xcfb_soft_reset(sc)
211: screen_softc_t sc;
212: {
213: xcfb_softc_t *xcfb = (xcfb_softc_t*) sc->hw_state;
214: user_info_t *up = sc->up;
215: extern cursor_sprite_t dc503_default_cursor;
216:
217: /*
218: * Restore params in mapped structure
219: */
220: pm_init_screen_params(sc,up);
221: up->row = up->max_row - 1;
222:
223: up->dev_dep_2.pm.x26 = 2; /* you do not want to know */
224: up->dev_dep_1.pm.x18 = (short*)2;
225:
226: /*
227: * Restore RAMDAC chip to default state
228: */
229: xcfb_init_screen(xcfb);
230:
231: /*
232: * Load kernel's cursor sprite: just use the same pmax one
233: */
234: xcfb_small_cursor_to_large(up, dc503_default_cursor);
235: ims332_cursor_sprite(xcfb->ims332, up->dev_dep_2.pm.cursor_sprite);
236:
237: /*
238: * Color map and cursor color
239: */
240: xcfb_init_colormap(sc);
241: }
242:
243:
244:
245:
246: #endif (NXCFB > 0)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.