usb 2.1.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +20 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/usb/bindings.d.ts +4 -0
- package/dist/usb/device.js +5 -0
- package/dist/usb/device.js.map +1 -1
- package/dist/usb/index.js +7 -16
- package/dist/usb/index.js.map +1 -1
- package/dist/webusb/webusb-device.d.ts +2 -1
- package/dist/webusb/webusb-device.js +21 -14
- package/dist/webusb/webusb-device.js.map +1 -1
- package/libusb/.gitattributes +2 -6
- package/libusb/.private/appveyor_build.sh +22 -0
- package/libusb/.private/bm.sh +1 -1
- package/libusb/.private/ci-build.sh +67 -0
- package/libusb/.private/ci-container-build.sh +70 -0
- package/libusb/.private/post-rewrite.sh +5 -1
- package/libusb/.private/pre-commit.sh +5 -1
- package/libusb/.private/wbs.txt +4 -19
- package/libusb/.travis.yml +32 -23
- package/libusb/AUTHORS +86 -3
- package/libusb/ChangeLog +54 -3
- package/libusb/INSTALL_WIN.txt +22 -44
- package/libusb/Makefile.am +32 -10
- package/libusb/{README.md → README} +2 -2
- package/libusb/README.git +3 -3
- package/libusb/Xcode/common.xcconfig +23 -19
- package/libusb/Xcode/config.h +25 -13
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +511 -109
- package/libusb/android/README +90 -54
- package/libusb/android/config.h +23 -43
- package/libusb/android/examples/unrooted_android.c +300 -0
- package/libusb/android/examples/unrooted_android.h +36 -0
- package/libusb/android/jni/Android.mk +1 -1
- package/libusb/android/jni/Application.mk +16 -0
- package/libusb/android/jni/examples.mk +63 -29
- package/libusb/android/jni/libusb.mk +14 -8
- package/libusb/android/jni/tests.mk +13 -24
- package/libusb/appveyor.yml +73 -30
- package/libusb/autogen.sh +5 -3
- package/libusb/bootstrap.sh +6 -2
- package/libusb/configure.ac +314 -227
- package/libusb/doc/Makefile.in +22 -0
- package/libusb/doc/doxygen.cfg.in +460 -223
- package/libusb/examples/Makefile.am +6 -13
- package/libusb/examples/dpfp.c +276 -73
- package/libusb/examples/ezusb.c +18 -8
- package/libusb/examples/ezusb.h +6 -17
- package/libusb/examples/fxload.c +4 -5
- package/libusb/examples/hotplugtest.c +1 -1
- package/libusb/examples/sam3u_benchmark.c +59 -24
- package/libusb/examples/testlibusb.c +138 -104
- package/libusb/examples/xusb.c +26 -22
- package/libusb/libusb/Makefile.am +57 -70
- package/libusb/libusb/Makefile.am.extra +26 -0
- package/libusb/libusb/core.c +432 -423
- package/libusb/libusb/descriptor.c +365 -419
- package/libusb/libusb/hotplug.c +200 -104
- package/libusb/libusb/io.c +522 -535
- package/libusb/libusb/libusb-1.0.def +7 -3
- package/libusb/libusb/libusb-1.0.rc +1 -9
- package/libusb/libusb/libusb.h +302 -226
- package/libusb/libusb/libusbi.h +607 -316
- package/libusb/libusb/os/darwin_usb.c +703 -329
- package/libusb/libusb/os/darwin_usb.h +39 -15
- package/libusb/libusb/os/events_posix.c +300 -0
- package/libusb/libusb/os/events_posix.h +59 -0
- package/libusb/libusb/os/events_windows.c +214 -0
- package/libusb/{msvc/missing.h → libusb/os/events_windows.h} +25 -11
- package/libusb/libusb/os/haiku_pollfs.cpp +14 -9
- package/libusb/libusb/os/haiku_usb.h +12 -12
- package/libusb/libusb/os/haiku_usb_backend.cpp +36 -37
- package/libusb/libusb/os/haiku_usb_raw.cpp +80 -116
- package/libusb/libusb/os/linux_netlink.c +55 -63
- package/libusb/libusb/os/linux_udev.c +61 -69
- package/libusb/libusb/os/linux_usbfs.c +926 -1015
- package/libusb/libusb/os/linux_usbfs.h +74 -57
- package/libusb/libusb/os/netbsd_usb.c +103 -168
- package/libusb/libusb/os/null_usb.c +111 -0
- package/libusb/libusb/os/openbsd_usb.c +71 -120
- package/libusb/libusb/os/sunos_usb.c +289 -375
- package/libusb/libusb/os/sunos_usb.h +0 -1
- package/libusb/libusb/os/threads_posix.c +81 -32
- package/libusb/libusb/os/threads_posix.h +19 -23
- package/libusb/libusb/os/threads_windows.c +9 -95
- package/libusb/libusb/os/threads_windows.h +33 -31
- package/libusb/libusb/os/windows_common.c +915 -0
- package/libusb/libusb/os/windows_common.h +330 -42
- package/libusb/libusb/os/windows_usbdk.c +161 -267
- package/libusb/libusb/os/windows_usbdk.h +5 -2
- package/libusb/libusb/os/windows_winusb.c +1355 -1192
- package/libusb/libusb/os/windows_winusb.h +167 -167
- package/libusb/libusb/strerror.c +20 -30
- package/libusb/libusb/sync.c +20 -21
- package/libusb/libusb/version.h +1 -1
- package/libusb/libusb/version_nano.h +1 -1
- package/libusb/msvc/.gitattributes +3 -0
- package/libusb/msvc/config.h +27 -20
- package/libusb/msvc/{hotplugtest_2012.vcxproj → dpfp_2013.vcxproj} +14 -10
- package/libusb/msvc/dpfp_2013.vcxproj.filters +26 -0
- package/libusb/msvc/{listdevs_2010.vcxproj → dpfp_2015.vcxproj} +14 -9
- package/libusb/msvc/dpfp_2015.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_2017.vcxproj +106 -0
- package/libusb/msvc/dpfp_2017.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_2019.vcxproj +106 -0
- package/libusb/msvc/dpfp_2019.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_threaded_2013.vcxproj +87 -0
- package/libusb/msvc/dpfp_threaded_2013.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_threaded_2015.vcxproj +87 -0
- package/libusb/msvc/dpfp_threaded_2015.vcxproj.filters +26 -0
- package/libusb/msvc/dpfp_threaded_2017.vcxproj +106 -0
- package/libusb/msvc/dpfp_threaded_2017.vcxproj.filters +26 -0
- package/libusb/msvc/{fxload_2012.vcxproj → dpfp_threaded_2019.vcxproj} +32 -17
- package/libusb/msvc/dpfp_threaded_2019.vcxproj.filters +26 -0
- package/libusb/msvc/fxload_2013.vcxproj +6 -3
- package/libusb/msvc/fxload_2013.vcxproj.filters +35 -0
- package/libusb/msvc/fxload_2015.vcxproj +6 -3
- package/libusb/msvc/fxload_2015.vcxproj.filters +35 -0
- package/libusb/msvc/fxload_2017.vcxproj +6 -7
- package/libusb/msvc/fxload_2017.vcxproj.filters +35 -0
- package/libusb/msvc/{fxload_2010.vcxproj → fxload_2019.vcxproj} +29 -6
- package/libusb/msvc/fxload_2019.vcxproj.filters +35 -0
- package/libusb/{examples → msvc}/getopt/getopt.c +0 -0
- package/libusb/{examples → msvc}/getopt/getopt.h +0 -0
- package/libusb/{examples → msvc}/getopt/getopt1.c +0 -0
- package/libusb/msvc/getopt_2013.vcxproj +4 -5
- package/libusb/msvc/getopt_2013.vcxproj.filters +26 -0
- package/libusb/msvc/getopt_2015.vcxproj +4 -4
- package/libusb/msvc/getopt_2015.vcxproj.filters +26 -0
- package/libusb/msvc/getopt_2017.vcxproj +4 -10
- package/libusb/msvc/getopt_2017.vcxproj.filters +26 -0
- package/libusb/msvc/{getopt_2012.vcxproj → getopt_2019.vcxproj} +25 -6
- package/libusb/msvc/getopt_2019.vcxproj.filters +26 -0
- package/libusb/msvc/hotplugtest_2013.vcxproj +6 -3
- package/libusb/msvc/hotplugtest_2013.vcxproj.filters +23 -0
- package/libusb/msvc/hotplugtest_2015.vcxproj +6 -3
- package/libusb/msvc/hotplugtest_2015.vcxproj.filters +23 -0
- package/libusb/msvc/hotplugtest_2017.vcxproj +6 -7
- package/libusb/msvc/hotplugtest_2017.vcxproj.filters +23 -0
- package/libusb/msvc/hotplugtest_2019.vcxproj +105 -0
- package/libusb/msvc/hotplugtest_2019.vcxproj.filters +23 -0
- package/libusb/msvc/libusb_2013.sln +50 -20
- package/libusb/msvc/libusb_2015.sln +51 -21
- package/libusb/msvc/libusb_2017.sln +90 -36
- package/libusb/msvc/libusb_2019.sln +240 -0
- package/libusb/msvc/libusb_dll_2013.vcxproj +6 -9
- package/libusb/msvc/libusb_dll_2013.vcxproj.filters +94 -0
- package/libusb/msvc/libusb_dll_2015.vcxproj +6 -8
- package/libusb/msvc/libusb_dll_2015.vcxproj.filters +94 -0
- package/libusb/msvc/libusb_dll_2017.vcxproj +6 -16
- package/libusb/msvc/libusb_dll_2017.vcxproj.filters +94 -0
- package/libusb/msvc/{libusb_dll_2010.vcxproj → libusb_dll_2019.vcxproj} +27 -9
- package/libusb/msvc/libusb_dll_2019.vcxproj.filters +94 -0
- package/libusb/msvc/libusb_static_2013.vcxproj +5 -9
- package/libusb/msvc/libusb_static_2013.vcxproj.filters +80 -0
- package/libusb/msvc/libusb_static_2015.vcxproj +5 -8
- package/libusb/msvc/libusb_static_2015.vcxproj.filters +80 -0
- package/libusb/msvc/libusb_static_2017.vcxproj +5 -8
- package/libusb/msvc/libusb_static_2017.vcxproj.filters +80 -0
- package/libusb/msvc/{libusb_static_2010.vcxproj → libusb_static_2019.vcxproj} +26 -9
- package/libusb/msvc/libusb_static_2019.vcxproj.filters +80 -0
- package/libusb/msvc/listdevs_2013.vcxproj +6 -3
- package/libusb/msvc/listdevs_2013.vcxproj.filters +23 -0
- package/libusb/msvc/listdevs_2015.vcxproj +6 -3
- package/libusb/msvc/listdevs_2015.vcxproj.filters +23 -0
- package/libusb/msvc/listdevs_2017.vcxproj +6 -7
- package/libusb/msvc/listdevs_2017.vcxproj.filters +23 -0
- package/libusb/msvc/listdevs_2019.vcxproj +105 -0
- package/libusb/msvc/listdevs_2019.vcxproj.filters +23 -0
- package/libusb/msvc/{listdevs_2012.vcxproj → sam3u_benchmark_2013.vcxproj} +13 -9
- package/libusb/msvc/sam3u_benchmark_2013.vcxproj.filters +26 -0
- package/libusb/msvc/{hotplugtest_2010.vcxproj → sam3u_benchmark_2015.vcxproj} +13 -8
- package/libusb/msvc/sam3u_benchmark_2015.vcxproj.filters +26 -0
- package/libusb/msvc/sam3u_benchmark_2017.vcxproj +106 -0
- package/libusb/msvc/sam3u_benchmark_2017.vcxproj.filters +26 -0
- package/libusb/msvc/sam3u_benchmark_2019.vcxproj +106 -0
- package/libusb/msvc/sam3u_benchmark_2019.vcxproj.filters +26 -0
- package/libusb/msvc/stress_2013.vcxproj +4 -2
- package/libusb/msvc/stress_2013.vcxproj.filters +32 -0
- package/libusb/msvc/stress_2015.vcxproj +4 -2
- package/libusb/msvc/stress_2015.vcxproj.filters +32 -0
- package/libusb/msvc/stress_2017.vcxproj +4 -6
- package/libusb/msvc/stress_2017.vcxproj.filters +32 -0
- package/libusb/msvc/{stress_2010.vcxproj → stress_2019.vcxproj} +26 -4
- package/libusb/msvc/stress_2019.vcxproj.filters +32 -0
- package/libusb/msvc/testlibusb_2013.vcxproj +6 -3
- package/libusb/msvc/testlibusb_2013.vcxproj.filters +23 -0
- package/libusb/msvc/testlibusb_2015.vcxproj +6 -3
- package/libusb/msvc/testlibusb_2015.vcxproj.filters +23 -0
- package/libusb/msvc/testlibusb_2017.vcxproj +6 -7
- package/libusb/msvc/testlibusb_2017.vcxproj.filters +23 -0
- package/libusb/msvc/{testlibusb_2010.vcxproj → testlibusb_2019.vcxproj} +28 -5
- package/libusb/msvc/testlibusb_2019.vcxproj.filters +23 -0
- package/libusb/msvc/xusb_2013.vcxproj +6 -3
- package/libusb/msvc/xusb_2013.vcxproj.filters +23 -0
- package/libusb/msvc/xusb_2015.vcxproj +6 -3
- package/libusb/msvc/xusb_2015.vcxproj.filters +23 -0
- package/libusb/msvc/xusb_2017.vcxproj +6 -7
- package/libusb/msvc/xusb_2017.vcxproj.filters +23 -0
- package/libusb/msvc/{xusb_2010.vcxproj → xusb_2019.vcxproj} +28 -5
- package/libusb/msvc/xusb_2019.vcxproj.filters +23 -0
- package/libusb/tests/Makefile.am +13 -1
- package/libusb/tests/libusb_testlib.h +12 -43
- package/libusb/tests/stress.c +59 -50
- package/libusb/tests/testlib.c +78 -171
- package/libusb/tests/umockdev.c +1175 -0
- package/libusb.gypi +10 -11
- package/package.json +2 -2
- package/prebuilds/android-arm/node.napi.armv7.node +0 -0
- package/prebuilds/android-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv6.node +0 -0
- package/prebuilds/linux-arm/node.napi.armv7.node +0 -0
- package/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
- package/prebuilds/linux-ia32/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/node.napi.musl.node +0 -0
- package/prebuilds/win32-ia32/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/device.cc +12 -7
- package/src/node_usb.cc +10 -0
- package/test/usb.coffee +6 -0
- package/tsc/index.ts +2 -0
- package/tsc/usb/bindings.ts +5 -0
- package/tsc/usb/device.ts +6 -0
- package/tsc/usb/index.ts +5 -8
- package/tsc/webusb/webusb-device.ts +12 -8
- package/libusb/.private/bd.cmd +0 -89
- package/libusb/.private/bwince.cmd +0 -57
- package/libusb/.private/wbs_wince.txt +0 -42
- package/libusb/Brewfile +0 -4
- package/libusb/appveyor_cygwin.bat +0 -11
- package/libusb/appveyor_minGW.bat +0 -19
- package/libusb/doc/Makefile.am +0 -9
- package/libusb/examples/dpfp_threaded.c +0 -557
- package/libusb/libusb/hotplug.h +0 -99
- package/libusb/libusb/os/poll_posix.c +0 -84
- package/libusb/libusb/os/poll_posix.h +0 -14
- package/libusb/libusb/os/poll_windows.c +0 -447
- package/libusb/libusb/os/poll_windows.h +0 -98
- package/libusb/libusb/os/wince_usb.c +0 -888
- package/libusb/libusb/os/wince_usb.h +0 -126
- package/libusb/libusb/os/windows_nt_common.c +0 -1010
- package/libusb/libusb/os/windows_nt_common.h +0 -110
- package/libusb/libusb/os/windows_nt_shared_types.h +0 -147
- package/libusb/msvc/appveyor.bat +0 -27
- package/libusb/msvc/ddk_build.cmd +0 -219
- package/libusb/msvc/errno.h +0 -102
- package/libusb/msvc/fxload_sources +0 -23
- package/libusb/msvc/getopt_2005.vcproj +0 -288
- package/libusb/msvc/getopt_2010.vcxproj +0 -72
- package/libusb/msvc/getopt_sources +0 -24
- package/libusb/msvc/hotplugtest_sources +0 -20
- package/libusb/msvc/inttypes.h +0 -295
- package/libusb/msvc/libusb.dsw +0 -71
- package/libusb/msvc/libusb_2005.sln +0 -95
- package/libusb/msvc/libusb_2010.sln +0 -105
- package/libusb/msvc/libusb_2012.sln +0 -105
- package/libusb/msvc/libusb_dll.dsp +0 -194
- package/libusb/msvc/libusb_dll_2005.vcproj +0 -464
- package/libusb/msvc/libusb_dll_2012.vcxproj +0 -107
- package/libusb/msvc/libusb_dll_wince.vcproj +0 -1251
- package/libusb/msvc/libusb_sources +0 -43
- package/libusb/msvc/libusb_static.dsp +0 -174
- package/libusb/msvc/libusb_static_2005.vcproj +0 -390
- package/libusb/msvc/libusb_static_2012.vcxproj +0 -98
- package/libusb/msvc/libusb_static_wince.vcproj +0 -1179
- package/libusb/msvc/libusb_wince.sln +0 -246
- package/libusb/msvc/listdevs.dsp +0 -103
- package/libusb/msvc/listdevs_2005.vcproj +0 -360
- package/libusb/msvc/listdevs_sources +0 -20
- package/libusb/msvc/listdevs_wince.vcproj +0 -1120
- package/libusb/msvc/missing.c +0 -80
- package/libusb/msvc/stdint.h +0 -256
- package/libusb/msvc/stress_2005.vcproj +0 -390
- package/libusb/msvc/stress_2012.vcxproj +0 -87
- package/libusb/msvc/stress_sources +0 -21
- package/libusb/msvc/stress_wince.vcproj +0 -1128
- package/libusb/msvc/testlibusb_2012.vcxproj +0 -83
- package/libusb/msvc/testlibusb_sources +0 -20
- package/libusb/msvc/xusb.dsp +0 -102
- package/libusb/msvc/xusb_2005.vcproj +0 -344
- package/libusb/msvc/xusb_2012.vcxproj +0 -83
- package/libusb/msvc/xusb_sources +0 -20
- package/libusb/msvc/xusb_wince.vcproj +0 -1120
- package/libusb/travis-autogen.sh +0 -39
|
@@ -36,8 +36,7 @@ struct device_priv {
|
|
|
36
36
|
char *devname; /* name of the ugen(4) node */
|
|
37
37
|
int fd; /* device file descriptor */
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
usb_device_descriptor_t ddesc; /* usb device descriptor */
|
|
39
|
+
usb_config_descriptor_t *cdesc; /* active config descriptor */
|
|
41
40
|
};
|
|
42
41
|
|
|
43
42
|
struct handle_priv {
|
|
@@ -52,30 +51,25 @@ static int obsd_get_device_list(struct libusb_context *,
|
|
|
52
51
|
static int obsd_open(struct libusb_device_handle *);
|
|
53
52
|
static void obsd_close(struct libusb_device_handle *);
|
|
54
53
|
|
|
55
|
-
static int obsd_get_device_descriptor(struct libusb_device *, unsigned char *,
|
|
56
|
-
int *);
|
|
57
54
|
static int obsd_get_active_config_descriptor(struct libusb_device *,
|
|
58
|
-
|
|
55
|
+
void *, size_t);
|
|
59
56
|
static int obsd_get_config_descriptor(struct libusb_device *, uint8_t,
|
|
60
|
-
|
|
57
|
+
void *, size_t);
|
|
61
58
|
|
|
62
|
-
static int obsd_get_configuration(struct libusb_device_handle *,
|
|
59
|
+
static int obsd_get_configuration(struct libusb_device_handle *, uint8_t *);
|
|
63
60
|
static int obsd_set_configuration(struct libusb_device_handle *, int);
|
|
64
61
|
|
|
65
|
-
static int obsd_claim_interface(struct libusb_device_handle *,
|
|
66
|
-
static int obsd_release_interface(struct libusb_device_handle *,
|
|
62
|
+
static int obsd_claim_interface(struct libusb_device_handle *, uint8_t);
|
|
63
|
+
static int obsd_release_interface(struct libusb_device_handle *, uint8_t);
|
|
67
64
|
|
|
68
|
-
static int obsd_set_interface_altsetting(struct libusb_device_handle *,
|
|
69
|
-
|
|
65
|
+
static int obsd_set_interface_altsetting(struct libusb_device_handle *, uint8_t,
|
|
66
|
+
uint8_t);
|
|
70
67
|
static int obsd_clear_halt(struct libusb_device_handle *, unsigned char);
|
|
71
|
-
static int obsd_reset_device(struct libusb_device_handle *);
|
|
72
68
|
static void obsd_destroy_device(struct libusb_device *);
|
|
73
69
|
|
|
74
70
|
static int obsd_submit_transfer(struct usbi_transfer *);
|
|
75
71
|
static int obsd_cancel_transfer(struct usbi_transfer *);
|
|
76
|
-
static void obsd_clear_transfer_priv(struct usbi_transfer *);
|
|
77
72
|
static int obsd_handle_transfer_completion(struct usbi_transfer *);
|
|
78
|
-
static int obsd_clock_gettime(int, struct timespec *);
|
|
79
73
|
|
|
80
74
|
/*
|
|
81
75
|
* Private functions
|
|
@@ -95,7 +89,6 @@ const struct usbi_os_backend usbi_backend = {
|
|
|
95
89
|
.open = obsd_open,
|
|
96
90
|
.close = obsd_close,
|
|
97
91
|
|
|
98
|
-
.get_device_descriptor = obsd_get_device_descriptor,
|
|
99
92
|
.get_active_config_descriptor = obsd_get_active_config_descriptor,
|
|
100
93
|
.get_config_descriptor = obsd_get_config_descriptor,
|
|
101
94
|
|
|
@@ -107,16 +100,13 @@ const struct usbi_os_backend usbi_backend = {
|
|
|
107
100
|
|
|
108
101
|
.set_interface_altsetting = obsd_set_interface_altsetting,
|
|
109
102
|
.clear_halt = obsd_clear_halt,
|
|
110
|
-
.reset_device = obsd_reset_device,
|
|
111
103
|
.destroy_device = obsd_destroy_device,
|
|
112
104
|
|
|
113
105
|
.submit_transfer = obsd_submit_transfer,
|
|
114
106
|
.cancel_transfer = obsd_cancel_transfer,
|
|
115
|
-
.clear_transfer_priv = obsd_clear_transfer_priv,
|
|
116
107
|
|
|
117
108
|
.handle_transfer_completion = obsd_handle_transfer_completion,
|
|
118
109
|
|
|
119
|
-
.clock_gettime = obsd_clock_gettime,
|
|
120
110
|
.device_priv_size = sizeof(struct device_priv),
|
|
121
111
|
.device_handle_priv_size = sizeof(struct handle_priv),
|
|
122
112
|
};
|
|
@@ -139,7 +129,7 @@ obsd_get_device_list(struct libusb_context * ctx,
|
|
|
139
129
|
char *udevname;
|
|
140
130
|
int fd, addr, i, j;
|
|
141
131
|
|
|
142
|
-
usbi_dbg("");
|
|
132
|
+
usbi_dbg(ctx, " ");
|
|
143
133
|
|
|
144
134
|
for (i = 0; i < 8; i++) {
|
|
145
135
|
snprintf(busnode, sizeof(busnode), USBDEV "%d", i);
|
|
@@ -183,10 +173,10 @@ obsd_get_device_list(struct libusb_context * ctx,
|
|
|
183
173
|
dev->bus_number = di.udi_bus;
|
|
184
174
|
dev->device_address = di.udi_addr;
|
|
185
175
|
dev->speed = di.udi_speed;
|
|
176
|
+
dev->port_number = di.udi_port;
|
|
186
177
|
|
|
187
|
-
dpriv = (
|
|
178
|
+
dpriv = usbi_get_device_priv(dev);
|
|
188
179
|
dpriv->fd = -1;
|
|
189
|
-
dpriv->cdesc = NULL;
|
|
190
180
|
dpriv->devname = udevname;
|
|
191
181
|
|
|
192
182
|
dd.udd_bus = di.udi_bus;
|
|
@@ -195,7 +185,11 @@ obsd_get_device_list(struct libusb_context * ctx,
|
|
|
195
185
|
libusb_unref_device(dev);
|
|
196
186
|
continue;
|
|
197
187
|
}
|
|
198
|
-
|
|
188
|
+
|
|
189
|
+
static_assert(sizeof(dev->device_descriptor) == sizeof(dd.udd_desc),
|
|
190
|
+
"mismatch between libusb and OS device descriptor sizes");
|
|
191
|
+
memcpy(&dev->device_descriptor, &dd.udd_desc, LIBUSB_DT_DEVICE_SIZE);
|
|
192
|
+
usbi_localize_device_descriptor(&dev->device_descriptor);
|
|
199
193
|
|
|
200
194
|
if (_cache_active_config_descriptor(dev)) {
|
|
201
195
|
libusb_unref_device(dev);
|
|
@@ -228,21 +222,23 @@ obsd_get_device_list(struct libusb_context * ctx,
|
|
|
228
222
|
int
|
|
229
223
|
obsd_open(struct libusb_device_handle *handle)
|
|
230
224
|
{
|
|
231
|
-
struct device_priv *dpriv = (
|
|
225
|
+
struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
|
|
232
226
|
char devnode[16];
|
|
233
227
|
|
|
234
228
|
if (dpriv->devname) {
|
|
229
|
+
int fd;
|
|
235
230
|
/*
|
|
236
231
|
* Only open ugen(4) attached devices read-write, all
|
|
237
232
|
* read-only operations are done through the bus node.
|
|
238
233
|
*/
|
|
239
234
|
snprintf(devnode, sizeof(devnode), DEVPATH "%s.00",
|
|
240
235
|
dpriv->devname);
|
|
241
|
-
|
|
242
|
-
if (
|
|
236
|
+
fd = open(devnode, O_RDWR);
|
|
237
|
+
if (fd < 0)
|
|
243
238
|
return _errno_to_libusb(errno);
|
|
239
|
+
dpriv->fd = fd;
|
|
244
240
|
|
|
245
|
-
usbi_dbg("open %s: fd %d", devnode, dpriv->fd);
|
|
241
|
+
usbi_dbg(HANDLE_CTX(handle), "open %s: fd %d", devnode, dpriv->fd);
|
|
246
242
|
}
|
|
247
243
|
|
|
248
244
|
return (LIBUSB_SUCCESS);
|
|
@@ -251,52 +247,34 @@ obsd_open(struct libusb_device_handle *handle)
|
|
|
251
247
|
void
|
|
252
248
|
obsd_close(struct libusb_device_handle *handle)
|
|
253
249
|
{
|
|
254
|
-
struct device_priv *dpriv = (
|
|
250
|
+
struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
|
|
255
251
|
|
|
256
252
|
if (dpriv->devname) {
|
|
257
|
-
usbi_dbg("close: fd %d", dpriv->fd);
|
|
253
|
+
usbi_dbg(HANDLE_CTX(handle), "close: fd %d", dpriv->fd);
|
|
258
254
|
|
|
259
255
|
close(dpriv->fd);
|
|
260
256
|
dpriv->fd = -1;
|
|
261
257
|
}
|
|
262
258
|
}
|
|
263
259
|
|
|
264
|
-
int
|
|
265
|
-
obsd_get_device_descriptor(struct libusb_device *dev, unsigned char *buf,
|
|
266
|
-
int *host_endian)
|
|
267
|
-
{
|
|
268
|
-
struct device_priv *dpriv = (struct device_priv *)dev->os_priv;
|
|
269
|
-
|
|
270
|
-
usbi_dbg("");
|
|
271
|
-
|
|
272
|
-
memcpy(buf, &dpriv->ddesc, DEVICE_DESC_LENGTH);
|
|
273
|
-
|
|
274
|
-
*host_endian = 0;
|
|
275
|
-
|
|
276
|
-
return (LIBUSB_SUCCESS);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
260
|
int
|
|
280
261
|
obsd_get_active_config_descriptor(struct libusb_device *dev,
|
|
281
|
-
|
|
262
|
+
void *buf, size_t len)
|
|
282
263
|
{
|
|
283
|
-
struct device_priv *dpriv = (
|
|
284
|
-
usb_config_descriptor_t *ucd = (usb_config_descriptor_t *)dpriv->cdesc;
|
|
264
|
+
struct device_priv *dpriv = usbi_get_device_priv(dev);
|
|
285
265
|
|
|
286
|
-
len = MIN(len, UGETW(
|
|
266
|
+
len = MIN(len, (size_t)UGETW(dpriv->cdesc->wTotalLength));
|
|
287
267
|
|
|
288
|
-
usbi_dbg("len %zu", len);
|
|
268
|
+
usbi_dbg(DEVICE_CTX(dev), "len %zu", len);
|
|
289
269
|
|
|
290
270
|
memcpy(buf, dpriv->cdesc, len);
|
|
291
271
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return (len);
|
|
272
|
+
return ((int)len);
|
|
295
273
|
}
|
|
296
274
|
|
|
297
275
|
int
|
|
298
276
|
obsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
|
|
299
|
-
|
|
277
|
+
void *buf, size_t len)
|
|
300
278
|
{
|
|
301
279
|
struct usb_device_fdesc udf;
|
|
302
280
|
int fd, err;
|
|
@@ -310,7 +288,7 @@ obsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
|
|
|
310
288
|
udf.udf_size = len;
|
|
311
289
|
udf.udf_data = buf;
|
|
312
290
|
|
|
313
|
-
usbi_dbg("index %d, len %zu", udf.udf_config_index, len);
|
|
291
|
+
usbi_dbg(DEVICE_CTX(dev), "index %d, len %zu", udf.udf_config_index, len);
|
|
314
292
|
|
|
315
293
|
if (ioctl(fd, USB_DEVICE_GET_FDESC, &udf) < 0) {
|
|
316
294
|
err = errno;
|
|
@@ -319,20 +297,17 @@ obsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
|
|
|
319
297
|
}
|
|
320
298
|
close(fd);
|
|
321
299
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
return (len);
|
|
300
|
+
return ((int)len);
|
|
325
301
|
}
|
|
326
302
|
|
|
327
303
|
int
|
|
328
|
-
obsd_get_configuration(struct libusb_device_handle *handle,
|
|
304
|
+
obsd_get_configuration(struct libusb_device_handle *handle, uint8_t *config)
|
|
329
305
|
{
|
|
330
|
-
struct device_priv *dpriv = (
|
|
331
|
-
usb_config_descriptor_t *ucd = (usb_config_descriptor_t *)dpriv->cdesc;
|
|
306
|
+
struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
|
|
332
307
|
|
|
333
|
-
*config =
|
|
308
|
+
*config = dpriv->cdesc->bConfigurationValue;
|
|
334
309
|
|
|
335
|
-
usbi_dbg("bConfigurationValue %
|
|
310
|
+
usbi_dbg(HANDLE_CTX(handle), "bConfigurationValue %u", *config);
|
|
336
311
|
|
|
337
312
|
return (LIBUSB_SUCCESS);
|
|
338
313
|
}
|
|
@@ -340,12 +315,12 @@ obsd_get_configuration(struct libusb_device_handle *handle, int *config)
|
|
|
340
315
|
int
|
|
341
316
|
obsd_set_configuration(struct libusb_device_handle *handle, int config)
|
|
342
317
|
{
|
|
343
|
-
struct device_priv *dpriv = (
|
|
318
|
+
struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
|
|
344
319
|
|
|
345
320
|
if (dpriv->devname == NULL)
|
|
346
321
|
return (LIBUSB_ERROR_NOT_SUPPORTED);
|
|
347
322
|
|
|
348
|
-
usbi_dbg("bConfigurationValue %d", config);
|
|
323
|
+
usbi_dbg(HANDLE_CTX(handle), "bConfigurationValue %d", config);
|
|
349
324
|
|
|
350
325
|
if (ioctl(dpriv->fd, USB_SET_CONFIG, &config) < 0)
|
|
351
326
|
return _errno_to_libusb(errno);
|
|
@@ -354,11 +329,13 @@ obsd_set_configuration(struct libusb_device_handle *handle, int config)
|
|
|
354
329
|
}
|
|
355
330
|
|
|
356
331
|
int
|
|
357
|
-
obsd_claim_interface(struct libusb_device_handle *handle,
|
|
332
|
+
obsd_claim_interface(struct libusb_device_handle *handle, uint8_t iface)
|
|
358
333
|
{
|
|
359
|
-
struct handle_priv *hpriv = (
|
|
334
|
+
struct handle_priv *hpriv = usbi_get_device_handle_priv(handle);
|
|
360
335
|
int i;
|
|
361
336
|
|
|
337
|
+
UNUSED(iface);
|
|
338
|
+
|
|
362
339
|
for (i = 0; i < USB_MAX_ENDPOINTS; i++)
|
|
363
340
|
hpriv->endpoints[i] = -1;
|
|
364
341
|
|
|
@@ -366,11 +343,13 @@ obsd_claim_interface(struct libusb_device_handle *handle, int iface)
|
|
|
366
343
|
}
|
|
367
344
|
|
|
368
345
|
int
|
|
369
|
-
obsd_release_interface(struct libusb_device_handle *handle,
|
|
346
|
+
obsd_release_interface(struct libusb_device_handle *handle, uint8_t iface)
|
|
370
347
|
{
|
|
371
|
-
struct handle_priv *hpriv = (
|
|
348
|
+
struct handle_priv *hpriv = usbi_get_device_handle_priv(handle);
|
|
372
349
|
int i;
|
|
373
350
|
|
|
351
|
+
UNUSED(iface);
|
|
352
|
+
|
|
374
353
|
for (i = 0; i < USB_MAX_ENDPOINTS; i++)
|
|
375
354
|
if (hpriv->endpoints[i] >= 0)
|
|
376
355
|
close(hpriv->endpoints[i]);
|
|
@@ -379,16 +358,16 @@ obsd_release_interface(struct libusb_device_handle *handle, int iface)
|
|
|
379
358
|
}
|
|
380
359
|
|
|
381
360
|
int
|
|
382
|
-
obsd_set_interface_altsetting(struct libusb_device_handle *handle,
|
|
383
|
-
|
|
361
|
+
obsd_set_interface_altsetting(struct libusb_device_handle *handle, uint8_t iface,
|
|
362
|
+
uint8_t altsetting)
|
|
384
363
|
{
|
|
385
|
-
struct device_priv *dpriv = (
|
|
364
|
+
struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
|
|
386
365
|
struct usb_alt_interface intf;
|
|
387
366
|
|
|
388
367
|
if (dpriv->devname == NULL)
|
|
389
368
|
return (LIBUSB_ERROR_NOT_SUPPORTED);
|
|
390
369
|
|
|
391
|
-
usbi_dbg("iface %
|
|
370
|
+
usbi_dbg(HANDLE_CTX(handle), "iface %u, setting %u", iface, altsetting);
|
|
392
371
|
|
|
393
372
|
memset(&intf, 0, sizeof(intf));
|
|
394
373
|
|
|
@@ -410,7 +389,7 @@ obsd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
|
|
|
410
389
|
if ((fd = _bus_open(handle->dev->bus_number)) < 0)
|
|
411
390
|
return _errno_to_libusb(errno);
|
|
412
391
|
|
|
413
|
-
usbi_dbg("");
|
|
392
|
+
usbi_dbg(HANDLE_CTX(handle), " ");
|
|
414
393
|
|
|
415
394
|
req.ucr_addr = handle->dev->device_address;
|
|
416
395
|
req.ucr_request.bmRequestType = UT_WRITE_ENDPOINT;
|
|
@@ -429,20 +408,12 @@ obsd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
|
|
|
429
408
|
return (LIBUSB_SUCCESS);
|
|
430
409
|
}
|
|
431
410
|
|
|
432
|
-
int
|
|
433
|
-
obsd_reset_device(struct libusb_device_handle *handle)
|
|
434
|
-
{
|
|
435
|
-
usbi_dbg("");
|
|
436
|
-
|
|
437
|
-
return (LIBUSB_ERROR_NOT_SUPPORTED);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
411
|
void
|
|
441
412
|
obsd_destroy_device(struct libusb_device *dev)
|
|
442
413
|
{
|
|
443
|
-
struct device_priv *dpriv = (
|
|
414
|
+
struct device_priv *dpriv = usbi_get_device_priv(dev);
|
|
444
415
|
|
|
445
|
-
usbi_dbg("");
|
|
416
|
+
usbi_dbg(DEVICE_CTX(dev), " ");
|
|
446
417
|
|
|
447
418
|
free(dpriv->cdesc);
|
|
448
419
|
free(dpriv->devname);
|
|
@@ -452,13 +423,11 @@ int
|
|
|
452
423
|
obsd_submit_transfer(struct usbi_transfer *itransfer)
|
|
453
424
|
{
|
|
454
425
|
struct libusb_transfer *transfer;
|
|
455
|
-
struct handle_priv *hpriv;
|
|
456
426
|
int err = 0;
|
|
457
427
|
|
|
458
|
-
usbi_dbg("");
|
|
428
|
+
usbi_dbg(ITRANSFER_CTX(itransfer), " ");
|
|
459
429
|
|
|
460
430
|
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
461
|
-
hpriv = (struct handle_priv *)transfer->dev_handle->os_priv;
|
|
462
431
|
|
|
463
432
|
switch (transfer->type) {
|
|
464
433
|
case LIBUSB_TRANSFER_TYPE_CONTROL:
|
|
@@ -497,17 +466,11 @@ obsd_submit_transfer(struct usbi_transfer *itransfer)
|
|
|
497
466
|
int
|
|
498
467
|
obsd_cancel_transfer(struct usbi_transfer *itransfer)
|
|
499
468
|
{
|
|
500
|
-
|
|
469
|
+
UNUSED(itransfer);
|
|
501
470
|
|
|
502
|
-
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
void
|
|
506
|
-
obsd_clear_transfer_priv(struct usbi_transfer *itransfer)
|
|
507
|
-
{
|
|
508
|
-
usbi_dbg("");
|
|
471
|
+
usbi_dbg(ITRANSFER_CTX(itransfer), " ");
|
|
509
472
|
|
|
510
|
-
|
|
473
|
+
return (LIBUSB_ERROR_NOT_SUPPORTED);
|
|
511
474
|
}
|
|
512
475
|
|
|
513
476
|
int
|
|
@@ -516,22 +479,10 @@ obsd_handle_transfer_completion(struct usbi_transfer *itransfer)
|
|
|
516
479
|
return usbi_handle_transfer_completion(itransfer, LIBUSB_TRANSFER_COMPLETED);
|
|
517
480
|
}
|
|
518
481
|
|
|
519
|
-
int
|
|
520
|
-
obsd_clock_gettime(int clkid, struct timespec *tp)
|
|
521
|
-
{
|
|
522
|
-
if (clkid == USBI_CLOCK_REALTIME)
|
|
523
|
-
return clock_gettime(CLOCK_REALTIME, tp);
|
|
524
|
-
|
|
525
|
-
if (clkid == USBI_CLOCK_MONOTONIC)
|
|
526
|
-
return clock_gettime(CLOCK_MONOTONIC, tp);
|
|
527
|
-
|
|
528
|
-
return (LIBUSB_ERROR_INVALID_PARAM);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
482
|
int
|
|
532
483
|
_errno_to_libusb(int err)
|
|
533
484
|
{
|
|
534
|
-
usbi_dbg("error: %s (%d)", strerror(err), err);
|
|
485
|
+
usbi_dbg(NULL, "error: %s (%d)", strerror(err), err);
|
|
535
486
|
|
|
536
487
|
switch (err) {
|
|
537
488
|
case EIO:
|
|
@@ -552,16 +503,16 @@ _errno_to_libusb(int err)
|
|
|
552
503
|
int
|
|
553
504
|
_cache_active_config_descriptor(struct libusb_device *dev)
|
|
554
505
|
{
|
|
555
|
-
struct device_priv *dpriv = (
|
|
506
|
+
struct device_priv *dpriv = usbi_get_device_priv(dev);
|
|
556
507
|
struct usb_device_cdesc udc;
|
|
557
508
|
struct usb_device_fdesc udf;
|
|
558
|
-
|
|
509
|
+
void *buf;
|
|
559
510
|
int fd, len, err;
|
|
560
511
|
|
|
561
512
|
if ((fd = _bus_open(dev->bus_number)) < 0)
|
|
562
513
|
return _errno_to_libusb(errno);
|
|
563
514
|
|
|
564
|
-
usbi_dbg("fd %d, addr %d", fd, dev->device_address);
|
|
515
|
+
usbi_dbg(DEVICE_CTX(dev), "fd %d, addr %d", fd, dev->device_address);
|
|
565
516
|
|
|
566
517
|
udc.udc_bus = dev->bus_number;
|
|
567
518
|
udc.udc_addr = dev->device_address;
|
|
@@ -572,10 +523,10 @@ _cache_active_config_descriptor(struct libusb_device *dev)
|
|
|
572
523
|
return _errno_to_libusb(errno);
|
|
573
524
|
}
|
|
574
525
|
|
|
575
|
-
usbi_dbg("active bLength %d", udc.udc_desc.bLength);
|
|
526
|
+
usbi_dbg(DEVICE_CTX(dev), "active bLength %d", udc.udc_desc.bLength);
|
|
576
527
|
|
|
577
528
|
len = UGETW(udc.udc_desc.wTotalLength);
|
|
578
|
-
buf = malloc(len);
|
|
529
|
+
buf = malloc((size_t)len);
|
|
579
530
|
if (buf == NULL)
|
|
580
531
|
return (LIBUSB_ERROR_NO_MEM);
|
|
581
532
|
|
|
@@ -585,7 +536,7 @@ _cache_active_config_descriptor(struct libusb_device *dev)
|
|
|
585
536
|
udf.udf_size = len;
|
|
586
537
|
udf.udf_data = buf;
|
|
587
538
|
|
|
588
|
-
usbi_dbg("index %d, len %d", udf.udf_config_index, len);
|
|
539
|
+
usbi_dbg(DEVICE_CTX(dev), "index %d, len %d", udf.udf_config_index, len);
|
|
589
540
|
|
|
590
541
|
if (ioctl(fd, USB_DEVICE_GET_FDESC, &udf) < 0) {
|
|
591
542
|
err = errno;
|
|
@@ -611,10 +562,10 @@ _sync_control_transfer(struct usbi_transfer *itransfer)
|
|
|
611
562
|
struct usb_ctl_request req;
|
|
612
563
|
|
|
613
564
|
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
614
|
-
dpriv = (
|
|
565
|
+
dpriv = usbi_get_device_priv(transfer->dev_handle->dev);
|
|
615
566
|
setup = (struct libusb_control_setup *)transfer->buffer;
|
|
616
567
|
|
|
617
|
-
usbi_dbg("type %x request %x value %x index %d length %d timeout %d",
|
|
568
|
+
usbi_dbg(ITRANSFER_CTX(itransfer), "type 0x%x request 0x%x value 0x%x index %d length %d timeout %d",
|
|
618
569
|
setup->bmRequestType, setup->bRequest,
|
|
619
570
|
libusb_le16_to_cpu(setup->wValue),
|
|
620
571
|
libusb_le16_to_cpu(setup->wIndex),
|
|
@@ -659,7 +610,7 @@ _sync_control_transfer(struct usbi_transfer *itransfer)
|
|
|
659
610
|
|
|
660
611
|
itransfer->transferred = req.ucr_actlen;
|
|
661
612
|
|
|
662
|
-
usbi_dbg("transferred %d", itransfer->transferred);
|
|
613
|
+
usbi_dbg(ITRANSFER_CTX(itransfer), "transferred %d", itransfer->transferred);
|
|
663
614
|
|
|
664
615
|
return (0);
|
|
665
616
|
}
|
|
@@ -673,13 +624,13 @@ _access_endpoint(struct libusb_transfer *transfer)
|
|
|
673
624
|
int fd, endpt;
|
|
674
625
|
mode_t mode;
|
|
675
626
|
|
|
676
|
-
hpriv = (
|
|
677
|
-
dpriv = (
|
|
627
|
+
hpriv = usbi_get_device_handle_priv(transfer->dev_handle);
|
|
628
|
+
dpriv = usbi_get_device_priv(transfer->dev_handle->dev);
|
|
678
629
|
|
|
679
630
|
endpt = UE_GET_ADDR(transfer->endpoint);
|
|
680
631
|
mode = IS_XFERIN(transfer) ? O_RDONLY : O_WRONLY;
|
|
681
632
|
|
|
682
|
-
usbi_dbg("endpoint %d mode %d", endpt, mode);
|
|
633
|
+
usbi_dbg(TRANSFER_CTX(transfer), "endpoint %d mode %d", endpt, mode);
|
|
683
634
|
|
|
684
635
|
if (hpriv->endpoints[endpt] < 0) {
|
|
685
636
|
/* Pick the right endpoint node */
|
|
@@ -705,7 +656,7 @@ _sync_gen_transfer(struct usbi_transfer *itransfer)
|
|
|
705
656
|
int fd, nr = 1;
|
|
706
657
|
|
|
707
658
|
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
708
|
-
dpriv = (
|
|
659
|
+
dpriv = usbi_get_device_priv(transfer->dev_handle->dev);
|
|
709
660
|
|
|
710
661
|
if (dpriv->devname == NULL)
|
|
711
662
|
return (LIBUSB_ERROR_NOT_SUPPORTED);
|