diff options
author | Nathan Binkert <nate@cvs.openbsd.org> | 2002-05-07 20:00:39 +0000 |
---|---|---|
committer | Nathan Binkert <nate@cvs.openbsd.org> | 2002-05-07 20:00:39 +0000 |
commit | e9e9b137eb263a894d27d51ee053665a919d17d7 (patch) | |
tree | 24e296f9fcfdd6ff3ae9b8c6981c770b678a3afd /sys/dev/usb | |
parent | 4c0479acdd176235604eaab005e915e7c22b0b63 (diff) |
Sync uvisor driver with NetBSD. This adds support for PALM4 devices
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/uvisor.c | 62 |
1 files changed, 52 insertions, 10 deletions
diff --git a/sys/dev/usb/uvisor.c b/sys/dev/usb/uvisor.c index 53096b1d515..6f6cb076447 100644 --- a/sys/dev/usb/uvisor.c +++ b/sys/dev/usb/uvisor.c @@ -1,5 +1,5 @@ -/* $OpenBSD: uvisor.c,v 1.5 2002/05/07 18:29:19 nate Exp $ */ -/* $NetBSD: uvisor.c,v 1.11 2001/01/23 21:56:17 augustss Exp $ */ +/* $OpenBSD: uvisor.c,v 1.6 2002/05/07 20:00:38 nate Exp $ */ +/* $NetBSD: uvisor.c,v 1.14 2002/02/27 23:00:03 augustss Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -104,7 +104,6 @@ struct uvisor_connection_info { }; #define UVISOR_CONNECTION_INFO_SIZE 18 - /* struct uvisor_connection_info.connection[x].port_function_id defines: */ #define UVISOR_FUNCTION_GENERIC 0x00 #define UVISOR_FUNCTION_DEBUGGER 0x01 @@ -112,6 +111,12 @@ struct uvisor_connection_info { #define UVISOR_FUNCTION_CONSOLE 0x03 #define UVISOR_FUNCTION_REMOTE_FILE_SYS 0x04 +/* + * Unknown PalmOS stuff. + */ +#define UVISOR_GET_PALM_INFORMATION 0x04 +#define UVISOR_GET_PALM_INFORMATION_LEN 0x14 + #define UVISORIBUFSIZE 1024 #define UVISOROBUFSIZE 1024 @@ -124,6 +129,8 @@ struct uvisor_softc { device_ptr_t sc_subdevs[UVISOR_MAX_CONN]; int sc_numcon; + u_int16_t sc_flags; + u_char sc_dying; }; @@ -144,6 +151,21 @@ struct ucom_methods uvisor_methods = { NULL, }; +struct uvisor_type { + struct usb_devno uv_dev; + u_int16_t uv_flags; +#define PALM4 0x0001 +}; +static const struct uvisor_type uvisor_devs[] = { + {{ USB_VENDOR_HANDSPRING, USB_PRODUCT_HANDSPRING_VISOR }, 0 }, + {{ USB_VENDOR_PALM, USB_PRODUCT_PALM_M500 }, PALM4 }, + {{ USB_VENDOR_PALM, USB_PRODUCT_PALM_M505 }, PALM4 }, + {{ USB_VENDOR_PALM, USB_PRODUCT_PALM_M125 }, PALM4 }, + {{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_40 }, PALM4 }, +/* {{ USB_VENDOR_SONY, USB_PRODUCT_SONY_CLIE_25 }, PALM4 },*/ +}; +#define uvisor_lookup(v, p) ((struct uvisor_type *)usb_lookup(uvisor_devs, v, p)) + USB_DECLARE_DRIVER(uvisor); USB_MATCH(uvisor) @@ -156,11 +178,8 @@ USB_MATCH(uvisor) DPRINTFN(20,("uvisor: vendor=0x%x, product=0x%x\n", uaa->vendor, uaa->product)); - if (uaa->vendor == USB_VENDOR_HANDSPRING && - uaa->product == USB_PRODUCT_HANDSPRING_VISOR) - return (UMATCH_VENDOR_PRODUCT); - - return (UMATCH_NONE); + return (uvisor_lookup(uaa->vendor, uaa->product) != NULL ? + UMATCH_VENDOR_PRODUCT : UMATCH_NONE); } USB_ATTACH(uvisor) @@ -198,6 +217,8 @@ USB_ATTACH(uvisor) USB_ATTACH_SETUP; printf("%s: %s\n", devname, devinfo); + sc->sc_flags = uvisor_lookup(uaa->vendor, uaa->product)->uv_flags; + id = usbd_get_interface_descriptor(iface); sc->sc_udev = dev; @@ -330,6 +351,7 @@ uvisor_init(struct uvisor_softc *sc, struct uvisor_connection_info *ci) usb_device_request_t req; int actlen; uWord avail; + char buffer[256]; DPRINTF(("uvisor_init: getting connection info\n")); req.bmRequestType = UT_READ_VENDOR_ENDPOINT; @@ -338,10 +360,30 @@ uvisor_init(struct uvisor_softc *sc, struct uvisor_connection_info *ci) USETW(req.wIndex, 0); USETW(req.wLength, UVISOR_CONNECTION_INFO_SIZE); err = usbd_do_request_flags(sc->sc_udev, &req, ci, - USBD_SHORT_XFER_OK, &actlen); + USBD_SHORT_XFER_OK, &actlen, USBD_DEFAULT_TIMEOUT); if (err) return (err); + if (sc->sc_flags & PALM4) { + /* Palm OS 4.0 Hack */ + req.bmRequestType = UT_READ_VENDOR_ENDPOINT; + req.bRequest = UVISOR_GET_PALM_INFORMATION; + USETW(req.wValue, 0); + USETW(req.wIndex, 0); + USETW(req.wLength, UVISOR_GET_PALM_INFORMATION_LEN); + err = usbd_do_request(sc->sc_udev, &req, buffer); + if (err) + return (err); + req.bmRequestType = UT_READ_VENDOR_ENDPOINT; + req.bRequest = UVISOR_GET_PALM_INFORMATION; + USETW(req.wValue, 0); + USETW(req.wIndex, 0); + USETW(req.wLength, UVISOR_GET_PALM_INFORMATION_LEN); + err = usbd_do_request(sc->sc_udev, &req, buffer); + if (err) + return (err); + } + DPRINTF(("uvisor_init: getting available bytes\n")); req.bmRequestType = UT_READ_VENDOR_ENDPOINT; req.bRequest = UVISOR_REQUEST_BYTES_AVAILABLE; @@ -374,5 +416,5 @@ uvisor_close(void *addr, int portno) USETW(req.wIndex, 0); USETW(req.wLength, UVISOR_CONNECTION_INFO_SIZE); (void)usbd_do_request_flags(sc->sc_udev, &req, &coninfo, - USBD_SHORT_XFER_OK, &actlen); + USBD_SHORT_XFER_OK, &actlen, USBD_DEFAULT_TIMEOUT); } |