Home | History | Annotate | Line # | Download | only in dec
vsxxx.c revision 1.8.38.1
      1  1.8.38.1      yamt /* $NetBSD: vsxxx.c,v 1.8.38.1 2008/06/04 02:05:10 yamt Exp $ */
      2       1.1  nisimura 
      3  1.8.38.1      yamt /*-
      4  1.8.38.1      yamt  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  1.8.38.1      yamt  * All rights reserved.
      6  1.8.38.1      yamt  *
      7  1.8.38.1      yamt  * This code is derived from software contributed to The NetBSD Foundation
      8  1.8.38.1      yamt  * by Tohru Nishimura.
      9       1.1  nisimura  *
     10       1.1  nisimura  * Redistribution and use in source and binary forms, with or without
     11       1.1  nisimura  * modification, are permitted provided that the following conditions
     12       1.1  nisimura  * are met:
     13       1.1  nisimura  * 1. Redistributions of source code must retain the above copyright
     14       1.1  nisimura  *    notice, this list of conditions and the following disclaimer.
     15       1.1  nisimura  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1  nisimura  *    notice, this list of conditions and the following disclaimer in the
     17       1.1  nisimura  *    documentation and/or other materials provided with the distribution.
     18       1.1  nisimura  *
     19  1.8.38.1      yamt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.8.38.1      yamt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.8.38.1      yamt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.8.38.1      yamt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.8.38.1      yamt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.8.38.1      yamt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.8.38.1      yamt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.8.38.1      yamt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.8.38.1      yamt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.8.38.1      yamt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.8.38.1      yamt  * POSSIBILITY OF SUCH DAMAGE.
     30       1.1  nisimura  */
     31       1.1  nisimura 
     32       1.3     lukem #include <sys/cdefs.h>
     33  1.8.38.1      yamt __KERNEL_RCSID(0, "$NetBSD: vsxxx.c,v 1.8.38.1 2008/06/04 02:05:10 yamt Exp $");
     34       1.1  nisimura 
     35       1.1  nisimura /*
     36       1.1  nisimura  * Common machinary for VSXXX mice and tablet
     37       1.1  nisimura  */
     38       1.1  nisimura 
     39       1.1  nisimura #include <sys/param.h>
     40       1.1  nisimura #include <sys/systm.h>
     41       1.1  nisimura #include <sys/device.h>
     42       1.1  nisimura 
     43       1.1  nisimura #include <dev/wscons/wsconsio.h>
     44       1.1  nisimura #include <dev/wscons/wsmousevar.h>
     45       1.1  nisimura 
     46       1.1  nisimura #include <dev/dec/vsxxxvar.h>
     47       1.1  nisimura 
     48       1.1  nisimura /*
     49       1.1  nisimura  * XXX XXX XXX
     50       1.1  nisimura  *
     51       1.1  nisimura  * collect various mice and tablet parameters/protocol design
     52       1.1  nisimura  * and establish vsxxx.h
     53       1.1  nisimura  *
     54       1.1  nisimura  * XXX XXX XXX
     55       1.1  nisimura  */
     56       1.1  nisimura #define	VS_SELFTEST	'T'
     57       1.1  nisimura #define	VS_INCREMENTAL	'R'
     58       1.1  nisimura #define	VS_PROMPTING	'D'
     59       1.1  nisimura #define	VS_REQ_POSITION	'P'
     60       1.1  nisimura 
     61       1.1  nisimura #define	VS_MOUSE_REPSZ	3
     62       1.1  nisimura #define	VS_TABLET_REPSZ	5
     63       1.1  nisimura 
     64       1.1  nisimura /* first octet */
     65       1.1  nisimura #define	VS_START_FRAME	0x80
     66       1.1  nisimura #define	VS_R_BUTTON	0x01
     67       1.1  nisimura #define	VS_M_BUTTON	0x02
     68       1.1  nisimura #define	VS_L_BUTTON	0x04
     69       1.1  nisimura #define	VS_Y_SIGN	0x08
     70       1.1  nisimura #define	VS_X_SIGN	0x10
     71       1.1  nisimura 
     72       1.1  nisimura /* low order 4 bit of the second octet in a SELFTEST reply */
     73       1.1  nisimura #define	VS_MOUSE	0x2
     74       1.1  nisimura #define	VS_TABLET	0x4
     75       1.1  nisimura 
     76       1.1  nisimura extern struct cfdriver vsms_cd;
     77       1.1  nisimura 
     78       1.5     perry static int  vsxxx_enable(void *);
     79       1.8  christos static int  vsxxx_ioctl(void *, u_long, void *, int, struct proc *);
     80       1.5     perry static void vsxxx_disable(void *);
     81       1.1  nisimura 
     82       1.1  nisimura struct wsmouse_accessops vsxxx_accessops = {	/* EXPORT */
     83       1.1  nisimura 	vsxxx_enable,				/* MD? */
     84       1.1  nisimura 	vsxxx_ioctl,
     85       1.1  nisimura 	vsxxx_disable,				/* MD? */
     86       1.1  nisimura };
     87       1.1  nisimura 
     88       1.1  nisimura static int
     89       1.1  nisimura vsxxx_enable(v)
     90       1.1  nisimura 	void *v;
     91       1.1  nisimura {
     92       1.1  nisimura 	/* turn on the hardware? */
     93       1.1  nisimura 	((struct vsxxx_softc *)v)->sc_nbyte = 0;
     94       1.1  nisimura 	return 0;
     95       1.1  nisimura }
     96       1.1  nisimura 
     97       1.1  nisimura static void
     98       1.1  nisimura vsxxx_disable(v)
     99       1.1  nisimura 	void *v;
    100       1.1  nisimura {
    101       1.1  nisimura 	/* turn off the hardware? */
    102       1.1  nisimura }
    103       1.1  nisimura 
    104       1.1  nisimura /*ARGUSED*/
    105       1.1  nisimura static int
    106       1.1  nisimura vsxxx_ioctl(v, cmd, data, flag, p)
    107       1.1  nisimura 	void *v;
    108       1.1  nisimura 	u_long cmd;
    109       1.8  christos 	void *data;
    110       1.1  nisimura 	int flag;
    111       1.1  nisimura 	struct proc *p;
    112       1.1  nisimura {
    113       1.1  nisimura 	if (cmd == WSMOUSEIO_GTYPE) {
    114       1.1  nisimura 		*(u_int *)data = WSMOUSE_TYPE_VSXXX;
    115       1.1  nisimura 		return 0;
    116       1.1  nisimura 	}
    117       1.4    atatat 	return EPASSTHROUGH;
    118       1.1  nisimura }
    119       1.1  nisimura 
    120       1.1  nisimura /* EXPORT */ void
    121       1.1  nisimura vsxxx_input(data)
    122       1.1  nisimura 	int data;
    123       1.1  nisimura {
    124       1.1  nisimura 	struct vsxxx_softc *sc = (void *)vsms_cd.cd_devs[0];
    125       1.1  nisimura 	int x, y;
    126       1.1  nisimura 
    127       1.1  nisimura 	if (data & VS_START_FRAME)
    128       1.1  nisimura 		sc->sc_nbyte = 0;
    129       1.1  nisimura 
    130       1.1  nisimura 	sc->sc_report.raw[sc->sc_nbyte++] = data;
    131       1.1  nisimura 
    132       1.1  nisimura 	if (sc->sc_nbyte < VS_MOUSE_REPSZ)
    133       1.1  nisimura 		return;
    134       1.1  nisimura 	sc->sc_nbyte = 0;
    135       1.1  nisimura 
    136       1.1  nisimura 	x = sc->sc_report.ms.xpos;
    137       1.1  nisimura 	y = sc->sc_report.ms.ypos;
    138       1.1  nisimura 	if ((sc->sc_report.raw[0] & VS_X_SIGN) == 0)
    139       1.1  nisimura 		x = -x;
    140       1.1  nisimura 	if ((sc->sc_report.raw[0] & VS_Y_SIGN) != 0)
    141       1.1  nisimura 		y = -y;					/* Eeeh? */
    142       1.7    plunky 	wsmouse_input(sc->sc_wsmousedev,
    143       1.7    plunky 			sc->sc_report.raw[0] & 07,
    144       1.7    plunky 			x, y, 0, 0,
    145       1.7    plunky 			WSMOUSE_INPUT_DELTA);
    146       1.1  nisimura }
    147