Date: Sun, 5 Jan 2014 10:52:57 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r260317 - stable/8/lib/libusb Message-ID: <201401051052.s05Aqvkh023005@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Sun Jan 5 10:52:57 2014 New Revision: 260317 URL: http://svnweb.freebsd.org/changeset/base/260317 Log: MFC r235128: Add missing LibUSB 1.0 API function: libusb_get_string_descriptor(). Modified: stable/8/lib/libusb/Makefile stable/8/lib/libusb/libusb.3 stable/8/lib/libusb/libusb.h stable/8/lib/libusb/libusb10_desc.c Directory Properties: stable/8/lib/ (props changed) stable/8/lib/libusb/ (props changed) Modified: stable/8/lib/libusb/Makefile ============================================================================== --- stable/8/lib/libusb/Makefile Sun Jan 5 10:49:56 2014 (r260316) +++ stable/8/lib/libusb/Makefile Sun Jan 5 10:52:57 2014 (r260317) @@ -75,6 +75,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/8/lib/libusb/libusb.3 ============================================================================== --- stable/8/lib/libusb/libusb.3 Sun Jan 5 10:49:56 2014 (r260316) +++ stable/8/lib/libusb/libusb.3 Sun Jan 5 10:52:57 2014 (r260317) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 12, 2012 +.Dd May 7, 2012 .Dt LIBUSB 3 .Os .Sh NAME @@ -314,6 +314,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/8/lib/libusb/libusb.h ============================================================================== --- stable/8/lib/libusb/libusb.h Sun Jan 5 10:49:56 2014 (r260316) +++ stable/8/lib/libusb/libusb.h Sun Jan 5 10:52:57 2014 (r260317) @@ -399,6 +399,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/8/lib/libusb/libusb10_desc.c ============================================================================== --- stable/8/lib/libusb/libusb10_desc.c Sun Jan 5 10:49:56 2014 (r260316) +++ stable/8/lib/libusb/libusb10_desc.c Sun Jan 5 10:52:57 2014 (r260317) @@ -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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201401051052.s05Aqvkh023005>