diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/client.c | 3 | ||||
| -rw-r--r-- | src/device.c | 2 | ||||
| -rw-r--r-- | src/device.h | 1 | ||||
| -rw-r--r-- | src/usb-linux.c | 29 | ||||
| -rw-r--r-- | src/usb.h | 1 |
5 files changed, 34 insertions, 2 deletions
diff --git a/src/client.c b/src/client.c index 403340a..268c8b9 100644 --- a/src/client.c +++ b/src/client.c | |||
| @@ -306,8 +306,7 @@ static plist_t create_device_attached_plist(struct device_info *dev) | |||
| 306 | plist_dict_set_item(dict, "MessageType", plist_new_string("Attached")); | 306 | plist_dict_set_item(dict, "MessageType", plist_new_string("Attached")); |
| 307 | plist_dict_set_item(dict, "DeviceID", plist_new_uint(dev->id)); | 307 | plist_dict_set_item(dict, "DeviceID", plist_new_uint(dev->id)); |
| 308 | plist_t props = plist_new_dict(); | 308 | plist_t props = plist_new_dict(); |
| 309 | // TODO: get current usb speed | 309 | plist_dict_set_item(props, "ConnectionSpeed", plist_new_uint(dev->speed)); |
| 310 | plist_dict_set_item(props, "ConnectionSpeed", plist_new_uint(480000000)); | ||
| 311 | plist_dict_set_item(props, "ConnectionType", plist_new_string("USB")); | 310 | plist_dict_set_item(props, "ConnectionType", plist_new_string("USB")); |
| 312 | plist_dict_set_item(props, "DeviceID", plist_new_uint(dev->id)); | 311 | plist_dict_set_item(props, "DeviceID", plist_new_uint(dev->id)); |
| 313 | plist_dict_set_item(props, "LocationID", plist_new_uint(dev->location)); | 312 | plist_dict_set_item(props, "LocationID", plist_new_uint(dev->location)); |
diff --git a/src/device.c b/src/device.c index e5377cc..ddd1d4a 100644 --- a/src/device.c +++ b/src/device.c | |||
| @@ -572,6 +572,7 @@ static void device_version_input(struct mux_device *dev, struct version_header * | |||
| 572 | info.location = usb_get_location(dev->usbdev); | 572 | info.location = usb_get_location(dev->usbdev); |
| 573 | info.serial = usb_get_serial(dev->usbdev); | 573 | info.serial = usb_get_serial(dev->usbdev); |
| 574 | info.pid = usb_get_pid(dev->usbdev); | 574 | info.pid = usb_get_pid(dev->usbdev); |
| 575 | info.speed = usb_get_speed(dev->usbdev); | ||
| 575 | preflight_worker_device_add(&info); | 576 | preflight_worker_device_add(&info); |
| 576 | } | 577 | } |
| 577 | 578 | ||
| @@ -924,6 +925,7 @@ int device_get_list(int include_hidden, struct device_info **devices) | |||
| 924 | p->serial = usb_get_serial(dev->usbdev); | 925 | p->serial = usb_get_serial(dev->usbdev); |
| 925 | p->location = usb_get_location(dev->usbdev); | 926 | p->location = usb_get_location(dev->usbdev); |
| 926 | p->pid = usb_get_pid(dev->usbdev); | 927 | p->pid = usb_get_pid(dev->usbdev); |
| 928 | p->speed = usb_get_speed(dev->usbdev); | ||
| 927 | count++; | 929 | count++; |
| 928 | p++; | 930 | p++; |
| 929 | } | 931 | } |
diff --git a/src/device.h b/src/device.h index e731b36..85703e4 100644 --- a/src/device.h +++ b/src/device.h | |||
| @@ -28,6 +28,7 @@ struct device_info { | |||
| 28 | const char *serial; | 28 | const char *serial; |
| 29 | uint32_t location; | 29 | uint32_t location; |
| 30 | uint16_t pid; | 30 | uint16_t pid; |
| 31 | uint64_t speed; | ||
| 31 | }; | 32 | }; |
| 32 | 33 | ||
| 33 | void device_data_input(struct usb_device *dev, unsigned char *buf, uint32_t length); | 34 | void device_data_input(struct usb_device *dev, unsigned char *buf, uint32_t length); |
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; |
| @@ -54,6 +54,7 @@ void usb_shutdown(void); | |||
| 54 | const char *usb_get_serial(struct usb_device *dev); | 54 | const char *usb_get_serial(struct usb_device *dev); |
| 55 | uint32_t usb_get_location(struct usb_device *dev); | 55 | uint32_t usb_get_location(struct usb_device *dev); |
| 56 | uint16_t usb_get_pid(struct usb_device *dev); | 56 | uint16_t usb_get_pid(struct usb_device *dev); |
| 57 | uint64_t usb_get_speed(struct usb_device *dev); | ||
| 57 | void usb_get_fds(struct fdlist *list); | 58 | void usb_get_fds(struct fdlist *list); |
| 58 | int usb_get_timeout(void); | 59 | int usb_get_timeout(void); |
| 59 | int usb_send(struct usb_device *dev, const unsigned char *buf, int length); | 60 | int usb_send(struct usb_device *dev, const unsigned char *buf, int length); |
