141480Smckusick /*
241480Smckusick * Copyright (c) 1988 University of Utah.
3*63731Sbostic * Copyright (c) 1990, 1993
4*63731Sbostic * The Regents of the University of California. All rights reserved.
541480Smckusick *
641480Smckusick * This code is derived from software contributed to Berkeley by
741480Smckusick * the Systems Programming Group of the University of Utah Computer
841480Smckusick * Science Department.
941480Smckusick *
1041480Smckusick * %sccs.include.redist.c%
1141480Smckusick *
1263729Shibler * from: Utah $Hdr: ite_rb.c 1.19 93/06/25$
1341480Smckusick *
14*63731Sbostic * @(#)ite_rb.c 8.1 (Berkeley) 07/08/93
1541480Smckusick */
1641480Smckusick
1741480Smckusick #include "ite.h"
1841480Smckusick #if NITE > 0
1941480Smckusick
2056507Sbostic #include <sys/param.h>
2156507Sbostic #include <sys/conf.h>
2256507Sbostic #include <sys/proc.h>
2356507Sbostic #include <sys/ioctl.h>
2456507Sbostic #include <sys/tty.h>
2556507Sbostic #include <sys/systm.h>
2641480Smckusick
2756507Sbostic #include <hp/dev/itevar.h>
2856507Sbostic #include <hp/dev/itereg.h>
2956507Sbostic #include <hp300/dev/grf_rbreg.h>
3041480Smckusick
3156507Sbostic #include <machine/cpu.h>
3241480Smckusick
3341480Smckusick /* XXX */
3456507Sbostic #include <hp/dev/grfioctl.h>
3556507Sbostic #include <hp/dev/grfvar.h>
3641480Smckusick
3741480Smckusick #define REGBASE ((struct rboxfb *)(ip->regbase))
3841480Smckusick #define WINDOWMOVER rbox_windowmove
3941480Smckusick
4041480Smckusick rbox_init(ip)
4141480Smckusick struct ite_softc *ip;
4241480Smckusick {
4341480Smckusick register int i;
4441480Smckusick
4541480Smckusick /* XXX */
4641480Smckusick if (ip->regbase == 0) {
4753929Shibler struct grf_softc *gp = ip->grf;
4853929Shibler
4949312Shibler ip->regbase = gp->g_regkva;
5049312Shibler ip->fbbase = gp->g_fbkva;
5153929Shibler ip->fbwidth = gp->g_display.gd_fbwidth;
5253929Shibler ip->fbheight = gp->g_display.gd_fbheight;
5353929Shibler ip->dwidth = gp->g_display.gd_dwidth;
5453929Shibler ip->dheight = gp->g_display.gd_dheight;
5563729Shibler /*
5663729Shibler * XXX some displays (e.g. the davinci) appear
5763729Shibler * to return a display height greater than the
5863729Shibler * returned FB height. Guess we should go back
5963729Shibler * to getting the display dimensions from the
6063729Shibler * fontrom...
6163729Shibler */
6263729Shibler if (ip->dwidth > ip->fbwidth)
6363729Shibler ip->dwidth = ip->fbwidth;
6463729Shibler if (ip->dheight > ip->fbheight)
6563729Shibler ip->dheight = ip->fbheight;
6641480Smckusick }
6741480Smckusick
6853929Shibler rb_waitbusy(ip->regbase);
6941480Smckusick
7041480Smckusick REGBASE->reset = 0x39;
7141480Smckusick DELAY(1000);
7241480Smckusick
7341480Smckusick REGBASE->interrupt = 0x04;
7441480Smckusick REGBASE->display_enable = 0x01;
7541480Smckusick REGBASE->video_enable = 0x01;
7641480Smckusick REGBASE->drive = 0x01;
7741480Smckusick REGBASE->vdrive = 0x0;
7841480Smckusick
7953929Shibler ite_fontinfo(ip);
8041480Smckusick
8141480Smckusick REGBASE->opwen = 0xFF;
8241480Smckusick
8341480Smckusick /*
8441480Smckusick * Clear the framebuffer.
8541480Smckusick */
8641480Smckusick rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
8753929Shibler rb_waitbusy(ip->regbase);
8841480Smckusick
8941480Smckusick for(i = 0; i < 16; i++) {
9053929Shibler *(ip->regbase + 0x63c3 + i*4) = 0x0;
9153929Shibler *(ip->regbase + 0x6403 + i*4) = 0x0;
9253929Shibler *(ip->regbase + 0x6803 + i*4) = 0x0;
9353929Shibler *(ip->regbase + 0x6c03 + i*4) = 0x0;
9453929Shibler *(ip->regbase + 0x73c3 + i*4) = 0x0;
9553929Shibler *(ip->regbase + 0x7403 + i*4) = 0x0;
9653929Shibler *(ip->regbase + 0x7803 + i*4) = 0x0;
9753929Shibler *(ip->regbase + 0x7c03 + i*4) = 0x0;
9841480Smckusick }
9941480Smckusick
10041480Smckusick REGBASE->rep_rule = 0x33;
10141480Smckusick
10241480Smckusick /*
10341480Smckusick * I cannot figure out how to make the blink planes stop. So, we
10441480Smckusick * must set both colormaps so that when the planes blink, and
10541480Smckusick * the secondary colormap is active, we still get text.
10641480Smckusick */
10741480Smckusick CM1RED[0x00].value = 0x00;
10841480Smckusick CM1GRN[0x00].value = 0x00;
10941480Smckusick CM1BLU[0x00].value = 0x00;
11041480Smckusick CM1RED[0x01].value = 0xFF;
11141480Smckusick CM1GRN[0x01].value = 0xFF;
11241480Smckusick CM1BLU[0x01].value = 0xFF;
11341480Smckusick
11441480Smckusick CM2RED[0x00].value = 0x00;
11541480Smckusick CM2GRN[0x00].value = 0x00;
11641480Smckusick CM2BLU[0x00].value = 0x00;
11741480Smckusick CM2RED[0x01].value = 0xFF;
11841480Smckusick CM2GRN[0x01].value = 0xFF;
11941480Smckusick CM2BLU[0x01].value = 0xFF;
12041480Smckusick
12141480Smckusick REGBASE->blink = 0x00;
12241480Smckusick REGBASE->write_enable = 0x01;
12341480Smckusick REGBASE->opwen = 0x00;
12441480Smckusick
12541480Smckusick ite_fontinit(ip);
12641480Smckusick
12741480Smckusick /*
12841480Smckusick * Stash the inverted cursor.
12941480Smckusick */
13041480Smckusick rbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
13141480Smckusick ip->cblanky, ip->cblankx, ip->ftheight,
13241480Smckusick ip->ftwidth, RR_COPYINVERTED);
13341480Smckusick }
13441480Smckusick
13541480Smckusick rbox_deinit(ip)
13641480Smckusick struct ite_softc *ip;
13741480Smckusick {
13841480Smckusick rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
13953929Shibler rb_waitbusy(ip->regbase);
14041480Smckusick
14141480Smckusick ip->flags &= ~ITE_INITED;
14241480Smckusick }
14341480Smckusick
rbox_putc(ip,c,dy,dx,mode)14441480Smckusick rbox_putc(ip, c, dy, dx, mode)
14541480Smckusick register struct ite_softc *ip;
14641480Smckusick register int dy, dx;
14741480Smckusick int c, mode;
14841480Smckusick {
14941480Smckusick register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
15041480Smckusick
15141480Smckusick rbox_windowmove(ip, charY(ip, c), charX(ip, c),
15241480Smckusick dy * ip->ftheight, dx * ip->ftwidth,
15341480Smckusick ip->ftheight, ip->ftwidth, wrr);
15441480Smckusick }
15541480Smckusick
rbox_cursor(ip,flag)15641480Smckusick rbox_cursor(ip, flag)
15741480Smckusick register struct ite_softc *ip;
15841480Smckusick register int flag;
15941480Smckusick {
16041480Smckusick if (flag == DRAW_CURSOR)
16141480Smckusick draw_cursor(ip)
16241480Smckusick else if (flag == MOVE_CURSOR) {
16341480Smckusick erase_cursor(ip)
16441480Smckusick draw_cursor(ip)
16541480Smckusick }
16641480Smckusick else
16741480Smckusick erase_cursor(ip)
16841480Smckusick }
16941480Smckusick
17041480Smckusick rbox_clear(ip, sy, sx, h, w)
17141480Smckusick struct ite_softc *ip;
17241480Smckusick register int sy, sx, h, w;
17341480Smckusick {
17441480Smckusick rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
17541480Smckusick sy * ip->ftheight, sx * ip->ftwidth,
17641480Smckusick h * ip->ftheight, w * ip->ftwidth,
17741480Smckusick RR_CLEAR);
17841480Smckusick }
17941480Smckusick
rbox_scroll(ip,sy,sx,count,dir)18041480Smckusick rbox_scroll(ip, sy, sx, count, dir)
18141480Smckusick register struct ite_softc *ip;
18241480Smckusick register int sy, count;
18341480Smckusick int dir, sx;
18441480Smckusick {
18541480Smckusick register int dy;
18641480Smckusick register int dx = sx;
18741480Smckusick register int height = 1;
18841480Smckusick register int width = ip->cols;
18941480Smckusick
19041480Smckusick if (dir == SCROLL_UP) {
19141480Smckusick dy = sy - count;
19241480Smckusick height = ip->rows - sy;
19341480Smckusick }
19441480Smckusick else if (dir == SCROLL_DOWN) {
19541480Smckusick dy = sy + count;
19641480Smckusick height = ip->rows - dy - 1;
19741480Smckusick }
19841480Smckusick else if (dir == SCROLL_RIGHT) {
19941480Smckusick dy = sy;
20041480Smckusick dx = sx + count;
20141480Smckusick width = ip->cols - dx;
20241480Smckusick }
20341480Smckusick else {
20441480Smckusick dy = sy;
20541480Smckusick dx = sx - count;
20641480Smckusick width = ip->cols - sx;
20741480Smckusick }
20841480Smckusick
20941480Smckusick rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
21041480Smckusick dy * ip->ftheight, dx * ip->ftwidth,
21141480Smckusick height * ip->ftheight,
21241480Smckusick width * ip->ftwidth, RR_COPY);
21341480Smckusick }
21441480Smckusick
21541480Smckusick rbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
21641480Smckusick struct ite_softc *ip;
21741480Smckusick int sy, sx, dy, dx, h, w, func;
21841480Smckusick {
21941480Smckusick register struct rboxfb *rp = REGBASE;
22041480Smckusick if (h == 0 || w == 0)
22141480Smckusick return;
22241480Smckusick
22353929Shibler rb_waitbusy(ip->regbase);
22441480Smckusick rp->rep_rule = func << 4 | func;
22541480Smckusick rp->source_y = sy;
22641480Smckusick rp->source_x = sx;
22741480Smckusick rp->dest_y = dy;
22841480Smckusick rp->dest_x = dx;
22941480Smckusick rp->wheight = h;
23041480Smckusick rp->wwidth = w;
23141480Smckusick rp->wmove = 1;
23241480Smckusick }
23341480Smckusick #endif
234