summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/libusb-Fix-Zero-Length-Packet-issue.patch71
-rw-r--r--contrib/libusb-New-flag-LIBUSB_TRANSFER_ZERO_PACKET.patch72
2 files changed, 72 insertions, 71 deletions
diff --git a/contrib/libusb-Fix-Zero-Length-Packet-issue.patch b/contrib/libusb-Fix-Zero-Length-Packet-issue.patch
deleted file mode 100644
index 40fc2dc..0000000
--- a/contrib/libusb-Fix-Zero-Length-Packet-issue.patch
+++ /dev/null
@@ -1,71 +0,0 @@
1>From e6a34fe2fcd69d05411d3a8d41c8e897c9c337e1 Mon Sep 17 00:00:00 2001
2From: Nikias Bassen <nikias@gmx.li>
3Date: Mon, 17 Aug 2009 00:48:17 +0200
4Subject: [PATCH] Fix Zero Length Packet issue, new LIBUSB_TRANSFER_ZERO_PACKET flag.
5
6This patch fixes the Zero Length Packet issue by allowing the client
7program to specify the LIBUSB_TRANSFER_ZERO_PACKET flag when calling
8libusb_submit_transfer. This will pass the URB_ZERO_PACKET flag to the
9appropriate ioctl and thus triggers zero-length packet processing
10inside the kernel. This patch will also pass the URB_SHORT_NOT_OK flag
11if LIBUSB_TRANSFER_SHORT_NOT_OK is specified.
12---
13 libusb/libusb.h | 5 ++++-
14 libusb/os/linux_usbfs.c | 5 +++++
15 libusb/os/linux_usbfs.h | 8 +++++---
16 3 files changed, 14 insertions(+), 4 deletions(-)
17
18diff --git a/libusb/libusb.h b/libusb/libusb.h
19index 1126380..1dc7ae0 100644
20--- a/libusb/libusb.h
21+++ b/libusb/libusb.h
22@@ -672,7 +672,10 @@ enum libusb_transfer_flags {
23 * If this flag is set, it is illegal to call libusb_free_transfer()
24 * from your transfer callback, as this will result in a double-free
25 * when this flag is acted upon. */
26- LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2
27+ LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2,
28+
29+ /** zero-terminate a packet that is N*wMaxPacketSize bytes long */
30+ LIBUSB_TRANSFER_ZERO_PACKET = 1<<3
31 };
32
33 /** \ingroup asyncio
34diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
35index 1280188..81a9498 100644
36--- a/libusb/os/linux_usbfs.c
37+++ b/libusb/os/linux_usbfs.c
38@@ -1307,6 +1307,11 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer,
39 else
40 urb->buffer_length = MAX_BULK_BUFFER_LENGTH;
41
42+ if (transfer->flags & LIBUSB_TRANSFER_SHORT_NOT_OK)
43+ urb->flags |= USBFS_URB_SHORT_NOT_OK;
44+ if (transfer->flags & LIBUSB_TRANSFER_ZERO_PACKET)
45+ urb->flags |= USBFS_URB_ZERO_PACKET;
46+
47 r = ioctl(dpriv->fd, IOCTL_USBFS_SUBMITURB, urb);
48 if (r < 0) {
49 int j;
50diff --git a/libusb/os/linux_usbfs.h b/libusb/os/linux_usbfs.h
51index fdf5e9b..4660e3b 100644
52--- a/libusb/os/linux_usbfs.h
53+++ b/libusb/os/linux_usbfs.h
54@@ -60,9 +60,11 @@ struct usbfs_getdriver {
55 char driver[USBFS_MAXDRIVERNAME + 1];
56 };
57
58-#define USBFS_URB_DISABLE_SPD 1
59-#define USBFS_URB_ISO_ASAP 2
60-#define USBFS_URB_QUEUE_BULK 0x10
61+#define USBFS_URB_SHORT_NOT_OK 0x01
62+#define USBFS_URB_ISO_ASAP 0x02
63+#define USBFS_URB_NO_FSBR 0x20
64+#define USBFS_URB_ZERO_PACKET 0x40
65+#define USBFS_URB_NO_INTERRUPT 0x80
66
67 enum usbfs_urb_type {
68 USBFS_URB_TYPE_ISO = 0,
69--
701.6.0.4
71
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 @@
1From 13123672fc1edb1e8ce52f60eef045e3c901e5d6 Mon Sep 17 00:00:00 2001
2From: Nikias Bassen <nikias@gmx.li>
3Date: Sat, 5 Sep 2009 15:42:01 +0200
4Subject: [PATCH] New flag LIBUSB_TRANSFER_ZERO_PACKET for bulk/interrupt transfers.
5
6This flag will let the kernel append an additional zero-length packet
7to a tansfer. This is required for certain devices when sending packets
8with 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
15diff --git a/libusb/libusb.h b/libusb/libusb.h
16index 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
44diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
45index 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;
58diff --git a/libusb/os/linux_usbfs.h b/libusb/os/linux_usbfs.h
59index 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--
711.6.0.4
72