mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-13 10:02:38 +00:00
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
This commit is contained in:
parent
0f7dcde977
commit
a0c93fa361
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=302125
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -1403,7 +1403,8 @@ libusb10_submit_transfer_sub(struct libusb20_device *pdev, uint8_t endpoint)
|
||||
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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user