qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 04/12] usb-desc: audio endpoint support
Date: Fri,  6 Jan 2012 14:58:58 +0100	[thread overview]
Message-ID: <1325858346-1071-5-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1325858346-1071-1-git-send-email-kraxel@redhat.com>

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 |   14 +++++++++++---
 hw/usb-desc.h |    5 +++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/hw/usb-desc.c b/hw/usb-desc.c
index b9996a1..9c38661 100644
--- a/hw/usb-desc.c
+++ b/hw/usb-desc.c
@@ -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)
diff --git a/hw/usb-desc.h b/hw/usb-desc.h
index 5c14e4a..d6e07ea 100644
--- a/hw/usb-desc.h
+++ b/hw/usb-desc.h
@@ -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 {
-- 
1.7.1

  parent reply	other threads:[~2012-01-06 13:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-06 13:58 [Qemu-devel] [PATCH 00/12] usb patch queue: audio, xhci Gerd Hoffmann
2012-01-06 13:58 ` [Qemu-devel] [PATCH 01/12] usb-host: rip out legacy procfs support Gerd Hoffmann
2012-01-06 13:58 ` [Qemu-devel] [PATCH 02/12] usb: track configuration and interface count in USBDevice Gerd Hoffmann
2012-01-06 13:58 ` [Qemu-devel] [PATCH 03/12] usb: track altsetting " Gerd Hoffmann
2012-01-06 13:58 ` Gerd Hoffmann [this message]
2012-01-06 13:58 ` [Qemu-devel] [PATCH 05/12] usb: add audio device model Gerd Hoffmann
2012-01-06 17:23   ` Alex Bradbury
2012-01-06 13:59 ` [Qemu-devel] [PATCH 06/12] xhci: Initial xHCI implementation Gerd Hoffmann
2012-01-06 14:54   ` Stefan Weil
2012-01-09  9:30     ` Gerd Hoffmann
2012-01-06 13:59 ` [Qemu-devel] [PATCH 07/12] usb: add USBEndpoint Gerd Hoffmann
2012-01-06 13:59 ` [Qemu-devel] [PATCH 08/12] usb: add ifnum to USBEndpoint Gerd Hoffmann
2012-01-06 13:59 ` [Qemu-devel] [PATCH 09/12] usb-desc: USBEndpoint support Gerd Hoffmann
2012-01-06 13:59 ` [Qemu-devel] [PATCH 10/12] usb/debug: add usb_ep_dump Gerd Hoffmann
2012-01-06 13:59 ` [Qemu-devel] [PATCH 11/12] usb: add max_packet_size to USBEndpoint Gerd Hoffmann
2012-01-06 13:59 ` [Qemu-devel] [PATCH 12/12] usb: link packets to endpoints not devices Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1325858346-1071-5-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).