https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e48d6136ec9984305a444…
commit e48d6136ec9984305a444f62968431fa5b2afe1d
Author: Vadim Galyant <vgal(a)rambler.ru>
AuthorDate: Mon Nov 27 18:30:58 2017 +0900
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Sun Jan 21 19:35:38 2018 +0100
[USBPORT] Add USBPORT_UpdateAllocatedBwTt().
---
drivers/usb/usbport/usb2.c | 34 ++++++++++++++++++++++++++++++++++
drivers/usb/usbport/usbport.h | 5 +++++
2 files changed, 39 insertions(+)
diff --git a/drivers/usb/usbport/usb2.c b/drivers/usb/usbport/usb2.c
index 1c4cd042de..2e511b5d9a 100644
--- a/drivers/usb/usbport/usb2.c
+++ b/drivers/usb/usbport/usb2.c
@@ -31,6 +31,40 @@ USB2_InitTtEndpoint(IN PUSB2_TT_ENDPOINT TtEndpoint,
TtEndpoint->Tt = Tt;
}
+VOID
+NTAPI
+USBPORT_UpdateAllocatedBwTt(IN PUSB2_TT_EXTENSION TtExtension)
+{
+ ULONG BusBandwidth;
+ ULONG NewBusBandwidth;
+ ULONG MaxBusBandwidth = 0;
+ ULONG MinBusBandwidth;
+ ULONG ix;
+
+ DPRINT("USBPORT_UpdateAllocatedBwTt: TtExtension - %p\n", TtExtension);
+
+ BusBandwidth = TtExtension->BusBandwidth;
+ MinBusBandwidth = BusBandwidth;
+
+ for (ix = 0; ix < USB2_FRAMES; ix++)
+ {
+ NewBusBandwidth = BusBandwidth - TtExtension->Bandwidth[ix];
+
+ if (NewBusBandwidth > MaxBusBandwidth)
+ MaxBusBandwidth = NewBusBandwidth;
+
+ if (NewBusBandwidth < MinBusBandwidth)
+ MinBusBandwidth = NewBusBandwidth;
+ }
+
+ TtExtension->MaxBandwidth = MaxBusBandwidth;
+
+ if (MinBusBandwidth == BusBandwidth)
+ TtExtension->MinBandwidth = 0;
+ else
+ TtExtension->MinBandwidth = MinBusBandwidth;
+}
+
BOOLEAN
NTAPI
USBPORT_AllocateBandwidthUSB2(IN PDEVICE_OBJECT FdoDevice,
diff --git a/drivers/usb/usbport/usbport.h b/drivers/usb/usbport/usbport.h
index 026b297f17..85636b24bf 100644
--- a/drivers/usb/usbport/usbport.h
+++ b/drivers/usb/usbport/usbport.h
@@ -1296,6 +1296,11 @@ USBPORT_FreeBandwidthUSB2(
IN PDEVICE_OBJECT FdoDevice,
IN PUSBPORT_ENDPOINT Endpoint);
+VOID
+NTAPI
+USBPORT_UpdateAllocatedBwTt(
+ IN PUSB2_TT_EXTENSION TtExtension);
+
VOID
NTAPI
USB2_InitTT(