From eb4f49b28395cec5dbec80ff4c95792461ab52a4 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 15 Aug 2018 10:06:14 +0200 Subject: [PATCH] libusb: use new ioctl to get full configuration descriptor --- dev-libs/libusb/libusb-1.0.22.recipe | 2 +- .../libusb/patches/libusb-1.0.22.patchset | 84 ++++++++++++++++++- 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/dev-libs/libusb/libusb-1.0.22.recipe b/dev-libs/libusb/libusb-1.0.22.recipe index 7fc3a0306..088a0dc2e 100644 --- a/dev-libs/libusb/libusb-1.0.22.recipe +++ b/dev-libs/libusb/libusb-1.0.22.recipe @@ -20,7 +20,7 @@ COPYRIGHT="2001 Johannes Erdfelt 2012-2013 Toby Gray 2013-2018 Chris Dickens" LICENSE="GNU LGPL v2.1" -REVISION="1" +REVISION="2" SOURCE_URI="https://github.com/libusb/libusb/archive/v$portVersion.tar.gz" CHECKSUM_SHA256="3500f7b182750cd9ccf9be8b1df998f83df56a39ab264976bdb3307773e16f48" SOURCE_FILENAME="libusb-$portVersion.tar.gz" diff --git a/dev-libs/libusb/patches/libusb-1.0.22.patchset b/dev-libs/libusb/patches/libusb-1.0.22.patchset index 05b526840..6323fbe5e 100644 --- a/dev-libs/libusb/patches/libusb-1.0.22.patchset +++ b/dev-libs/libusb/patches/libusb-1.0.22.patchset @@ -1,4 +1,4 @@ -From 6272b5474073c90978488ec441270ed3511c09b4 Mon Sep 17 00:00:00 2001 +From f4267b4e34668722beb8cefc6487fb980be4faa6 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Fri, 14 Jul 2017 14:51:19 +0200 Subject: Add a stub for clear_halt. @@ -33,10 +33,10 @@ index c701e34..c81658f 100644 /*.alloc_streams =*/ NULL, -- -2.16.3 +2.16.4 -From 25fd71c6bc25bd1084f7c9a623b78aba8678b127 Mon Sep 17 00:00:00 2001 +From 5338068972352f26c70b98142e8f94832cba52f5 Mon Sep 17 00:00:00 2001 From: fbrosson Date: Tue, 27 Mar 2018 11:17:19 +0000 Subject: Use the default alignment when compiling with gcc2. @@ -56,5 +56,81 @@ index 31d6ce9..221d2c2 100644 #else #define PTR_ALIGNED -- -2.16.3 +2.16.4 + + +From cfe2018ebb07ccb12bacc30a9450d240e05f060a Mon Sep 17 00:00:00 2001 +From: Adrien Destugues +Date: Wed, 15 Aug 2018 10:03:17 +0200 +Subject: Use new GET_CONFIGURATION_DESCRIPTOR_ETC ioctl +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fixes the problem I was getting, at least for usb2 ports. Time to dig in +the xhci driver now… + +diff --git a/libusb/os/haiku_usb_backend.cpp b/libusb/os/haiku_usb_backend.cpp +index d3de8cc..bac8297 100644 +--- a/libusb/os/haiku_usb_backend.cpp ++++ b/libusb/os/haiku_usb_backend.cpp +@@ -432,6 +432,7 @@ USBDevice::EndpointToInterface(uint8 address) const + int + USBDevice::Initialise() //Do we need more error checking, etc? How to report? + { ++ usbi_dbg("Haiku init dev %s", fPath); + int fRawFD = open(fPath, O_RDWR | O_CLOEXEC); + if (fRawFD < 0) + return B_ERROR; +@@ -458,15 +459,13 @@ USBDevice::Initialise() //Do we need more error checking, etc? How to report? + } + fConfigToIndex[tmp_config.configuration_value] = i; + fConfigurationDescriptors[i] = new(std::nothrow) unsigned char[tmp_config.total_length]; +- command.control.request_type = 128; +- command.control.request = 6; +- command.control.value = (2 << 8) | i; +- command.control.index = 0; +- command.control.length = tmp_config.total_length; +- command.control.data = fConfigurationDescriptors[i]; +- if (ioctl(fRawFD, B_USB_RAW_COMMAND_CONTROL_TRANSFER, &command, sizeof(command)) || +- command.control.status!=B_USB_RAW_STATUS_SUCCESS) { +- usbi_err(NULL, "failed retrieving full configuration descriptor"); ++ ++ command.config_etc.descriptor = (usb_configuration_descriptor*)fConfigurationDescriptors[i]; ++ command.config_etc.length = tmp_config.total_length; ++ command.config_etc.config_index = i; ++ if (ioctl(fRawFD, B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR_ETC, &command, sizeof(command)) || ++ command.config_etc.status != B_USB_RAW_STATUS_SUCCESS) { ++ usbi_err(NULL, "failed retrieving configuration descriptor"); + close(fRawFD); + return B_ERROR; + } +diff --git a/libusb/os/haiku_usb_raw.h b/libusb/os/haiku_usb_raw.h +index 5baf53d..d371f01 100644 +--- a/libusb/os/haiku_usb_raw.h ++++ b/libusb/os/haiku_usb_raw.h +@@ -25,6 +25,7 @@ typedef enum { + B_USB_RAW_COMMAND_GET_INTERFACE_DESCRIPTOR_ETC, + B_USB_RAW_COMMAND_GET_ENDPOINT_DESCRIPTOR_ETC, + B_USB_RAW_COMMAND_GET_GENERIC_DESCRIPTOR_ETC, ++ B_USB_RAW_COMMAND_GET_CONFIGURATION_DESCRIPTOR_ETC, + + B_USB_RAW_COMMAND_SET_CONFIGURATION = 0x3000, + B_USB_RAW_COMMAND_SET_FEATURE, +@@ -74,6 +75,13 @@ typedef union { + uint32 config_index; + } config; + ++ struct { ++ status_t status; ++ usb_configuration_descriptor *descriptor; ++ uint32 config_index; ++ size_t length; ++ } config_etc; ++ + struct { + status_t status; + uint32 alternate_info; +-- +2.16.4