1 /* $NetBSD: vsxxx.c,v 1.10 2008/06/12 21:51:12 cegger Exp $ */
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: vsxxx.c,v 1.10 2008/06/12 21:51:12 cegger Exp $");
36 * Common machinary for VSXXX mice and tablet
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/device.h>
43 #include <dev/wscons/wsconsio.h>
44 #include <dev/wscons/wsmousevar.h>
46 #include <dev/dec/vsxxxvar.h>
51 * collect various mice and tablet parameters/protocol design
52 * and establish vsxxx.h
56 #define VS_SELFTEST 'T'
57 #define VS_INCREMENTAL 'R'
58 #define VS_PROMPTING 'D'
59 #define VS_REQ_POSITION 'P'
61 #define VS_MOUSE_REPSZ 3
62 #define VS_TABLET_REPSZ 5
65 #define VS_START_FRAME 0x80
66 #define VS_R_BUTTON 0x01
67 #define VS_M_BUTTON 0x02
68 #define VS_L_BUTTON 0x04
69 #define VS_Y_SIGN 0x08
70 #define VS_X_SIGN 0x10
72 /* low order 4 bit of the second octet in a SELFTEST reply */
76 extern struct cfdriver vsms_cd
;
78 static int vsxxx_enable(void *);
79 static int vsxxx_ioctl(void *, u_long
, void *, int, struct proc
*);
80 static void vsxxx_disable(void *);
82 struct wsmouse_accessops vsxxx_accessops
= { /* EXPORT */
83 vsxxx_enable
, /* MD? */
85 vsxxx_disable
, /* MD? */
91 /* turn on the hardware? */
92 ((struct vsxxx_softc
*)v
)->sc_nbyte
= 0;
97 vsxxx_disable(void *v
)
99 /* turn off the hardware? */
104 vsxxx_ioctl(void *v
, u_long cmd
, void *data
, int flag
, struct proc
*p
)
106 if (cmd
== WSMOUSEIO_GTYPE
) {
107 *(u_int
*)data
= WSMOUSE_TYPE_VSXXX
;
114 vsxxx_input(int data
)
116 struct vsxxx_softc
*sc
= device_lookup_private(&vsms_cd
, 0);
119 if (data
& VS_START_FRAME
)
122 sc
->sc_report
.raw
[sc
->sc_nbyte
++] = data
;
124 if (sc
->sc_nbyte
< VS_MOUSE_REPSZ
)
128 x
= sc
->sc_report
.ms
.xpos
;
129 y
= sc
->sc_report
.ms
.ypos
;
130 if ((sc
->sc_report
.raw
[0] & VS_X_SIGN
) == 0)
132 if ((sc
->sc_report
.raw
[0] & VS_Y_SIGN
) != 0)
134 wsmouse_input(sc
->sc_wsmousedev
,
135 sc
->sc_report
.raw
[0] & 07,
137 WSMOUSE_INPUT_DELTA
);