[BACK]Return to hyper.c CVS log [TXT][DIR] Up to [local] / sys / arch / hp300 / dev

Annotation of sys/arch/hp300/dev/hyper.c, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: hyper.c,v 1.15 2006/04/14 21:05:43 miod Exp $ */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 2005, 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:  * Copyright (c) 1996 Jason R. Thorpe.  All rights reserved.
        !            31:  * Copyright (c) 1991 University of Utah.
        !            32:  * Copyright (c) 1990, 1993
        !            33:  *     The Regents of the University of California.  All rights reserved.
        !            34:  *
        !            35:  * This code is derived from software contributed to Berkeley by
        !            36:  * the Systems Programming Group of the University of Utah Computer
        !            37:  * Science Department and Mark Davies of the Department of Computer
        !            38:  * Science, Victoria University of Wellington, New Zealand.
        !            39:  *
        !            40:  * Redistribution and use in source and binary forms, with or without
        !            41:  * modification, are permitted provided that the following conditions
        !            42:  * are met:
        !            43:  * 1. Redistributions of source code must retain the above copyright
        !            44:  *    notice, this list of conditions and the following disclaimer.
        !            45:  * 2. Redistributions in binary form must reproduce the above copyright
        !            46:  *    notice, this list of conditions and the following disclaimer in the
        !            47:  *    documentation and/or other materials provided with the distribution.
        !            48:  * 3. Neither the name of the University nor the names of its contributors
        !            49:  *    may be used to endorse or promote products derived from this software
        !            50:  *    without specific prior written permission.
        !            51:  *
        !            52:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
        !            53:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            54:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            55:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            56:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            57:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            58:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            59:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            60:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            61:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            62:  * SUCH DAMAGE.
        !            63:  *
        !            64:  * from: Utah $Hdr: grf_hy.c 1.2 93/08/13$
        !            65:  *
        !            66:  *     @(#)grf_hy.c    8.4 (Berkeley) 1/12/94
        !            67:  */
        !            68:
        !            69: /*
        !            70:  * Graphics routines for HYPERION frame buffer
        !            71:  */
        !            72:
        !            73: #include <sys/param.h>
        !            74: #include <sys/systm.h>
        !            75: #include <sys/conf.h>
        !            76: #include <sys/device.h>
        !            77: #include <sys/ioctl.h>
        !            78: #include <sys/proc.h>
        !            79:
        !            80: #include <machine/autoconf.h>
        !            81: #include <machine/bus.h>
        !            82: #include <machine/cpu.h>
        !            83:
        !            84: #include <hp300/dev/dioreg.h>
        !            85: #include <hp300/dev/diovar.h>
        !            86: #include <hp300/dev/diodevs.h>
        !            87: #include <hp300/dev/intiovar.h>
        !            88:
        !            89: #include <dev/wscons/wsconsio.h>
        !            90: #include <dev/wscons/wsdisplayvar.h>
        !            91: #include <dev/rasops/rasops.h>
        !            92:
        !            93: #include <hp300/dev/diofbreg.h>
        !            94: #include <hp300/dev/diofbvar.h>
        !            95: #include <hp300/dev/hyperreg.h>
        !            96:
        !            97: struct hyper_softc {
        !            98:        struct device           sc_dev;
        !            99:        struct diofb            *sc_fb;
        !           100:        struct diofb            sc_fb_store;
        !           101: };
        !           102:
        !           103: int    hyper_match(struct device *, void *, void *);
        !           104: void   hyper_attach(struct device *, struct device *, void *);
        !           105:
        !           106: struct cfattach hyper_ca = {
        !           107:        sizeof(struct hyper_softc), hyper_match, hyper_attach
        !           108: };
        !           109:
        !           110: struct cfdriver hyper_cd = {
        !           111:        NULL, "hyper", DV_DULL
        !           112: };
        !           113:
        !           114: int    hyper_reset(struct diofb *, int, struct diofbreg *);
        !           115:
        !           116: int    hyper_ioctl(void *, u_long, caddr_t, int, struct proc *);
        !           117: void   hyper_burner(void *, u_int, u_int);
        !           118:
        !           119: struct wsdisplay_accessops hyper_accessops = {
        !           120:        hyper_ioctl,
        !           121:        diofb_mmap,
        !           122:        diofb_alloc_screen,
        !           123:        diofb_free_screen,
        !           124:        diofb_show_screen,
        !           125:        NULL,   /* load_font */
        !           126:        NULL,   /* scrollback */
        !           127:        NULL,   /* getchar */
        !           128:        hyper_burner
        !           129: };
        !           130:
        !           131: /*
        !           132:  * Attachment glue
        !           133:  */
        !           134:
        !           135: int
        !           136: hyper_match(struct device *parent, void *match, void *aux)
        !           137: {
        !           138:        struct dio_attach_args *da = aux;
        !           139:
        !           140:        if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER &&
        !           141:            da->da_secid == DIO_DEVICE_SECID_HYPERION)
        !           142:                return (1);
        !           143:
        !           144:        return (0);
        !           145: }
        !           146:
        !           147: void
        !           148: hyper_attach(struct device *parent, struct device *self, void *aux)
        !           149: {
        !           150:        struct hyper_softc *sc = (struct hyper_softc *)self;
        !           151:        struct dio_attach_args *da = aux;
        !           152:        struct diofbreg *fbr;
        !           153:        int scode;
        !           154:
        !           155:        scode = da->da_scode;
        !           156:        if (scode == conscode) {
        !           157:                fbr = (struct diofbreg *)conaddr;       /* already mapped */
        !           158:                sc->sc_fb = &diofb_cn;
        !           159:        } else {
        !           160:                sc->sc_fb = &sc->sc_fb_store;
        !           161:                fbr = (struct diofbreg *)
        !           162:                    iomap(dio_scodetopa(scode), da->da_size);
        !           163:                if (fbr == NULL ||
        !           164:                    hyper_reset(sc->sc_fb, scode, fbr) != 0) {
        !           165:                        printf(": can't map framebuffer\n");
        !           166:                        return;
        !           167:                }
        !           168:        }
        !           169:
        !           170:        diofb_end_attach(self, &hyper_accessops, sc->sc_fb,
        !           171:            scode == conscode, NULL);
        !           172: }
        !           173:
        !           174: /*
        !           175:  * Initialize hardware and display routines.
        !           176:  */
        !           177: int
        !           178: hyper_reset(struct diofb *fb, int scode, struct diofbreg *fbr)
        !           179: {
        !           180:        volatile struct hyboxfb *hy = (struct hyboxfb *)fbr;
        !           181:        int rc;
        !           182:
        !           183:        if ((rc = diofb_fbinquire(fb, scode, fbr)) != 0)
        !           184:                return (rc);
        !           185:
        !           186:        fb->bmv = diofb_mono_windowmove;
        !           187:
        !           188:        fb->ri.ri_depth = 1;    /* do not fake a 8bpp frame buffer */
        !           189:        diofb_fbsetup(fb);
        !           190:
        !           191:        /* enable display */
        !           192:        hy->nblank = DISP_VIDEO_ENABLE | DISP_SYNC_ENABLE;
        !           193:
        !           194:        return (0);
        !           195: }
        !           196:
        !           197: int
        !           198: hyper_ioctl(void *v, u_long cmd, caddr_t data, int flags, struct proc *p)
        !           199: {
        !           200:        struct diofb *fb = v;
        !           201:        struct wsdisplay_fbinfo *wdf;
        !           202:
        !           203:        switch (cmd) {
        !           204:        case WSDISPLAYIO_GTYPE:
        !           205:                *(u_int *)data = WSDISPLAY_TYPE_HYPERION;
        !           206:                break;
        !           207:        case WSDISPLAYIO_SMODE:
        !           208:                fb->mapmode = *(u_int *)data;
        !           209:                break;
        !           210:        case WSDISPLAYIO_GINFO:
        !           211:                wdf = (void *)data;
        !           212:                wdf->width = fb->ri.ri_width;
        !           213:                wdf->height = fb->ri.ri_height;
        !           214:                wdf->depth = fb->ri.ri_depth;
        !           215:                wdf->cmsize = 0;
        !           216:                break;
        !           217:        case WSDISPLAYIO_LINEBYTES:
        !           218:                *(u_int *)data = fb->ri.ri_stride;
        !           219:                break;
        !           220:        case WSDISPLAYIO_GVIDEO:
        !           221:        case WSDISPLAYIO_SVIDEO:
        !           222:        case WSDISPLAYIO_GETCMAP:
        !           223:        case WSDISPLAYIO_PUTCMAP:
        !           224:                break;
        !           225:        default:
        !           226:                return (-1);
        !           227:        }
        !           228:
        !           229:        return (0);
        !           230: }
        !           231:
        !           232: void
        !           233: hyper_burner(void *v, u_int on, u_int flags)
        !           234: {
        !           235:        struct diofb *fb = v;
        !           236:        volatile struct hyboxfb *hy = (struct hyboxfb *)fb->regkva;
        !           237:
        !           238:        if (on) {
        !           239:                hy->nblank = DISP_VIDEO_ENABLE | DISP_SYNC_ENABLE;
        !           240:        } else {
        !           241:                if (flags & WSDISPLAY_BURN_VBLANK)
        !           242:                        hy->nblank = 0;
        !           243:                else
        !           244:                        hy->nblank = DISP_SYNC_ENABLE;
        !           245:        }
        !           246: }
        !           247:
        !           248: /*
        !           249:  * Hyperion console support
        !           250:  */
        !           251:
        !           252: void
        !           253: hypercninit()
        !           254: {
        !           255:        hyper_reset(&diofb_cn, conscode, (struct diofbreg *)conaddr);
        !           256:        diofb_cnattach(&diofb_cn);
        !           257: }

CVSweb