uts.c revision 1.1.12.2 1 1.1.12.2 sborrill /*
2 1.1.12.2 sborrill * Copyright (c) 2012 The NetBSD Foundation, Inc.
3 1.1.12.2 sborrill * All rights reserved.
4 1.1.12.2 sborrill *
5 1.1.12.2 sborrill * This code is derived from software contributed to The NetBSD Foundation
6 1.1.12.2 sborrill * by Pierre Pronchery (khorben (at) defora.org).
7 1.1.12.2 sborrill *
8 1.1.12.2 sborrill * Redistribution and use in source and binary forms, with or without
9 1.1.12.2 sborrill * modification, are permitted provided that the following conditions
10 1.1.12.2 sborrill * are met:
11 1.1.12.2 sborrill * 1. Redistributions of source code must retain the above copyright
12 1.1.12.2 sborrill * notice, this list of conditions and the following disclaimer.
13 1.1.12.2 sborrill * 2. Redistributions in binary form must reproduce the above copyright
14 1.1.12.2 sborrill * notice, this list of conditions and the following disclaimer in the
15 1.1.12.2 sborrill * documentation and/or other materials provided with the distribution.
16 1.1.12.2 sborrill *
17 1.1.12.2 sborrill * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 1.1.12.2 sborrill * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 1.1.12.2 sborrill * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 1.1.12.2 sborrill * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 1.1.12.2 sborrill * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 1.1.12.2 sborrill * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 1.1.12.2 sborrill * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 1.1.12.2 sborrill * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 1.1.12.2 sborrill * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 1.1.12.2 sborrill * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 1.1.12.2 sborrill * POSSIBILITY OF SUCH DAMAGE.
28 1.1.12.2 sborrill */
29 1.1.12.2 sborrill
30 1.1.12.2 sborrill /*
31 1.1.12.2 sborrill * USB generic Touch Screen driver.
32 1.1.12.2 sborrill */
33 1.1.12.2 sborrill
34 1.1.12.2 sborrill #include <sys/cdefs.h>
35 1.1.12.2 sborrill __KERNEL_RCSID(0, "$NetBSD: uts.c,v 1.1.12.2 2012/09/28 10:58:17 sborrill Exp $");
36 1.1.12.2 sborrill
37 1.1.12.2 sborrill #include <sys/param.h>
38 1.1.12.2 sborrill #include <sys/systm.h>
39 1.1.12.2 sborrill #include <sys/kernel.h>
40 1.1.12.2 sborrill #include <sys/malloc.h>
41 1.1.12.2 sborrill #include <sys/device.h>
42 1.1.12.2 sborrill #include <sys/ioctl.h>
43 1.1.12.2 sborrill #include <sys/vnode.h>
44 1.1.12.2 sborrill
45 1.1.12.2 sborrill #include <dev/usb/usb.h>
46 1.1.12.2 sborrill #include <dev/usb/usbhid.h>
47 1.1.12.2 sborrill
48 1.1.12.2 sborrill #include <dev/usb/usbdi.h>
49 1.1.12.2 sborrill #include <dev/usb/usbdi_util.h>
50 1.1.12.2 sborrill #include <dev/usb/usbdevs.h>
51 1.1.12.2 sborrill #include <dev/usb/usb_quirks.h>
52 1.1.12.2 sborrill #include <dev/usb/uhidev.h>
53 1.1.12.2 sborrill #include <dev/usb/hid.h>
54 1.1.12.2 sborrill
55 1.1.12.2 sborrill #include <dev/wscons/wsconsio.h>
56 1.1.12.2 sborrill #include <dev/wscons/wsmousevar.h>
57 1.1.12.2 sborrill #include <dev/wscons/tpcalibvar.h>
58 1.1.12.2 sborrill
59 1.1.12.2 sborrill #ifdef USB_DEBUG
60 1.1.12.2 sborrill #define DPRINTF(x) if (utsdebug) printf x
61 1.1.12.2 sborrill #define DPRINTFN(n,x) if (utsdebug>(n)) printf x
62 1.1.12.2 sborrill int utsdebug = 0;
63 1.1.12.2 sborrill #else
64 1.1.12.2 sborrill #define DPRINTF(x)
65 1.1.12.2 sborrill #define DPRINTFN(n,x)
66 1.1.12.2 sborrill #endif
67 1.1.12.2 sborrill
68 1.1.12.2 sborrill
69 1.1.12.2 sborrill struct uts_softc {
70 1.1.12.2 sborrill struct uhidev sc_hdev;
71 1.1.12.2 sborrill
72 1.1.12.2 sborrill struct hid_location sc_loc_x, sc_loc_y, sc_loc_z;
73 1.1.12.2 sborrill struct hid_location sc_loc_btn;
74 1.1.12.2 sborrill
75 1.1.12.2 sborrill int sc_enabled;
76 1.1.12.2 sborrill
77 1.1.12.2 sborrill int flags; /* device configuration */
78 1.1.12.2 sborrill #define UTS_ABS 0x1 /* absolute position */
79 1.1.12.2 sborrill
80 1.1.12.2 sborrill u_int32_t sc_buttons; /* touchscreen button status */
81 1.1.12.2 sborrill device_t sc_wsmousedev;
82 1.1.12.2 sborrill struct tpcalib_softc sc_tpcalib; /* calibration */
83 1.1.12.2 sborrill struct wsmouse_calibcoords sc_calibcoords;
84 1.1.12.2 sborrill
85 1.1.12.2 sborrill char sc_dying;
86 1.1.12.2 sborrill };
87 1.1.12.2 sborrill
88 1.1.12.2 sborrill #define TSCREEN_FLAGS_MASK (HIO_CONST|HIO_RELATIVE)
89 1.1.12.2 sborrill
90 1.1.12.2 sborrill Static void uts_intr(struct uhidev *addr, void *ibuf, u_int len);
91 1.1.12.2 sborrill
92 1.1.12.2 sborrill Static int uts_enable(void *);
93 1.1.12.2 sborrill Static void uts_disable(void *);
94 1.1.12.2 sborrill Static int uts_ioctl(void *, u_long, void *, int, struct lwp *);
95 1.1.12.2 sborrill
96 1.1.12.2 sborrill Static const struct wsmouse_accessops uts_accessops = {
97 1.1.12.2 sborrill uts_enable,
98 1.1.12.2 sborrill uts_ioctl,
99 1.1.12.2 sborrill uts_disable,
100 1.1.12.2 sborrill };
101 1.1.12.2 sborrill
102 1.1.12.2 sborrill Static int uts_match(device_t, cfdata_t, void *);
103 1.1.12.2 sborrill Static void uts_attach(device_t, device_t, void *);
104 1.1.12.2 sborrill Static void uts_childdet(device_t, device_t);
105 1.1.12.2 sborrill Static int uts_detach(device_t, int);
106 1.1.12.2 sborrill Static int uts_activate(device_t, enum devact);
107 1.1.12.2 sborrill
108 1.1.12.2 sborrill extern struct cfdriver uts_cd;
109 1.1.12.2 sborrill
110 1.1.12.2 sborrill CFATTACH_DECL2_NEW(uts, sizeof(struct uts_softc), uts_match, uts_attach,
111 1.1.12.2 sborrill uts_detach, uts_activate, NULL, uts_childdet);
112 1.1.12.2 sborrill
113 1.1.12.2 sborrill Static int
114 1.1.12.2 sborrill uts_match(device_t parent, cfdata_t match, void *aux)
115 1.1.12.2 sborrill {
116 1.1.12.2 sborrill struct uhidev_attach_arg *uha = aux;
117 1.1.12.2 sborrill int size;
118 1.1.12.2 sborrill void *desc;
119 1.1.12.2 sborrill
120 1.1.12.2 sborrill uhidev_get_report_desc(uha->parent, &desc, &size);
121 1.1.12.2 sborrill if (!hid_is_collection(desc, size, uha->reportid,
122 1.1.12.2 sborrill HID_USAGE2(HUP_DIGITIZERS, HUD_TOUCH_SCREEN)) &&
123 1.1.12.2 sborrill !hid_is_collection(desc, size, uha->reportid,
124 1.1.12.2 sborrill HID_USAGE2(HUP_DIGITIZERS, HUD_FINGER)))
125 1.1.12.2 sborrill return UMATCH_NONE;
126 1.1.12.2 sborrill
127 1.1.12.2 sborrill return UMATCH_IFACECLASS;
128 1.1.12.2 sborrill }
129 1.1.12.2 sborrill
130 1.1.12.2 sborrill Static void
131 1.1.12.2 sborrill uts_attach(device_t parent, device_t self, void *aux)
132 1.1.12.2 sborrill {
133 1.1.12.2 sborrill struct uts_softc *sc = device_private(self);
134 1.1.12.2 sborrill struct uhidev_attach_arg *uha = aux;
135 1.1.12.2 sborrill struct wsmousedev_attach_args a;
136 1.1.12.2 sborrill int size;
137 1.1.12.2 sborrill void *desc;
138 1.1.12.2 sborrill u_int32_t flags;
139 1.1.12.2 sborrill struct hid_data * d;
140 1.1.12.2 sborrill struct hid_item item;
141 1.1.12.2 sborrill
142 1.1.12.2 sborrill aprint_naive("\n");
143 1.1.12.2 sborrill
144 1.1.12.2 sborrill sc->sc_hdev.sc_dev = self;
145 1.1.12.2 sborrill sc->sc_hdev.sc_intr = uts_intr;
146 1.1.12.2 sborrill sc->sc_hdev.sc_parent = uha->parent;
147 1.1.12.2 sborrill sc->sc_hdev.sc_report_id = uha->reportid;
148 1.1.12.2 sborrill
149 1.1.12.2 sborrill uhidev_get_report_desc(uha->parent, &desc, &size);
150 1.1.12.2 sborrill
151 1.1.12.2 sborrill if (!pmf_device_register(self, NULL, NULL))
152 1.1.12.2 sborrill aprint_error_dev(self, "couldn't establish power handler\n");
153 1.1.12.2 sborrill
154 1.1.12.2 sborrill /* requires HID usage Generic_Desktop:X */
155 1.1.12.2 sborrill if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X),
156 1.1.12.2 sborrill uha->reportid, hid_input, &sc->sc_loc_x, &flags)) {
157 1.1.12.2 sborrill aprint_error_dev(sc->sc_hdev.sc_dev,
158 1.1.12.2 sborrill "touchscreen has no X report\n");
159 1.1.12.2 sborrill return;
160 1.1.12.2 sborrill }
161 1.1.12.2 sborrill switch (flags & TSCREEN_FLAGS_MASK) {
162 1.1.12.2 sborrill case 0:
163 1.1.12.2 sborrill sc->flags |= UTS_ABS;
164 1.1.12.2 sborrill break;
165 1.1.12.2 sborrill case HIO_RELATIVE:
166 1.1.12.2 sborrill break;
167 1.1.12.2 sborrill default:
168 1.1.12.2 sborrill aprint_error_dev(sc->sc_hdev.sc_dev,
169 1.1.12.2 sborrill "X report 0x%04x not supported\n", flags);
170 1.1.12.2 sborrill return;
171 1.1.12.2 sborrill }
172 1.1.12.2 sborrill
173 1.1.12.2 sborrill /* requires HID usage Generic_Desktop:Y */
174 1.1.12.2 sborrill if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y),
175 1.1.12.2 sborrill uha->reportid, hid_input, &sc->sc_loc_y, &flags)) {
176 1.1.12.2 sborrill aprint_error_dev(sc->sc_hdev.sc_dev,
177 1.1.12.2 sborrill "touchscreen has no Y report\n");
178 1.1.12.2 sborrill return;
179 1.1.12.2 sborrill }
180 1.1.12.2 sborrill switch (flags & TSCREEN_FLAGS_MASK) {
181 1.1.12.2 sborrill case 0:
182 1.1.12.2 sborrill sc->flags |= UTS_ABS;
183 1.1.12.2 sborrill break;
184 1.1.12.2 sborrill case HIO_RELATIVE:
185 1.1.12.2 sborrill break;
186 1.1.12.2 sborrill default:
187 1.1.12.2 sborrill aprint_error_dev(sc->sc_hdev.sc_dev,
188 1.1.12.2 sborrill "Y report 0x%04x not supported\n", flags);
189 1.1.12.2 sborrill return;
190 1.1.12.2 sborrill }
191 1.1.12.2 sborrill
192 1.1.12.2 sborrill /* requires HID usage Digitizer:Tip_Switch */
193 1.1.12.2 sborrill if (!hid_locate(desc, size, HID_USAGE2(HUP_DIGITIZERS, HUD_TIP_SWITCH),
194 1.1.12.2 sborrill uha->reportid, hid_input, &sc->sc_loc_btn, 0)) {
195 1.1.12.2 sborrill aprint_error_dev(sc->sc_hdev.sc_dev,
196 1.1.12.2 sborrill "touchscreen has no tip switch report\n");
197 1.1.12.2 sborrill return;
198 1.1.12.2 sborrill }
199 1.1.12.2 sborrill
200 1.1.12.2 sborrill /* requires HID usage Digitizer:In_Range */
201 1.1.12.2 sborrill if (!hid_locate(desc, size, HID_USAGE2(HUP_DIGITIZERS, HUD_IN_RANGE),
202 1.1.12.2 sborrill uha->reportid, hid_input, &sc->sc_loc_z, &flags)) {
203 1.1.12.2 sborrill aprint_error_dev(sc->sc_hdev.sc_dev,
204 1.1.12.2 sborrill "touchscreen has no range report\n");
205 1.1.12.2 sborrill return;
206 1.1.12.2 sborrill }
207 1.1.12.2 sborrill
208 1.1.12.2 sborrill /* multi-touch support would need HUD_CONTACTID and HUD_CONTACTMAX */
209 1.1.12.2 sborrill
210 1.1.12.2 sborrill #ifdef USB_DEBUG
211 1.1.12.2 sborrill DPRINTF(("uts_attach: sc=%p\n", sc));
212 1.1.12.2 sborrill DPRINTF(("uts_attach: X\t%d/%d\n",
213 1.1.12.2 sborrill sc->sc_loc_x.pos, sc->sc_loc_x.size));
214 1.1.12.2 sborrill DPRINTF(("uts_attach: Y\t%d/%d\n",
215 1.1.12.2 sborrill sc->sc_loc_y.pos, sc->sc_loc_y.size));
216 1.1.12.2 sborrill DPRINTF(("uts_attach: Z\t%d/%d\n",
217 1.1.12.2 sborrill sc->sc_loc_z.pos, sc->sc_loc_z.size));
218 1.1.12.2 sborrill #endif
219 1.1.12.2 sborrill
220 1.1.12.2 sborrill a.accessops = &uts_accessops;
221 1.1.12.2 sborrill a.accesscookie = sc;
222 1.1.12.2 sborrill
223 1.1.12.2 sborrill sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
224 1.1.12.2 sborrill
225 1.1.12.2 sborrill /* calibrate the touchscreen */
226 1.1.12.2 sborrill memset(&sc->sc_calibcoords, 0, sizeof(sc->sc_calibcoords));
227 1.1.12.2 sborrill sc->sc_calibcoords.maxx = 4095;
228 1.1.12.2 sborrill sc->sc_calibcoords.maxy = 4095;
229 1.1.12.2 sborrill sc->sc_calibcoords.samplelen = WSMOUSE_CALIBCOORDS_RESET;
230 1.1.12.2 sborrill d = hid_start_parse(desc, size, hid_input);
231 1.1.12.2 sborrill while (hid_get_item(d, &item)) {
232 1.1.12.2 sborrill if (item.kind != hid_input
233 1.1.12.2 sborrill || HID_GET_USAGE_PAGE(item.usage) != HUP_GENERIC_DESKTOP
234 1.1.12.2 sborrill || item.report_ID != sc->sc_hdev.sc_report_id)
235 1.1.12.2 sborrill continue;
236 1.1.12.2 sborrill if (HID_GET_USAGE(item.usage) == HUG_X) {
237 1.1.12.2 sborrill sc->sc_calibcoords.minx = item.logical_minimum;
238 1.1.12.2 sborrill sc->sc_calibcoords.maxx = item.logical_maximum;
239 1.1.12.2 sborrill }
240 1.1.12.2 sborrill if (HID_GET_USAGE(item.usage) == HUG_Y) {
241 1.1.12.2 sborrill sc->sc_calibcoords.miny = item.logical_minimum;
242 1.1.12.2 sborrill sc->sc_calibcoords.maxy = item.logical_maximum;
243 1.1.12.2 sborrill }
244 1.1.12.2 sborrill }
245 1.1.12.2 sborrill hid_end_parse(d);
246 1.1.12.2 sborrill
247 1.1.12.2 sborrill tpcalib_init(&sc->sc_tpcalib);
248 1.1.12.2 sborrill tpcalib_ioctl(&sc->sc_tpcalib, WSMOUSEIO_SCALIBCOORDS,
249 1.1.12.2 sborrill (void *)&sc->sc_calibcoords, 0, 0);
250 1.1.12.2 sborrill
251 1.1.12.2 sborrill return;
252 1.1.12.2 sborrill }
253 1.1.12.2 sborrill
254 1.1.12.2 sborrill Static int
255 1.1.12.2 sborrill uts_detach(device_t self, int flags)
256 1.1.12.2 sborrill {
257 1.1.12.2 sborrill struct uts_softc *sc = device_private(self);
258 1.1.12.2 sborrill int rv = 0;
259 1.1.12.2 sborrill
260 1.1.12.2 sborrill DPRINTF(("uts_detach: sc=%p flags=%d\n", sc, flags));
261 1.1.12.2 sborrill
262 1.1.12.2 sborrill if (sc->sc_wsmousedev != NULL)
263 1.1.12.2 sborrill rv = config_detach(sc->sc_wsmousedev, flags);
264 1.1.12.2 sborrill
265 1.1.12.2 sborrill pmf_device_deregister(self);
266 1.1.12.2 sborrill
267 1.1.12.2 sborrill return rv;
268 1.1.12.2 sborrill }
269 1.1.12.2 sborrill
270 1.1.12.2 sborrill Static void
271 1.1.12.2 sborrill uts_childdet(device_t self, device_t child)
272 1.1.12.2 sborrill {
273 1.1.12.2 sborrill struct uts_softc *sc = device_private(self);
274 1.1.12.2 sborrill
275 1.1.12.2 sborrill KASSERT(sc->sc_wsmousedev == child);
276 1.1.12.2 sborrill sc->sc_wsmousedev = NULL;
277 1.1.12.2 sborrill }
278 1.1.12.2 sborrill
279 1.1.12.2 sborrill Static int
280 1.1.12.2 sborrill uts_activate(device_t self, enum devact act)
281 1.1.12.2 sborrill {
282 1.1.12.2 sborrill struct uts_softc *sc = device_private(self);
283 1.1.12.2 sborrill
284 1.1.12.2 sborrill switch (act) {
285 1.1.12.2 sborrill case DVACT_DEACTIVATE:
286 1.1.12.2 sborrill sc->sc_dying = 1;
287 1.1.12.2 sborrill return 0;
288 1.1.12.2 sborrill default:
289 1.1.12.2 sborrill return EOPNOTSUPP;
290 1.1.12.2 sborrill }
291 1.1.12.2 sborrill }
292 1.1.12.2 sborrill
293 1.1.12.2 sborrill Static int
294 1.1.12.2 sborrill uts_enable(void *v)
295 1.1.12.2 sborrill {
296 1.1.12.2 sborrill struct uts_softc *sc = v;
297 1.1.12.2 sborrill
298 1.1.12.2 sborrill DPRINTFN(1,("uts_enable: sc=%p\n", sc));
299 1.1.12.2 sborrill
300 1.1.12.2 sborrill if (sc->sc_dying)
301 1.1.12.2 sborrill return EIO;
302 1.1.12.2 sborrill
303 1.1.12.2 sborrill if (sc->sc_enabled)
304 1.1.12.2 sborrill return EBUSY;
305 1.1.12.2 sborrill
306 1.1.12.2 sborrill sc->sc_enabled = 1;
307 1.1.12.2 sborrill sc->sc_buttons = 0;
308 1.1.12.2 sborrill
309 1.1.12.2 sborrill return uhidev_open(&sc->sc_hdev);
310 1.1.12.2 sborrill }
311 1.1.12.2 sborrill
312 1.1.12.2 sborrill Static void
313 1.1.12.2 sborrill uts_disable(void *v)
314 1.1.12.2 sborrill {
315 1.1.12.2 sborrill struct uts_softc *sc = v;
316 1.1.12.2 sborrill
317 1.1.12.2 sborrill DPRINTFN(1,("uts_disable: sc=%p\n", sc));
318 1.1.12.2 sborrill #ifdef DIAGNOSTIC
319 1.1.12.2 sborrill if (!sc->sc_enabled) {
320 1.1.12.2 sborrill printf("uts_disable: not enabled\n");
321 1.1.12.2 sborrill return;
322 1.1.12.2 sborrill }
323 1.1.12.2 sborrill #endif
324 1.1.12.2 sborrill
325 1.1.12.2 sborrill sc->sc_enabled = 0;
326 1.1.12.2 sborrill uhidev_close(&sc->sc_hdev);
327 1.1.12.2 sborrill }
328 1.1.12.2 sborrill
329 1.1.12.2 sborrill Static int
330 1.1.12.2 sborrill uts_ioctl(void *v, u_long cmd, void *data, int flag, struct lwp *l)
331 1.1.12.2 sborrill {
332 1.1.12.2 sborrill struct uts_softc *sc = v;
333 1.1.12.2 sborrill
334 1.1.12.2 sborrill switch (cmd) {
335 1.1.12.2 sborrill case WSMOUSEIO_GTYPE:
336 1.1.12.2 sborrill if (sc->flags & UTS_ABS)
337 1.1.12.2 sborrill *(u_int *)data = WSMOUSE_TYPE_TPANEL;
338 1.1.12.2 sborrill else
339 1.1.12.2 sborrill *(u_int *)data = WSMOUSE_TYPE_USB;
340 1.1.12.2 sborrill return 0;
341 1.1.12.2 sborrill case WSMOUSEIO_SCALIBCOORDS:
342 1.1.12.2 sborrill case WSMOUSEIO_GCALIBCOORDS:
343 1.1.12.2 sborrill return tpcalib_ioctl(&sc->sc_tpcalib, cmd, data, flag, l);
344 1.1.12.2 sborrill }
345 1.1.12.2 sborrill
346 1.1.12.2 sborrill return EPASSTHROUGH;
347 1.1.12.2 sborrill }
348 1.1.12.2 sborrill
349 1.1.12.2 sborrill Static void
350 1.1.12.2 sborrill uts_intr(struct uhidev *addr, void *ibuf, u_int len)
351 1.1.12.2 sborrill {
352 1.1.12.2 sborrill struct uts_softc *sc = (struct uts_softc *)addr;
353 1.1.12.2 sborrill int dx, dy, dz;
354 1.1.12.2 sborrill u_int32_t buttons = 0;
355 1.1.12.2 sborrill int flags, s;
356 1.1.12.2 sborrill
357 1.1.12.2 sborrill DPRINTFN(5,("uts_intr: len=%d\n", len));
358 1.1.12.2 sborrill
359 1.1.12.2 sborrill flags = WSMOUSE_INPUT_DELTA | WSMOUSE_INPUT_ABSOLUTE_Z;
360 1.1.12.2 sborrill
361 1.1.12.2 sborrill dx = hid_get_data(ibuf, &sc->sc_loc_x);
362 1.1.12.2 sborrill if (sc->flags & UTS_ABS) {
363 1.1.12.2 sborrill flags |= (WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y);
364 1.1.12.2 sborrill dy = hid_get_data(ibuf, &sc->sc_loc_y);
365 1.1.12.2 sborrill tpcalib_trans(&sc->sc_tpcalib, dx, dy, &dx, &dy);
366 1.1.12.2 sborrill } else
367 1.1.12.2 sborrill dy = -hid_get_data(ibuf, &sc->sc_loc_y);
368 1.1.12.2 sborrill
369 1.1.12.2 sborrill dz = hid_get_data(ibuf, &sc->sc_loc_z);
370 1.1.12.2 sborrill
371 1.1.12.2 sborrill if (hid_get_data(ibuf, &sc->sc_loc_btn))
372 1.1.12.2 sborrill buttons |= 1;
373 1.1.12.2 sborrill
374 1.1.12.2 sborrill if (dx != 0 || dy != 0 || dz != 0 || buttons != sc->sc_buttons) {
375 1.1.12.2 sborrill DPRINTFN(10,("uts_intr: x:%d y:%d z:%d buttons:0x%x\n",
376 1.1.12.2 sborrill dx, dy, dz, buttons));
377 1.1.12.2 sborrill sc->sc_buttons = buttons;
378 1.1.12.2 sborrill if (sc->sc_wsmousedev != NULL) {
379 1.1.12.2 sborrill s = spltty();
380 1.1.12.2 sborrill wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, dz, 0,
381 1.1.12.2 sborrill flags);
382 1.1.12.2 sborrill splx(s);
383 1.1.12.2 sborrill }
384 1.1.12.2 sborrill }
385 1.1.12.2 sborrill }
386