diff options
author | Hector Martin | 2009-09-20 19:18:15 +0200 |
---|---|---|
committer | Hector Martin | 2009-10-03 17:16:24 +0200 |
commit | 8ea6dc804457d3ad02b5bc2017007f965359d8c5 (patch) | |
tree | fb08beb66949691bc6fddb56c2de1a0d0d377f74 | |
parent | e619fc9e4d90c9e86d1e05fe37ad6fbf284d6de8 (diff) | |
download | usbmuxd-8ea6dc804457d3ad02b5bc2017007f965359d8c5.tar.gz usbmuxd-8ea6dc804457d3ad02b5bc2017007f965359d8c5.tar.bz2 |
Require libusb-1.0.3 and hardcode explicit ZLP logic
1.0.3 has the 0-byte transaction fix. The saga
continues on the libusb trac. Whenever they add the
ZLP flag we can get rid of the 0-byte logic and just
set it.
-rw-r--r-- | Modules/FindUSB.cmake | 2 | ||||
-rw-r--r-- | contrib/libusb-New-flag-LIBUSB_TRANSFER_ZERO_PACKET.patch | 72 | ||||
-rw-r--r-- | daemon/CMakeLists.txt | 19 | ||||
-rw-r--r-- | daemon/usb-linux.c | 7 |
4 files changed, 1 insertions, 99 deletions
diff --git a/Modules/FindUSB.cmake b/Modules/FindUSB.cmake index 8659ec2..d1d705a 100644 --- a/Modules/FindUSB.cmake +++ b/Modules/FindUSB.cmake @@ -10,7 +10,7 @@ include(LibFindMacros) # Dependencies # Use pkg-config to get hints about paths -libfind_pkg_check_modules(USB_PKGCONF libusb-1.0>=1.0.2) +libfind_pkg_check_modules(USB_PKGCONF libusb-1.0>=1.0.3) # Include dir find_path(USB_INCLUDE_DIR diff --git a/contrib/libusb-New-flag-LIBUSB_TRANSFER_ZERO_PACKET.patch b/contrib/libusb-New-flag-LIBUSB_TRANSFER_ZERO_PACKET.patch deleted file mode 100644 index 84d8a0a..0000000 --- a/contrib/libusb-New-flag-LIBUSB_TRANSFER_ZERO_PACKET.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 13123672fc1edb1e8ce52f60eef045e3c901e5d6 Mon Sep 17 00:00:00 2001 -From: Nikias Bassen <nikias@gmx.li> -Date: Sat, 5 Sep 2009 15:42:01 +0200 -Subject: [PATCH] New flag LIBUSB_TRANSFER_ZERO_PACKET for bulk/interrupt transfers. - -This flag will let the kernel append an additional zero-length packet -to a tansfer. This is required for certain devices when sending packets -with a size that is a multiple of wMaxPacketSize. ---- - libusb/libusb.h | 18 +++++++++++++++++- - libusb/os/linux_usbfs.c | 3 +++ - libusb/os/linux_usbfs.h | 1 + - 3 files changed, 21 insertions(+), 1 deletions(-) - -diff --git a/libusb/libusb.h b/libusb/libusb.h -index 1126380..bf7f02d 100644 ---- a/libusb/libusb.h -+++ b/libusb/libusb.h -@@ -672,7 +672,23 @@ enum libusb_transfer_flags { - * If this flag is set, it is illegal to call libusb_free_transfer() - * from your transfer callback, as this will result in a double-free - * when this flag is acted upon. */ -- LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2 -+ LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2, -+ -+ /** If this flag is set, a zero-length packet will be appended to -+ * the transfer indicating that the transfer is complete. -+ * Some devices require to be notified when a transfer is complete. -+ * Usually a device knows about the end of the transfer if the last -+ * packet's size is less than wMaxPacketSize. -+ * But if the last packet of a transfer has _exactly_ the size of -+ * wMaxPacketSize, the device does not know that it is the last -+ * packet. This is where a zero-length packet is required, which -+ * will let the device know that the transfer is complete. -+ * -+ * This flag is valid for the following transfer types: -+ * LIBUSB_TRANSFER_TYPE_BULK -+ * LIBUSB_TRANSFER_TYPE_INTERRUPT -+ */ -+ LIBUSB_TRANSFER_ZERO_PACKET = 1<<3 - }; - - /** \ingroup asyncio -diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c -index 1280188..816bcbf 100644 ---- a/libusb/os/linux_usbfs.c -+++ b/libusb/os/linux_usbfs.c -@@ -1307,6 +1307,9 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer, - else - urb->buffer_length = MAX_BULK_BUFFER_LENGTH; - -+ if (i == num_urbs -1 && (transfer->flags & LIBUSB_TRANSFER_ZERO_PACKET)) -+ urb->flags |= USBFS_URB_ZERO_PACKET; -+ - r = ioctl(dpriv->fd, IOCTL_USBFS_SUBMITURB, urb); - if (r < 0) { - int j; -diff --git a/libusb/os/linux_usbfs.h b/libusb/os/linux_usbfs.h -index fdf5e9b..9ed0b4f 100644 ---- a/libusb/os/linux_usbfs.h -+++ b/libusb/os/linux_usbfs.h -@@ -63,6 +63,7 @@ struct usbfs_getdriver { - #define USBFS_URB_DISABLE_SPD 1 - #define USBFS_URB_ISO_ASAP 2 - #define USBFS_URB_QUEUE_BULK 0x10 -+#define USBFS_URB_ZERO_PACKET 0x40 - - enum usbfs_urb_type { - USBFS_URB_TYPE_ISO = 0, --- -1.6.0.4 - diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index e5f9b11..8a5c417 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -6,25 +6,6 @@ include_directories (${CMAKE_SOURCE_DIR}/common) include_directories (${CMAKE_SOURCE_DIR}/daemon) include_directories (${CMAKE_SOURCE_DIR}/libusbmuxd) -include(CheckConstantExists) -set(CMAKE_REQUIRED_INCLUDES ${USB_INCLUDE_DIRS}) -check_constant_exists(LIBUSB_TRANSFER_ZERO_PACKET libusb.h HAVE_LIBUSB_ZLP) - -if(NOT HAVE_LIBUSB_ZLP) - message(" -================================================================================ -==================================== WARNING =================================== -================================================================================ -Your libusb is missing proper Zero Length Packet support! If you are using a -recent libusb Git, things may or may not work. If you are using libusb 1.0.2 or -earlier, things will definitely not work properly. - -Please apply the patch in the contrib/ directory to your libusb 1.0 tree. -================================================================================ -") - add_definitions(-DEXPLICIT_ZLP_TRANSACTION) -endif(NOT HAVE_LIBUSB_ZLP) - add_definitions(-Wall -O2 -g -DUSBMUXD_DAEMON -DUSBMUXD_VERSION="${USBMUXD_VERSION}") add_executable(usbmuxd main.c usb-linux.c log.c ../common/utils.c device.c client.c) target_link_libraries(usbmuxd ${LIBS}) diff --git a/daemon/usb-linux.c b/daemon/usb-linux.c index f1be612..0edc557 100644 --- a/daemon/usb-linux.c +++ b/daemon/usb-linux.c @@ -134,18 +134,12 @@ int usb_send(struct usb_device *dev, const unsigned char *buf, int length) struct libusb_transfer *xfer = libusb_alloc_transfer(0); libusb_fill_bulk_transfer(xfer, dev->dev, BULK_OUT, (void*)buf, length, tx_callback, dev, 0); xfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK; -#ifndef EXPLICIT_ZLP_TRANSACTION - if (length % dev->wMaxPacketSize == 0) { - xfer->flags |= LIBUSB_TRANSFER_ZERO_PACKET; - } -#endif if((res = libusb_submit_transfer(xfer)) < 0) { usbmuxd_log(LL_ERROR, "Failed to submit TX transfer %p len %d to device %d-%d: %d", buf, length, dev->bus, dev->address, res); libusb_free_transfer(xfer); return res; } collection_add(&dev->tx_xfers, xfer); -#ifdef EXPLICIT_ZLP_TRANSACTION if (length % dev->wMaxPacketSize == 0) { usbmuxd_log(LL_DEBUG, "Send ZLP"); // Send Zero Length Packet @@ -160,7 +154,6 @@ int usb_send(struct usb_device *dev, const unsigned char *buf, int length) } collection_add(&dev->tx_xfers, xfer); } -#endif return 0; } |