summaryrefslogtreecommitdiff
path: root/sys/dev/usb/uvisor.c
diff options
context:
space:
mode:
authorNathan Binkert <nate@cvs.openbsd.org>2002-05-07 18:08:06 +0000
committerNathan Binkert <nate@cvs.openbsd.org>2002-05-07 18:08:06 +0000
commit98e3a0a3b6a5b0271467c9f199a555d22161f072 (patch)
tree04221a5a893956a1fe82881463802b2e507063b3 /sys/dev/usb/uvisor.c
parent3a7a8acd4f0393073cd00591e53b1b8a4eb1bd60 (diff)
Sync ulpt driver with NetBSD
Diffstat (limited to 'sys/dev/usb/uvisor.c')
-rw-r--r--sys/dev/usb/uvisor.c62
1 files changed, 52 insertions, 10 deletions
diff --git a/sys/dev/usb/uvisor.c b/sys/dev/usb/uvisor.c
index a0a45c54ddd..e44687355f9 100644
--- a/sys/dev/usb/uvisor.c
+++ b/sys/dev/usb/uvisor.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvisor.c,v 1.3 2001/05/03 02:20:35 aaron Exp $ */
-/* $NetBSD: uvisor.c,v 1.11 2001/01/23 21:56:17 augustss Exp $ */
+/* $OpenBSD: uvisor.c,v 1.4 2002/05/07 18:08:05 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);
}