]> sigrok.org Git - sigrok-util.git/blob - cross-compile/mingw/libusb1_upgrade.patch
sigrok-fwextract-kingst-la2016: concentrate RCC flags in one spot
[sigrok-util.git] / cross-compile / mingw / libusb1_upgrade.patch
1 The sigrok project build references a libusb feature which is not yet
2 available in mainline libusb1, enabling the RAW_IO policy by default
3 to improve performance on Windows. And applies an autotools fix to the
4 mainline MXE build rules.
5
6 See the libusb pull request https://github.com/libusb/libusb/pull/1069
7 for a discussion of the RAW_IO policy tweak.
8
9 Manipulation of the libusb1 configuration in the MXE setup avoids the
10 necessity for a custom libusb1 build as a step in the sigrok procedure.
11 When the MXE modification is considered undesirable, then the sigrok
12 build script or the manual sequence of building needs to get adjusted
13 to include a local libusb1 build which then gets referenced in the
14 configure step.
15
16
17 diff --git a/src/libusb1.mk b/src/libusb1.mk
18 index ab01bf69..53aed36e 100644
19 --- a/src/libusb1.mk
20 +++ b/src/libusb1.mk
21 @@ -19,7 +19,7 @@ define $(PKG)_UPDATE
22  endef
23  
24  define $(PKG)_BUILD
25 -    cd '$(1)' && ./configure \
26 +    cd '$(1)' && autoreconf -i && ./configure \
27          $(MXE_CONFIGURE_OPTS) \
28          CFLAGS=-D_WIN32_WINNT=0x0500
29      $(MAKE) -C '$(1)' -j '$(JOBS)' install
30
31
32 diff --git a/src/libusb1.mk b/src/libusb1.mk
33 index ab01bf69..53aed36e 100644
34 --- a/src/libusb1.mk
35 +++ b/src/libusb1.mk
36 @@ -4,8 +4,8 @@ PKG             := libusb1
37  $(PKG)_WEBSITE  := https://libusb.info/
38  $(PKG)_DESCR    := LibUsb-1.0
39  $(PKG)_IGNORE   :=
40 -$(PKG)_VERSION  := 1.0.24
41 -$(PKG)_CHECKSUM := 7efd2685f7b327326dcfb85cee426d9b871fd70e22caa15bb68d595ce2a2b12a
42 +$(PKG)_VERSION  := 1.0.25
43 +$(PKG)_CHECKSUM := 8a28ef197a797ebac2702f095e81975e2b02b2eeff2774fa909c78a74ef50849
44  $(PKG)_SUBDIR   := libusb-$($(PKG)_VERSION)
45  $(PKG)_FILE     := libusb-$($(PKG)_VERSION).tar.bz2
46  $(PKG)_URL      := https://$(SOURCEFORGE_MIRROR)/project/libusb/libusb-1.0/libusb-$($(PKG)_VERSION)/$($(PKG)_FILE)
47
48
49 diff --git a/src/libusb1-1-fixes.patch b/src/libusb1-1-fixes.patch
50 new file mode 100644
51 index 00000000..6cdeb0c4
52 --- /dev/null
53 +++ b/src/libusb1-1-fixes.patch
54 @@ -0,0 +1,31 @@
55 +commit f341e4a086edd4f45c2db4df892a52ebfd52ac5b
56 +Author:     Petteri Aimonen <jpa@git.mail.kapsi.fi>
57 +AuthorDate: 2022-02-11 12:08:01 +0200
58 +Commit:     Petteri Aimonen <jpa@git.mail.kapsi.fi>
59 +CommitDate: 2022-02-11 12:08:01 +0200
60 +
61 +    WinUSB: Use RAW_IO when transfer size is divisible by 512 bytes
62 +---
63 + libusb/os/windows_winusb.c | 9 +++++++++
64 + 1 file changed, 9 insertions(+)
65 +
66 +diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c
67 +index a03d6a51216a..a0ac0c609e99 100644
68 +--- a/libusb/os/windows_winusb.c
69 ++++ b/libusb/os/windows_winusb.c
70 +@@ -3086,6 +3086,15 @@ static int winusbx_submit_bulk_transfer(int sub_api, struct usbi_transfer *itran
71 +       set_transfer_priv_handle(itransfer, handle_priv->interface_handle[current_interface].dev_handle);
72 +       overlapped = get_transfer_priv_overlapped(itransfer);
73
74 ++      if (sub_api == SUB_API_WINUSB)
75 ++      {
76 ++              // Use RAW_IO when transfer size is divisible by 512 bytes.
77 ++              UCHAR policy = (transfer->length % 512 == 0);
78 ++              if (!WinUSBX[sub_api].SetPipePolicy(winusb_handle, transfer->endpoint, RAW_IO, sizeof(UCHAR), &policy)) {
79 ++                              usbi_err(TRANSFER_CTX(transfer), "failed to set RAW_IO for endpoint %02X", transfer->endpoint);
80 ++              }
81 ++      }
82 ++
83 +       if (IS_XFERIN(transfer)) {
84 +               usbi_dbg(TRANSFER_CTX(transfer), "reading %d bytes", transfer->length);
85 +               ret = WinUSBX[sub_api].ReadPipe(winusb_handle, transfer->endpoint, transfer->buffer, transfer->length, NULL, overlapped);