//
// parse configuration descriptor
//
- InterfaceDescriptor = USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor, CurrentPosition, -1, -1, -1, -1, -1);
+ InterfaceDescriptor = USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor, ConfigurationDescriptor, InterfaceIndex, -1, -1, -1, -1);
if (InterfaceDescriptor)
{
//
//
PDODeviceExtension->Common.IsFDO = FALSE;
PDODeviceExtension->FunctionDescriptor = &FDODeviceExtension->FunctionDescriptor[Index];
- PDODeviceExtension->NextDeviceObject = DeviceObject;
+ PDODeviceExtension->NextDeviceObject = FDODeviceExtension->NextDeviceObject; //DeviceObject; HACK
PDODeviceExtension->FunctionIndex = Index;
+ PDODeviceExtension->InterfaceList = FDODeviceExtension->InterfaceList;
+ PDODeviceExtension->InterfaceListCount = FDODeviceExtension->InterfaceListCount;
PDODeviceExtension->ConfigurationHandle = FDODeviceExtension->ConfigurationHandle;
PDODeviceExtension->ConfigurationDescriptor = FDODeviceExtension->ConfigurationDescriptor;
RtlCopyMemory(&PDODeviceExtension->Capabilities, &FDODeviceExtension->Capabilities, sizeof(DEVICE_CAPABILITIES));
// get stack location
IoStack = IoGetCurrentIrpStackLocation(Irp);
-
+ DPRINT1("[USBCCGP] PnP Minor %x\n", IoStack->MinorFunction);
switch(IoStack->MinorFunction)
{
case IRP_MN_START_DEVICE:
for(Index = 0; Index < FDODeviceExtension->ConfigurationDescriptor->bNumInterfaces; Index++)
{
// get interface descriptor
- InterfaceDescriptor = USBD_ParseConfigurationDescriptor(FDODeviceExtension->ConfigurationDescriptor, Index, 0);
+ InterfaceDescriptor = USBD_ParseConfigurationDescriptorEx(FDODeviceExtension->ConfigurationDescriptor, FDODeviceExtension->ConfigurationDescriptor, Index, 0, -1, -1, -1);
if (InterfaceDescriptor == NULL)
{
//
// failed to find interface descriptor
//
DPRINT1("[USBCCGP] Failed to find interface descriptor index %lu\n", Index);
+ ASSERT(FALSE);
return STATUS_UNSUCCESSFUL;
}
PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor, FirstDescriptor = NULL;
PFDO_DEVICE_EXTENSION FDODeviceExtension;
NTSTATUS Status = STATUS_SUCCESS;
+ PVOID StartPosition;
//
// get device extension
//
// first check if all interfaces belong to the same audio class
//
- for(Index = 0; Index < FDODeviceExtension->ConfigurationDescriptor->bNumInterfaces; Index++)
+ StartPosition = FDODeviceExtension->ConfigurationDescriptor;
+ for(Index = 0; Index < CountInterfaceDescriptors(FDODeviceExtension->ConfigurationDescriptor); Index++)
{
//
// get interface descriptor
//
- InterfaceDescriptor = USBD_ParseConfigurationDescriptorEx(FDODeviceExtension->ConfigurationDescriptor, FDODeviceExtension->ConfigurationDescriptor, Index, -1, -1, -1, -1);
+ InterfaceDescriptor = USBD_ParseConfigurationDescriptorEx(FDODeviceExtension->ConfigurationDescriptor, StartPosition, -1, -1, -1, -1, -1);
+ DPRINT1("Index %lu Descriptor %p\n", Index, InterfaceDescriptor);
+ ASSERT(InterfaceDescriptor);
+
+ //
+ // move to next descriptor
+ //
+ StartPosition = (PVOID)((ULONG_PTR)InterfaceDescriptor + InterfaceDescriptor->bLength);
+
if (InterfaceDescriptor->bInterfaceClass != 0x1)
{
//
IN PUSBC_FUNCTION_DESCRIPTOR FunctionDescriptor,
IN ULONG FunctionDescriptorCount)
{
- ULONG Index;
+ ULONG Index, SubIndex;
DPRINT1("FunctionCount %lu\n", FunctionDescriptorCount);
DPRINT1("CompatibleId %wZ\n", &FunctionDescriptor[Index].CompatibleId);
DPRINT1("FunctionDescription %wZ\n", &FunctionDescriptor[Index].FunctionDescription);
DPRINT1("NumInterfaces %lu\n", FunctionDescriptor[Index].NumberOfInterfaces);
+
+ for(SubIndex = 0; SubIndex < FunctionDescriptor[Index].NumberOfInterfaces; SubIndex++)
+ {
+ DPRINT1(" Interface %p\n", FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]);
+ DPRINT1(" Interface InterfaceNumber %x\n", FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bInterfaceNumber);
+ DPRINT1(" Interface Alternate %x\n", FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bAlternateSetting );
+ }
}
}
\ No newline at end of file
PUSBD_INTERFACE_INFORMATION InterfaceInformation;
ULONG InterfaceInformationCount, Index, InterfaceIndex;
PUSBD_INTERFACE_LIST_ENTRY Entry;
- ULONG NeedSelect;
+ ULONG NeedSelect, FoundInterface;
//
// get current stack location
InterfaceInformation = &Urb->UrbSelectConfiguration.Interface;
Index = 0;
Entry = NULL;
-
+ DPRINT1("Count %x\n", InterfaceInformationCount);
do
{
+ DPRINT1("[USBCCGP] SelectConfiguration Function %x InterfaceNumber %x Alternative %x\n", PDODeviceExtension->FunctionDescriptor->FunctionNumber, InterfaceInformation->InterfaceNumber, InterfaceInformation->AlternateSetting);
+
//
- // search for the interface
+ // search for the interface in the local interface list
//
+ FoundInterface = FALSE;
for(InterfaceIndex = 0; InterfaceIndex < PDODeviceExtension->FunctionDescriptor->NumberOfInterfaces; InterfaceIndex++)
{
- if (PDODeviceExtension->InterfaceList[InterfaceIndex].Interface->InterfaceNumber == InterfaceInformation->InterfaceNumber)
+ if (PDODeviceExtension->FunctionDescriptor->InterfaceDescriptorList[InterfaceIndex]->bInterfaceNumber == InterfaceInformation->InterfaceNumber)
{
// found interface entry
- Entry = &PDODeviceExtension->InterfaceList[InterfaceIndex];
+ FoundInterface = TRUE;
break;
}
}
- if (!Entry || Entry->InterfaceDescriptor)
+ if (!FoundInterface)
{
//
// invalid parameter
//
+ DPRINT1("InterfaceInformation InterfaceNumber %x Alternative %x NumberOfPipes %x not found\n", InterfaceInformation->InterfaceNumber, InterfaceInformation->AlternateSetting, InterfaceInformation->NumberOfPipes);
ASSERT(FALSE);
return STATUS_INVALID_PARAMETER;
}
+ //
+ // now query the total interface list
+ //
+ Entry = NULL;
+ for(InterfaceIndex = 0; InterfaceIndex < PDODeviceExtension->InterfaceListCount; InterfaceIndex++)
+ {
+ if (PDODeviceExtension->InterfaceList[InterfaceIndex].Interface->InterfaceNumber == InterfaceInformation->InterfaceNumber)
+ {
+ //
+ // found entry
+ //
+ Entry = &PDODeviceExtension->InterfaceList[InterfaceIndex];
+ }
+ }
+
+ //
+ // sanity check
+ //
+ ASSERT(Entry);
+ if (!Entry)
+ {
+ //
+ // corruption detected
+ //
+ KeBugCheck(0);
+ }
+
NeedSelect = FALSE;
if (Entry->InterfaceDescriptor->bAlternateSetting == InterfaceInformation->AlternateSetting)
{
- for(InterfaceIndex = 0; Entry->InterfaceDescriptor->bNumEndpoints; InterfaceIndex++)
+ for(InterfaceIndex = 0; InterfaceIndex < Entry->InterfaceDescriptor->bNumEndpoints; InterfaceIndex++)
{
if (InterfaceInformation->Pipes[InterfaceIndex].MaximumTransferSize != Entry->Interface->Pipes[InterfaceIndex].MaximumTransferSize)
{
else
{
//
- // need select
+ // need select as the interface number differ
//
NeedSelect = TRUE;
}
Index++;
}while(Index < InterfaceInformationCount);
+ //
+ // store configuration handle
+ //
+ Urb->UrbSelectConfiguration.ConfigurationHandle = PDODeviceExtension->ConfigurationHandle;
+
+ DPRINT1("[USBCCGP] SelectConfiguration Function %x Completed\n", PDODeviceExtension->FunctionDescriptor->FunctionNumber);
+
+ //
+ // done
+ //
return STATUS_SUCCESS;
}
return Status;
}
}
-
-
-
+ else if (Urb->UrbHeader.Function == URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE)
+ {
+ DPRINT1("URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE\n");
+ IoSkipCurrentIrpStackLocation(Irp);
+ Status = IoCallDriver(PDODeviceExtension->NextDeviceObject, Irp);
+ DPRINT1("URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE Status %x\n", Status);
+ return Status;
+ }
}
{
// initialize driver object
+ DPRINT1("[USBCCGP] DriverEntry\n");
DriverObject->DriverExtension->AddDevice = USBCCGP_AddDevice;
DriverObject->MajorFunction[IRP_MJ_CREATE] = USBCCGP_Dispatch;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = USBCCGP_Dispatch;