1*8448487eStsutsui /* $NetBSD: rbox.c,v 1.4 2023/01/15 06:19:45 tsutsui Exp $ */
2b04b7da8Stsutsui /* $OpenBSD: rbox.c,v 1.14 2006/08/11 18:33:13 miod Exp $ */
3b04b7da8Stsutsui
4b04b7da8Stsutsui /*
5b04b7da8Stsutsui * Copyright (c) 2005, Miodrag Vallat
6b04b7da8Stsutsui *
7b04b7da8Stsutsui * Redistribution and use in source and binary forms, with or without
8b04b7da8Stsutsui * modification, are permitted provided that the following conditions
9b04b7da8Stsutsui * are met:
10b04b7da8Stsutsui * 1. Redistributions of source code must retain the above copyright
11b04b7da8Stsutsui * notice, this list of conditions and the following disclaimer.
12b04b7da8Stsutsui * 2. Redistributions in binary form must reproduce the above copyright
13b04b7da8Stsutsui * notice, this list of conditions and the following disclaimer in the
14b04b7da8Stsutsui * documentation and/or other materials provided with the distribution.
15b04b7da8Stsutsui *
16b04b7da8Stsutsui * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17b04b7da8Stsutsui * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18b04b7da8Stsutsui * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19b04b7da8Stsutsui * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20b04b7da8Stsutsui * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21b04b7da8Stsutsui * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22b04b7da8Stsutsui * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23b04b7da8Stsutsui * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24b04b7da8Stsutsui * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25b04b7da8Stsutsui * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26b04b7da8Stsutsui * POSSIBILITY OF SUCH DAMAGE.
27b04b7da8Stsutsui */
28b04b7da8Stsutsui /*-
29b04b7da8Stsutsui * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
30b04b7da8Stsutsui * All rights reserved.
31b04b7da8Stsutsui *
32b04b7da8Stsutsui * This code is derived from software contributed to The NetBSD Foundation
33b04b7da8Stsutsui * by Jason R. Thorpe.
34b04b7da8Stsutsui *
35b04b7da8Stsutsui * Redistribution and use in source and binary forms, with or without
36b04b7da8Stsutsui * modification, are permitted provided that the following conditions
37b04b7da8Stsutsui * are met:
38b04b7da8Stsutsui * 1. Redistributions of source code must retain the above copyright
39b04b7da8Stsutsui * notice, this list of conditions and the following disclaimer.
40b04b7da8Stsutsui * 2. Redistributions in binary form must reproduce the above copyright
41b04b7da8Stsutsui * notice, this list of conditions and the following disclaimer in the
42b04b7da8Stsutsui * documentation and/or other materials provided with the distribution.
43b04b7da8Stsutsui *
44b04b7da8Stsutsui * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
45b04b7da8Stsutsui * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
46b04b7da8Stsutsui * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
47b04b7da8Stsutsui * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
48b04b7da8Stsutsui * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
49b04b7da8Stsutsui * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
50b04b7da8Stsutsui * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
51b04b7da8Stsutsui * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
52b04b7da8Stsutsui * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53b04b7da8Stsutsui * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
54b04b7da8Stsutsui * POSSIBILITY OF SUCH DAMAGE.
55b04b7da8Stsutsui */
56b04b7da8Stsutsui
57b04b7da8Stsutsui /*
58b04b7da8Stsutsui * Copyright (c) 1988 University of Utah.
59b04b7da8Stsutsui * Copyright (c) 1990, 1993
60b04b7da8Stsutsui * The Regents of the University of California. All rights reserved.
61b04b7da8Stsutsui *
62b04b7da8Stsutsui * This code is derived from software contributed to Berkeley by
63b04b7da8Stsutsui * the Systems Programming Group of the University of Utah Computer
64b04b7da8Stsutsui * Science Department.
65b04b7da8Stsutsui *
66b04b7da8Stsutsui * Redistribution and use in source and binary forms, with or without
67b04b7da8Stsutsui * modification, are permitted provided that the following conditions
68b04b7da8Stsutsui * are met:
69b04b7da8Stsutsui * 1. Redistributions of source code must retain the above copyright
70b04b7da8Stsutsui * notice, this list of conditions and the following disclaimer.
71b04b7da8Stsutsui * 2. Redistributions in binary form must reproduce the above copyright
72b04b7da8Stsutsui * notice, this list of conditions and the following disclaimer in the
73b04b7da8Stsutsui * documentation and/or other materials provided with the distribution.
74b04b7da8Stsutsui * 3. Neither the name of the University nor the names of its contributors
75b04b7da8Stsutsui * may be used to endorse or promote products derived from this software
76b04b7da8Stsutsui * without specific prior written permission.
77b04b7da8Stsutsui *
78b04b7da8Stsutsui * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
79b04b7da8Stsutsui * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
80b04b7da8Stsutsui * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
81b04b7da8Stsutsui * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
82b04b7da8Stsutsui * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
83b04b7da8Stsutsui * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
84b04b7da8Stsutsui * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
85b04b7da8Stsutsui * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
86b04b7da8Stsutsui * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
87b04b7da8Stsutsui * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
88b04b7da8Stsutsui * SUCH DAMAGE.
89b04b7da8Stsutsui *
90b04b7da8Stsutsui * from: Utah $Hdr: grf_rb.c 1.15 93/08/13$
91b04b7da8Stsutsui *
92b04b7da8Stsutsui * @(#)grf_rb.c 8.4 (Berkeley) 1/12/94
93b04b7da8Stsutsui */
94b04b7da8Stsutsui
95b04b7da8Stsutsui /*
96b04b7da8Stsutsui * Graphics routines for the Renaissance, HP98720 Graphics system.
97b04b7da8Stsutsui */
98b04b7da8Stsutsui
99b04b7da8Stsutsui #include <sys/param.h>
100b04b7da8Stsutsui #include <sys/systm.h>
101b04b7da8Stsutsui #include <sys/conf.h>
102b04b7da8Stsutsui #include <sys/device.h>
103b04b7da8Stsutsui #include <sys/proc.h>
104b04b7da8Stsutsui #include <sys/ioctl.h>
105b04b7da8Stsutsui #include <sys/bus.h>
106b04b7da8Stsutsui #include <sys/cpu.h>
107b04b7da8Stsutsui
108b04b7da8Stsutsui #include <machine/autoconf.h>
109b04b7da8Stsutsui
110b04b7da8Stsutsui #include <hp300/dev/dioreg.h>
111b04b7da8Stsutsui #include <hp300/dev/diovar.h>
112b04b7da8Stsutsui #include <hp300/dev/diodevs.h>
113b04b7da8Stsutsui #include <hp300/dev/intiovar.h>
114b04b7da8Stsutsui
115b04b7da8Stsutsui #include <dev/wscons/wsconsio.h>
116b04b7da8Stsutsui #include <dev/wscons/wsdisplayvar.h>
117b04b7da8Stsutsui #include <dev/rasops/rasops.h>
118b04b7da8Stsutsui
119b04b7da8Stsutsui #include <hp300/dev/diofbreg.h>
120b04b7da8Stsutsui #include <hp300/dev/diofbvar.h>
121b04b7da8Stsutsui #include <hp300/dev/rboxreg.h>
122b04b7da8Stsutsui
123b04b7da8Stsutsui struct rbox_softc {
124b04b7da8Stsutsui device_t sc_dev;
125b04b7da8Stsutsui struct diofb *sc_fb;
126b04b7da8Stsutsui struct diofb sc_fb_store;
127b04b7da8Stsutsui int sc_scode;
128b04b7da8Stsutsui };
129b04b7da8Stsutsui
1305d7f465dStsutsui static int rbox_dio_match(device_t, cfdata_t, void *);
1315d7f465dStsutsui static void rbox_dio_attach(device_t, device_t, void *);
1325d7f465dStsutsui static int rbox_intio_match(device_t, cfdata_t, void *);
1335d7f465dStsutsui static void rbox_intio_attach(device_t, device_t, void *);
134b04b7da8Stsutsui
135b04b7da8Stsutsui CFATTACH_DECL_NEW(rbox_dio, sizeof(struct rbox_softc),
136b04b7da8Stsutsui rbox_dio_match, rbox_dio_attach, NULL, NULL);
137b04b7da8Stsutsui
138b04b7da8Stsutsui CFATTACH_DECL_NEW(rbox_intio, sizeof(struct rbox_softc),
139b04b7da8Stsutsui rbox_intio_match, rbox_intio_attach, NULL, NULL);
140b04b7da8Stsutsui
1415d7f465dStsutsui static int rbox_reset(struct diofb *, int, struct diofbreg *);
1425d7f465dStsutsui static void rbox_restore(struct diofb *);
1435d7f465dStsutsui static int rbox_windowmove(struct diofb *, uint16_t, uint16_t, uint16_t,
1445d7f465dStsutsui uint16_t, uint16_t, uint16_t, int16_t, int16_t);
145b04b7da8Stsutsui
1465d7f465dStsutsui static int rbox_ioctl(void *, void *, u_long, void *, int, struct lwp *);
147b04b7da8Stsutsui
1485d7f465dStsutsui static struct wsdisplay_accessops rbox_accessops = {
149b04b7da8Stsutsui rbox_ioctl,
150b04b7da8Stsutsui diofb_mmap,
151b04b7da8Stsutsui diofb_alloc_screen,
152b04b7da8Stsutsui diofb_free_screen,
153b04b7da8Stsutsui diofb_show_screen,
154b04b7da8Stsutsui NULL, /* load_font */
155b04b7da8Stsutsui };
156b04b7da8Stsutsui
157b04b7da8Stsutsui /*
158b04b7da8Stsutsui * Attachment glue
159b04b7da8Stsutsui */
160b04b7da8Stsutsui
161b04b7da8Stsutsui int
rbox_intio_match(device_t parent,cfdata_t cf,void * aux)162b04b7da8Stsutsui rbox_intio_match(device_t parent, cfdata_t cf, void *aux)
163b04b7da8Stsutsui {
164b04b7da8Stsutsui struct intio_attach_args *ia = aux;
165b04b7da8Stsutsui struct diofbreg *fbr;
166b04b7da8Stsutsui
167b04b7da8Stsutsui if (strcmp("fb", ia->ia_modname) != 0)
168b04b7da8Stsutsui return 0;
169b04b7da8Stsutsui
170b04b7da8Stsutsui fbr = (struct diofbreg *)ia->ia_addr;
171b04b7da8Stsutsui
172b04b7da8Stsutsui if (badaddr((void *)fbr))
1735d7f465dStsutsui return 0;
174b04b7da8Stsutsui
175b04b7da8Stsutsui if (fbr->id == GRFHWID && fbr->fbid == GID_RENAISSANCE) {
1765d7f465dStsutsui return 1;
177b04b7da8Stsutsui }
178b04b7da8Stsutsui
1795d7f465dStsutsui return 0;
180b04b7da8Stsutsui }
181b04b7da8Stsutsui
182b04b7da8Stsutsui void
rbox_intio_attach(device_t parent,device_t self,void * aux)183b04b7da8Stsutsui rbox_intio_attach(device_t parent, device_t self, void *aux)
184b04b7da8Stsutsui {
185b04b7da8Stsutsui struct rbox_softc *sc = device_private(self);
186b04b7da8Stsutsui struct intio_attach_args *ia = aux;
187b04b7da8Stsutsui struct diofbreg *fbr;
188b04b7da8Stsutsui
189b04b7da8Stsutsui sc->sc_dev = self;
190b04b7da8Stsutsui fbr = (struct diofbreg *)ia->ia_addr;
191b04b7da8Stsutsui sc->sc_scode = CONSCODE_INTERNAL;
192b04b7da8Stsutsui
193b04b7da8Stsutsui if (sc->sc_scode == conscode) {
194b04b7da8Stsutsui sc->sc_fb = &diofb_cn;
195b04b7da8Stsutsui } else {
196b04b7da8Stsutsui sc->sc_fb = &sc->sc_fb_store;
197b04b7da8Stsutsui rbox_reset(sc->sc_fb, sc->sc_scode, fbr);
198b04b7da8Stsutsui }
199b04b7da8Stsutsui
200b04b7da8Stsutsui diofb_end_attach(self, &rbox_accessops, sc->sc_fb,
201b04b7da8Stsutsui sc->sc_scode == conscode, NULL);
202b04b7da8Stsutsui }
203b04b7da8Stsutsui
204b04b7da8Stsutsui int
rbox_dio_match(device_t parent,cfdata_t cf,void * aux)205b04b7da8Stsutsui rbox_dio_match(device_t parent, cfdata_t cf, void *aux)
206b04b7da8Stsutsui {
207b04b7da8Stsutsui struct dio_attach_args *da = aux;
208b04b7da8Stsutsui
209b04b7da8Stsutsui if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER &&
210b04b7da8Stsutsui da->da_secid == DIO_DEVICE_SECID_RENAISSANCE)
2115d7f465dStsutsui return 1;
212b04b7da8Stsutsui
2135d7f465dStsutsui return 0;
214b04b7da8Stsutsui }
215b04b7da8Stsutsui
216b04b7da8Stsutsui void
rbox_dio_attach(device_t parent,device_t self,void * aux)217b04b7da8Stsutsui rbox_dio_attach(device_t parent, device_t self, void *aux)
218b04b7da8Stsutsui {
219b04b7da8Stsutsui struct rbox_softc *sc = device_private(self);
220b04b7da8Stsutsui struct dio_attach_args *da = aux;
221b04b7da8Stsutsui bus_space_handle_t bsh;
222b04b7da8Stsutsui struct diofbreg *fbr;
223b04b7da8Stsutsui
224b04b7da8Stsutsui sc->sc_dev = self;
225b04b7da8Stsutsui sc->sc_scode = da->da_scode;
226b04b7da8Stsutsui if (sc->sc_scode == conscode) {
227b04b7da8Stsutsui fbr = (struct diofbreg *)conaddr; /* already mapped */
228b04b7da8Stsutsui sc->sc_fb = &diofb_cn;
229b04b7da8Stsutsui } else {
230b04b7da8Stsutsui sc->sc_fb = &sc->sc_fb_store;
231b04b7da8Stsutsui if (bus_space_map(da->da_bst, da->da_addr, da->da_size,
232b04b7da8Stsutsui 0, &bsh)) {
233b04b7da8Stsutsui aprint_error(": can't map framebuffer\n");
234b04b7da8Stsutsui return;
235b04b7da8Stsutsui }
236b04b7da8Stsutsui fbr = bus_space_vaddr(da->da_bst, bsh);
237b04b7da8Stsutsui if (rbox_reset(sc->sc_fb, sc->sc_scode, fbr) != 0) {
2382ba8a55cStsutsui aprint_error(": can't reset framebuffer\n");
239b04b7da8Stsutsui return;
240b04b7da8Stsutsui }
241b04b7da8Stsutsui }
242b04b7da8Stsutsui
243b04b7da8Stsutsui diofb_end_attach(self, &rbox_accessops, sc->sc_fb,
244b04b7da8Stsutsui sc->sc_scode == conscode, NULL);
245b04b7da8Stsutsui }
246b04b7da8Stsutsui
247b04b7da8Stsutsui /*
248b04b7da8Stsutsui * Initialize hardware and display routines.
249b04b7da8Stsutsui */
250b04b7da8Stsutsui int
rbox_reset(struct diofb * fb,int scode,struct diofbreg * fbr)251b04b7da8Stsutsui rbox_reset(struct diofb *fb, int scode, struct diofbreg *fbr)
252b04b7da8Stsutsui {
253b04b7da8Stsutsui int rc;
254b04b7da8Stsutsui
255b04b7da8Stsutsui if ((rc = diofb_fbinquire(fb, scode, fbr)) != 0)
2565d7f465dStsutsui return rc;
257b04b7da8Stsutsui
258b04b7da8Stsutsui /*
259b04b7da8Stsutsui * Restrict the framebuffer to a monochrome view for now, until
260b04b7da8Stsutsui * I know better how to detect and frob overlay planes, and
261b04b7da8Stsutsui * setup a proper colormap. -- miod
262b04b7da8Stsutsui */
263b04b7da8Stsutsui fb->planes = fb->planemask = 1;
264b04b7da8Stsutsui
265b04b7da8Stsutsui fb->bmv = rbox_windowmove;
266b04b7da8Stsutsui rbox_restore(fb);
267b04b7da8Stsutsui diofb_fbsetup(fb);
268b04b7da8Stsutsui
2695d7f465dStsutsui return 0;
270b04b7da8Stsutsui }
271b04b7da8Stsutsui
272b04b7da8Stsutsui void
rbox_restore(struct diofb * fb)273b04b7da8Stsutsui rbox_restore(struct diofb *fb)
274b04b7da8Stsutsui {
275b04b7da8Stsutsui volatile struct rboxfb *rb = (struct rboxfb *)fb->regkva;
276b04b7da8Stsutsui u_int i;
277b04b7da8Stsutsui
278b04b7da8Stsutsui rb_waitbusy(rb);
279b04b7da8Stsutsui
280b04b7da8Stsutsui rb->regs.id = GRFHWID; /* trigger reset */
281b04b7da8Stsutsui DELAY(1000);
282b04b7da8Stsutsui
283b04b7da8Stsutsui rb->regs.interrupt = 0x04;
284b04b7da8Stsutsui rb->video_enable = 0x01;
285b04b7da8Stsutsui rb->drive = 0x01;
286b04b7da8Stsutsui rb->vdrive = 0x0;
287b04b7da8Stsutsui
288b04b7da8Stsutsui rb->opwen = 0xFF;
289b04b7da8Stsutsui
290b04b7da8Stsutsui /*
291b04b7da8Stsutsui * Clear color map
292b04b7da8Stsutsui */
293b04b7da8Stsutsui rb_waitbusy(fb->regkva);
294b04b7da8Stsutsui for (i = 0; i < 16; i++) {
295b04b7da8Stsutsui *(fb->regkva + 0x63c3 + i*4) = 0x0;
296b04b7da8Stsutsui *(fb->regkva + 0x6403 + i*4) = 0x0;
297b04b7da8Stsutsui *(fb->regkva + 0x6803 + i*4) = 0x0;
298b04b7da8Stsutsui *(fb->regkva + 0x6c03 + i*4) = 0x0;
299b04b7da8Stsutsui *(fb->regkva + 0x73c3 + i*4) = 0x0;
300b04b7da8Stsutsui *(fb->regkva + 0x7403 + i*4) = 0x0;
301b04b7da8Stsutsui *(fb->regkva + 0x7803 + i*4) = 0x0;
302b04b7da8Stsutsui *(fb->regkva + 0x7c03 + i*4) = 0x0;
303b04b7da8Stsutsui }
304b04b7da8Stsutsui
305b04b7da8Stsutsui rb->rep_rule = RBOX_DUALROP(RR_COPY);
306b04b7da8Stsutsui
307b04b7da8Stsutsui /*
308b04b7da8Stsutsui * I cannot figure out how to make the blink planes stop. So, we
309b04b7da8Stsutsui * must set both colormaps so that when the planes blink, and
310b04b7da8Stsutsui * the secondary colormap is active, we still get text.
311b04b7da8Stsutsui */
312b04b7da8Stsutsui CM1RED(fb)[0x00].value = 0x00;
313b04b7da8Stsutsui CM1GRN(fb)[0x00].value = 0x00;
314b04b7da8Stsutsui CM1BLU(fb)[0x00].value = 0x00;
315b04b7da8Stsutsui CM1RED(fb)[0x01].value = 0xFF;
316b04b7da8Stsutsui CM1GRN(fb)[0x01].value = 0xFF;
317b04b7da8Stsutsui CM1BLU(fb)[0x01].value = 0xFF;
318b04b7da8Stsutsui
319b04b7da8Stsutsui CM2RED(fb)[0x00].value = 0x00;
320b04b7da8Stsutsui CM2GRN(fb)[0x00].value = 0x00;
321b04b7da8Stsutsui CM2BLU(fb)[0x00].value = 0x00;
322b04b7da8Stsutsui CM2RED(fb)[0x01].value = 0xFF;
323b04b7da8Stsutsui CM2GRN(fb)[0x01].value = 0xFF;
324b04b7da8Stsutsui CM2BLU(fb)[0x01].value = 0xFF;
325b04b7da8Stsutsui
326b04b7da8Stsutsui rb->blink = 0x00;
327b04b7da8Stsutsui rb->write_enable = 0x01;
328b04b7da8Stsutsui rb->opwen = 0x00;
329b04b7da8Stsutsui
330b04b7da8Stsutsui /* enable display */
331b04b7da8Stsutsui rb->display_enable = 0x01;
332b04b7da8Stsutsui }
333b04b7da8Stsutsui
334b04b7da8Stsutsui int
rbox_ioctl(void * v,void * vs,u_long cmd,void * data,int flags,struct lwp * l)335b04b7da8Stsutsui rbox_ioctl(void *v, void *vs, u_long cmd, void *data, int flags, struct lwp *l)
336b04b7da8Stsutsui {
337b04b7da8Stsutsui struct diofb *fb = v;
338b04b7da8Stsutsui struct wsdisplay_fbinfo *wdf;
339b04b7da8Stsutsui
340b04b7da8Stsutsui switch (cmd) {
341b04b7da8Stsutsui case WSDISPLAYIO_GTYPE:
342b04b7da8Stsutsui *(u_int *)data = WSDISPLAY_TYPE_RBOX;
343b04b7da8Stsutsui return 0;
344b04b7da8Stsutsui case WSDISPLAYIO_SMODE:
345b04b7da8Stsutsui fb->mapmode = *(u_int *)data;
346b04b7da8Stsutsui if (fb->mapmode == WSDISPLAYIO_MODE_EMUL)
347b04b7da8Stsutsui rbox_restore(fb);
348b04b7da8Stsutsui return 0;
349b04b7da8Stsutsui case WSDISPLAYIO_GINFO:
350b04b7da8Stsutsui wdf = (void *)data;
351b04b7da8Stsutsui wdf->width = fb->ri.ri_width;
352b04b7da8Stsutsui wdf->height = fb->ri.ri_height;
353b04b7da8Stsutsui wdf->depth = fb->ri.ri_depth;
354b04b7da8Stsutsui wdf->cmsize = 0; /* XXX */
355b04b7da8Stsutsui return 0;
356b04b7da8Stsutsui case WSDISPLAYIO_LINEBYTES:
357b04b7da8Stsutsui *(u_int *)data = fb->ri.ri_stride;
358b04b7da8Stsutsui return 0;
359b04b7da8Stsutsui case WSDISPLAYIO_GETCMAP:
360b04b7da8Stsutsui case WSDISPLAYIO_PUTCMAP:
361b04b7da8Stsutsui /* XXX until color support is implemented */
362b04b7da8Stsutsui return EPASSTHROUGH;
363b04b7da8Stsutsui case WSDISPLAYIO_GVIDEO:
364b04b7da8Stsutsui case WSDISPLAYIO_SVIDEO:
365b04b7da8Stsutsui return EPASSTHROUGH;
366b04b7da8Stsutsui }
367b04b7da8Stsutsui
368b04b7da8Stsutsui return EPASSTHROUGH;
369b04b7da8Stsutsui }
370b04b7da8Stsutsui
371b04b7da8Stsutsui int
rbox_windowmove(struct diofb * fb,uint16_t sx,uint16_t sy,uint16_t dx,uint16_t dy,uint16_t cx,uint16_t cy,int16_t rop,int16_t planemask)3725d7f465dStsutsui rbox_windowmove(struct diofb *fb, uint16_t sx, uint16_t sy,
3735d7f465dStsutsui uint16_t dx, uint16_t dy, uint16_t cx, uint16_t cy, int16_t rop,
374b04b7da8Stsutsui int16_t planemask)
375b04b7da8Stsutsui {
376b04b7da8Stsutsui volatile struct rboxfb *rb = (struct rboxfb *)fb->regkva;
377b04b7da8Stsutsui
378b04b7da8Stsutsui if (planemask != 0xff)
3795d7f465dStsutsui return EINVAL;
380b04b7da8Stsutsui
381b04b7da8Stsutsui rb_waitbusy(rb);
382b04b7da8Stsutsui
383b04b7da8Stsutsui rb->rep_rule = RBOX_DUALROP(rop);
384b04b7da8Stsutsui rb->source_y = sy;
385b04b7da8Stsutsui rb->source_x = sx;
386b04b7da8Stsutsui rb->dest_y = dy;
387b04b7da8Stsutsui rb->dest_x = dx;
388b04b7da8Stsutsui rb->wheight = cy;
389b04b7da8Stsutsui rb->wwidth = cx;
390b04b7da8Stsutsui rb->wmove = 1;
391b04b7da8Stsutsui
392b04b7da8Stsutsui rb_waitbusy(rb);
393b04b7da8Stsutsui
3945d7f465dStsutsui return 0;
395b04b7da8Stsutsui }
396b04b7da8Stsutsui
397b04b7da8Stsutsui /*
398b04b7da8Stsutsui * Renaissance console support
399b04b7da8Stsutsui */
400b04b7da8Stsutsui int
rboxcnattach(bus_space_tag_t bst,bus_addr_t addr,int scode)401b04b7da8Stsutsui rboxcnattach(bus_space_tag_t bst, bus_addr_t addr, int scode)
402b04b7da8Stsutsui {
403b04b7da8Stsutsui bus_space_handle_t bsh;
404b04b7da8Stsutsui void *va;
405b04b7da8Stsutsui struct diofbreg *fbr;
406b04b7da8Stsutsui struct diofb *fb = &diofb_cn;
407b04b7da8Stsutsui int size;
408b04b7da8Stsutsui
409b04b7da8Stsutsui if (bus_space_map(bst, addr, PAGE_SIZE, 0, &bsh))
410b04b7da8Stsutsui return 1;
411b04b7da8Stsutsui va = bus_space_vaddr(bst, bsh);
412b04b7da8Stsutsui fbr = va;
413b04b7da8Stsutsui
414b04b7da8Stsutsui if (badaddr(va) ||
415b04b7da8Stsutsui (fbr->id != GRFHWID) || (fbr->fbid != GID_RENAISSANCE)) {
416b04b7da8Stsutsui bus_space_unmap(bst, bsh, PAGE_SIZE);
417b04b7da8Stsutsui return 1;
418b04b7da8Stsutsui }
419b04b7da8Stsutsui
420b04b7da8Stsutsui size = DIO_SIZE(scode, va);
421b04b7da8Stsutsui
422b04b7da8Stsutsui bus_space_unmap(bst, bsh, PAGE_SIZE);
423b04b7da8Stsutsui if (bus_space_map(bst, addr, size, 0, &bsh))
424b04b7da8Stsutsui return 1;
425b04b7da8Stsutsui va = bus_space_vaddr(bst, bsh);
426b04b7da8Stsutsui
427b04b7da8Stsutsui /*
428b04b7da8Stsutsui * Initialize the framebuffer hardware.
429b04b7da8Stsutsui */
430b04b7da8Stsutsui conscode = scode;
431b04b7da8Stsutsui conaddr = va;
432b04b7da8Stsutsui rbox_reset(fb, conscode, (struct diofbreg *)conaddr);
433b04b7da8Stsutsui
434b04b7da8Stsutsui /*
435b04b7da8Stsutsui * Initialize the terminal emulator.
436b04b7da8Stsutsui */
437b04b7da8Stsutsui diofb_cnattach(fb);
438b04b7da8Stsutsui return 0;
439b04b7da8Stsutsui }
440