-$(PKG)_SUBDIR := libusb-$($(PKG)_VERSION)
-$(PKG)_FILE := libusb-$($(PKG)_VERSION).tar.bz2
-$(PKG)_URL := https://$(SOURCEFORGE_MIRROR)/project/libusb/libusb-1.0/libusb-$($(PKG)_VERSION)/$($(PKG)_FILE)
-+$(PKG)_VERSION := 1.0.20-rc3-event-abstraction-v4
-+$(PKG)_CHECKSUM := 58fee7f3f05fda209d14c55763df36ab86028bd9ab82c9bb74f1d5ab3208bcfd
-+$(PKG)_SUBDIR := libusb-event-abstraction-v4
-+$(PKG)_FILE := libusb-event-abstraction-v4.zip
-+$(PKG)_URL := https://github.com/uwehermann/libusb/archive/event-abstraction-v4.zip
++$(PKG)_VERSION := 1.0.24
++$(PKG)_CHECKSUM := 7efd2685f7b327326dcfb85cee426d9b871fd70e22caa15bb68d595ce2a2b12a
++$(PKG)_SUBDIR := libusb-$($(PKG)_VERSION)
++$(PKG)_FILE := libusb-$($(PKG)_VERSION).tar.bz2
++$(PKG)_URL := https://$(SOURCEFORGE_MIRROR)/project/libusb/libusb-1.0/libusb-$($(PKG)_VERSION)/$($(PKG)_FILE)
$(PKG)_DEPS := cc
define $(PKG)_UPDATE
-Unconditionally enable RAW_IO policy to improve performance on Windows.
+Enable RAW_IO policy on Windows when constraints are met. This assumes
+recent libusb1 versions, see https://github.com/libusb/libusb/pull/1069
+for details.
diff --git a/src/libusb1-1-fixes.patch b/src/libusb1-1-fixes.patch
new file mode 100644
--- /dev/null
+++ b/src/libusb1-1-fixes.patch
@@ -0,0 +1,31 @@
-+From d4f7a49d77bd8f4ac871a999fc9ec898cb22b8c3 Mon Sep 17 00:00:00 2001
-+From: Vlad Ivanov <vlad-mbx@ya.ru>
-+Date: Tue, 9 Feb 2016 10:35:23 +0300
-+Subject: [PATCH] windows_usb: enable RAW_IO policy by default
++commit f341e4a086edd4f45c2db4df892a52ebfd52ac5b
++Author: Petteri Aimonen <jpa@git.mail.kapsi.fi>
++AuthorDate: 2022-02-11 12:08:01 +0200
++Commit: Petteri Aimonen <jpa@git.mail.kapsi.fi>
++CommitDate: 2022-02-11 12:08:01 +0200
+
-+libusb should set RAW_IO policy unconditionally because it
-+implements the buffer management itself.
-+
-+Signed-off-by: Vlad Ivanov <vlad-mbx@ya.ru>
++ WinUSB: Use RAW_IO when transfer size is divisible by 512 bytes
+---
-+ libusb/os/windows_usb.c | 4 ++++
-+ 1 file changed, 4 insertions(+)
++ libusb/os/windows_winusb.c | 9 +++++++++
++ 1 file changed, 9 insertions(+)
+
-+diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
-+index 6640ad5..12fdab0 100644
-+--- a/libusb/os/windows_usb.c
-++++ b/libusb/os/windows_usb.c
-+@@ -2890,6 +2890,10 @@ static int winusbx_configure_endpoints(int sub_api, struct libusb_device_handle
-+ AUTO_CLEAR_STALL, sizeof(UCHAR), &policy)) {
-+ usbi_dbg("failed to enable AUTO_CLEAR_STALL for endpoint %02X", endpoint_address);
-+ }
-++ if (!WinUSBX[sub_api].SetPipePolicy(winusb_handle, endpoint_address,
-++ RAW_IO, sizeof(UCHAR), &policy)) {
-++ usbi_dbg("failed to enable RAW_IO for endpoint %02X", endpoint_address);
-++ }
-+ }
++diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c
++index a03d6a51216a..a0ac0c609e99 100644
++--- a/libusb/os/windows_winusb.c
+++++ b/libusb/os/windows_winusb.c
++@@ -3086,6 +3086,15 @@ static int winusbx_submit_bulk_transfer(int sub_api, struct usbi_transfer *itran
++ set_transfer_priv_handle(itransfer, handle_priv->interface_handle[current_interface].dev_handle);
++ overlapped = get_transfer_priv_overlapped(itransfer);
+
-+ return LIBUSB_SUCCESS;
-+--
-+2.5.0
-+
+++ if (sub_api == SUB_API_WINUSB)
+++ {
+++ // Use RAW_IO when transfer size is divisible by 512 bytes.
+++ UCHAR policy = (transfer->length % 512 == 0);
+++ if (!WinUSBX[sub_api].SetPipePolicy(winusb_handle, transfer->endpoint, RAW_IO, sizeof(UCHAR), &policy)) {
+++ usbi_err(TRANSFER_CTX(transfer), "failed to set RAW_IO for endpoint %02X", transfer->endpoint);
+++ }
+++ }
+++
++ if (IS_XFERIN(transfer)) {
++ usbi_dbg(TRANSFER_CTX(transfer), "reading %d bytes", transfer->length);
++ ret = WinUSBX[sub_api].ReadPipe(winusb_handle, transfer->endpoint, transfer->buffer, transfer->length, NULL, overlapped);