[USBPORT] Add USB2_GetHsOverhead().
authorVadim Galyant <vgal@rambler.ru>
Tue, 5 Dec 2017 07:56:07 +0000 (16:56 +0900)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sun, 21 Jan 2018 18:35:46 +0000 (19:35 +0100)
drivers/usb/usbport/usb2.c
drivers/usb/usbport/usbport.h

index a91650e..0ca831b 100644 (file)
@@ -159,6 +159,53 @@ USB2_GetOverhead(IN PUSB2_TT_ENDPOINT TtEndpoint)
     return Overhead;
 }
 
+VOID
+NTAPI
+USB2_GetHsOverhead(IN PUSB2_TT_ENDPOINT TtEndpoint,
+                   IN PULONG OverheadSS,
+                   IN PULONG OverheadCS)
+{
+    ULONG TransferType;
+    ULONG Direction;
+    ULONG HostDelay;
+
+    TransferType = TtEndpoint->TtEndpointParams.TransferType;
+    Direction = TtEndpoint->TtEndpointParams.Direction;
+
+    HostDelay = TtEndpoint->Tt->HcExtension->HcDelayTime;
+
+    if (Direction == USBPORT_TRANSFER_DIRECTION_OUT)
+    {
+        if (TransferType == USBPORT_TRANSFER_TYPE_ISOCHRONOUS)
+        {
+            *OverheadSS = HostDelay + USB2_HS_SS_ISOCHRONOUS_OUT_OVERHEAD;
+            *OverheadCS = 0;
+        }
+        else
+        {
+            *OverheadSS = HostDelay + USB2_HS_SS_INTERRUPT_OUT_OVERHEAD;
+            *OverheadCS = HostDelay + USB2_HS_CS_INTERRUPT_OUT_OVERHEAD;
+        }
+    }
+    else
+    {
+        if (TransferType == USBPORT_TRANSFER_TYPE_ISOCHRONOUS)
+        {
+            *OverheadSS = HostDelay + USB2_HS_SS_ISOCHRONOUS_IN_OVERHEAD;
+            *OverheadCS = HostDelay + USB2_HS_CS_ISOCHRONOUS_IN_OVERHEAD;
+        }
+        else
+        {
+            *OverheadSS = HostDelay + USB2_HS_SS_INTERRUPT_IN_OVERHEAD;
+            *OverheadCS = HostDelay + USB2_HS_CS_INTERRUPT_IN_OVERHEAD;
+        }
+
+        DPRINT("USB2_GetHsOverhead: *OverheadSS - %X, *OverheadCS - %X\n",
+               *OverheadSS,
+               *OverheadCS);
+    }
+}
+
 ULONG
 NTAPI
 USB2_GetLastIsoTime(IN PUSB2_TT_ENDPOINT TtEndpoint,
index bb68680..8827716 100644 (file)
@@ -469,6 +469,15 @@ typedef struct _TIMER_WORK_QUEUE_ITEM {
 #define USB2_HS_ISOCHRONOUS_OUT_OVERHEAD       38
 #define USB2_HS_ISOCHRONOUS_IN_OVERHEAD        18
 
+#define USB2_HS_SS_INTERRUPT_OUT_OVERHEAD      58
+#define USB2_HS_CS_INTERRUPT_OUT_OVERHEAD      36
+#define USB2_HS_SS_INTERRUPT_IN_OVERHEAD       39
+#define USB2_HS_CS_INTERRUPT_IN_OVERHEAD       38
+
+#define USB2_HS_SS_ISOCHRONOUS_OUT_OVERHEAD    58
+#define USB2_HS_SS_ISOCHRONOUS_IN_OVERHEAD     39
+#define USB2_HS_CS_ISOCHRONOUS_IN_OVERHEAD     38
+
 typedef union _USB2_TT_ENDPOINT_PARAMS {
   struct {
     ULONG TransferType           : 4;