summaryrefslogtreecommitdiffstats
path: root/lib/libusb
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2016-06-23 07:12:22 +0000
committerhselasky <hselasky@FreeBSD.org>2016-06-23 07:12:22 +0000
commit113f2d399881db003b011a131ba80137a4966a4c (patch)
tree7f513dd438131d57905f8ed39f300e8fffca1610 /lib/libusb
parent6efa34305bb5e56714c708e0ea703023b0c8cfd1 (diff)
downloadFreeBSD-src-113f2d399881db003b011a131ba80137a4966a4c.zip
FreeBSD-src-113f2d399881db003b011a131ba80137a4966a4c.tar.gz
Add support for USB streams to the LibUSB v1.0 API and update the
libusb(3) manual page. Approved by: re (gjb) Requested by: swills MFC after: 1 week
Diffstat (limited to 'lib/libusb')
-rw-r--r--lib/libusb/Makefile4
-rw-r--r--lib/libusb/libusb.325
-rw-r--r--lib/libusb/libusb.h7
-rw-r--r--lib/libusb/libusb10.c3
-rw-r--r--lib/libusb/libusb10.h1
-rw-r--r--lib/libusb/libusb10_io.c45
6 files changed, 83 insertions, 2 deletions
diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile
index adc5179..397c181 100644
--- a/lib/libusb/Makefile
+++ b/lib/libusb/Makefile
@@ -120,8 +120,12 @@ MLINKS += libusb.3 libusb_get_ss_usb_device_capability_descriptor.3
MLINKS += libusb.3 libusb_free_ss_usb_device_capability_descriptor.3
MLINKS += libusb.3 libusb_get_container_id_descriptor.3
MLINKS += libusb.3 libusb_free_container_id_descriptor.3
+MLINKS += libusb.3 libusb_alloc_streams.3
+MLINKS += libusb.3 libusb_free_streams.3
MLINKS += libusb.3 libusb_alloc_transfer.3
MLINKS += libusb.3 libusb_free_transfer.3
+MLINKS += libusb.3 libusb_transfer_set_stream_id.3
+MLINKS += libusb.3 libusb_transfer_get_stream_id.3
MLINKS += libusb.3 libusb_submit_transfer.3
MLINKS += libusb.3 libusb_cancel_transfer.3
MLINKS += libusb.3 libusb_control_transfer.3
diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3
index 4950a25..05bd727 100644
--- a/lib/libusb/libusb.3
+++ b/lib/libusb/libusb.3
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 22, 2016
+.Dd June 23, 2016
.Dt LIBUSB 3
.Os
.Sh NAME
@@ -521,6 +521,29 @@ if the transfer timed out, LIBUSB_ERROR_PIPE if the control request was not
supported, LIBUSB_ERROR_OVERFLOW if the device offered more data,
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and
a LIBUSB_ERROR code on other failure.
+.Sh USB STREAMS SUPPORT
+.Ft int
+.Fn libusb_alloc_streams "libusb_device_handle *dev" "uint32_t num_streams" "unsigned char *endpoints" "int num_endpoints"
+This function verifies that the given number of streams using the
+given number of endpoints is allowed and allocates the resources
+needed to use so-called USB streams.
+Currently only a single stream per endpoint is supported to simplify
+the internals of LibUSB.
+This function returns 0 on success or a LIBUSB_ERROR code on failure.
+.Pp
+.Ft int
+.Fn libusb_free_streams "libusb_device_handle *dev" "unsigned char *endpoints" "int num_endpoints"
+This function release resources needed for streams usage.
+Returns 0 on success or a LIBUSB_ERROR code on failure.
+.Pp
+.Ft void
+.Fn libusb_transfer_set_stream_id "struct libusb_transfer *transfer" "uint32_t stream_id"
+This function sets the stream ID for the given USB transfer.
+.Pp
+.Ft uint32_t
+.Fn libusb_transfer_get_stream_id "struct libusb_transfer *transfer"
+This function returns the stream ID for the given USB transfer.
+If no stream ID is used a value of zero is returned.
.Sh USB EVENTS
.Ft int
.Fn libusb_try_lock_events "libusb_context *ctx"
diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h
index 1738301..9b48894 100644
--- a/lib/libusb/libusb.h
+++ b/lib/libusb/libusb.h
@@ -561,6 +561,13 @@ typedef int (*libusb_hotplug_callback_fn)(libusb_context *ctx,
int libusb_hotplug_register_callback(libusb_context *ctx, libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, int dev_class, libusb_hotplug_callback_fn cb_fn, void *user_data, libusb_hotplug_callback_handle *handle);
void libusb_hotplug_deregister_callback(libusb_context *ctx, libusb_hotplug_callback_handle handle);
+/* Streams support */
+
+int libusb_alloc_streams(libusb_device_handle *dev, uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
+int libusb_free_streams(libusb_device_handle *dev, unsigned char *endpoints, int num_endpoints);
+void libusb_transfer_set_stream_id(struct libusb_transfer *transfer, uint32_t stream_id);
+uint32_t libusb_transfer_get_stream_id(struct libusb_transfer *transfer);
+
#if 0
{ /* indent fix */
#endif
diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c
index c6eb771..e7aeee5 100644
--- a/lib/libusb/libusb10.c
+++ b/lib/libusb/libusb10.c
@@ -1403,7 +1403,8 @@ found:
maxframe = libusb10_get_maxframe(pdev, uxfer);
/* make sure the transfer is opened */
- err = libusb20_tr_open(pxfer0, buffsize, maxframe, endpoint);
+ err = libusb20_tr_open_stream(pxfer0, buffsize, maxframe,
+ endpoint, sxfer->stream_id);
if (err && (err != LIBUSB20_ERROR_BUSY)) {
goto failure;
}
diff --git a/lib/libusb/libusb10.h b/lib/libusb/libusb10.h
index d2df6e0..ad3f934 100644
--- a/lib/libusb/libusb10.h
+++ b/lib/libusb/libusb10.h
@@ -69,6 +69,7 @@ struct libusb_super_transfer {
uint8_t *curr_data;
uint32_t rem_len;
uint32_t last_len;
+ uint32_t stream_id;
uint8_t state;
#define LIBUSB_SUPER_XFER_ST_NONE 0
#define LIBUSB_SUPER_XFER_ST_PEND 1
diff --git a/lib/libusb/libusb10_io.c b/lib/libusb/libusb10_io.c
index e27bbba..a276231 100644
--- a/lib/libusb/libusb10_io.c
+++ b/lib/libusb/libusb10_io.c
@@ -767,3 +767,48 @@ libusb_fill_iso_transfer(struct libusb_transfer *transfer,
transfer->callback = callback;
}
+int
+libusb_alloc_streams(libusb_device_handle *dev, uint32_t num_streams,
+ unsigned char *endpoints, int num_endpoints)
+{
+ if (num_streams > 1)
+ return (LIBUSB_ERROR_INVALID_PARAM);
+ return (0);
+}
+
+int
+libusb_free_streams(libusb_device_handle *dev, unsigned char *endpoints, int num_endpoints)
+{
+
+ return (0);
+}
+
+void
+libusb_transfer_set_stream_id(struct libusb_transfer *transfer, uint32_t stream_id)
+{
+ struct libusb_super_transfer *sxfer;
+
+ if (transfer == NULL)
+ return;
+
+ sxfer = (struct libusb_super_transfer *)(
+ ((uint8_t *)transfer) - sizeof(*sxfer));
+
+ /* set stream ID */
+ sxfer->stream_id = stream_id;
+}
+
+uint32_t
+libusb_transfer_get_stream_id(struct libusb_transfer *transfer)
+{
+ struct libusb_super_transfer *sxfer;
+
+ if (transfer == NULL)
+ return (0);
+
+ sxfer = (struct libusb_super_transfer *)(
+ ((uint8_t *)transfer) - sizeof(*sxfer));
+
+ /* get stream ID */
+ return (sxfer->stream_id);
+}
OpenPOWER on IntegriCloud