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 10/12] usb/debug: add usb_ep_dump
Date: Fri,  6 Jan 2012 14:59:04 +0100	[thread overview]
Message-ID: <1325858346-1071-11-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1325858346-1071-1-git-send-email-kraxel@redhat.com>

Add function to dump endpoint data, for debugging purposes.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/usb.c    |   40 ++++++++++++++++++++++++++++++++++++++++
 hw/usb.h    |    1 +
 usb-linux.c |    3 +++
 3 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/hw/usb.c b/hw/usb.c
index 6ba063a..f07cb9d 100644
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -427,6 +427,46 @@ void usb_ep_init(USBDevice *dev)
     }
 }
 
+void usb_ep_dump(USBDevice *dev)
+{
+    static const char *tname[] = {
+        [USB_ENDPOINT_XFER_CONTROL] = "control",
+        [USB_ENDPOINT_XFER_ISOC]    = "isoc",
+        [USB_ENDPOINT_XFER_BULK]    = "bulk",
+        [USB_ENDPOINT_XFER_INT]     = "int",
+    };
+    int ifnum, ep, first;
+
+    fprintf(stderr, "Device \"%s\", config %d\n",
+            dev->product_desc, dev->configuration);
+    for (ifnum = 0; ifnum < 16; ifnum++) {
+        first = 1;
+        for (ep = 0; ep < USB_MAX_ENDPOINTS; ep++) {
+            if (dev->ep_in[ep].type != USB_ENDPOINT_XFER_INVALID &&
+                dev->ep_in[ep].ifnum == ifnum) {
+                if (first) {
+                    first = 0;
+                    fprintf(stderr, "  Interface %d, alternative %d\n",
+                            ifnum, dev->altsetting[ifnum]);
+                }
+                fprintf(stderr, "    Endpoint %d, IN, %s\n", ep,
+                        tname[dev->ep_in[ep].type]);
+            }
+            if (dev->ep_out[ep].type != USB_ENDPOINT_XFER_INVALID &&
+                dev->ep_out[ep].ifnum == ifnum) {
+                if (first) {
+                    first = 0;
+                    fprintf(stderr, "  Interface %d, alternative %d\n",
+                            ifnum, dev->altsetting[ifnum]);
+                }
+                fprintf(stderr, "    Endpoint %d, OUT, %s\n", ep,
+                        tname[dev->ep_out[ep].type]);
+            }
+        }
+    }
+    fprintf(stderr, "--\n");
+}
+
 struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep)
 {
     struct USBEndpoint *eps = pid == USB_TOKEN_IN ? dev->ep_in : dev->ep_out;
diff --git a/hw/usb.h b/hw/usb.h
index 60e8858..c35ff74 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -333,6 +333,7 @@ void usb_packet_complete(USBDevice *dev, USBPacket *p);
 void usb_cancel_packet(USBPacket * p);
 
 void usb_ep_init(USBDevice *dev);
+void usb_ep_dump(USBDevice *dev);
 struct USBEndpoint *usb_ep_get(USBDevice *dev, int pid, int ep);
 uint8_t usb_ep_get_type(USBDevice *dev, int pid, int ep);
 uint8_t usb_ep_get_ifnum(USBDevice *dev, int pid, int ep);
diff --git a/usb-linux.c b/usb-linux.c
index cb66ef3..2a7b748 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -1214,6 +1214,9 @@ static int usb_linux_update_endp_table(USBHostDevice *s)
             i += descriptors[i];
         }
     }
+#ifdef DEBUG
+    usb_ep_dump(&s->dev);
+#endif
     return 0;
 }
 
-- 
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 ` [Qemu-devel] [PATCH 04/12] usb-desc: audio endpoint support Gerd Hoffmann
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 ` Gerd Hoffmann [this message]
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-11-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).