xref: /original-bsd/sys/hp300/dev/grf_tc.c (revision acda45c0)
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: grf_tc.c 1.13 89/08/25$
13  *
14  *	@(#)grf_tc.c	7.3 (Berkeley) 12/16/90
15  */
16 
17 #include "grf.h"
18 #if NGRF > 0
19 
20 /*
21  * Graphics routines for TOPCAT frame buffer
22  */
23 #include "sys/param.h"
24 #include "sys/errno.h"
25 
26 #include "grfioctl.h"
27 #include "grfvar.h"
28 #include "grf_tcreg.h"
29 
30 #include "../include/cpu.h"
31 
32 /*
33  * Initialize hardware.
34  * Must fill in the grfinfo structure in g_softc.
35  * Returns 0 if hardware not present, non-zero ow.
36  */
37 tc_init(gp, addr)
38 	struct grf_softc *gp;
39 	u_char *addr;
40 {
41 	register struct tcboxfb *tp = (struct tcboxfb *) addr;
42 	struct grfinfo *gi = &gp->g_display;
43 	volatile u_char *fbp;
44 	u_char save;
45 	int fboff;
46 
47 	gi->gd_regaddr = (caddr_t) UNIOV(addr);
48 	gi->gd_regsize = 0x10000;
49 	gi->gd_fbwidth = (tp->fbwmsb << 8) | tp->fbwlsb;
50 	gi->gd_fbheight = (tp->fbhmsb << 8) | tp->fbhlsb;
51 	fboff = (tp->fbomsb << 8) | tp->fbolsb;
52 	gi->gd_fbaddr = (caddr_t) (*(addr + fboff) << 16);
53 	gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight;
54 	gi->gd_dwidth = (tp->dwmsb << 8) | tp->dwlsb;
55 	gi->gd_dheight = (tp->dhmsb << 8) | tp->dhlsb;
56 	gi->gd_planes = tp->num_planes;
57 	gi->gd_colors = 1 << gi->gd_planes;
58 	if (gi->gd_colors == 1) {
59 		fbp = (u_char *) IOV(gi->gd_fbaddr);
60 		tp->wen = ~0;
61 		tp->prr = 0x3;
62 		tp->fben = ~0;
63 		save = *fbp;
64 		*fbp = 0xFF;
65 		gi->gd_colors = *fbp + 1;
66 		*fbp = save;
67 	}
68 	return(1);
69 }
70 
71 /*
72  * Change the mode of the display.
73  * Right now all we can do is grfon/grfoff.
74  * Return a UNIX error number or 0 for success.
75  * Function may not be needed anymore.
76  */
77 /*ARGSUSED*/
78 tc_mode(gp, cmd)
79 	struct grf_softc *gp;
80 {
81 	int error = 0;
82 
83 	switch (cmd) {
84 	case GM_GRFON:
85 	case GM_GRFOFF:
86 		break;
87 	default:
88 		error = EINVAL;
89 		break;
90 	}
91 	return(error);
92 }
93 #endif
94