xref: /csrg-svn/sys/hp/dev/ite_subr.c (revision 45507)
141480Smckusick /*
241480Smckusick  * Copyright (c) 1988 University of Utah.
341480Smckusick  * Copyright (c) 1990 The Regents of the University of California.
441480Smckusick  * 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  *
12*45507Smckusick  * from: Utah $Hdr: ite_subr.c 1.1 90/07/09$
1341480Smckusick  *
14*45507Smckusick  *	@(#)ite_subr.c	7.2 (Berkeley) 11/04/90
1541480Smckusick  */
1641480Smckusick 
1741480Smckusick #include "ite.h"
1841480Smckusick #if NITE > 0
1941480Smckusick 
2041480Smckusick #include "param.h"
2141480Smckusick #include "conf.h"
2241480Smckusick #include "user.h"
2341480Smckusick #include "proc.h"
2441480Smckusick #include "ioctl.h"
2541480Smckusick #include "tty.h"
2641480Smckusick #include "systm.h"
2741480Smckusick #include "uio.h"
2841480Smckusick 
2941480Smckusick #include "itevar.h"
3041480Smckusick #include "itereg.h"
3141480Smckusick 
3241480Smckusick #include "machine/cpu.h"
3341480Smckusick 
3441480Smckusick ite_devinfo(ip)
3541480Smckusick 	struct ite_softc *ip;
3641480Smckusick {
3741480Smckusick 	struct fontinfo *fi;
3841480Smckusick 	struct font *fd;
3941480Smckusick 
4041480Smckusick 	fi = (struct fontinfo *) ((*FONTROM << 8 | *(FONTROM + 2)) + REGADDR);
4141480Smckusick 	fd = (struct font *) ((fi->haddr << 8 | fi->laddr) + REGADDR);
4241480Smckusick 
4341480Smckusick 	ip->ftheight = fd->fh;
4441480Smckusick 	ip->ftwidth  = fd->fw;
4541480Smckusick 	ip->fbwidth  = ITEREGS->fbwidth_h << 8 | ITEREGS->fbwidth_l;
4641480Smckusick 	ip->fbheight = ITEREGS->fbheight_h << 8 | ITEREGS->fbheight_l;
4741480Smckusick 	ip->dwidth   = ITEREGS->dispwidth_h << 8 | ITEREGS->dispwidth_l;
4841480Smckusick 	ip->dheight  = ITEREGS->dispheight_h << 8 | ITEREGS->dispheight_l;
4941480Smckusick 	ip->rows     = ip->dheight / ip->ftheight;
5041480Smckusick 	ip->cols     = ip->dwidth / ip->ftwidth;
5141480Smckusick 
5241480Smckusick 	if (ip->fbwidth > ip->dwidth) {
5341480Smckusick 		/*
5441480Smckusick 		 * Stuff goes to right of display.
5541480Smckusick 		 */
5641480Smckusick 		ip->fontx    = ip->dwidth;
5741480Smckusick 		ip->fonty    = 0;
5841480Smckusick 		ip->cpl      = (ip->fbwidth - ip->dwidth) / ip->ftwidth;
5941480Smckusick 		ip->cblankx  = ip->dwidth;
6041480Smckusick 		ip->cblanky  = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
6141480Smckusick 	}
6241480Smckusick 	else {
6341480Smckusick 		/*
6441480Smckusick 		 * Stuff goes below the display.
6541480Smckusick 		 */
6641480Smckusick 		ip->fontx   = 0;
6741480Smckusick 		ip->fonty   = ip->dheight;
6841480Smckusick 		ip->cpl     = ip->fbwidth / ip->ftwidth;
6941480Smckusick 		ip->cblankx = 0;
7041480Smckusick 		ip->cblanky = ip->fonty + ((128 / ip->cpl) + 1) * ip->ftheight;
7141480Smckusick 	}
7241480Smckusick }
7341480Smckusick 
7441480Smckusick ite_fontinit(ip)
7541480Smckusick 	register struct ite_softc *ip;
7641480Smckusick {
7741480Smckusick 	struct fontinfo *fi;
7841480Smckusick 	struct font *fd;
7941480Smckusick 	register u_char *fbmem, *dp;
8041480Smckusick 	register int bn;
8141480Smckusick 	int c, l, b;
8241480Smckusick 
8341480Smckusick 	fi = (struct fontinfo *) ((*FONTROM << 8 | *(FONTROM + 2)) + REGADDR);
8441480Smckusick 	fd = (struct font *) ((fi->haddr << 8 | fi->laddr) + REGADDR);
8541480Smckusick 
8641480Smckusick 	dp = fd->data;
8741480Smckusick 
8841480Smckusick 	for (c = 0; c < 128; c++) {
8941480Smckusick 		fbmem = (u_char *) FBBASE +
9041480Smckusick 			(ip->fonty + (c / ip->cpl) * ip->ftheight) *
9141480Smckusick 			ip->fbwidth;
9241480Smckusick 		fbmem += ip->fontx + (c % ip->cpl) * ip->ftwidth;
9341480Smckusick 		for (l = 0; l < ip->ftheight; l++) {
9441480Smckusick 			bn = 7;
9541480Smckusick 			for (b = 0; b < ip->ftwidth; b++) {
9641480Smckusick 				if ((1 << bn) & *dp)
9741480Smckusick 					*fbmem++ = 1;
9841480Smckusick 				else
9941480Smckusick 					*fbmem++ = 0;
10041480Smckusick 				if (--bn < 0) {
10141480Smckusick 					bn = 7;
10241480Smckusick 					dp += 2;
10341480Smckusick 				}
10441480Smckusick 			}
10541480Smckusick 			if (bn < 7)
10641480Smckusick 				dp += 2;
10741480Smckusick 			fbmem -= ip->ftwidth;
10841480Smckusick 			fbmem += ip->fbwidth;
10941480Smckusick 		}
11041480Smckusick 	}
11141480Smckusick 
11241480Smckusick }
11341480Smckusick #endif
114