1 /*        $NetBSD: ite_dv.c,v 1.10 2011/02/10 12:46:22 tsutsui Exp $  */
2 
3 /*
4  * Copyright (c) 1988 University of Utah.
5  * Copyright (c) 1990, 1993
6  *        The Regents of the University of California.  All rights reserved.
7  *
8  * This code is derived from software contributed to Berkeley by
9  * the Systems Programming Group of the University of Utah Computer
10  * Science Department.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. Neither the name of the University nor the names of its contributors
21  *    may be used to endorse or promote products derived from this software
22  *    without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  *
36  * from: Utah $Hdr: ite_dv.c 1.2 92/01/20$
37  *
38  *        @(#)ite_dv.c        8.1 (Berkeley) 6/10/93
39  */
40 
41 #ifdef ITECONSOLE
42 
43 #include <sys/param.h>
44 
45 #include <hp300/stand/common/itereg.h>
46 #include <hp300/stand/common/grf_dvreg.h>
47 
48 #include <hp300/stand/common/samachdep.h>
49 #include <hp300/stand/common/itevar.h>
50 
51 static void dv_reset(struct dvboxfb *);
52 static void dvbox_windowmove(struct ite_data *, int, int, int, int,
53     int, int, int);
54 
55 void
dvbox_init(struct ite_data * ip)56 dvbox_init(struct ite_data *ip)
57 {
58           struct dvboxfb *regbase;
59           int i;
60 
61           ip->bmv = dvbox_windowmove;
62           regbase = (void *)ip->regbase;
63           dv_reset(regbase);
64           DELAY(4000);
65 
66           /*
67            * Turn on frame buffer, turn on overlay planes, set replacement
68            * rule, enable top overlay plane writes for ite, disable all frame
69            * buffer planes, set byte per pixel, and display frame buffer 0.
70            * Lastly, turn on the box.
71            */
72           regbase->interrupt = 0x04;
73           regbase->drive     = 0x10;
74           regbase->rep_rule  = RR_COPY << 4 | RR_COPY;
75           regbase->opwen     = 0x01;
76           regbase->fbwen     = 0x0;
77           regbase->fold      = 0x01;
78           regbase->vdrive    = 0x0;
79           regbase->dispen    = 0x01;
80 
81           /*
82            * Video enable top overlay plane.
83            */
84           regbase->opvenp = 0x01;
85           regbase->opvens = 0x01;
86 
87           /*
88            * Make sure that overlay planes override frame buffer planes.
89            */
90           regbase->ovly0p  = 0x0;
91           regbase->ovly0s  = 0x0;
92           regbase->ovly1p  = 0x0;
93           regbase->ovly1s  = 0x0;
94           regbase->fv_trig = 0x1;
95           DELAY(400);
96 
97           /*
98            * Setup the overlay colormaps. Need to set the 0,1 (black/white)
99            * color for both banks.
100            */
101 
102           for (i = 0; i <= 1; i++) {
103                     regbase->cmapbank = i;
104                     regbase->rgb[0].red   = 0x00;
105                     regbase->rgb[0].green = 0x00;
106                     regbase->rgb[0].blue  = 0x00;
107                     regbase->rgb[1].red   = 0xFF;
108                     regbase->rgb[1].green = 0xFF;
109                     regbase->rgb[1].blue  = 0xFF;
110           }
111 
112           regbase->cmapbank = 0;
113 
114           db_waitbusy(regbase);
115 
116           ite_fontinfo(ip);
117           ite_fontinit8bpp(ip);
118 
119           /*
120            * Clear the (visible) framebuffer.
121            */
122           dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
123           db_waitbusy(regbase);
124 
125           /*
126            * Stash the inverted cursor.
127            */
128           dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
129                                ip->cblanky, ip->cblankx, ip->ftheight,
130                                ip->ftwidth, RR_COPYINVERTED);
131           db_waitbusy(regbase);
132 }
133 
134 void
dvbox_windowmove(struct ite_data * ip,int sy,int sx,int dy,int dx,int h,int w,int func)135 dvbox_windowmove(struct ite_data *ip, int sy, int sx, int dy, int dx, int h,
136     int w, int func)
137 {
138           struct dvboxfb *dp = (void *)ip->regbase;
139 
140           if (h == 0 || w == 0)
141                     return;
142 
143           db_waitbusy(dp);
144           dp->rep_rule = func << 4 | func;
145           dp->source_y = sy;
146           dp->source_x = sx;
147           dp->dest_y   = dy;
148           dp->dest_x   = dx;
149           dp->wheight  = h;
150           dp->wwidth   = w;
151           dp->wmove    = 1;
152 }
153 
154 static void
dv_reset(struct dvboxfb * dbp)155 dv_reset(struct dvboxfb *dbp)
156 {
157 
158           dbp->reset = 0x80;
159           DELAY(400);
160 
161           dbp->interrupt = 0x04;
162           dbp->en_scan   = 0x01;
163           dbp->fbwen     = ~0;
164           dbp->opwen     = ~0;
165           dbp->fold      = 0x01;
166           dbp->drive     = 0x01;
167           dbp->rep_rule  = 0x33;
168           dbp->alt_rr    = 0x33;
169           dbp->zrr       = 0x33;
170 
171           dbp->fbvenp    = 0xFF;
172           dbp->dispen    = 0x01;
173           dbp->fbvens    = 0x0;
174           dbp->fv_trig   = 0x01;
175           DELAY(400);
176           dbp->vdrive    = 0x0;
177           dbp->zconfig   = 0x0;
178 
179           while (dbp->wbusy & 0x01)
180                     DELAY(400);
181 
182           /*
183            * Start of missing ROM code.
184            */
185           dbp->cmapbank = 0;
186 
187           dbp->red0   = 0;
188           dbp->red1   = 0;
189           dbp->green0 = 0;
190           dbp->green1 = 0;
191           dbp->blue0  = 0;
192           dbp->blue1  = 0;
193 
194           dbp->panxh   = 0;
195           dbp->panxl   = 0;
196           dbp->panyh   = 0;
197           dbp->panyl   = 0;
198           dbp->zoom    = 0;
199           dbp->cdwidth = 0x50;
200           dbp->chstart = 0x52;
201           dbp->cvwidth = 0x22;
202           dbp->pz_trig = 1;
203           /*
204            * End of missing ROM code.
205            */
206 }
207 #endif
208