svn commit: r260316 - stable/9/lib/libusb
Hans Petter Selasky
hselasky at FreeBSD.org
Sun Jan 5 10:49:58 UTC 2014
Author: hselasky
Date: Sun Jan 5 10:49:56 2014
New Revision: 260316
URL: http://svnweb.freebsd.org/changeset/base/260316
Log:
MFC r235128:
Add missing LibUSB 1.0 API function: libusb_get_string_descriptor().
Modified:
stable/9/lib/libusb/Makefile
stable/9/lib/libusb/libusb.3
stable/9/lib/libusb/libusb.h
stable/9/lib/libusb/libusb10_desc.c
Directory Properties:
stable/9/lib/ (props changed)
stable/9/lib/libusb/ (props changed)
Modified: stable/9/lib/libusb/Makefile
==============================================================================
--- stable/9/lib/libusb/Makefile Sun Jan 5 10:41:43 2014 (r260315)
+++ stable/9/lib/libusb/Makefile Sun Jan 5 10:49:56 2014 (r260316)
@@ -77,6 +77,7 @@ MLINKS += libusb.3 libusb_get_active_con
MLINKS += libusb.3 libusb_get_config_descriptor.3
MLINKS += libusb.3 libusb_get_config_descriptor_by_value.3
MLINKS += libusb.3 libusb_free_config_descriptor.3
+MLINKS += libusb.3 libusb_get_string_descriptor.3
MLINKS += libusb.3 libusb_get_string_descriptor_ascii.3
MLINKS += libusb.3 libusb_parse_ss_endpoint_comp.3
MLINKS += libusb.3 libusb_free_ss_endpoint_comp.3
Modified: stable/9/lib/libusb/libusb.3
==============================================================================
--- stable/9/lib/libusb/libusb.3 Sun Jan 5 10:41:43 2014 (r260315)
+++ stable/9/lib/libusb/libusb.3 Sun Jan 5 10:49:56 2014 (r260316)
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 20, 2013
+.Dd January 5, 2014
.Dt LIBUSB 3
.Os
.Sh NAME
@@ -327,6 +327,12 @@ LIBUSB_ERROR code on failure.
Free a configuration descriptor.
.Pp
.Ft int
+.Fn libusb_get_string_descriptor "libusb_device_handle *devh" "uint8_t desc_idx" "uint16_t langid" "unsigned char *data" "int length"
+Retrieve a string descriptor in raw format.
+Returns the number of bytes actually transferred on success
+or a negative LIBUSB_ERROR code on failure.
+.Pp
+.Ft int
.Fn libusb_get_string_descriptor_ascii "libusb_device_handle *devh" "uint8_t desc_idx" "unsigned char *data" "int length"
Retrieve a string descriptor in C style ASCII.
Returns the positive number of bytes in the resulting ASCII string
Modified: stable/9/lib/libusb/libusb.h
==============================================================================
--- stable/9/lib/libusb/libusb.h Sun Jan 5 10:41:43 2014 (r260315)
+++ stable/9/lib/libusb/libusb.h Sun Jan 5 10:49:56 2014 (r260316)
@@ -401,6 +401,7 @@ int libusb_get_active_config_descriptor(
int libusb_get_config_descriptor(libusb_device * dev, uint8_t config_index, struct libusb_config_descriptor **config);
int libusb_get_config_descriptor_by_value(libusb_device * dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config);
void libusb_free_config_descriptor(struct libusb_config_descriptor *config);
+int libusb_get_string_descriptor(libusb_device_handle * devh, uint8_t desc_index, uint16_t langid, unsigned char *data, int length);
int libusb_get_string_descriptor_ascii(libusb_device_handle * devh, uint8_t desc_index, uint8_t *data, int length);
int libusb_get_descriptor(libusb_device_handle * devh, uint8_t desc_type, uint8_t desc_index, uint8_t *data, int length);
int libusb_parse_ss_endpoint_comp(const void *buf, int len, struct libusb_ss_endpoint_companion_descriptor **ep_comp);
Modified: stable/9/lib/libusb/libusb10_desc.c
==============================================================================
--- stable/9/lib/libusb/libusb10_desc.c Sun Jan 5 10:41:43 2014 (r260315)
+++ stable/9/lib/libusb/libusb10_desc.c Sun Jan 5 10:49:56 2014 (r260316)
@@ -294,6 +294,25 @@ libusb_free_config_descriptor(struct lib
}
int
+libusb_get_string_descriptor(libusb_device_handle *pdev,
+ uint8_t desc_index, uint16_t langid, unsigned char *data,
+ int length)
+{
+ if (pdev == NULL || data == NULL || length < 1)
+ return (LIBUSB_ERROR_INVALID_PARAM);
+
+ if (length > 65535)
+ length = 65535;
+
+ /* put some default data into the destination buffer */
+ data[0] = 0;
+
+ return (libusb_control_transfer(pdev, LIBUSB_ENDPOINT_IN,
+ LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | desc_index,
+ langid, data, length, 1000));
+}
+
+int
libusb_get_string_descriptor_ascii(libusb_device_handle *pdev,
uint8_t desc_index, unsigned char *data, int length)
{
More information about the svn-src-stable-9
mailing list