diff options
-rw-r--r-- | src/usb.c | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -395,7 +395,31 @@ static int usb_device_add(libusb_device* dev) | |||
395 | 395 | ||
396 | int desired_config = devdesc.bNumConfigurations; | 396 | int desired_config = devdesc.bNumConfigurations; |
397 | if (desired_config > 4) { | 397 | if (desired_config > 4) { |
398 | desired_config = 4; | 398 | if (desired_config > 5) { |
399 | usbmuxd_log(LL_ERROR, "Device %d-%d has more than 5 configurations, but usbmuxd doesn't support that. Choosing configuration 5 instead.", bus, address); | ||
400 | desired_config = 5; | ||
401 | } | ||
402 | /* verify if the configuration 5 is actually usable */ | ||
403 | do { | ||
404 | struct libusb_config_descriptor *config; | ||
405 | const struct libusb_interface_descriptor *intf; | ||
406 | if (libusb_get_config_descriptor_by_value(dev, 5, &config) != 0) { | ||
407 | usbmuxd_log(LL_WARNING, "Device %d-%d: Failed to get config descriptor for configuration 5, choosing configuration 4 instead.", bus, address); | ||
408 | desired_config = 4; | ||
409 | break; | ||
410 | } | ||
411 | if (config->bNumInterfaces != 3) { | ||
412 | usbmuxd_log(LL_WARNING, "Device %d-%d: Ignoring possibly bad configuration 5, choosing configuration 4 instead.", bus, address); | ||
413 | desired_config = 4; | ||
414 | break; | ||
415 | } | ||
416 | intf = &config->interface[2].altsetting[0]; | ||
417 | if (intf->bInterfaceClass != 0xFF || intf->bInterfaceSubClass != 0x2A || intf->bInterfaceProtocol != 0xFF) { | ||
418 | usbmuxd_log(LL_WARNING, "Device %d-%d: Ignoring possibly bad configuration 5, choosing configuration 4 instead.", bus, address); | ||
419 | desired_config = 4; | ||
420 | break; | ||
421 | } | ||
422 | } while (0); | ||
399 | } | 423 | } |
400 | int current_config = 0; | 424 | int current_config = 0; |
401 | if((res = libusb_get_configuration(handle, ¤t_config)) != 0) { | 425 | if((res = libusb_get_configuration(handle, ¤t_config)) != 0) { |