summaryrefslogtreecommitdiffstats
path: root/usbmuxd
diff options
context:
space:
mode:
authorGravatar Hector Martin2009-08-21 03:17:44 +0200
committerGravatar Hector Martin2009-08-21 03:19:23 +0200
commit0a1fe2abddbd73ed00a93afd8dcaf38f5210c0fc (patch)
tree2ce0e07f5423944cdf3328a050d8febc76510726 /usbmuxd
parent3fd317ed089d082d94b801ef73c8b84ab6a1083e (diff)
downloadusbmuxd-0a1fe2abddbd73ed00a93afd8dcaf38f5210c0fc.tar.gz
usbmuxd-0a1fe2abddbd73ed00a93afd8dcaf38f5210c0fc.tar.bz2
Warn if libusb is missing ZLP patch and keep old workaround in that case.
Revert this once libusb has the patch in a stable release.
Diffstat (limited to 'usbmuxd')
-rw-r--r--usbmuxd/usb-linux.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/usbmuxd/usb-linux.c b/usbmuxd/usb-linux.c
index fb22d03..2d6053e 100644
--- a/usbmuxd/usb-linux.c
+++ b/usbmuxd/usb-linux.c
@@ -33,6 +33,17 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33#include "log.h" 33#include "log.h"
34#include "device.h" 34#include "device.h"
35 35
36#ifndef LIBUSB_TRANSFER_ZERO_PACKET
37#warning Your libusb is missing proper Zero Length Packet support!
38#warning
39#warning If you are using a recent libusb Git, things may or may not work.
40#warning If you are using libusb 1.0.2 or earlier, things will definitely not work
41#warning properly.
42#warning
43#warning Please apply the patch in the contrib/ directory to your libusb 1.0 tree.
44#define EXPLICIT_ZLP_TRANSACTION
45#endif
46
36// interval for device connection/disconnection polling, in milliseconds 47// interval for device connection/disconnection polling, in milliseconds
37// we need this because there is currently no asynchronous device discovery mechanism in libusb 48// we need this because there is currently no asynchronous device discovery mechanism in libusb
38#define DEVICE_POLL_TIME 1000 49#define DEVICE_POLL_TIME 1000
@@ -134,15 +145,33 @@ int usb_send(struct usb_device *dev, const unsigned char *buf, int length)
134 struct libusb_transfer *xfer = libusb_alloc_transfer(0); 145 struct libusb_transfer *xfer = libusb_alloc_transfer(0);
135 libusb_fill_bulk_transfer(xfer, dev->dev, BULK_OUT, (void*)buf, length, tx_callback, dev, 0); 146 libusb_fill_bulk_transfer(xfer, dev->dev, BULK_OUT, (void*)buf, length, tx_callback, dev, 0);
136 xfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK; 147 xfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK;
148#ifndef EXPLICIT_ZLP_TRANSACTION
137 if (length % dev->wMaxPacketSize == 0) { 149 if (length % dev->wMaxPacketSize == 0) {
138 xfer->flags |= LIBUSB_TRANSFER_ZERO_PACKET; 150 xfer->flags |= LIBUSB_TRANSFER_ZERO_PACKET;
139 } 151 }
152#endif
140 if((res = libusb_submit_transfer(xfer)) < 0) { 153 if((res = libusb_submit_transfer(xfer)) < 0) {
141 usbmuxd_log(LL_ERROR, "Failed to submit TX transfer %p len %d to device %d-%d: %d", buf, length, dev->bus, dev->address, res); 154 usbmuxd_log(LL_ERROR, "Failed to submit TX transfer %p len %d to device %d-%d: %d", buf, length, dev->bus, dev->address, res);
142 libusb_free_transfer(xfer); 155 libusb_free_transfer(xfer);
143 return res; 156 return res;
144 } 157 }
145 collection_add(&dev->tx_xfers, xfer); 158 collection_add(&dev->tx_xfers, xfer);
159#ifdef EXPLICIT_ZLP_TRANSACTION
160 if (length % dev->wMaxPacketSize == 0) {
161 usbmuxd_log(LL_DEBUG, "Send ZLP");
162 // Send Zero Length Packet
163 xfer = libusb_alloc_transfer(0);
164 void *buffer = malloc(1);
165 libusb_fill_bulk_transfer(xfer, dev->dev, BULK_OUT, buffer, 0, tx_callback, dev, 0);
166 xfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK;
167 if((res = libusb_submit_transfer(xfer)) < 0) {
168 usbmuxd_log(LL_ERROR, "Failed to submit TX ZLP transfer to device %d-%d: %d", dev->bus, dev->address, res);
169 libusb_free_transfer(xfer);
170 return res;
171 }
172 collection_add(&dev->tx_xfers, xfer);
173 }
174#endif
146 return 0; 175 return 0;
147} 176}
148 177