diff options
| author | 2009-09-05 15:56:24 +0200 | |
|---|---|---|
| committer | 2009-09-05 15:56:24 +0200 | |
| commit | 3460b9db79e08a25534b04582eb7b7329c89a28d (patch) | |
| tree | d1cce8d93f04891b3c839da92ea00cc58dac303b /contrib/libusb-New-flag-LIBUSB_TRANSFER_ZERO_PACKET.patch | |
| parent | 856ddf1fe694686d98dc4b847a4e0f9ec6a8f418 (diff) | |
| download | usbmuxd-3460b9db79e08a25534b04582eb7b7329c89a28d.tar.gz usbmuxd-3460b9db79e08a25534b04582eb7b7329c89a28d.tar.bz2 | |
Updated libusb ZLP flag patch.
Diffstat (limited to 'contrib/libusb-New-flag-LIBUSB_TRANSFER_ZERO_PACKET.patch')
| -rw-r--r-- | contrib/libusb-New-flag-LIBUSB_TRANSFER_ZERO_PACKET.patch | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/contrib/libusb-New-flag-LIBUSB_TRANSFER_ZERO_PACKET.patch b/contrib/libusb-New-flag-LIBUSB_TRANSFER_ZERO_PACKET.patch new file mode 100644 index 0000000..84d8a0a --- /dev/null +++ b/contrib/libusb-New-flag-LIBUSB_TRANSFER_ZERO_PACKET.patch | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | From 13123672fc1edb1e8ce52f60eef045e3c901e5d6 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Nikias Bassen <nikias@gmx.li> | ||
| 3 | Date: Sat, 5 Sep 2009 15:42:01 +0200 | ||
| 4 | Subject: [PATCH] New flag LIBUSB_TRANSFER_ZERO_PACKET for bulk/interrupt transfers. | ||
| 5 | |||
| 6 | This flag will let the kernel append an additional zero-length packet | ||
| 7 | to a tansfer. This is required for certain devices when sending packets | ||
| 8 | with a size that is a multiple of wMaxPacketSize. | ||
| 9 | --- | ||
| 10 | libusb/libusb.h | 18 +++++++++++++++++- | ||
| 11 | libusb/os/linux_usbfs.c | 3 +++ | ||
| 12 | libusb/os/linux_usbfs.h | 1 + | ||
| 13 | 3 files changed, 21 insertions(+), 1 deletions(-) | ||
| 14 | |||
| 15 | diff --git a/libusb/libusb.h b/libusb/libusb.h | ||
| 16 | index 1126380..bf7f02d 100644 | ||
| 17 | --- a/libusb/libusb.h | ||
| 18 | +++ b/libusb/libusb.h | ||
| 19 | @@ -672,7 +672,23 @@ enum libusb_transfer_flags { | ||
| 20 | * If this flag is set, it is illegal to call libusb_free_transfer() | ||
| 21 | * from your transfer callback, as this will result in a double-free | ||
| 22 | * when this flag is acted upon. */ | ||
| 23 | - LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2 | ||
| 24 | + LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2, | ||
| 25 | + | ||
| 26 | + /** If this flag is set, a zero-length packet will be appended to | ||
| 27 | + * the transfer indicating that the transfer is complete. | ||
| 28 | + * Some devices require to be notified when a transfer is complete. | ||
| 29 | + * Usually a device knows about the end of the transfer if the last | ||
| 30 | + * packet's size is less than wMaxPacketSize. | ||
| 31 | + * But if the last packet of a transfer has _exactly_ the size of | ||
| 32 | + * wMaxPacketSize, the device does not know that it is the last | ||
| 33 | + * packet. This is where a zero-length packet is required, which | ||
| 34 | + * will let the device know that the transfer is complete. | ||
| 35 | + * | ||
| 36 | + * This flag is valid for the following transfer types: | ||
| 37 | + * LIBUSB_TRANSFER_TYPE_BULK | ||
| 38 | + * LIBUSB_TRANSFER_TYPE_INTERRUPT | ||
| 39 | + */ | ||
| 40 | + LIBUSB_TRANSFER_ZERO_PACKET = 1<<3 | ||
| 41 | }; | ||
| 42 | |||
| 43 | /** \ingroup asyncio | ||
| 44 | diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c | ||
| 45 | index 1280188..816bcbf 100644 | ||
| 46 | --- a/libusb/os/linux_usbfs.c | ||
| 47 | +++ b/libusb/os/linux_usbfs.c | ||
| 48 | @@ -1307,6 +1307,9 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer, | ||
| 49 | else | ||
| 50 | urb->buffer_length = MAX_BULK_BUFFER_LENGTH; | ||
| 51 | |||
| 52 | + if (i == num_urbs -1 && (transfer->flags & LIBUSB_TRANSFER_ZERO_PACKET)) | ||
| 53 | + urb->flags |= USBFS_URB_ZERO_PACKET; | ||
| 54 | + | ||
| 55 | r = ioctl(dpriv->fd, IOCTL_USBFS_SUBMITURB, urb); | ||
| 56 | if (r < 0) { | ||
| 57 | int j; | ||
| 58 | diff --git a/libusb/os/linux_usbfs.h b/libusb/os/linux_usbfs.h | ||
| 59 | index fdf5e9b..9ed0b4f 100644 | ||
| 60 | --- a/libusb/os/linux_usbfs.h | ||
| 61 | +++ b/libusb/os/linux_usbfs.h | ||
| 62 | @@ -63,6 +63,7 @@ struct usbfs_getdriver { | ||
| 63 | #define USBFS_URB_DISABLE_SPD 1 | ||
| 64 | #define USBFS_URB_ISO_ASAP 2 | ||
| 65 | #define USBFS_URB_QUEUE_BULK 0x10 | ||
| 66 | +#define USBFS_URB_ZERO_PACKET 0x40 | ||
| 67 | |||
| 68 | enum usbfs_urb_type { | ||
| 69 | USBFS_URB_TYPE_ISO = 0, | ||
| 70 | -- | ||
| 71 | 1.6.0.4 | ||
| 72 | |||
