[USBPORT] Add USB2_GetSMASK()and USB2_ConvertFrame().

This commit is contained in:
Vadim Galyant 2017-12-09 17:06:52 +09:00 committed by Amine Khaldi
parent df44bc6d84
commit f3c869a16b

View file

@ -503,6 +503,67 @@ USB2_MoveTtEndpoint(IN PUSB2_TT_ENDPOINT TtEndpoint,
return FALSE;
}
VOID
NTAPI
USB2_ConvertFrame(IN UCHAR Frame,
IN UCHAR Microframe,
OUT PUCHAR HcFrame,
OUT PUCHAR HcMicroframe)
{
DPRINT("USB2_ConvertFrame: Frame - %x, Microframe - %x\n",
Frame,
Microframe);
if (Microframe == 0xFF)
{
*HcFrame = Frame;
*HcMicroframe = 0;
}
if (Microframe >= 0 &&
Microframe <= (USB2_MICROFRAMES - 2))
{
*HcFrame = Frame;
*HcMicroframe = Microframe + 1;
}
if (Microframe == (USB2_MICROFRAMES - 1))
{
*HcFrame = Frame + 1;
*HcMicroframe = 0;
}
}
UCHAR
NTAPI
USB2_GetSMASK(IN PUSB2_TT_ENDPOINT TtEndpoint)
{
ULONG ix;
UCHAR SMask = 0;
UCHAR HcFrame;
UCHAR HcMicroFrame;
if (TtEndpoint->TtEndpointParams.DeviceSpeed == UsbHighSpeed)
{
SMask = (1 << TtEndpoint->StartMicroframe);
}
else
{
USB2_ConvertFrame(TtEndpoint->StartFrame,
TtEndpoint->StartMicroframe,
&HcFrame,
&HcMicroFrame);
for (ix = 0; ix < TtEndpoint->Nums.NumStarts; ix++)
{
SMask |= (1 << HcMicroFrame);
HcMicroFrame++;
}
}
return SMask;
}
BOOLEAN
NTAPI
USB2_DeallocateEndpointBudget(IN PUSB2_TT_ENDPOINT TtEndpoint,