xref: /csrg-svn/sys/hp300/dev/ite_tc.c (revision 49132)
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_tc.c 1.22 89/04/11$
13  *
14  *	@(#)ite_tc.c	7.3 (Berkeley) 05/04/91
15  */
16 
17 #include "ite.h"
18 #if NITE > 0
19 
20 #include "param.h"
21 #include "conf.h"
22 #include "proc.h"
23 #include "ioctl.h"
24 #include "tty.h"
25 #include "systm.h"
26 
27 #include "grf_tcreg.h"
28 #include "itereg.h"
29 #include "itevar.h"
30 
31 #include "machine/cpu.h"
32 
33 #define REGBASE	    	((struct tcboxfb *)(ip->regbase))
34 #define WINDOWMOVER 	topcat_windowmove
35 
36 /* XXX */
37 #include "grfioctl.h"
38 #include "grfvar.h"
39 
40 topcat_init(ip)
41 	register struct ite_softc *ip;
42 {
43 	/* XXX */
44 	if (ip->regbase == NULL) {
45 		struct grfinfo *gi = &grf_softc[ip - ite_softc].g_display;
46 		ip->regbase = IOV(gi->gd_regaddr);
47 		ip->fbbase = IOV(gi->gd_fbaddr);
48 	}
49 
50 	/*
51 	 * Determine the number of planes by writing to the first frame
52 	 * buffer display location, then reading it back.
53 	 */
54 	REGBASE->wen = ~0;
55 	REGBASE->fben = ~0;
56 	REGBASE->prr = RR_COPY;
57 	*FBBASE = 0xFF;
58 	ip->planemask = *FBBASE;
59 
60 	/*
61 	 * Enable reading/writing of all the planes.
62 	 */
63 	REGBASE->fben = ip->planemask;
64 	REGBASE->wen  = ip->planemask;
65 	REGBASE->ren  = ip->planemask;
66 	REGBASE->prr  = RR_COPY;
67 
68 	ite_devinfo(ip);
69 
70 	/*
71 	 * Clear the framebuffer on all planes.
72 	 */
73 	topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
74 	tc_waitbusy(REGADDR, ip->planemask);
75 
76 	ite_fontinit(ip);
77 
78 	/*
79 	 * Initialize color map for color displays
80 	 */
81 	if (ip->planemask != 1) {
82 	  	tc_waitbusy(REGADDR, ip->planemask);
83 		REGBASE->nblank = 0x01;
84 
85 		tccm_waitbusy(REGADDR);
86 		REGBASE->rdata  = 0x0;
87 		REGBASE->gdata  = 0x0;
88 		REGBASE->bdata  = 0x0;
89 		REGBASE->cindex = 0xFF;
90 		REGBASE->strobe = 0xFF;
91 
92 		DELAY(100);
93 		tccm_waitbusy(REGADDR);
94 		REGBASE->rdata  = 0x0;
95 		REGBASE->gdata  = 0x0;
96 		REGBASE->bdata  = 0x0;
97 		REGBASE->cindex = 0x0;
98 
99 		DELAY(100);
100 		tccm_waitbusy(REGADDR);
101 		REGBASE->rdata  = 0xFF;
102 		REGBASE->gdata  = 0xFF;
103 		REGBASE->bdata  = 0xFF;
104 		REGBASE->cindex = 0xFE;
105 		REGBASE->strobe = 0xFF;
106 
107 		DELAY(100);
108 		tccm_waitbusy(REGADDR);
109 		REGBASE->rdata  = 0x0;
110 		REGBASE->gdata  = 0x0;
111 		REGBASE->bdata  = 0x0;
112 		REGBASE->cindex = 0x0;
113 	}
114 
115 	/*
116 	 * Stash the inverted cursor.
117 	 */
118 	topcat_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
119 			  ip->cblanky, ip->cblankx, ip->ftheight,
120 			  ip->ftwidth, RR_COPYINVERTED);
121 }
122 
123 topcat_deinit(ip)
124 	register struct ite_softc *ip;
125 {
126 	topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
127 	tc_waitbusy(REGADDR, ip->planemask);
128 
129 	REGBASE->nblank = ~0;
130    	ip->flags &= ~ITE_INITED;
131 }
132 
133 topcat_putc(ip, c, dy, dx, mode)
134 	register struct ite_softc *ip;
135 	int c, dy, dx, mode;
136 {
137         int wmrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
138 
139 	topcat_windowmove(ip, charY(ip, c), charX(ip, c),
140 			  dy * ip->ftheight, dx * ip->ftwidth,
141 			  ip->ftheight, ip->ftwidth, wmrr);
142 }
143 
144 topcat_cursor(ip, flag)
145 	register struct ite_softc *ip;
146 	register int flag;
147 {
148 	if (flag == DRAW_CURSOR)
149 		draw_cursor(ip)
150 	else if (flag == MOVE_CURSOR) {
151 		erase_cursor(ip)
152 		draw_cursor(ip)
153 	}
154 	else
155 		erase_cursor(ip)
156 }
157 
158 topcat_clear(ip, sy, sx, h, w)
159 	register struct ite_softc *ip;
160 	register int sy, sx, h, w;
161 {
162 	topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
163 			  sy * ip->ftheight, sx * ip->ftwidth,
164 			  h  * ip->ftheight, w  * ip->ftwidth,
165 			  RR_CLEAR);
166 }
167 
168 topcat_scroll(ip, sy, sx, count, dir)
169         register struct ite_softc *ip;
170         register int sy, count;
171         int dir, sx;
172 {
173 	register int dy;
174 	register int dx = sx;
175 	register int height = 1;
176 	register int width = ip->cols;
177 
178 	topcat_cursor(ip, ERASE_CURSOR);
179 
180 	if (dir == SCROLL_UP) {
181 		dy = sy - count;
182 		height = ip->rows - sy;
183 	}
184 	else if (dir == SCROLL_DOWN) {
185 		dy = sy + count;
186 		height = ip->rows - dy - 1;
187 	}
188 	else if (dir == SCROLL_RIGHT) {
189 		dy = sy;
190 		dx = sx + count;
191 		width = ip->cols - dx;
192 	}
193 	else {
194 		dy = sy;
195 		dx = sx - count;
196 		width = ip->cols - sx;
197 	}
198 
199 	topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
200 			  dy * ip->ftheight, dx * ip->ftwidth,
201 			  height * ip->ftheight,
202 			  width  * ip->ftwidth, RR_COPY);
203 }
204 
205 topcat_windowmove(ip, sy, sx, dy, dx, h, w, func)
206 	struct ite_softc *ip;
207 	int sy, sx, dy, dx, h, w, func;
208 {
209   	register struct tcboxfb *rp = REGBASE;
210 
211 	if (h == 0 || w == 0)
212 		return;
213 	tc_waitbusy(REGADDR, ip->planemask);
214 	rp->wmrr     = func;
215 	rp->source_y = sy;
216 	rp->source_x = sx;
217 	rp->dest_y   = dy;
218 	rp->dest_x   = dx;
219 	rp->wheight  = h;
220 	rp->wwidth   = w;
221 	rp->wmove    = ip->planemask;
222 }
223 #endif
224