aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2020-06-16 12:21:55 +0000
committerKyle Evans <kevans@FreeBSD.org>2020-06-16 12:21:55 +0000
commit3e776406b031a85604827eaeb15b5e535e29987a (patch)
treee7bffa0df0a436db13c270fdbe3d3aba583ad497
parent0be584a9496934fd6c9b029a1da757363be30d5c (diff)
downloadsrc-3e776406b031a85604827eaeb15b5e535e29987a.tar.gz
src-3e776406b031a85604827eaeb15b5e535e29987a.zip
MFC r361977: 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
Notes
Notes: svn path=/stable/10/; revision=362224
-rw-r--r--lib/libusb/Makefile1
-rw-r--r--lib/libusb/libusb.329
-rw-r--r--lib/libusb/libusb.h17
-rw-r--r--lib/libusb/libusb10.c15
4 files changed, 61 insertions, 1 deletions
diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile
index a5398443e19e..b2ed3ca407c9 100644
--- a/lib/libusb/Makefile
+++ b/lib/libusb/Makefile
@@ -71,6 +71,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
diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3
index c6f4082c75f9..c5d016b1e5b6 100644
--- a/lib/libusb/libusb.3
+++ b/lib/libusb/libusb.3
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 23, 2016
+.Dd June 16, 2020
.Dt LIBUSB 3
.Os
.Sh NAME
@@ -61,6 +61,33 @@ 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"
Get the ASCII representation of the error given by the
diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h
index 44bdb4bd21f1..54ecef6a260a 100644
--- a/lib/libusb/libusb.h
+++ b/lib/libusb/libusb.h
@@ -52,6 +52,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,
@@ -176,6 +177,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,
@@ -447,6 +463,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 */
diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c
index 519f3ad37c69..f076878800f4 100644
--- a/lib/libusb/libusb10.c
+++ b/lib/libusb/libusb10.c
@@ -1706,3 +1706,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);
+ }
+}