1 1.5 tsutsui /* $NetBSD: dvbox.c,v 1.5 2025/05/27 18:44:31 tsutsui Exp $ */ 2 1.1 tsutsui /* $OpenBSD: dvbox.c,v 1.13 2006/08/11 18:33:13 miod Exp $ */ 3 1.1 tsutsui 4 1.1 tsutsui /* 5 1.1 tsutsui * Copyright (c) 2005, Miodrag Vallat 6 1.1 tsutsui * 7 1.1 tsutsui * Redistribution and use in source and binary forms, with or without 8 1.1 tsutsui * modification, are permitted provided that the following conditions 9 1.1 tsutsui * are met: 10 1.1 tsutsui * 1. Redistributions of source code must retain the above copyright 11 1.1 tsutsui * notice, this list of conditions and the following disclaimer. 12 1.1 tsutsui * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 tsutsui * notice, this list of conditions and the following disclaimer in the 14 1.1 tsutsui * documentation and/or other materials provided with the distribution. 15 1.1 tsutsui * 16 1.1 tsutsui * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 1.1 tsutsui * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 1.1 tsutsui * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 1.1 tsutsui * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 20 1.1 tsutsui * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 1.1 tsutsui * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 1.1 tsutsui * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 1.1 tsutsui * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 1.1 tsutsui * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 1.1 tsutsui * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 1.1 tsutsui * POSSIBILITY OF SUCH DAMAGE. 27 1.1 tsutsui */ 28 1.1 tsutsui /*- 29 1.1 tsutsui * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. 30 1.1 tsutsui * All rights reserved. 31 1.1 tsutsui * 32 1.1 tsutsui * This code is derived from software contributed to The NetBSD Foundation 33 1.1 tsutsui * by Jason R. Thorpe. 34 1.1 tsutsui * 35 1.1 tsutsui * Redistribution and use in source and binary forms, with or without 36 1.1 tsutsui * modification, are permitted provided that the following conditions 37 1.1 tsutsui * are met: 38 1.1 tsutsui * 1. Redistributions of source code must retain the above copyright 39 1.1 tsutsui * notice, this list of conditions and the following disclaimer. 40 1.1 tsutsui * 2. Redistributions in binary form must reproduce the above copyright 41 1.1 tsutsui * notice, this list of conditions and the following disclaimer in the 42 1.1 tsutsui * documentation and/or other materials provided with the distribution. 43 1.1 tsutsui * 44 1.1 tsutsui * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 45 1.1 tsutsui * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 46 1.1 tsutsui * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 47 1.1 tsutsui * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 48 1.1 tsutsui * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 49 1.1 tsutsui * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 50 1.1 tsutsui * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 51 1.1 tsutsui * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 52 1.1 tsutsui * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 53 1.1 tsutsui * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 54 1.1 tsutsui * POSSIBILITY OF SUCH DAMAGE. 55 1.1 tsutsui */ 56 1.1 tsutsui 57 1.1 tsutsui /* 58 1.1 tsutsui * Copyright (c) 1988 University of Utah. 59 1.1 tsutsui * Copyright (c) 1990, 1993 60 1.1 tsutsui * The Regents of the University of California. All rights reserved. 61 1.1 tsutsui * 62 1.1 tsutsui * This code is derived from software contributed to Berkeley by 63 1.1 tsutsui * the Systems Programming Group of the University of Utah Computer 64 1.1 tsutsui * Science Department. 65 1.1 tsutsui * 66 1.1 tsutsui * Redistribution and use in source and binary forms, with or without 67 1.1 tsutsui * modification, are permitted provided that the following conditions 68 1.1 tsutsui * are met: 69 1.1 tsutsui * 1. Redistributions of source code must retain the above copyright 70 1.1 tsutsui * notice, this list of conditions and the following disclaimer. 71 1.1 tsutsui * 2. Redistributions in binary form must reproduce the above copyright 72 1.1 tsutsui * notice, this list of conditions and the following disclaimer in the 73 1.1 tsutsui * documentation and/or other materials provided with the distribution. 74 1.1 tsutsui * 3. Neither the name of the University nor the names of its contributors 75 1.1 tsutsui * may be used to endorse or promote products derived from this software 76 1.1 tsutsui * without specific prior written permission. 77 1.1 tsutsui * 78 1.1 tsutsui * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 79 1.1 tsutsui * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 80 1.1 tsutsui * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 81 1.1 tsutsui * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 82 1.1 tsutsui * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 83 1.1 tsutsui * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 84 1.1 tsutsui * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 85 1.1 tsutsui * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 86 1.1 tsutsui * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 87 1.1 tsutsui * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 88 1.1 tsutsui * SUCH DAMAGE. 89 1.1 tsutsui * 90 1.1 tsutsui * from: Utah $Hdr: grf_dv.c 1.12 93/08/13$ 91 1.1 tsutsui * 92 1.1 tsutsui * @(#)grf_dv.c 8.4 (Berkeley) 1/12/94 93 1.1 tsutsui */ 94 1.1 tsutsui 95 1.1 tsutsui /* 96 1.1 tsutsui * Graphics routines for the DaVinci, HP98730/98731 Graphics system. 97 1.1 tsutsui */ 98 1.1 tsutsui 99 1.1 tsutsui #include <sys/param.h> 100 1.1 tsutsui #include <sys/systm.h> 101 1.1 tsutsui #include <sys/conf.h> 102 1.1 tsutsui #include <sys/device.h> 103 1.1 tsutsui #include <sys/proc.h> 104 1.1 tsutsui #include <sys/ioctl.h> 105 1.1 tsutsui #include <sys/bus.h> 106 1.1 tsutsui #include <sys/cpu.h> 107 1.1 tsutsui 108 1.1 tsutsui #include <machine/autoconf.h> 109 1.1 tsutsui 110 1.1 tsutsui #include <hp300/dev/dioreg.h> 111 1.1 tsutsui #include <hp300/dev/diovar.h> 112 1.1 tsutsui #include <hp300/dev/diodevs.h> 113 1.1 tsutsui #include <hp300/dev/intiovar.h> 114 1.1 tsutsui 115 1.1 tsutsui #include <dev/wscons/wsconsio.h> 116 1.1 tsutsui #include <dev/wscons/wsdisplayvar.h> 117 1.1 tsutsui #include <dev/rasops/rasops.h> 118 1.1 tsutsui 119 1.1 tsutsui #include <hp300/dev/diofbreg.h> 120 1.1 tsutsui #include <hp300/dev/diofbvar.h> 121 1.1 tsutsui #include <hp300/dev/dvboxreg.h> 122 1.1 tsutsui 123 1.1 tsutsui struct dvbox_softc { 124 1.1 tsutsui device_t sc_dev; 125 1.1 tsutsui struct diofb *sc_fb; 126 1.1 tsutsui struct diofb sc_fb_store; 127 1.1 tsutsui int sc_scode; 128 1.1 tsutsui }; 129 1.1 tsutsui 130 1.2 tsutsui static int dvbox_dio_match(device_t, cfdata_t, void *); 131 1.2 tsutsui static void dvbox_dio_attach(device_t, device_t, void *); 132 1.2 tsutsui static int dvbox_intio_match(device_t, cfdata_t, void *); 133 1.2 tsutsui static void dvbox_intio_attach(device_t, device_t, void *); 134 1.1 tsutsui 135 1.1 tsutsui CFATTACH_DECL_NEW(dvbox_dio, sizeof(struct dvbox_softc), 136 1.1 tsutsui dvbox_dio_match, dvbox_dio_attach, NULL, NULL); 137 1.1 tsutsui 138 1.1 tsutsui CFATTACH_DECL_NEW(dvbox_intio, sizeof(struct dvbox_softc), 139 1.1 tsutsui dvbox_intio_match, dvbox_intio_attach, NULL, NULL); 140 1.1 tsutsui 141 1.2 tsutsui static int dvbox_reset(struct diofb *, int, struct diofbreg *); 142 1.2 tsutsui static void dvbox_restore(struct diofb *); 143 1.2 tsutsui static int dvbox_windowmove(struct diofb *, uint16_t, uint16_t, uint16_t, 144 1.2 tsutsui uint16_t, uint16_t, uint16_t, int16_t, int16_t); 145 1.1 tsutsui 146 1.2 tsutsui static int dvbox_ioctl(void *, void *, u_long, void *, int, struct lwp *); 147 1.1 tsutsui 148 1.2 tsutsui static struct wsdisplay_accessops dvbox_accessops = { 149 1.5 tsutsui .ioctl = dvbox_ioctl, 150 1.5 tsutsui .mmap = diofb_mmap, 151 1.5 tsutsui .alloc_screen = diofb_alloc_screen, 152 1.5 tsutsui .free_screen = diofb_free_screen, 153 1.5 tsutsui .show_screen = diofb_show_screen, 154 1.5 tsutsui .load_font = NULL, 155 1.1 tsutsui }; 156 1.1 tsutsui 157 1.1 tsutsui /* 158 1.1 tsutsui * Attachment glue 159 1.1 tsutsui */ 160 1.1 tsutsui 161 1.1 tsutsui int 162 1.1 tsutsui dvbox_intio_match(device_t parent, cfdata_t cf, void *aux) 163 1.1 tsutsui { 164 1.1 tsutsui struct intio_attach_args *ia = aux; 165 1.1 tsutsui struct diofbreg *fbr; 166 1.1 tsutsui 167 1.1 tsutsui if (strcmp("fb", ia->ia_modname) != 0) 168 1.1 tsutsui return 0; 169 1.1 tsutsui 170 1.1 tsutsui fbr = (struct diofbreg *)ia->ia_addr; 171 1.1 tsutsui 172 1.1 tsutsui if (badaddr((void *)fbr)) 173 1.2 tsutsui return 0; 174 1.1 tsutsui 175 1.1 tsutsui if (fbr->id == GRFHWID && fbr->fbid == GID_DAVINCI) { 176 1.2 tsutsui return 1; 177 1.1 tsutsui } 178 1.1 tsutsui 179 1.2 tsutsui return 0; 180 1.1 tsutsui } 181 1.1 tsutsui 182 1.1 tsutsui void 183 1.1 tsutsui dvbox_intio_attach(device_t parent, device_t self, void *aux) 184 1.1 tsutsui { 185 1.1 tsutsui struct dvbox_softc *sc = device_private(self); 186 1.1 tsutsui struct intio_attach_args *ia = aux; 187 1.1 tsutsui struct diofbreg *fbr; 188 1.1 tsutsui 189 1.1 tsutsui sc->sc_dev = self; 190 1.1 tsutsui fbr = (struct diofbreg *)ia->ia_addr; 191 1.1 tsutsui sc->sc_scode = CONSCODE_INTERNAL; 192 1.1 tsutsui 193 1.1 tsutsui if (sc->sc_scode == conscode) { 194 1.1 tsutsui sc->sc_fb = &diofb_cn; 195 1.1 tsutsui } else { 196 1.1 tsutsui sc->sc_fb = &sc->sc_fb_store; 197 1.1 tsutsui dvbox_reset(sc->sc_fb, sc->sc_scode, fbr); 198 1.1 tsutsui } 199 1.1 tsutsui 200 1.1 tsutsui diofb_end_attach(self, &dvbox_accessops, sc->sc_fb, 201 1.1 tsutsui sc->sc_scode == conscode, NULL); 202 1.1 tsutsui } 203 1.1 tsutsui 204 1.1 tsutsui int 205 1.1 tsutsui dvbox_dio_match(device_t parent, cfdata_t cf, void *aux) 206 1.1 tsutsui { 207 1.1 tsutsui struct dio_attach_args *da = aux; 208 1.1 tsutsui 209 1.1 tsutsui if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER && 210 1.1 tsutsui da->da_secid == DIO_DEVICE_SECID_DAVINCI) 211 1.2 tsutsui return 1; 212 1.1 tsutsui 213 1.2 tsutsui return 0; 214 1.1 tsutsui } 215 1.1 tsutsui 216 1.1 tsutsui void 217 1.1 tsutsui dvbox_dio_attach(device_t parent, device_t self, void *aux) 218 1.1 tsutsui { 219 1.1 tsutsui struct dvbox_softc *sc = device_private(self); 220 1.1 tsutsui struct dio_attach_args *da = aux; 221 1.1 tsutsui bus_space_handle_t bsh; 222 1.1 tsutsui struct diofbreg *fbr; 223 1.1 tsutsui 224 1.1 tsutsui sc->sc_dev = self; 225 1.1 tsutsui sc->sc_scode = da->da_scode; 226 1.1 tsutsui if (sc->sc_scode == conscode) { 227 1.1 tsutsui fbr = (struct diofbreg *)conaddr; /* already mapped */ 228 1.1 tsutsui sc->sc_fb = &diofb_cn; 229 1.1 tsutsui } else { 230 1.1 tsutsui sc->sc_fb = &sc->sc_fb_store; 231 1.1 tsutsui if (bus_space_map(da->da_bst, da->da_addr, da->da_size, 0, 232 1.1 tsutsui &bsh)) { 233 1.1 tsutsui aprint_error(": can't map framebuffer\n"); 234 1.1 tsutsui return; 235 1.1 tsutsui } 236 1.1 tsutsui fbr = bus_space_vaddr(da->da_bst, bsh); 237 1.1 tsutsui if (dvbox_reset(sc->sc_fb, sc->sc_scode, fbr) != 0) { 238 1.3 tsutsui aprint_error(": can't reset framebuffer\n"); 239 1.1 tsutsui return; 240 1.1 tsutsui } 241 1.1 tsutsui } 242 1.1 tsutsui 243 1.1 tsutsui diofb_end_attach(self, &dvbox_accessops, sc->sc_fb, 244 1.1 tsutsui sc->sc_scode == conscode, NULL); 245 1.1 tsutsui } 246 1.1 tsutsui 247 1.1 tsutsui /* 248 1.1 tsutsui * Initialize hardware and display routines. 249 1.1 tsutsui */ 250 1.1 tsutsui int 251 1.1 tsutsui dvbox_reset(struct diofb *fb, int scode, struct diofbreg *fbr) 252 1.1 tsutsui { 253 1.1 tsutsui int rc; 254 1.1 tsutsui 255 1.1 tsutsui if ((rc = diofb_fbinquire(fb, scode, fbr)) != 0) 256 1.2 tsutsui return rc; 257 1.1 tsutsui 258 1.1 tsutsui /* 259 1.1 tsutsui * Restrict the framebuffer to a monochrome view for now, until 260 1.1 tsutsui * I know better how to detect and frob overlay planes, and 261 1.1 tsutsui * setup a proper colormap. -- miod 262 1.1 tsutsui */ 263 1.1 tsutsui fb->planes = fb->planemask = 1; 264 1.1 tsutsui 265 1.1 tsutsui fb->bmv = dvbox_windowmove; 266 1.1 tsutsui dvbox_restore(fb); 267 1.1 tsutsui diofb_fbsetup(fb); 268 1.1 tsutsui 269 1.2 tsutsui return 0; 270 1.1 tsutsui } 271 1.1 tsutsui 272 1.1 tsutsui /* 273 1.1 tsutsui * Magic initialization code. 274 1.1 tsutsui */ 275 1.1 tsutsui void 276 1.1 tsutsui dvbox_restore(struct diofb *fb) 277 1.1 tsutsui { 278 1.1 tsutsui volatile struct dvboxfb *db = (struct dvboxfb *)fb->regkva; 279 1.1 tsutsui u_int i; 280 1.1 tsutsui 281 1.4 tsutsui db->regs.id = 0x80; 282 1.1 tsutsui DELAY(100); 283 1.1 tsutsui 284 1.1 tsutsui db->regs.interrupt = 0x04; 285 1.1 tsutsui db->en_scan = 0x01; 286 1.1 tsutsui db->fbwen = ~0; 287 1.1 tsutsui db->opwen = ~0; 288 1.1 tsutsui db->fold = 0x01; /* 8bpp */ 289 1.1 tsutsui db->drive = 0x01; /* use FB plane */ 290 1.1 tsutsui db->rep_rule = DVBOX_DUALROP(RR_COPY); 291 1.1 tsutsui db->alt_rr = DVBOX_DUALROP(RR_COPY); 292 1.1 tsutsui db->zrr = DVBOX_DUALROP(RR_COPY); 293 1.1 tsutsui 294 1.1 tsutsui db->fbvenp = 0xFF; /* enable video */ 295 1.1 tsutsui db->dispen = 0x01; /* enable display */ 296 1.1 tsutsui db->fbvens = 0x0; 297 1.1 tsutsui db->fv_trig = 0x01; 298 1.1 tsutsui DELAY(100); 299 1.1 tsutsui db->vdrive = 0x0; 300 1.1 tsutsui db->zconfig = 0x0; 301 1.1 tsutsui 302 1.1 tsutsui while (db->wbusy & 0x01) 303 1.1 tsutsui DELAY(10); 304 1.1 tsutsui 305 1.1 tsutsui db->cmapbank = 0; 306 1.1 tsutsui 307 1.1 tsutsui db->red0 = 0; 308 1.1 tsutsui db->red1 = 0; 309 1.1 tsutsui db->green0 = 0; 310 1.1 tsutsui db->green1 = 0; 311 1.1 tsutsui db->blue0 = 0; 312 1.1 tsutsui db->blue1 = 0; 313 1.1 tsutsui 314 1.1 tsutsui db->panxh = 0; 315 1.1 tsutsui db->panxl = 0; 316 1.1 tsutsui db->panyh = 0; 317 1.1 tsutsui db->panyl = 0; 318 1.1 tsutsui db->zoom = 0; 319 1.1 tsutsui db->cdwidth = 0x50; 320 1.1 tsutsui db->chstart = 0x52; 321 1.1 tsutsui db->cvwidth = 0x22; 322 1.1 tsutsui db->pz_trig = 1; 323 1.1 tsutsui 324 1.1 tsutsui /* 325 1.1 tsutsui * Turn on frame buffer, turn on overlay planes, set replacement 326 1.1 tsutsui * rule, enable top overlay plane writes for ite, disable all frame 327 1.1 tsutsui * buffer planes, set byte per pixel, and display frame buffer 0. 328 1.1 tsutsui * Lastly, turn on the box. 329 1.1 tsutsui */ 330 1.1 tsutsui db->regs.interrupt = 0x04; 331 1.1 tsutsui db->drive = 0x10; 332 1.4 tsutsui db->rep_rule = DVBOX_DUALROP(RR_COPY); 333 1.1 tsutsui db->opwen = 0x01; 334 1.1 tsutsui db->fbwen = 0x0; 335 1.1 tsutsui db->fold = 0x01; 336 1.1 tsutsui db->vdrive = 0x0; 337 1.1 tsutsui db->dispen = 0x01; 338 1.1 tsutsui 339 1.1 tsutsui /* 340 1.1 tsutsui * Video enable top overlay plane. 341 1.1 tsutsui */ 342 1.1 tsutsui db->opvenp = 0x01; 343 1.1 tsutsui db->opvens = 0x01; 344 1.1 tsutsui 345 1.1 tsutsui /* 346 1.1 tsutsui * Make sure that overlay planes override frame buffer planes. 347 1.1 tsutsui */ 348 1.1 tsutsui db->ovly0p = 0x0; 349 1.1 tsutsui db->ovly0s = 0x0; 350 1.1 tsutsui db->ovly1p = 0x0; 351 1.1 tsutsui db->ovly1s = 0x0; 352 1.1 tsutsui db->fv_trig = 0x1; 353 1.1 tsutsui DELAY(100); 354 1.1 tsutsui 355 1.1 tsutsui /* 356 1.1 tsutsui * Setup the overlay colormaps. Need to set the 0,1 (black/white) 357 1.1 tsutsui * color for both banks. 358 1.1 tsutsui */ 359 1.1 tsutsui db_waitbusy(db); 360 1.1 tsutsui for (i = 0; i <= 1; i++) { 361 1.1 tsutsui db->cmapbank = i; 362 1.1 tsutsui db->rgb[0].red = 0x00; 363 1.1 tsutsui db->rgb[0].green = 0x00; 364 1.1 tsutsui db->rgb[0].blue = 0x00; 365 1.1 tsutsui db->rgb[1].red = 0xff; 366 1.1 tsutsui db->rgb[1].green = 0xff; 367 1.1 tsutsui db->rgb[1].blue = 0xff; 368 1.1 tsutsui } 369 1.1 tsutsui db->cmapbank = 0; 370 1.1 tsutsui db_waitbusy(db); 371 1.1 tsutsui } 372 1.1 tsutsui 373 1.1 tsutsui int 374 1.1 tsutsui dvbox_ioctl(void *v, void *vs, u_long cmd, void *data, int flags, struct lwp *l) 375 1.1 tsutsui { 376 1.1 tsutsui struct diofb *fb = v; 377 1.1 tsutsui struct wsdisplay_fbinfo *wdf; 378 1.1 tsutsui 379 1.1 tsutsui switch (cmd) { 380 1.1 tsutsui case WSDISPLAYIO_GTYPE: 381 1.1 tsutsui *(u_int *)data = WSDISPLAY_TYPE_DVBOX; 382 1.1 tsutsui return 0; 383 1.1 tsutsui case WSDISPLAYIO_SMODE: 384 1.1 tsutsui fb->mapmode = *(u_int *)data; 385 1.1 tsutsui if (fb->mapmode == WSDISPLAYIO_MODE_EMUL) 386 1.1 tsutsui dvbox_restore(fb); 387 1.1 tsutsui return 0; 388 1.1 tsutsui case WSDISPLAYIO_GINFO: 389 1.1 tsutsui wdf = (void *)data; 390 1.1 tsutsui wdf->width = fb->ri.ri_width; 391 1.1 tsutsui wdf->height = fb->ri.ri_height; 392 1.1 tsutsui wdf->depth = fb->ri.ri_depth; 393 1.1 tsutsui wdf->cmsize = 0; /* XXX */ 394 1.1 tsutsui return 0; 395 1.1 tsutsui case WSDISPLAYIO_LINEBYTES: 396 1.1 tsutsui *(u_int *)data = fb->ri.ri_stride; 397 1.1 tsutsui return 0; 398 1.1 tsutsui case WSDISPLAYIO_GETCMAP: 399 1.1 tsutsui case WSDISPLAYIO_PUTCMAP: 400 1.1 tsutsui /* XXX until color support is implemented */ 401 1.1 tsutsui return EPASSTHROUGH; 402 1.1 tsutsui case WSDISPLAYIO_GVIDEO: 403 1.1 tsutsui case WSDISPLAYIO_SVIDEO: 404 1.1 tsutsui return EPASSTHROUGH; 405 1.1 tsutsui } 406 1.1 tsutsui 407 1.1 tsutsui return EPASSTHROUGH; 408 1.1 tsutsui } 409 1.1 tsutsui 410 1.1 tsutsui int 411 1.2 tsutsui dvbox_windowmove(struct diofb *fb, uint16_t sx, uint16_t sy, 412 1.2 tsutsui uint16_t dx, uint16_t dy, uint16_t cx, uint16_t cy, int16_t rop, 413 1.1 tsutsui int16_t planemask) 414 1.1 tsutsui { 415 1.1 tsutsui volatile struct dvboxfb *db = (struct dvboxfb *)fb->regkva; 416 1.1 tsutsui 417 1.1 tsutsui if (planemask != 0xff) 418 1.2 tsutsui return EINVAL; 419 1.1 tsutsui 420 1.1 tsutsui db_waitbusy(db); 421 1.1 tsutsui 422 1.1 tsutsui db->rep_rule = DVBOX_DUALROP(rop); 423 1.1 tsutsui db->source_y = sy; 424 1.1 tsutsui db->source_x = sx; 425 1.1 tsutsui db->dest_y = dy; 426 1.1 tsutsui db->dest_x = dx; 427 1.1 tsutsui db->wheight = cy; 428 1.1 tsutsui db->wwidth = cx; 429 1.1 tsutsui db->wmove = 1; 430 1.1 tsutsui 431 1.1 tsutsui db_waitbusy(db); 432 1.1 tsutsui 433 1.2 tsutsui return 0; 434 1.1 tsutsui } 435 1.1 tsutsui 436 1.1 tsutsui /* 437 1.1 tsutsui * DaVinci console support 438 1.1 tsutsui */ 439 1.1 tsutsui 440 1.1 tsutsui int 441 1.1 tsutsui dvboxcnattach(bus_space_tag_t bst, bus_addr_t addr, int scode) 442 1.1 tsutsui { 443 1.1 tsutsui bus_space_handle_t bsh; 444 1.1 tsutsui void *va; 445 1.1 tsutsui struct diofbreg *fbr; 446 1.1 tsutsui struct diofb *fb = &diofb_cn; 447 1.1 tsutsui int size; 448 1.1 tsutsui 449 1.1 tsutsui if (bus_space_map(bst, addr, PAGE_SIZE, 0, &bsh)) 450 1.1 tsutsui return 1; 451 1.1 tsutsui va = bus_space_vaddr(bst, bsh); 452 1.1 tsutsui fbr = va; 453 1.1 tsutsui 454 1.1 tsutsui if (badaddr(va) || 455 1.1 tsutsui (fbr->id != GRFHWID) || (fbr->fbid != GID_DAVINCI)) { 456 1.1 tsutsui bus_space_unmap(bst, bsh, PAGE_SIZE); 457 1.1 tsutsui return 1; 458 1.1 tsutsui } 459 1.1 tsutsui 460 1.1 tsutsui size = DIO_SIZE(scode, va); 461 1.1 tsutsui 462 1.1 tsutsui bus_space_unmap(bst, bsh, PAGE_SIZE); 463 1.1 tsutsui if (bus_space_map(bst, addr, size, 0, &bsh)) 464 1.1 tsutsui return 1; 465 1.1 tsutsui va = bus_space_vaddr(bst, bsh); 466 1.1 tsutsui 467 1.1 tsutsui /* 468 1.1 tsutsui * Initialize the framebuffer hardware. 469 1.1 tsutsui */ 470 1.1 tsutsui conscode = scode; 471 1.1 tsutsui conaddr = va; 472 1.1 tsutsui dvbox_reset(fb, conscode, (struct diofbreg *)conaddr); 473 1.1 tsutsui 474 1.1 tsutsui /* 475 1.1 tsutsui * Initialize the terminal emulator. 476 1.1 tsutsui */ 477 1.1 tsutsui diofb_cnattach(fb); 478 1.1 tsutsui return 0; 479 1.1 tsutsui } 480