diff options
| author | 2014-11-10 16:58:10 +0100 | |
|---|---|---|
| committer | 2014-11-11 13:52:52 +0100 | |
| commit | 4da37c1e130e32c4bbad13de7461e0612ca15597 (patch) | |
| tree | af7e129ba4668fbc91c9cf567027e517503725f9 /src/usb-linux.c | |
| parent | 07c5634cef09a913d6307de5b0edd6e73aaebfb3 (diff) | |
| download | usbmuxd-4da37c1e130e32c4bbad13de7461e0612ca15597.tar.gz usbmuxd-4da37c1e130e32c4bbad13de7461e0612ca15597.tar.bz2 | |
Get USB speed for device and use it for device attached client message
Diffstat (limited to 'src/usb-linux.c')
| -rw-r--r-- | src/usb-linux.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/usb-linux.c b/src/usb-linux.c index 8acbace..9878f41 100644 --- a/src/usb-linux.c +++ b/src/usb-linux.c | |||
| @@ -56,6 +56,7 @@ struct usb_device { | |||
| 56 | struct collection rx_xfers; | 56 | struct collection rx_xfers; |
| 57 | struct collection tx_xfers; | 57 | struct collection tx_xfers; |
| 58 | int wMaxPacketSize; | 58 | int wMaxPacketSize; |
| 59 | uint64_t speed; | ||
| 59 | }; | 60 | }; |
| 60 | 61 | ||
| 61 | static struct collection device_list; | 62 | static struct collection device_list; |
| @@ -425,6 +426,7 @@ int usb_discover(void) | |||
| 425 | usbdev->address = address; | 426 | usbdev->address = address; |
| 426 | usbdev->vid = devdesc.idVendor; | 427 | usbdev->vid = devdesc.idVendor; |
| 427 | usbdev->pid = devdesc.idProduct; | 428 | usbdev->pid = devdesc.idProduct; |
| 429 | usbdev->speed = 480000000; | ||
| 428 | usbdev->dev = handle; | 430 | usbdev->dev = handle; |
| 429 | usbdev->alive = 1; | 431 | usbdev->alive = 1; |
| 430 | usbdev->wMaxPacketSize = libusb_get_max_packet_size(dev, usbdev->ep_out); | 432 | usbdev->wMaxPacketSize = libusb_get_max_packet_size(dev, usbdev->ep_out); |
| @@ -435,6 +437,25 @@ int usb_discover(void) | |||
| 435 | usbmuxd_log(LL_INFO, "Using wMaxPacketSize=%d for device %d-%d", usbdev->wMaxPacketSize, usbdev->bus, usbdev->address); | 437 | usbmuxd_log(LL_INFO, "Using wMaxPacketSize=%d for device %d-%d", usbdev->wMaxPacketSize, usbdev->bus, usbdev->address); |
| 436 | } | 438 | } |
| 437 | 439 | ||
| 440 | switch (libusb_get_device_speed(dev)) { | ||
| 441 | case LIBUSB_SPEED_LOW: | ||
| 442 | usbdev->speed = 1500000; | ||
| 443 | break; | ||
| 444 | case LIBUSB_SPEED_FULL: | ||
| 445 | usbdev->speed = 12000000; | ||
| 446 | break; | ||
| 447 | case LIBUSB_SPEED_SUPER: | ||
| 448 | usbdev->speed = 5000000000; | ||
| 449 | break; | ||
| 450 | case LIBUSB_SPEED_HIGH: | ||
| 451 | case LIBUSB_SPEED_UNKNOWN: | ||
| 452 | default: | ||
| 453 | usbdev->speed = 480000000; | ||
| 454 | break; | ||
| 455 | } | ||
| 456 | |||
| 457 | usbmuxd_log(LL_INFO, "USB Speed is %g MBit/s for device %d-%d", (double)(usbdev->speed / 1000000.0), usbdev->bus, usbdev->address); | ||
| 458 | |||
| 438 | collection_init(&usbdev->tx_xfers); | 459 | collection_init(&usbdev->tx_xfers); |
| 439 | collection_init(&usbdev->rx_xfers); | 460 | collection_init(&usbdev->rx_xfers); |
| 440 | 461 | ||
| @@ -510,6 +531,14 @@ uint16_t usb_get_pid(struct usb_device *dev) | |||
| 510 | return dev->pid; | 531 | return dev->pid; |
| 511 | } | 532 | } |
| 512 | 533 | ||
| 534 | uint64_t usb_get_speed(struct usb_device *dev) | ||
| 535 | { | ||
| 536 | if (!dev->dev) { | ||
| 537 | return 0; | ||
| 538 | } | ||
| 539 | return dev->speed; | ||
| 540 | } | ||
| 541 | |||
| 513 | void usb_get_fds(struct fdlist *list) | 542 | void usb_get_fds(struct fdlist *list) |
| 514 | { | 543 | { |
| 515 | const struct libusb_pollfd **usbfds; | 544 | const struct libusb_pollfd **usbfds; |
