https://git.reactos.org/?p=reactos.git;a=commitdiff;h=664e48cad50ae7a707f2d…
commit 664e48cad50ae7a707f2dcaf7562fa460380b201
Author: Vadim Galyant <vgal(a)rambler.ru>
AuthorDate: Tue Nov 28 15:13:22 2017 +0900
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Sun Jan 21 19:35:40 2018 +0100
[USBPORT] Implement USBPORT_FreeBandwidth().
---
drivers/usb/usbport/endpoint.c | 58 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 57 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/usbport/endpoint.c b/drivers/usb/usbport/endpoint.c
index 1e037f9ff4..23bccb14c3 100644
--- a/drivers/usb/usbport/endpoint.c
+++ b/drivers/usb/usbport/endpoint.c
@@ -173,7 +173,63 @@ NTAPI
USBPORT_FreeBandwidth(IN PDEVICE_OBJECT FdoDevice,
IN PUSBPORT_ENDPOINT Endpoint)
{
- DPRINT1("USBPORT_FreeBandwidth: UNIMPLEMENTED. FIXME. \n");
+ PUSBPORT_DEVICE_EXTENSION FdoExtension;
+ PUSBPORT_ENDPOINT_PROPERTIES EndpointProperties;
+ ULONG TransferType;
+ ULONG Offset;
+ ULONG EndpointBandwidth;
+ ULONG Period;
+ ULONG Factor;
+ UCHAR Bit;
+
+ DPRINT("USBPORT_FreeBandwidth: FdoDevice - %p, Endpoint - %p\n",
+ FdoDevice,
+ Endpoint);
+
+ FdoExtension = FdoDevice->DeviceExtension;
+
+ EndpointProperties = &Endpoint->EndpointProperties;
+ TransferType = EndpointProperties->TransferType;
+
+ if (TransferType == USBPORT_TRANSFER_TYPE_BULK ||
+ TransferType == USBPORT_TRANSFER_TYPE_CONTROL ||
+ (Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0))
+ {
+ return;
+ }
+
+ Offset = Endpoint->EndpointProperties.ScheduleOffset;
+ EndpointBandwidth = Endpoint->EndpointProperties.UsbBandwidth;
+ Period = Endpoint->EndpointProperties.Period;
+
+ ASSERT(USB2_FRAMES / Period);
+
+ for (Factor = USB2_FRAMES / Period; Factor; Factor--)
+ {
+ FdoExtension->Bandwidth[Offset * Factor] += EndpointBandwidth;
+ }
+
+ if (TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT)
+ {
+ for (Bit = 0x80; Bit != 0; Bit >>= 1)
+ {
+ if ((Period & Bit) != 0)
+ {
+ Period = Bit;
+ break;
+ }
+ }
+
+ ASSERT(Period != 0);
+
+ DPRINT("USBPORT_AllocateBandwidth: FIXME AllocedInterrupt_XXms\n");
+ }
+ else
+ {
+ DPRINT("USBPORT_AllocateBandwidth: FIXME AllocedIso\n");
+ }
+
+ DPRINT1("USBPORT_FreeBandwidth: FIXME USBPORT_UpdateAllocatedBw\n");
}
UCHAR