[USBEHCI]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Sun, 12 Feb 2012 00:49:18 +0000 (00:49 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Sun, 12 Feb 2012 00:49:18 +0000 (00:49 +0000)
- Enable async park mode when available
- Use correct type for the pipe handle
- Implement  URB_FUNCTION_GET_STATUS_FROM_INTERFACE,  URB_FUNCTION_GET_STATUS_FROM_ENDPOINT
- Verify that there is buffer provided in SubmitSetupPacket
[KBDCLASS]
- Forward requests to lower device

svn path=/branches/usb-bringup-trunk/; revision=55552

drivers/input/kbdclass/kbdclass.c
drivers/usb/usbehci/hardware.cpp
drivers/usb/usbehci/hub_controller.cpp
drivers/usb/usbehci/usb_device.cpp

index 03be367..e1bbe58 100644 (file)
@@ -878,7 +878,7 @@ ClassPnp(
        }
 
        Irp->IoStatus.Status = Status;
-       if (NT_SUCCESS(Status))
+       if (NT_SUCCESS(Status) || Status == STATUS_NOT_SUPPORTED)
        {
                IoSkipCurrentIrpStackLocation(Irp);
                return IoCallDriver(DeviceExtension->LowerDevice, Irp);
index 5af6529..f00fea3 100644 (file)
@@ -737,8 +737,19 @@ CUSBHardwareDevice::StartController(void)
     UsbCmd.IntThreshold = 0x8; //1ms
     UsbCmd.Run = TRUE;
     UsbCmd.FrameListSize = 0x0; //1024
+
+    if (m_Capabilities.HCCParams.ParkMode)
+    {
+        //
+        // enable async park mode
+        //
+        UsbCmd.AsyncParkEnable = TRUE;
+        UsbCmd.AsyncParkCount = 3;
+    }
+
     SetCommandRegister(&UsbCmd);
 
+
     //
     // Wait for execution to start
     //
index 5c49c21..1dc1962 100644 (file)
@@ -827,7 +827,7 @@ CHubController::HandleBulkOrInterruptTransfer(
     PURB Urb)
 {
     PUSBDEVICE UsbDevice;
-    PUSB_ENDPOINT_DESCRIPTOR EndPointDesc = NULL;
+    PUSB_ENDPOINT EndPointDesc = NULL;
     //
     // First check if the request is for the Status Change Endpoint
     //
@@ -856,13 +856,13 @@ CHubController::HandleBulkOrInterruptTransfer(
     //
     // Check PipeHandle to determine if this is a Bulk or Interrupt Transfer Request
     //
-    EndPointDesc = (PUSB_ENDPOINT_DESCRIPTOR)Urb->UrbBulkOrInterruptTransfer.PipeHandle;
+    EndPointDesc = (PUSB_ENDPOINT)Urb->UrbBulkOrInterruptTransfer.PipeHandle;
 
     //
     // sanity checks
     //
     ASSERT(EndPointDesc);
-    ASSERT((EndPointDesc->bmAttributes & USB_ENDPOINT_TYPE_MASK) == USB_ENDPOINT_TYPE_BULK || (EndPointDesc->bmAttributes & USB_ENDPOINT_TYPE_MASK) == USB_ENDPOINT_TYPE_INTERRUPT);
+    ASSERT((EndPointDesc->EndPointDescriptor.bmAttributes & USB_ENDPOINT_TYPE_MASK) == USB_ENDPOINT_TYPE_BULK || (EndPointDesc->EndPointDescriptor.bmAttributes & USB_ENDPOINT_TYPE_MASK) == USB_ENDPOINT_TYPE_INTERRUPT);
 
     //
     // check if this is a valid usb device handle
@@ -881,7 +881,6 @@ CHubController::HandleBulkOrInterruptTransfer(
     // get device
     //
     UsbDevice = PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle);
-
     return UsbDevice->SubmitIrp(Irp);
 }
 
@@ -1171,7 +1170,6 @@ CHubController::HandleGetStatusFromDevice(
     //
     // sanity checks
     //
-    PC_ASSERT(Urb->UrbControlGetStatusRequest.Index == 0);
     PC_ASSERT(Urb->UrbControlGetStatusRequest.TransferBufferLength >= sizeof(USHORT));
     PC_ASSERT(Urb->UrbControlGetStatusRequest.TransferBuffer);
 
@@ -1215,10 +1213,26 @@ CHubController::HandleGetStatusFromDevice(
      CtrlSetup.bRequest = USB_REQUEST_GET_STATUS;
      CtrlSetup.wValue.LowByte = 0;
      CtrlSetup.wValue.HiByte = 0;
-     CtrlSetup.wIndex.W = Urb->UrbControlGetStatusRequest.Index; 
+     CtrlSetup.wIndex.W = Urb->UrbControlGetStatusRequest.Index;
      CtrlSetup.wLength = (USHORT)Urb->UrbControlGetStatusRequest.TransferBufferLength;
      CtrlSetup.bmRequestType.B = 0x80;
 
+
+     if (Urb->UrbHeader.Function == URB_FUNCTION_GET_STATUS_FROM_INTERFACE)
+     {
+         //
+         // add interface type
+         //
+         CtrlSetup.bmRequestType.B |= 0x01;
+     }
+     else if (Urb->UrbHeader.Function == URB_FUNCTION_GET_STATUS_FROM_ENDPOINT)
+     {
+         //
+         // add interface type
+         //
+         CtrlSetup.bmRequestType.B |= 0x02;
+     }
+
     //
     // submit setup packet
     //
@@ -2030,6 +2044,8 @@ CHubController::HandleDeviceControl(
                     Status = HandleClassDevice(Irp, Urb);
                     break;
                 case URB_FUNCTION_GET_STATUS_FROM_DEVICE:
+                case URB_FUNCTION_GET_STATUS_FROM_INTERFACE:
+                case URB_FUNCTION_GET_STATUS_FROM_ENDPOINT:
                     Status = HandleGetStatusFromDevice(Irp, Urb);
                     break;
                 case URB_FUNCTION_SELECT_CONFIGURATION:
@@ -2523,7 +2539,7 @@ USBHI_CreateUsbDevice(
     //
     // now initialize device
     //
-    Status = NewUsbDevice->Initialize(PHUBCONTROLLER(Controller), Controller->GetUsbHardware(),PVOID(Controller), PortNumber, PortStatus);
+    Status = NewUsbDevice->Initialize(PHUBCONTROLLER(Controller), Controller->GetUsbHardware(), HubDeviceHandle, PortNumber, PortStatus);
 
     //
     // check for success
index ea3f89b..b9f4a80 100644 (file)
@@ -1038,27 +1038,40 @@ CUSBDevice::SubmitSetupPacket(
     OUT PVOID Buffer)
 {
     NTSTATUS Status;
-    PMDL Mdl;
+    PMDL Mdl = NULL;
 
-    //
-    // allocate mdl
-    //
-    Mdl = IoAllocateMdl(Buffer, BufferLength, FALSE, FALSE, 0);
+    if (BufferLength)
+    {
+        //
+        // allocate mdl
+        //
+        Mdl = IoAllocateMdl(Buffer, BufferLength, FALSE, FALSE, 0);
+        if (!Mdl)
+        {
+            //
+            // no memory
+            //
+            return STATUS_INSUFFICIENT_RESOURCES;
+        }
 
-    //
-    // HACK HACK HACK: assume the buffer is build from non paged pool
-    //
-    MmBuildMdlForNonPagedPool(Mdl);
+        //
+        // HACK HACK HACK: assume the buffer is build from non paged pool
+        //
+        MmBuildMdlForNonPagedPool(Mdl);
+    }
 
     //
     // commit setup packet
     //
     Status = CommitSetupPacket(SetupPacket, 0, BufferLength, Mdl);
 
-    //
-    // free mdl
-    //
-    IoFreeMdl(Mdl);
+    if (Mdl != NULL)
+    {
+        //
+        // free mdl
+        //
+        IoFreeMdl(Mdl);
+    }
 
     //
     // done