From: Vadim Galyant Date: Sat, 9 Dec 2017 08:15:40 +0000 (+0900) Subject: [USBPORT] Add USB2_GetCMASK(). X-Git-Tag: 0.4.9-RC~357^2~30 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=5ffefbe9456217f4dbeb655137fc040605ba89c0 [USBPORT] Add USB2_GetCMASK(). --- diff --git a/drivers/usb/usbport/usb2.c b/drivers/usb/usbport/usb2.c index d9742388545..d234c7e3904 100644 --- a/drivers/usb/usbport/usb2.c +++ b/drivers/usb/usbport/usb2.c @@ -564,6 +564,79 @@ USB2_GetSMASK(IN PUSB2_TT_ENDPOINT TtEndpoint) return SMask; } +UCHAR +NTAPI +USB2_GetCMASK(IN PUSB2_TT_ENDPOINT TtEndpoint) +{ + ULONG NumCompletes; + ULONG TransferType; + ULONG DeviceSpeed; + ULONG Direction; + UCHAR Result; + UCHAR MicroFrameCS; + UCHAR HcFrame; + UCHAR HcMicroFrame; + UCHAR MaskCS = 0; + static const UCHAR CMASKS[USB2_MICROFRAMES] = { + 0x1C, 0x38, 0x70, 0xE0, 0xC1, 0x83, 0x07, 0x0E + }; + + TransferType = TtEndpoint->TtEndpointParams.TransferType; + DeviceSpeed = TtEndpoint->TtEndpointParams.DeviceSpeed; + Direction = TtEndpoint->TtEndpointParams.Direction; + + if (DeviceSpeed == UsbHighSpeed) + { + return 0; + } + + if (TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT) + { + USB2_ConvertFrame(TtEndpoint->StartFrame, + TtEndpoint->StartMicroframe, + &HcFrame, + &HcMicroFrame); + + Result = CMASKS[HcMicroFrame]; + } + else + { + if (Direction == USBPORT_TRANSFER_DIRECTION_OUT) + { + return 0; + } + + USB2_ConvertFrame(TtEndpoint->StartFrame, + TtEndpoint->StartMicroframe, + &HcFrame, + &HcMicroFrame); + + NumCompletes = TtEndpoint->Nums.NumCompletes; + + for (MicroFrameCS = HcMicroFrame + 2; + MicroFrameCS < USB2_MICROFRAMES; + MicroFrameCS++) + { + MaskCS |= (1 << MicroFrameCS); + NumCompletes--; + + if (!NumCompletes) + { + return MaskCS; + } + } + + for (; NumCompletes; NumCompletes--) + { + MaskCS |= (1 << (MicroFrameCS - USB2_MICROFRAMES)); + } + + Result = MaskCS; + } + + return Result; +} + BOOLEAN NTAPI USB2_DeallocateEndpointBudget(IN PUSB2_TT_ENDPOINT TtEndpoint,