xref: /original-bsd/sys/hp300/dev/ite_rb.c (revision 3705696b)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1990, 1993
4  *	The Regents of the University of California.  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.19 93/06/25$
13  *
14  *	@(#)ite_rb.c	8.1 (Berkeley) 07/08/93
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 		 * XXX some displays (e.g. the davinci) appear
57 		 * to return a display height greater than the
58 		 * returned FB height.  Guess we should go back
59 		 * to getting the display dimensions from the
60 		 * fontrom...
61 		 */
62 		if (ip->dwidth > ip->fbwidth)
63 			ip->dwidth = ip->fbwidth;
64 		if (ip->dheight > ip->fbheight)
65 			ip->dheight = ip->fbheight;
66 	}
67 
68 	rb_waitbusy(ip->regbase);
69 
70 	REGBASE->reset = 0x39;
71 	DELAY(1000);
72 
73 	REGBASE->interrupt = 0x04;
74 	REGBASE->display_enable = 0x01;
75 	REGBASE->video_enable = 0x01;
76 	REGBASE->drive = 0x01;
77 	REGBASE->vdrive = 0x0;
78 
79 	ite_fontinfo(ip);
80 
81 	REGBASE->opwen = 0xFF;
82 
83 	/*
84 	 * Clear the framebuffer.
85 	 */
86 	rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
87 	rb_waitbusy(ip->regbase);
88 
89 	for(i = 0; i < 16; i++) {
90 		*(ip->regbase + 0x63c3 + i*4) = 0x0;
91 		*(ip->regbase + 0x6403 + i*4) = 0x0;
92 		*(ip->regbase + 0x6803 + i*4) = 0x0;
93 		*(ip->regbase + 0x6c03 + i*4) = 0x0;
94 		*(ip->regbase + 0x73c3 + i*4) = 0x0;
95 		*(ip->regbase + 0x7403 + i*4) = 0x0;
96 		*(ip->regbase + 0x7803 + i*4) = 0x0;
97 		*(ip->regbase + 0x7c03 + i*4) = 0x0;
98 	}
99 
100 	REGBASE->rep_rule = 0x33;
101 
102 	/*
103 	 * I cannot figure out how to make the blink planes stop. So, we
104 	 * must set both colormaps so that when the planes blink, and
105 	 * the secondary colormap is active, we still get text.
106 	 */
107 	CM1RED[0x00].value = 0x00;
108 	CM1GRN[0x00].value = 0x00;
109 	CM1BLU[0x00].value = 0x00;
110 	CM1RED[0x01].value = 0xFF;
111 	CM1GRN[0x01].value = 0xFF;
112 	CM1BLU[0x01].value = 0xFF;
113 
114 	CM2RED[0x00].value = 0x00;
115 	CM2GRN[0x00].value = 0x00;
116 	CM2BLU[0x00].value = 0x00;
117 	CM2RED[0x01].value = 0xFF;
118 	CM2GRN[0x01].value = 0xFF;
119 	CM2BLU[0x01].value = 0xFF;
120 
121  	REGBASE->blink = 0x00;
122 	REGBASE->write_enable = 0x01;
123 	REGBASE->opwen = 0x00;
124 
125 	ite_fontinit(ip);
126 
127 	/*
128 	 * Stash the inverted cursor.
129 	 */
130 	rbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
131 			    ip->cblanky, ip->cblankx, ip->ftheight,
132 			    ip->ftwidth, RR_COPYINVERTED);
133 }
134 
135 rbox_deinit(ip)
136 	struct ite_softc *ip;
137 {
138 	rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
139 	rb_waitbusy(ip->regbase);
140 
141    	ip->flags &= ~ITE_INITED;
142 }
143 
144 rbox_putc(ip, c, dy, dx, mode)
145 	register struct ite_softc *ip;
146         register int dy, dx;
147 	int c, mode;
148 {
149         register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
150 
151 	rbox_windowmove(ip, charY(ip, c), charX(ip, c),
152 			dy * ip->ftheight, dx * ip->ftwidth,
153 			ip->ftheight, ip->ftwidth, wrr);
154 }
155 
156 rbox_cursor(ip, flag)
157 	register struct ite_softc *ip;
158         register int flag;
159 {
160 	if (flag == DRAW_CURSOR)
161 		draw_cursor(ip)
162 	else if (flag == MOVE_CURSOR) {
163 		erase_cursor(ip)
164 		draw_cursor(ip)
165 	}
166 	else
167 		erase_cursor(ip)
168 }
169 
170 rbox_clear(ip, sy, sx, h, w)
171 	struct ite_softc *ip;
172 	register int sy, sx, h, w;
173 {
174 	rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
175 			sy * ip->ftheight, sx * ip->ftwidth,
176 			h  * ip->ftheight, w  * ip->ftwidth,
177 			RR_CLEAR);
178 }
179 
180 rbox_scroll(ip, sy, sx, count, dir)
181         register struct ite_softc *ip;
182         register int sy, count;
183         int dir, sx;
184 {
185 	register int dy;
186 	register int dx = sx;
187 	register int height = 1;
188 	register int width = ip->cols;
189 
190 	if (dir == SCROLL_UP) {
191 		dy = sy - count;
192 		height = ip->rows - sy;
193 	}
194 	else if (dir == SCROLL_DOWN) {
195 		dy = sy + count;
196 		height = ip->rows - dy - 1;
197 	}
198 	else if (dir == SCROLL_RIGHT) {
199 		dy = sy;
200 		dx = sx + count;
201 		width = ip->cols - dx;
202 	}
203 	else {
204 		dy = sy;
205 		dx = sx - count;
206 		width = ip->cols - sx;
207 	}
208 
209 	rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
210 			dy * ip->ftheight, dx * ip->ftwidth,
211 			height * ip->ftheight,
212 			width  * ip->ftwidth, RR_COPY);
213 }
214 
215 rbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
216 	struct ite_softc *ip;
217 	int sy, sx, dy, dx, h, w, func;
218 {
219 	register struct rboxfb *rp = REGBASE;
220 	if (h == 0 || w == 0)
221 		return;
222 
223 	rb_waitbusy(ip->regbase);
224 	rp->rep_rule = func << 4 | func;
225 	rp->source_y = sy;
226 	rp->source_x = sx;
227 	rp->dest_y = dy;
228 	rp->dest_x = dx;
229 	rp->wheight = h;
230 	rp->wwidth  = w;
231 	rp->wmove = 1;
232 }
233 #endif
234