[BACK]Return to qscms.c CVS log [TXT][DIR] Up to [local] / sys / arch / vax / vxt

Annotation of sys/arch/vax/vxt/qscms.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: qscms.c,v 1.1 2006/08/27 16:55:41 miod Exp $  */
                      2: /*     from OpenBSD: qscms.c,v 1.6 2006/07/31 18:50:13 miod Exp        */
                      3: /*
                      4:  * Copyright (c) 2006 Miodrag Vallat.
                      5:  *
                      6:  * Permission to use, copy, modify, and distribute this software for any
                      7:  * purpose with or without fee is hereby granted, provided that the above
                      8:  * copyright notice, this permission notice, and the disclaimer below
                      9:  * appear in all copies.
                     10:  *
                     11:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     12:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     13:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     14:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     15:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     16:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     17:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     18:  */
                     19: /*
                     20:  * Copyright (c) 1992, 1993
                     21:  *     The Regents of the University of California.  All rights reserved.
                     22:  *
                     23:  * This software was developed by the Computer Systems Engineering group
                     24:  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
                     25:  * contributed to Berkeley.
                     26:  *
                     27:  * All advertising materials mentioning features or use of this software
                     28:  * must display the following acknowledgement:
                     29:  *     This product includes software developed by the University of
                     30:  *     California, Lawrence Berkeley Laboratory.
                     31:  *
                     32:  * Redistribution and use in source and binary forms, with or without
                     33:  * modification, are permitted provided that the following conditions
                     34:  * are met:
                     35:  * 1. Redistributions of source code must retain the above copyright
                     36:  *    notice, this list of conditions and the following disclaimer.
                     37:  * 2. Redistributions in binary form must reproduce the above copyright
                     38:  *    notice, this list of conditions and the following disclaimer in the
                     39:  *    documentation and/or other materials provided with the distribution.
                     40:  * 3. Neither the name of the University nor the names of its contributors
                     41:  *    may be used to endorse or promote products derived from this software
                     42:  *    without specific prior written permission.
                     43:  *
                     44:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     45:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     46:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     47:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     48:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     49:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     50:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     51:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     52:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     53:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     54:  * SUCH DAMAGE.
                     55:  *
                     56:  *     @(#)ms.c        8.1 (Berkeley) 6/11/93
                     57:  */
                     58:
                     59: /*
                     60:  * VSXXX mice attached to line D of the SC26C94
                     61:  */
                     62:
                     63: #include <sys/param.h>
                     64: #include <sys/systm.h>
                     65: #include <sys/device.h>
                     66: #include <sys/ioctl.h>
                     67: #include <sys/syslog.h>
                     68: #include <sys/kernel.h>
                     69: #include <sys/proc.h>
                     70: #include <sys/tty.h>
                     71:
                     72: #include <machine/bus.h>
                     73:
                     74: #include <vax/qbus/dzreg.h>
                     75: #include <vax/qbus/dzvar.h>
                     76:
                     77: #include <vax/vxt/qscvar.h>
                     78: #include <vax/dec/vsmsvar.h>
                     79:
                     80: #include <dev/wscons/wsconsio.h>
                     81: #include <dev/wscons/wsmousevar.h>
                     82:
                     83: struct qscms_softc {
                     84:        struct lkms_softc       sc_base;
                     85:        u_int                   sc_line;
                     86: };
                     87:
                     88: int    qscms_match(struct device *, void *, void *);
                     89: void   qscms_attach(struct device *, struct device *, void *);
                     90:
                     91: struct cfattach qscms_ca = {
                     92:        sizeof(struct qscms_softc), qscms_match, qscms_attach,
                     93: };
                     94:
                     95: int    qscms_enable(void *);
                     96: void   qscms_disable(void *);
                     97:
                     98: const struct wsmouse_accessops qscms_accessops = {
                     99:        qscms_enable,
                    100:        lkms_ioctl,
                    101:        qscms_disable,
                    102: };
                    103:
                    104: int
                    105: qscms_match(struct device *parent, void *vcf, void *aux)
                    106: {
                    107:        struct qsc_attach_args *qa = aux;
                    108:        struct cfdata *cf = vcf;
                    109:
                    110:        if (cf->cf_loc[0] == qa->qa_line)
                    111:                return 1;
                    112:
                    113:        return 0;
                    114: }
                    115:
                    116: void
                    117: qscms_attach(struct device *parent, struct device *self, void *aux)
                    118: {
                    119:        struct qscms_softc *qscms = (void *)self;
                    120:        struct lkms_softc *sc = (void *)self;
                    121:        struct qsc_attach_args *qa = aux;
                    122:        struct wsmousedev_attach_args a;
                    123:
                    124:        qa->qa_hook->fn = lkms_input;
                    125:        qa->qa_hook->arg = self;
                    126:        qscms->sc_line = qa->qa_line;
                    127:
                    128:        printf("\n");
                    129:
                    130:        a.accessops = &qscms_accessops;
                    131:        a.accesscookie = qscms;
                    132:
                    133:        sc->sc_enabled = 0;
                    134:        sc->sc_selftest = 0;
                    135:        sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
                    136: }
                    137:
                    138: int
                    139: qscms_enable(void *v)
                    140: {
                    141:        struct qscms_softc *qscms = v;
                    142:        struct lkms_softc *sc = v;
                    143:
                    144:        if (sc->sc_enabled)
                    145:                return EBUSY;
                    146:
                    147:        sc->sc_selftest = 4;    /* wait for 4 byte reply upto 1/2 sec */
                    148:        qscputc(qscms->sc_line, MOUSE_SELF_TEST);
                    149:        (void)tsleep(&sc->sc_enabled, TTIPRI, "qscmsopen", hz / 2);
                    150:        if (sc->sc_selftest != 0) {
                    151:                sc->sc_selftest = 0;
                    152:                return ENXIO;
                    153:        }
                    154:        DELAY(150);
                    155:        qscputc(qscms->sc_line, MOUSE_INCREMENTAL);
                    156:        sc->sc_enabled = 1;
                    157:        sc->inputstate = 0;
                    158:        return 0;
                    159: }
                    160:
                    161: void
                    162: qscms_disable(void *v)
                    163: {
                    164:        struct lkms_softc *sc = v;
                    165:
                    166:        sc->sc_enabled = 0;
                    167: }

CVSweb