]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/usb/uvisor.c
Start each of the license/copyright comments with /*-, minor shuffle of lines
[FreeBSD/FreeBSD.git] / sys / dev / usb / uvisor.c
1 /*      $NetBSD: uvisor.c,v 1.9 2001/01/23 14:04:14 augustss Exp $      */
2 /*      $FreeBSD$       */
3
4 /* Also already merged from NetBSD:
5  *      $NetBSD: uvisor.c,v 1.12 2001/11/13 06:24:57 lukem Exp $
6  *      $NetBSD: uvisor.c,v 1.13 2002/02/11 15:11:49 augustss Exp $
7  *      $NetBSD: uvisor.c,v 1.14 2002/02/27 23:00:03 augustss Exp $
8  *      $NetBSD: uvisor.c,v 1.15 2002/06/16 15:01:31 augustss Exp $
9  *      $NetBSD: uvisor.c,v 1.16 2002/07/11 21:14:36 augustss Exp $
10  *      $NetBSD: uvisor.c,v 1.17 2002/08/13 11:38:15 augustss Exp $
11  *      $NetBSD: uvisor.c,v 1.18 2003/02/05 00:50:14 augustss Exp $
12  *      $NetBSD: uvisor.c,v 1.19 2003/02/07 18:12:37 augustss Exp $
13  *      $NetBSD: uvisor.c,v 1.20 2003/04/11 01:30:10 simonb Exp $
14  */
15
16
17 /*-
18  * Copyright (c) 2000 The NetBSD Foundation, Inc.
19  * All rights reserved.
20  *
21  * This code is derived from software contributed to The NetBSD Foundation
22  * by Lennart Augustsson (lennart@augustsson.net) at
23  * Carlstedt Research & Technology.
24  *
25  * Redistribution and use in source and binary forms, with or without
26  * modification, are permitted provided that the following conditions
27  * are met:
28  * 1. Redistributions of source code must retain the above copyright
29  *    notice, this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright
31  *    notice, this list of conditions and the following disclaimer in the
32  *    documentation and/or other materials provided with the distribution.
33  * 3. All advertising materials mentioning features or use of this software
34  *    must display the following acknowledgement:
35  *        This product includes software developed by the NetBSD
36  *        Foundation, Inc. and its contributors.
37  * 4. Neither the name of The NetBSD Foundation nor the names of its
38  *    contributors may be used to endorse or promote products derived
39  *    from this software without specific prior written permission.
40  *
41  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
42  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
43  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
45  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
46  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
47  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
48  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
49  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
51  * POSSIBILITY OF SUCH DAMAGE.
52  */
53
54 /*
55  * Handspring Visor (Palmpilot compatible PDA) driver
56  */
57
58 #include <sys/param.h>
59 #include <sys/systm.h>
60 #include <sys/kernel.h>
61 #if defined(__NetBSD__) || defined(__OpenBSD__)
62 #include <sys/device.h>
63 #elif defined(__FreeBSD__)
64 #include <sys/module.h>
65 #include <sys/bus.h>
66 #endif
67 #include <sys/conf.h>
68 #include <sys/tty.h>
69 #include <sys/sysctl.h>
70
71 #include <dev/usb/usb.h>
72 #include <dev/usb/usbhid.h>
73
74 #include <dev/usb/usbdi.h>
75 #include <dev/usb/usbdi_util.h>
76 #include "usbdevs.h"
77
78 #include <dev/usb/ucomvar.h>
79
80 #ifdef USB_DEBUG
81 #define DPRINTF(x)      if (uvisordebug) printf x
82 #define DPRINTFN(n,x)   if (uvisordebug>(n)) printf x
83 int uvisordebug = 0;
84 SYSCTL_NODE(_hw_usb, OID_AUTO, uvisor, CTLFLAG_RW, 0, "USB uvisor");
85 SYSCTL_INT(_hw_usb_uvisor, OID_AUTO, debug, CTLFLAG_RW,
86            &uvisordebug, 0, "uvisor debug level");
87 #else
88 #define DPRINTF(x)
89 #define DPRINTFN(n,x)
90 #endif
91
92 #define UVISOR_CONFIG_INDEX     0
93 #define UVISOR_IFACE_INDEX      0
94 #define UVISOR_MODVER           1
95
96 /* From the Linux driver */
97 /*
98  * UVISOR_REQUEST_BYTES_AVAILABLE asks the visor for the number of bytes that
99  * are available to be transfered to the host for the specified endpoint.
100  * Currently this is not used, and always returns 0x0001
101  */
102 #define UVISOR_REQUEST_BYTES_AVAILABLE          0x01
103
104 /*
105  * UVISOR_CLOSE_NOTIFICATION is set to the device to notify it that the host
106  * is now closing the pipe. An empty packet is sent in response.
107  */
108 #define UVISOR_CLOSE_NOTIFICATION               0x02
109
110 /*
111  * UVISOR_GET_CONNECTION_INFORMATION is sent by the host during enumeration to
112  * get the endpoints used by the connection.
113  */
114 #define UVISOR_GET_CONNECTION_INFORMATION       0x03
115
116
117 /*
118  * UVISOR_GET_CONNECTION_INFORMATION returns data in the following format
119  */
120 #define UVISOR_MAX_CONN 8
121 struct uvisor_connection_info {
122         uWord   num_ports;
123         struct {
124                 uByte   port_function_id;
125                 uByte   port;
126         } connections[UVISOR_MAX_CONN];
127 };
128 #define UVISOR_CONNECTION_INFO_SIZE 18
129
130 /* struct uvisor_connection_info.connection[x].port defines: */
131 #define UVISOR_ENDPOINT_1               0x01
132 #define UVISOR_ENDPOINT_2               0x02
133
134 /* struct uvisor_connection_info.connection[x].port_function_id defines: */
135 #define UVISOR_FUNCTION_GENERIC         0x00
136 #define UVISOR_FUNCTION_DEBUGGER        0x01
137 #define UVISOR_FUNCTION_HOTSYNC         0x02
138 #define UVISOR_FUNCTION_CONSOLE         0x03
139 #define UVISOR_FUNCTION_REMOTE_FILE_SYS 0x04
140
141 /*
142  * Unknown PalmOS stuff.
143  */
144 #define UVISOR_GET_PALM_INFORMATION             0x04
145 #define UVISOR_GET_PALM_INFORMATION_LEN         0x14
146
147
148 /*
149  * Crank down UVISORBUFSIZE from 1024 to 64 to avoid a problem where
150  * the Palm device and the USB host controller deadlock. The USB host
151  * controller is expecting an early-end-of-transmission packet with 0
152  * data, and the Palm doesn't send one because it's already
153  * communicated the amount of data it's going to send in a header
154  * (which ucom/uvisor are oblivious to). This is the problem that has
155  * been known on the pilot-link lists as the "[Free]BSD USB problem",
156  * but not understood.
157  */
158 #define UVISORIBUFSIZE 64
159 #define UVISOROBUFSIZE 1024
160
161 struct uvisor_softc {
162         struct ucom_softc       sc_ucom;
163         u_int16_t               sc_flags;
164 };
165
166 Static usbd_status uvisor_init(struct uvisor_softc *);
167
168 Static usbd_status clie_3_5_init(struct uvisor_softc *);
169
170 Static void uvisor_close(void *, int);
171
172 struct ucom_callback uvisor_callback = {
173         NULL,
174         NULL,
175         NULL,
176         NULL,
177         NULL,
178         uvisor_close,
179         NULL,
180         NULL,
181 };
182
183 Static device_probe_t uvisor_match;
184 Static device_attach_t uvisor_attach;
185 Static device_detach_t uvisor_detach;
186 Static device_method_t uvisor_methods[] = {
187        /* Device interface */
188        DEVMETHOD(device_probe, uvisor_match),
189        DEVMETHOD(device_attach, uvisor_attach),
190        DEVMETHOD(device_detach, uvisor_detach),
191        { 0, 0 }
192  };
193
194
195 Static driver_t uvisor_driver = {
196        "ucom",
197        uvisor_methods,
198        sizeof (struct uvisor_softc)
199 };
200
201 DRIVER_MODULE(uvisor, uhub, uvisor_driver, ucom_devclass, usbd_driver_load, 0);
202 MODULE_DEPEND(uvisor, usb, 1, 1, 1);
203 MODULE_DEPEND(uvisor, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER);
204 MODULE_VERSION(uvisor, UVISOR_MODVER);
205
206 struct uvisor_type {
207         struct usb_devno        uv_dev;
208         u_int16_t               uv_flags;
209 #define PALM4   0x0001
210 };
211 static const struct uvisor_type uvisor_devs[] = {
212         {{ USB_VENDOR_HANDSPRING, USB_PRODUCT_HANDSPRING_VISOR }, 0 },
213         {{ USB_VENDOR_HANDSPRING, USB_PRODUCT_HANDSPRING_TREO }, PALM4 },
214         {{ USB_VENDOR_HANDSPRING, USB_PRODUCT_HANDSPRING_TREO600 }, PALM4 },
215         {{ USB_VENDOR_PALM, USB_PRODUCT_PALM_M500 }, PALM4 },
216         {{ USB_VENDOR_PALM, USB_PRODUCT_PALM_M505 }, PALM4 },
217         {{ USB_VENDOR_PALM, USB_PRODUCT_PALM_M515 }, PALM4 },
218         {{ USB_VENDOR_PALM, USB_PRODUCT_PALM_I705 }, PALM4 },
219         {{ USB_VENDOR_PALM, USB_PRODUCT_PALM_M125 }, PALM4 },
220         {{ USB_VENDOR_PALM, USB_PRODUCT_PALM_M130 }, PALM4 },
221         {{ USB_VENDOR_PALM, USB_PRODUCT_PALM_TUNGSTEN_Z }, PALM4 },
222         {{ USB_VENDOR_PALM, USB_PRODUCT_PALM_TUNGSTEN_T }, PALM4 },
223         {{ USB_VENDOR_PALM, USB_PRODUCT_PALM_ZIRE }, PALM4 },
224         {{ USB_VENDOR_PALM, USB_PRODUCT_PALM_ZIRE31 }, PALM4 },
225         {{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_40 }, 0 },
226         {{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_41 }, PALM4 },
227         {{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_S360 }, PALM4 },
228         {{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_NX60 }, PALM4 },
229         {{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_35 }, 0 },
230 /*      {{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_25 }, PALM4 },*/
231 };
232 #define uvisor_lookup(v, p) ((const struct uvisor_type *)usb_lookup(uvisor_devs, v, p))
233
234
235 USB_MATCH(uvisor)
236 {
237         USB_MATCH_START(uvisor, uaa);
238
239         if (uaa->iface != NULL)
240                 return (UMATCH_NONE);
241
242         DPRINTFN(20,("uvisor: vendor=0x%x, product=0x%x\n",
243                      uaa->vendor, uaa->product));
244
245         return (uvisor_lookup(uaa->vendor, uaa->product) != NULL ?
246                 UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
247 }
248
249 USB_ATTACH(uvisor)
250 {
251         USB_ATTACH_START(uvisor, sc, uaa);
252         usbd_device_handle dev = uaa->device;
253         usbd_interface_handle iface;
254         usb_interface_descriptor_t *id;
255         usb_endpoint_descriptor_t *ed;
256         char *devinfo;
257         const char *devname;
258         int i;
259         usbd_status err;
260         struct ucom_softc *ucom;
261
262         devinfo = malloc(1024, M_USBDEV, M_WAITOK);
263         ucom = &sc->sc_ucom;
264
265         bzero(sc, sizeof (struct uvisor_softc));
266         usbd_devinfo(dev, 0, devinfo);
267
268         ucom->sc_dev = self;
269         device_set_desc_copy(self, devinfo);
270
271         ucom->sc_udev = dev;
272         ucom->sc_iface = uaa->iface;
273
274         devname = USBDEVNAME(ucom->sc_dev);
275         printf("%s: %s\n", devname, devinfo);
276
277         DPRINTFN(10,("\nuvisor_attach: sc=%p\n", sc));
278
279         /* Move the device into the configured state. */
280         err = usbd_set_config_index(dev, UVISOR_CONFIG_INDEX, 1);
281         if (err) {
282                 printf("\n%s: failed to set configuration, err=%s\n",
283                        devname, usbd_errstr(err));
284                 goto bad;
285         }
286
287         err = usbd_device2interface_handle(dev, UVISOR_IFACE_INDEX, &iface);
288         if (err) {
289                 printf("\n%s: failed to get interface, err=%s\n",
290                        devname, usbd_errstr(err));
291                 goto bad;
292         }
293
294         printf("%s: %s\n", devname, devinfo);
295
296         sc->sc_flags = uvisor_lookup(uaa->vendor, uaa->product)->uv_flags;
297
298         id = usbd_get_interface_descriptor(iface);
299
300         ucom->sc_udev = dev;
301         ucom->sc_iface = iface;
302
303         ucom->sc_bulkin_no = ucom->sc_bulkout_no = -1;
304         for (i = 0; i < id->bNumEndpoints; i++) {
305                 int addr, dir, attr;
306                 ed = usbd_interface2endpoint_descriptor(iface, i);
307                 if (ed == NULL) {
308                         printf("%s: could not read endpoint descriptor"
309                                ": %s\n", devname, usbd_errstr(err));
310                         goto bad;
311                 }
312
313                 addr = ed->bEndpointAddress;
314                 dir = UE_GET_DIR(ed->bEndpointAddress);
315                 attr = ed->bmAttributes & UE_XFERTYPE;
316                 if (dir == UE_DIR_IN && attr == UE_BULK)
317                         ucom->sc_bulkin_no = addr;
318                 else if (dir == UE_DIR_OUT && attr == UE_BULK)
319                         ucom->sc_bulkout_no = addr;
320                 else {
321                         printf("%s: unexpected endpoint\n", devname);
322                         goto bad;
323                 }
324         }
325         if (ucom->sc_bulkin_no == -1) {
326                 printf("%s: Could not find data bulk in\n",
327                        USBDEVNAME(ucom->sc_dev));
328                 goto bad;
329         }
330         if (ucom->sc_bulkout_no == -1) {
331                 printf("%s: Could not find data bulk out\n",
332                        USBDEVNAME(ucom->sc_dev));
333                 goto bad;
334         }
335
336         ucom->sc_parent = sc;
337         ucom->sc_portno = UCOM_UNK_PORTNO;
338         /* bulkin, bulkout set above */
339         ucom->sc_ibufsize = UVISORIBUFSIZE;
340         ucom->sc_obufsize = UVISOROBUFSIZE;
341         ucom->sc_ibufsizepad = UVISORIBUFSIZE;
342         ucom->sc_opkthdrlen = 0;
343         ucom->sc_callback = &uvisor_callback;
344
345         if (uaa->vendor == USB_VENDOR_SONY &&
346             uaa->product == USB_PRODUCT_SONY_CLIE_35)
347                 err = clie_3_5_init(sc);
348         else
349                 err = uvisor_init(sc);
350
351         if (err) {
352                 printf("%s: init failed, %s\n", USBDEVNAME(ucom->sc_dev),
353                        usbd_errstr(err));
354                 goto bad;
355         }
356
357         usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, ucom->sc_udev,
358                            USBDEV(ucom->sc_dev));
359
360         DPRINTF(("uvisor: in=0x%x out=0x%x\n", ucom->sc_bulkin_no, ucom->sc_bulkout_no));
361         ucom_attach(&sc->sc_ucom);
362
363         USB_ATTACH_SUCCESS_RETURN;
364
365 bad:
366         DPRINTF(("uvisor_attach: ATTACH ERROR\n"));
367         ucom->sc_dying = 1;
368         USB_ATTACH_ERROR_RETURN;
369 }
370
371 #if 0
372
373 int
374 uvisor_activate(device_ptr_t self, enum devact act)
375 {
376         struct uvisor_softc *sc = (struct uvisor_softc *)self;
377         int rv = 0;
378
379         switch (act) {
380         case DVACT_ACTIVATE:
381                 return (EOPNOTSUPP);
382                 break;
383
384         case DVACT_DEACTIVATE:
385                 if (sc->sc_subdev != NULL)
386                         rv = config_deactivate(sc->sc_subdev);
387                 sc->sc_dying = 1;
388                 break;
389         }
390         return (rv);
391 }
392
393 #endif
394
395 USB_DETACH(uvisor)
396 {
397         USB_DETACH_START(uvisor, sc);
398         int rv = 0;
399
400         DPRINTF(("uvisor_detach: sc=%p\n", sc));
401         sc->sc_ucom.sc_dying = 1;
402         rv = ucom_detach(&sc->sc_ucom);
403
404         usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_ucom.sc_udev,
405                            USBDEV(sc->sc_ucom.sc_dev));
406
407         return (rv);
408 }
409
410 usbd_status
411 uvisor_init(struct uvisor_softc *sc)
412 {
413         usbd_status err;
414         usb_device_request_t req;
415         struct uvisor_connection_info coninfo;
416         int actlen;
417         uWord avail;
418         char buffer[256];
419
420         DPRINTF(("uvisor_init: getting connection info\n"));
421         req.bmRequestType = UT_READ_VENDOR_ENDPOINT;
422         req.bRequest = UVISOR_GET_CONNECTION_INFORMATION;
423         USETW(req.wValue, 0);
424         USETW(req.wIndex, 0);
425         USETW(req.wLength, UVISOR_CONNECTION_INFO_SIZE);
426         err = usbd_do_request_flags(sc->sc_ucom.sc_udev, &req, &coninfo,
427                                     USBD_SHORT_XFER_OK, &actlen,
428                                     USBD_DEFAULT_TIMEOUT);
429         if (err)
430                 return (err);
431
432 #ifdef USB_DEBUG
433         {
434                 int i, np;
435                 char *string;
436
437                 np = UGETW(coninfo.num_ports);
438                 printf("%s: Number of ports: %d\n", USBDEVNAME(sc->sc_ucom.sc_dev), np);
439                 for (i = 0; i < np; ++i) {
440                         switch (coninfo.connections[i].port_function_id) {
441                         case UVISOR_FUNCTION_GENERIC:
442                                 string = "Generic";
443                                 break;
444                         case UVISOR_FUNCTION_DEBUGGER:
445                                 string = "Debugger";
446                                 break;
447                         case UVISOR_FUNCTION_HOTSYNC:
448                                 string = "HotSync";
449                                 break;
450                         case UVISOR_FUNCTION_REMOTE_FILE_SYS:
451                                 string = "Remote File System";
452                                 break;
453                         default:
454                                 string = "unknown";
455                                 break;
456                         }
457                         printf("%s: port %d, is for %s\n",
458                             USBDEVNAME(sc->sc_ucom.sc_dev), coninfo.connections[i].port,
459                             string);
460                 }
461         }
462 #endif
463
464         if (sc->sc_flags & PALM4) {
465                 /* Palm OS 4.0 Hack */
466                 req.bmRequestType = UT_READ_VENDOR_ENDPOINT;
467                 req.bRequest = UVISOR_GET_PALM_INFORMATION;
468                 USETW(req.wValue, 0);
469                 USETW(req.wIndex, 0);
470                 USETW(req.wLength, UVISOR_GET_PALM_INFORMATION_LEN);
471                 err = usbd_do_request(sc->sc_ucom.sc_udev, &req, buffer);
472                 if (err)
473                         return (err);
474                 req.bmRequestType = UT_READ_VENDOR_ENDPOINT;
475                 req.bRequest = UVISOR_GET_PALM_INFORMATION;
476                 USETW(req.wValue, 0);
477                 USETW(req.wIndex, 0);
478                 USETW(req.wLength, UVISOR_GET_PALM_INFORMATION_LEN);
479                 err = usbd_do_request(sc->sc_ucom.sc_udev, &req, buffer);
480                 if (err)
481                         return (err);
482         }
483
484         DPRINTF(("uvisor_init: getting available bytes\n"));
485         req.bmRequestType = UT_READ_VENDOR_ENDPOINT;
486         req.bRequest = UVISOR_REQUEST_BYTES_AVAILABLE;
487         USETW(req.wValue, 0);
488         USETW(req.wIndex, 5);
489         USETW(req.wLength, sizeof avail);
490         err = usbd_do_request(sc->sc_ucom.sc_udev, &req, &avail);
491         if (err)
492                 return (err);
493         DPRINTF(("uvisor_init: avail=%d\n", UGETW(avail)));
494
495         DPRINTF(("uvisor_init: done\n"));
496         return (err);
497 }
498
499 usbd_status
500 clie_3_5_init(struct uvisor_softc *sc)
501 {
502         usbd_status err;
503         usb_device_request_t req;
504         char buffer[256];
505
506         /*
507          * Note that PEG-300 series devices expect the following two calls.
508          */
509
510         /* get the config number */
511         DPRINTF(("clie_3_5_init: getting config info\n"));
512         req.bmRequestType = UT_READ;
513         req.bRequest = UR_GET_CONFIG;
514         USETW(req.wValue, 0);
515         USETW(req.wIndex, 0);
516         USETW(req.wLength, 1);
517         err = usbd_do_request(sc->sc_ucom.sc_udev, &req, buffer);
518         if (err)
519                 return (err);
520
521         /* get the interface number */
522         DPRINTF(("clie_3_5_init: get the interface number\n"));
523         req.bmRequestType = UT_READ_DEVICE;
524         req.bRequest = UR_GET_INTERFACE;
525         USETW(req.wValue, 0);
526         USETW(req.wIndex, 0);
527         USETW(req.wLength, 1);
528         err = usbd_do_request(sc->sc_ucom.sc_udev, &req, buffer);
529         if (err)
530                 return (err);
531
532 #ifdef USB_DEBUG
533         {
534                 struct uvisor_connection_info coninfo;
535                 int i, np;
536                 char *string;
537
538                 np = UGETW(coninfo.num_ports);
539                 DPRINTF(("%s: Number of ports: %d\n", USBDEVNAME(sc->sc_ucom.sc_dev), np));
540                 for (i = 0; i < np; ++i) {
541                         switch (coninfo.connections[i].port_function_id) {
542                         case UVISOR_FUNCTION_GENERIC:
543                                 string = "Generic";
544                                 break;
545                         case UVISOR_FUNCTION_DEBUGGER:
546                                 string = "Debugger";
547                                 break;
548                         case UVISOR_FUNCTION_HOTSYNC:
549                                 string = "HotSync";
550                                 break;
551                         case UVISOR_FUNCTION_REMOTE_FILE_SYS:
552                                 string = "Remote File System";
553                                 break;
554                         default:
555                                 string = "unknown";
556                                 break;  
557                         }
558                         DPRINTF(("%s: port %d, is for %s\n",
559                             USBDEVNAME(sc->sc_ucom.sc_dev), coninfo.connections[i].port,
560                             string));
561                 }
562         }
563 #endif
564
565         DPRINTF(("clie_3_5_init: done\n"));
566         return (err);
567 }
568
569 void
570 uvisor_close(void *addr, int portno)
571 {
572         struct uvisor_softc *sc = addr;
573         usb_device_request_t req;
574         struct uvisor_connection_info coninfo; /* XXX ? */
575         int actlen;
576
577         if (sc->sc_ucom.sc_dying)
578                 return;
579
580         req.bmRequestType = UT_READ_VENDOR_ENDPOINT; /* XXX read? */
581         req.bRequest = UVISOR_CLOSE_NOTIFICATION;
582         USETW(req.wValue, 0);
583         USETW(req.wIndex, 0);
584         USETW(req.wLength, UVISOR_CONNECTION_INFO_SIZE);
585         (void)usbd_do_request_flags(sc->sc_ucom.sc_udev, &req, &coninfo,
586                                     USBD_SHORT_XFER_OK, &actlen,
587                                     USBD_DEFAULT_TIMEOUT);
588 }