usb 2.17.0 → 3.0.0-alpha.2
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/LICENSE +18 -4
- package/README.md +25 -516
- package/dist/index.d.ts +67 -13
- package/dist/index.js +333 -64
- package/index.d.ts +89 -0
- package/index.js +583 -0
- package/package.json +53 -33
- package/CHANGELOG.md +0 -294
- package/binding.gyp +0 -128
- package/dist/index.js.map +0 -1
- package/dist/usb/bindings.d.ts +0 -266
- package/dist/usb/bindings.js +0 -10
- package/dist/usb/bindings.js.map +0 -1
- package/dist/usb/capability.d.ts +0 -13
- package/dist/usb/capability.js +0 -17
- package/dist/usb/capability.js.map +0 -1
- package/dist/usb/descriptors.d.ts +0 -128
- package/dist/usb/descriptors.js +0 -3
- package/dist/usb/descriptors.js.map +0 -1
- package/dist/usb/device.d.ts +0 -100
- package/dist/usb/device.js +0 -297
- package/dist/usb/device.js.map +0 -1
- package/dist/usb/endpoint.d.ts +0 -94
- package/dist/usb/endpoint.js +0 -219
- package/dist/usb/endpoint.js.map +0 -1
- package/dist/usb/index.d.ts +0 -31
- package/dist/usb/index.js +0 -116
- package/dist/usb/index.js.map +0 -1
- package/dist/usb/interface.d.ts +0 -80
- package/dist/usb/interface.js +0 -133
- package/dist/usb/interface.js.map +0 -1
- package/dist/webusb/index.d.ts +0 -64
- package/dist/webusb/index.js +0 -295
- package/dist/webusb/index.js.map +0 -1
- package/dist/webusb/webusb-device.d.ts +0 -54
- package/dist/webusb/webusb-device.js +0 -434
- package/dist/webusb/webusb-device.js.map +0 -1
- package/libusb/.clang-tidy +0 -34
- package/libusb/.codespellrc +0 -3
- package/libusb/.private/README.txt +0 -5
- package/libusb/.private/appveyor_build.sh +0 -26
- package/libusb/.private/bm.sh +0 -54
- package/libusb/.private/ci-build.sh +0 -92
- package/libusb/.private/ci-container-build.sh +0 -67
- package/libusb/.private/post-rewrite.sh +0 -32
- package/libusb/.private/pre-commit.sh +0 -52
- package/libusb/.private/wbs.txt +0 -43
- package/libusb/.travis.yml +0 -58
- package/libusb/AUTHORS +0 -231
- package/libusb/COPYING +0 -504
- package/libusb/ChangeLog +0 -365
- package/libusb/HACKING +0 -25
- package/libusb/INSTALL_WIN.txt +0 -52
- package/libusb/KEYS +0 -123
- package/libusb/Makefile.am +0 -50
- package/libusb/NEWS +0 -2
- package/libusb/PORTING +0 -94
- package/libusb/README +0 -29
- package/libusb/README.git +0 -41
- package/libusb/TODO +0 -2
- package/libusb/Xcode/common.xcconfig +0 -92
- package/libusb/Xcode/config.h +0 -31
- package/libusb/Xcode/debug.xcconfig +0 -32
- package/libusb/Xcode/libusb.xcconfig +0 -21
- package/libusb/Xcode/libusb.xcodeproj/project.pbxproj +0 -1391
- package/libusb/Xcode/libusb_debug.xcconfig +0 -21
- package/libusb/Xcode/libusb_release.xcconfig +0 -21
- package/libusb/Xcode/release.xcconfig +0 -30
- package/libusb/android/README +0 -152
- package/libusb/android/config.h +0 -55
- package/libusb/android/examples/unrooted_android.c +0 -301
- package/libusb/android/examples/unrooted_android.h +0 -36
- package/libusb/android/jni/Android.mk +0 -23
- package/libusb/android/jni/Application.mk +0 -40
- package/libusb/android/jni/examples.mk +0 -168
- package/libusb/android/jni/libusb.mk +0 -60
- package/libusb/android/jni/tests.mk +0 -45
- package/libusb/appveyor.yml +0 -108
- package/libusb/autogen.sh +0 -10
- package/libusb/bootstrap.sh +0 -10
- package/libusb/configure.ac +0 -450
- package/libusb/doc/Makefile.in +0 -22
- package/libusb/doc/doxygen.cfg.in +0 -2571
- package/libusb/doc/libusb.png +0 -0
- package/libusb/examples/Makefile.am +0 -12
- package/libusb/examples/dpfp.c +0 -711
- package/libusb/examples/ezusb.c +0 -846
- package/libusb/examples/ezusb.h +0 -109
- package/libusb/examples/fxload.c +0 -310
- package/libusb/examples/hotplugtest.c +0 -147
- package/libusb/examples/listdevs.c +0 -73
- package/libusb/examples/sam3u_benchmark.c +0 -228
- package/libusb/examples/testlibusb.c +0 -312
- package/libusb/examples/xusb.c +0 -1254
- package/libusb/libusb/Makefile.am +0 -98
- package/libusb/libusb/Makefile.am.extra +0 -26
- package/libusb/libusb/core.c +0 -2925
- package/libusb/libusb/descriptor.c +0 -1558
- package/libusb/libusb/hotplug.c +0 -489
- package/libusb/libusb/io.c +0 -2865
- package/libusb/libusb/libusb-1.0.def +0 -199
- package/libusb/libusb/libusb-1.0.rc +0 -53
- package/libusb/libusb/libusb.h +0 -2421
- package/libusb/libusb/libusbi.h +0 -1535
- package/libusb/libusb/os/darwin_usb.c +0 -2977
- package/libusb/libusb/os/darwin_usb.h +0 -156
- package/libusb/libusb/os/emscripten_webusb.cpp +0 -875
- package/libusb/libusb/os/events_posix.c +0 -340
- package/libusb/libusb/os/events_posix.h +0 -62
- package/libusb/libusb/os/events_windows.c +0 -214
- package/libusb/libusb/os/events_windows.h +0 -46
- package/libusb/libusb/os/haiku_pollfs.cpp +0 -372
- package/libusb/libusb/os/haiku_usb.h +0 -113
- package/libusb/libusb/os/haiku_usb_backend.cpp +0 -532
- package/libusb/libusb/os/haiku_usb_raw.cpp +0 -231
- package/libusb/libusb/os/haiku_usb_raw.h +0 -188
- package/libusb/libusb/os/linux_netlink.c +0 -401
- package/libusb/libusb/os/linux_udev.c +0 -321
- package/libusb/libusb/os/linux_usbfs.c +0 -2829
- package/libusb/libusb/os/linux_usbfs.h +0 -221
- package/libusb/libusb/os/netbsd_usb.c +0 -617
- package/libusb/libusb/os/null_usb.c +0 -111
- package/libusb/libusb/os/openbsd_usb.c +0 -700
- package/libusb/libusb/os/sunos_usb.c +0 -1619
- package/libusb/libusb/os/sunos_usb.h +0 -79
- package/libusb/libusb/os/threads_posix.c +0 -126
- package/libusb/libusb/os/threads_posix.h +0 -98
- package/libusb/libusb/os/threads_windows.c +0 -40
- package/libusb/libusb/os/threads_windows.h +0 -113
- package/libusb/libusb/os/windows_common.c +0 -923
- package/libusb/libusb/os/windows_common.h +0 -424
- package/libusb/libusb/os/windows_usbdk.c +0 -724
- package/libusb/libusb/os/windows_usbdk.h +0 -106
- package/libusb/libusb/os/windows_winusb.c +0 -4766
- package/libusb/libusb/os/windows_winusb.h +0 -787
- package/libusb/libusb/strerror.c +0 -223
- package/libusb/libusb/sync.c +0 -342
- package/libusb/libusb/version.h +0 -18
- package/libusb/libusb/version_nano.h +0 -1
- package/libusb/libusb-1.0.pc.in +0 -11
- package/libusb/msvc/Base.props +0 -60
- package/libusb/msvc/Configuration.Application.props +0 -7
- package/libusb/msvc/Configuration.Base.props +0 -47
- package/libusb/msvc/Configuration.DynamicLibrary.props +0 -21
- package/libusb/msvc/Configuration.StaticLibrary.props +0 -7
- package/libusb/msvc/ProjectConfigurations.Base.props +0 -69
- package/libusb/msvc/build_all.ps1 +0 -17
- package/libusb/msvc/config.h +0 -58
- package/libusb/msvc/dpfp.vcxproj +0 -33
- package/libusb/msvc/dpfp_threaded.vcxproj +0 -38
- package/libusb/msvc/fxload.vcxproj +0 -46
- package/libusb/msvc/getopt/getopt.c +0 -1060
- package/libusb/msvc/getopt/getopt.h +0 -180
- package/libusb/msvc/getopt/getopt1.c +0 -188
- package/libusb/msvc/getopt.vcxproj +0 -33
- package/libusb/msvc/hotplugtest.vcxproj +0 -32
- package/libusb/msvc/init_context.vcxproj +0 -35
- package/libusb/msvc/libusb.sln +0 -542
- package/libusb/msvc/libusb_dll.vcxproj +0 -61
- package/libusb/msvc/libusb_static.vcxproj +0 -49
- package/libusb/msvc/listdevs.vcxproj +0 -32
- package/libusb/msvc/sam3u_benchmark.vcxproj +0 -33
- package/libusb/msvc/set_option.vcxproj +0 -35
- package/libusb/msvc/stress.vcxproj +0 -35
- package/libusb/msvc/stress_mt.vcxproj +0 -33
- package/libusb/msvc/testlibusb.vcxproj +0 -32
- package/libusb/msvc/xusb.vcxproj +0 -38
- package/libusb/tests/Makefile.am +0 -40
- package/libusb/tests/init_context.c +0 -153
- package/libusb/tests/libusb_testlib.h +0 -76
- package/libusb/tests/macos.c +0 -130
- package/libusb/tests/set_option.c +0 -253
- package/libusb/tests/stress.c +0 -172
- package/libusb/tests/stress_mt.c +0 -267
- package/libusb/tests/testlib.c +0 -184
- package/libusb/tests/umockdev.c +0 -1175
- package/libusb/tests/webusb-test-shim/index.js +0 -12
- package/libusb/tests/webusb-test-shim/package-lock.json +0 -50
- package/libusb/tests/webusb-test-shim/package.json +0 -10
- package/libusb.gypi +0 -154
- package/libusb_config/config.h +0 -1
- 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-arm64/node.napi.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 +0 -439
- package/src/helpers.h +0 -64
- package/src/hotplug/hotplug.h +0 -22
- package/src/hotplug/libusb.cc +0 -90
- package/src/hotplug/windows.cc +0 -168
- package/src/node_usb.cc +0 -314
- package/src/node_usb.h +0 -131
- package/src/thread_name.cc +0 -79
- package/src/thread_name.h +0 -11
- package/src/transfer.cc +0 -143
- package/src/uv_async_queue.h +0 -41
- package/test/usb.coffee +0 -250
- package/test/webusb.coffee +0 -227
- package/test/worker.cjs +0 -13
|
@@ -1,617 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © 2011 Martin Pieuchot <mpi@openbsd.org>
|
|
3
|
-
*
|
|
4
|
-
* This library is free software; you can redistribute it and/or
|
|
5
|
-
* modify it under the terms of the GNU Lesser General Public
|
|
6
|
-
* License as published by the Free Software Foundation; either
|
|
7
|
-
* version 2.1 of the License, or (at your option) any later version.
|
|
8
|
-
*
|
|
9
|
-
* This library is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
-
* Lesser General Public License for more details.
|
|
13
|
-
*
|
|
14
|
-
* You should have received a copy of the GNU Lesser General Public
|
|
15
|
-
* License along with this library; if not, write to the Free Software
|
|
16
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
#include <config.h>
|
|
20
|
-
|
|
21
|
-
#include <sys/time.h>
|
|
22
|
-
#include <sys/types.h>
|
|
23
|
-
|
|
24
|
-
#include <errno.h>
|
|
25
|
-
#include <fcntl.h>
|
|
26
|
-
#include <stdio.h>
|
|
27
|
-
#include <stdlib.h>
|
|
28
|
-
#include <string.h>
|
|
29
|
-
#include <unistd.h>
|
|
30
|
-
|
|
31
|
-
#include <dev/usb/usb.h>
|
|
32
|
-
|
|
33
|
-
#include "libusbi.h"
|
|
34
|
-
|
|
35
|
-
struct device_priv {
|
|
36
|
-
char devnode[16];
|
|
37
|
-
int fd;
|
|
38
|
-
|
|
39
|
-
usb_config_descriptor_t *cdesc; /* active config descriptor */
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
struct handle_priv {
|
|
43
|
-
int endpoints[USB_MAX_ENDPOINTS];
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/*
|
|
47
|
-
* Backend functions
|
|
48
|
-
*/
|
|
49
|
-
static int netbsd_get_device_list(struct libusb_context *,
|
|
50
|
-
struct discovered_devs **);
|
|
51
|
-
static int netbsd_open(struct libusb_device_handle *);
|
|
52
|
-
static void netbsd_close(struct libusb_device_handle *);
|
|
53
|
-
|
|
54
|
-
static int netbsd_get_active_config_descriptor(struct libusb_device *,
|
|
55
|
-
void *, size_t);
|
|
56
|
-
static int netbsd_get_config_descriptor(struct libusb_device *, uint8_t,
|
|
57
|
-
void *, size_t);
|
|
58
|
-
|
|
59
|
-
static int netbsd_get_configuration(struct libusb_device_handle *, uint8_t *);
|
|
60
|
-
static int netbsd_set_configuration(struct libusb_device_handle *, int);
|
|
61
|
-
|
|
62
|
-
static int netbsd_claim_interface(struct libusb_device_handle *, uint8_t);
|
|
63
|
-
static int netbsd_release_interface(struct libusb_device_handle *, uint8_t);
|
|
64
|
-
|
|
65
|
-
static int netbsd_set_interface_altsetting(struct libusb_device_handle *,
|
|
66
|
-
uint8_t, uint8_t);
|
|
67
|
-
static int netbsd_clear_halt(struct libusb_device_handle *, unsigned char);
|
|
68
|
-
static void netbsd_destroy_device(struct libusb_device *);
|
|
69
|
-
|
|
70
|
-
static int netbsd_submit_transfer(struct usbi_transfer *);
|
|
71
|
-
static int netbsd_cancel_transfer(struct usbi_transfer *);
|
|
72
|
-
static int netbsd_handle_transfer_completion(struct usbi_transfer *);
|
|
73
|
-
|
|
74
|
-
/*
|
|
75
|
-
* Private functions
|
|
76
|
-
*/
|
|
77
|
-
static int _errno_to_libusb(int);
|
|
78
|
-
static int _cache_active_config_descriptor(struct libusb_device *, int);
|
|
79
|
-
static int _sync_control_transfer(struct usbi_transfer *);
|
|
80
|
-
static int _sync_gen_transfer(struct usbi_transfer *);
|
|
81
|
-
static int _access_endpoint(struct libusb_transfer *);
|
|
82
|
-
|
|
83
|
-
const struct usbi_os_backend usbi_backend = {
|
|
84
|
-
.name = "Synchronous NetBSD backend",
|
|
85
|
-
.caps = 0,
|
|
86
|
-
.get_device_list = netbsd_get_device_list,
|
|
87
|
-
.open = netbsd_open,
|
|
88
|
-
.close = netbsd_close,
|
|
89
|
-
|
|
90
|
-
.get_active_config_descriptor = netbsd_get_active_config_descriptor,
|
|
91
|
-
.get_config_descriptor = netbsd_get_config_descriptor,
|
|
92
|
-
|
|
93
|
-
.get_configuration = netbsd_get_configuration,
|
|
94
|
-
.set_configuration = netbsd_set_configuration,
|
|
95
|
-
|
|
96
|
-
.claim_interface = netbsd_claim_interface,
|
|
97
|
-
.release_interface = netbsd_release_interface,
|
|
98
|
-
|
|
99
|
-
.set_interface_altsetting = netbsd_set_interface_altsetting,
|
|
100
|
-
.clear_halt = netbsd_clear_halt,
|
|
101
|
-
|
|
102
|
-
.destroy_device = netbsd_destroy_device,
|
|
103
|
-
|
|
104
|
-
.submit_transfer = netbsd_submit_transfer,
|
|
105
|
-
.cancel_transfer = netbsd_cancel_transfer,
|
|
106
|
-
|
|
107
|
-
.handle_transfer_completion = netbsd_handle_transfer_completion,
|
|
108
|
-
|
|
109
|
-
.device_priv_size = sizeof(struct device_priv),
|
|
110
|
-
.device_handle_priv_size = sizeof(struct handle_priv),
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
int
|
|
114
|
-
netbsd_get_device_list(struct libusb_context * ctx,
|
|
115
|
-
struct discovered_devs **discdevs)
|
|
116
|
-
{
|
|
117
|
-
struct libusb_device *dev;
|
|
118
|
-
struct device_priv *dpriv;
|
|
119
|
-
struct usb_device_info di;
|
|
120
|
-
usb_device_descriptor_t ddesc;
|
|
121
|
-
unsigned long session_id;
|
|
122
|
-
char devnode[16];
|
|
123
|
-
int fd, err, i;
|
|
124
|
-
|
|
125
|
-
usbi_dbg(ctx, " ");
|
|
126
|
-
|
|
127
|
-
/* Only ugen(4) is supported */
|
|
128
|
-
for (i = 0; i < USB_MAX_DEVICES; i++) {
|
|
129
|
-
/* Control endpoint is always .00 */
|
|
130
|
-
snprintf(devnode, sizeof(devnode), "/dev/ugen%d.00", i);
|
|
131
|
-
|
|
132
|
-
if ((fd = open(devnode, O_RDONLY)) < 0) {
|
|
133
|
-
if (errno != ENOENT && errno != ENXIO)
|
|
134
|
-
usbi_err(ctx, "could not open %s", devnode);
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (ioctl(fd, USB_GET_DEVICEINFO, &di) < 0)
|
|
139
|
-
continue;
|
|
140
|
-
|
|
141
|
-
session_id = (di.udi_bus << 8 | di.udi_addr);
|
|
142
|
-
dev = usbi_get_device_by_session_id(ctx, session_id);
|
|
143
|
-
|
|
144
|
-
if (dev == NULL) {
|
|
145
|
-
dev = usbi_alloc_device(ctx, session_id);
|
|
146
|
-
if (dev == NULL)
|
|
147
|
-
return LIBUSB_ERROR_NO_MEM;
|
|
148
|
-
|
|
149
|
-
dev->bus_number = 1 + di.udi_bus;
|
|
150
|
-
dev->device_address = 1 + di.udi_addr;
|
|
151
|
-
dev->speed = di.udi_speed; /* NetBSD #define's happen to match libusb enum */
|
|
152
|
-
|
|
153
|
-
dpriv = usbi_get_device_priv(dev);
|
|
154
|
-
strlcpy(dpriv->devnode, devnode, sizeof(devnode));
|
|
155
|
-
dpriv->fd = -1;
|
|
156
|
-
|
|
157
|
-
if (ioctl(fd, USB_GET_DEVICE_DESC, &ddesc) < 0) {
|
|
158
|
-
err = errno;
|
|
159
|
-
goto error;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
static_assert(sizeof(dev->device_descriptor) == sizeof(ddesc),
|
|
163
|
-
"mismatch between libusb and OS device descriptor sizes");
|
|
164
|
-
memcpy(&dev->device_descriptor, &ddesc, LIBUSB_DT_DEVICE_SIZE);
|
|
165
|
-
usbi_localize_device_descriptor(&dev->device_descriptor);
|
|
166
|
-
|
|
167
|
-
if (_cache_active_config_descriptor(dev, fd)) {
|
|
168
|
-
err = errno;
|
|
169
|
-
goto error;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if ((err = usbi_sanitize_device(dev)))
|
|
173
|
-
goto error;
|
|
174
|
-
}
|
|
175
|
-
close(fd);
|
|
176
|
-
|
|
177
|
-
if (discovered_devs_append(*discdevs, dev) == NULL)
|
|
178
|
-
return LIBUSB_ERROR_NO_MEM;
|
|
179
|
-
|
|
180
|
-
libusb_unref_device(dev);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return LIBUSB_SUCCESS;
|
|
184
|
-
|
|
185
|
-
error:
|
|
186
|
-
close(fd);
|
|
187
|
-
libusb_unref_device(dev);
|
|
188
|
-
return _errno_to_libusb(err);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
int
|
|
192
|
-
netbsd_open(struct libusb_device_handle *handle)
|
|
193
|
-
{
|
|
194
|
-
struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
|
|
195
|
-
struct handle_priv *hpriv = usbi_get_device_handle_priv(handle);
|
|
196
|
-
int i;
|
|
197
|
-
|
|
198
|
-
dpriv->fd = open(dpriv->devnode, O_RDWR);
|
|
199
|
-
if (dpriv->fd < 0) {
|
|
200
|
-
dpriv->fd = open(dpriv->devnode, O_RDONLY);
|
|
201
|
-
if (dpriv->fd < 0)
|
|
202
|
-
return _errno_to_libusb(errno);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
for (i = 0; i < USB_MAX_ENDPOINTS; i++)
|
|
206
|
-
hpriv->endpoints[i] = -1;
|
|
207
|
-
|
|
208
|
-
usbi_dbg(HANDLE_CTX(handle), "open %s: fd %d", dpriv->devnode, dpriv->fd);
|
|
209
|
-
|
|
210
|
-
return LIBUSB_SUCCESS;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
void
|
|
214
|
-
netbsd_close(struct libusb_device_handle *handle)
|
|
215
|
-
{
|
|
216
|
-
struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
|
|
217
|
-
|
|
218
|
-
usbi_dbg(HANDLE_CTX(handle), "close: fd %d", dpriv->fd);
|
|
219
|
-
|
|
220
|
-
close(dpriv->fd);
|
|
221
|
-
dpriv->fd = -1;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
int
|
|
225
|
-
netbsd_get_active_config_descriptor(struct libusb_device *dev,
|
|
226
|
-
void *buf, size_t len)
|
|
227
|
-
{
|
|
228
|
-
struct device_priv *dpriv = usbi_get_device_priv(dev);
|
|
229
|
-
|
|
230
|
-
len = MIN(len, (size_t)UGETW(dpriv->cdesc->wTotalLength));
|
|
231
|
-
|
|
232
|
-
usbi_dbg(DEVICE_CTX(dev), "len %zu", len);
|
|
233
|
-
|
|
234
|
-
memcpy(buf, dpriv->cdesc, len);
|
|
235
|
-
|
|
236
|
-
return (int)len;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
int
|
|
240
|
-
netbsd_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
|
|
241
|
-
void *buf, size_t len)
|
|
242
|
-
{
|
|
243
|
-
struct device_priv *dpriv = usbi_get_device_priv(dev);
|
|
244
|
-
struct usb_full_desc ufd;
|
|
245
|
-
int fd, err;
|
|
246
|
-
|
|
247
|
-
usbi_dbg(DEVICE_CTX(dev), "index %u, len %zu", idx, len);
|
|
248
|
-
|
|
249
|
-
/* A config descriptor may be requested before opening the device */
|
|
250
|
-
if (dpriv->fd >= 0) {
|
|
251
|
-
fd = dpriv->fd;
|
|
252
|
-
} else {
|
|
253
|
-
fd = open(dpriv->devnode, O_RDONLY);
|
|
254
|
-
if (fd < 0)
|
|
255
|
-
return _errno_to_libusb(errno);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
ufd.ufd_config_index = idx;
|
|
259
|
-
ufd.ufd_size = len;
|
|
260
|
-
ufd.ufd_data = buf;
|
|
261
|
-
|
|
262
|
-
if (ioctl(fd, USB_GET_FULL_DESC, &ufd) < 0) {
|
|
263
|
-
err = errno;
|
|
264
|
-
if (dpriv->fd < 0)
|
|
265
|
-
close(fd);
|
|
266
|
-
return _errno_to_libusb(err);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (dpriv->fd < 0)
|
|
270
|
-
close(fd);
|
|
271
|
-
|
|
272
|
-
return (int)len;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
int
|
|
276
|
-
netbsd_get_configuration(struct libusb_device_handle *handle, uint8_t *config)
|
|
277
|
-
{
|
|
278
|
-
struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
|
|
279
|
-
int tmp;
|
|
280
|
-
|
|
281
|
-
usbi_dbg(HANDLE_CTX(handle), " ");
|
|
282
|
-
|
|
283
|
-
if (ioctl(dpriv->fd, USB_GET_CONFIG, &tmp) < 0)
|
|
284
|
-
return _errno_to_libusb(errno);
|
|
285
|
-
|
|
286
|
-
usbi_dbg(HANDLE_CTX(handle), "configuration %d", tmp);
|
|
287
|
-
*config = (uint8_t)tmp;
|
|
288
|
-
|
|
289
|
-
return LIBUSB_SUCCESS;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
int
|
|
293
|
-
netbsd_set_configuration(struct libusb_device_handle *handle, int config)
|
|
294
|
-
{
|
|
295
|
-
struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
|
|
296
|
-
|
|
297
|
-
usbi_dbg(HANDLE_CTX(handle), "configuration %d", config);
|
|
298
|
-
|
|
299
|
-
if (ioctl(dpriv->fd, USB_SET_CONFIG, &config) < 0)
|
|
300
|
-
return _errno_to_libusb(errno);
|
|
301
|
-
|
|
302
|
-
return _cache_active_config_descriptor(handle->dev, dpriv->fd);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
int
|
|
306
|
-
netbsd_claim_interface(struct libusb_device_handle *handle, uint8_t iface)
|
|
307
|
-
{
|
|
308
|
-
struct handle_priv *hpriv = usbi_get_device_handle_priv(handle);
|
|
309
|
-
int i;
|
|
310
|
-
|
|
311
|
-
UNUSED(iface);
|
|
312
|
-
|
|
313
|
-
for (i = 0; i < USB_MAX_ENDPOINTS; i++)
|
|
314
|
-
hpriv->endpoints[i] = -1;
|
|
315
|
-
|
|
316
|
-
return LIBUSB_SUCCESS;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
int
|
|
320
|
-
netbsd_release_interface(struct libusb_device_handle *handle, uint8_t iface)
|
|
321
|
-
{
|
|
322
|
-
struct handle_priv *hpriv = usbi_get_device_handle_priv(handle);
|
|
323
|
-
int i;
|
|
324
|
-
|
|
325
|
-
UNUSED(iface);
|
|
326
|
-
|
|
327
|
-
for (i = 0; i < USB_MAX_ENDPOINTS; i++)
|
|
328
|
-
if (hpriv->endpoints[i] >= 0)
|
|
329
|
-
close(hpriv->endpoints[i]);
|
|
330
|
-
|
|
331
|
-
return LIBUSB_SUCCESS;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
int
|
|
335
|
-
netbsd_set_interface_altsetting(struct libusb_device_handle *handle, uint8_t iface,
|
|
336
|
-
uint8_t altsetting)
|
|
337
|
-
{
|
|
338
|
-
struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
|
|
339
|
-
struct usb_alt_interface intf;
|
|
340
|
-
|
|
341
|
-
usbi_dbg(HANDLE_CTX(handle), "iface %u, setting %u", iface, altsetting);
|
|
342
|
-
|
|
343
|
-
memset(&intf, 0, sizeof(intf));
|
|
344
|
-
|
|
345
|
-
intf.uai_interface_index = iface;
|
|
346
|
-
intf.uai_alt_no = altsetting;
|
|
347
|
-
|
|
348
|
-
if (ioctl(dpriv->fd, USB_SET_ALTINTERFACE, &intf) < 0)
|
|
349
|
-
return _errno_to_libusb(errno);
|
|
350
|
-
|
|
351
|
-
return LIBUSB_SUCCESS;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
int
|
|
355
|
-
netbsd_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
|
|
356
|
-
{
|
|
357
|
-
struct device_priv *dpriv = usbi_get_device_priv(handle->dev);
|
|
358
|
-
struct usb_ctl_request req;
|
|
359
|
-
|
|
360
|
-
usbi_dbg(HANDLE_CTX(handle), " ");
|
|
361
|
-
|
|
362
|
-
req.ucr_request.bmRequestType = UT_WRITE_ENDPOINT;
|
|
363
|
-
req.ucr_request.bRequest = UR_CLEAR_FEATURE;
|
|
364
|
-
USETW(req.ucr_request.wValue, UF_ENDPOINT_HALT);
|
|
365
|
-
USETW(req.ucr_request.wIndex, endpoint);
|
|
366
|
-
USETW(req.ucr_request.wLength, 0);
|
|
367
|
-
|
|
368
|
-
if (ioctl(dpriv->fd, USB_DO_REQUEST, &req) < 0)
|
|
369
|
-
return _errno_to_libusb(errno);
|
|
370
|
-
|
|
371
|
-
return LIBUSB_SUCCESS;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
void
|
|
375
|
-
netbsd_destroy_device(struct libusb_device *dev)
|
|
376
|
-
{
|
|
377
|
-
struct device_priv *dpriv = usbi_get_device_priv(dev);
|
|
378
|
-
|
|
379
|
-
usbi_dbg(DEVICE_CTX(dev), " ");
|
|
380
|
-
|
|
381
|
-
free(dpriv->cdesc);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
int
|
|
385
|
-
netbsd_submit_transfer(struct usbi_transfer *itransfer)
|
|
386
|
-
{
|
|
387
|
-
struct libusb_transfer *transfer;
|
|
388
|
-
int err = 0;
|
|
389
|
-
|
|
390
|
-
usbi_dbg(ITRANSFER_CTX(itransfer), " ");
|
|
391
|
-
|
|
392
|
-
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
393
|
-
|
|
394
|
-
switch (transfer->type) {
|
|
395
|
-
case LIBUSB_TRANSFER_TYPE_CONTROL:
|
|
396
|
-
err = _sync_control_transfer(itransfer);
|
|
397
|
-
break;
|
|
398
|
-
case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
|
|
399
|
-
if (IS_XFEROUT(transfer)) {
|
|
400
|
-
/* Isochronous write is not supported */
|
|
401
|
-
err = LIBUSB_ERROR_NOT_SUPPORTED;
|
|
402
|
-
break;
|
|
403
|
-
}
|
|
404
|
-
err = _sync_gen_transfer(itransfer);
|
|
405
|
-
break;
|
|
406
|
-
case LIBUSB_TRANSFER_TYPE_BULK:
|
|
407
|
-
case LIBUSB_TRANSFER_TYPE_INTERRUPT:
|
|
408
|
-
if (IS_XFEROUT(transfer) &&
|
|
409
|
-
transfer->flags & LIBUSB_TRANSFER_ADD_ZERO_PACKET) {
|
|
410
|
-
err = LIBUSB_ERROR_NOT_SUPPORTED;
|
|
411
|
-
break;
|
|
412
|
-
}
|
|
413
|
-
err = _sync_gen_transfer(itransfer);
|
|
414
|
-
break;
|
|
415
|
-
case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
|
|
416
|
-
err = LIBUSB_ERROR_NOT_SUPPORTED;
|
|
417
|
-
break;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
if (err)
|
|
421
|
-
return err;
|
|
422
|
-
|
|
423
|
-
usbi_signal_transfer_completion(itransfer);
|
|
424
|
-
|
|
425
|
-
return LIBUSB_SUCCESS;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
int
|
|
429
|
-
netbsd_cancel_transfer(struct usbi_transfer *itransfer)
|
|
430
|
-
{
|
|
431
|
-
UNUSED(itransfer);
|
|
432
|
-
|
|
433
|
-
usbi_dbg(ITRANSFER_CTX(itransfer), " ");
|
|
434
|
-
|
|
435
|
-
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
int
|
|
439
|
-
netbsd_handle_transfer_completion(struct usbi_transfer *itransfer)
|
|
440
|
-
{
|
|
441
|
-
return usbi_handle_transfer_completion(itransfer, LIBUSB_TRANSFER_COMPLETED);
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
int
|
|
445
|
-
_errno_to_libusb(int err)
|
|
446
|
-
{
|
|
447
|
-
usbi_dbg(NULL, "error: %s (%d)", strerror(err), err);
|
|
448
|
-
|
|
449
|
-
switch (err) {
|
|
450
|
-
case EIO:
|
|
451
|
-
return LIBUSB_ERROR_IO;
|
|
452
|
-
case EACCES:
|
|
453
|
-
return LIBUSB_ERROR_ACCESS;
|
|
454
|
-
case ENOENT:
|
|
455
|
-
return LIBUSB_ERROR_NO_DEVICE;
|
|
456
|
-
case ENOMEM:
|
|
457
|
-
return LIBUSB_ERROR_NO_MEM;
|
|
458
|
-
case EWOULDBLOCK:
|
|
459
|
-
case ETIMEDOUT:
|
|
460
|
-
return LIBUSB_ERROR_TIMEOUT;
|
|
461
|
-
default:
|
|
462
|
-
return LIBUSB_ERROR_OTHER;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
int
|
|
467
|
-
_cache_active_config_descriptor(struct libusb_device *dev, int fd)
|
|
468
|
-
{
|
|
469
|
-
struct device_priv *dpriv = usbi_get_device_priv(dev);
|
|
470
|
-
struct usb_config_desc ucd;
|
|
471
|
-
struct usb_full_desc ufd;
|
|
472
|
-
void *buf;
|
|
473
|
-
int len;
|
|
474
|
-
|
|
475
|
-
usbi_dbg(DEVICE_CTX(dev), "fd %d", fd);
|
|
476
|
-
|
|
477
|
-
ucd.ucd_config_index = USB_CURRENT_CONFIG_INDEX;
|
|
478
|
-
|
|
479
|
-
if (ioctl(fd, USB_GET_CONFIG_DESC, &ucd) < 0)
|
|
480
|
-
return _errno_to_libusb(errno);
|
|
481
|
-
|
|
482
|
-
usbi_dbg(DEVICE_CTX(dev), "active bLength %d", ucd.ucd_desc.bLength);
|
|
483
|
-
|
|
484
|
-
len = UGETW(ucd.ucd_desc.wTotalLength);
|
|
485
|
-
buf = malloc((size_t)len);
|
|
486
|
-
if (buf == NULL)
|
|
487
|
-
return LIBUSB_ERROR_NO_MEM;
|
|
488
|
-
|
|
489
|
-
ufd.ufd_config_index = ucd.ucd_config_index;
|
|
490
|
-
ufd.ufd_size = len;
|
|
491
|
-
ufd.ufd_data = buf;
|
|
492
|
-
|
|
493
|
-
usbi_dbg(DEVICE_CTX(dev), "index %d, len %d", ufd.ufd_config_index, len);
|
|
494
|
-
|
|
495
|
-
if (ioctl(fd, USB_GET_FULL_DESC, &ufd) < 0) {
|
|
496
|
-
free(buf);
|
|
497
|
-
return _errno_to_libusb(errno);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
if (dpriv->cdesc)
|
|
501
|
-
free(dpriv->cdesc);
|
|
502
|
-
dpriv->cdesc = buf;
|
|
503
|
-
|
|
504
|
-
return 0;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
int
|
|
508
|
-
_sync_control_transfer(struct usbi_transfer *itransfer)
|
|
509
|
-
{
|
|
510
|
-
struct libusb_transfer *transfer;
|
|
511
|
-
struct libusb_control_setup *setup;
|
|
512
|
-
struct device_priv *dpriv;
|
|
513
|
-
struct usb_ctl_request req;
|
|
514
|
-
|
|
515
|
-
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
516
|
-
dpriv = usbi_get_device_priv(transfer->dev_handle->dev);
|
|
517
|
-
setup = (struct libusb_control_setup *)transfer->buffer;
|
|
518
|
-
|
|
519
|
-
usbi_dbg(ITRANSFER_CTX(itransfer), "type 0x%x request 0x%x value 0x%x index %d length %d timeout %d",
|
|
520
|
-
setup->bmRequestType, setup->bRequest,
|
|
521
|
-
libusb_le16_to_cpu(setup->wValue),
|
|
522
|
-
libusb_le16_to_cpu(setup->wIndex),
|
|
523
|
-
libusb_le16_to_cpu(setup->wLength), transfer->timeout);
|
|
524
|
-
|
|
525
|
-
req.ucr_request.bmRequestType = setup->bmRequestType;
|
|
526
|
-
req.ucr_request.bRequest = setup->bRequest;
|
|
527
|
-
/* Don't use USETW, libusb already deals with the endianness */
|
|
528
|
-
(*(uint16_t *)req.ucr_request.wValue) = setup->wValue;
|
|
529
|
-
(*(uint16_t *)req.ucr_request.wIndex) = setup->wIndex;
|
|
530
|
-
(*(uint16_t *)req.ucr_request.wLength) = setup->wLength;
|
|
531
|
-
req.ucr_data = transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE;
|
|
532
|
-
|
|
533
|
-
if ((transfer->flags & LIBUSB_TRANSFER_SHORT_NOT_OK) == 0)
|
|
534
|
-
req.ucr_flags = USBD_SHORT_XFER_OK;
|
|
535
|
-
|
|
536
|
-
if (ioctl(dpriv->fd, USB_SET_TIMEOUT, &transfer->timeout) < 0)
|
|
537
|
-
return _errno_to_libusb(errno);
|
|
538
|
-
|
|
539
|
-
if (ioctl(dpriv->fd, USB_DO_REQUEST, &req) < 0)
|
|
540
|
-
return _errno_to_libusb(errno);
|
|
541
|
-
|
|
542
|
-
itransfer->transferred = req.ucr_actlen;
|
|
543
|
-
|
|
544
|
-
usbi_dbg(ITRANSFER_CTX(itransfer), "transferred %d", itransfer->transferred);
|
|
545
|
-
|
|
546
|
-
return 0;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
int
|
|
550
|
-
_access_endpoint(struct libusb_transfer *transfer)
|
|
551
|
-
{
|
|
552
|
-
struct handle_priv *hpriv;
|
|
553
|
-
struct device_priv *dpriv;
|
|
554
|
-
char *s, devnode[16];
|
|
555
|
-
int fd, endpt;
|
|
556
|
-
mode_t mode;
|
|
557
|
-
|
|
558
|
-
hpriv = usbi_get_device_handle_priv(transfer->dev_handle);
|
|
559
|
-
dpriv = usbi_get_device_priv(transfer->dev_handle->dev);
|
|
560
|
-
|
|
561
|
-
endpt = UE_GET_ADDR(transfer->endpoint);
|
|
562
|
-
mode = IS_XFERIN(transfer) ? O_RDONLY : O_WRONLY;
|
|
563
|
-
|
|
564
|
-
usbi_dbg(TRANSFER_CTX(transfer), "endpoint %d mode %d", endpt, mode);
|
|
565
|
-
|
|
566
|
-
if (hpriv->endpoints[endpt] < 0) {
|
|
567
|
-
/* Pick the right node given the control one */
|
|
568
|
-
strlcpy(devnode, dpriv->devnode, sizeof(devnode));
|
|
569
|
-
s = strchr(devnode, '.');
|
|
570
|
-
snprintf(s, 4, ".%02d", endpt);
|
|
571
|
-
|
|
572
|
-
/* We may need to read/write to the same endpoint later. */
|
|
573
|
-
if (((fd = open(devnode, O_RDWR)) < 0) && (errno == ENXIO))
|
|
574
|
-
if ((fd = open(devnode, mode)) < 0)
|
|
575
|
-
return -1;
|
|
576
|
-
|
|
577
|
-
hpriv->endpoints[endpt] = fd;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
return hpriv->endpoints[endpt];
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
int
|
|
584
|
-
_sync_gen_transfer(struct usbi_transfer *itransfer)
|
|
585
|
-
{
|
|
586
|
-
struct libusb_transfer *transfer;
|
|
587
|
-
int fd, nr = 1;
|
|
588
|
-
|
|
589
|
-
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
|
|
590
|
-
|
|
591
|
-
/*
|
|
592
|
-
* Bulk, Interrupt or Isochronous transfer depends on the
|
|
593
|
-
* endpoint and thus the node to open.
|
|
594
|
-
*/
|
|
595
|
-
if ((fd = _access_endpoint(transfer)) < 0)
|
|
596
|
-
return _errno_to_libusb(errno);
|
|
597
|
-
|
|
598
|
-
if (ioctl(fd, USB_SET_TIMEOUT, &transfer->timeout) < 0)
|
|
599
|
-
return _errno_to_libusb(errno);
|
|
600
|
-
|
|
601
|
-
if (IS_XFERIN(transfer)) {
|
|
602
|
-
if ((transfer->flags & LIBUSB_TRANSFER_SHORT_NOT_OK) == 0)
|
|
603
|
-
if (ioctl(fd, USB_SET_SHORT_XFER, &nr) < 0)
|
|
604
|
-
return _errno_to_libusb(errno);
|
|
605
|
-
|
|
606
|
-
nr = read(fd, transfer->buffer, transfer->length);
|
|
607
|
-
} else {
|
|
608
|
-
nr = write(fd, transfer->buffer, transfer->length);
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
if (nr < 0)
|
|
612
|
-
return _errno_to_libusb(errno);
|
|
613
|
-
|
|
614
|
-
itransfer->transferred = nr;
|
|
615
|
-
|
|
616
|
-
return 0;
|
|
617
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © 2019 Pino Toscano <toscano.pino@tiscali.it>
|
|
3
|
-
*
|
|
4
|
-
* This library is free software; you can redistribute it and/or
|
|
5
|
-
* modify it under the terms of the GNU Lesser General Public
|
|
6
|
-
* License as published by the Free Software Foundation; either
|
|
7
|
-
* version 2.1 of the License, or (at your option) any later version.
|
|
8
|
-
*
|
|
9
|
-
* This library is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
-
* Lesser General Public License for more details.
|
|
13
|
-
*
|
|
14
|
-
* You should have received a copy of the GNU Lesser General Public
|
|
15
|
-
* License along with this library; if not, write to the Free Software
|
|
16
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
#include "libusbi.h"
|
|
20
|
-
|
|
21
|
-
static int
|
|
22
|
-
null_get_device_list(struct libusb_context * ctx,
|
|
23
|
-
struct discovered_devs **discdevs)
|
|
24
|
-
{
|
|
25
|
-
return LIBUSB_SUCCESS;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static int
|
|
29
|
-
null_open(struct libusb_device_handle *handle)
|
|
30
|
-
{
|
|
31
|
-
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static void
|
|
35
|
-
null_close(struct libusb_device_handle *handle)
|
|
36
|
-
{
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static int
|
|
40
|
-
null_get_active_config_descriptor(struct libusb_device *dev,
|
|
41
|
-
void *buf, size_t len)
|
|
42
|
-
{
|
|
43
|
-
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static int
|
|
47
|
-
null_get_config_descriptor(struct libusb_device *dev, uint8_t idx,
|
|
48
|
-
void *buf, size_t len)
|
|
49
|
-
{
|
|
50
|
-
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
static int
|
|
54
|
-
null_set_configuration(struct libusb_device_handle *handle, int config)
|
|
55
|
-
{
|
|
56
|
-
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
static int
|
|
60
|
-
null_claim_interface(struct libusb_device_handle *handle, uint8_t iface)
|
|
61
|
-
{
|
|
62
|
-
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
static int
|
|
66
|
-
null_release_interface(struct libusb_device_handle *handle, uint8_t iface)
|
|
67
|
-
{
|
|
68
|
-
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
static int
|
|
72
|
-
null_set_interface_altsetting(struct libusb_device_handle *handle, uint8_t iface,
|
|
73
|
-
uint8_t altsetting)
|
|
74
|
-
{
|
|
75
|
-
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
static int
|
|
79
|
-
null_clear_halt(struct libusb_device_handle *handle, unsigned char endpoint)
|
|
80
|
-
{
|
|
81
|
-
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
static int
|
|
85
|
-
null_submit_transfer(struct usbi_transfer *itransfer)
|
|
86
|
-
{
|
|
87
|
-
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
static int
|
|
91
|
-
null_cancel_transfer(struct usbi_transfer *itransfer)
|
|
92
|
-
{
|
|
93
|
-
return LIBUSB_ERROR_NOT_SUPPORTED;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const struct usbi_os_backend usbi_backend = {
|
|
97
|
-
.name = "Null backend",
|
|
98
|
-
.caps = 0,
|
|
99
|
-
.get_device_list = null_get_device_list,
|
|
100
|
-
.open = null_open,
|
|
101
|
-
.close = null_close,
|
|
102
|
-
.get_active_config_descriptor = null_get_active_config_descriptor,
|
|
103
|
-
.get_config_descriptor = null_get_config_descriptor,
|
|
104
|
-
.set_configuration = null_set_configuration,
|
|
105
|
-
.claim_interface = null_claim_interface,
|
|
106
|
-
.release_interface = null_release_interface,
|
|
107
|
-
.set_interface_altsetting = null_set_interface_altsetting,
|
|
108
|
-
.clear_halt = null_clear_halt,
|
|
109
|
-
.submit_transfer = null_submit_transfer,
|
|
110
|
-
.cancel_transfer = null_cancel_transfer,
|
|
111
|
-
};
|