https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3ba9fffbb2594b1909366…
commit 3ba9fffbb2594b1909366fba1ce5af69ab28a44b
Author: Vadim Galyant <vgal(a)rambler.ru>
AuthorDate: Wed Dec 13 03:51:54 2017 +0900
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Sun Jan 21 19:35:53 2018 +0100
[USBPORT] Start implementation USB2_DeallocateEndpointBudget().
---
drivers/usb/usbport/usb2.c | 53 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/usbport/usb2.c b/drivers/usb/usbport/usb2.c
index 0e305b4d11..a6a2f218ee 100644
--- a/drivers/usb/usbport/usb2.c
+++ b/drivers/usb/usbport/usb2.c
@@ -879,9 +879,60 @@ USB2_DeallocateEndpointBudget(IN PUSB2_TT_ENDPOINT TtEndpoint,
IN PULONG RebalanceListEntries,
IN ULONG MaxFrames)
{
+ PUSB2_TT Tt;
+ PUSB2_HC_EXTENSION HcExtension;
+ ULONG Speed;
+ ULONG StartMicroframe;
+ ULONG ix;
+
+ UCHAR frame;
+ UCHAR uframe;
+
+ DPRINT("USB2_DeallocateEndpointBudget: TtEndpoint - %p, MaxFrames - %X\n",
+ TtEndpoint,
+ MaxFrames);
+
+ if (TtEndpoint->CalcBusTime == 0)
+ {
+ DPRINT("USB2_DeallocateEndpointBudget: endpoint not
allocated\n");//error((int)"endpoint not allocated");
+ return FALSE;
+ }
+
+ Tt = TtEndpoint->Tt;
+ HcExtension = Tt->HcExtension;
+
+ Speed = TtEndpoint->TtEndpointParams.DeviceSpeed;
+ DPRINT("USB2_DeallocateEndpointBudget: DeviceSpeed - %X\n", Speed);
+
+ StartMicroframe = TtEndpoint->StartFrame * USB2_MICROFRAMES +
+ TtEndpoint->StartMicroframe;
+
+ if (Speed == UsbHighSpeed)
+ {
+ for (ix = StartMicroframe;
+ ix < USB2_MAX_MICROFRAMES;
+ ix += TtEndpoint->ActualPeriod)
+ {
+ frame = ix / USB2_MICROFRAMES;
+ uframe = ix % (USB2_MICROFRAMES - 1);
+
+ HcExtension->TimeUsed[frame][uframe] -= TtEndpoint->CalcBusTime;
+ }
+
+ TtEndpoint->CalcBusTime = 0;
+
+ DPRINT("USB2_DeallocateEndpointBudget: return TRUE\n");
+ return TRUE;
+ }
+
+ /* Speed != UsbHighSpeed (FS/LS) */
+
DPRINT("USB2_DeallocateEndpointBudget: UNIMPLEMENTED FIXME\n");
ASSERT(FALSE);
- return FALSE;
+
+ TtEndpoint->CalcBusTime = 0;
+ DPRINT("USB2_DeallocateEndpointBudget: return TRUE\n");
+ return TRUE;
}
BOOLEAN