usb-desc: audio endpoint support
authorGerd Hoffmann <kraxel@redhat.com>
Wed, 10 Aug 2011 12:10:04 +0000 (14:10 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Fri, 13 Jan 2012 09:25:44 +0000 (10:25 +0100)
Add support for audio endpoints which have two more fields in the
descriptor.  Also add support for extra class specific endpoint
descriptors.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb-desc.c
hw/usb-desc.h

index b9996a126492686dc65bbd69e5107ab661273be1..9c3866180e0b797cf9d14890ba2b372f9d9913cf 100644 (file)
@@ -192,9 +192,10 @@ int usb_desc_iface(const USBDescIface *iface, uint8_t *dest, size_t len)
 
 int usb_desc_endpoint(const USBDescEndpoint *ep, uint8_t *dest, size_t len)
 {
-    uint8_t bLength = 0x07;
+    uint8_t bLength = ep->is_audio ? 0x09 : 0x07;
+    uint8_t extralen = ep->extra ? ep->extra[0] : 0;
 
-    if (len < bLength) {
+    if (len < bLength + extralen) {
         return -1;
     }
 
@@ -205,8 +206,15 @@ int usb_desc_endpoint(const USBDescEndpoint *ep, uint8_t *dest, size_t len)
     dest[0x04] = usb_lo(ep->wMaxPacketSize);
     dest[0x05] = usb_hi(ep->wMaxPacketSize);
     dest[0x06] = ep->bInterval;
+    if (ep->is_audio) {
+        dest[0x07] = ep->bRefresh;
+        dest[0x08] = ep->bSynchAddress;
+    }
+    if (ep->extra) {
+        memcpy(dest + bLength, ep->extra, extralen);
+    }
 
-    return bLength;
+    return bLength + extralen;
 }
 
 int usb_desc_other(const USBDescOther *desc, uint8_t *dest, size_t len)
index 5c14e4abdc2b20f03df77631b86d069b3cf5c7c4..d6e07ea5d24da097c145b98a85521760206754a3 100644 (file)
@@ -71,6 +71,11 @@ struct USBDescEndpoint {
     uint8_t                   bmAttributes;
     uint16_t                  wMaxPacketSize;
     uint8_t                   bInterval;
+    uint8_t                   bRefresh;
+    uint8_t                   bSynchAddress;
+
+    uint8_t                   is_audio; /* has bRefresh + bSynchAddress */
+    uint8_t                   *extra;
 };
 
 struct USBDescOther {