Home | History | Annotate | Line # | Download | only in common
ite_dv.c revision 1.8
      1 /*	$NetBSD: ite_dv.c,v 1.8 2011/02/08 20:20:14 rmind 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 #define WINDOWMOVER	dvbox_windowmove
     52 
     53 static void dv_reset(struct dvboxfb *);
     54 static void dvbox_windowmove(struct ite_data *, int, int, int, int,
     55     int, int, int);
     56 
     57 void
     58 dvbox_init(struct ite_data *ip)
     59 {
     60 	struct dvboxfb *regbase;
     61 	int i;
     62 
     63 	regbase = (void *)ip->regbase;
     64 	dv_reset(regbase);
     65 	DELAY(4000);
     66 
     67 	/*
     68 	 * Turn on frame buffer, turn on overlay planes, set replacement
     69 	 * rule, enable top overlay plane writes for ite, disable all frame
     70 	 * buffer planes, set byte per pixel, and display frame buffer 0.
     71 	 * Lastly, turn on the box.
     72 	 */
     73 	regbase->interrupt = 0x04;
     74 	regbase->drive     = 0x10;
     75 	regbase->rep_rule  = RR_COPY << 4 | RR_COPY;
     76 	regbase->opwen     = 0x01;
     77 	regbase->fbwen     = 0x0;
     78 	regbase->fold      = 0x01;
     79 	regbase->vdrive    = 0x0;
     80 	regbase->dispen    = 0x01;
     81 
     82 	/*
     83 	 * Video enable top overlay plane.
     84 	 */
     85 	regbase->opvenp = 0x01;
     86 	regbase->opvens = 0x01;
     87 
     88 	/*
     89 	 * Make sure that overlay planes override frame buffer planes.
     90 	 */
     91 	regbase->ovly0p  = 0x0;
     92 	regbase->ovly0s  = 0x0;
     93 	regbase->ovly1p  = 0x0;
     94 	regbase->ovly1s  = 0x0;
     95 	regbase->fv_trig = 0x1;
     96 	DELAY(400);
     97 
     98 	/*
     99 	 * Setup the overlay colormaps. Need to set the 0,1 (black/white)
    100 	 * color for both banks.
    101 	 */
    102 
    103 	for (i = 0; i <= 1; i++) {
    104 		regbase->cmapbank = i;
    105 		regbase->rgb[0].red   = 0x00;
    106 		regbase->rgb[0].green = 0x00;
    107 		regbase->rgb[0].blue  = 0x00;
    108 		regbase->rgb[1].red   = 0xFF;
    109 		regbase->rgb[1].green = 0xFF;
    110 		regbase->rgb[1].blue  = 0xFF;
    111 	}
    112 
    113 	regbase->cmapbank = 0;
    114 
    115 	db_waitbusy(regbase);
    116 
    117 	ite_fontinfo(ip);
    118 	ite_fontinit(ip);
    119 
    120 	/*
    121 	 * Clear the (visible) framebuffer.
    122 	 */
    123 	dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
    124 	db_waitbusy(regbase);
    125 
    126 	/*
    127 	 * Stash the inverted cursor.
    128 	 */
    129 	dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
    130 			 ip->cblanky, ip->cblankx, ip->ftheight,
    131 			 ip->ftwidth, RR_COPYINVERTED);
    132 	db_waitbusy(regbase);
    133 }
    134 
    135 void
    136 dvbox_putc(struct ite_data *ip, int c, int dy, int dx, int mode)
    137 {
    138 
    139 	dvbox_windowmove(ip, charY(ip, c), charX(ip, c),
    140 			 dy * ip->ftheight, dx * ip->ftwidth,
    141 			 ip->ftheight, ip->ftwidth, RR_COPY);
    142 }
    143 
    144 void
    145 dvbox_cursor(struct ite_data *ip, int flag)
    146 {
    147 	if (flag == DRAW_CURSOR)
    148 		draw_cursor(ip)
    149 	else if (flag == MOVE_CURSOR) {
    150 		erase_cursor(ip)
    151 		draw_cursor(ip)
    152 	}
    153 	else
    154 		erase_cursor(ip)
    155 }
    156 
    157 void
    158 dvbox_clear(struct ite_data *ip, int sy, int sx, int h, int w)
    159 {
    160 
    161 	dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
    162 			 sy * ip->ftheight, sx * ip->ftwidth,
    163 			 h  * ip->ftheight, w  * ip->ftwidth,
    164 			 RR_CLEAR);
    165 }
    166 
    167 void
    168 dvbox_scroll(struct ite_data *ip, int sy, int sx, int count, int dir)
    169 {
    170 	int dy = sy - count;
    171 	int height = ip->rows - sy;
    172 
    173 	dvbox_cursor(ip, ERASE_CURSOR);
    174 
    175 	dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
    176 			 dy * ip->ftheight, sx * ip->ftwidth,
    177 			 height * ip->ftheight,
    178 			 ip->cols * ip->ftwidth, RR_COPY);
    179 }
    180 
    181 void
    182 dvbox_windowmove(struct ite_data *ip, int sy, int sx, int dy, int dx,
    183     int h, int w, int func)
    184 {
    185 	struct dvboxfb *dp = (void *)ip->regbase;
    186 
    187 	if (h == 0 || w == 0)
    188 		return;
    189 
    190 	db_waitbusy(dp);
    191 	dp->rep_rule = func << 4 | func;
    192 	dp->source_y = sy;
    193 	dp->source_x = sx;
    194 	dp->dest_y   = dy;
    195 	dp->dest_x   = dx;
    196 	dp->wheight  = h;
    197 	dp->wwidth   = w;
    198 	dp->wmove    = 1;
    199 }
    200 
    201 static void
    202 dv_reset(struct dvboxfb *dbp)
    203 {
    204 
    205 	dbp->reset = 0x80;
    206 	DELAY(400);
    207 
    208 	dbp->interrupt = 0x04;
    209 	dbp->en_scan   = 0x01;
    210 	dbp->fbwen     = ~0;
    211 	dbp->opwen     = ~0;
    212 	dbp->fold      = 0x01;
    213 	dbp->drive     = 0x01;
    214 	dbp->rep_rule  = 0x33;
    215 	dbp->alt_rr    = 0x33;
    216 	dbp->zrr       = 0x33;
    217 
    218 	dbp->fbvenp    = 0xFF;
    219 	dbp->dispen    = 0x01;
    220 	dbp->fbvens    = 0x0;
    221 	dbp->fv_trig   = 0x01;
    222 	DELAY(400);
    223 	dbp->vdrive    = 0x0;
    224 	dbp->zconfig   = 0x0;
    225 
    226 	while (dbp->wbusy & 0x01)
    227 		DELAY(400);
    228 
    229 	/*
    230 	 * Start of missing ROM code.
    231 	 */
    232 	dbp->cmapbank = 0;
    233 
    234 	dbp->red0   = 0;
    235 	dbp->red1   = 0;
    236 	dbp->green0 = 0;
    237 	dbp->green1 = 0;
    238 	dbp->blue0  = 0;
    239 	dbp->blue1  = 0;
    240 
    241 	dbp->panxh   = 0;
    242 	dbp->panxl   = 0;
    243 	dbp->panyh   = 0;
    244 	dbp->panyl   = 0;
    245 	dbp->zoom    = 0;
    246 	dbp->cdwidth = 0x50;
    247 	dbp->chstart = 0x52;
    248 	dbp->cvwidth = 0x22;
    249 	dbp->pz_trig = 1;
    250 	/*
    251 	 * End of missing ROM code.
    252 	 */
    253 }
    254 
    255 #endif
    256