cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
958e1b
From 232db7b0f138480202ce2bba4e69de5b0972c455 Mon Sep 17 00:00:00 2001
958e1b
From: Gerd Hoffmann <kraxel@redhat.com>
958e1b
Date: Fri, 11 Jul 2014 14:20:53 +0200
958e1b
Subject: [PATCH 19/43] usb: Add max_streams attribute to endpoint info
958e1b
958e1b
Message-id: <1405088470-24115-21-git-send-email-kraxel@redhat.com>
958e1b
Patchwork-id: 59847
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH 20/37] usb: Add max_streams attribute to endpoint info
958e1b
Bugzilla: 1111450
958e1b
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
958e1b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
958e1b
958e1b
From: Hans de Goede <hdegoede@redhat.com>
958e1b
958e1b
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
958e1b
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
958e1b
(cherry picked from commit 04b300f85fafd2d6a92ec0a766f0035e9bc5835c)
958e1b
---
958e1b
 hw/usb/core.c    | 22 ++++++++++++++++++++++
958e1b
 hw/usb/desc.c    |  2 ++
958e1b
 include/hw/usb.h |  3 +++
958e1b
 3 files changed, 27 insertions(+)
958e1b
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 hw/usb/core.c    | 22 ++++++++++++++++++++++
958e1b
 hw/usb/desc.c    |  2 ++
958e1b
 include/hw/usb.h |  3 +++
958e1b
 3 files changed, 27 insertions(+)
958e1b
958e1b
diff --git a/hw/usb/core.c b/hw/usb/core.c
958e1b
index cf59a1a..67ba7d6 100644
958e1b
--- a/hw/usb/core.c
958e1b
+++ b/hw/usb/core.c
958e1b
@@ -623,6 +623,7 @@ void usb_ep_reset(USBDevice *dev)
958e1b
     dev->ep_ctl.type = USB_ENDPOINT_XFER_CONTROL;
958e1b
     dev->ep_ctl.ifnum = 0;
958e1b
     dev->ep_ctl.max_packet_size = 64;
958e1b
+    dev->ep_ctl.max_streams = 0;
958e1b
     dev->ep_ctl.dev = dev;
958e1b
     dev->ep_ctl.pipeline = false;
958e1b
     for (ep = 0; ep < USB_MAX_ENDPOINTS; ep++) {
958e1b
@@ -636,6 +637,8 @@ void usb_ep_reset(USBDevice *dev)
958e1b
         dev->ep_out[ep].ifnum = USB_INTERFACE_INVALID;
958e1b
         dev->ep_in[ep].max_packet_size = 0;
958e1b
         dev->ep_out[ep].max_packet_size = 0;
958e1b
+        dev->ep_in[ep].max_streams = 0;
958e1b
+        dev->ep_out[ep].max_streams = 0;
958e1b
         dev->ep_in[ep].dev = dev;
958e1b
         dev->ep_out[ep].dev = dev;
958e1b
         dev->ep_in[ep].pipeline = false;
958e1b
@@ -764,6 +767,25 @@ int usb_ep_get_max_packet_size(USBDevice *dev, int pid, int ep)
958e1b
     return uep->max_packet_size;
958e1b
 }
958e1b
 
958e1b
+void usb_ep_set_max_streams(USBDevice *dev, int pid, int ep, uint8_t raw)
958e1b
+{
958e1b
+    struct USBEndpoint *uep = usb_ep_get(dev, pid, ep);
958e1b
+    int MaxStreams;
958e1b
+
958e1b
+    MaxStreams = raw & 0x1f;
958e1b
+    if (MaxStreams) {
958e1b
+        uep->max_streams = 1 << MaxStreams;
958e1b
+    } else {
958e1b
+        uep->max_streams = 0;
958e1b
+    }
958e1b
+}
958e1b
+
958e1b
+int usb_ep_get_max_streams(USBDevice *dev, int pid, int ep)
958e1b
+{
958e1b
+    struct USBEndpoint *uep = usb_ep_get(dev, pid, ep);
958e1b
+    return uep->max_streams;
958e1b
+}
958e1b
+
958e1b
 void usb_ep_set_pipeline(USBDevice *dev, int pid, int ep, bool enabled)
958e1b
 {
958e1b
     struct USBEndpoint *uep = usb_ep_get(dev, pid, ep);
958e1b
diff --git a/hw/usb/desc.c b/hw/usb/desc.c
958e1b
index 5a954c6..f133ddb 100644
958e1b
--- a/hw/usb/desc.c
958e1b
+++ b/hw/usb/desc.c
958e1b
@@ -385,6 +385,8 @@ static void usb_desc_ep_init(USBDevice *dev)
958e1b
             usb_ep_set_ifnum(dev, pid, ep, iface->bInterfaceNumber);
958e1b
             usb_ep_set_max_packet_size(dev, pid, ep,
958e1b
                                        iface->eps[e].wMaxPacketSize);
958e1b
+            usb_ep_set_max_streams(dev, pid, ep,
958e1b
+                                   iface->eps[e].bmAttributes_super);
958e1b
         }
958e1b
     }
958e1b
 }
958e1b
diff --git a/include/hw/usb.h b/include/hw/usb.h
958e1b
index 5668701..116293e 100644
958e1b
--- a/include/hw/usb.h
958e1b
+++ b/include/hw/usb.h
958e1b
@@ -199,6 +199,7 @@ struct USBEndpoint {
958e1b
     uint8_t type;
958e1b
     uint8_t ifnum;
958e1b
     int max_packet_size;
958e1b
+    int max_streams;
958e1b
     bool pipeline;
958e1b
     bool halted;
958e1b
     USBDevice *dev;
958e1b
@@ -433,6 +434,8 @@ void usb_ep_set_ifnum(USBDevice *dev, int pid, int ep, uint8_t ifnum);
958e1b
 void usb_ep_set_max_packet_size(USBDevice *dev, int pid, int ep,
958e1b
                                 uint16_t raw);
958e1b
 int usb_ep_get_max_packet_size(USBDevice *dev, int pid, int ep);
958e1b
+void usb_ep_set_max_streams(USBDevice *dev, int pid, int ep, uint8_t raw);
958e1b
+int usb_ep_get_max_streams(USBDevice *dev, int pid, int ep);
958e1b
 void usb_ep_set_pipeline(USBDevice *dev, int pid, int ep, bool enabled);
958e1b
 void usb_ep_set_halted(USBDevice *dev, int pid, int ep, bool halted);
958e1b
 USBPacket *usb_ep_find_packet_by_id(USBDevice *dev, int pid, int ep,
958e1b
-- 
958e1b
1.8.3.1
958e1b