[USBPORT] Add USB2_CheckTtEndpointInsert().
authorVadim Galyant <vgal@rambler.ru>
Wed, 29 Nov 2017 14:25:12 +0000 (23:25 +0900)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sun, 21 Jan 2018 18:35:43 +0000 (19:35 +0100)
drivers/usb/usbport/usb2.c

index 080d48c..ad8375d 100644 (file)
@@ -38,6 +38,52 @@ USB2_AddDataBitStuff(IN USHORT DataTime)
     return (DataTime + (DataTime / 16));
 }
 
+BOOLEAN
+NTAPI
+USB2_CheckTtEndpointInsert(IN PUSB2_TT_ENDPOINT nextTtEndpoint,
+                           IN PUSB2_TT_ENDPOINT TtEndpoint)
+{
+    ULONG TransferType;
+
+    DPRINT("USB2_CheckTtEndpointInsert: nextTtEndpoint - %p, TtEndpoint - %p\n",
+           nextTtEndpoint,
+           TtEndpoint);
+
+    ASSERT(TtEndpoint);
+
+    if (TtEndpoint->CalcBusTime >= (USB2_FS_MAX_PERIODIC_ALLOCATION / 2))
+    {
+        DPRINT1("USB2_CheckTtEndpointInsert: Result - FALSE\n");
+        return FALSE;
+    }
+
+    if (!nextTtEndpoint)
+    {
+        DPRINT("USB2_CheckTtEndpointInsert: Result - TRUE\n");
+        return TRUE;
+    }
+
+    TransferType = TtEndpoint->TtEndpointParams.TransferType;
+
+    if (nextTtEndpoint->ActualPeriod < TtEndpoint->ActualPeriod &&
+        TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT)
+    {
+        DPRINT("USB2_CheckTtEndpointInsert: Result - TRUE\n");
+        return TRUE;
+    }
+
+    if ((nextTtEndpoint->ActualPeriod <= TtEndpoint->ActualPeriod &&
+        TransferType == USBPORT_TRANSFER_TYPE_ISOCHRONOUS) ||
+        nextTtEndpoint == TtEndpoint)
+    {
+        DPRINT("USB2_CheckTtEndpointInsert: Result - TRUE\n");
+        return TRUE;
+    }
+
+    DPRINT("USB2_CheckTtEndpointInsert: Result - FALSE\n");
+    return FALSE;
+}
+
 ULONG
 NTAPI
 USB2_GetOverhead(IN PUSB2_TT_ENDPOINT TtEndpoint)