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