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