summaryrefslogtreecommitdiffstats
path: root/src/usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/usb.c')
-rw-r--r--src/usb.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/usb.c b/src/usb.c
index 0a5a46c..d0e9afc 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -394,7 +394,7 @@ static struct usb_device* find_device(int bus, int address)
394/// @param dev 394/// @param dev
395/// @param usbdev 395/// @param usbdev
396/// @param handle 396/// @param handle
397/// @return 0 - undetermined, 1 - initial, 2 - valeria, 3 - cdc_ncm 397/// @return 0 - undetermined, 1 - initial, 2 - valeria, 3 - cdc_ncm, 4 - usbeth+cdc_ncm, 5 - cdc_ncm direct
398static int guess_mode(struct libusb_device* dev, struct usb_device *usbdev) 398static int guess_mode(struct libusb_device* dev, struct usb_device *usbdev)
399{ 399{
400 int res, j; 400 int res, j;
@@ -404,11 +404,21 @@ static int guess_mode(struct libusb_device* dev, struct usb_device *usbdev)
404 int bus = usbdev->bus; 404 int bus = usbdev->bus;
405 int address = usbdev->address; 405 int address = usbdev->address;
406 406
407 if(devdesc.bNumConfigurations == 1) {
408 // CDC-NCM Direct
409 return 5;
410 }
411
407 if(devdesc.bNumConfigurations <= 4) { 412 if(devdesc.bNumConfigurations <= 4) {
408 // Assume this is initial mode 413 // Assume this is initial mode
409 return 1; 414 return 1;
410 } 415 }
411 416
417 if(devdesc.bNumConfigurations == 6) {
418 // USB Ethernet + CDC-NCM
419 return 4;
420 }
421
412 if(devdesc.bNumConfigurations != 5) { 422 if(devdesc.bNumConfigurations != 5) {
413 // No known modes with more then 5 configurations 423 // No known modes with more then 5 configurations
414 return 0; 424 return 0;
@@ -699,7 +709,7 @@ static void get_mode_cb(struct libusb_transfer* transfer)
699 709
700 // Response is 3:3:3:0 for initial mode, 5:3:3:0 otherwise. 710 // Response is 3:3:3:0 for initial mode, 5:3:3:0 otherwise.
701 usbmuxd_log(LL_INFO, "Received response %i:%i:%i:%i for get_mode request for device %i-%i", data[0], data[1], data[2], data[3], context->bus, context->address); 711 usbmuxd_log(LL_INFO, "Received response %i:%i:%i:%i for get_mode request for device %i-%i", data[0], data[1], data[2], data[3], context->bus, context->address);
702 if(desired_mode >= 1 && desired_mode <= 3 && 712 if(desired_mode >= 1 && desired_mode <= 5 &&
703 guessed_mode > 0 && // do not switch mode if guess failed 713 guessed_mode > 0 && // do not switch mode if guess failed
704 guessed_mode != desired_mode) { 714 guessed_mode != desired_mode) {
705 usbmuxd_log(LL_WARNING, "Switching device %i-%i mode to %i", context->bus, context->address, desired_mode); 715 usbmuxd_log(LL_WARNING, "Switching device %i-%i mode to %i", context->bus, context->address, desired_mode);