1/*	$NetBSD: ite_tc.c,v 1.9 2011/02/10 11:08:23 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_tc.c 1.11 92/01/20$
37 *
38 *	@(#)ite_tc.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/grfreg.h>
47#include <hp300/stand/common/grf_tcreg.h>
48
49#include <hp300/stand/common/samachdep.h>
50#include <hp300/stand/common/itevar.h>
51
52void topcat_windowmove(struct ite_data *, int, int, int, int, int, int, int);
53
54void
55topcat_init(struct ite_data *ip)
56{
57	struct tcboxfb *regbase = (void *)ip->regbase;
58
59	ip->bmv = topcat_windowmove;
60
61	/*
62	 * Catseye looks a lot like a topcat, but not completely.
63	 * So, we set some bits to make it work.
64	 */
65	if (regbase->fbid != GID_TOPCAT) {
66		while ((regbase->catseye_status & 1))
67			;
68		regbase->catseye_status = 0x0;
69		regbase->vb_select      = 0x0;
70		regbase->tcntrl         = 0x0;
71		regbase->acntrl         = 0x0;
72		regbase->pncntrl        = 0x0;
73		regbase->rug_cmdstat    = 0x90;
74	}
75
76	/*
77	 * Determine the number of planes by writing to the first frame
78	 * buffer display location, then reading it back.
79	 */
80	regbase->wen = ~0;
81	regbase->fben = ~0;
82	regbase->prr = RR_COPY;
83	*FBBASE = 0xFF;
84	ip->planemask = *FBBASE;
85
86	/*
87	 * Enable reading/writing of all the planes.
88	 */
89	regbase->fben = ip->planemask;
90	regbase->wen  = ip->planemask;
91	regbase->ren  = ip->planemask;
92	regbase->prr  = RR_COPY;
93
94	ite_fontinfo(ip);
95
96	/*
97	 * Clear the framebuffer on all planes.
98	 */
99	topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
100	tc_waitbusy(regbase, ip->planemask);
101
102	ite_fontinit8bpp(ip);
103
104	/*
105	 * Stash the inverted cursor.
106	 */
107	topcat_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
108			  ip->cblanky, ip->cblankx, ip->ftheight,
109			  ip->ftwidth, RR_COPYINVERTED);
110}
111
112void
113topcat_windowmove(struct ite_data *ip, int sy, int sx, int dy, int dx, int h,
114    int w, int func)
115{
116	struct tcboxfb *rp = (void *)ip->regbase;
117
118	if (h == 0 || w == 0)
119		return;
120	tc_waitbusy(rp, ip->planemask);
121	rp->wmrr     = func;
122	rp->source_y = sy;
123	rp->source_x = sx;
124	rp->dest_y   = dy;
125	rp->dest_x   = dx;
126	rp->wheight  = h;
127	rp->wwidth   = w;
128	rp->wmove    = ip->planemask;
129}
130#endif
131