From 291bcc09e3818fb138304663945c94f81a4101ad Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sat, 15 Mar 2014 11:20:45 +0100 Subject: usbdump: get interval from descriptor It looks very ugly, perhaps a helper function should moved to desc.c? Signed-off-by: Peter Wu --- hw/usb/dump.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'hw/usb/dump.c') diff --git a/hw/usb/dump.c b/hw/usb/dump.c index 727567a4c1..48da328126 100644 --- a/hw/usb/dump.c +++ b/hw/usb/dump.c @@ -26,11 +26,13 @@ */ #include "hw/usb.h" -#include "dump.h" +#include "hw/usb/dump.h" #include "qemu-common.h" #include "qemu/error-report.h" #include "qemu/log.h" #include "qemu/timer.h" +#include "hw/usb.h" +#include "hw/usb/desc.h" typedef struct UsbDumpState { int64_t start_ts; @@ -144,6 +146,23 @@ static uint8_t get_xfer_type_from_ep(USBEndpoint *ep) return xfer_types[ep->type]; } +static uint8_t get_ep_interval(USBEndpoint *ep) +{ + USBDevice *dev = ep->dev; + + if (ep->type != USB_ENDPOINT_XFER_ISOC && ep->type != USB_ENDPOINT_XFER_INT) { + return 0; + } + + assert(ep->ifnum < dev->ninterfaces); + const USBDescIface *iface = dev->ifaces[ep->ifnum]; + + assert(ep->nr < iface->bNumEndpoints); + const USBDescEndpoint *uep = iface->eps + ep->nr; + + return uep->bInterval; +} + /* initialize usbmon_packet header from USBPacket */ static void init_from_usbpacket(UsbDumpState *s, struct usbmon_packet *u, USBPacket *p, char ev_type, unsigned datalen) @@ -226,7 +245,7 @@ static void init_from_usbpacket(UsbDumpState *s, struct usbmon_packet *u, } /* int32_t - 48: Only for Interrupt and ISO */ - u->interval = 0; // FIXME iso, intr + u->interval = get_ep_interval(p->ep); /* int32_t - 52: For ISO */ u->start_frame = 0; // FIXME iso -- cgit v1.2.1