diff options
author | hselasky <hselasky@FreeBSD.org> | 2011-08-16 08:34:16 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2011-08-16 08:34:16 +0000 |
commit | 4b6d77c49fb3e3ead2658ade7f76b8820c79cf99 (patch) | |
tree | 686e0853904fe214dccaf7c66fb986b3eee489a5 /lib/libusb | |
parent | e2a937e93da51c5a2a48b120f3084e54b72a467a (diff) | |
download | FreeBSD-src-4b6d77c49fb3e3ead2658ade7f76b8820c79cf99.zip FreeBSD-src-4b6d77c49fb3e3ead2658ade7f76b8820c79cf99.tar.gz |
Add missing function to get device speed to the LibUSB v1.0 API.
MFC after: 1 week
Approved by: re (kib)
Diffstat (limited to 'lib/libusb')
-rw-r--r-- | lib/libusb/libusb.h | 9 | ||||
-rw-r--r-- | lib/libusb/libusb10.c | 21 |
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h index 0c9e50f..bbde475 100644 --- a/lib/libusb/libusb.h +++ b/lib/libusb/libusb.h @@ -151,6 +151,14 @@ enum libusb_error { LIBUSB_ERROR_OTHER = -99, }; +enum libusb_speed { + LIBUSB_SPEED_UNKNOWN = 0, + LIBUSB_SPEED_LOW = 1, + LIBUSB_SPEED_FULL = 2, + LIBUSB_SPEED_HIGH = 3, + LIBUSB_SPEED_SUPER = 4, +}; + enum libusb_transfer_status { LIBUSB_TRANSFER_COMPLETED, LIBUSB_TRANSFER_ERROR, @@ -304,6 +312,7 @@ ssize_t libusb_get_device_list(libusb_context * ctx, libusb_device *** list); void libusb_free_device_list(libusb_device ** list, int unref_devices); uint8_t libusb_get_bus_number(libusb_device * dev); uint8_t libusb_get_device_address(libusb_device * dev); +enum libusb_speed libusb_get_device_speed(libusb_device * dev); int libusb_clear_halt(libusb_device_handle *devh, uint8_t endpoint); int libusb_get_max_packet_size(libusb_device * dev, uint8_t endpoint); libusb_device *libusb_ref_device(libusb_device * dev); diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c index 3ecba58..d11f631 100644 --- a/lib/libusb/libusb10.c +++ b/lib/libusb/libusb10.c @@ -272,6 +272,27 @@ libusb_get_device_address(libusb_device *dev) return (libusb20_dev_get_address(dev->os_priv)); } +enum libusb_speed +libusb_get_device_speed(libusb_device *dev) +{ + if (dev == NULL) + return (0); /* should not happen */ + + switch (libusb20_dev_get_speed(dev->os_priv)) { + case LIBUSB20_SPEED_LOW: + return (LIBUSB_SPEED_LOW); + case LIBUSB20_SPEED_FULL: + return (LIBUSB_SPEED_FULL); + case LIBUSB20_SPEED_HIGH: + return (LIBUSB_SPEED_HIGH); + case LIBUSB20_SPEED_SUPER: + return (LIBUSB_SPEED_SUPER); + default: + break; + } + return (LIBUSB_SPEED_UNKNOWN); +} + int libusb_get_max_packet_size(libusb_device *dev, uint8_t endpoint) { |