Annotation of sys/arch/hp300/dev/tvrx.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: tvrx.c,v 1.1 2006/04/14 21:05:43 miod Exp $ */
! 2:
! 3: /*
! 4: * Copyright (c) 2006, Miodrag Vallat.
! 5: * All rights reserved.
! 6: *
! 7: * Redistribution and use in source and binary forms, with or without
! 8: * modification, are permitted provided that the following conditions
! 9: * are met:
! 10: * 1. Redistributions of source code must retain the above copyright
! 11: * notice, this list of conditions and the following disclaimer.
! 12: * 2. Redistributions in binary form must reproduce the above copyright
! 13: * notice, this list of conditions and the following disclaimer in the
! 14: * documentation and/or other materials provided with the distribution.
! 15: *
! 16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
! 18: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
! 19: * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
! 20: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
! 21: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
! 22: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 23: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
! 24: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
! 25: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! 26: * POSSIBILITY OF SUCH DAMAGE.
! 27: *
! 28: */
! 29:
! 30: /*
! 31: * Graphics routines for the TurboVRX frame buffer
! 32: */
! 33:
! 34: #include <sys/param.h>
! 35: #include <sys/systm.h>
! 36: #include <sys/conf.h>
! 37: #include <sys/device.h>
! 38: #include <sys/proc.h>
! 39: #include <sys/ioctl.h>
! 40:
! 41: #include <machine/autoconf.h>
! 42: #include <machine/bus.h>
! 43: #include <machine/cpu.h>
! 44:
! 45: #include <hp300/dev/dioreg.h>
! 46: #include <hp300/dev/diovar.h>
! 47: #include <hp300/dev/diodevs.h>
! 48:
! 49: #include <dev/cons.h>
! 50:
! 51: #include <dev/wscons/wsconsio.h>
! 52: #include <dev/wscons/wsdisplayvar.h>
! 53: #include <dev/rasops/rasops.h>
! 54:
! 55: #include <hp300/dev/diofbreg.h>
! 56: #include <hp300/dev/diofbvar.h>
! 57:
! 58: struct tvrx_softc {
! 59: struct device sc_dev;
! 60: struct diofb *sc_fb;
! 61: struct diofb sc_fb_store;
! 62: int sc_scode;
! 63: };
! 64:
! 65: int tvrx_match(struct device *, void *, void *);
! 66: void tvrx_attach(struct device *, struct device *, void *);
! 67:
! 68: struct cfattach tvrx_ca = {
! 69: sizeof(struct tvrx_softc), tvrx_match, tvrx_attach
! 70: };
! 71:
! 72: struct cfdriver tvrx_cd = {
! 73: NULL, "tvrx", DV_DULL
! 74: };
! 75:
! 76: int tvrx_reset(struct diofb *, int, struct diofbreg *);
! 77:
! 78: int tvrx_ioctl(void *, u_long, caddr_t, int, struct proc *);
! 79:
! 80: struct wsdisplay_accessops tvrx_accessops = {
! 81: tvrx_ioctl,
! 82: diofb_mmap,
! 83: diofb_alloc_screen,
! 84: diofb_free_screen,
! 85: diofb_show_screen,
! 86: NULL, /* load_font */
! 87: NULL, /* scrollback */
! 88: NULL, /* getchar */
! 89: NULL /* burner */
! 90: };
! 91:
! 92: /*
! 93: * Attachment glue
! 94: */
! 95:
! 96: int
! 97: tvrx_match(struct device *parent, void *match, void *aux)
! 98: {
! 99: struct dio_attach_args *da = aux;
! 100:
! 101: if (da->da_id != DIO_DEVICE_ID_FRAMEBUFFER ||
! 102: da->da_secid != DIO_DEVICE_SECID_TIGERSHARK)
! 103: return (0);
! 104:
! 105: return (1);
! 106: }
! 107:
! 108: void
! 109: tvrx_attach(struct device *parent, struct device *self, void *aux)
! 110: {
! 111: struct tvrx_softc *sc = (struct tvrx_softc *)self;
! 112: struct dio_attach_args *da = aux;
! 113: struct diofbreg *fbr;
! 114:
! 115: sc->sc_scode = da->da_scode;
! 116: if (sc->sc_scode == conscode) {
! 117: fbr = (struct diofbreg *)conaddr; /* already mapped */
! 118: sc->sc_fb = &diofb_cn;
! 119: } else {
! 120: sc->sc_fb = &sc->sc_fb_store;
! 121: fbr = (struct diofbreg *)
! 122: iomap(dio_scodetopa(sc->sc_scode), da->da_size);
! 123: if (fbr == NULL ||
! 124: tvrx_reset(sc->sc_fb, sc->sc_scode, fbr) != 0) {
! 125: printf(": can't map framebuffer\n");
! 126: return;
! 127: }
! 128: }
! 129:
! 130: diofb_end_attach(sc, &tvrx_accessops, sc->sc_fb,
! 131: sc->sc_scode == conscode, NULL);
! 132: }
! 133:
! 134: /*
! 135: * Initialize hardware and display routines.
! 136: */
! 137: int
! 138: tvrx_reset(struct diofb *fb, int scode, struct diofbreg *fbr)
! 139: {
! 140: int rc;
! 141:
! 142: if ((rc = diofb_fbinquire(fb, scode, fbr)) != 0)
! 143: return (rc);
! 144:
! 145: /*
! 146: * We rely on the PROM to initialize the frame buffer in the mode
! 147: * we expect it: cleared, overlay plane enabled and accessible
! 148: * at the beginning of the video memory.
! 149: *
! 150: * This is NOT the mode we would end up by simply resetting the
! 151: * board.
! 152: */
! 153:
! 154: fb->ri.ri_depth = 1;
! 155: fb->bmv = diofb_mono_windowmove;
! 156: diofb_fbsetup(fb);
! 157:
! 158: return (0);
! 159: }
! 160:
! 161: int
! 162: tvrx_ioctl(void *v, u_long cmd, caddr_t data, int flags, struct proc *p)
! 163: {
! 164: struct diofb *fb = v;
! 165: struct wsdisplay_fbinfo *wdf;
! 166:
! 167: switch (cmd) {
! 168: case WSDISPLAYIO_GTYPE:
! 169: *(u_int *)data = WSDISPLAY_TYPE_TVRX;
! 170: break;
! 171: case WSDISPLAYIO_SMODE:
! 172: fb->mapmode = *(u_int *)data;
! 173: break;
! 174: case WSDISPLAYIO_GINFO:
! 175: wdf = (void *)data;
! 176: wdf->width = fb->ri.ri_width;
! 177: wdf->height = fb->ri.ri_height;
! 178: wdf->depth = fb->ri.ri_depth;
! 179: wdf->cmsize = 0;
! 180: break;
! 181: case WSDISPLAYIO_LINEBYTES:
! 182: *(u_int *)data = fb->ri.ri_stride;
! 183: break;
! 184: case WSDISPLAYIO_GETCMAP:
! 185: case WSDISPLAYIO_PUTCMAP:
! 186: break; /* until color support is implemented */
! 187: case WSDISPLAYIO_GVIDEO:
! 188: case WSDISPLAYIO_SVIDEO:
! 189: /* unsupported */
! 190: return (-1);
! 191: default:
! 192: return (-1);
! 193: }
! 194:
! 195: return (0);
! 196: }
! 197:
! 198: /*
! 199: * Console support
! 200: */
! 201:
! 202: void
! 203: tvrxcninit()
! 204: {
! 205: tvrx_reset(&diofb_cn, conscode, (struct diofbreg *)conaddr);
! 206: diofb_cnattach(&diofb_cn);
! 207: }
CVSweb