xref: /csrg-svn/sys/hp300/dev/grf_rb.c (revision 41480)
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_rb.c 1.10 89/04/11$
13  *
14  *	@(#)grf_rb.c	7.1 (Berkeley) 05/08/90
15  */
16 
17 #include "grf.h"
18 #if NGRF > 0
19 
20 /*
21  * Graphics routines for the Renaissance, HP98720 Graphics system.
22  */
23 #include "param.h"
24 #include "errno.h"
25 
26 #include "grfioctl.h"
27 #include "grfvar.h"
28 #include "grf_rbreg.h"
29 
30 #include "machine/cpu.h"
31 
32 #ifdef notyet
33 static short rb_microcode[] = {
34 	0x5efe, 0x8a38, 0x0000, 0x0000, 0x0f00, 0, 0, 0,
35 	0x3efe, 0x8a38, 0x0000, 0x7003, 0xf706, 0, 0, 0,
36 	0x1efe, 0x8a38, 0x0000, 0x0000, 0x0000, 0, 0, 0,
37 	0x3efe, 0x8a38, 0x0000, 0x7003, 0xfc06, 0, 0, 0,
38 	0x1efe, 0x8a38, 0x0000, 0x0000, 0x0000, 0, 0, 0,
39 	0x3efe, 0x8a38, 0x0004, 0x40f7, 0xa006, 0, 0, 0,
40 	0x9efe, 0x8a38, 0x0000, 0x0000, 0x0000, 0, 0, 0,
41 	0x1efe, 0x8a38, 0x0000, 0x0000, 0x0000
42 };
43 #endif
44 
45 /*
46  * Initialize hardware.
47  * Must point g_display at a grfinfo structure describing the hardware.
48  * Returns 0 if hardware not present, non-zero ow.
49  */
50 rb_init(gp, addr)
51 	struct grf_softc *gp;
52 	u_char *addr;
53 {
54 	register struct rboxfb *rbp;
55 	struct grfinfo *gi = &gp->g_display;
56 	int fboff;
57 
58 	rbp = (struct rboxfb *) addr;
59 	gi->gd_regaddr = (caddr_t) UNIOV(addr);
60 	gi->gd_regsize = 0x20000;
61 	gi->gd_fbwidth = (rbp->fbwmsb << 8) | rbp->fbwlsb;
62 	gi->gd_fbheight = (rbp->fbhmsb << 8) | rbp->fbhlsb;
63 	fboff = (rbp->fbomsb << 8) | rbp->fbolsb;
64 	gi->gd_fbaddr = (caddr_t) (*(addr + fboff) << 16);
65 	gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight;
66 	gi->gd_dwidth = (rbp->dwmsb << 8) | rbp->dwlsb;
67 	gi->gd_dheight = (rbp->dwmsb << 8) | rbp->dwlsb;
68 	gi->gd_planes = 0;	/* ?? */
69 	gi->gd_colors = 256;
70 	return(1);
71 }
72 
73 #ifdef notyet
74 /*
75  * Download the microcode to the rbox.
76  */
77 rb_download_microcode(regbase)
78      caddr_t regbase;
79 {
80 	register short *rb_microcode_ptr = rb_microcode;
81 	register short *rb_cntlstore_ptr = (short *)((char *)regbase + 0xC000);
82 	register int i;
83 
84 	/*
85 	 * Reset and halt transform engine
86 	 */
87 	*((char *)regbase + 0x8002) = 0x00a0;
88 	*((char *)regbase + 0x8002) = 0x0020;
89 	*((char *)regbase + 0x8002) = 0x0080;
90 
91 	/*
92 	 * Select the first bank of control store.
93 	 */
94 	*((char *)regbase + 0x8007) = 0x0;
95 
96 	/*
97 	 * Write the microcode into the control store address space.
98 	 */
99 	for (i = 0; i < sizeof(rb_microcode) / sizeof(rb_microcode[0]); i++)
100 		*rb_cntlstore_ptr++ = *rb_microcode_ptr++;
101 
102 	/*
103 	 * Start microcode execution.
104 	 */
105 	*(short *)((char *)regbase + 0x8002) = 0x2000;
106 	*(short *)((char *)regbase + 0x8002) = 0x0;
107 
108 	/*
109 	 * wait for renaissance to finish up.
110 	 */
111 	for (i = 0; i < 1000; i++) {
112 		if (*((char *)regbase + 0x8012) < 0)
113 			continue;
114 	}
115 }
116 #endif
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 rb_mode(gp, cmd)
124 	register struct grf_softc *gp;
125 {
126 	register struct rboxfb *rbp;
127 	int error = 0;
128 
129 	rbp = (struct rboxfb *) IOV(gp->g_display.gd_regaddr);
130 	switch (cmd) {
131 	/*
132 	 * The minimal register info here is from the Renaissance X driver.
133 	 */
134 	case GM_GRFON:
135 	case GM_GRFOFF:
136 		break;
137 	case GM_GRFOVON:
138 		rbp->write_enable = 0;
139 		rbp->opwen = 0xF;
140 		rbp->drive = 0x10;
141 		break;
142 	case GM_GRFOVOFF:
143 		rbp->opwen = 0;
144 		rbp->write_enable = 0xffffffff;
145 		rbp->drive = 0x01;
146 		break;
147 	default:
148 		error = EINVAL;
149 		break;
150 	}
151 	return(error);
152 }
153 
154 #endif
155