Add missing LibUSB 1.0 API function.

Reported by:	lme @
MFC after:	1 week
This commit is contained in:
Hans Petter Selasky 2012-04-12 18:06:30 +00:00
parent 0cc457b000
commit 748205a370
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=234193
4 changed files with 33 additions and 1 deletions

View File

@ -48,6 +48,7 @@ MLINKS += libusb.3 libusb_get_bus_number.3
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

View File

@ -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 of unknown wire speed.
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

View File

@ -371,6 +371,7 @@ 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);
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);

View File

@ -331,6 +331,30 @@ libusb_get_max_packet_size(libusb_device *dev, uint8_t endpoint)
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)
{