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