diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-02-11 02:36:01 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-02-11 02:36:01 +0000 |
commit | fb469693dc16682c912f157cfc4ccc8870d226f4 (patch) | |
tree | 33cb0515625eeac844fd800af5ae78640c56b124 | |
parent | a2edaab1b166b17bdaa06a95a1bcbecd5df5828a (diff) | |
download | nuttx-fb469693dc16682c912f157cfc4ccc8870d226f4.tar.gz nuttx-fb469693dc16682c912f157cfc4ccc8870d226f4.tar.bz2 nuttx-fb469693dc16682c912f157cfc4ccc8870d226f4.zip |
Add logic to get the VID and PID
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3282 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r-- | nuttx/ChangeLog | 2 | ||||
-rw-r--r-- | nuttx/Documentation/NuttX.html | 2 | ||||
-rwxr-xr-x | nuttx/drivers/usbhost/usbhost_enumerate.c | 79 |
3 files changed, 40 insertions, 43 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 011bff6d8..ac179ffd2 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -1450,3 +1450,5 @@ the -o option is not standard and is not supported under, for example, OS-X or Solaris. This was solved by changing all 'uname -o' references to the more complex: 'uname -o 2>/dev/null || echo "Other"' + * drivers/usbhost/usbhost_enumerate.c -- Add logic to get the VID and PID. This + is necessary in order to support vendor-specific USB devices. diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index fdaa8e957..537e00e70 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -2027,6 +2027,8 @@ nuttx-5.18 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> the -o option is not standard and is not supported under, for example, OS-X or Solaris. This was solved by changing all 'uname -o' references to the more complex: 'uname -o 2>/dev/null || echo "Other"' + * drivers/usbhost/usbhost_enumerate.c -- Add logic to get the VID and PID. This + is necessary in order to support vendor-specific USB devices. pascal-2.1 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> diff --git a/nuttx/drivers/usbhost/usbhost_enumerate.c b/nuttx/drivers/usbhost/usbhost_enumerate.c index 6c56ffc5a..82c65c8bf 100755 --- a/nuttx/drivers/usbhost/usbhost_enumerate.c +++ b/nuttx/drivers/usbhost/usbhost_enumerate.c @@ -1,7 +1,7 @@ /******************************************************************************* * drivers/usbhost/usbhost_enumerate.c * - * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2011 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -65,7 +65,7 @@ static inline uint16_t usbhost_getle16(const uint8_t *val); static void usbhost_putle16(uint8_t *dest, uint16_t val); -static inline int usbhost_devdesc(const struct usb_devdesc_s *devdesc, int desclen, +static inline int usbhost_devdesc(const struct usb_devdesc_s *devdesc, struct usbhost_id_s *id); static inline int usbhost_configdesc(const uint8_t *configdesc, int desclen, struct usbhost_id_s *id); @@ -123,36 +123,24 @@ static void usbhost_putle16(uint8_t *dest, uint16_t val) *******************************************************************************/ static inline int usbhost_devdesc(const struct usb_devdesc_s *devdesc, - int desclen, struct usbhost_id_s *id) + struct usbhost_id_s *id) { /* Clear the ID info */ memset(id, 0, sizeof(struct usbhost_id_s)); - /* Check we have enough of the structure to see the ID info. */ - - if (desclen >= 7) - { - /* Pick off the ID info */ - - id->base = devdesc->class; - id->subclass = devdesc->subclass; - id->proto = devdesc->protocol; - uvdbg("class:%d subclass:%d protocol:%d\n", - id->base, id->subclass, id->proto); - - /* Check if we have enough of the structure to see the VID/PID */ + /* Pick off the ID info */ - if (desclen >= 12) - { - /* Yes, then pick off the VID and PID as well */ + id->base = devdesc->class; + id->subclass = devdesc->subclass; + id->proto = devdesc->protocol; + uvdbg("class:%d subclass:%d protocol:%d\n", id->base, id->subclass, id->proto); - id->vid = usbhost_getle16(devdesc->vendor); - id->pid = usbhost_getle16(devdesc->product); - uvdbg("vid:%d pid:%d\n", id->vid, id->pid); - } - } + /* Yes, then pick off the VID and PID as well */ + id->vid = usbhost_getle16(devdesc->vendor); + id->pid = usbhost_getle16(devdesc->product); + uvdbg("vid:%d pid:%d\n", id->vid, id->pid); return OK; } @@ -367,32 +355,37 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr, goto errout; } - /* Extract info from the device descriptor */ + /* Extract the correct max packetsize from the device descriptor */ - { - struct usb_devdesc_s *devdesc = (struct usb_devdesc_s *)buffer; + maxpacketsize = ((struct usb_devdesc_s *)buffer)->mxpacketsize; + uvdbg("maxpacksetsize: %d\n", maxpacketsize); - /* Extract the max packetsize for endpoint 0 */ + /* And reconfigure EP0 */ - maxpacketsize = devdesc->mxpacketsize; - uvdbg("maxpacksetsize: %d\n", maxpacketsize); + DRVR_EP0CONFIGURE(drvr, 0, maxpacketsize); - DRVR_EP0CONFIGURE(drvr, 0, maxpacketsize); + /* Now read the full device descriptor */ + + ctrlreq->type = USB_REQ_DIR_IN|USB_REQ_RECIPIENT_DEVICE; + ctrlreq->req = USB_REQ_GETDESCRIPTOR; + usbhost_putle16(ctrlreq->value, (USB_DESC_TYPE_DEVICE << 8)); + usbhost_putle16(ctrlreq->index, 0); + usbhost_putle16(ctrlreq->len, USB_SIZEOF_DEVDESC); - /* Get class identification information from the device descriptor. Most - * devices set this to USB_CLASS_PER_INTERFACE (zero) and provide the - * identification informatino in the interface descriptor(s). That allows - * a device to support multiple, different classes. - */ + ret = DRVR_CTRLIN(drvr, ctrlreq, buffer); + if (ret != OK) + { + udbg("ERROR: GETDESCRIPTOR/DEVICE, DRVR_CTRLIN returned %d\n", ret); + goto errout; + } - (void)usbhost_devdesc(devdesc, 8, &id); + /* Get class identification information from the device descriptor. Most + * devices set this to USB_CLASS_PER_INTERFACE (zero) and provide the + * identification informatino in the interface descriptor(s). That allows + * a device to support multiple, different classes. + */ - /* NOTE: Additional logic is needed here. We will need additional logic - * to (1) get the full device descriptor, (1) extract the vendor/product IDs - * and (2) extract the number of configurations from the (full) device - * descriptor. - */ - } + (void)usbhost_devdesc((struct usb_devdesc_s *)buffer, &id); /* Set the USB device address to the value in the 'funcaddr' input */ |