Commit | Line | Data |
---|---|---|
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: grf_tc.c 1.13 89/08/25$ | |
13 | * | |
14 | * @(#)grf_tc.c 7.1 (Berkeley) %G% | |
15 | */ | |
16 | ||
17 | #include "grf.h" | |
18 | #if NGRF > 0 | |
19 | ||
20 | /* | |
21 | * Graphics routines for TOPCAT frame buffer | |
22 | */ | |
23 | #include "param.h" | |
24 | #include "errno.h" | |
25 | ||
26 | #include "grfioctl.h" | |
27 | #include "grfvar.h" | |
28 | #include "grf_tcreg.h" | |
29 | ||
30 | #include "machine/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 | #if defined(HP360) || defined(HP370) | |
48 | extern char grfregs[]; | |
49 | if (addr == (u_char *)grfregs) | |
50 | gi->gd_regaddr = (caddr_t) DIOIIBASE; | |
51 | else | |
52 | #endif | |
53 | gi->gd_regaddr = (caddr_t) UNIOV(addr); | |
54 | gi->gd_regsize = 0x10000; | |
55 | gi->gd_fbwidth = (tp->fbwmsb << 8) | tp->fbwlsb; | |
56 | gi->gd_fbheight = (tp->fbhmsb << 8) | tp->fbhlsb; | |
57 | fboff = (tp->fbomsb << 8) | tp->fbolsb; | |
58 | gi->gd_fbaddr = (caddr_t) (*(addr + fboff) << 16); | |
59 | #if defined(HP360) || defined(HP370) | |
60 | /* | |
61 | * For DIO II space addresses offset is relative to the DIO II space. | |
62 | * XXX: this should apply to all frame buffer types. | |
63 | */ | |
64 | if (gi->gd_regaddr >= (caddr_t)DIOIIBASE) | |
65 | gi->gd_fbaddr += (int) gi->gd_regaddr; | |
66 | #endif | |
67 | gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight; | |
68 | gi->gd_dwidth = (tp->dwmsb << 8) | tp->dwlsb; | |
69 | gi->gd_dheight = (tp->dhmsb << 8) | tp->dhlsb; | |
70 | gi->gd_planes = tp->num_planes; | |
71 | gi->gd_colors = 1 << gi->gd_planes; | |
72 | if (gi->gd_colors == 1) { | |
73 | fbp = (u_char *) IOV(gi->gd_fbaddr); | |
74 | tp->wen = ~0; | |
75 | tp->prr = 0x3; | |
76 | tp->fben = ~0; | |
77 | save = *fbp; | |
78 | *fbp = 0xFF; | |
79 | gi->gd_colors = *fbp + 1; | |
80 | *fbp = save; | |
81 | } | |
82 | return(1); | |
83 | } | |
84 | ||
85 | /* | |
86 | * Change the mode of the display. | |
87 | * Right now all we can do is grfon/grfoff. | |
88 | * Return a UNIX error number or 0 for success. | |
89 | * Function may not be needed anymore. | |
90 | */ | |
91 | /*ARGSUSED*/ | |
92 | tc_mode(gp, cmd) | |
93 | struct grf_softc *gp; | |
94 | { | |
95 | int error = 0; | |
96 | ||
97 | switch (cmd) { | |
98 | case GM_GRFON: | |
99 | case GM_GRFOFF: | |
100 | break; | |
101 | default: | |
102 | error = EINVAL; | |
103 | break; | |
104 | } | |
105 | return(error); | |
106 | } | |
107 | #endif |