xref: /original-bsd/sys/hp300/dev/ite_rb.c (revision 160e36b4)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1990 The Regents of the University of California.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Systems Programming Group of the University of Utah Computer
8  * Science Department.
9  *
10  * %sccs.include.redist.c%
11  *
12  * from: Utah $Hdr: ite_rb.c 1.18 92/12/20$
13  *
14  *	@(#)ite_rb.c	7.8 (Berkeley) 12/27/92
15  */
16 
17 #include "ite.h"
18 #if NITE > 0
19 
20 #include <sys/param.h>
21 #include <sys/conf.h>
22 #include <sys/proc.h>
23 #include <sys/ioctl.h>
24 #include <sys/tty.h>
25 #include <sys/systm.h>
26 
27 #include <hp/dev/itevar.h>
28 #include <hp/dev/itereg.h>
29 #include <hp300/dev/grf_rbreg.h>
30 
31 #include <machine/cpu.h>
32 
33 /* XXX */
34 #include <hp/dev/grfioctl.h>
35 #include <hp/dev/grfvar.h>
36 
37 #define REGBASE		((struct rboxfb *)(ip->regbase))
38 #define WINDOWMOVER	rbox_windowmove
39 
40 rbox_init(ip)
41 	struct ite_softc *ip;
42 {
43 	register int i;
44 
45 	/* XXX */
46 	if (ip->regbase == 0) {
47 		struct grf_softc *gp = ip->grf;
48 
49 		ip->regbase = gp->g_regkva;
50 		ip->fbbase = gp->g_fbkva;
51 		ip->fbwidth = gp->g_display.gd_fbwidth;
52 		ip->fbheight = gp->g_display.gd_fbheight;
53 		ip->dwidth = gp->g_display.gd_dwidth;
54 		ip->dheight = gp->g_display.gd_dheight;
55 	}
56 
57 	rb_waitbusy(ip->regbase);
58 
59 	REGBASE->reset = 0x39;
60 	DELAY(1000);
61 
62 	REGBASE->interrupt = 0x04;
63 	REGBASE->display_enable = 0x01;
64 	REGBASE->video_enable = 0x01;
65 	REGBASE->drive = 0x01;
66 	REGBASE->vdrive = 0x0;
67 
68 	ite_fontinfo(ip);
69 
70 	REGBASE->opwen = 0xFF;
71 
72 	/*
73 	 * Clear the framebuffer.
74 	 */
75 	rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
76 	rb_waitbusy(ip->regbase);
77 
78 	for(i = 0; i < 16; i++) {
79 		*(ip->regbase + 0x63c3 + i*4) = 0x0;
80 		*(ip->regbase + 0x6403 + i*4) = 0x0;
81 		*(ip->regbase + 0x6803 + i*4) = 0x0;
82 		*(ip->regbase + 0x6c03 + i*4) = 0x0;
83 		*(ip->regbase + 0x73c3 + i*4) = 0x0;
84 		*(ip->regbase + 0x7403 + i*4) = 0x0;
85 		*(ip->regbase + 0x7803 + i*4) = 0x0;
86 		*(ip->regbase + 0x7c03 + i*4) = 0x0;
87 	}
88 
89 	REGBASE->rep_rule = 0x33;
90 
91 	/*
92 	 * I cannot figure out how to make the blink planes stop. So, we
93 	 * must set both colormaps so that when the planes blink, and
94 	 * the secondary colormap is active, we still get text.
95 	 */
96 	CM1RED[0x00].value = 0x00;
97 	CM1GRN[0x00].value = 0x00;
98 	CM1BLU[0x00].value = 0x00;
99 	CM1RED[0x01].value = 0xFF;
100 	CM1GRN[0x01].value = 0xFF;
101 	CM1BLU[0x01].value = 0xFF;
102 
103 	CM2RED[0x00].value = 0x00;
104 	CM2GRN[0x00].value = 0x00;
105 	CM2BLU[0x00].value = 0x00;
106 	CM2RED[0x01].value = 0xFF;
107 	CM2GRN[0x01].value = 0xFF;
108 	CM2BLU[0x01].value = 0xFF;
109 
110  	REGBASE->blink = 0x00;
111 	REGBASE->write_enable = 0x01;
112 	REGBASE->opwen = 0x00;
113 
114 	ite_fontinit(ip);
115 
116 	/*
117 	 * Stash the inverted cursor.
118 	 */
119 	rbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
120 			    ip->cblanky, ip->cblankx, ip->ftheight,
121 			    ip->ftwidth, RR_COPYINVERTED);
122 }
123 
124 rbox_deinit(ip)
125 	struct ite_softc *ip;
126 {
127 	rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
128 	rb_waitbusy(ip->regbase);
129 
130    	ip->flags &= ~ITE_INITED;
131 }
132 
133 rbox_putc(ip, c, dy, dx, mode)
134 	register struct ite_softc *ip;
135         register int dy, dx;
136 	int c, mode;
137 {
138         register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
139 
140 	rbox_windowmove(ip, charY(ip, c), charX(ip, c),
141 			dy * ip->ftheight, dx * ip->ftwidth,
142 			ip->ftheight, ip->ftwidth, wrr);
143 }
144 
145 rbox_cursor(ip, flag)
146 	register struct ite_softc *ip;
147         register int flag;
148 {
149 	if (flag == DRAW_CURSOR)
150 		draw_cursor(ip)
151 	else if (flag == MOVE_CURSOR) {
152 		erase_cursor(ip)
153 		draw_cursor(ip)
154 	}
155 	else
156 		erase_cursor(ip)
157 }
158 
159 rbox_clear(ip, sy, sx, h, w)
160 	struct ite_softc *ip;
161 	register int sy, sx, h, w;
162 {
163 	rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
164 			sy * ip->ftheight, sx * ip->ftwidth,
165 			h  * ip->ftheight, w  * ip->ftwidth,
166 			RR_CLEAR);
167 }
168 
169 rbox_scroll(ip, sy, sx, count, dir)
170         register struct ite_softc *ip;
171         register int sy, count;
172         int dir, sx;
173 {
174 	register int dy;
175 	register int dx = sx;
176 	register int height = 1;
177 	register int width = ip->cols;
178 
179 	if (dir == SCROLL_UP) {
180 		dy = sy - count;
181 		height = ip->rows - sy;
182 	}
183 	else if (dir == SCROLL_DOWN) {
184 		dy = sy + count;
185 		height = ip->rows - dy - 1;
186 	}
187 	else if (dir == SCROLL_RIGHT) {
188 		dy = sy;
189 		dx = sx + count;
190 		width = ip->cols - dx;
191 	}
192 	else {
193 		dy = sy;
194 		dx = sx - count;
195 		width = ip->cols - sx;
196 	}
197 
198 	rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
199 			dy * ip->ftheight, dx * ip->ftwidth,
200 			height * ip->ftheight,
201 			width  * ip->ftwidth, RR_COPY);
202 }
203 
204 rbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
205 	struct ite_softc *ip;
206 	int sy, sx, dy, dx, h, w, func;
207 {
208 	register struct rboxfb *rp = REGBASE;
209 	if (h == 0 || w == 0)
210 		return;
211 
212 	rb_waitbusy(ip->regbase);
213 	rp->rep_rule = func << 4 | func;
214 	rp->source_y = sy;
215 	rp->source_x = sx;
216 	rp->dest_y = dy;
217 	rp->dest_x = dx;
218 	rp->wheight = h;
219 	rp->wwidth  = w;
220 	rp->wmove = 1;
221 }
222 #endif
223