Deleted Added
full compact
libusb20.3 (184610) libusb20.3 (185087)
1.\"
2.\" Copyright (c) 2008 Hans Petter Selasky
3.\"
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:

--- 10 unchanged lines hidden (view full) ---

19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
1.\"
2.\" Copyright (c) 2008 Hans Petter Selasky
3.\"
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:

--- 10 unchanged lines hidden (view full) ---

19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.\" $FreeBSD: head/lib/libusb20/libusb20.3 184610 2008-11-04 02:31:03Z alfred $
27.\" $FreeBSD: head/lib/libusb20/libusb20.3 185087 2008-11-19 08:56:35Z alfred $
28.\"
29.Dd Oct 23, 2008
30.Dt LIBUSB20 3
31.Os
32.Sh NAME
33.Nm libusb20
34.
35.Nd "USB access library"

--- 19 unchanged lines hidden (view full) ---

55library implements functions to be able to easily access and control
56USB through the USB file system interface.
57.
58.
59.Sh USB TRANSFER OPERATIONS
60.
61.Pp
62.
28.\"
29.Dd Oct 23, 2008
30.Dt LIBUSB20 3
31.Os
32.Sh NAME
33.Nm libusb20
34.
35.Nd "USB access library"

--- 19 unchanged lines hidden (view full) ---

55library implements functions to be able to easily access and control
56USB through the USB file system interface.
57.
58.
59.Sh USB TRANSFER OPERATIONS
60.
61.Pp
62.
63.Fn libusb20_tr_close
63.Fn libusb20_tr_close pxfer
64This function will release all kernel resources associated with an USB
64This function will release all kernel resources associated with an USB
65.Fa xfer .
65.Fa pxfer .
66.
67This function returns zero upon success.
68.
69Non-zero return values indicate a LIBUSB20_ERROR value.
70.
71.Pp
72.
66.
67This function returns zero upon success.
68.
69Non-zero return values indicate a LIBUSB20_ERROR value.
70.
71.Pp
72.
73.Fn libusb20_tr_open
73.Fn libusb20_tr_open pxfer max_buf_size max_frame_count ep_no
74This function will allocate kernel resources like
74This function will allocate kernel resources like
75.Fa MaxBufSize
75.Fa max_buf_size
76and
76and
77.Fa MaxFrameCount
77.Fa max_frame_count
78associated with an USB
78associated with an USB
79.Fa xfer
79.Fa pxfer
80and bind the transfer to the specified
81.Fa ep_no .
82.
83This function returns zero upon success.
84.
85Non-zero return values indicate a LIBUSB20_ERROR value.
86.
87.Pp
88.
80and bind the transfer to the specified
81.Fa ep_no .
82.
83This function returns zero upon success.
84.
85Non-zero return values indicate a LIBUSB20_ERROR value.
86.
87.Pp
88.
89.Fn libusb20_tr_get_pointer
89.Fn libusb20_tr_get_pointer pdev tr_index
90This function will return a pointer to the allocated USB transfer according to the
91.Fa pdev
92and
93.Fa tr_index
94arguments.
95.
96This function returns NULL in case of failure.
97.
98.Pp
99.
90This function will return a pointer to the allocated USB transfer according to the
91.Fa pdev
92and
93.Fa tr_index
94arguments.
95.
96This function returns NULL in case of failure.
97.
98.Pp
99.
100.Fn libusb20_tr_get_time_complete
100.Fn libusb20_tr_get_time_complete pxfer
101This function will return the completion time of an USB transfer in
102millisecond units. This function is most useful for isochronous USB
103transfers when doing echo cancelling.
104.
105.Pp
106.
101This function will return the completion time of an USB transfer in
102millisecond units. This function is most useful for isochronous USB
103transfers when doing echo cancelling.
104.
105.Pp
106.
107.Fn libusb20_tr_get_actual_frames
107.Fn libusb20_tr_get_actual_frames pxfer
108This function will return the actual number of USB frames after an USB
109transfer completed. A value of zero means that no data was transferred.
110.
111.Pp
112.
108This function will return the actual number of USB frames after an USB
109transfer completed. A value of zero means that no data was transferred.
110.
111.Pp
112.
113.Fn libusb20_tr_get_actual_length
113.Fn libusb20_tr_get_actual_length pxfer
114This function will return the sum of the actual length for all
115transferred USB frames for the given USB transfer.
116.
117.Pp
118.
114This function will return the sum of the actual length for all
115transferred USB frames for the given USB transfer.
116.
117.Pp
118.
119.Fn libusb20_tr_get_max_frames
119.Fn libusb20_tr_get_max_frames pxfer
120This function will return the maximum number of USB frames that were
121allocated when an USB transfer was setup for the given USB transfer.
122.
123.Pp
124.
120This function will return the maximum number of USB frames that were
121allocated when an USB transfer was setup for the given USB transfer.
122.
123.Pp
124.
125.Fn libusb20_tr_get_max_packet_length
125.Fn libusb20_tr_get_max_packet_length pxfer
126This function will return the maximum packet length in bytes
127associated with the given USB transfer.
128.
129The packet length can be used round up buffer sizes so that short USB
130packets are avoided for proxy buffers.
131.
132.
133.Pp
134.
126This function will return the maximum packet length in bytes
127associated with the given USB transfer.
128.
129The packet length can be used round up buffer sizes so that short USB
130packets are avoided for proxy buffers.
131.
132.
133.Pp
134.
135.Fn libusb20_tr_get_max_total_length
135.Fn libusb20_tr_get_max_total_length pxfer
136This function will return the maximum value for the length sum of all
137USB frames associated with an USB transfer.
138.
139.Pp
140.
136This function will return the maximum value for the length sum of all
137USB frames associated with an USB transfer.
138.
139.Pp
140.
141.Fn libusb20_tr_get_status
141.Fn libusb20_tr_get_status pxfer
142This function will return the status of an USB transfer.
143.
144Status values are defined by a set of LIBUSB20_TRANSFER_XXX enums.
145.
146.Pp
147.
142This function will return the status of an USB transfer.
143.
144Status values are defined by a set of LIBUSB20_TRANSFER_XXX enums.
145.
146.Pp
147.
148.Fn libusb20_tr_pending
148.Fn libusb20_tr_pending pxfer
149This function will return non-zero if the given USB transfer is
150pending for completion.
151.
152Else this function returns zero.
153.
154.Pp
155.
149This function will return non-zero if the given USB transfer is
150pending for completion.
151.
152Else this function returns zero.
153.
154.Pp
155.
156.Fn libusb20_tr_callback_wrapper
156.Fn libusb20_tr_callback_wrapper pxfer
157This is an internal function used to wrap asynchronous USB callbacks.
158.
159.Pp
160.
157This is an internal function used to wrap asynchronous USB callbacks.
158.
159.Pp
160.
161.Fn libusb20_tr_clear_stall_sync
161.Fn libusb20_tr_clear_stall_sync pxfer
162This is an internal function used to synchronously clear the stall on
163the given USB transfer.
164.
165Please see the USB specification for more information on stall
166clearing.
167.
168If the given USB transfer is pending when this function is called, the
169USB transfer will complete with an error after that this function has
170been called.
171.
172.Pp
173.
162This is an internal function used to synchronously clear the stall on
163the given USB transfer.
164.
165Please see the USB specification for more information on stall
166clearing.
167.
168If the given USB transfer is pending when this function is called, the
169USB transfer will complete with an error after that this function has
170been called.
171.
172.Pp
173.
174.Fn libusb20_tr_drain
174.Fn libusb20_tr_drain pxfer
175This function will stop the given USB transfer and will not return
176until the USB transfer has been stopped in hardware.
177.
178.Pp
179.
175This function will stop the given USB transfer and will not return
176until the USB transfer has been stopped in hardware.
177.
178.Pp
179.
180.Fn libusb20_tr_set_buffer
180.Fn libusb20_tr_set_buffer pxfer pbuf fr_index
181This function is used to set the
182.Fa buffer
183pointer for the given USB transfer and
184.Fa fr_index .
185.
186Typically the frame index is zero.
187.
188.
189.Pp
190.
181This function is used to set the
182.Fa buffer
183pointer for the given USB transfer and
184.Fa fr_index .
185.
186Typically the frame index is zero.
187.
188.
189.Pp
190.
191.Fn libusb20_tr_set_callback
191.Fn libusb20_tr_set_callback pxfer pcallback
192This function is used to set the USB callback for asynchronous USB
193transfers.
194.
195The callback type is defined by libusb20_tr_callback_t.
196.
197.Pp
198.
192This function is used to set the USB callback for asynchronous USB
193transfers.
194.
195The callback type is defined by libusb20_tr_callback_t.
196.
197.Pp
198.
199.Fn libusb20_tr_set_flags
199.Fn libusb20_tr_set_flags pxfer flags
200This function is used to set various USB flags for the given USB transfer.
201.Bl -tag
202.It LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK
203Report a short frame as error.
204.It LIBUSB20_TRANSFER_MULTI_SHORT_NOT_OK
205Multiple short frames are not allowed.
206.It LIBUSB20_TRANSFER_FORCE_SHORT
207All transmitted frames are short terminated.
208.It LIBUSB20_TRANSFER_DO_CLEAR_STALL
209Will do a clear-stall before starting the transfer.
210.El
211.
212.Pp
213.
200This function is used to set various USB flags for the given USB transfer.
201.Bl -tag
202.It LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK
203Report a short frame as error.
204.It LIBUSB20_TRANSFER_MULTI_SHORT_NOT_OK
205Multiple short frames are not allowed.
206.It LIBUSB20_TRANSFER_FORCE_SHORT
207All transmitted frames are short terminated.
208.It LIBUSB20_TRANSFER_DO_CLEAR_STALL
209Will do a clear-stall before starting the transfer.
210.El
211.
212.Pp
213.
214.Fn libusb20_tr_set_length
214.Fn libusb20_tr_set_length pxfer length fr_index
215This function sets the length of a given USB transfer and frame index.
216.
217.Pp
218.
215This function sets the length of a given USB transfer and frame index.
216.
217.Pp
218.
219.Fn libusb20_tr_set_priv_sc0
219.Fn libusb20_tr_set_priv_sc0 pxfer psc0
220This function sets private driver pointer number zero.
221.
222.Pp
223.
220This function sets private driver pointer number zero.
221.
222.Pp
223.
224.Fn libusb20_tr_set_priv_sc1
224.Fn libusb20_tr_set_priv_sc1 pxfer psc1
225This function sets private driver pointer number one.
226.
227.Pp
228.
225This function sets private driver pointer number one.
226.
227.Pp
228.
229.Fn libusb20_tr_set_timeout
229.Fn libusb20_tr_set_timeout pxfer timeout
230This function sets the timeout for the given USB transfer.
231.
232A timeout value of zero means no timeout.
233.
234The timeout is given in milliseconds.
235.
236.Pp
237.
230This function sets the timeout for the given USB transfer.
231.
232A timeout value of zero means no timeout.
233.
234The timeout is given in milliseconds.
235.
236.Pp
237.
238.Fn libusb20_tr_set_total_frames
238.Fn libusb20_tr_set_total_frames pxfer nframes
239This function sets the total number of frames that should be executed when the USB transfer is submitted.
240.
241The total number of USB frames must be less than the maximum number of USB frames associated with the given USB transfer.
242.
243.Pp
244.
239This function sets the total number of frames that should be executed when the USB transfer is submitted.
240.
241The total number of USB frames must be less than the maximum number of USB frames associated with the given USB transfer.
242.
243.Pp
244.
245.Fn libusb20_tr_setup_bulk
245.Fn libusb20_tr_setup_bulk pxfer pbuf length timeout
246This function is a helper function for setting up a single frame USB BULK transfer.
247.
248.Pp
249.
246This function is a helper function for setting up a single frame USB BULK transfer.
247.
248.Pp
249.
250.Fn libusb20_tr_setup_control
250.Fn libusb20_tr_setup_control pxfer psetup pbuf timeout
251This function is a helper function for setting up a single or dual
252frame USB CONTROL transfer depending on the control transfer length.
253.
254.Pp
255.
251This function is a helper function for setting up a single or dual
252frame USB CONTROL transfer depending on the control transfer length.
253.
254.Pp
255.
256.Fn libusb20_tr_setup_intr
256.Fn libusb20_tr_setup_intr pxfer pbuf length timeout
257This function is a helper function for setting up a single frame USB INTERRUPT transfer.
258.
259.Pp
260.
257This function is a helper function for setting up a single frame USB INTERRUPT transfer.
258.
259.Pp
260.
261.Fn libusb20_tr_setup_isoc
261.Fn libusb20_tr_setup_isoc pxfer pbuf length fr_index
262This function is a helper function for setting up a multi frame USB ISOCHRONOUS transfer.
263.
264.Pp
265.
262This function is a helper function for setting up a multi frame USB ISOCHRONOUS transfer.
263.
264.Pp
265.
266.Fn libusb20_tr_start
266.Fn libusb20_tr_start pxfer
267This function will get the USB transfer started, if not already
268started.
269.
270This function will not get the transfer queued in hardware.
271.
272This function is non-blocking.
273.
274.Pp
275.
267This function will get the USB transfer started, if not already
268started.
269.
270This function will not get the transfer queued in hardware.
271.
272This function is non-blocking.
273.
274.Pp
275.
276.Fn libusb20_tr_stop
276.Fn libusb20_tr_stop pxfer
277This function will get the USB transfer stopped, if not already stopped.
278.
279This function is non-blocking, which means that the actual stop can
280happen after the return of this function.
281.
282.Pp
283.
277This function will get the USB transfer stopped, if not already stopped.
278.
279This function is non-blocking, which means that the actual stop can
280happen after the return of this function.
281.
282.Pp
283.
284.Fn libusb20_tr_submit
284.Fn libusb20_tr_submit pxfer
285This function will get the USB transfer queued in hardware.
286.
287.
288.Pp
289.
285This function will get the USB transfer queued in hardware.
286.
287.
288.Pp
289.
290.Fn libusb20_tr_get_priv_sc0
290.Fn libusb20_tr_get_priv_sc0 pxfer
291This function returns private driver pointer number zero associated
292with an USB transfer.
293.
294.
295.Pp
296.
291This function returns private driver pointer number zero associated
292with an USB transfer.
293.
294.
295.Pp
296.
297.Fn libusb20_tr_get_priv_sc1
297.Fn libusb20_tr_get_priv_sc1 pxfer
298This function returns private driver pointer number one associated
299with an USB transfer.
300.
301.
302.Sh USB DEVICE OPERATIONS
303.
304.Pp
305.
298This function returns private driver pointer number one associated
299with an USB transfer.
300.
301.
302.Sh USB DEVICE OPERATIONS
303.
304.Pp
305.
306.Fn libusb20_dev_get_backend_name
306.Fn libusb20_dev_get_backend_name pdev
307This function returns a zero terminated string describing the backend used.
308.
309.Pp
310.
307This function returns a zero terminated string describing the backend used.
308.
309.Pp
310.
311.Fn libusb20_dev_get_desc
311.Fn libusb20_dev_get_desc pdev
312This function returns a zero terminated string describing the given USB device.
313.
314.Pp
315.
312This function returns a zero terminated string describing the given USB device.
313.
314.Pp
315.
316.Fn libusb20_dev_claim_interface
316.Fn libusb20_dev_claim_interface pdev iface_index
317This function will try to claim the given USB interface given by
318.Fa iface_index .
319This function returns zero on success else a LIBUSB20_ERROR value is
320returned.
321.
322.Pp
323.
317This function will try to claim the given USB interface given by
318.Fa iface_index .
319This function returns zero on success else a LIBUSB20_ERROR value is
320returned.
321.
322.Pp
323.
324.Fn libusb20_dev_close
324.Fn libusb20_dev_close pdev
325This function will close the given USB device.
326.
327This function returns zero on success else a LIBUSB20_ERROR value is
328returned.
329.
330.Pp
331.
325This function will close the given USB device.
326.
327This function returns zero on success else a LIBUSB20_ERROR value is
328returned.
329.
330.Pp
331.
332.Fn libusb20_dev_detach_kernel_driver
332.Fn libusb20_dev_detach_kernel_driver pdev iface_index
333This function will try to detach the kernel driver for the USB interface given by
334.Fa iface_index .
335.
336This function returns zero on success else a LIBUSB20_ERROR value is
337returned.
338.
339.Pp
340.
333This function will try to detach the kernel driver for the USB interface given by
334.Fa iface_index .
335.
336This function returns zero on success else a LIBUSB20_ERROR value is
337returned.
338.
339.Pp
340.
341.Fn libusb20_dev_set_config_index
341.Fn libusb20_dev_set_config_index pdev config_index
342This function will try to set the configuration index on an USB
343device.
344.
345The first configuration index is zero.
346.
347The un-configure index is 255.
348.
349This function returns zero on success else a LIBUSB20_ERROR value is returned.
350.
351.Pp
352.
342This function will try to set the configuration index on an USB
343device.
344.
345The first configuration index is zero.
346.
347The un-configure index is 255.
348.
349This function returns zero on success else a LIBUSB20_ERROR value is returned.
350.
351.Pp
352.
353.Fn libusb20_dev_get_debug
353.Fn libusb20_dev_get_debug pdev
354This function returns the debug level of an USB device.
355.
356.Pp
357.
354This function returns the debug level of an USB device.
355.
356.Pp
357.
358.Fn libusb20_dev_get_fd
358.Fn libusb20_dev_get_fd pdev
359This function returns the file descriptor of the given USB device.
360.
361A negative value is returned when no file descriptor is present.
362.
363The file descriptor can be used for polling purposes.
364.
365.Pp
366.
359This function returns the file descriptor of the given USB device.
360.
361A negative value is returned when no file descriptor is present.
362.
363The file descriptor can be used for polling purposes.
364.
365.Pp
366.
367.Fn libusb20_dev_kernel_driver_active
367.Fn libusb20_dev_kernel_driver_active pdev iface_index
368This function returns a non-zero value if a kernel driver is active on
369the given USB interface.
370.
371Else zero is returned.
372.
373.Pp
374.
368This function returns a non-zero value if a kernel driver is active on
369the given USB interface.
370.
371Else zero is returned.
372.
373.Pp
374.
375.Fn libusb20_dev_open
375.Fn libusb20_dev_open pdev transfer_max
376This function opens an USB device so that setting up USB transfers
377becomes possible.
378.
379The number of USB transfers can be zero which means only control
380transfers are allowed.
381.
382This function returns zero on success else a LIBUSB20_ERROR value is
383returned.
384.
385A return value of LIBUSB20_ERROR_BUSY means that the device is already
386opened.
387.
388.Pp
389.
376This function opens an USB device so that setting up USB transfers
377becomes possible.
378.
379The number of USB transfers can be zero which means only control
380transfers are allowed.
381.
382This function returns zero on success else a LIBUSB20_ERROR value is
383returned.
384.
385A return value of LIBUSB20_ERROR_BUSY means that the device is already
386opened.
387.
388.Pp
389.
390.Fn libusb20_dev_process
390.Fn libusb20_dev_process pdev
391This function is called to sync kernel USB transfers with userland USB
392transfers.
393.
394This function returns zero on success else a LIBUSB20_ERROR value is
395returned typically indicating that the given USB device has been
396detached.
397.
398.Pp
399.
391This function is called to sync kernel USB transfers with userland USB
392transfers.
393.
394This function returns zero on success else a LIBUSB20_ERROR value is
395returned typically indicating that the given USB device has been
396detached.
397.
398.Pp
399.
400.Fn libusb20_dev_release_interface
400.Fn libusb20_dev_release_interface pdev iface_index
401This function will try to release a claimed USB interface for the specified USB device.
402.
403This function returns zero on success else a LIBUSB20_ERROR value is
404returned.
405.
406.Pp
407.
401This function will try to release a claimed USB interface for the specified USB device.
402.
403This function returns zero on success else a LIBUSB20_ERROR value is
404returned.
405.
406.Pp
407.
408.Fn libusb20_dev_request_sync
408.Fn libusb20_dev_request_sync pdev psetup pdata pactlen timeout flags
409This function will perform a synchronous control request on the given
410USB device.
411.
412Before this call will succeed the USB device must be opened.
413.
414.Fa setup
415is a pointer to a decoded and host endian SETUP packet.
416.Fa data

--- 6 unchanged lines hidden (view full) ---

423.Fa flags
424is used to specify transaction flags, for example LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK.
425.
426This function returns zero on success else a LIBUSB20_ERROR value is
427returned.
428.
429.Pp
430.
409This function will perform a synchronous control request on the given
410USB device.
411.
412Before this call will succeed the USB device must be opened.
413.
414.Fa setup
415is a pointer to a decoded and host endian SETUP packet.
416.Fa data

--- 6 unchanged lines hidden (view full) ---

423.Fa flags
424is used to specify transaction flags, for example LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK.
425.
426This function returns zero on success else a LIBUSB20_ERROR value is
427returned.
428.
429.Pp
430.
431.Fn libusb20_dev_req_string_sync
431.Fn libusb20_dev_req_string_sync pdev index lang_id pbuf len
432This function will synchronously request an USB string by language ID
433and string index into the given buffer limited by a maximum length.
434.
435This function returns zero on success else a LIBUSB20_ERROR value is
436returned.
437.
438.Pp
439.
432This function will synchronously request an USB string by language ID
433and string index into the given buffer limited by a maximum length.
434.
435This function returns zero on success else a LIBUSB20_ERROR value is
436returned.
437.
438.Pp
439.
440.Fn libusb20_dev_req_string_simple_sync
440.Fn libusb20_dev_req_string_simple_sync pdev index pbuf len
441This function will synchronously request an USB string using the
442default language ID and convert the string into ASCII before storing
443the string into the given buffer limited by a maximum length which
444includes the terminating zero.
445.
446This function returns zero on success else a LIBUSB20_ERROR value is
447returned.
448.
449.
450.Pp
451.
441This function will synchronously request an USB string using the
442default language ID and convert the string into ASCII before storing
443the string into the given buffer limited by a maximum length which
444includes the terminating zero.
445.
446This function returns zero on success else a LIBUSB20_ERROR value is
447returned.
448.
449.
450.Pp
451.
452.Fn libusb20_dev_reset
452.Fn libusb20_dev_reset pdev
453This function will try to BUS reset the given USB device and restore
454the last set USB configuration.
455.
456This function returns zero on success else a LIBUSB20_ERROR value is
457returned.
458.
459.Pp
460.
453This function will try to BUS reset the given USB device and restore
454the last set USB configuration.
455.
456This function returns zero on success else a LIBUSB20_ERROR value is
457returned.
458.
459.Pp
460.
461.Fn libusb20_dev_set_power_mode
461.Fn libusb20_dev_set_power_mode pdev power_mode
462This function sets the power mode of the USB device.
463.
464Valid power modes:
465.Bl -tag
466.It LIBUSB20_POWER_OFF
467.It LIBUSB20_POWER_ON
468.It LIBUSB20_POWER_SAVE
469.It LIBUSB20_POWER_SUSPEND
470.It LIBUSB20_POWER_RESUME
471.El
472.
473This function returns zero on success else a LIBUSB20_ERROR value is
474returned.
475.
476.Pp
477.
462This function sets the power mode of the USB device.
463.
464Valid power modes:
465.Bl -tag
466.It LIBUSB20_POWER_OFF
467.It LIBUSB20_POWER_ON
468.It LIBUSB20_POWER_SAVE
469.It LIBUSB20_POWER_SUSPEND
470.It LIBUSB20_POWER_RESUME
471.El
472.
473This function returns zero on success else a LIBUSB20_ERROR value is
474returned.
475.
476.Pp
477.
478.Fn libusb20_dev_get_power_mode
478.Fn libusb20_dev_get_power_mode pdev
479This function returns the currently selected power mode for the given
480USB device.
481.
482.Pp
483.
479This function returns the currently selected power mode for the given
480USB device.
481.
482.Pp
483.
484.Fn libusb20_dev_set_alt_index
484.Fn libusb20_dev_set_alt_index pdev iface_index alt_index
485This function will try to set the given alternate index for the given
486USB interface index.
487.
488This function returns zero on success else a LIBUSB20_ERROR value is
489returned.
490.
491.Pp
492.
485This function will try to set the given alternate index for the given
486USB interface index.
487.
488This function returns zero on success else a LIBUSB20_ERROR value is
489returned.
490.
491.Pp
492.
493.Fn libusb20_dev_set_owner
493.Fn libusb20_dev_set_owner pdev uid gid
494This function will set the ownership of the given USB device.
495.
496This function returns zero on success else a LIBUSB20_ERROR value is
497returned.
498.
499.Pp
500.
494This function will set the ownership of the given USB device.
495.
496This function returns zero on success else a LIBUSB20_ERROR value is
497returned.
498.
499.Pp
500.
501.Fn libusb20_dev_set_perm
501.Fn libusb20_dev_set_perm pdev mode
502This function will set the permissions of the given USB device.
503.
504This function returns zero on success else a LIBUSB20_ERROR value is
505returned.
506.
507.Pp
508.
502This function will set the permissions of the given USB device.
503.
504This function returns zero on success else a LIBUSB20_ERROR value is
505returned.
506.
507.Pp
508.
509.Fn libusb20_dev_set_iface_owner
509.Fn libusb20_dev_set_iface_owner pdev iface_index uid gid
510This function will set the ownership of the given USB interface.
511.
512This function returns zero on success else a LIBUSB20_ERROR value is
513returned.
514.
515.Pp
516.
510This function will set the ownership of the given USB interface.
511.
512This function returns zero on success else a LIBUSB20_ERROR value is
513returned.
514.
515.Pp
516.
517.Fn libusb20_dev_set_iface_perm
517.Fn libusb20_dev_set_iface_perm pdev iface_index mode
518This function will set the permissions of the given USB interface.
519.
520This function returns zero on success else a LIBUSB20_ERROR value is
521returned.
522.
523.Pp
524.
518This function will set the permissions of the given USB interface.
519.
520This function returns zero on success else a LIBUSB20_ERROR value is
521returned.
522.
523.Pp
524.
525.Fn libusb20_dev_get_owner
525.Fn libusb20_dev_get_owner pdev puid pgid
526This function will retrieve the current USB device ownership.
527.
528This function returns zero on success else a LIBUSB20_ERROR value is
529returned.
530.
531.Pp
532.
526This function will retrieve the current USB device ownership.
527.
528This function returns zero on success else a LIBUSB20_ERROR value is
529returned.
530.
531.Pp
532.
533.Fn libusb20_dev_get_perm
533.Fn libusb20_dev_get_perm pdev pmode
534This function will retrieve the current USB device permissions.
535.
536This function returns zero on success else a LIBUSB20_ERROR value is
537returned.
538.
539.Pp
540.
534This function will retrieve the current USB device permissions.
535.
536This function returns zero on success else a LIBUSB20_ERROR value is
537returned.
538.
539.Pp
540.
541.Fn libusb20_dev_get_iface_owner
541.Fn libusb20_dev_get_iface_owner pdev iface_index puid pgid
542This function will retrieve the current USB interface ownership for
543the given USB interface.
544.
545This function returns zero on success else a LIBUSB20_ERROR value is
546returned.
547.
548.Pp
549.
542This function will retrieve the current USB interface ownership for
543the given USB interface.
544.
545This function returns zero on success else a LIBUSB20_ERROR value is
546returned.
547.
548.Pp
549.
550.Fn libusb20_dev_get_iface_perm
550.Fn libusb20_dev_get_iface_perm pdev iface_index pmode
551This function will retrieve the current USB interface permissions for
552the given USB interface.
553.
554This function returns zero on success else a LIBUSB20_ERROR value is
555returned.
556.
557.Pp
558.
551This function will retrieve the current USB interface permissions for
552the given USB interface.
553.
554This function returns zero on success else a LIBUSB20_ERROR value is
555returned.
556.
557.Pp
558.
559.Fn libusb20_dev_get_device_desc
559.Fn libusb20_dev_get_device_desc pdev
560This function returns a pointer to the decoded and host endian version
561of the device descriptor.
562.
563The USB device need not be opened when calling this function.
564.
565.Pp
566.
560This function returns a pointer to the decoded and host endian version
561of the device descriptor.
562.
563The USB device need not be opened when calling this function.
564.
565.Pp
566.
567.Fn libusb20_dev_alloc_config
567.Fn libusb20_dev_alloc_config pdev config_index
568This function will read out and decode the USB config descriptor for
569the given USB device and config index. This function returns a pointer
570to the decoded configuration which must eventually be passed to
571free(). NULL is returned in case of failure.
572.
573.Pp
574.
568This function will read out and decode the USB config descriptor for
569the given USB device and config index. This function returns a pointer
570to the decoded configuration which must eventually be passed to
571free(). NULL is returned in case of failure.
572.
573.Pp
574.
575.Fn libusb20_dev_alloc(void)
575.Fn libusb20_dev_alloc void
576This is an internal function to allocate a new USB device.
577.
578.Pp
579.
576This is an internal function to allocate a new USB device.
577.
578.Pp
579.
580.Fn libusb20_dev_get_address
580.Fn libusb20_dev_get_address pdev
581This function returns the internal and not necessarily the real
582hardware address of the given USB device.
583.
584.Pp
585.
581This function returns the internal and not necessarily the real
582hardware address of the given USB device.
583.
584.Pp
585.
586.Fn libusb20_dev_get_bus_number
586.Fn libusb20_dev_get_bus_number pdev
587This function return the internal bus number which the given USB
588device belongs to.
589.
590.Pp
591.
587This function return the internal bus number which the given USB
588device belongs to.
589.
590.Pp
591.
592.Fn libusb20_dev_get_mode
592.Fn libusb20_dev_get_mode pdev
593This function returns the current operation mode of the USB entity.
594.
595Valid return values are:
596.Bl -tag
597.It LIBUSB20_MODE_HOST
598.It LIBUSB20_MODE_DEVICE
599.El
600.
601.Pp
602.
593This function returns the current operation mode of the USB entity.
594.
595Valid return values are:
596.Bl -tag
597.It LIBUSB20_MODE_HOST
598.It LIBUSB20_MODE_DEVICE
599.El
600.
601.Pp
602.
603.Fn libusb20_dev_get_speed
603.Fn libusb20_dev_get_speed pdev
604This function returns the current speed of the given USB device.
605.
606.Bl -tag
607.It LIBUSB20_SPEED_UNKNOWN
608.It LIBUSB20_SPEED_LOW
609.It LIBUSB20_SPEED_FULL
610.It LIBUSB20_SPEED_HIGH
611.It LIBUSB20_SPEED_VARIABLE
612.It LIBUSB20_SPEED_SUPER
613.El
614.
615.Pp
616.
604This function returns the current speed of the given USB device.
605.
606.Bl -tag
607.It LIBUSB20_SPEED_UNKNOWN
608.It LIBUSB20_SPEED_LOW
609.It LIBUSB20_SPEED_FULL
610.It LIBUSB20_SPEED_HIGH
611.It LIBUSB20_SPEED_VARIABLE
612.It LIBUSB20_SPEED_SUPER
613.El
614.
615.Pp
616.
617.Fn libusb20_dev_get_config_index
617.Fn libusb20_dev_get_config_index pdev
618This function returns the currently select config index for the given
619USB device.
620.
621.Pp
622.
618This function returns the currently select config index for the given
619USB device.
620.
621.Pp
622.
623.Fn libusb20_dev_free
623.Fn libusb20_dev_free pdev
624This function will free the given USB device and all associated USB
625transfers.
626.
627.Pp
628.
624This function will free the given USB device and all associated USB
625transfers.
626.
627.Pp
628.
629.Fn libusb20_dev_set_debug
629.Fn libusb20_dev_set_debug pdev debug_level
630This function will set the debug level for the given USB device.
631.
632.Pp
633.
630This function will set the debug level for the given USB device.
631.
632.Pp
633.
634.Fn libusb20_dev_wait_process
634.Fn libusb20_dev_wait_process pdev timeout
635This function will wait until a pending USB transfer has completed on
636the given USB device.
637.
638A timeout value can be specified which is passed on to the
639.Xr 2 poll
640function.
641.
642.Sh USB BUS OPERATIONS
643.
635This function will wait until a pending USB transfer has completed on
636the given USB device.
637.
638A timeout value can be specified which is passed on to the
639.Xr 2 poll
640function.
641.
642.Sh USB BUS OPERATIONS
643.
644.Fn libusb20_bus_set_owner
644.Fn libusb20_bus_set_owner pbackend bus_index uid gid
645This function will set the ownership for the given USB bus.
646.
647This function returns zero on success else a LIBUSB20_ERROR value is
648returned.
649.
650.Pp
651.
645This function will set the ownership for the given USB bus.
646.
647This function returns zero on success else a LIBUSB20_ERROR value is
648returned.
649.
650.Pp
651.
652.Fn libusb20_bus_set_perm
652.Fn libusb20_bus_set_perm pbackend bus_index mode
653This function will set the permissions for the given USB bus.
654.
655This function returns zero on success else a LIBUSB20_ERROR value is
656returned.
657.
658.Pp
659.
653This function will set the permissions for the given USB bus.
654.
655This function returns zero on success else a LIBUSB20_ERROR value is
656returned.
657.
658.Pp
659.
660.Fn libusb20_bus_get_owner
660.Fn libusb20_bus_get_owner pbackend bus_index puid pgid
661This function will retrieve the ownership for the given USB bus.
662.
663This function returns zero on success else a LIBUSB20_ERROR value is
664returned.
665.
666.Pp
667.
661This function will retrieve the ownership for the given USB bus.
662.
663This function returns zero on success else a LIBUSB20_ERROR value is
664returned.
665.
666.Pp
667.
668.Fn libusb20_bus_get_perm
668.Fn libusb20_bus_get_perm pbackend bus_index pmode
669This function will retrieve the permissions for the given USB bus.
670.
671This function returns zero on success else a LIBUSB20_ERROR value is
672returned.
673.
674.
675.Sh USB BACKEND OPERATIONS
676.
669This function will retrieve the permissions for the given USB bus.
670.
671This function returns zero on success else a LIBUSB20_ERROR value is
672returned.
673.
674.
675.Sh USB BACKEND OPERATIONS
676.
677.Fn libusb20_be_get_dev_quirk
677.Fn libusb20_be_get_dev_quirk pbackend index pquirk
678This function will return the device quirk according to
679.Fa index
680into the libusb20_quirk structure pointed to by
681.Fa pq .
682This function returns zero on success else a LIBUSB20_ERROR value is
683returned.
684.
685If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
686returned.
687.
688.Pp
689.
678This function will return the device quirk according to
679.Fa index
680into the libusb20_quirk structure pointed to by
681.Fa pq .
682This function returns zero on success else a LIBUSB20_ERROR value is
683returned.
684.
685If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
686returned.
687.
688.Pp
689.
690.Fn libusb20_be_get_quirk_name
690.Fn libusb20_be_get_quirk_name pbackend index pquirk
691This function will return the quirk name according to
692.Fa index
693into the libusb20_quirk structure pointed to by
694.Fa pq .
695This function returns zero on success else a LIBUSB20_ERROR value is
696returned.
697.
698If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
699returned.
700.
701.Pp
702.
691This function will return the quirk name according to
692.Fa index
693into the libusb20_quirk structure pointed to by
694.Fa pq .
695This function returns zero on success else a LIBUSB20_ERROR value is
696returned.
697.
698If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
699returned.
700.
701.Pp
702.
703.Fn libusb20_be_add_dev_quirk
703.Fn libusb20_be_add_dev_quirk pbackend pquirk
704This function will add the libusb20_quirk structure pointed to by the
705.Fa pq
706argument into the device quirk list.
707.
708This function returns zero on success else a LIBUSB20_ERROR value is
709returned.
710.
711If the given quirk cannot be added LIBUSB20_ERROR_NO_MEM is
712returned.
713.
714.Pp
715.
704This function will add the libusb20_quirk structure pointed to by the
705.Fa pq
706argument into the device quirk list.
707.
708This function returns zero on success else a LIBUSB20_ERROR value is
709returned.
710.
711If the given quirk cannot be added LIBUSB20_ERROR_NO_MEM is
712returned.
713.
714.Pp
715.
716.Fn libusb20_be_remove_dev_quirk
716.Fn libusb20_be_remove_dev_quirk pbackend pquirk
717This function will remove the quirk matching the libusb20_quirk structure pointed to by the
718.Fa pq
719argument from the device quirk list.
720.
721This function returns zero on success else a LIBUSB20_ERROR value is
722returned.
723.
724If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
725returned.
726.
727.Pp
728.
717This function will remove the quirk matching the libusb20_quirk structure pointed to by the
718.Fa pq
719argument from the device quirk list.
720.
721This function returns zero on success else a LIBUSB20_ERROR value is
722returned.
723.
724If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
725returned.
726.
727.Pp
728.
729.Fn libusb20_be_set_owner
729.Fn libusb20_be_set_owner pbackend uid gid
730This function will set the ownership for the given backend.
731.
732This function returns zero on success else a LIBUSB20_ERROR value is
733returned.
734.
735.Pp
736.
730This function will set the ownership for the given backend.
731.
732This function returns zero on success else a LIBUSB20_ERROR value is
733returned.
734.
735.Pp
736.
737.Fn libusb20_be_set_perm
737.Fn libusb20_be_set_perm pbackend mode
738This function will set the permissions for the given backend.
739.
740This function returns zero on success else a LIBUSB20_ERROR value is
741returned.
742.
743.Pp
744.
738This function will set the permissions for the given backend.
739.
740This function returns zero on success else a LIBUSB20_ERROR value is
741returned.
742.
743.Pp
744.
745.Fn libusb20_be_get_owner
745.Fn libusb20_be_get_owner pbackend puid pgid
746This function will retrieve the ownership of the given backend.
747.
748This function returns zero on success else a LIBUSB20_ERROR value is
749returned.
750.
751.Pp
752.
746This function will retrieve the ownership of the given backend.
747.
748This function returns zero on success else a LIBUSB20_ERROR value is
749returned.
750.
751.Pp
752.
753.Fn libusb20_be_get_perm
753.Fn libusb20_be_get_perm pbackend pmode
754This function will retrieve the permissions of the given backend.
755.
756.
757This function returns zero on success else a LIBUSB20_ERROR value is
758returned.
759.
760.Pp
761.
754This function will retrieve the permissions of the given backend.
755.
756.
757This function returns zero on success else a LIBUSB20_ERROR value is
758returned.
759.
760.Pp
761.
762.Fn libusb20_be_alloc
762.Fn libusb20_be_alloc pmethods
763This is an internal function to allocate a USB backend.
764.
765.Pp
763This is an internal function to allocate a USB backend.
764.
765.Pp
766.Fn libusb20_be_alloc_default
767.Fn libusb20_be_alloc_freebsd
768.Fn libusb20_be_alloc_linux
766.Fn libusb20_be_alloc_default void
767.Fn libusb20_be_alloc_freebsd void
768.Fn libusb20_be_alloc_linux void
769These functions are used to allocate a specific USB backend or the
770operating system default USB backend. Allocating a backend is a way to
771scan for currently present USB devices.
772.
773.Pp
774.
769These functions are used to allocate a specific USB backend or the
770operating system default USB backend. Allocating a backend is a way to
771scan for currently present USB devices.
772.
773.Pp
774.
775.Fn libusb20_be_device_foreach
775.Fn libusb20_be_device_foreach pbackend pdev
776This function is used to iterate USB devices present in a USB backend.
777.
778The starting value of
779.Fa pdev
780is NULL.
781.
782This function returns the next USB device in the list.
783.
784If NULL is returned the end of the USB device list has been reached.
785.
786.Pp
787.
776This function is used to iterate USB devices present in a USB backend.
777.
778The starting value of
779.Fa pdev
780is NULL.
781.
782This function returns the next USB device in the list.
783.
784If NULL is returned the end of the USB device list has been reached.
785.
786.Pp
787.
788.Fn libusb20_be_dequeue_device
788.Fn libusb20_be_dequeue_device pbackend pdev
789This function will dequeue the given USB device pointer from the
790backend USB device list.
791.
792Dequeued USB devices will not be freed when the backend is freed.
793.
794.Pp
795.
789This function will dequeue the given USB device pointer from the
790backend USB device list.
791.
792Dequeued USB devices will not be freed when the backend is freed.
793.
794.Pp
795.
796.Fn libusb20_be_enqueue_device
796.Fn libusb20_be_enqueue_device pbackend pdev
797This function will enqueue the given USB device pointer in the backend USB device list.
798.
799Enqueued USB devices will get freed when the backend is freed.
800.
801.Pp
802.
797This function will enqueue the given USB device pointer in the backend USB device list.
798.
799Enqueued USB devices will get freed when the backend is freed.
800.
801.Pp
802.
803.Fn libusb20_be_free
803.Fn libusb20_be_free pbackend
804This function will free the given backend and all USB devices in its device list.
805.
806.
807.Sh USB DESCRIPTOR PARSING
808.
804This function will free the given backend and all USB devices in its device list.
805.
806.
807.Sh USB DESCRIPTOR PARSING
808.
809.Fn libusb20_me_get_1
809.Fn libusb20_me_get_1 pie offset
810This function will return a byte at the given byte offset of a message
811entity.
812.
813This function is safe against invalid offsets.
814.
815.Pp
816.
810This function will return a byte at the given byte offset of a message
811entity.
812.
813This function is safe against invalid offsets.
814.
815.Pp
816.
817.Fn libusb20_me_get_2
817.Fn libusb20_me_get_2 pie offset
818This function will return a little endian 16-bit value at the given byte offset of a message
819entity.
820.
821This function is safe against invalid offsets.
822.
823.Pp
824.
818This function will return a little endian 16-bit value at the given byte offset of a message
819entity.
820.
821This function is safe against invalid offsets.
822.
823.Pp
824.
825.Fn libusb20_me_encode
825.Fn libusb20_me_encode pbuf len pdecoded
826This function will encode a so-called *DECODED structure into binary
827format.
828.
829The total encoded length that will fit in the given buffer is
830returned.
831.
832If the buffer pointer is NULL no data will be written to the buffer
833location.
834.
835.Pp
836.
826This function will encode a so-called *DECODED structure into binary
827format.
828.
829The total encoded length that will fit in the given buffer is
830returned.
831.
832If the buffer pointer is NULL no data will be written to the buffer
833location.
834.
835.Pp
836.
837.Fn libusb20_me_decode
837.Fn libusb20_me_decode pbuf len pdecoded
838This function will decode a binary structure into a so-called *DECODED
839structure.
840.
841The total decoded length is returned.
842.
843The buffer pointer cannot be NULL.
844.
845.

--- 48 unchanged lines hidden ---
838This function will decode a binary structure into a so-called *DECODED
839structure.
840.
841The total decoded length is returned.
842.
843The buffer pointer cannot be NULL.
844.
845.

--- 48 unchanged lines hidden ---