https://git.reactos.org/?p=reactos.git;a=commitdiff;h=720d7cfd9b95b20f8cb1bb534a4c4160a4457266

commit 720d7cfd9b95b20f8cb1bb534a4c4160a4457266
Author:     Vadim Galyant <v...@rambler.ru>
AuthorDate: Tue Dec 5 16:56:07 2017 +0900
Commit:     Amine Khaldi <amine.kha...@reactos.org>
CommitDate: Sun Jan 21 19:35:46 2018 +0100

    [USBPORT] Add USB2_GetHsOverhead().
---
 drivers/usb/usbport/usb2.c    | 47 +++++++++++++++++++++++++++++++++++++++++++
 drivers/usb/usbport/usbport.h |  9 +++++++++
 2 files changed, 56 insertions(+)

diff --git a/drivers/usb/usbport/usb2.c b/drivers/usb/usbport/usb2.c
index a91650ebdd..0ca831befe 100644
--- a/drivers/usb/usbport/usb2.c
+++ b/drivers/usb/usbport/usb2.c
@@ -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,
diff --git a/drivers/usb/usbport/usbport.h b/drivers/usb/usbport/usbport.h
index bb68680216..88277167c4 100644
--- a/drivers/usb/usbport/usbport.h
+++ b/drivers/usb/usbport/usbport.h
@@ -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;

Reply via email to