From owner-svn-src-stable-8@FreeBSD.ORG Sun Jan 5 10:52:58 2014 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7A7927CC; Sun, 5 Jan 2014 10:52:58 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 65A511508; Sun, 5 Jan 2014 10:52:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s05AqwMc023009; Sun, 5 Jan 2014 10:52:58 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s05Aqvkh023005; Sun, 5 Jan 2014 10:52:57 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201401051052.s05Aqvkh023005@svn.freebsd.org> From: Hans Petter Selasky Date: Sun, 5 Jan 2014 10:52:57 +0000 (UTC) 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 X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jan 2014 10:52:58 -0000 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) {