|
|
1.1 root 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: * Redistribution and use in source and binary forms, with or without
11: * modification, are permitted provided that the following conditions
12: * are met:
13: * 1. Redistributions of source code must retain the above copyright
14: * notice, this list of conditions and the following disclaimer.
15: * 2. Redistributions in binary form must reproduce the above copyright
16: * notice, this list of conditions and the following disclaimer in the
17: * documentation and/or other materials provided with the distribution.
18: * 3. All advertising materials mentioning features or use of this software
19: * must display the following acknowledgement:
20: * This product includes software developed by the University of
21: * California, Berkeley and its contributors.
22: * 4. Neither the name of the University nor the names of its contributors
23: * may be used to endorse or promote products derived from this software
24: * without specific prior written permission.
25: *
26: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36: * SUCH DAMAGE.
37: *
38: * from: Utah $Hdr: grf_gb.c 1.16 91/04/02$
39: *
40: * @(#)grf_gb.c 7.4 (Berkeley) 5/7/91
41: */
42:
43: #include "grf.h"
44: #if NGRF > 0
45:
46: /*
47: * Graphics routines for the Gatorbox.
48: *
49: * Note: In the context of this system, "gator" and "gatorbox" both refer to
50: * HP 987x0 graphics systems. "Gator" is not used for high res mono.
51: * (as in 9837 Gator systems)
52: */
53: #include "sys/param.h"
54: #include "sys/errno.h"
55:
56: #include "grfioctl.h"
57: #include "grfvar.h"
58: #include "grf_gbreg.h"
59:
60: #include "../include/cpu.h"
61:
62: #define CRTC_DATA_LENGTH 0x0e
63: u_char crtc_init_data[CRTC_DATA_LENGTH] = {
64: 0x29, 0x20, 0x23, 0x04, 0x30, 0x0b, 0x30,
65: 0x30, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00
66: };
67:
68: /*
69: * Initialize hardware.
70: * Must point g_display at a grfinfo structure describing the hardware.
71: * Returns 0 if hardware not present, non-zero ow.
72: */
73: gb_init(gp, addr)
74: struct grf_softc *gp;
75: caddr_t addr;
76: {
77: register struct gboxfb *gbp;
78: struct grfinfo *gi = &gp->g_display;
79: u_char *fbp, save;
80: int fboff;
81: extern caddr_t sctopa(), iomap();
82:
83: gbp = (struct gboxfb *) addr;
84: if (ISIIOVA(addr))
85: gi->gd_regaddr = (caddr_t) IIOP(addr);
86: else
87: gi->gd_regaddr = sctopa(vatosc(addr));
88: gi->gd_regsize = 0x10000;
89: gi->gd_fbwidth = 1024; /* XXX */
90: gi->gd_fbheight = 1024; /* XXX */
91: gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight;
92: fboff = (gbp->fbomsb << 8) | gbp->fbolsb;
93: gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16);
94: gp->g_regkva = addr;
95: gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize);
96: gi->gd_dwidth = 1024; /* XXX */
97: gi->gd_dheight = 768; /* XXX */
98: gi->gd_planes = 0; /* how do we do this? */
99: /*
100: * The minimal register info here is from the Gatorbox X driver.
101: */
102: fbp = (u_char *) gp->g_fbkva;
103: gbp->write_protect = 0;
104: gbp->interrupt = 4; /** fb_enable ? **/
105: gbp->rep_rule = 3; /* GXcopy */
106: gbp->blink1 = 0xff;
107: gbp->blink2 = 0xff;
108:
109: gb_microcode(gbp);
110:
111: /*
112: * Find out how many colors are available by determining
113: * which planes are installed. That is, write all ones to
114: * a frame buffer location, see how many ones are read back.
115: */
116: save = *fbp;
117: *fbp = 0xFF;
118: gi->gd_colors = *fbp + 1;
119: *fbp = save;
120: return(1);
121: }
122:
123: /*
124: * Program the 6845.
125: */
126: gb_microcode(gbp)
127: register struct gboxfb *gbp;
128: {
129: register int i;
130:
131: for (i = 0; i < CRTC_DATA_LENGTH; i++) {
132: gbp->crtc_address = i;
133: gbp->crtc_data = crtc_init_data[i];
134: }
135: }
136:
137: /*
138: * Change the mode of the display.
139: * Right now all we can do is grfon/grfoff.
140: * Return a UNIX error number or 0 for success.
141: */
142: gb_mode(gp, cmd)
143: register struct grf_softc *gp;
144: {
145: struct gboxfb *gbp;
146: int error = 0;
147:
148: gbp = (struct gboxfb *) gp->g_regkva;
149: switch (cmd) {
150: case GM_GRFON:
151: gbp->sec_interrupt = 1;
152: break;
153: case GM_GRFOFF:
154: break;
155: default:
156: error = EINVAL;
157: break;
158: }
159: return(error);
160: }
161:
162: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.