diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libusb/libusb20.3 | 13 | ||||
-rw-r--r-- | lib/libusb/libusb20.c | 9 | ||||
-rw-r--r-- | lib/libusb/libusb20.h | 1 | ||||
-rw-r--r-- | lib/libusb/libusb20_int.h | 2 | ||||
-rw-r--r-- | lib/libusb/libusb20_ugen20.c | 32 |
5 files changed, 43 insertions, 14 deletions
diff --git a/lib/libusb/libusb20.3 b/lib/libusb/libusb20.3 index c9bf902..af80c6c 100644 --- a/lib/libusb/libusb20.3 +++ b/lib/libusb/libusb20.3 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 14, 2010 +.Dd August 13, 2012 .Dt LIBUSB20 3 .Os .Sh NAME @@ -48,6 +48,7 @@ USB access library (libusb -lusb) .Fn libusb20_tr_close "struct libusb20_transfer *xfer" .Ft int .Fn libusb20_tr_open "struct libusb20_transfer *xfer" "uint32_t max_buf_size" "uint32_t max_frame_count" "uint8_t ep_no" +.Fn libusb20_tr_open_stream "struct libusb20_transfer *xfer" "uint32_t max_buf_size" "uint32_t max_frame_count" "uint8_t ep_no" "uint16_t stream_id" .Ft struct libusb20_transfer* .Fn libusb20_tr_get_pointer "struct libusb20_device *pdev" "uint16_t tr_index" .Ft uint16_t @@ -284,6 +285,16 @@ Non-zero return values indicate a LIBUSB20_ERROR value. . .Pp . +.Fn libusb20_tr_open_stream +is identical to +.Fn libusb20_tr_open +except that a stream ID can be specified for BULK endpoints having +such a feature. +.Fn libusb20_tr_open +can be used to open stream ID zero. +. +.Pp +. .Fn libusb20_tr_get_pointer will return a pointer to the allocated USB transfer according to the .Fa pdev diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c index 75af7a1..aa45991 100644 --- a/lib/libusb/libusb20.c +++ b/lib/libusb/libusb20.c @@ -155,6 +155,13 @@ int libusb20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize, uint32_t MaxFrameCount, uint8_t ep_no) { + return (libusb20_tr_open_stream(xfer, MaxBufSize, MaxFrameCount, ep_no, 0)); +} + +int +libusb20_tr_open_stream(struct libusb20_transfer *xfer, uint32_t MaxBufSize, + uint32_t MaxFrameCount, uint8_t ep_no, uint16_t stream_id) +{ uint32_t size; uint8_t pre_scale; int error; @@ -188,7 +195,7 @@ libusb20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize, memset(xfer->ppBuffer, 0, size); error = xfer->pdev->methods->tr_open(xfer, MaxBufSize, - MaxFrameCount, ep_no, pre_scale); + MaxFrameCount, ep_no, stream_id, pre_scale); if (error) { free(xfer->ppBuffer); diff --git a/lib/libusb/libusb20.h b/lib/libusb/libusb20.h index e4359fc..87e0572 100644 --- a/lib/libusb/libusb20.h +++ b/lib/libusb/libusb20.h @@ -202,6 +202,7 @@ struct libusb20_quirk { /* USB transfer operations */ int libusb20_tr_close(struct libusb20_transfer *xfer); int libusb20_tr_open(struct libusb20_transfer *xfer, uint32_t max_buf_size, uint32_t max_frame_count, uint8_t ep_no); +int libusb20_tr_open_stream(struct libusb20_transfer *xfer, uint32_t max_buf_size, uint32_t max_frame_count, uint8_t ep_no, uint16_t stream_id); struct libusb20_transfer *libusb20_tr_get_pointer(struct libusb20_device *pdev, uint16_t tr_index); uint16_t libusb20_tr_get_time_complete(struct libusb20_transfer *xfer); uint32_t libusb20_tr_get_actual_frames(struct libusb20_transfer *xfer); diff --git a/lib/libusb/libusb20_int.h b/lib/libusb/libusb20_int.h index bef4d02..0251c5f 100644 --- a/lib/libusb/libusb20_int.h +++ b/lib/libusb/libusb20_int.h @@ -110,7 +110,7 @@ typedef int (libusb20_set_config_index_t)(struct libusb20_device *pdev, uint8_t typedef int (libusb20_check_connected_t)(struct libusb20_device *pdev); /* USB transfer specific */ -typedef int (libusb20_tr_open_t)(struct libusb20_transfer *xfer, uint32_t MaxBufSize, uint32_t MaxFrameCount, uint8_t ep_no, uint8_t pre_scale); +typedef int (libusb20_tr_open_t)(struct libusb20_transfer *xfer, uint32_t MaxBufSize, uint32_t MaxFrameCount, uint8_t ep_no, uint16_t stream_id, uint8_t pre_scale); typedef int (libusb20_tr_close_t)(struct libusb20_transfer *xfer); typedef int (libusb20_tr_clear_stall_sync_t)(struct libusb20_transfer *xfer); typedef void (libusb20_tr_submit_t)(struct libusb20_transfer *xfer); diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c index 17c948b..2c67778 100644 --- a/lib/libusb/libusb20_ugen20.c +++ b/lib/libusb/libusb20_ugen20.c @@ -741,9 +741,13 @@ ugen20_process(struct libusb20_device *pdev) static int ugen20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize, - uint32_t MaxFrameCount, uint8_t ep_no, uint8_t pre_scale) + uint32_t MaxFrameCount, uint8_t ep_no, uint16_t stream_id, + uint8_t pre_scale) { - struct usb_fs_open temp; + union { + struct usb_fs_open fs_open; + struct usb_fs_open_stream fs_open_stream; + } temp; struct usb_fs_endpoint *fsep; if (pre_scale) @@ -754,20 +758,26 @@ ugen20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize, fsep = xfer->pdev->privBeData; fsep += xfer->trIndex; - temp.max_bufsize = MaxBufSize; - temp.max_frames = MaxFrameCount; - temp.ep_index = xfer->trIndex; - temp.ep_no = ep_no; + temp.fs_open.max_bufsize = MaxBufSize; + temp.fs_open.max_frames = MaxFrameCount; + temp.fs_open.ep_index = xfer->trIndex; + temp.fs_open.ep_no = ep_no; - if (ioctl(xfer->pdev->file, USB_FS_OPEN, &temp)) { - return (LIBUSB20_ERROR_INVALID_PARAM); + if (stream_id != 0) { + temp.fs_open_stream.stream_id = stream_id; + + if (ioctl(xfer->pdev->file, USB_FS_OPEN_STREAM, &temp.fs_open_stream)) + return (LIBUSB20_ERROR_INVALID_PARAM); + } else { + if (ioctl(xfer->pdev->file, USB_FS_OPEN, &temp.fs_open)) + return (LIBUSB20_ERROR_INVALID_PARAM); } /* maximums might have changed - update */ - xfer->maxFrames = temp.max_frames; + xfer->maxFrames = temp.fs_open.max_frames; /* "max_bufsize" should be multiple of "max_packet_length" */ - xfer->maxTotalLength = temp.max_bufsize; - xfer->maxPacketLen = temp.max_packet_length; + xfer->maxTotalLength = temp.fs_open.max_bufsize; + xfer->maxPacketLen = temp.fs_open.max_packet_length; /* setup buffer and length lists using zero copy */ fsep->ppBuffer = libusb20_pass_ptr(xfer->ppBuffer); |