[USBPORT] Correcting USB2_AllocateHS().

This commit is contained in:
Vadim Galyant 2017-12-09 18:42:16 +09:00 committed by Amine Khaldi
parent 1926238056
commit 00dd0c67b6

View file

@ -315,16 +315,18 @@ USB2_AllocateHS(IN PUSB2_TT_ENDPOINT TtEndpoint,
ULONG TransferType; ULONG TransferType;
ULONG Direction; ULONG Direction;
ULONG DataTime; ULONG DataTime;
ULONG DataSize;
ULONG RemainDataTime; ULONG RemainDataTime;
ULONG OverheadCS; ULONG OverheadCS;
ULONG OverheadSS; ULONG OverheadSS;
ULONG ix; ULONG ix;
USHORT PktSize; USHORT PktSize;
USHORT PktSizeBitStuff;
UCHAR frame; UCHAR frame;
UCHAR uframe; UCHAR uframe;
BOOL Result = TRUE; BOOL Result = TRUE;
DPRINT("USB2_AllocateHS: TtEndpoint - %p, Frame - %X, TtEndpoint->StartFrame - %X\n", DPRINT("USB2_AllocateHS: TtEndpoint - %p, Frame - %X, StartFrame - %X\n",
TtEndpoint, TtEndpoint,
Frame, Frame,
TtEndpoint->StartFrame); TtEndpoint->StartFrame);
@ -352,14 +354,10 @@ USB2_AllocateHS(IN PUSB2_TT_ENDPOINT TtEndpoint,
{ {
TtEndpoint->Nums.NumStarts = 1; TtEndpoint->Nums.NumStarts = 1;
if ((CHAR)TtEndpoint->StartMicroframe < 5) if ((CHAR)TtEndpoint->StartMicroframe < (USB2_MICROFRAMES - 3))
{
TtEndpoint->Nums.NumCompletes = 3; TtEndpoint->Nums.NumCompletes = 3;
}
else else
{
TtEndpoint->Nums.NumCompletes = 2; TtEndpoint->Nums.NumCompletes = 2;
}
} }
} }
else else
@ -391,7 +389,8 @@ USB2_AllocateHS(IN PUSB2_TT_ENDPOINT TtEndpoint,
Result = FALSE; Result = FALSE;
} }
if (Tt->NumStartSplits[frame][uframe] > (USB2_MAX_FS_LS_TRANSACTIONS_IN_UFRAME - 1)) if (Tt->NumStartSplits[frame][uframe] >
(USB2_MAX_FS_LS_TRANSACTIONS_IN_UFRAME - 1))
{ {
DPRINT1("USB2_AllocateHS: Num Start Splits - %X\n", DPRINT1("USB2_AllocateHS: Num Start Splits - %X\n",
Tt->NumStartSplits[frame][uframe] + 1); Tt->NumStartSplits[frame][uframe] + 1);
@ -419,10 +418,44 @@ USB2_AllocateHS(IN PUSB2_TT_ENDPOINT TtEndpoint,
USB2_IncMicroFrame(&frame, &uframe); USB2_IncMicroFrame(&frame, &uframe);
} }
PktSize = TtEndpoint->MaxPacketSize;
PktSizeBitStuff = USB2_AddDataBitStuff(PktSize);
if (Direction == USBPORT_TRANSFER_DIRECTION_OUT) if (Direction == USBPORT_TRANSFER_DIRECTION_OUT)
{ {
DPRINT("USB2_AllocateHS: DIRECTION OUT UNIMPLEMENTED\n"); frame = TtEndpoint->StartFrame + Frame;
ASSERT(FALSE); uframe = TtEndpoint->StartMicroframe;
if (uframe == 0xFF)
USB2_GetPrevMicroFrame(&frame, &uframe);
DataTime = 0;
for (ix = 0; ix < TtEndpoint->Nums.NumStarts; ix++)
{
DataSize = PktSizeBitStuff - DataTime;
if (DataSize <= USB2_FS_RAW_BYTES_IN_MICROFRAME)
DataTime = DataSize;
else
DataTime = USB2_FS_RAW_BYTES_IN_MICROFRAME;
DPRINT("USB2_AllocateHS: ix - %X, frame - %X, uframe - %X, TimeUsed - %X\n",
ix,
frame,
uframe,
HcExtension->TimeUsed[frame][uframe]);
if (!USB2_AllocateCheck(&HcExtension->TimeUsed[frame][uframe],
DataTime,
USB2_MAX_MICROFRAME_ALLOCATION))
{
Result = FALSE;
}
USB2_IncMicroFrame(&frame, &uframe);
DataTime += USB2_FS_RAW_BYTES_IN_MICROFRAME;
}
} }
else else
{ {
@ -433,26 +466,21 @@ USB2_AllocateHS(IN PUSB2_TT_ENDPOINT TtEndpoint,
{ {
if (Tt->TimeCS[frame][uframe] < USB2_FS_RAW_BYTES_IN_MICROFRAME) if (Tt->TimeCS[frame][uframe] < USB2_FS_RAW_BYTES_IN_MICROFRAME)
{ {
if (Tt->TimeCS[frame][uframe] < USB2_FS_RAW_BYTES_IN_MICROFRAME) RemainDataTime = USB2_FS_RAW_BYTES_IN_MICROFRAME -
{ Tt->TimeCS[frame][uframe];
RemainDataTime = USB2_FS_RAW_BYTES_IN_MICROFRAME -
Tt->TimeCS[frame][uframe];
}
else
{
RemainDataTime = 0;
}
PktSize = TtEndpoint->MaxPacketSize; if (RemainDataTime >= PktSizeBitStuff)
if (RemainDataTime >= USB2_AddDataBitStuff(PktSize))
{ {
DataTime = USB2_AddDataBitStuff(PktSize); DataTime = PktSizeBitStuff;
} }
else else if (RemainDataTime > 0)
{ {
DataTime = RemainDataTime; DataTime = RemainDataTime;
} }
else
{
DataTime = 0;
}
if (!USB2_AllocateCheck(&HcExtension->TimeUsed[frame][uframe], if (!USB2_AllocateCheck(&HcExtension->TimeUsed[frame][uframe],
DataTime, DataTime,
@ -462,16 +490,10 @@ USB2_AllocateHS(IN PUSB2_TT_ENDPOINT TtEndpoint,
} }
} }
PktSize = TtEndpoint->MaxPacketSize; if (PktSizeBitStuff < USB2_FS_RAW_BYTES_IN_MICROFRAME)
Tt->TimeCS[frame][uframe] += PktSizeBitStuff;
if (USB2_AddDataBitStuff(PktSize) < USB2_FS_RAW_BYTES_IN_MICROFRAME)
{
Tt->TimeCS[frame][uframe] += USB2_AddDataBitStuff(PktSize);
}
else else
{
Tt->TimeCS[frame][uframe] += USB2_FS_RAW_BYTES_IN_MICROFRAME; Tt->TimeCS[frame][uframe] += USB2_FS_RAW_BYTES_IN_MICROFRAME;
}
USB2_IncMicroFrame(&frame, &uframe); USB2_IncMicroFrame(&frame, &uframe);
} }