xref: /freebsd/lib/libusb/libusb20.3 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1a5118bdfSAndrew Thompson.\"
234b0ca24SHans Petter Selasky.\" Copyright (c) 2008-2019 Hans Petter Selasky
3a5118bdfSAndrew Thompson.\"
4a5118bdfSAndrew Thompson.\" All rights reserved.
5a5118bdfSAndrew Thompson.\"
6a5118bdfSAndrew Thompson.\" Redistribution and use in source and binary forms, with or without
7a5118bdfSAndrew Thompson.\" modification, are permitted provided that the following conditions
8a5118bdfSAndrew Thompson.\" are met:
9a5118bdfSAndrew Thompson.\" 1. Redistributions of source code must retain the above copyright
10a5118bdfSAndrew Thompson.\"    notice, this list of conditions and the following disclaimer.
11a5118bdfSAndrew Thompson.\" 2. Redistributions in binary form must reproduce the above copyright
12a5118bdfSAndrew Thompson.\"    notice, this list of conditions and the following disclaimer in the
13a5118bdfSAndrew Thompson.\"    documentation and/or other materials provided with the distribution.
14a5118bdfSAndrew Thompson.\"
15a5118bdfSAndrew Thompson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16a5118bdfSAndrew Thompson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17a5118bdfSAndrew Thompson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18a5118bdfSAndrew Thompson.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19a5118bdfSAndrew Thompson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20a5118bdfSAndrew Thompson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21a5118bdfSAndrew Thompson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22a5118bdfSAndrew Thompson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23a5118bdfSAndrew Thompson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24a5118bdfSAndrew Thompson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25a5118bdfSAndrew Thompson.\" SUCH DAMAGE.
26a5118bdfSAndrew Thompson.\"
2734b0ca24SHans Petter Selasky.Dd December 27, 2019
28a5118bdfSAndrew Thompson.Dt LIBUSB20 3
29a5118bdfSAndrew Thompson.Os
30a5118bdfSAndrew Thompson.Sh NAME
31a5118bdfSAndrew Thompson.Nm libusb20
32a5118bdfSAndrew Thompson.
33a5118bdfSAndrew Thompson.Nd "USB access library"
34a5118bdfSAndrew Thompson.
35a5118bdfSAndrew Thompson.
36a5118bdfSAndrew Thompson.Sh LIBRARY
37a5118bdfSAndrew Thompson.
38a5118bdfSAndrew Thompson.
39a5118bdfSAndrew ThompsonUSB access library (libusb -lusb)
40a5118bdfSAndrew Thompson.
41a5118bdfSAndrew Thompson.
42a5118bdfSAndrew Thompson.
43a5118bdfSAndrew Thompson.Sh SYNOPSIS
44a5118bdfSAndrew Thompson.In libusb20.h
45a5118bdfSAndrew Thompson.Ft int
46a5118bdfSAndrew Thompson.Fn libusb20_tr_close "struct libusb20_transfer *xfer"
47a5118bdfSAndrew Thompson.Ft int
48a5118bdfSAndrew Thompson.Fn libusb20_tr_open "struct libusb20_transfer *xfer" "uint32_t max_buf_size" "uint32_t max_frame_count" "uint8_t ep_no"
4907b6ce3bSHans Petter Selasky.Fn libusb20_tr_open_stream "struct libusb20_transfer *xfer" "uint32_t max_buf_size" "uint32_t max_frame_count" "uint8_t ep_no" "uint16_t stream_id"
50a5118bdfSAndrew Thompson.Ft struct libusb20_transfer*
51a5118bdfSAndrew Thompson.Fn libusb20_tr_get_pointer "struct libusb20_device *pdev"  "uint16_t tr_index"
52a5118bdfSAndrew Thompson.Ft uint16_t
53a5118bdfSAndrew Thompson.Fn libusb20_tr_get_time_complete "struct libusb20_transfer *xfer"
54a5118bdfSAndrew Thompson.Ft uint32_t
55a5118bdfSAndrew Thompson.Fn libusb20_tr_get_actual_frames "struct libusb20_transfer *xfer"
56a5118bdfSAndrew Thompson.Ft uint32_t
57a5118bdfSAndrew Thompson.Fn libusb20_tr_get_actual_length "struct libusb20_transfer *xfer"
58a5118bdfSAndrew Thompson.Ft uint32_t
59a5118bdfSAndrew Thompson.Fn libusb20_tr_get_max_frames "struct libusb20_transfer *xfer"
60a5118bdfSAndrew Thompson.Ft uint32_t
61a5118bdfSAndrew Thompson.Fn libusb20_tr_get_max_packet_length "struct libusb20_transfer *xfer"
62a5118bdfSAndrew Thompson.Ft uint32_t
63a5118bdfSAndrew Thompson.Fn libusb20_tr_get_max_total_length "struct libusb20_transfer *xfer"
64a5118bdfSAndrew Thompson.Ft uint8_t
65a5118bdfSAndrew Thompson.Fn libusb20_tr_get_status "struct libusb20_transfer *xfer"
66a5118bdfSAndrew Thompson.Ft uint8_t
67a5118bdfSAndrew Thompson.Fn libusb20_tr_pending "struct libusb20_transfer *xfer"
68a5118bdfSAndrew Thompson.Ft void
69a5118bdfSAndrew Thompson.Fn libusb20_tr_callback_wrapper "struct libusb20_transfer *xfer"
70a5118bdfSAndrew Thompson.Ft void
71a5118bdfSAndrew Thompson.Fn libusb20_tr_clear_stall_sync "struct libusb20_transfer *xfer"
72a5118bdfSAndrew Thompson.Ft void
73a5118bdfSAndrew Thompson.Fn libusb20_tr_drain "struct libusb20_transfer *xfer"
74a5118bdfSAndrew Thompson.Ft void
75a5118bdfSAndrew Thompson.Fn libusb20_tr_set_buffer "struct libusb20_transfer *xfer" "void *buffer" "uint16_t fr_index"
76a5118bdfSAndrew Thompson.Ft void
77a5118bdfSAndrew Thompson.Fn libusb20_tr_set_callback "struct libusb20_transfer *xfer" "libusb20_tr_callback_t *cb"
78a5118bdfSAndrew Thompson.Ft void
79a5118bdfSAndrew Thompson.Fn libusb20_tr_set_flags "struct libusb20_transfer *xfer" "uint8_t flags"
80a5118bdfSAndrew Thompson.Ft uint32_t
81a5118bdfSAndrew Thompson.Fn libusb20_tr_get_length "struct libusb20_transfer *xfer" "uint16_t fr_index"
82a5118bdfSAndrew Thompson.Ft void
83a5118bdfSAndrew Thompson.Fn libusb20_tr_set_length "struct libusb20_transfer *xfer" "uint32_t length" "uint16_t fr_index"
84a5118bdfSAndrew Thompson.Ft void
85a5118bdfSAndrew Thompson.Fn libusb20_tr_set_priv_sc0 "struct libusb20_transfer *xfer" "void *sc0"
86a5118bdfSAndrew Thompson.Ft void
87a5118bdfSAndrew Thompson.Fn libusb20_tr_set_priv_sc1 "struct libusb20_transfer *xfer" "void *sc1"
88a5118bdfSAndrew Thompson.Ft void
89a5118bdfSAndrew Thompson.Fn libusb20_tr_set_timeout "struct libusb20_transfer *xfer" "uint32_t timeout"
90a5118bdfSAndrew Thompson.Ft void
91a5118bdfSAndrew Thompson.Fn libusb20_tr_set_total_frames "struct libusb20_transfer *xfer" "uint32_t nframes"
92a5118bdfSAndrew Thompson.Ft void
93a5118bdfSAndrew Thompson.Fn libusb20_tr_setup_bulk "struct libusb20_transfer *xfer" "void *pbuf" "uint32_t length" "uint32_t timeout"
94a5118bdfSAndrew Thompson.Ft void
95a5118bdfSAndrew Thompson.Fn libusb20_tr_setup_control "struct libusb20_transfer *xfer" "void *psetup" "void *pbuf" "uint32_t timeout"
96a5118bdfSAndrew Thompson.Ft void
97a5118bdfSAndrew Thompson.Fn libusb20_tr_setup_intr "struct libusb20_transfer *xfer" "void *pbuf" "uint32_t length" "uint32_t timeout"
98a5118bdfSAndrew Thompson.Ft void
99a5118bdfSAndrew Thompson.Fn libusb20_tr_setup_isoc "struct libusb20_transfer *xfer" "void *pbuf" "uint32_t length" "uint61_t fr_index"
1004594d907SAndrew Thompson.Ft uint8_t
1014594d907SAndrew Thompson.Fn libusb20_tr_bulk_intr_sync "struct libusb20_transfer *xfer" "void *pbuf" "uint32_t length" "uint32_t *pactlen" "uint32_t timeout"
102a5118bdfSAndrew Thompson.Ft void
103a5118bdfSAndrew Thompson.Fn libusb20_tr_start "struct libusb20_transfer *xfer"
104a5118bdfSAndrew Thompson.Ft void
105a5118bdfSAndrew Thompson.Fn libusb20_tr_stop "struct libusb20_transfer *xfer"
106a5118bdfSAndrew Thompson.Ft void
107a5118bdfSAndrew Thompson.Fn libusb20_tr_submit "struct libusb20_transfer *xfer"
108a5118bdfSAndrew Thompson.Ft void *
109a5118bdfSAndrew Thompson.Fn libusb20_tr_get_priv_sc0 "struct libusb20_transfer *xfer"
110a5118bdfSAndrew Thompson.Ft void *
111a5118bdfSAndrew Thompson.Fn libusb20_tr_get_priv_sc1 "struct libusb20_transfer *xfer"
112a5118bdfSAndrew Thompson.Ft const char *
113a5118bdfSAndrew Thompson.Fn libusb20_dev_get_backend_name "struct libusb20_device *"
114a5118bdfSAndrew Thompson.Ft int
115c77a24c2SHans Petter Selasky.Fn libusb20_dev_get_port_path "struct libusb20_device *pdev" "uint8_t *buf" "uint8_t bufsize"
116c77a24c2SHans Petter Selasky.Ft int
117a5118bdfSAndrew Thompson.Fn libusb20_dev_get_info "struct libusb20_device *pdev" "struct usb_device_info *pinfo"
118a5118bdfSAndrew Thompson.Ft int
119a5118bdfSAndrew Thompson.Fn libusb20_dev_get_iface_desc "struct libusb20_device *pdev" "uint8_t iface_index" "char *buf" "uint8_t len"
120a5118bdfSAndrew Thompson.Ft const char *
121a5118bdfSAndrew Thompson.Fn libusb20_dev_get_desc "struct libusb20_device *pdev"
122a5118bdfSAndrew Thompson.Ft int
12334b0ca24SHans Petter Selasky.Fn libusb20_dev_get_stats "struct libusb20_device *pdev" "struct libusb20_device_stats *pstats"
12434b0ca24SHans Petter Selasky.Ft int
125a5118bdfSAndrew Thompson.Fn libusb20_dev_close "struct libusb20_device *pdev"
126a5118bdfSAndrew Thompson.Ft int
127a5118bdfSAndrew Thompson.Fn libusb20_dev_detach_kernel_driver "struct libusb20_device *pdev" "uint8_t iface_index"
128a5118bdfSAndrew Thompson.Ft int
129a5118bdfSAndrew Thompson.Fn libusb20_dev_set_config_index "struct libusb20_device *pdev" "uint8_t configIndex"
130a5118bdfSAndrew Thompson.Ft int
131a5118bdfSAndrew Thompson.Fn libusb20_dev_get_debug "struct libusb20_device *pdev"
132a5118bdfSAndrew Thompson.Ft int
133a5118bdfSAndrew Thompson.Fn libusb20_dev_get_fd "struct libusb20_device *pdev"
134a5118bdfSAndrew Thompson.Ft int
135a5118bdfSAndrew Thompson.Fn libusb20_dev_kernel_driver_active "struct libusb20_device *pdev" "uint8_t iface_index"
136a5118bdfSAndrew Thompson.Ft int
137a5118bdfSAndrew Thompson.Fn libusb20_dev_open "struct libusb20_device *pdev" "uint16_t transfer_max"
138a5118bdfSAndrew Thompson.Ft int
139a5118bdfSAndrew Thompson.Fn libusb20_dev_process "struct libusb20_device *pdev"
140a5118bdfSAndrew Thompson.Ft int
141a5118bdfSAndrew Thompson.Fn libusb20_dev_request_sync "struct libusb20_device *pdev" "struct LIBUSB20_CONTROL_SETUP_DECODED *setup" "void *data" "uint16_t *pactlen" "uint32_t timeout" "uint8_t flags"
142a5118bdfSAndrew Thompson.Ft int
143a5118bdfSAndrew Thompson.Fn libusb20_dev_req_string_sync "struct libusb20_device *pdev" "uint8_t index" "uint16_t langid" "void *ptr" "uint16_t len"
144a5118bdfSAndrew Thompson.Ft int
145a5118bdfSAndrew Thompson.Fn libusb20_dev_req_string_simple_sync "struct libusb20_device *pdev" "uint8_t index" "void *ptr" "uint16_t len"
146a5118bdfSAndrew Thompson.Ft int
147a5118bdfSAndrew Thompson.Fn libusb20_dev_reset "struct libusb20_device *pdev"
148a5118bdfSAndrew Thompson.Ft int
149e50ac68bSAndrew Thompson.Fn libusb20_dev_check_connected "struct libusb20_device *pdev"
150e50ac68bSAndrew Thompson.Ft int
151a5118bdfSAndrew Thompson.Fn libusb20_dev_set_power_mode "struct libusb20_device *pdev" "uint8_t power_mode"
152a5118bdfSAndrew Thompson.Ft uint8_t
153a5118bdfSAndrew Thompson.Fn libusb20_dev_get_power_mode "struct libusb20_device *pdev"
154aafcb732SHans Petter Selasky.Ft uint16_t
155aafcb732SHans Petter Selasky.Fn libusb20_dev_get_power_usage "struct libusb20_device *pdev"
156a5118bdfSAndrew Thompson.Ft int
157a5118bdfSAndrew Thompson.Fn libusb20_dev_set_alt_index "struct libusb20_device *pdev" "uint8_t iface_index" "uint8_t alt_index"
158a5118bdfSAndrew Thompson.Ft struct LIBUSB20_DEVICE_DESC_DECODED *
159a5118bdfSAndrew Thompson.Fn libusb20_dev_get_device_desc "struct libusb20_device *pdev"
160a5118bdfSAndrew Thompson.Ft struct libusb20_config *
161a5118bdfSAndrew Thompson.Fn libusb20_dev_alloc_config "struct libusb20_device *pdev" "uint8_t config_index"
162a5118bdfSAndrew Thompson.Ft struct libusb20_device *
163a5118bdfSAndrew Thompson.Fn libusb20_dev_alloc "void"
164a5118bdfSAndrew Thompson.Ft uint8_t
165a5118bdfSAndrew Thompson.Fn libusb20_dev_get_address "struct libusb20_device *pdev"
166a5118bdfSAndrew Thompson.Ft uint8_t
1672485d8a7SHans Petter Selasky.Fn libusb20_dev_get_parent_address "struct libusb20_device *pdev"
1682485d8a7SHans Petter Selasky.Ft uint8_t
1692485d8a7SHans Petter Selasky.Fn libusb20_dev_get_parent_port "struct libusb20_device *pdev"
1702485d8a7SHans Petter Selasky.Ft uint8_t
171a5118bdfSAndrew Thompson.Fn libusb20_dev_get_bus_number "struct libusb20_device *pdev"
172a5118bdfSAndrew Thompson.Ft uint8_t
173a5118bdfSAndrew Thompson.Fn libusb20_dev_get_mode "struct libusb20_device *pdev"
174a5118bdfSAndrew Thompson.Ft uint8_t
175a5118bdfSAndrew Thompson.Fn libusb20_dev_get_speed "struct libusb20_device *pdev"
176a5118bdfSAndrew Thompson.Ft uint8_t
177a5118bdfSAndrew Thompson.Fn libusb20_dev_get_config_index "struct libusb20_device *pdev"
178a5118bdfSAndrew Thompson.Ft void
179a5118bdfSAndrew Thompson.Fn libusb20_dev_free "struct libusb20_device *pdev"
180a5118bdfSAndrew Thompson.Ft void
181a5118bdfSAndrew Thompson.Fn libusb20_dev_set_debug "struct libusb20_device *pdev" "int debug"
182a5118bdfSAndrew Thompson.Ft void
183a5118bdfSAndrew Thompson.Fn libusb20_dev_wait_process "struct libusb20_device *pdev" "int timeout"
184a5118bdfSAndrew Thompson.Ft int
185a5118bdfSAndrew Thompson.Fn libusb20_be_get_template "struct libusb20_backend *pbe" "int *ptemp"
186a5118bdfSAndrew Thompson.Ft int
187a5118bdfSAndrew Thompson.Fn libusb20_be_set_template "struct libusb20_backend *pbe" "int temp"
188a5118bdfSAndrew Thompson.Ft int
189698e791aSHans Petter Selasky.Fn libusb20_be_get_dev_quirk "struct libusb20_backend *pber" "uint16_t index" "struct libusb20_quirk *pq"
190a5118bdfSAndrew Thompson.Ft int
191a5118bdfSAndrew Thompson.Fn libusb20_be_get_quirk_name "struct libusb20_backend *pbe" "uint16_t index" "struct libusb20_quirk *pq"
192a5118bdfSAndrew Thompson.Ft int
193a5118bdfSAndrew Thompson.Fn libusb20_be_add_dev_quirk "struct libusb20_backend *pbe" "struct libusb20_quirk *pq"
194a5118bdfSAndrew Thompson.Ft int
195a5118bdfSAndrew Thompson.Fn libusb20_be_remove_dev_quirk "struct libusb20_backend *pbe" "struct libusb20_quirk *pq"
196a5118bdfSAndrew Thompson.Ft struct libusb20_backend *
197a5118bdfSAndrew Thompson.Fn libusb20_be_alloc_default "void"
198a5118bdfSAndrew Thompson.Ft struct libusb20_backend *
199a5118bdfSAndrew Thompson.Fn libusb20_be_alloc_freebsd "void"
200a5118bdfSAndrew Thompson.Ft struct libusb20_backend *
201a5118bdfSAndrew Thompson.Fn libusb20_be_alloc_linux "void"
202a5118bdfSAndrew Thompson.Ft struct libusb20_device *
203a5118bdfSAndrew Thompson.Fn libusb20_be_device_foreach  "struct libusb20_backend *pbe" "struct libusb20_device *pdev"
204a5118bdfSAndrew Thompson.Ft void
205a5118bdfSAndrew Thompson.Fn libusb20_be_dequeue_device "struct libusb20_backend *pbe" "struct libusb20_device *pdev"
206a5118bdfSAndrew Thompson.Ft void
207a5118bdfSAndrew Thompson.Fn libusb20_be_enqueue_device "struct libusb20_backend *pbe" "struct libusb20_device *pdev"
208a5118bdfSAndrew Thompson.Ft void
209a5118bdfSAndrew Thompson.Fn libusb20_be_free "struct libusb20_backend *pbe"
210a5118bdfSAndrew Thompson.Ft uint8_t
211a5118bdfSAndrew Thompson.Fn libusb20_me_get_1 "const struct libusb20_me_struct *me" "uint16_t off"
212a5118bdfSAndrew Thompson.Ft uint16_t
213a5118bdfSAndrew Thompson.Fn libusb20_me_get_2 "const struct libusb20_me_struct *me" "uint16_t off"
214a5118bdfSAndrew Thompson.Ft uint16_t
215a5118bdfSAndrew Thompson.Fn libusb20_me_encode "void *pdata" "uint16_t len" "const void *pdecoded"
216a5118bdfSAndrew Thompson.Ft uint16_t
217a5118bdfSAndrew Thompson.Fn libusb20_me_decode "const void *pdata" "uint16_t len" "void *pdecoded"
218a5118bdfSAndrew Thompson.Ft "const uint8_t *"
219a5118bdfSAndrew Thompson.Fn libusb20_desc_foreach "const struct libusb20_me_struct *me" "const uint8_t *pdesc"
220c61f2561SHans Petter Selasky.Ft "const char *"
221c61f2561SHans Petter Selasky.Fn libusb20_strerror "int code"
222c61f2561SHans Petter Selasky.Ft "const char *"
223c61f2561SHans Petter Selasky.Fn libusb20_error_name "int code"
224a5118bdfSAndrew Thompson.
225a5118bdfSAndrew Thompson.
226a5118bdfSAndrew Thompson.Sh DESCRIPTION
227a5118bdfSAndrew Thompson.
228a5118bdfSAndrew ThompsonThe
229a5118bdfSAndrew Thompson.Nm
230a5118bdfSAndrew Thompsonlibrary implements functions to be able to easily access and control
231a5118bdfSAndrew ThompsonUSB through the USB file system interface.
232a5118bdfSAndrew ThompsonThe
233a5118bdfSAndrew Thompson.Nm
234a5118bdfSAndrew Thompsoninterfaces are specific to the
235a5118bdfSAndrew Thompson.Fx
236a5118bdfSAndrew Thompsonusb stack and are not available on other operating systems, portable
237a5118bdfSAndrew Thompsonapplications should consider using
238a5118bdfSAndrew Thompson.Xr libusb 3 .
239a5118bdfSAndrew Thompson.
240a5118bdfSAndrew Thompson.
241a5118bdfSAndrew Thompson.Sh USB TRANSFER OPERATIONS
242a5118bdfSAndrew Thompson.
243a5118bdfSAndrew Thompson.
244a5118bdfSAndrew Thompson.Fn libusb20_tr_close
245a5118bdfSAndrew Thompsonwill release all kernel resources associated with an USB
246a5118bdfSAndrew Thompson.Fa xfer .
247a5118bdfSAndrew Thompson.
248a5118bdfSAndrew ThompsonThis function returns zero upon success.
249a5118bdfSAndrew Thompson.
250a5118bdfSAndrew ThompsonNon-zero return values indicate a LIBUSB20_ERROR value.
251a5118bdfSAndrew Thompson.
252a5118bdfSAndrew Thompson.Pp
253a5118bdfSAndrew Thompson.
254a5118bdfSAndrew Thompson.Fn libusb20_tr_open
255a5118bdfSAndrew Thompsonwill allocate kernel buffer resources according to
256a5118bdfSAndrew Thompson.Fa max_buf_size
257a5118bdfSAndrew Thompsonand
258a5118bdfSAndrew Thompson.Fa max_frame_count
259a5118bdfSAndrew Thompsonassociated with an USB
260a5118bdfSAndrew Thompson.Fa pxfer
261a5118bdfSAndrew Thompsonand bind the transfer to the specified
262a5118bdfSAndrew Thompson.Fa ep_no .
263a5118bdfSAndrew Thompson.Fa max_buf_size
264a5118bdfSAndrew Thompsonis the minimum buffer size which the data transport layer has to support.
265a5118bdfSAndrew ThompsonIf
266a5118bdfSAndrew Thompson.Fa max_buf_size
267a5118bdfSAndrew Thompsonis zero, the
268a5118bdfSAndrew Thompson.Nm
269a5118bdfSAndrew Thompsonlibrary will use wMaxPacketSize to compute the buffer size.
270a5118bdfSAndrew ThompsonThis can be useful for isochronous transfers.
271a5118bdfSAndrew ThompsonThe actual buffer size can be greater than
272a5118bdfSAndrew Thompson.Fa max_buf_size
273a5118bdfSAndrew Thompsonand is returned by
274a5118bdfSAndrew Thompson.Fn libusb20_tr_get_max_total_length .
275a5118bdfSAndrew Thompson.
2761c497368SHans Petter SelaskyIf
2771c497368SHans Petter Selasky.Fa max_frame_count
2781c497368SHans Petter Selaskyis OR'ed with LIBUSB20_MAX_FRAME_PRE_SCALE the remaining part of the
2791c497368SHans Petter Selaskyargument is converted from milliseconds into the actual number of
2801c497368SHans Petter Selaskyframes rounded up, when this function returns.
2811c497368SHans Petter SelaskyThis flag is only valid for ISOCHRONOUS transfers and has no effect
2821c497368SHans Petter Selaskyfor other transfer types.
2831c497368SHans Petter SelaskyThe actual number of frames setup is found by calling
2841c497368SHans Petter Selasky.Fn libusb20_tr_get_max_frames .
2851c497368SHans Petter Selasky.
286a5118bdfSAndrew ThompsonThis function returns zero upon success.
287a5118bdfSAndrew Thompson.
288a5118bdfSAndrew ThompsonNon-zero return values indicate a LIBUSB20_ERROR value.
289a5118bdfSAndrew Thompson.
290a5118bdfSAndrew Thompson.Pp
291a5118bdfSAndrew Thompson.
29207b6ce3bSHans Petter Selasky.Fn libusb20_tr_open_stream
29307b6ce3bSHans Petter Selaskyis identical to
29407b6ce3bSHans Petter Selasky.Fn libusb20_tr_open
29507b6ce3bSHans Petter Selaskyexcept that a stream ID can be specified for BULK endpoints having
29607b6ce3bSHans Petter Selaskysuch a feature.
29707b6ce3bSHans Petter Selasky.Fn libusb20_tr_open
29807b6ce3bSHans Petter Selaskycan be used to open stream ID zero.
29907b6ce3bSHans Petter Selasky.
30007b6ce3bSHans Petter Selasky.Pp
30107b6ce3bSHans Petter Selasky.
302a5118bdfSAndrew Thompson.Fn libusb20_tr_get_pointer
303a5118bdfSAndrew Thompsonwill return a pointer to the allocated USB transfer according to the
304a5118bdfSAndrew Thompson.Fa pdev
305a5118bdfSAndrew Thompsonand
306a5118bdfSAndrew Thompson.Fa tr_index
307a5118bdfSAndrew Thompsonarguments.
308a5118bdfSAndrew Thompson.
309a5118bdfSAndrew ThompsonThis function returns NULL in case of failure.
310a5118bdfSAndrew Thompson.
311a5118bdfSAndrew Thompson.Pp
312a5118bdfSAndrew Thompson.
313a5118bdfSAndrew Thompson.Fn libusb20_tr_get_time_complete
314a5118bdfSAndrew Thompsonwill return the completion time of an USB transfer in
315*3d265fceSGordon Berglingmillisecond units.
316*3d265fceSGordon BerglingThis function is most useful for isochronous USB transfers when doing echo
317*3d265fceSGordon Berglingcancelling.
318a5118bdfSAndrew Thompson.
319a5118bdfSAndrew Thompson.Pp
320a5118bdfSAndrew Thompson.
321a5118bdfSAndrew Thompson.Fn libusb20_tr_get_actual_frames
322a5118bdfSAndrew Thompsonwill return the actual number of USB frames after an USB
323*3d265fceSGordon Berglingtransfer completed.
324*3d265fceSGordon BerglingA value of zero means that no data was transferred.
325a5118bdfSAndrew Thompson.Pp
326a5118bdfSAndrew Thompson.
327a5118bdfSAndrew Thompson.Fn libusb20_tr_get_actual_length
328a5118bdfSAndrew Thompsonwill return the sum of the actual length for all
329a5118bdfSAndrew Thompsontransferred USB frames for the given USB transfer.
330a5118bdfSAndrew Thompson.
331a5118bdfSAndrew Thompson.Pp
332a5118bdfSAndrew Thompson.
333a5118bdfSAndrew Thompson.Fn libusb20_tr_get_max_frames
334a5118bdfSAndrew Thompsonwill return the maximum number of USB frames that were
335a5118bdfSAndrew Thompsonallocated when an USB transfer was setup for the given USB transfer.
336a5118bdfSAndrew Thompson.
337a5118bdfSAndrew Thompson.Pp
338a5118bdfSAndrew Thompson.
339a5118bdfSAndrew Thompson.Fn libusb20_tr_get_max_packet_length
340a5118bdfSAndrew Thompsonwill return the maximum packet length in bytes
341a5118bdfSAndrew Thompsonassociated with the given USB transfer.
342a5118bdfSAndrew Thompson.
343a5118bdfSAndrew ThompsonThe packet length can be used round up buffer sizes so that short USB
344a5118bdfSAndrew Thompsonpackets are avoided for proxy buffers.
345a5118bdfSAndrew Thompson.
346a5118bdfSAndrew Thompson.
347a5118bdfSAndrew Thompson.Pp
348a5118bdfSAndrew Thompson.
349a5118bdfSAndrew Thompson.Fn libusb20_tr_get_max_total_length
350a3fb6da9SGlen Barberwill return the maximum value for the data length sum of all USB
351390065b1SAlfred Perlsteinframes associated with an USB transfer.
352390065b1SAlfred PerlsteinIn case of control transfers the value returned does not include the
353390065b1SAlfred Perlsteinlength of the SETUP packet, 8 bytes, which is part of frame zero.
354390065b1SAlfred PerlsteinThe returned value of this function is always aligned to the maximum
355390065b1SAlfred Perlsteinpacket size, wMaxPacketSize, of the endpoint which the USB transfer is
356390065b1SAlfred Perlsteinbound to.
357a5118bdfSAndrew Thompson.
358a5118bdfSAndrew Thompson.Pp
359a5118bdfSAndrew Thompson.
360a5118bdfSAndrew Thompson.Fn libusb20_tr_get_status
361a5118bdfSAndrew Thompsonwill return the status of an USB transfer.
362a5118bdfSAndrew Thompson.
363a5118bdfSAndrew ThompsonStatus values are defined by a set of LIBUSB20_TRANSFER_XXX enums.
364a5118bdfSAndrew Thompson.
365a5118bdfSAndrew Thompson.Pp
366a5118bdfSAndrew Thompson.
367a5118bdfSAndrew Thompson.Fn libusb20_tr_pending
368a5118bdfSAndrew Thompsonwill return non-zero if the given USB transfer is
369a5118bdfSAndrew Thompsonpending for completion.
370a5118bdfSAndrew Thompson.
371a5118bdfSAndrew ThompsonElse this function returns zero.
372a5118bdfSAndrew Thompson.
373a5118bdfSAndrew Thompson.Pp
374a5118bdfSAndrew Thompson.
375a5118bdfSAndrew Thompson.Fn libusb20_tr_callback_wrapper
376a5118bdfSAndrew ThompsonThis is an internal function used to wrap asynchronous USB callbacks.
377a5118bdfSAndrew Thompson.
378a5118bdfSAndrew Thompson.Pp
379a5118bdfSAndrew Thompson.
380a5118bdfSAndrew Thompson.Fn libusb20_tr_clear_stall_sync
381a5118bdfSAndrew ThompsonThis is an internal function used to synchronously clear the stall on
382a5118bdfSAndrew Thompsonthe given USB transfer.
383a5118bdfSAndrew Thompson.
384a5118bdfSAndrew ThompsonPlease see the USB specification for more information on stall
385a5118bdfSAndrew Thompsonclearing.
386a5118bdfSAndrew Thompson.
387a5118bdfSAndrew ThompsonIf the given USB transfer is pending when this function is called, the
388a5118bdfSAndrew ThompsonUSB transfer will complete with an error after that this function has
389a5118bdfSAndrew Thompsonbeen called.
390a5118bdfSAndrew Thompson.
391a5118bdfSAndrew Thompson.Pp
392a5118bdfSAndrew Thompson.
393a5118bdfSAndrew Thompson.Fn libusb20_tr_drain
394a5118bdfSAndrew Thompsonwill stop the given USB transfer and will not return
395a5118bdfSAndrew Thompsonuntil the USB transfer has been stopped in hardware.
396a5118bdfSAndrew Thompson.
397a5118bdfSAndrew Thompson.Pp
398a5118bdfSAndrew Thompson.
399a5118bdfSAndrew Thompson.Fn libusb20_tr_set_buffer
400a5118bdfSAndrew Thompsonis used to set the
401a5118bdfSAndrew Thompson.Fa buffer
402a5118bdfSAndrew Thompsonpointer for the given USB transfer and
403a5118bdfSAndrew Thompson.Fa fr_index .
404a5118bdfSAndrew Thompson.
405a5118bdfSAndrew ThompsonTypically the frame index is zero.
406a5118bdfSAndrew Thompson.
407a5118bdfSAndrew Thompson.
408a5118bdfSAndrew Thompson.Pp
409a5118bdfSAndrew Thompson.
410a5118bdfSAndrew Thompson.Fn libusb20_tr_set_callback
411a5118bdfSAndrew Thompsonis used to set the USB callback for asynchronous USB
412a5118bdfSAndrew Thompsontransfers.
413a5118bdfSAndrew Thompson.
414a5118bdfSAndrew ThompsonThe callback type is defined by libusb20_tr_callback_t.
415a5118bdfSAndrew Thompson.
416a5118bdfSAndrew Thompson.Pp
417a5118bdfSAndrew Thompson.
418a5118bdfSAndrew Thompson.Fn libusb20_tr_set_flags
419a5118bdfSAndrew Thompsonis used to set various USB flags for the given USB transfer.
4209ee2158bSJoel Dahl.Bl -tag -width "LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK"
421a5118bdfSAndrew Thompson.It LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK
422a5118bdfSAndrew ThompsonReport a short frame as error.
423a5118bdfSAndrew Thompson.It LIBUSB20_TRANSFER_MULTI_SHORT_NOT_OK
424a5118bdfSAndrew ThompsonMultiple short frames are not allowed.
425a5118bdfSAndrew Thompson.It LIBUSB20_TRANSFER_FORCE_SHORT
426a5118bdfSAndrew ThompsonAll transmitted frames are short terminated.
427a5118bdfSAndrew Thompson.It LIBUSB20_TRANSFER_DO_CLEAR_STALL
428a5118bdfSAndrew ThompsonWill do a clear-stall before starting the transfer.
429a5118bdfSAndrew Thompson.El
430a5118bdfSAndrew Thompson.
431a5118bdfSAndrew Thompson.Pp
432a5118bdfSAndrew Thompson.
433a5118bdfSAndrew Thompson.Fn libusb20_tr_get_length
434a5118bdfSAndrew Thompsonreturns the length of the given USB frame by index.
435a5118bdfSAndrew ThompsonAfter an USB transfer is complete the USB frame length will get updated to the actual transferred length.
436a5118bdfSAndrew Thompson.
437a5118bdfSAndrew Thompson.Pp
438a5118bdfSAndrew Thompson.
439a5118bdfSAndrew Thompson.Fn libusb20_tr_set_length
440a5118bdfSAndrew Thompsonsets the length of the given USB frame by index.
441a5118bdfSAndrew Thompson.
442a5118bdfSAndrew Thompson.Pp
443a5118bdfSAndrew Thompson.
444a5118bdfSAndrew Thompson.Fn libusb20_tr_set_priv_sc0
445a5118bdfSAndrew Thompsonsets private driver pointer number zero.
446a5118bdfSAndrew Thompson.
447a5118bdfSAndrew Thompson.Pp
448a5118bdfSAndrew Thompson.
449a5118bdfSAndrew Thompson.Fn libusb20_tr_set_priv_sc1
450a5118bdfSAndrew Thompsonsets private driver pointer number one.
451a5118bdfSAndrew Thompson.
452a5118bdfSAndrew Thompson.Pp
453a5118bdfSAndrew Thompson.
454a5118bdfSAndrew Thompson.Fn libusb20_tr_set_timeout
455a5118bdfSAndrew Thompsonsets the timeout for the given USB transfer.
456a5118bdfSAndrew Thompson.
457a5118bdfSAndrew ThompsonA timeout value of zero means no timeout.
458a5118bdfSAndrew Thompson.
459a5118bdfSAndrew ThompsonThe timeout is given in milliseconds.
460a5118bdfSAndrew Thompson.
461a5118bdfSAndrew Thompson.Pp
462a5118bdfSAndrew Thompson.
463a5118bdfSAndrew Thompson.Fn libusb20_tr_set_total_frames
464a5118bdfSAndrew Thompsonsets the total number of frames that should be executed when the USB transfer is submitted.
465a5118bdfSAndrew Thompson.
466a5118bdfSAndrew ThompsonThe total number of USB frames must be less than the maximum number of USB frames associated with the given USB transfer.
467a5118bdfSAndrew Thompson.
468a5118bdfSAndrew Thompson.Pp
469a5118bdfSAndrew Thompson.
470a5118bdfSAndrew Thompson.Fn libusb20_tr_setup_bulk
471a5118bdfSAndrew Thompsonis a helper function for setting up a single frame USB BULK transfer.
472a5118bdfSAndrew Thompson.
473a5118bdfSAndrew Thompson.Pp
474a5118bdfSAndrew Thompson.
475a5118bdfSAndrew Thompson.Fn libusb20_tr_setup_control
476a5118bdfSAndrew Thompsonis a helper function for setting up a single or dual
477a5118bdfSAndrew Thompsonframe USB CONTROL transfer depending on the control transfer length.
478a5118bdfSAndrew Thompson.
479a5118bdfSAndrew Thompson.Pp
480a5118bdfSAndrew Thompson.
481a5118bdfSAndrew Thompson.Fn libusb20_tr_setup_intr
482a5118bdfSAndrew Thompsonis a helper function for setting up a single frame USB INTERRUPT transfer.
483a5118bdfSAndrew Thompson.
484a5118bdfSAndrew Thompson.Pp
485a5118bdfSAndrew Thompson.
486a5118bdfSAndrew Thompson.Fn libusb20_tr_setup_isoc
487a5118bdfSAndrew Thompsonis a helper function for setting up a multi frame USB ISOCHRONOUS transfer.
488a5118bdfSAndrew Thompson.
489a5118bdfSAndrew Thompson.Pp
490a5118bdfSAndrew Thompson.
4914594d907SAndrew Thompson.Fn libusb20_tr_bulk_intr_sync
4924594d907SAndrew Thompsonwill perform a synchronous BULK or INTERRUPT transfer having length given by the
4934594d907SAndrew Thompson.Fa length
4944594d907SAndrew Thompsonargument and buffer pointer given by the
4954594d907SAndrew Thompson.Fa pbuf
4964594d907SAndrew Thompsonargument on the USB transfer given by the
4974594d907SAndrew Thompson.Fa xfer
4984594d907SAndrew Thompsonargument.
4994594d907SAndrew Thompson.
5004594d907SAndrew ThompsonIf the
5014594d907SAndrew Thompson.Fa pactlen
5024594d907SAndrew Thompsonargument is non-NULL the actual transfer length will be stored at the given pointer destination.
5034594d907SAndrew Thompson.
5044594d907SAndrew ThompsonIf the
5054594d907SAndrew Thompson.Fa timeout
5064594d907SAndrew Thompsonargument is non-zero the transfer will timeout after the given value in milliseconds.
5074594d907SAndrew Thompson.
5084594d907SAndrew ThompsonThis function does not change the transfer flags, like short packet not ok.
5094594d907SAndrew Thompson.
5104594d907SAndrew ThompsonThis function returns zero on success else a LIBUSB20_TRANSFER_XXX value is returned.
5114594d907SAndrew Thompson.
5124594d907SAndrew Thompson.Pp
5134594d907SAndrew Thompson.
514a5118bdfSAndrew Thompson.Fn libusb20_tr_start
515a5118bdfSAndrew Thompsonwill get the USB transfer started, if not already
516a5118bdfSAndrew Thompsonstarted.
517a5118bdfSAndrew Thompson.
518a5118bdfSAndrew ThompsonThis function will not get the transfer queued in hardware.
519a5118bdfSAndrew Thompson.
520a5118bdfSAndrew ThompsonThis function is non-blocking.
521a5118bdfSAndrew Thompson.
522a5118bdfSAndrew Thompson.Pp
523a5118bdfSAndrew Thompson.
524a5118bdfSAndrew Thompson.Fn libusb20_tr_stop
525a5118bdfSAndrew Thompsonwill get the USB transfer stopped, if not already stopped.
526a5118bdfSAndrew Thompson.
527a5118bdfSAndrew ThompsonThis function is non-blocking, which means that the actual stop can
528a5118bdfSAndrew Thompsonhappen after the return of this function.
529a5118bdfSAndrew Thompson.
530a5118bdfSAndrew Thompson.Pp
531a5118bdfSAndrew Thompson.
532a5118bdfSAndrew Thompson.Fn libusb20_tr_submit
533a5118bdfSAndrew Thompsonwill get the USB transfer queued in hardware.
534a5118bdfSAndrew Thompson.
535a5118bdfSAndrew Thompson.
536a5118bdfSAndrew Thompson.Pp
537a5118bdfSAndrew Thompson.
538a5118bdfSAndrew Thompson.Fn libusb20_tr_get_priv_sc0
539a5118bdfSAndrew Thompsonreturns private driver pointer number zero associated
540a5118bdfSAndrew Thompsonwith an USB transfer.
541a5118bdfSAndrew Thompson.
542a5118bdfSAndrew Thompson.
543a5118bdfSAndrew Thompson.Pp
544a5118bdfSAndrew Thompson.
545a5118bdfSAndrew Thompson.Fn libusb20_tr_get_priv_sc1
546a5118bdfSAndrew Thompsonreturns private driver pointer number one associated
547a5118bdfSAndrew Thompsonwith an USB transfer.
548a5118bdfSAndrew Thompson.
549a5118bdfSAndrew Thompson.
550a5118bdfSAndrew Thompson.Sh USB DEVICE OPERATIONS
551a5118bdfSAndrew Thompson.
552a5118bdfSAndrew Thompson.
553a5118bdfSAndrew Thompson.Fn libusb20_dev_get_backend_name
554a5118bdfSAndrew Thompsonreturns a zero terminated string describing the backend used.
555a5118bdfSAndrew Thompson.
556a5118bdfSAndrew Thompson.Pp
557a5118bdfSAndrew Thompson.
558c77a24c2SHans Petter Selasky.Fn libusb20_dev_get_port_path
559c77a24c2SHans Petter Selaskyretrieves the list of USB port numbers which the datastream for a given USB device follows.
560c77a24c2SHans Petter SelaskyThe first port number is the Root HUB port number.
561c77a24c2SHans Petter SelaskyThen children port numbers follow.
562c77a24c2SHans Petter SelaskyThe Root HUB device itself has a port path length of zero.
563c77a24c2SHans Petter SelaskyValid port numbers start at one and range until and including 255.
564c77a24c2SHans Petter SelaskyTypically there should not be more than 16 levels, due to electrical and protocol limitations.
565c77a24c2SHans Petter SelaskyThis functions returns the number of actual port levels upon success
566c77a24c2SHans Petter Selaskyelse a LIBUSB20_ERROR value is returned which are always negative.
567c77a24c2SHans Petter SelaskyIf the actual number of port levels is greater than the maximum
568c77a24c2SHans Petter Selaskyspecified, a LIBUSB20_ERROR value is returned.
569c77a24c2SHans Petter Selasky.
570c77a24c2SHans Petter Selasky.Pp
571c77a24c2SHans Petter Selasky.
572a5118bdfSAndrew Thompson.Fn libusb20_dev_get_info
573c2025a76SJoel Dahlretrieves the BSD specific usb_device_info structure into the memory location given by
574a5118bdfSAndrew Thompson.Fa pinfo .
575a5118bdfSAndrew ThompsonThe USB device given by
576a5118bdfSAndrew Thompson.Fa pdev
577a5118bdfSAndrew Thompsonmust be opened before this function will succeed.
578a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is returned.
579a5118bdfSAndrew Thompson.
580a5118bdfSAndrew Thompson.Pp
581a5118bdfSAndrew Thompson.
582a5118bdfSAndrew Thompson.Fn libusb20_dev_get_iface_desc
583a5118bdfSAndrew Thompsonretrieves the kernel interface description for the given USB
584a5118bdfSAndrew Thompson.Fa iface_index .
585a5118bdfSAndrew ThompsonThe format of the USB interface description is: "drivername<unit>: <description>"
586a5118bdfSAndrew ThompsonThe description string is always zero terminated.
587a5118bdfSAndrew ThompsonA zero length string is written in case no driver is attached to the given interface.
588a5118bdfSAndrew ThompsonThe USB device given by
589a5118bdfSAndrew Thompson.Fa pdev
590a5118bdfSAndrew Thompsonmust be opened before this function will succeed.
591a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is returned.
592a5118bdfSAndrew Thompson.
593a5118bdfSAndrew Thompson.Pp
594a5118bdfSAndrew Thompson.
595a5118bdfSAndrew Thompson.Fn libusb20_dev_get_desc
596a5118bdfSAndrew Thompsonreturns a zero terminated string describing the given USB device.
597a5118bdfSAndrew ThompsonThe format of the string is: "drivername<unit>: <description>"
598a5118bdfSAndrew Thompson.
599a5118bdfSAndrew Thompson.Pp
600a5118bdfSAndrew Thompson.
60134b0ca24SHans Petter Selasky.Fn libusb20_dev_get_stats
60234b0ca24SHans Petter Selaskyretrieves the device statistics into the structure pointed to by the
60334b0ca24SHans Petter Selasky.Fa pstats
60434b0ca24SHans Petter Selaskyargument.
60534b0ca24SHans Petter SelaskyThis function returns zero on success else a LIBUSB20_ERROR value is returned.
60634b0ca24SHans Petter Selasky.
60734b0ca24SHans Petter Selasky.Pp
60834b0ca24SHans Petter Selasky.
609a5118bdfSAndrew Thompson.Fn libusb20_dev_close
610a5118bdfSAndrew Thompsonwill close the given USB device.
611a5118bdfSAndrew Thompson.
612a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
613a5118bdfSAndrew Thompsonreturned.
614a5118bdfSAndrew Thompson.
615a5118bdfSAndrew Thompson.Pp
616a5118bdfSAndrew Thompson.
617a5118bdfSAndrew Thompson.Fn libusb20_dev_detach_kernel_driver
618a5118bdfSAndrew Thompsonwill try to detach the kernel driver for the USB interface given by
619a5118bdfSAndrew Thompson.Fa iface_index .
620a5118bdfSAndrew Thompson.
621a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
622a5118bdfSAndrew Thompsonreturned.
623a5118bdfSAndrew Thompson.
624a5118bdfSAndrew Thompson.Pp
625a5118bdfSAndrew Thompson.
626a5118bdfSAndrew Thompson.Fn libusb20_dev_set_config_index
627a5118bdfSAndrew Thompsonwill try to set the configuration index on an USB
628a5118bdfSAndrew Thompsondevice.
629a5118bdfSAndrew Thompson.
630a5118bdfSAndrew ThompsonThe first configuration index is zero.
631a5118bdfSAndrew Thompson.
632a5118bdfSAndrew ThompsonThe un-configure index is 255.
633a5118bdfSAndrew Thompson.
634a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is returned.
635a5118bdfSAndrew Thompson.
636a5118bdfSAndrew Thompson.Pp
637a5118bdfSAndrew Thompson.
638a5118bdfSAndrew Thompson.Fn libusb20_dev_get_debug
639a5118bdfSAndrew Thompsonreturns the debug level of an USB device.
640a5118bdfSAndrew Thompson.
641a5118bdfSAndrew Thompson.Pp
642a5118bdfSAndrew Thompson.
643a5118bdfSAndrew Thompson.Fn libusb20_dev_get_fd
644a5118bdfSAndrew Thompsonreturns the file descriptor of the given USB device.
645a5118bdfSAndrew Thompson.
646a5118bdfSAndrew ThompsonA negative value is returned when no file descriptor is present.
647a5118bdfSAndrew Thompson.
648a5118bdfSAndrew ThompsonThe file descriptor can be used for polling purposes.
649a5118bdfSAndrew Thompson.
650a5118bdfSAndrew Thompson.Pp
651a5118bdfSAndrew Thompson.
652a5118bdfSAndrew Thompson.Fn libusb20_dev_kernel_driver_active
6534d2472aaSHans Petter Selaskyreturns zero if a kernel driver is active on the given USB interface.
654a5118bdfSAndrew Thompson.
6554d2472aaSHans Petter SelaskyElse a LIBUSB20_ERROR value is returned.
656a5118bdfSAndrew Thompson.
657a5118bdfSAndrew Thompson.Pp
658a5118bdfSAndrew Thompson.
659a5118bdfSAndrew Thompson.Fn libusb20_dev_open
660a5118bdfSAndrew Thompsonopens an USB device so that setting up USB transfers
661a5118bdfSAndrew Thompsonbecomes possible.
662a5118bdfSAndrew Thompson.
663a5118bdfSAndrew ThompsonThe number of USB transfers can be zero which means only control
664a5118bdfSAndrew Thompsontransfers are allowed.
665a5118bdfSAndrew Thompson.
666a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
667a5118bdfSAndrew Thompsonreturned.
668a5118bdfSAndrew Thompson.
669a5118bdfSAndrew ThompsonA return value of LIBUSB20_ERROR_BUSY means that the device is already
670a5118bdfSAndrew Thompsonopened.
671a5118bdfSAndrew Thompson.
672a5118bdfSAndrew Thompson.Pp
673a5118bdfSAndrew Thompson.
674a5118bdfSAndrew Thompson.Fn libusb20_dev_process
675a5118bdfSAndrew Thompsonis called to sync kernel USB transfers with userland USB
676a5118bdfSAndrew Thompsontransfers.
677a5118bdfSAndrew Thompson.
678a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
679a5118bdfSAndrew Thompsonreturned typically indicating that the given USB device has been
680a5118bdfSAndrew Thompsondetached.
681a5118bdfSAndrew Thompson.
682a5118bdfSAndrew Thompson.Pp
683a5118bdfSAndrew Thompson.
684a5118bdfSAndrew Thompson.Fn libusb20_dev_request_sync
685a5118bdfSAndrew Thompsonwill perform a synchronous control request on the given
686a5118bdfSAndrew ThompsonUSB device.
687a5118bdfSAndrew Thompson.
688a5118bdfSAndrew ThompsonBefore this call will succeed the USB device must be opened.
689a5118bdfSAndrew Thompson.
690a5118bdfSAndrew Thompson.Fa setup
691a5118bdfSAndrew Thompsonis a pointer to a decoded and host endian SETUP packet.
692a5118bdfSAndrew Thompson.Fa data
693*3d265fceSGordon Berglingis a pointer to a data transfer buffer associated with the control transaction.
694*3d265fceSGordon BerglingThis argument can be NULL.
695a5118bdfSAndrew Thompson.Fa pactlen
696*3d265fceSGordon Berglingis a pointer to a variable that will hold the actual transfer length after the
697*3d265fceSGordon Berglingcontrol transaction is complete.
698a5118bdfSAndrew Thompson.Fa timeout
699a5118bdfSAndrew Thompsonis the transaction timeout given in milliseconds.
700a5118bdfSAndrew ThompsonA timeout of zero means no timeout.
701a5118bdfSAndrew Thompson.Fa flags
702a5118bdfSAndrew Thompsonis used to specify transaction flags, for example LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK.
703a5118bdfSAndrew Thompson.
704a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
705a5118bdfSAndrew Thompsonreturned.
706a5118bdfSAndrew Thompson.
707a5118bdfSAndrew Thompson.Pp
708a5118bdfSAndrew Thompson.
709a5118bdfSAndrew Thompson.Fn libusb20_dev_req_string_sync
710a5118bdfSAndrew Thompsonwill synchronously request an USB string by language ID
711a5118bdfSAndrew Thompsonand string index into the given buffer limited by a maximum length.
712a5118bdfSAndrew Thompson.
713a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
714a5118bdfSAndrew Thompsonreturned.
715a5118bdfSAndrew Thompson.
716a5118bdfSAndrew Thompson.Pp
717a5118bdfSAndrew Thompson.
718a5118bdfSAndrew Thompson.Fn libusb20_dev_req_string_simple_sync
719a5118bdfSAndrew Thompsonwill synchronously request an USB string using the
720a5118bdfSAndrew Thompsondefault language ID and convert the string into ASCII before storing
721a5118bdfSAndrew Thompsonthe string into the given buffer limited by a maximum length which
722a5118bdfSAndrew Thompsonincludes the terminating zero.
723a5118bdfSAndrew Thompson.
724a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
725a5118bdfSAndrew Thompsonreturned.
726a5118bdfSAndrew Thompson.
727a5118bdfSAndrew Thompson.
728a5118bdfSAndrew Thompson.Pp
729a5118bdfSAndrew Thompson.
730a5118bdfSAndrew Thompson.Fn libusb20_dev_reset
731a5118bdfSAndrew Thompsonwill try to BUS reset the given USB device and restore
732a5118bdfSAndrew Thompsonthe last set USB configuration.
733a5118bdfSAndrew Thompson.
734a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
735a5118bdfSAndrew Thompsonreturned.
736a5118bdfSAndrew Thompson.
737e50ac68bSAndrew Thompson.
738e50ac68bSAndrew Thompson.Pp
739e50ac68bSAndrew Thompson.
740e50ac68bSAndrew Thompson.Fn libusb20_dev_check_connected
741e50ac68bSAndrew Thompsonwill check if an opened USB device is still connected.
742e50ac68bSAndrew Thompson.
743e50ac68bSAndrew ThompsonThis function returns zero if the device is still connected else a LIBUSB20_ERROR value is returned.
744e50ac68bSAndrew Thompson.
745e50ac68bSAndrew Thompson.
746a5118bdfSAndrew Thompson.Pp
747a5118bdfSAndrew Thompson.
748a5118bdfSAndrew Thompson.Fn libusb20_dev_set_power_mode
749a5118bdfSAndrew Thompsonsets the power mode of the USB device.
750a5118bdfSAndrew Thompson.
751a5118bdfSAndrew ThompsonValid power modes:
7529ee2158bSJoel Dahl.Bl -tag -width "LIBUSB20_POWER_OFF"
753a5118bdfSAndrew Thompson.It LIBUSB20_POWER_OFF
754a5118bdfSAndrew Thompson.It LIBUSB20_POWER_ON
755a5118bdfSAndrew Thompson.It LIBUSB20_POWER_SAVE
756a5118bdfSAndrew Thompson.It LIBUSB20_POWER_SUSPEND
757a5118bdfSAndrew Thompson.It LIBUSB20_POWER_RESUME
758a5118bdfSAndrew Thompson.El
7599ee2158bSJoel Dahl.Pp
760a5118bdfSAndrew Thompson.
761a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
762a5118bdfSAndrew Thompsonreturned.
763a5118bdfSAndrew Thompson.
764a5118bdfSAndrew Thompson.Pp
765a5118bdfSAndrew Thompson.
766a5118bdfSAndrew Thompson.Fn libusb20_dev_get_power_mode
767a5118bdfSAndrew Thompsonreturns the currently selected power mode for the given
768a5118bdfSAndrew ThompsonUSB device.
769a5118bdfSAndrew Thompson.
770a5118bdfSAndrew Thompson.Pp
771a5118bdfSAndrew Thompson.
772aafcb732SHans Petter Selasky.Fn libusb20_dev_get_power_usage
773aafcb732SHans Petter Selaskyreturns the reported power usage in milliamps for the given USB device.
774aafcb732SHans Petter SelaskyA power usage of zero typically means that the device is self powered.
775aafcb732SHans Petter Selasky.
776aafcb732SHans Petter Selasky.Pp
777aafcb732SHans Petter Selasky.
778a5118bdfSAndrew Thompson.Fn libusb20_dev_set_alt_index
779a5118bdfSAndrew Thompsonwill try to set the given alternate index for the given
780a5118bdfSAndrew ThompsonUSB interface index.
781a5118bdfSAndrew Thompson.
782a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
783a5118bdfSAndrew Thompsonreturned.
784a5118bdfSAndrew Thompson.
785a5118bdfSAndrew Thompson.Pp
786a5118bdfSAndrew Thompson.
787a5118bdfSAndrew Thompson.Fn libusb20_dev_get_device_desc
788a5118bdfSAndrew Thompsonreturns a pointer to the decoded and host endian version
789a5118bdfSAndrew Thompsonof the device descriptor.
790a5118bdfSAndrew Thompson.
791a5118bdfSAndrew ThompsonThe USB device need not be opened when calling this function.
792a5118bdfSAndrew Thompson.
793a5118bdfSAndrew Thompson.Pp
794a5118bdfSAndrew Thompson.
795a5118bdfSAndrew Thompson.Fn libusb20_dev_alloc_config
796*3d265fceSGordon Berglingwill read out and decode the USB config descriptor for the given USB device
797*3d265fceSGordon Berglingand config index.
798*3d265fceSGordon BerglingThis function returns a pointer to the decoded configuration which must eventually
799*3d265fceSGordon Berglingbe passed to free().
800*3d265fceSGordon BerglingNULL is returned in case of failure.
801a5118bdfSAndrew Thompson.
802a5118bdfSAndrew Thompson.Pp
803a5118bdfSAndrew Thompson.
804a5118bdfSAndrew Thompson.Fn libusb20_dev_alloc
805a5118bdfSAndrew Thompsonis an internal function to allocate a new USB device.
806a5118bdfSAndrew Thompson.
807a5118bdfSAndrew Thompson.Pp
808a5118bdfSAndrew Thompson.
809a5118bdfSAndrew Thompson.Fn libusb20_dev_get_address
810a5118bdfSAndrew Thompsonreturns the internal and not necessarily the real
811a5118bdfSAndrew Thompsonhardware address of the given USB device.
8122485d8a7SHans Petter SelaskyValid addresses start at one.
8132485d8a7SHans Petter Selasky.
8142485d8a7SHans Petter Selasky.Pp
8152485d8a7SHans Petter Selasky.
8162485d8a7SHans Petter Selasky.Fn libusb20_dev_get_parent_address
8172485d8a7SHans Petter Selaskyreturns the internal and not necessarily the real hardware address of
8182485d8a7SHans Petter Selaskythe given parent USB HUB device.
8192485d8a7SHans Petter SelaskyThis value is zero for the root HUB which usually has a device address
8202485d8a7SHans Petter Selaskyequal to one.
8212485d8a7SHans Petter SelaskyValid addresses start at one.
8222485d8a7SHans Petter Selasky.
8232485d8a7SHans Petter Selasky.Pp
8242485d8a7SHans Petter Selasky.
8252485d8a7SHans Petter Selasky.Fn libusb20_dev_get_parent_port
8262485d8a7SHans Petter Selaskyreturns the port number on the parent USB HUB device.
8272485d8a7SHans Petter SelaskyThis value is zero for the root HUB which usually has a device address
8282485d8a7SHans Petter Selaskyequal to one.
8292485d8a7SHans Petter SelaskyValid port numbers start at one.
830a5118bdfSAndrew Thompson.
831a5118bdfSAndrew Thompson.Pp
832a5118bdfSAndrew Thompson.
833a5118bdfSAndrew Thompson.Fn libusb20_dev_get_bus_number
834a5118bdfSAndrew Thompsonreturns the internal bus number which the given USB
835a5118bdfSAndrew Thompsondevice belongs to.
8362485d8a7SHans Petter SelaskyValid bus numbers start at zero.
837a5118bdfSAndrew Thompson.
838a5118bdfSAndrew Thompson.Pp
839a5118bdfSAndrew Thompson.
840a5118bdfSAndrew Thompson.Fn libusb20_dev_get_mode
841a5118bdfSAndrew Thompsonreturns the current operation mode of the USB entity.
842a5118bdfSAndrew Thompson.
843a5118bdfSAndrew ThompsonValid return values are:
8449ee2158bSJoel Dahl.Bl -tag -width "LIBUSB20_MODE_DEVICE"
845a5118bdfSAndrew Thompson.It LIBUSB20_MODE_HOST
846a5118bdfSAndrew Thompson.It LIBUSB20_MODE_DEVICE
847a5118bdfSAndrew Thompson.El
848a5118bdfSAndrew Thompson.
849a5118bdfSAndrew Thompson.Pp
850a5118bdfSAndrew Thompson.
851a5118bdfSAndrew Thompson.Fn libusb20_dev_get_speed
852a5118bdfSAndrew Thompsonreturns the current speed of the given USB device.
853a5118bdfSAndrew Thompson.
8549ee2158bSJoel Dahl.Bl -tag -width "LIBUSB20_SPEED_VARIABLE"
855a5118bdfSAndrew Thompson.It LIBUSB20_SPEED_UNKNOWN
856a5118bdfSAndrew Thompson.It LIBUSB20_SPEED_LOW
857a5118bdfSAndrew Thompson.It LIBUSB20_SPEED_FULL
858a5118bdfSAndrew Thompson.It LIBUSB20_SPEED_HIGH
859a5118bdfSAndrew Thompson.It LIBUSB20_SPEED_VARIABLE
860a5118bdfSAndrew Thompson.It LIBUSB20_SPEED_SUPER
861a5118bdfSAndrew Thompson.El
862a5118bdfSAndrew Thompson.
863a5118bdfSAndrew Thompson.Pp
864a5118bdfSAndrew Thompson.
865a5118bdfSAndrew Thompson.Fn libusb20_dev_get_config_index
866a3fb6da9SGlen Barberreturns the currently selected config index for the given
867a5118bdfSAndrew ThompsonUSB device.
868a5118bdfSAndrew Thompson.
869a5118bdfSAndrew Thompson.Pp
870a5118bdfSAndrew Thompson.
871a5118bdfSAndrew Thompson.Fn libusb20_dev_free
872a5118bdfSAndrew Thompsonwill free the given USB device and all associated USB
873a5118bdfSAndrew Thompsontransfers.
874a5118bdfSAndrew Thompson.
875a5118bdfSAndrew Thompson.Pp
876a5118bdfSAndrew Thompson.
877a5118bdfSAndrew Thompson.Fn libusb20_dev_set_debug
878a5118bdfSAndrew Thompsonwill set the debug level for the given USB device.
879a5118bdfSAndrew Thompson.
880a5118bdfSAndrew Thompson.Pp
881a5118bdfSAndrew Thompson.
882a5118bdfSAndrew Thompson.Fn libusb20_dev_wait_process
883a3fb6da9SGlen Barberwill wait until a pending USB transfer has completed on
884a5118bdfSAndrew Thompsonthe given USB device.
885a5118bdfSAndrew Thompson.
886a5118bdfSAndrew ThompsonA timeout value can be specified which is passed on to the
887a5118bdfSAndrew Thompson.Xr poll 2
888a5118bdfSAndrew Thompsonfunction.
889a5118bdfSAndrew Thompson.
890a5118bdfSAndrew Thompson.Sh USB BACKEND OPERATIONS
891a5118bdfSAndrew Thompson.
892a5118bdfSAndrew Thompson.Fn libusb20_be_get_template
893a5118bdfSAndrew Thompsonwill return the currently selected global USB device
894a5118bdfSAndrew Thompsonside mode template into the integer pointer
895a5118bdfSAndrew Thompson.Fa ptemp .
896a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
897a5118bdfSAndrew Thompsonreturned.
898a5118bdfSAndrew Thompson.
899a5118bdfSAndrew Thompson.Pp
900a5118bdfSAndrew Thompson.
901a5118bdfSAndrew Thompson.Fn libusb20_be_set_template
902a5118bdfSAndrew Thompsonwill set the global USB device side mode template to
903a5118bdfSAndrew Thompson.Fa temp .
904a5118bdfSAndrew ThompsonThe new template is not activated until after the next USB
905a5118bdfSAndrew Thompsonenumeration.
906a5118bdfSAndrew ThompsonThe template number decides how the USB device will present itself to
907*3d265fceSGordon Berglingthe USB Host, like Mass Storage Device, USB Ethernet Device.
908*3d265fceSGordon BerglingAlso see the
909a5118bdfSAndrew Thompson.Xr usb2_template 4
910a5118bdfSAndrew Thompsonmodule.
911a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
912a5118bdfSAndrew Thompsonreturned.
913a5118bdfSAndrew Thompson.
914a5118bdfSAndrew Thompson.Pp
915a5118bdfSAndrew Thompson.
916a5118bdfSAndrew Thompson.Fn libusb20_be_get_dev_quirk
917a3fb6da9SGlen Barberwill return the device quirk according to
918a5118bdfSAndrew Thompson.Fa index
919a5118bdfSAndrew Thompsoninto the libusb20_quirk structure pointed to by
920a5118bdfSAndrew Thompson.Fa pq .
921a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
922a5118bdfSAndrew Thompsonreturned.
923a5118bdfSAndrew Thompson.
924a5118bdfSAndrew ThompsonIf the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
925a5118bdfSAndrew Thompsonreturned.
926a5118bdfSAndrew Thompson.
927a5118bdfSAndrew Thompson.Pp
928a5118bdfSAndrew Thompson.
929a5118bdfSAndrew Thompson.Fn libusb20_be_get_quirk_name
930a5118bdfSAndrew Thompsonwill return the quirk name according to
931a5118bdfSAndrew Thompson.Fa index
932a5118bdfSAndrew Thompsoninto the libusb20_quirk structure pointed to by
933a5118bdfSAndrew Thompson.Fa pq .
934a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
935a5118bdfSAndrew Thompsonreturned.
936a5118bdfSAndrew Thompson.
937a5118bdfSAndrew ThompsonIf the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
938a5118bdfSAndrew Thompsonreturned.
939a5118bdfSAndrew Thompson.
940a5118bdfSAndrew Thompson.Pp
941a5118bdfSAndrew Thompson.
942a5118bdfSAndrew Thompson.Fn libusb20_be_add_dev_quirk
943a5118bdfSAndrew Thompsonwill add the libusb20_quirk structure pointed to by the
944a5118bdfSAndrew Thompson.Fa pq
945a5118bdfSAndrew Thompsonargument into the device quirk list.
946a5118bdfSAndrew Thompson.
947a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
948a5118bdfSAndrew Thompsonreturned.
949a5118bdfSAndrew Thompson.
950a5118bdfSAndrew ThompsonIf the given quirk cannot be added LIBUSB20_ERROR_NO_MEM is
951a5118bdfSAndrew Thompsonreturned.
952a5118bdfSAndrew Thompson.
953a5118bdfSAndrew Thompson.Pp
954a5118bdfSAndrew Thompson.
955a5118bdfSAndrew Thompson.Fn libusb20_be_remove_dev_quirk
956a5118bdfSAndrew Thompsonwill remove the quirk matching the libusb20_quirk structure pointed to by the
957a5118bdfSAndrew Thompson.Fa pq
958a5118bdfSAndrew Thompsonargument from the device quirk list.
959a5118bdfSAndrew Thompson.
960a5118bdfSAndrew ThompsonThis function returns zero on success else a LIBUSB20_ERROR value is
961a5118bdfSAndrew Thompsonreturned.
962a5118bdfSAndrew Thompson.
963a5118bdfSAndrew ThompsonIf the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
964a5118bdfSAndrew Thompsonreturned.
965a5118bdfSAndrew Thompson.
966a5118bdfSAndrew Thompson.Pp
967a5118bdfSAndrew Thompson.
968a5118bdfSAndrew Thompson.Fn libusb20_be_alloc_default
969a5118bdfSAndrew Thompson.Fn libusb20_be_alloc_freebsd
970a5118bdfSAndrew Thompson.Fn libusb20_be_alloc_linux
971*3d265fceSGordon BerglingThese functions are used to allocate a specific USB backend or the operating system
972*3d265fceSGordon Berglingdefault USB backend.
973*3d265fceSGordon BerglingAllocating a backend is a way to scan for currently present USB devices.
974a5118bdfSAndrew Thompson.Pp
975a5118bdfSAndrew Thompson.
976a5118bdfSAndrew Thompson.Fn libusb20_be_device_foreach
977a5118bdfSAndrew Thompsonis used to iterate USB devices present in a USB backend.
978a5118bdfSAndrew Thompson.
979a5118bdfSAndrew ThompsonThe starting value of
980a5118bdfSAndrew Thompson.Fa pdev
981a5118bdfSAndrew Thompsonis NULL.
982a5118bdfSAndrew Thompson.
983a5118bdfSAndrew ThompsonThis function returns the next USB device in the list.
984a5118bdfSAndrew Thompson.
985a5118bdfSAndrew ThompsonIf NULL is returned the end of the USB device list has been reached.
986a5118bdfSAndrew Thompson.
987a5118bdfSAndrew Thompson.Pp
988a5118bdfSAndrew Thompson.
989a5118bdfSAndrew Thompson.Fn libusb20_be_dequeue_device
990a5118bdfSAndrew Thompsonwill dequeue the given USB device pointer from the
991a5118bdfSAndrew Thompsonbackend USB device list.
992a5118bdfSAndrew Thompson.
993a5118bdfSAndrew ThompsonDequeued USB devices will not be freed when the backend is freed.
994a5118bdfSAndrew Thompson.
995a5118bdfSAndrew Thompson.Pp
996a5118bdfSAndrew Thompson.
997a5118bdfSAndrew Thompson.Fn libusb20_be_enqueue_device
998a3fb6da9SGlen Barberwill enqueue the given USB device pointer in the backend USB device list.
999a5118bdfSAndrew Thompson.
1000a5118bdfSAndrew ThompsonEnqueued USB devices will get freed when the backend is freed.
1001a5118bdfSAndrew Thompson.
1002a5118bdfSAndrew Thompson.Pp
1003a5118bdfSAndrew Thompson.
1004a5118bdfSAndrew Thompson.Fn libusb20_be_free
1005a5118bdfSAndrew Thompsonwill free the given backend and all USB devices in its device list.
1006a5118bdfSAndrew Thompson.
1007a5118bdfSAndrew Thompson.
1008a5118bdfSAndrew Thompson.Sh USB DESCRIPTOR PARSING
1009a5118bdfSAndrew Thompson.
1010a5118bdfSAndrew Thompson.Fn libusb20_me_get_1 pie offset
1011a5118bdfSAndrew ThompsonThis function will return a byte at the given byte offset of a message
1012a5118bdfSAndrew Thompsonentity.
1013a5118bdfSAndrew Thompson.
1014a5118bdfSAndrew ThompsonThis function is safe against invalid offsets.
1015a5118bdfSAndrew Thompson.
1016a5118bdfSAndrew Thompson.Pp
1017a5118bdfSAndrew Thompson.
1018a5118bdfSAndrew Thompson.Fn libusb20_me_get_2 pie offset
1019a5118bdfSAndrew ThompsonThis function will return a little endian 16-bit value at the given byte offset of a message
1020a5118bdfSAndrew Thompsonentity.
1021a5118bdfSAndrew Thompson.
1022a5118bdfSAndrew ThompsonThis function is safe against invalid offsets.
1023a5118bdfSAndrew Thompson.
1024a5118bdfSAndrew Thompson.Pp
1025a5118bdfSAndrew Thompson.
1026a5118bdfSAndrew Thompson.Fn libusb20_me_encode pbuf len pdecoded
1027a5118bdfSAndrew ThompsonThis function will encode a so-called *DECODED structure into binary
1028a5118bdfSAndrew Thompsonformat.
1029a5118bdfSAndrew Thompson.
1030a5118bdfSAndrew ThompsonThe total encoded length that will fit in the given buffer is
1031a5118bdfSAndrew Thompsonreturned.
1032a5118bdfSAndrew Thompson.
1033a5118bdfSAndrew ThompsonIf the buffer pointer is NULL no data will be written to the buffer
1034a5118bdfSAndrew Thompsonlocation.
1035a5118bdfSAndrew Thompson.
1036a5118bdfSAndrew Thompson.Pp
1037a5118bdfSAndrew Thompson.
1038a5118bdfSAndrew Thompson.Fn libusb20_me_decode pbuf len pdecoded
1039a5118bdfSAndrew ThompsonThis function will decode a binary structure into a so-called *DECODED
1040a5118bdfSAndrew Thompsonstructure.
1041a5118bdfSAndrew Thompson.
1042a5118bdfSAndrew ThompsonThe total decoded length is returned.
1043a5118bdfSAndrew Thompson.
1044a5118bdfSAndrew ThompsonThe buffer pointer cannot be NULL.
1045a5118bdfSAndrew Thompson.
1046a5118bdfSAndrew Thompson.
1047c61f2561SHans Petter Selasky.Sh USB DEBUGGING
1048c61f2561SHans Petter Selasky.Ft const char *
1049c61f2561SHans Petter Selasky.Fn libusb20_strerror "int code"
1050c61f2561SHans Petter SelaskyGet the ASCII representation of the error given by the
1051c61f2561SHans Petter Selasky.Fa code
1052c61f2561SHans Petter Selaskyargument.
1053c61f2561SHans Petter SelaskyThis function does not return NULL.
1054c61f2561SHans Petter Selasky.Pp
1055c61f2561SHans Petter Selasky.Ft const char *
1056c61f2561SHans Petter Selasky.Fn libusb20_error_name "int code"
1057c61f2561SHans Petter SelaskyGet the ASCII representation of the error enum given by the
1058c61f2561SHans Petter Selasky.Fa code
1059c61f2561SHans Petter Selaskyargument.
1060c61f2561SHans Petter SelaskyThis function does not return NULL.
1061c61f2561SHans Petter Selasky.
1062a5118bdfSAndrew Thompson.Sh FILES
10632710751bSJoel Dahl.Bl -tag -width Pa
10642710751bSJoel Dahl.It Pa /dev/usb
10652710751bSJoel Dahl.El
1066a5118bdfSAndrew Thompson.Sh SEE ALSO
1067a5118bdfSAndrew Thompson.Xr libusb 3 ,
10684990a1c0SJoel Dahl.Xr usb 4 ,
1069c61f2561SHans Petter Selasky.Xr usbconfig 8 ,
1070c61f2561SHans Petter Selasky.Xr usbdump 8
1071a5118bdfSAndrew Thompson.
1072a5118bdfSAndrew Thompson.
1073a5118bdfSAndrew Thompson.Sh HISTORY
1074a5118bdfSAndrew Thompson.
1075a5118bdfSAndrew Thompson.
1076a5118bdfSAndrew ThompsonSome parts of the
1077a5118bdfSAndrew Thompson.Nm
1078a5118bdfSAndrew ThompsonAPI derives from the libusb project at sourceforge.
1079