[HIDCLASS]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Tue, 31 Jan 2012 18:37:49 +0000 (18:37 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Tue, 31 Jan 2012 18:37:49 +0000 (18:37 +0000)
- Implement set idle request. The device should only send data when there is actual data. May also fix the mouse debug flood when mouse is ejected
- Not yet supported in OHCI
- Add missing constants

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

drivers/hid/hidusb/hidusb.c
drivers/hid/hidusb/hidusb.h
drivers/usb/usbohci/hub_controller.cpp
include/ddk/hidport.h

index 88265c1..69a5215 100644 (file)
@@ -1230,6 +1230,72 @@ Hid_SelectConfiguration(
     return Status;
 }
 
+NTSTATUS
+Hid_SetIdle(
+    IN PDEVICE_OBJECT DeviceObject)
+{
+    PHID_USB_DEVICE_EXTENSION HidDeviceExtension;
+    PHID_DEVICE_EXTENSION DeviceExtension;
+    PURB Urb;
+    NTSTATUS Status;
+
+    //
+    // 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),
+                          0,
+                          HID_REPORT_DESCRIPTOR_TYPE,
+                          USB_SET_IDLE_REQUEST, // HID_SET_IDLE
+                          0,
+                          0,
+                          NULL,
+                          NULL,
+                          0,
+                          NULL);
+
+    //
+    // dispatch urb
+    //
+    Status = Hid_DispatchUrb(DeviceObject, Urb);
+
+    //
+    // free urb
+    //
+    ExFreePool(Urb);
+
+    //
+    // print status
+    //
+    DPRINT1("Status %x\n", Status);
+    return Status;
+}
+
+
 
 NTSTATUS
 Hid_PnpStart(
@@ -1333,6 +1399,12 @@ Hid_PnpStart(
     ASSERT(InterfaceDescriptor->bDescriptorType == USB_INTERFACE_DESCRIPTOR_TYPE);
     ASSERT(InterfaceDescriptor->bLength == sizeof(USB_INTERFACE_DESCRIPTOR));
 
+    //
+    // now set the device idle
+    //
+    Hid_SetIdle(DeviceObject);
+
+
     //
     // move to next descriptor
     //
index 02eb640..84e50cf 100644 (file)
@@ -12,6 +12,8 @@
 #include <usb.h>
 #include <usbdlib.h>
 
+#include <hidport.h>
+
 typedef struct
 {
     //
@@ -80,3 +82,5 @@ NTSTATUS
 Hid_DispatchUrb(
     IN PDEVICE_OBJECT DeviceObject,
     IN PURB Urb);
+
+#define USB_SET_IDLE_REQUEST 0xA
index 54726de..02e96cb 100644 (file)
@@ -1731,7 +1731,10 @@ CHubController::HandleClassInterface(
 
     if (Urb->UrbControlVendorClassRequest.TransferBufferLength == 0)
     {
-        DPRINT1("Invalid request length\n");
+        //
+        // FIXME: support requests w/o data stage
+        //;
+        ASSERT(FALSE);
         return STATUS_SUCCESS;
     }
 
index 078f58e..e6819e9 100644 (file)
@@ -47,6 +47,11 @@ typedef struct _HID_DESCRIPTOR
 
 #include <poppack.h>
 
+#define HID_HID_DESCRIPTOR_TYPE             0x21
+#define HID_REPORT_DESCRIPTOR_TYPE          0x22
+#define HID_PHYSICAL_DESCRIPTOR_TYPE        0x23
+
+
 
 typedef 
 VOID