Home | History | Annotate | Line # | Download | only in dec
vsxxx.c revision 1.10.4.1
      1  1.10.4.1     skrll /* $NetBSD: vsxxx.c,v 1.10.4.1 2009/04/28 07:35:21 skrll Exp $ */
      2       1.1  nisimura 
      3       1.9  nisimura /*-
      4       1.9  nisimura  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5       1.9  nisimura  * All rights reserved.
      6       1.9  nisimura  *
      7       1.9  nisimura  * This code is derived from software contributed to The NetBSD Foundation
      8       1.9  nisimura  * 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.9  nisimura  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.9  nisimura  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.9  nisimura  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.9  nisimura  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.9  nisimura  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.9  nisimura  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.9  nisimura  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.9  nisimura  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.9  nisimura  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.9  nisimura  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.9  nisimura  * POSSIBILITY OF SUCH DAMAGE.
     30       1.1  nisimura  */
     31       1.1  nisimura 
     32       1.3     lukem #include <sys/cdefs.h>
     33  1.10.4.1     skrll __KERNEL_RCSID(0, "$NetBSD: vsxxx.c,v 1.10.4.1 2009/04/28 07:35:21 skrll 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.10.4.1     skrll vsxxx_enable(void *v)
     90       1.1  nisimura {
     91       1.1  nisimura 	/* turn on the hardware? */
     92       1.1  nisimura 	((struct vsxxx_softc *)v)->sc_nbyte = 0;
     93       1.1  nisimura 	return 0;
     94       1.1  nisimura }
     95       1.1  nisimura 
     96       1.1  nisimura static void
     97  1.10.4.1     skrll vsxxx_disable(void *v)
     98       1.1  nisimura {
     99       1.1  nisimura 	/* turn off the hardware? */
    100       1.1  nisimura }
    101       1.1  nisimura 
    102       1.1  nisimura /*ARGUSED*/
    103       1.1  nisimura static int
    104  1.10.4.1     skrll vsxxx_ioctl(void *v, u_long cmd, void *data, int flag, struct proc *p)
    105       1.1  nisimura {
    106       1.1  nisimura 	if (cmd == WSMOUSEIO_GTYPE) {
    107       1.1  nisimura 		*(u_int *)data = WSMOUSE_TYPE_VSXXX;
    108       1.1  nisimura 		return 0;
    109       1.1  nisimura 	}
    110       1.4    atatat 	return EPASSTHROUGH;
    111       1.1  nisimura }
    112       1.1  nisimura 
    113       1.1  nisimura /* EXPORT */ void
    114      1.10    cegger vsxxx_input(int data)
    115       1.1  nisimura {
    116      1.10    cegger 	struct vsxxx_softc *sc = device_lookup_private(&vsms_cd, 0);
    117       1.1  nisimura 	int x, y;
    118       1.1  nisimura 
    119       1.1  nisimura 	if (data & VS_START_FRAME)
    120       1.1  nisimura 		sc->sc_nbyte = 0;
    121       1.1  nisimura 
    122       1.1  nisimura 	sc->sc_report.raw[sc->sc_nbyte++] = data;
    123       1.1  nisimura 
    124       1.1  nisimura 	if (sc->sc_nbyte < VS_MOUSE_REPSZ)
    125       1.1  nisimura 		return;
    126       1.1  nisimura 	sc->sc_nbyte = 0;
    127       1.1  nisimura 
    128       1.1  nisimura 	x = sc->sc_report.ms.xpos;
    129       1.1  nisimura 	y = sc->sc_report.ms.ypos;
    130       1.1  nisimura 	if ((sc->sc_report.raw[0] & VS_X_SIGN) == 0)
    131       1.1  nisimura 		x = -x;
    132       1.1  nisimura 	if ((sc->sc_report.raw[0] & VS_Y_SIGN) != 0)
    133       1.1  nisimura 		y = -y;					/* Eeeh? */
    134       1.7    plunky 	wsmouse_input(sc->sc_wsmousedev,
    135       1.7    plunky 			sc->sc_report.raw[0] & 07,
    136       1.7    plunky 			x, y, 0, 0,
    137       1.7    plunky 			WSMOUSE_INPUT_DELTA);
    138       1.1  nisimura }
    139