From owner-svn-src-head@freebsd.org Tue Jun 9 17:17:45 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3B927336D10; Tue, 9 Jun 2020 17:17:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49hGyx0kPHz498H; Tue, 9 Jun 2020 17:17:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0EC1618EEC; Tue, 9 Jun 2020 17:17:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 059HHiHo027027; Tue, 9 Jun 2020 17:17:44 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 059HHiee027024; Tue, 9 Jun 2020 17:17:44 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202006091717.059HHiee027024@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 9 Jun 2020 17:17:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361977 - head/lib/libusb X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/lib/libusb X-SVN-Commit-Revision: 361977 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jun 2020 17:17:45 -0000 Author: kevans Date: Tue Jun 9 17:17:43 2020 New Revision: 361977 URL: https://svnweb.freebsd.org/changeset/base/361977 Log: libusb: improve compatibility Specifically, add LIBUSB_CLASS_PHYSICAL and the libusb_has_capability API. Descriptions and functionality for these derived from the documentation at [0]. The current set of capabilities are all supported by libusb. These were detected as missing after updating net/freerdp to 2.1.1, which attempted to use both. [0] http://libusb.sourceforge.net/api-1.0/group__libusb__misc.html Reviewed by: hselasky MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25194 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 Tue Jun 9 17:07:42 2020 (r361976) +++ head/lib/libusb/Makefile Tue Jun 9 17:17:43 2020 (r361977) @@ -68,6 +68,7 @@ CFLAGS+= -I ../../sys MLINKS += libusb.3 libusb_get_version.3 MLINKS += libusb.3 libusb_init.3 MLINKS += libusb.3 libusb_exit.3 +MLINKS += libusb.3 libusb_has_capability.3 MLINKS += libusb.3 libusb_strerror.3 MLINKS += libusb.3 libusb_error_name.3 MLINKS += libusb.3 libusb_set_debug.3 Modified: head/lib/libusb/libusb.3 ============================================================================== --- head/lib/libusb/libusb.3 Tue Jun 9 17:07:42 2020 (r361976) +++ head/lib/libusb/libusb.3 Tue Jun 9 17:17:43 2020 (r361977) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 11, 2018 +.Dd June 9, 2020 .Dt LIBUSB 3 .Os .Sh NAME @@ -60,6 +60,33 @@ failure. Deinitialise libusb. Must be called at the end of the application. Other libusb routines may not be called after this function. +.Pp +.Ft int +.Fn libusb_has_capability "uint32_t capability" +This function checks the runtime capabilities of +.Nm . +This function will return non-zero if the given +.Fa capability +is supported, 0 if it is not supported. +The valid values for +.Fa capability +are: +.Bl -tag -width LIBUSB_CAP -offset indent +.It Va LIBUSB_CAP_HAS_CAPABILITY +.Nm +supports +.Fn libusb_has_capability . +.It Va LIBUSB_CAP_HAS_HOTPLUG +.Nm +supports hotplug notifications. +.It Va LIBUSB_CAP_HAS_HID_ACCESS +.Nm +can access HID devices without requiring user intervention. +.It Va LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER +.Nm +supports detaching of the default USB driver with +.Fn libusb_detach_kernel_driver . +.El .Pp .Ft const char * .Fn libusb_strerror "int code" Modified: head/lib/libusb/libusb.h ============================================================================== --- head/lib/libusb/libusb.h Tue Jun 9 17:07:42 2020 (r361976) +++ head/lib/libusb/libusb.h Tue Jun 9 17:17:43 2020 (r361977) @@ -54,6 +54,7 @@ enum libusb_class_code { LIBUSB_CLASS_AUDIO = 1, LIBUSB_CLASS_COMM = 2, LIBUSB_CLASS_HID = 3, + LIBUSB_CLASS_PHYSICAL = 5, LIBUSB_CLASS_PTP = 6, LIBUSB_CLASS_IMAGE = 6, LIBUSB_CLASS_PRINTER = 7, @@ -178,6 +179,21 @@ enum libusb_bos_type { LIBUSB_BT_CONTAINER_ID = 4, }; +enum libusb_capability { + /* libusb supports libusb_has_capability(). */ + LIBUSB_CAP_HAS_CAPABILITY = 0, + /* Hotplug support is available. */ + LIBUSB_CAP_HAS_HOTPLUG, + /* Can access HID devices without requiring user intervention. */ + LIBUSB_CAP_HAS_HID_ACCESS, + + /* + * Supports detaching of the default USB driver with + * libusb_detach_kernel_driver(). + */ + LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER, +}; + enum libusb_error { LIBUSB_SUCCESS = 0, LIBUSB_ERROR_IO = -1, @@ -450,6 +466,7 @@ const char *libusb_strerror(int code); const char *libusb_error_name(int code); int libusb_init(libusb_context ** context); void libusb_exit(struct libusb_context *ctx); +int libusb_has_capability(uint32_t capability); /* Device handling and enumeration */ Modified: head/lib/libusb/libusb10.c ============================================================================== --- head/lib/libusb/libusb10.c Tue Jun 9 17:07:42 2020 (r361976) +++ head/lib/libusb/libusb10.c Tue Jun 9 17:17:43 2020 (r361977) @@ -1716,3 +1716,18 @@ libusb_error_name(int code) return ("LIBUSB_ERROR_UNKNOWN"); } } + +int +libusb_has_capability(uint32_t capability) +{ + + switch (capability) { + case LIBUSB_CAP_HAS_CAPABILITY: + case LIBUSB_CAP_HAS_HOTPLUG: + case LIBUSB_CAP_HAS_HID_ACCESS: + case LIBUSB_CAP_SUPPORTS_DETACH_KERNEL_DRIVER: + return (1); + default: + return (0); + } +}