|
|
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 is only permitted until one year after the first shipment
11: * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and
12: * binary forms are permitted provided that: (1) source distributions retain
13: * this entire copyright notice and comment, and (2) distributions including
14: * binaries display the following acknowledgement: This product includes
15: * software developed by the University of California, Berkeley and its
16: * contributors'' in the documentation or other materials provided with the
17: * distribution and in all advertising materials mentioning features or use
18: * of this software. Neither the name of the University nor the names of
19: * its contributors may be used to endorse or promote products derived from
20: * this software without specific prior written permission.
21: * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
22: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
23: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
24: *
25: * from: Utah $Hdr: grf_gb.c 1.13 89/04/11$
26: *
27: * @(#)grf_gb.c 7.1 (Berkeley) 5/8/90
28: */
29:
30: #include "grf.h"
31: #if NGRF > 0
32:
33: /*
34: * Graphics routines for the Gatorbox.
35: *
36: * Note: In the context of this system, "gator" and "gatorbox" both refer to
37: * HP 987x0 graphics systems. "Gator" is not used for high res mono.
38: * (as in 9837 Gator systems)
39: */
40: #include "param.h"
41: #include "errno.h"
42:
43: #include "grfioctl.h"
44: #include "grfvar.h"
45: #include "grf_gbreg.h"
46:
47: #include "machine/cpu.h"
48:
49: #define CRTC_DATA_LENGTH 0x0e
50: u_char crtc_init_data[CRTC_DATA_LENGTH] = {
51: 0x29, 0x20, 0x23, 0x04, 0x30, 0x0b, 0x30,
52: 0x30, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00
53: };
54:
55: /*
56: * Initialize hardware.
57: * Must point g_display at a grfinfo structure describing the hardware.
58: * Returns 0 if hardware not present, non-zero ow.
59: */
60: gb_init(gp, addr)
61: struct grf_softc *gp;
62: u_char *addr;
63: {
64: register struct gboxfb *gbp;
65: struct grfinfo *gi = &gp->g_display;
66: u_char *fbp, save;
67: int fboff;
68:
69: gbp = (struct gboxfb *) addr;
70: gi->gd_regaddr = (caddr_t) UNIOV(addr);
71: gi->gd_regsize = 0x10000;
72: gi->gd_fbwidth = 1024; /* XXX */
73: gi->gd_fbheight = 1024; /* XXX */
74: fboff = (gbp->fbomsb << 8) | gbp->fbolsb;
75: gi->gd_fbaddr = (caddr_t) (*(addr + fboff) << 16);
76: gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight;
77: gi->gd_dwidth = 1024; /* XXX */
78: gi->gd_dheight = 768; /* XXX */
79: gi->gd_planes = 0; /* how do we do this? */
80: /*
81: * The minimal register info here is from the Gatorbox X driver.
82: */
83: fbp = (u_char *) IOV(gi->gd_fbaddr);
84: gbp->write_protect = 0;
85: gbp->interrupt = 4; /** fb_enable ? **/
86: gbp->rep_rule = 3; /* GXcopy */
87: gbp->blink1 = 0xff;
88: gbp->blink2 = 0xff;
89:
90: gb_microcode(gbp);
91:
92: /*
93: * Find out how many colors are available by determining
94: * which planes are installed. That is, write all ones to
95: * a frame buffer location, see how many ones are read back.
96: */
97: save = *fbp;
98: *fbp = 0xFF;
99: gi->gd_colors = *fbp + 1;
100: *fbp = save;
101: return(1);
102: }
103:
104: /*
105: * Program the 6845.
106: */
107: gb_microcode(gbp)
108: register struct gboxfb *gbp;
109: {
110: register int i;
111:
112: for (i = 0; i < CRTC_DATA_LENGTH; i++) {
113: gbp->crtc_address = i;
114: gbp->crtc_data = crtc_init_data[i];
115: }
116: }
117:
118: /*
119: * Change the mode of the display.
120: * Right now all we can do is grfon/grfoff.
121: * Return a UNIX error number or 0 for success.
122: */
123: gb_mode(gp, cmd)
124: register struct grf_softc *gp;
125: {
126: struct gboxfb *gbp;
127: int error = 0;
128:
129: gbp = (struct gboxfb *) IOV(gp->g_display.gd_regaddr);
130: switch (cmd) {
131: case GM_GRFON:
132: gbp->sec_interrupt = 1;
133: break;
134: case GM_GRFOFF:
135: break;
136: default:
137: error = EINVAL;
138: break;
139: }
140: return(error);
141: }
142:
143: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.