xref: /original-bsd/sys/hp300/dev/grf_dv.c (revision f3c03cba)
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_dv.c 1.1 90/07/09$
13  *
14  *	@(#)grf_dv.c	7.3 (Berkeley) 12/16/90
15  */
16 
17 #include "grf.h"
18 #if NGRF > 0
19 
20 /*
21  * Graphics routines for the DaVinci, HP98730/98731 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_dvreg.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 dv_init(gp, addr)
38 	struct grf_softc *gp;
39 	u_char *addr;
40 {
41 	register struct dvboxfb *dbp;
42 	struct grfinfo *gi = &gp->g_display;
43 	int fboff;
44 
45 	dbp = (struct dvboxfb *) addr;
46 	gi->gd_regaddr = (caddr_t) UNIOV(addr);
47 	gi->gd_regsize = 0x20000;
48 	gi->gd_fbwidth = (dbp->fbwmsb << 8) | dbp->fbwlsb;
49 	gi->gd_fbheight = (dbp->fbhmsb << 8) | dbp->fbhlsb;
50 	fboff = (dbp->fbomsb << 8) | dbp->fbolsb;
51 	gi->gd_fbaddr = (caddr_t) (*(addr + fboff) << 16);
52 	gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight;
53 	gi->gd_dwidth = (dbp->dwmsb << 8) | dbp->dwlsb;
54 	gi->gd_dheight = (dbp->dwmsb << 8) | dbp->dwlsb;
55 	gi->gd_planes = 0;	/* ?? */
56 	gi->gd_colors = 256;
57 
58 	dv_reset(dbp);
59 	return(1);
60 }
61 
62 /*
63  *  Magic code herein.
64  */
65 dv_reset(dbp)
66 	register struct dvboxfb *dbp;
67 {
68   	dbp->reset = 0x80;
69 	DELAY(100);
70 
71 	dbp->interrupt = 0x04;
72 	dbp->en_scan   = 0x01;
73 	dbp->fbwen     = ~0;
74 	dbp->opwen     = ~0;
75 	dbp->fold      = 0x01;
76 	dbp->drive     = 0x01;
77 	dbp->rep_rule  = 0x33;
78 	dbp->alt_rr    = 0x33;
79 	dbp->zrr       = 0x33;
80 
81 	dbp->fbvenp    = 0xFF;
82 	dbp->dispen    = 0x01;
83 	dbp->fbvens    = 0x0;
84 	dbp->fv_trig   = 0x01;
85 	DELAY(100);
86 	dbp->vdrive    = 0x0;
87 	dbp->zconfig   = 0x0;
88 
89 	while (dbp->wbusy & 0x01)
90 	  DELAY(100);
91 
92 	dbp->cmapbank = 0;
93 
94 	dbp->red0   = 0;
95 	dbp->red1   = 0;
96 	dbp->green0 = 0;
97 	dbp->green1 = 0;
98 	dbp->blue0  = 0;
99 	dbp->blue1  = 0;
100 
101 	dbp->panxh   = 0;
102 	dbp->panxl   = 0;
103 	dbp->panyh   = 0;
104 	dbp->panyl   = 0;
105 	dbp->zoom    = 0;
106 	dbp->cdwidth = 0x50;
107 	dbp->chstart = 0x52;
108 	dbp->cvwidth = 0x22;
109 	dbp->pz_trig = 1;
110 }
111 
112 /*
113  * Change the mode of the display.
114  * Right now all we can do is grfon/grfoff.
115  * Return a UNIX error number or 0 for success.
116  */
117 dv_mode(gp, cmd)
118 	register struct grf_softc *gp;
119 {
120 	register struct dvboxfb *dbp;
121 	int error = 0;
122 
123 	dbp = (struct dvboxfb *) IOV(gp->g_display.gd_regaddr);
124 	switch (cmd) {
125 	case GM_GRFON:
126 	  	dbp->dispen = 0x01;
127 	  	break;
128 	case GM_GRFOFF:
129 		break;
130 	case GM_GRFOVON:
131 		dbp->opwen = 0xF;
132 		dbp->drive = 0x10;
133 		break;
134 	case GM_GRFOVOFF:
135 		dbp->opwen = 0;
136 		dbp->drive = 0x01;
137 		break;
138 	default:
139 		error = EINVAL;
140 		break;
141 	}
142 	return(error);
143 }
144 
145 #endif
146