[HIDUSB]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Wed, 1 Feb 2012 03:02:25 +0000 (03:02 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Wed, 1 Feb 2012 03:02:25 +0000 (03:02 +0000)
- Add support function to detect when the boot protocol is still active

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

drivers/hid/hidusb/hidusb.c
drivers/hid/hidusb/hidusb.h

index 69a5215..f859b2b 100644 (file)
@@ -1269,7 +1269,7 @@ Hid_SetIdle(
                           URB_FUNCTION_CLASS_INTERFACE, 
                           sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST),
                           0,
-                          HID_REPORT_DESCRIPTOR_TYPE,
+                          0,
                           USB_SET_IDLE_REQUEST, // HID_SET_IDLE
                           0,
                           0,
@@ -1296,6 +1296,76 @@ Hid_SetIdle(
 }
 
 
+NTSTATUS
+Hid_GetProtocol(
+    IN PDEVICE_OBJECT DeviceObject)
+{
+    PHID_USB_DEVICE_EXTENSION HidDeviceExtension;
+    PHID_DEVICE_EXTENSION DeviceExtension;
+    PURB Urb;
+    NTSTATUS Status;
+    UCHAR Protocol[1];
+
+    //
+    // get device extension
+    //
+    DeviceExtension = (PHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+    HidDeviceExtension = (PHID_USB_DEVICE_EXTENSION)DeviceExtension->MiniDeviceExtension;
+
+    //
+    // allocate urb
+    //
+    Urb = ExAllocatePool(NonPagedPool, sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));
+    if (!Urb)
+    {
+        //
+        // no memory
+        //
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
+
+    //
+    // zero urb
+    //
+    RtlZeroMemory(Urb, sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));
+
+    //
+    // format urb
+    //
+    UsbBuildVendorRequest(Urb,
+                          URB_FUNCTION_CLASS_INTERFACE, 
+                          sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST),
+                          USBD_TRANSFER_DIRECTION_IN,
+                          0,
+                          USB_GET_PROTOCOL_REQUEST,
+                          0,
+                          0,
+                          Protocol,
+                          NULL,
+                          1,
+                          NULL);
+    Protocol[0] = 0xFF;
+    //
+    // dispatch urb
+    //
+    Status = Hid_DispatchUrb(DeviceObject, Urb);
+
+    //
+    // free urb
+    //
+    ExFreePool(Urb);
+
+    //
+    // print status
+    //
+    DPRINT1("Status %x Protocol %x\n", Status, Protocol[0] & 0xFF);
+
+    //
+    // assert when boot protocol is still active
+    //
+    ASSERT(Protocol[0] == 0x1); 
+    return Status;
+}
 
 NTSTATUS
 Hid_PnpStart(
@@ -1404,6 +1474,7 @@ Hid_PnpStart(
     //
     Hid_SetIdle(DeviceObject);
 
+   Hid_GetProtocol(DeviceObject);
 
     //
     // move to next descriptor
index 84e50cf..816afb8 100644 (file)
@@ -84,3 +84,5 @@ Hid_DispatchUrb(
     IN PURB Urb);
 
 #define USB_SET_IDLE_REQUEST 0xA
+#define USB_GET_PROTOCOL_REQUEST 0x3
+