2

libusb provides libusb_set_interface_alt_setting() method for providing alternate setting for an interface. My question is what is the meaning of having alternate setting for a interface.

if ((ret = libusb_claim_interface(handle, interface))  == LIBUSB_SUCCESS)
       {
           printf("%s: interface %d claimed.\n", __FUNCTION__, interface);

           /* Set alternate interface */
           if ((ret = libusb_set_interface_alt_setting(handle, interface, alternate)) == LIBUSB_SUCCESS)
           {
              printf("%s: alternate interface %d set.\n", __FUNCTION__, alternate);
              return CIMAX_USB_NO_ERROR;
           }
           else
             printf("%s: setting alternate interface %d failed (%s)!\n", __FUNCTION__, alternate, libusb_error_name(ret));
        }
        else
          printf("%s: claim interface %d failed (%s)!\n", __FUNCTION__, interface, libusb_error_name(ret));
Sourav Singh
  • 99
  • 2
  • 6

2 Answers2

1

USB devices support multiple interfaces in a single device. This API sets the active alternate setting of the current interface as per the function user space application’s requirement. Internally, it uses IOCTL_USB_SETINTF to communicate the application’s requirement to the usbcore module of the Linux USB host framework.

0

Alternate interface setting is for multifunction devices.To use a particular function or an interface, you need to select interface and an associated alternate setting.

For example a video camera needs initialization of two interface settings one for audio and another for video.

Dayal rai
  • 6,548
  • 22
  • 29