Vendor Interface in UVC - KBA218335

Version: **

 

Question:

How do you send vendor requests to a UVC device?

 

Answer:

To send vendor commands from the Control Center, a vendor interface should be created in the UVC descriptor file. An endpoint may or may not be associated with this interface. After enumeration, this vendor interface must be bound with the cyusb3 driver so that it appears in the Control Center.

The following modifications are required in the AN75779 example project, to create a vendor interface:

  1. In the UVC descriptor file (cyfxuvcdscr.c), in CyFxUSBHSConfigDscr[ ] and CyFxUSBSSConfigDscr[ ]   
        
    1. Update the length of the descriptor and all sub-descriptor fields from D9 to E2 (in CyFxUSBSSConfigDscr) and CD to D6 (in CyFxUSBHSConfigDscr).
    2.   
    3. Change the number of interfaces from 2 to 3. 
    4.   
    5. After the Endpoint Descriptor for BULK Streaming Video Data (in CyFxUSBHSConfigDscr) and Super Speed Endpoint Companion Descriptor for BULK endpoint (in CyFxUSBSSConfigDscr), include the following:    

      0x09,                           /* Descriptor size */
           CY_U3P_USB_INTRFC_DESCR,        /* Interface descriptor type */
           0x02,                           /* Interface number */
           0x00,                         /* Alternate setting number */
           0x00,                           /* Number of end points */
           0xFF,                           /* Interface class */
           0x00,                           /* Interface sub class */
           0x00,                           /* Interface protocol code */
           0x00                            /* Interface descriptor string index */

        
    6.  
  2. In the CyFxUVCApplnUSBSetupCB() function of the uvc.c file, before the switch case for UVC Class Requests include the following template to handle vendor requests: if ((bmReqType & CY_U3P_USB_TYPE_MASK) == 
                CY_U3P_USB_VENDOR_RQT)
            {
               switch(bRequest)
               {
                     case 0x76:
                         CyU3PDebugPrint(2, "Vendor command received…\n");
                                      /* Implement the code as per the functionality required*/
                            CyU3PUsbAckSetup();
                         return CyTrue;
                     default:
                         return CyFalse;
               }
           }