xref: /original-bsd/sys/hp300/dev/grf_rb.c (revision 703f6d5d)
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.13 91/04/02$
13  *
14  *	@(#)grf_rb.c	7.5 (Berkeley) 05/07/91
15  */
16 
17 #include "grf.h"
18 #if NGRF > 0
19 
20 /*
21  * Graphics routines for the Renaissance, HP98720 Graphics system.
22  */
23 #include "sys/param.h"
24 #include "sys/errno.h"
25 
26 #include "grfioctl.h"
27 #include "grfvar.h"
28 #include "grf_rbreg.h"
29 
30 #include "../include/cpu.h"
31 
32 /*
33  * Initialize hardware.
34  * Must point g_display at a grfinfo structure describing the hardware.
35  * Returns 0 if hardware not present, non-zero ow.
36  */
37 rb_init(gp, addr)
38 	struct grf_softc *gp;
39 	caddr_t addr;
40 {
41 	register struct rboxfb *rbp;
42 	struct grfinfo *gi = &gp->g_display;
43 	int fboff;
44 	extern caddr_t sctopa(), iomap();
45 
46 	rbp = (struct rboxfb *) addr;
47 	if (ISIIOVA(addr))
48 		gi->gd_regaddr = (caddr_t) IIOP(addr);
49 	else
50 		gi->gd_regaddr = sctopa(vatosc(addr));
51 	gi->gd_regsize = 0x20000;
52 	gi->gd_fbwidth = (rbp->fbwmsb << 8) | rbp->fbwlsb;
53 	gi->gd_fbheight = (rbp->fbhmsb << 8) | rbp->fbhlsb;
54 	gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight;
55 	fboff = (rbp->fbomsb << 8) | rbp->fbolsb;
56 	gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16);
57 	if (gi->gd_regaddr >= (caddr_t)DIOIIBASE) {
58 		/*
59 		 * For DIO II space the fbaddr just computed is the offset
60 		 * from the select code base (regaddr) of the framebuffer.
61 		 * Hence it is also implicitly the size of the register set.
62 		 */
63 		gi->gd_regsize = (int) gi->gd_fbaddr;
64 		gi->gd_fbaddr += (int) gi->gd_regaddr;
65 		gp->g_regkva = addr;
66 		gp->g_fbkva = addr + gi->gd_regsize;
67 	} else {
68 		/*
69 		 * For DIO space we need to map the seperate framebuffer.
70 		 */
71 		gp->g_regkva = addr;
72 		gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize);
73 	}
74 	gi->gd_dwidth = (rbp->dwmsb << 8) | rbp->dwlsb;
75 	gi->gd_dheight = (rbp->dwmsb << 8) | rbp->dwlsb;
76 	gi->gd_planes = 0;	/* ?? */
77 	gi->gd_colors = 256;
78 	return(1);
79 }
80 
81 /*
82  * Change the mode of the display.
83  * Right now all we can do is grfon/grfoff.
84  * Return a UNIX error number or 0 for success.
85  */
86 rb_mode(gp, cmd)
87 	register struct grf_softc *gp;
88 {
89 	register struct rboxfb *rbp;
90 	int error = 0;
91 
92 	rbp = (struct rboxfb *) gp->g_regkva;
93 	switch (cmd) {
94 	/*
95 	 * The minimal register info here is from the Renaissance X driver.
96 	 */
97 	case GM_GRFON:
98 	case GM_GRFOFF:
99 		break;
100 	case GM_GRFOVON:
101 		rbp->write_enable = 0;
102 		rbp->opwen = 0xF;
103 		rbp->drive = 0x10;
104 		break;
105 	case GM_GRFOVOFF:
106 		rbp->opwen = 0;
107 		rbp->write_enable = 0xffffffff;
108 		rbp->drive = 0x01;
109 		break;
110 	default:
111 		error = EINVAL;
112 		break;
113 	}
114 	return(error);
115 }
116 
117 #endif
118