uhidev.c revision 1.33.6.3 1 /* $NetBSD: uhidev.c,v 1.33.6.3 2007/10/09 13:42:10 ad Exp $ */
2
3 /*
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart (at) augustsson.net) at
9 * Carlstedt Research & Technology.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 /*
41 * HID spec: http://www.usb.org/developers/devclass_docs/HID1_11.pdf
42 */
43
44 #include <sys/cdefs.h>
45 __KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.33.6.3 2007/10/09 13:42:10 ad Exp $");
46
47 #include <sys/param.h>
48 #include <sys/systm.h>
49 #include <sys/kernel.h>
50 #include <sys/malloc.h>
51 #include <sys/signalvar.h>
52 #include <sys/device.h>
53 #include <sys/ioctl.h>
54 #include <sys/conf.h>
55
56 #include <dev/usb/usb.h>
57 #include <dev/usb/usbhid.h>
58
59 #include <dev/usb/usbdevs.h>
60 #include <dev/usb/usbdi.h>
61 #include <dev/usb/usbdi_util.h>
62 #include <dev/usb/hid.h>
63 #include <dev/usb/usb_quirks.h>
64
65 #include <dev/usb/uhidev.h>
66
67 /* Report descriptor for broken Wacom Graphire */
68 #include <dev/usb/ugraphire_rdesc.h>
69
70 #include "locators.h"
71
72 #ifdef UHIDEV_DEBUG
73 #define DPRINTF(x) if (uhidevdebug) logprintf x
74 #define DPRINTFN(n,x) if (uhidevdebug>(n)) logprintf x
75 int uhidevdebug = 0;
76 #else
77 #define DPRINTF(x)
78 #define DPRINTFN(n,x)
79 #endif
80
81 Static void uhidev_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
82
83 Static int uhidev_maxrepid(void *, int);
84 Static int uhidevprint(void *, const char *);
85
86 USB_DECLARE_DRIVER(uhidev);
87
88 USB_MATCH(uhidev)
89 {
90 USB_IFMATCH_START(uhidev, uaa);
91
92 if (uaa->class != UICLASS_HID)
93 return (UMATCH_NONE);
94 if (usbd_get_quirks(uaa->device)->uq_flags & UQ_HID_IGNORE)
95 return (UMATCH_NONE);
96 return (UMATCH_IFACECLASS_GENERIC);
97 }
98
99 USB_ATTACH(uhidev)
100 {
101 USB_IFATTACH_START(uhidev, sc, uaa);
102 usbd_interface_handle iface = uaa->iface;
103 usb_interface_descriptor_t *id;
104 usb_endpoint_descriptor_t *ed;
105 struct uhidev_attach_arg uha;
106 struct uhidev *dev;
107 int size, nrepid, repid, repsz;
108 int *repsizes;
109 int i;
110 void *desc;
111 const void *descptr;
112 usbd_status err;
113 char *devinfop;
114 int locs[UHIDBUSCF_NLOCS];
115
116 sc->sc_udev = uaa->device;
117 sc->sc_iface = iface;
118 id = usbd_get_interface_descriptor(iface);
119
120 devinfop = usbd_devinfo_alloc(uaa->device, 0);
121 USB_ATTACH_SETUP;
122 printf("%s: %s, iclass %d/%d\n", USBDEVNAME(sc->sc_dev),
123 devinfop, id->bInterfaceClass, id->bInterfaceSubClass);
124 usbd_devinfo_free(devinfop);
125
126 (void)usbd_set_idle(iface, 0, 0);
127 #if 0
128
129 qflags = usbd_get_quirks(sc->sc_udev)->uq_flags;
130 if ((qflags & UQ_NO_SET_PROTO) == 0 &&
131 id->bInterfaceSubClass != UISUBCLASS_BOOT)
132 (void)usbd_set_protocol(iface, 1);
133 #endif
134
135 sc->sc_iep_addr = sc->sc_oep_addr = -1;
136 for (i = 0; i < id->bNumEndpoints; i++) {
137 ed = usbd_interface2endpoint_descriptor(iface, i);
138 if (ed == NULL) {
139 printf("%s: could not read endpoint descriptor\n",
140 USBDEVNAME(sc->sc_dev));
141 sc->sc_dying = 1;
142 USB_ATTACH_ERROR_RETURN;
143 }
144
145 DPRINTFN(10,("uhidev_attach: bLength=%d bDescriptorType=%d "
146 "bEndpointAddress=%d-%s bmAttributes=%d wMaxPacketSize=%d"
147 " bInterval=%d\n",
148 ed->bLength, ed->bDescriptorType,
149 ed->bEndpointAddress & UE_ADDR,
150 UE_GET_DIR(ed->bEndpointAddress)==UE_DIR_IN? "in" : "out",
151 ed->bmAttributes & UE_XFERTYPE,
152 UGETW(ed->wMaxPacketSize), ed->bInterval));
153
154 if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
155 (ed->bmAttributes & UE_XFERTYPE) == UE_INTERRUPT) {
156 sc->sc_iep_addr = ed->bEndpointAddress;
157 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
158 (ed->bmAttributes & UE_XFERTYPE) == UE_INTERRUPT) {
159 sc->sc_oep_addr = ed->bEndpointAddress;
160 } else {
161 printf("%s: endpoint %d: ignored\n", USBDEVNAME(sc->sc_dev), i);
162 }
163 }
164
165 /*
166 * Check that we found an input interrupt endpoint. The output interrupt
167 * endpoint is optional
168 */
169 if (sc->sc_iep_addr == -1) {
170 printf("%s: no input interrupt endpoint\n", USBDEVNAME(sc->sc_dev));
171 sc->sc_dying = 1;
172 USB_ATTACH_ERROR_RETURN;
173 }
174
175 /* XXX need to extend this */
176 descptr = NULL;
177 if (uaa->vendor == USB_VENDOR_WACOM) {
178 static uByte reportbuf[] = {2, 2, 2};
179
180 /* The report descriptor for the Wacom Graphire is broken. */
181 switch (uaa->product) {
182 case USB_PRODUCT_WACOM_GRAPHIRE:
183 size = sizeof uhid_graphire_report_descr;
184 descptr = uhid_graphire_report_descr;
185 break;
186
187 case USB_PRODUCT_WACOM_GRAPHIRE3_4X5:
188 case USB_PRODUCT_WACOM_GRAPHIRE3_6X8:
189 case USB_PRODUCT_WACOM_GRAPHIRE4_4X5: /* The 6x8 too? */
190 /*
191 * The Graphire3 needs 0x0202 to be written to
192 * feature report ID 2 before it'll start
193 * returning digitizer data.
194 */
195 usbd_set_report(uaa->iface, UHID_FEATURE_REPORT, 2,
196 &reportbuf, sizeof reportbuf);
197
198 size = sizeof uhid_graphire3_4x5_report_descr;
199 descptr = uhid_graphire3_4x5_report_descr;
200 break;
201 default:
202 /* Keep descriptor */
203 break;
204 }
205 }
206
207 if (descptr) {
208 desc = malloc(size, M_USBDEV, M_NOWAIT);
209 if (desc == NULL)
210 err = USBD_NOMEM;
211 else {
212 err = USBD_NORMAL_COMPLETION;
213 memcpy(desc, descptr, size);
214 }
215 } else {
216 desc = NULL;
217 err = usbd_read_report_desc(uaa->iface, &desc, &size,
218 M_USBDEV);
219 }
220 if (err) {
221 printf("%s: no report descriptor\n", USBDEVNAME(sc->sc_dev));
222 sc->sc_dying = 1;
223 USB_ATTACH_ERROR_RETURN;
224 }
225
226 if (uaa->vendor == USB_VENDOR_HOSIDEN &&
227 uaa->product == USB_PRODUCT_HOSIDEN_PPP) {
228 static uByte reportbuf[] = { 1 };
229 /*
230 * This device was sold by Konami with its ParaParaParadise
231 * game for PlayStation2. It needs to be "turned on"
232 * before it will send any reports.
233 */
234
235 usbd_set_report(uaa->iface, UHID_FEATURE_REPORT, 0,
236 &reportbuf, sizeof reportbuf);
237 }
238
239 sc->sc_repdesc = desc;
240 sc->sc_repdesc_size = size;
241
242 uha.uaa = uaa;
243 nrepid = uhidev_maxrepid(desc, size);
244 if (nrepid < 0)
245 USB_ATTACH_SUCCESS_RETURN;
246 if (nrepid > 0)
247 printf("%s: %d report ids\n", USBDEVNAME(sc->sc_dev), nrepid);
248 nrepid++;
249 repsizes = malloc(nrepid * sizeof(*repsizes), M_TEMP, M_NOWAIT);
250 if (repsizes == NULL)
251 goto nomem;
252 sc->sc_subdevs = malloc(nrepid * sizeof(device_ptr_t),
253 M_USBDEV, M_NOWAIT | M_ZERO);
254 if (sc->sc_subdevs == NULL) {
255 free(repsizes, M_TEMP);
256 nomem:
257 printf("%s: no memory\n", USBDEVNAME(sc->sc_dev));
258 USB_ATTACH_ERROR_RETURN;
259 }
260 sc->sc_nrepid = nrepid;
261 sc->sc_isize = 0;
262
263 usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
264 USBDEV(sc->sc_dev));
265
266 for (repid = 0; repid < nrepid; repid++) {
267 repsz = hid_report_size(desc, size, hid_input, repid);
268 DPRINTF(("uhidev_match: repid=%d, repsz=%d\n", repid, repsz));
269 repsizes[repid] = repsz;
270 if (repsz > 0) {
271 if (repsz > sc->sc_isize)
272 sc->sc_isize = repsz;
273 }
274 }
275 sc->sc_isize += nrepid != 1; /* space for report ID */
276 DPRINTF(("uhidev_attach: isize=%d\n", sc->sc_isize));
277
278 uha.parent = sc;
279 for (repid = 0; repid < nrepid; repid++) {
280 DPRINTF(("uhidev_match: try repid=%d\n", repid));
281 if (hid_report_size(desc, size, hid_input, repid) == 0 &&
282 hid_report_size(desc, size, hid_output, repid) == 0 &&
283 hid_report_size(desc, size, hid_feature, repid) == 0) {
284 ; /* already NULL in sc->sc_subdevs[repid] */
285 } else {
286 uha.reportid = repid;
287 locs[UHIDBUSCF_REPORTID] = repid;
288
289 dev = (struct uhidev *)config_found_sm_loc(self,
290 "uhidbus", locs, &uha,
291 uhidevprint, config_stdsubmatch);
292 sc->sc_subdevs[repid] = dev;
293 if (dev != NULL) {
294 dev->sc_in_rep_size = repsizes[repid];
295 #ifdef DIAGNOSTIC
296 DPRINTF(("uhidev_match: repid=%d dev=%p\n",
297 repid, dev));
298 if (dev->sc_intr == NULL) {
299 free(repsizes, M_TEMP);
300 printf("%s: sc_intr == NULL\n",
301 USBDEVNAME(sc->sc_dev));
302 USB_ATTACH_ERROR_RETURN;
303 }
304 #endif
305 #if NRND > 0
306 rnd_attach_source(&dev->rnd_source,
307 USBDEVNAME(dev->sc_dev),
308 RND_TYPE_TTY, 0);
309 #endif
310 }
311 }
312 }
313 free(repsizes, M_TEMP);
314
315 USB_ATTACH_SUCCESS_RETURN;
316 }
317
318 int
319 uhidev_maxrepid(void *buf, int len)
320 {
321 struct hid_data *d;
322 struct hid_item h;
323 int maxid;
324
325 maxid = -1;
326 h.report_ID = 0;
327 for (d = hid_start_parse(buf, len, hid_none); hid_get_item(d, &h); )
328 if (h.report_ID > maxid)
329 maxid = h.report_ID;
330 hid_end_parse(d);
331 return (maxid);
332 }
333
334 int
335 uhidevprint(void *aux, const char *pnp)
336 {
337 struct uhidev_attach_arg *uha = aux;
338
339 if (pnp)
340 aprint_normal("uhid at %s", pnp);
341 if (uha->reportid != 0)
342 aprint_normal(" reportid %d", uha->reportid);
343 return (UNCONF);
344 }
345
346 int
347 uhidev_activate(device_ptr_t self, enum devact act)
348 {
349 struct uhidev_softc *sc = (struct uhidev_softc *)self;
350 int i, rv;
351
352 switch (act) {
353 case DVACT_ACTIVATE:
354 return (EOPNOTSUPP);
355
356 case DVACT_DEACTIVATE:
357 rv = 0;
358 for (i = 0; i < sc->sc_nrepid; i++)
359 if (sc->sc_subdevs[i] != NULL)
360 rv |= config_deactivate(
361 &sc->sc_subdevs[i]->sc_dev);
362 sc->sc_dying = 1;
363 break;
364 default:
365 rv = 0;
366 break;
367 }
368 return (rv);
369 }
370
371 USB_DETACH(uhidev)
372 {
373 USB_DETACH_START(uhidev, sc);
374 int i, rv;
375
376 DPRINTF(("uhidev_detach: sc=%p flags=%d\n", sc, flags));
377
378 sc->sc_dying = 1;
379 if (sc->sc_ipipe != NULL)
380 usbd_abort_pipe(sc->sc_ipipe);
381
382 if (sc->sc_repdesc != NULL)
383 free(sc->sc_repdesc, M_USBDEV);
384
385 rv = 0;
386 for (i = 0; i < sc->sc_nrepid; i++) {
387 if (sc->sc_subdevs[i] != NULL) {
388 #if NRND > 0
389 rnd_detach_source(&sc->sc_subdevs[i]->rnd_source);
390 #endif
391 rv |= config_detach(&sc->sc_subdevs[i]->sc_dev, flags);
392 sc->sc_subdevs[i] = NULL;
393 }
394 }
395
396 usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
397 USBDEV(sc->sc_dev));
398
399 return (rv);
400 }
401
402 void
403 uhidev_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status)
404 {
405 struct uhidev_softc *sc = addr;
406 struct uhidev *scd;
407 u_char *p;
408 u_int rep;
409 u_int32_t cc;
410
411 usbd_get_xfer_status(xfer, NULL, NULL, &cc, NULL);
412
413 #ifdef UHIDEV_DEBUG
414 if (uhidevdebug > 5) {
415 u_int32_t i;
416
417 DPRINTF(("uhidev_intr: status=%d cc=%d\n", status, cc));
418 DPRINTF(("uhidev_intr: data ="));
419 for (i = 0; i < cc; i++)
420 DPRINTF((" %02x", sc->sc_ibuf[i]));
421 DPRINTF(("\n"));
422 }
423 #endif
424
425 if (status == USBD_CANCELLED)
426 return;
427
428 if (status != USBD_NORMAL_COMPLETION) {
429 DPRINTF(("%s: interrupt status=%d\n", USBDEVNAME(sc->sc_dev),
430 status));
431 usbd_clear_endpoint_stall_async(sc->sc_ipipe);
432 return;
433 }
434
435 p = sc->sc_ibuf;
436 if (sc->sc_nrepid != 1)
437 rep = *p++, cc--;
438 else
439 rep = 0;
440 if (rep >= sc->sc_nrepid) {
441 printf("uhidev_intr: bad repid %d\n", rep);
442 return;
443 }
444 scd = sc->sc_subdevs[rep];
445 DPRINTFN(5,("uhidev_intr: rep=%d, scd=%p state=0x%x\n",
446 rep, scd, scd ? scd->sc_state : 0));
447 if (scd == NULL || !(scd->sc_state & UHIDEV_OPEN))
448 return;
449 if (scd->sc_in_rep_size != cc) {
450 printf("%s: bad input length %d != %d\n",
451 USBDEVNAME(sc->sc_dev), scd->sc_in_rep_size, cc);
452 return;
453 }
454 #if NRND > 0
455 rnd_add_uint32(&scd->rnd_source, (uintptr_t)(sc->sc_ibuf));
456 #endif
457 scd->sc_intr(scd, p, cc);
458 }
459
460 void
461 uhidev_get_report_desc(struct uhidev_softc *sc, void **desc, int *size)
462 {
463 *desc = sc->sc_repdesc;
464 *size = sc->sc_repdesc_size;
465 }
466
467 int
468 uhidev_open(struct uhidev *scd)
469 {
470 struct uhidev_softc *sc = scd->sc_parent;
471 usbd_status err;
472 int error;
473
474 DPRINTF(("uhidev_open: open pipe, state=%d refcnt=%d\n",
475 scd->sc_state, sc->sc_refcnt));
476
477 if (scd->sc_state & UHIDEV_OPEN)
478 return (EBUSY);
479 scd->sc_state |= UHIDEV_OPEN;
480 if (sc->sc_refcnt++)
481 return (0);
482
483 if (sc->sc_isize == 0)
484 return (0);
485
486 sc->sc_ibuf = malloc(sc->sc_isize, M_USBDEV, M_WAITOK);
487
488 /* Set up input interrupt pipe. */
489 DPRINTF(("uhidev_open: isize=%d, ep=0x%02x\n", sc->sc_isize,
490 sc->sc_iep_addr));
491
492 err = usbd_open_pipe_intr(sc->sc_iface, sc->sc_iep_addr,
493 USBD_SHORT_XFER_OK, &sc->sc_ipipe, sc, sc->sc_ibuf,
494 sc->sc_isize, uhidev_intr, USBD_DEFAULT_INTERVAL);
495 if (err != USBD_NORMAL_COMPLETION) {
496 DPRINTF(("uhidopen: usbd_open_pipe_intr failed, "
497 "error=%d\n", err));
498 error = EIO;
499 goto out1;
500 }
501
502 /*
503 * Set up output interrupt pipe if an output interrupt endpoint
504 * exists.
505 */
506 if (sc->sc_oep_addr != -1) {
507 DPRINTF(("uhidev_open: oep=0x%02x\n", sc->sc_oep_addr));
508
509 err = usbd_open_pipe(sc->sc_iface, sc->sc_oep_addr,
510 0, &sc->sc_opipe);
511
512 if (err != USBD_NORMAL_COMPLETION) {
513 DPRINTF(("uhidev_open: usbd_open_pipe failed, "
514 "error=%d\n", err));
515 error = EIO;
516 goto out2;
517 }
518 DPRINTF(("uhidev_open: sc->sc_opipe=%p\n", sc->sc_opipe));
519
520 sc->sc_oxfer = usbd_alloc_xfer(sc->sc_udev);
521 if (sc->sc_oxfer == NULL) {
522 DPRINTF(("uhidev_open: couldn't allocate an xfer\n"));
523 error = ENOMEM;
524 goto out3;
525 }
526 }
527
528 return (0);
529 out3:
530 /* Abort output pipe */
531 usbd_close_pipe(sc->sc_opipe);
532 out2:
533 /* Abort input pipe */
534 usbd_close_pipe(sc->sc_ipipe);
535 out1:
536 DPRINTF(("uhidev_open: failed in someway"));
537 free(sc->sc_ibuf, M_USBDEV);
538 scd->sc_state &= ~UHIDEV_OPEN;
539 sc->sc_refcnt = 0;
540 sc->sc_ipipe = NULL;
541 sc->sc_opipe = NULL;
542 sc->sc_oxfer = NULL;
543 return error;
544 }
545
546 void
547 uhidev_close(struct uhidev *scd)
548 {
549 struct uhidev_softc *sc = scd->sc_parent;
550
551 if (!(scd->sc_state & UHIDEV_OPEN))
552 return;
553 scd->sc_state &= ~UHIDEV_OPEN;
554 if (--sc->sc_refcnt)
555 return;
556 DPRINTF(("uhidev_close: close pipe\n"));
557
558 if (sc->sc_oxfer != NULL)
559 usbd_free_xfer(sc->sc_oxfer);
560
561 /* Disable interrupts. */
562 if (sc->sc_opipe != NULL) {
563 usbd_abort_pipe(sc->sc_opipe);
564 usbd_close_pipe(sc->sc_opipe);
565 sc->sc_opipe = NULL;
566 }
567
568 if (sc->sc_ipipe != NULL) {
569 usbd_abort_pipe(sc->sc_ipipe);
570 usbd_close_pipe(sc->sc_ipipe);
571 sc->sc_ipipe = NULL;
572 }
573
574 if (sc->sc_ibuf != NULL) {
575 free(sc->sc_ibuf, M_USBDEV);
576 sc->sc_ibuf = NULL;
577 }
578 }
579
580 usbd_status
581 uhidev_set_report(struct uhidev *scd, int type, void *data, int len)
582 {
583 char *buf;
584 usbd_status retstat;
585
586 if (scd->sc_report_id == 0)
587 return usbd_set_report(scd->sc_parent->sc_iface, type,
588 scd->sc_report_id, data, len);
589
590 buf = malloc(len + 1, M_TEMP, M_WAITOK);
591 buf[0] = scd->sc_report_id;
592 memcpy(buf+1, data, len);
593
594 retstat = usbd_set_report(scd->sc_parent->sc_iface, type,
595 scd->sc_report_id, buf, len + 1);
596
597 free(buf, M_TEMP);
598
599 return retstat;
600 }
601
602 void
603 uhidev_set_report_async(struct uhidev *scd, int type, void *data, int len)
604 {
605 /* XXX */
606 char buf[100];
607 if (scd->sc_report_id) {
608 buf[0] = scd->sc_report_id;
609 memcpy(buf+1, data, len);
610 len++;
611 data = buf;
612 }
613
614 usbd_set_report_async(scd->sc_parent->sc_iface, type,
615 scd->sc_report_id, data, len);
616 }
617
618 usbd_status
619 uhidev_get_report(struct uhidev *scd, int type, void *data, int len)
620 {
621 return usbd_get_report(scd->sc_parent->sc_iface, type,
622 scd->sc_report_id, data, len);
623 }
624
625 usbd_status
626 uhidev_write(struct uhidev_softc *sc, void *data, int len)
627 {
628
629 DPRINTF(("uhidev_write: data=%p, len=%d\n", data, len));
630
631 if (sc->sc_opipe == NULL)
632 return USBD_INVAL;
633
634 #ifdef UHIDEV_DEBUG
635 if (uhidevdebug > 50) {
636
637 u_int32_t i;
638 u_int8_t *d = data;
639
640 DPRINTF(("uhidev_write: data ="));
641 for (i = 0; i < len; i++)
642 DPRINTF((" %02x", d[i]));
643 DPRINTF(("\n"));
644 }
645 #endif
646 return usbd_intr_transfer(sc->sc_oxfer, sc->sc_opipe, 0,
647 USBD_NO_TIMEOUT, data, &len, "uhidevwi");
648 }
649