update from Mike Hibler
[unix-history] / usr / src / sys / hp300 / dev / ite_dv.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 *
12 * from: Utah $Hdr: ite_dv.c 1.5 89/04/11$
13 *
14 * @(#)ite_dv.c 7.1 (Berkeley) %G%
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_dvreg.h"
32
33#include "machine/cpu.h"
34
35/* XXX */
36#include "grfioctl.h"
37#include "grfvar.h"
38
39#define REGBASE ((struct dvboxfb *)(ip->regbase))
40#define WINDOWMOVER dvbox_windowmove
41
42dvbox_init(ip)
43 struct ite_softc *ip;
44{
45 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 dv_reset(REGADDR);
55
56 /*
57 * Turn on frame buffer, turn on overlay planes, set replacement
58 * rule, enable top overlay plane writes for ite, disable all frame
59 * buffer planes, set byte per pixel, and display frame buffer 0.
60 * Lastly, turn on the box.
61 */
62 REGBASE->interrupt = 0x04;
63 REGBASE->drive = 0x10;
64 REGBASE->rep_rule = RR_COPY << 4 | RR_COPY;
65 REGBASE->opwen = 0x01;
66 REGBASE->fbwen = 0x0;
67 REGBASE->fold = 0x01;
68 REGBASE->vdrive = 0x0;
69 REGBASE->dispen = 0x01;
70
71 /*
72 * Video enable top overlay plane.
73 */
74 REGBASE->opvenp = 0x01;
75 REGBASE->opvens = 0x01;
76
77 /*
78 * Make sure that overlay planes override frame buffer planes.
79 */
80 REGBASE->ovly0p = 0x0;
81 REGBASE->ovly0s = 0x0;
82 REGBASE->ovly1p = 0x0;
83 REGBASE->ovly1s = 0x0;
84 REGBASE->fv_trig = 0x1;
85 DELAY(100);
86
87 /*
88 * Setup the overlay colormaps. Need to set the 0,1 (black/white)
89 * color for both banks.
90 */
91
92 for (i = 0; i <= 1; i++) {
93 REGBASE->cmapbank = i;
94 REGBASE->rgb[0].red = 0x00;
95 REGBASE->rgb[0].green = 0x00;
96 REGBASE->rgb[0].blue = 0x00;
97 REGBASE->rgb[1].red = 0xFF;
98 REGBASE->rgb[1].green = 0xFF;
99 REGBASE->rgb[1].blue = 0xFF;
100 }
101 REGBASE->cmapbank = 0;
102
103 db_waitbusy(REGADDR);
104
105 ite_devinfo(ip);
106 ite_fontinit(ip);
107
108 /*
109 * Clear the (visible) framebuffer.
110 */
111 dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
112 db_waitbusy(REGADDR);
113
114 /*
115 * Stash the inverted cursor.
116 */
117 dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
118 ip->cblanky, ip->cblankx, ip->ftheight,
119 ip->ftwidth, RR_COPYINVERTED);
120}
121
122dvbox_deinit(ip)
123 struct ite_softc *ip;
124{
125 dvbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
126 db_waitbusy(REGADDR);
127
128 ip->flags &= ~ITE_INITED;
129}
130
131dvbox_putc(ip, c, dy, dx, mode)
132 register struct ite_softc *ip;
133 register int dy, dx;
134 int c, mode;
135{
136 register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
137
138 dvbox_windowmove(ip, charY(ip, c), charX(ip, c),
139 dy * ip->ftheight, dx * ip->ftwidth,
140 ip->ftheight, ip->ftwidth, wrr);
141}
142
143dvbox_cursor(ip, flag)
144 register struct ite_softc *ip;
145 register int flag;
146{
147 if (flag == DRAW_CURSOR)
148 draw_cursor(ip)
149 else if (flag == MOVE_CURSOR) {
150 erase_cursor(ip)
151 draw_cursor(ip)
152 }
153 else
154 erase_cursor(ip)
155}
156
157dvbox_clear(ip, sy, sx, h, w)
158 struct ite_softc *ip;
159 register int sy, sx, h, w;
160{
161 dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
162 sy * ip->ftheight, sx * ip->ftwidth,
163 h * ip->ftheight, w * ip->ftwidth,
164 RR_CLEAR);
165}
166
167dvbox_scroll(ip, sy, sx, count, dir)
168 register struct ite_softc *ip;
169 register int sy, count;
170 int dir, sx;
171{
172 register int dy;
173 register int dx = sx;
174 register int height = 1;
175 register int width = ip->cols;
176
177 dvbox_cursor(ip, ERASE_CURSOR);
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 dvbox_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
204dvbox_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 dvboxfb *dp = REGBASE;
209 if (h == 0 || w == 0)
210 return;
211
212 db_waitbusy(REGADDR);
213 dp->rep_rule = func << 4 | func;
214 dp->source_y = sy;
215 dp->source_x = sx;
216 dp->dest_y = dy;
217 dp->dest_x = dx;
218 dp->wheight = h;
219 dp->wwidth = w;
220 dp->wmove = 1;
221}
222#endif