Date: Thu, 12 Apr 2012 18:06:30 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r234193 - head/lib/libusb Message-ID: <201204121806.q3CI6Ugw040155@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Thu Apr 12 18:06:30 2012 New Revision: 234193 URL: http://svn.freebsd.org/changeset/base/234193 Log: Add missing LibUSB 1.0 API function. Reported by: lme @ MFC after: 1 week Modified: head/lib/libusb/Makefile head/lib/libusb/libusb.3 head/lib/libusb/libusb.h head/lib/libusb/libusb10.c Modified: head/lib/libusb/Makefile ============================================================================== --- head/lib/libusb/Makefile Thu Apr 12 17:59:17 2012 (r234192) +++ head/lib/libusb/Makefile Thu Apr 12 18:06:30 2012 (r234193) @@ -48,6 +48,7 @@ MLINKS += libusb.3 libusb_get_bus_number MLINKS += libusb.3 libusb_get_device_address.3 MLINKS += libusb.3 libusb_get_device_speed.3 MLINKS += libusb.3 libusb_get_max_packet_size.3 +MLINKS += libusb.3 libusb_get_max_iso_packet_size.3 MLINKS += libusb.3 libusb_ref_device.3 MLINKS += libusb.3 libusb_unref_device.3 MLINKS += libusb.3 libusb_open.3 Modified: head/lib/libusb/libusb.3 ============================================================================== --- head/lib/libusb/libusb.3 Thu Apr 12 17:59:17 2012 (r234192) +++ head/lib/libusb/libusb.3 Thu Apr 12 18:06:30 2012 (r234193) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 25, 2012 +.Dd April 12, 2012 .Dt LIBUSB 3 .Os .Sh NAME @@ -118,6 +118,12 @@ LIBUSB_SPEED_UNKNOWN is returned in case Returns the wMaxPacketSize value on success, LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist and LIBUSB_ERROR_OTHERS on other failure. .Pp +.Ft int +.Fn libusb_get_max_iso_packet_size "libusb_device *dev" "unsigned char endpoint" +Returns the packet size multiplied by the packet multiplier on success, +LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist and +LIBUSB_ERROR_OTHERS on other failure. +.Pp .Ft libusb_device * .Fn libusb_ref_device "libusb_device *dev" Increment the reference counter of the device Modified: head/lib/libusb/libusb.h ============================================================================== --- head/lib/libusb/libusb.h Thu Apr 12 17:59:17 2012 (r234192) +++ head/lib/libusb/libusb.h Thu Apr 12 18:06:30 2012 (r234193) @@ -371,6 +371,7 @@ uint8_t libusb_get_device_address(libusb 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); +int libusb_get_max_iso_packet_size(libusb_device * dev, uint8_t endpoint); libusb_device *libusb_ref_device(libusb_device * dev); void libusb_unref_device(libusb_device * dev); int libusb_open(libusb_device * dev, libusb_device_handle ** devh); Modified: head/lib/libusb/libusb10.c ============================================================================== --- head/lib/libusb/libusb10.c Thu Apr 12 17:59:17 2012 (r234192) +++ head/lib/libusb/libusb10.c Thu Apr 12 18:06:30 2012 (r234193) @@ -331,6 +331,30 @@ out: return (ret); } +int +libusb_get_max_iso_packet_size(libusb_device *dev, uint8_t endpoint) +{ + int multiplier; + int ret; + + ret = libusb_get_max_packet_size(dev, endpoint); + + switch (libusb20_dev_get_speed(dev->os_priv)) { + case LIBUSB20_SPEED_LOW: + case LIBUSB20_SPEED_FULL: + break; + default: + if (ret > -1) { + multiplier = (1 + ((ret >> 11) & 3)); + if (multiplier > 3) + multiplier = 3; + ret = (ret & 0x7FF) * multiplier; + } + break; + } + return (ret); +} + libusb_device * libusb_ref_device(libusb_device *dev) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204121806.q3CI6Ugw040155>