]> sigrok.org Git - sigrok-util.git/blob - cross-compile/mingw/libusb1_upgrade.patch
sigrok-cross-mingw: group and sort libusb1 patches for MXE
[sigrok-util.git] / cross-compile / mingw / libusb1_upgrade.patch
1 The sigrok build references an older libusb1 library version, which
2 addresses two specific aspects:
3
4   - Presence of an "event abstraction" is desired. Which once was
5     available as a branch on top of 1.0.20-rc3, but has gone away
6     in the meantime and got archived locally. -- Library versions
7     1.0.24 and above may provide that feature under the common API
8     but are yet to get verified.
9
10   - For performance reasons the RAW_IO feature is enabled. libusb1
11     mainline may provide such an approach later (automatically, after
12     checking more conditions for improved reliability), but does not
13     in versions up to and including 1.0.25 yet.
14
15 Manipulation of the libusb1 configuration in the MXE setup avoids the
16 necessity for a custom libusb1 build as a step in the sigrok procedure.
17
18 Ideally the sigrok build would use libusb1 version 1.0.25+ to benefit
19 from the many portability and robustness and feature set improvements.
20 Regardless of which libusb1 version ships with mainline MXE. That is
21 why this file is called "libusb1_upgrade.patch". Until then it patches
22 the local archive of the older library version.
23
24
25 Explicitly prepare autotools use between checkout and configuration.
26
27 diff --git a/src/libusb1.mk b/src/libusb1.mk
28 index ab01bf69..53aed36e 100644
29 --- a/src/libusb1.mk
30 +++ b/src/libusb1.mk
31 @@ -19,7 +19,7 @@ define $(PKG)_UPDATE
32  endef
33  
34  define $(PKG)_BUILD
35 -    cd '$(1)' && ./configure \
36 +    cd '$(1)' && autoreconf -i && ./configure \
37          $(MXE_CONFIGURE_OPTS) \
38          CFLAGS=-D_WIN32_WINNT=0x0500
39      $(MAKE) -C '$(1)' -j '$(JOBS)' install
40
41
42 Don't use MXE's provided 1.0.24 version. Use an "event abstraction"
43 enabled older version instead.
44
45 diff --git a/src/libusb1.mk b/src/libusb1.mk
46 index ab01bf69..53aed36e 100644
47 --- a/src/libusb1.mk
48 +++ b/src/libusb1.mk
49 @@ -4,11 +4,11 @@ PKG             := libusb1
50  $(PKG)_WEBSITE  := https://libusb.info/
51  $(PKG)_DESCR    := LibUsb-1.0
52  $(PKG)_IGNORE   :=
53 -$(PKG)_VERSION  := 1.0.24
54 -$(PKG)_CHECKSUM := 7efd2685f7b327326dcfb85cee426d9b871fd70e22caa15bb68d595ce2a2b12a
55 -$(PKG)_SUBDIR   := libusb-$($(PKG)_VERSION)
56 -$(PKG)_FILE     := libusb-$($(PKG)_VERSION).tar.bz2
57 -$(PKG)_URL      := https://$(SOURCEFORGE_MIRROR)/project/libusb/libusb-1.0/libusb-$($(PKG)_VERSION)/$($(PKG)_FILE)
58 +$(PKG)_VERSION  := 1.0.20-rc3-event-abstraction-v4
59 +$(PKG)_CHECKSUM := 58fee7f3f05fda209d14c55763df36ab86028bd9ab82c9bb74f1d5ab3208bcfd
60 +$(PKG)_SUBDIR   := libusb-event-abstraction-v4
61 +$(PKG)_FILE     := libusb-event-abstraction-v4.zip
62 +$(PKG)_URL      := https://github.com/uwehermann/libusb/archive/event-abstraction-v4.zip
63  $(PKG)_DEPS     := cc
64  
65  define $(PKG)_UPDATE
66
67
68 Unconditionally enable RAW_IO policy to improve performance on Windows.
69
70 diff --git a/src/libusb1-1-fixes.patch b/src/libusb1-1-fixes.patch
71 new file mode 100644
72 index 00000000..6cdeb0c4
73 --- /dev/null
74 +++ b/src/libusb1-1-fixes.patch
75 @@ -0,0 +1,31 @@
76 +From d4f7a49d77bd8f4ac871a999fc9ec898cb22b8c3 Mon Sep 17 00:00:00 2001
77 +From: Vlad Ivanov <vlad-mbx@ya.ru>
78 +Date: Tue, 9 Feb 2016 10:35:23 +0300
79 +Subject: [PATCH] windows_usb: enable RAW_IO policy by default
80 +
81 +libusb should set RAW_IO policy unconditionally because it
82 +implements the buffer management itself.
83 +
84 +Signed-off-by: Vlad Ivanov <vlad-mbx@ya.ru>
85 +---
86 + libusb/os/windows_usb.c | 4 ++++
87 + 1 file changed, 4 insertions(+)
88 +
89 +diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
90 +index 6640ad5..12fdab0 100644
91 +--- a/libusb/os/windows_usb.c
92 ++++ b/libusb/os/windows_usb.c
93 +@@ -2890,6 +2890,10 @@ static int winusbx_configure_endpoints(int sub_api, struct libusb_device_handle
94 +                       AUTO_CLEAR_STALL, sizeof(UCHAR), &policy)) {
95 +                       usbi_dbg("failed to enable AUTO_CLEAR_STALL for endpoint %02X", endpoint_address);
96 +               }
97 ++              if (!WinUSBX[sub_api].SetPipePolicy(winusb_handle, endpoint_address,
98 ++                      RAW_IO, sizeof(UCHAR), &policy)) {
99 ++                      usbi_dbg("failed to enable RAW_IO for endpoint %02X", endpoint_address);
100 ++              }
101 +       }
102
103 +       return LIBUSB_SUCCESS;
104 +-- 
105 +2.5.0
106 +