]> 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      $(MAKE) -C '$(1)' -j '$(JOBS)' install
29  
30
31 diff --git a/src/libusb1-1-fixes.patch b/src/libusb1-1-fixes.patch
32 new file mode 100644
33 index 00000000..6cdeb0c4
34 --- /dev/null
35 +++ b/src/libusb1-1-fixes.patch
36 @@ -0,0 +1,31 @@
37 +commit f341e4a086edd4f45c2db4df892a52ebfd52ac5b
38 +Author:     Petteri Aimonen <jpa@git.mail.kapsi.fi>
39 +AuthorDate: 2022-02-11 12:08:01 +0200
40 +Commit:     Petteri Aimonen <jpa@git.mail.kapsi.fi>
41 +CommitDate: 2022-02-11 12:08:01 +0200
42 +
43 +    WinUSB: Use RAW_IO when transfer size is divisible by 512 bytes
44 +---
45 + libusb/os/windows_winusb.c | 9 +++++++++
46 + 1 file changed, 9 insertions(+)
47 +
48 +diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c
49 +index a03d6a51216a..a0ac0c609e99 100644
50 +--- a/libusb/os/windows_winusb.c
51 ++++ b/libusb/os/windows_winusb.c
52 +@@ -3086,6 +3086,15 @@ static int winusbx_submit_bulk_transfer(int sub_api, struct usbi_transfer *itran
53 +       set_transfer_priv_handle(itransfer, handle_priv->interface_handle[current_interface].dev_handle);
54 +       overlapped = get_transfer_priv_overlapped(itransfer);
55
56 ++      if (sub_api == SUB_API_WINUSB)
57 ++      {
58 ++              // Use RAW_IO when transfer size is divisible by 512 bytes.
59 ++              UCHAR policy = (transfer->length % 512 == 0);
60 ++              if (!WinUSBX[sub_api].SetPipePolicy(winusb_handle, transfer->endpoint, RAW_IO, sizeof(UCHAR), &policy)) {
61 ++                              usbi_err(TRANSFER_CTX(transfer), "failed to set RAW_IO for endpoint %02X", transfer->endpoint);
62 ++              }
63 ++      }
64 ++
65 +       if (IS_XFERIN(transfer)) {
66 +               usbi_dbg(TRANSFER_CTX(transfer), "reading %d bytes", transfer->length);
67 +               ret = WinUSBX[sub_api].ReadPipe(winusb_handle, transfer->endpoint, transfer->buffer, transfer->length, NULL, overlapped);