Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163406179
D51759.id180295.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D51759.id180295.diff
View Options
diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h
--- a/lib/libusb/libusb.h
+++ b/lib/libusb/libusb.h
@@ -264,6 +264,7 @@
LIBUSB_TRANSFER_SHORT_NOT_OK = 1 << 0,
LIBUSB_TRANSFER_FREE_BUFFER = 1 << 1,
LIBUSB_TRANSFER_FREE_TRANSFER = 1 << 2,
+ LIBUSB_TRANSFER_ADD_ZERO_PACKET = 1 << 3,
};
enum libusb_log_level {
diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c
--- a/lib/libusb/libusb10.c
+++ b/lib/libusb/libusb10.c
@@ -1419,6 +1419,7 @@
uint32_t actlen;
uint8_t status;
uint8_t flags;
+ uint8_t tr_flags;
status = libusb20_tr_get_status(pxfer);
sxfer = libusb20_tr_get_priv_sc1(pxfer);
@@ -1471,6 +1472,20 @@
sxfer->curr_data += max_bulk;
sxfer->rem_len -= max_bulk;
+ /*
+ * When a zero length packet (ZLP) is requested, ask the
+ * kernel to terminate the last frame of the transfer with
+ * a short packet. This appends a ZLP when the data length
+ * is an exact multiple of the maximum packet size.
+ */
+ tr_flags = libusb20_tr_get_flags(pxfer);
+ if (sxfer->rem_len == 0 &&
+ (flags & LIBUSB_TRANSFER_ADD_ZERO_PACKET))
+ tr_flags |= LIBUSB20_TRANSFER_FORCE_SHORT;
+ else
+ tr_flags &= ~LIBUSB20_TRANSFER_FORCE_SHORT;
+ libusb20_tr_set_flags(pxfer, tr_flags);
+
libusb20_tr_submit(pxfer);
/* check if we can fork another USB transfer */
@@ -1710,7 +1725,7 @@
struct libusb_super_transfer *sxfer;
struct libusb_device *dev;
uint8_t endpoint;
- int err;
+ int err, mps;
if (uxfer == NULL)
return (LIBUSB_ERROR_INVALID_PARAM);
@@ -1731,6 +1746,18 @@
pxfer0 = libusb10_get_transfer(uxfer->dev_handle, endpoint, 0);
pxfer1 = libusb10_get_transfer(uxfer->dev_handle, endpoint, 1);
+ mps = libusb_get_max_packet_size(dev, endpoint);
+
+ /*
+ * The ADD_ZERO_PACKET flag only has an effect on host-to-device
+ * (OUT) transfers whose length is an exact multiple of the maximum
+ * packet size. Clear it otherwise so the kernel is not asked to
+ * terminate the transfer with a short packet, see
+ * libusb10_bulk_intr_proxy().
+ */
+ if ((uxfer->flags & LIBUSB_TRANSFER_ADD_ZERO_PACKET) &&
+ ((endpoint & LIBUSB_ENDPOINT_IN) || uxfer->length % mps != 0))
+ uxfer->flags &= ~LIBUSB_TRANSFER_ADD_ZERO_PACKET;
if (pxfer0 == NULL || pxfer1 == NULL) {
err = LIBUSB_ERROR_OTHER;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 23, 10:33 PM (19 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35417994
Default Alt Text
D51759.id180295.diff (2 KB)
Attached To
Mode
D51759: libusb: implement zlp flag in libusb transfer
Attached
Detach File
Event Timeline
Log In to Comment