Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

Isochronous endpoints MSFT UDE

bojan_janjicbojan_janjic Member Posts: 1
edited January 10 in NTDEV

I am writing USB device emulator using Microsoft Usb Device Emulation framework.

So far I have implemented support for interrupt and bulk transfers, but isochronous transfers just do not work.

Driver sets up dynamic endpoints (UdecxUsbDeviceInitSetEndpointsType is called with UdecxEndpointTypeDynamic). So when virtual USB device is plugged (UdecxUsbDevicePlugIn), UDE framework calls callback for endpoint creation. There I create and associate queue with endpoint:

Here is a part of the code:
...
WDF_IO_QUEUE_CONFIG queueConfig;
WDF_IO_QUEUE_CONFIG_INIT(&queueConfig, WdfIoQueueDispatchSequential);
queueConfig.EvtIoInternalDeviceControl = OnTestIoInternalControl;
queueConfig.EvtIoCanceledOnQueue = OnTestCancelled;
queueConfig.EvtIoDefault = OnTestDefault;
queueConfig.EvtIoDeviceControl = OnTestIoControl;
queueConfig.EvtIoRead = OnTestRead;
queueConfig.EvtIoResume = OnTestResume;
queueConfig.EvtIoStop = OnTestStop;
queueConfig.EvtIoWrite = OnTestWrite;

WdfIoQueueCreate(hubDevice, &queueConfig, &queueAttributes, &queue);

...

UdecxUsbEndpointCreate(&endpointInit, &endpointAttributes, &udecxEndpoint);
UdecxUsbEndpointSetWdfIoQueue(udecxEndpoint, queue);

Note: I have just extracted part of the code, to make this post as short as possible

For bulk and interrupt endpoints it works fine, but for isochronous endpoint no "Test" callbacks are called. From log I can see that UDE has created endpoint and queue. USBVIEW shows opened pipe for isochronous endpoint, but when I try to play some music (tested virtual USB is audio device) it just does not trigger any callbacks that I could use to transfer data.

Does anybody know is isochronous transfers supported at all by Microsoft UDE?
If so, is there any additional setup required to make this work?

Comments

  • Benjamin_HöglingerBenjamin_Höglinger Member - All Emails Posts: 15

    Yes, UDE supports isochronous transfers but you need to be careful of certain pitfalls with the descriptors. Can you post your Configuration Descriptor here?

  • Andreas_GraefeAndreas_Graefe Member Posts: 1

    (Sorry for double or triple posting, somehow my post was deleted when I tried to edit)

    I have a similar issue with an emulated audio device. Communication with default control endpoint is OK, but the ISO endpoint's callback is only called once, then never again. Looks like something is blocking the queue, but I have no idea what.

    Here is the configuration descriptor I use. This should be a simple stereo USB speaker with 16bit / 48 kHz plus volume and mute controls.

    // Configuration Descriptor Type
    0x9,                              // Descriptor Size
    USB_CONFIGURATION_DESCRIPTOR_TYPE, // Configuration Descriptor Type
    0x76, 0x00,                        // Length of this descriptor and all sub descriptors
    0x02,                              // Number of interfaces
    0x01,                              // Configuration number
    0x00,                              // Configuration string index
    0xA0,                              // Config characteristics - bus powered
    0x32,                              // Max power consumption of device (in 2mA unit) : 0 ma
    
    // Interface association descriptor
    0x08,                                      // Descriptor size
    USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE, // Descriptor Type (Interface Association)
    0x00,                                      // bFirstInterface (number of first interface of the collection)
    0x02,                                      // bInterfaceCount (number of interfaces in the collection)
    USB_DEVICE_CLASS_AUDIO,                    // bFunctionClass (Audio)
    0x01,                                      // bFunctionSubclass (Audio)
    0x00,                                      // bFunctionProtocol (None)
    0x00,                                      // iFunction
    
    // Audio Interface descriptor (Control)
    0x09,                                     // Descriptor size
    USB_INTERFACE_DESCRIPTOR_TYPE,            // Descriptor type (Interface descriptor)
    0x00,                                     // bInterfaceNumber
    0x00,                                     // bAlternateSetting
    0x00,                                     // bNumEndpoints
    USB_DEVICE_CLASS_AUDIO,                   // bInterfaceClass (Audio)
    0x01,                                     // bInterfaceSubClass (Control)
    0x00,                                     // bInterfaceProtocol 
    0x00,                                     // iInterface
    
    // AudioControl Interface Descriptor (Header)
    0x09,                                     // Descriptor size
    0x24,                                     // bDescriptorType (CS Interface)
    0x01,                                     // bDescriptorSubType (HEADER)
    0x00, 0x01,                               // bdcADC
    0x28, 0x00,                               // wTotalLength
    0x01,                                     // bInCollection
    0x01,                                     // baInterfaceNr
    
    // AudioControl Interface Descriptor (Input Terminal)
    0x0C,                                     // Descriptor size
    0x24,                                     // bDescriptorType (CS Interface)
    0x02,                                     // bDescriptorSubType (Input Terminal)
    0x01,                                     // bTerminalID
    0x01, 0x01,                               // wTerminalType (USB Streaming)
    0x00,                                     // bAssocTerminal
    0x02,                                     // bNrChannels
    0x03, 0x00,                               // wChannelConfig
    0x00,                                     // iChannelNames
    0x00,                                     // iTerminal
    
    // AudioControl Interface Descriptor (Feature Unit)
    0x0A,                                     // Descriptor size
    0x24,                                     // bDescriptorType (CS Interface)
    0x06,                                     // bDescriptorSubType (Feature Unit)
    0x02,                                     // bUnitID
    0x01,                                     // bSourceID
    0x01,                                     // bControlSize
    0x03,                                     // bmaControls (Mute, Volume)
    0x00,                                     // bmaControls (1)
    0x00,                                     // bmaControls (2)
    0x00,                                     // iFeature
    
    // AudioControl Interface Descriptor (Output Terminal)
    0x09,                                     // Descriptor size
    0x24,                                     // bDescriptorType (Class specific interface)
    0x03,                                     // bDescriptorSubType (Output Terminal)
    0x03,                                     // bTerminalID
    0x01, 0x03,                               // wTerminalType (Speaker)
    0x00,                                     // bAssocTerminal
    0x02,                                     // bSourceID
    0x00,                                     // iTerminal
    
    // Audio Interface  descriptor (Streaming)
    0x9,                                      // Descriptor size
    USB_INTERFACE_DESCRIPTOR_TYPE,            // Interface Association Descriptor Type
    0x01,                                     // bInterfaceNumber
    0x00,                                     // bAlternateSetting
    0x00,                                     // bNumEndpoints
    0x01,                                     // bInterfaceClass (Audio)
    0x02,                                     // bInterfaceSubClass (Streaming)
    0x00,                                     // bInterfaceProtocol 
    0x00,                                     // iInterface
    
    // Audio Interface  descriptor (Streaming)
    0x9,                                      // Descriptor size
    USB_INTERFACE_DESCRIPTOR_TYPE,            // Interface Association Descriptor Type
    0x01,                                     // bInterfaceNumber
    0x01,                                     // bAlternateSetting
    0x01,                                     // bNumEndpoints
    0x01,                                     // bInterfaceClass (Audio)
    0x02,                                     // bInterfaceSubClass (Streaming)
    0x00,                                     // bInterfaceProtocol 
    0x00,                                     // iInterface
    
    // Audio Streaming interface descriptor
    0x07,                                     // Descriptor size
    0x24,                                     // Descriptor type 
    0x1,                                      // bDescriptorSubType
    0x1,                                      // bTerminalLink
    0x0,                                      // bDelay
    0x01, 0x00,                               // wFormatTag (PCM)
    
    // Audio Streaming interface descriptor
    0x0B,                                      // Descriptor size
    0x24,                                      // Descriptor type 
    0x02,                                      // Descriptor subtype (FORMAT_TYPE)
    0x01,                                      // bFormatType
    0x02,                                      // bNrChannels
    0x02,                                      // bSubFrameSize
    0x10,                                      // bBitResolution (16)
    0x01,                                      // bSamFreqType
    0x80, 0xBB, 0x00,                          // tSamFreq 48000
    
    // Endpoint Descriptor :
    0x9,                                       // Descriptor size
    USB_ENDPOINT_DESCRIPTOR_TYPE,              // Descriptor type (endpoint)
    0x01,                   // Endpoint address
    0x9,                                       // bmAttributes (Iso, Adaptive, Data)
    0xc0, 0x00,                                // wMaxPacketSize (192 bytes)
    0x4,                                       // bInterval (8 microframes = 1 millisecond)
    0x0,                                       // bRefresh
    0x0,                                       // bSynchAddress
    
    // AudioStreaming Endpoint descriptor
    0x7,                                       // bLength
    0x25,                                      // bDescriptorType
    0x1,                                       // bDescriptorSubType (EP General)
    0x00,                                      // bmAttributes
    0x0,                                       // bLockDelayUnits
    0x00, 0x00                                 // wLockDelay
    
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,218

    How are you testing this? In battle, using a live audio app?

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 24 January 2022 Live, Online
Internals & Software Drivers 7 February 2022 Live, Online
Kernel Debugging 21 March 2022 Live, Online
Developing Minifilters 23 May 2022 Live, Online