2 .\" Copyright (c) 2008 Hans Petter Selasky
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
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
35 .Nd "USB access library"
41 USB access library (libusb -lusb)
48 .Fn libusb20_tr_close "struct libusb20_transfer *xfer"
50 .Fn libusb20_tr_open "struct libusb20_transfer *xfer" "uint32_t max_buf_size" "uint32_t max_frame_count" "uint8_t ep_no"
51 .Ft struct libusb20_transfer*
52 .Fn libusb20_tr_get_pointer "struct libusb20_device *pdev" "uint16_t tr_index"
54 .Fn libusb20_tr_get_time_complete "struct libusb20_transfer *xfer"
56 .Fn libusb20_tr_get_actual_frames "struct libusb20_transfer *xfer"
58 .Fn libusb20_tr_get_actual_length "struct libusb20_transfer *xfer"
60 .Fn libusb20_tr_get_max_frames "struct libusb20_transfer *xfer"
62 .Fn libusb20_tr_get_max_packet_length "struct libusb20_transfer *xfer"
64 .Fn libusb20_tr_get_max_total_length "struct libusb20_transfer *xfer"
66 .Fn libusb20_tr_get_status "struct libusb20_transfer *xfer"
68 .Fn libusb20_tr_pending "struct libusb20_transfer *xfer"
70 .Fn libusb20_tr_callback_wrapper "struct libusb20_transfer *xfer"
72 .Fn libusb20_tr_clear_stall_sync "struct libusb20_transfer *xfer"
74 .Fn libusb20_tr_drain "struct libusb20_transfer *xfer"
76 .Fn libusb20_tr_set_buffer "struct libusb20_transfer *xfer" "void *buffer" "uint16_t fr_index"
78 .Fn libusb20_tr_set_callback "struct libusb20_transfer *xfer" "libusb20_tr_callback_t *cb"
80 .Fn libusb20_tr_set_flags "struct libusb20_transfer *xfer" "uint8_t flags"
82 .Fn libusb20_tr_get_length "struct libusb20_transfer *xfer" "uint16_t fr_index"
84 .Fn libusb20_tr_set_length "struct libusb20_transfer *xfer" "uint32_t length" "uint16_t fr_index"
86 .Fn libusb20_tr_set_priv_sc0 "struct libusb20_transfer *xfer" "void *sc0"
88 .Fn libusb20_tr_set_priv_sc1 "struct libusb20_transfer *xfer" "void *sc1"
90 .Fn libusb20_tr_set_timeout "struct libusb20_transfer *xfer" "uint32_t timeout"
92 .Fn libusb20_tr_set_total_frames "struct libusb20_transfer *xfer" "uint32_t nframes"
94 .Fn libusb20_tr_setup_bulk "struct libusb20_transfer *xfer" "void *pbuf" "uint32_t length" "uint32_t timeout"
96 .Fn libusb20_tr_setup_control "struct libusb20_transfer *xfer" "void *psetup" "void *pbuf" "uint32_t timeout"
98 .Fn libusb20_tr_setup_intr "struct libusb20_transfer *xfer" "void *pbuf" "uint32_t length" "uint32_t timeout"
100 .Fn libusb20_tr_setup_isoc "struct libusb20_transfer *xfer" "void *pbuf" "uint32_t length" "uint61_t fr_index"
102 .Fn libusb20_tr_bulk_intr_sync "struct libusb20_transfer *xfer" "void *pbuf" "uint32_t length" "uint32_t *pactlen" "uint32_t timeout"
104 .Fn libusb20_tr_start "struct libusb20_transfer *xfer"
106 .Fn libusb20_tr_stop "struct libusb20_transfer *xfer"
108 .Fn libusb20_tr_submit "struct libusb20_transfer *xfer"
110 .Fn libusb20_tr_get_priv_sc0 "struct libusb20_transfer *xfer"
112 .Fn libusb20_tr_get_priv_sc1 "struct libusb20_transfer *xfer"
114 .Fn libusb20_dev_get_backend_name "struct libusb20_device *"
116 .Fn libusb20_dev_get_info "struct libusb20_device *pdev" "struct usb_device_info *pinfo"
118 .Fn libusb20_dev_get_iface_desc "struct libusb20_device *pdev" "uint8_t iface_index" "char *buf" "uint8_t len"
120 .Fn libusb20_dev_get_desc "struct libusb20_device *pdev"
122 .Fn libusb20_dev_close "struct libusb20_device *pdev"
124 .Fn libusb20_dev_detach_kernel_driver "struct libusb20_device *pdev" "uint8_t iface_index"
126 .Fn libusb20_dev_set_config_index "struct libusb20_device *pdev" "uint8_t configIndex"
128 .Fn libusb20_dev_get_debug "struct libusb20_device *pdev"
130 .Fn libusb20_dev_get_fd "struct libusb20_device *pdev"
132 .Fn libusb20_dev_kernel_driver_active "struct libusb20_device *pdev" "uint8_t iface_index"
134 .Fn libusb20_dev_open "struct libusb20_device *pdev" "uint16_t transfer_max"
136 .Fn libusb20_dev_process "struct libusb20_device *pdev"
138 .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"
140 .Fn libusb20_dev_req_string_sync "struct libusb20_device *pdev" "uint8_t index" "uint16_t langid" "void *ptr" "uint16_t len"
142 .Fn libusb20_dev_req_string_simple_sync "struct libusb20_device *pdev" "uint8_t index" "void *ptr" "uint16_t len"
144 .Fn libusb20_dev_reset "struct libusb20_device *pdev"
146 .Fn libusb20_dev_check_connected "struct libusb20_device *pdev"
148 .Fn libusb20_dev_set_power_mode "struct libusb20_device *pdev" "uint8_t power_mode"
150 .Fn libusb20_dev_get_power_mode "struct libusb20_device *pdev"
152 .Fn libusb20_dev_get_power_usage "struct libusb20_device *pdev"
154 .Fn libusb20_dev_set_alt_index "struct libusb20_device *pdev" "uint8_t iface_index" "uint8_t alt_index"
155 .Ft struct LIBUSB20_DEVICE_DESC_DECODED *
156 .Fn libusb20_dev_get_device_desc "struct libusb20_device *pdev"
157 .Ft struct libusb20_config *
158 .Fn libusb20_dev_alloc_config "struct libusb20_device *pdev" "uint8_t config_index"
159 .Ft struct libusb20_device *
160 .Fn libusb20_dev_alloc "void"
162 .Fn libusb20_dev_get_address "struct libusb20_device *pdev"
164 .Fn libusb20_dev_get_parent_address "struct libusb20_device *pdev"
166 .Fn libusb20_dev_get_parent_port "struct libusb20_device *pdev"
168 .Fn libusb20_dev_get_bus_number "struct libusb20_device *pdev"
170 .Fn libusb20_dev_get_mode "struct libusb20_device *pdev"
172 .Fn libusb20_dev_get_speed "struct libusb20_device *pdev"
174 .Fn libusb20_dev_get_config_index "struct libusb20_device *pdev"
176 .Fn libusb20_dev_free "struct libusb20_device *pdev"
178 .Fn libusb20_dev_set_debug "struct libusb20_device *pdev" "int debug"
180 .Fn libusb20_dev_wait_process "struct libusb20_device *pdev" "int timeout"
182 .Fn libusb20_be_get_template "struct libusb20_backend *pbe" "int *ptemp"
184 .Fn libusb20_be_set_template "struct libusb20_backend *pbe" "int temp"
186 .Fn libusb20_be_get_dev_quirk "struct libusb20_backend *pber" "uint16_t index" "struct libusb20_quirk *pq"
188 .Fn libusb20_be_get_quirk_name "struct libusb20_backend *pbe" "uint16_t index" "struct libusb20_quirk *pq"
190 .Fn libusb20_be_add_dev_quirk "struct libusb20_backend *pbe" "struct libusb20_quirk *pq"
192 .Fn libusb20_be_remove_dev_quirk "struct libusb20_backend *pbe" "struct libusb20_quirk *pq"
193 .Ft struct libusb20_backend *
194 .Fn libusb20_be_alloc_default "void"
195 .Ft struct libusb20_backend *
196 .Fn libusb20_be_alloc_freebsd "void"
197 .Ft struct libusb20_backend *
198 .Fn libusb20_be_alloc_linux "void"
199 .Ft struct libusb20_device *
200 .Fn libusb20_be_device_foreach "struct libusb20_backend *pbe" "struct libusb20_device *pdev"
202 .Fn libusb20_be_dequeue_device "struct libusb20_backend *pbe" "struct libusb20_device *pdev"
204 .Fn libusb20_be_enqueue_device "struct libusb20_backend *pbe" "struct libusb20_device *pdev"
206 .Fn libusb20_be_free "struct libusb20_backend *pbe"
208 .Fn libusb20_me_get_1 "const struct libusb20_me_struct *me" "uint16_t off"
210 .Fn libusb20_me_get_2 "const struct libusb20_me_struct *me" "uint16_t off"
212 .Fn libusb20_me_encode "void *pdata" "uint16_t len" "const void *pdecoded"
214 .Fn libusb20_me_decode "const void *pdata" "uint16_t len" "void *pdecoded"
215 .Ft "const uint8_t *"
216 .Fn libusb20_desc_foreach "const struct libusb20_me_struct *me" "const uint8_t *pdesc"
218 .Fn libusb20_strerror "int code"
220 .Fn libusb20_error_name "int code"
227 library implements functions to be able to easily access and control
228 USB through the USB file system interface.
231 interfaces are specific to the
233 usb stack and are not available on other operating systems, portable
234 applications should consider using
238 .Sh USB TRANSFER OPERATIONS
241 .Fn libusb20_tr_close
242 will release all kernel resources associated with an USB
245 This function returns zero upon success.
247 Non-zero return values indicate a LIBUSB20_ERROR value.
252 will allocate kernel buffer resources according to
256 associated with an USB
258 and bind the transfer to the specified
261 is the minimum buffer size which the data transport layer has to support.
266 library will use wMaxPacketSize to compute the buffer size.
267 This can be useful for isochronous transfers.
268 The actual buffer size can be greater than
271 .Fn libusb20_tr_get_max_total_length .
275 is OR'ed with LIBUSB20_MAX_FRAME_PRE_SCALE the remaining part of the
276 argument is converted from milliseconds into the actual number of
277 frames rounded up, when this function returns.
278 This flag is only valid for ISOCHRONOUS transfers and has no effect
279 for other transfer types.
280 The actual number of frames setup is found by calling
281 .Fn libusb20_tr_get_max_frames .
283 This function returns zero upon success.
285 Non-zero return values indicate a LIBUSB20_ERROR value.
289 .Fn libusb20_tr_get_pointer
290 will return a pointer to the allocated USB transfer according to the
296 This function returns NULL in case of failure.
300 .Fn libusb20_tr_get_time_complete
301 will return the completion time of an USB transfer in
302 millisecond units. This function is most useful for isochronous USB
303 transfers when doing echo cancelling.
307 .Fn libusb20_tr_get_actual_frames
308 will return the actual number of USB frames after an USB
309 transfer completed. A value of zero means that no data was transferred.
313 .Fn libusb20_tr_get_actual_length
314 will return the sum of the actual length for all
315 transferred USB frames for the given USB transfer.
319 .Fn libusb20_tr_get_max_frames
320 will return the maximum number of USB frames that were
321 allocated when an USB transfer was setup for the given USB transfer.
325 .Fn libusb20_tr_get_max_packet_length
326 will return the maximum packet length in bytes
327 associated with the given USB transfer.
329 The packet length can be used round up buffer sizes so that short USB
330 packets are avoided for proxy buffers.
335 .Fn libusb20_tr_get_max_total_length
336 will return the maximum value for the data length sum of all USB
337 frames associated with an USB transfer.
338 In case of control transfers the value returned does not include the
339 length of the SETUP packet, 8 bytes, which is part of frame zero.
340 The returned value of this function is always aligned to the maximum
341 packet size, wMaxPacketSize, of the endpoint which the USB transfer is
346 .Fn libusb20_tr_get_status
347 will return the status of an USB transfer.
349 Status values are defined by a set of LIBUSB20_TRANSFER_XXX enums.
353 .Fn libusb20_tr_pending
354 will return non-zero if the given USB transfer is
355 pending for completion.
357 Else this function returns zero.
361 .Fn libusb20_tr_callback_wrapper
362 This is an internal function used to wrap asynchronous USB callbacks.
366 .Fn libusb20_tr_clear_stall_sync
367 This is an internal function used to synchronously clear the stall on
368 the given USB transfer.
370 Please see the USB specification for more information on stall
373 If the given USB transfer is pending when this function is called, the
374 USB transfer will complete with an error after that this function has
379 .Fn libusb20_tr_drain
380 will stop the given USB transfer and will not return
381 until the USB transfer has been stopped in hardware.
385 .Fn libusb20_tr_set_buffer
388 pointer for the given USB transfer and
391 Typically the frame index is zero.
396 .Fn libusb20_tr_set_callback
397 is used to set the USB callback for asynchronous USB
400 The callback type is defined by libusb20_tr_callback_t.
404 .Fn libusb20_tr_set_flags
405 is used to set various USB flags for the given USB transfer.
407 .It LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK
408 Report a short frame as error.
409 .It LIBUSB20_TRANSFER_MULTI_SHORT_NOT_OK
410 Multiple short frames are not allowed.
411 .It LIBUSB20_TRANSFER_FORCE_SHORT
412 All transmitted frames are short terminated.
413 .It LIBUSB20_TRANSFER_DO_CLEAR_STALL
414 Will do a clear-stall before starting the transfer.
419 .Fn libusb20_tr_get_length
420 returns the length of the given USB frame by index.
421 After an USB transfer is complete the USB frame length will get updated to the actual transferred length.
425 .Fn libusb20_tr_set_length
426 sets the length of the given USB frame by index.
430 .Fn libusb20_tr_set_priv_sc0
431 sets private driver pointer number zero.
435 .Fn libusb20_tr_set_priv_sc1
436 sets private driver pointer number one.
440 .Fn libusb20_tr_set_timeout
441 sets the timeout for the given USB transfer.
443 A timeout value of zero means no timeout.
445 The timeout is given in milliseconds.
449 .Fn libusb20_tr_set_total_frames
450 sets the total number of frames that should be executed when the USB transfer is submitted.
452 The total number of USB frames must be less than the maximum number of USB frames associated with the given USB transfer.
456 .Fn libusb20_tr_setup_bulk
457 is a helper function for setting up a single frame USB BULK transfer.
461 .Fn libusb20_tr_setup_control
462 is a helper function for setting up a single or dual
463 frame USB CONTROL transfer depending on the control transfer length.
467 .Fn libusb20_tr_setup_intr
468 is a helper function for setting up a single frame USB INTERRUPT transfer.
472 .Fn libusb20_tr_setup_isoc
473 is a helper function for setting up a multi frame USB ISOCHRONOUS transfer.
477 .Fn libusb20_tr_bulk_intr_sync
478 will perform a synchronous BULK or INTERRUPT transfer having length given by the
480 argument and buffer pointer given by the
482 argument on the USB transfer given by the
488 argument is non-NULL the actual transfer length will be stored at the given pointer destination.
492 argument is non-zero the transfer will timeout after the given value in milliseconds.
494 This function does not change the transfer flags, like short packet not ok.
496 This function returns zero on success else a LIBUSB20_TRANSFER_XXX value is returned.
500 .Fn libusb20_tr_start
501 will get the USB transfer started, if not already
504 This function will not get the transfer queued in hardware.
506 This function is non-blocking.
511 will get the USB transfer stopped, if not already stopped.
513 This function is non-blocking, which means that the actual stop can
514 happen after the return of this function.
518 .Fn libusb20_tr_submit
519 will get the USB transfer queued in hardware.
524 .Fn libusb20_tr_get_priv_sc0
525 returns private driver pointer number zero associated
526 with an USB transfer.
531 .Fn libusb20_tr_get_priv_sc1
532 returns private driver pointer number one associated
533 with an USB transfer.
536 .Sh USB DEVICE OPERATIONS
539 .Fn libusb20_dev_get_backend_name
540 returns a zero terminated string describing the backend used.
544 .Fn libusb20_dev_get_info
545 retrieves the BSD specific usb_device_info structure into the memory location given by
547 The USB device given by
549 must be opened before this function will succeed.
550 This function returns zero on success else a LIBUSB20_ERROR value is returned.
554 .Fn libusb20_dev_get_iface_desc
555 retrieves the kernel interface description for the given USB
557 The format of the USB interface description is: "drivername<unit>: <description>"
558 The description string is always zero terminated.
559 A zero length string is written in case no driver is attached to the given interface.
560 The USB device given by
562 must be opened before this function will succeed.
563 This function returns zero on success else a LIBUSB20_ERROR value is returned.
567 .Fn libusb20_dev_get_desc
568 returns a zero terminated string describing the given USB device.
569 The format of the string is: "drivername<unit>: <description>"
573 .Fn libusb20_dev_close
574 will close the given USB device.
576 This function returns zero on success else a LIBUSB20_ERROR value is
581 .Fn libusb20_dev_detach_kernel_driver
582 will try to detach the kernel driver for the USB interface given by
585 This function returns zero on success else a LIBUSB20_ERROR value is
590 .Fn libusb20_dev_set_config_index
591 will try to set the configuration index on an USB
594 The first configuration index is zero.
596 The un-configure index is 255.
598 This function returns zero on success else a LIBUSB20_ERROR value is returned.
602 .Fn libusb20_dev_get_debug
603 returns the debug level of an USB device.
607 .Fn libusb20_dev_get_fd
608 returns the file descriptor of the given USB device.
610 A negative value is returned when no file descriptor is present.
612 The file descriptor can be used for polling purposes.
616 .Fn libusb20_dev_kernel_driver_active
617 returns zero if a kernel driver is active on the given USB interface.
619 Else a LIBUSB20_ERROR value is returned.
623 .Fn libusb20_dev_open
624 opens an USB device so that setting up USB transfers
627 The number of USB transfers can be zero which means only control
628 transfers are allowed.
630 This function returns zero on success else a LIBUSB20_ERROR value is
633 A return value of LIBUSB20_ERROR_BUSY means that the device is already
638 .Fn libusb20_dev_process
639 is called to sync kernel USB transfers with userland USB
642 This function returns zero on success else a LIBUSB20_ERROR value is
643 returned typically indicating that the given USB device has been
648 .Fn libusb20_dev_request_sync
649 will perform a synchronous control request on the given
652 Before this call will succeed the USB device must be opened.
655 is a pointer to a decoded and host endian SETUP packet.
657 is a pointer to a data transfer buffer associated with the control transaction. This argument can be NULL.
659 is a pointer to a variable that will hold the actual transfer length after the control transaction is complete.
661 is the transaction timeout given in milliseconds.
662 A timeout of zero means no timeout.
664 is used to specify transaction flags, for example LIBUSB20_TRANSFER_SINGLE_SHORT_NOT_OK.
666 This function returns zero on success else a LIBUSB20_ERROR value is
671 .Fn libusb20_dev_req_string_sync
672 will synchronously request an USB string by language ID
673 and string index into the given buffer limited by a maximum length.
675 This function returns zero on success else a LIBUSB20_ERROR value is
680 .Fn libusb20_dev_req_string_simple_sync
681 will synchronously request an USB string using the
682 default language ID and convert the string into ASCII before storing
683 the string into the given buffer limited by a maximum length which
684 includes the terminating zero.
686 This function returns zero on success else a LIBUSB20_ERROR value is
692 .Fn libusb20_dev_reset
693 will try to BUS reset the given USB device and restore
694 the last set USB configuration.
696 This function returns zero on success else a LIBUSB20_ERROR value is
702 .Fn libusb20_dev_check_connected
703 will check if an opened USB device is still connected.
705 This function returns zero if the device is still connected else a LIBUSB20_ERROR value is returned.
710 .Fn libusb20_dev_set_power_mode
711 sets the power mode of the USB device.
715 .It LIBUSB20_POWER_OFF
716 .It LIBUSB20_POWER_ON
717 .It LIBUSB20_POWER_SAVE
718 .It LIBUSB20_POWER_SUSPEND
719 .It LIBUSB20_POWER_RESUME
722 This function returns zero on success else a LIBUSB20_ERROR value is
727 .Fn libusb20_dev_get_power_mode
728 returns the currently selected power mode for the given
733 .Fn libusb20_dev_get_power_usage
734 returns the reported power usage in milliamps for the given USB device.
735 A power usage of zero typically means that the device is self powered.
739 .Fn libusb20_dev_set_alt_index
740 will try to set the given alternate index for the given
743 This function returns zero on success else a LIBUSB20_ERROR value is
748 .Fn libusb20_dev_get_device_desc
749 returns a pointer to the decoded and host endian version
750 of the device descriptor.
752 The USB device need not be opened when calling this function.
756 .Fn libusb20_dev_alloc_config
757 will read out and decode the USB config descriptor for
758 the given USB device and config index. This function returns a pointer
759 to the decoded configuration which must eventually be passed to
760 free(). NULL is returned in case of failure.
764 .Fn libusb20_dev_alloc
765 is an internal function to allocate a new USB device.
769 .Fn libusb20_dev_get_address
770 returns the internal and not necessarily the real
771 hardware address of the given USB device.
772 Valid addresses start at one.
776 .Fn libusb20_dev_get_parent_address
777 returns the internal and not necessarily the real hardware address of
778 the given parent USB HUB device.
779 This value is zero for the root HUB which usually has a device address
781 Valid addresses start at one.
785 .Fn libusb20_dev_get_parent_port
786 returns the port number on the parent USB HUB device.
787 This value is zero for the root HUB which usually has a device address
789 Valid port numbers start at one.
793 .Fn libusb20_dev_get_bus_number
794 returns the internal bus number which the given USB
796 Valid bus numbers start at zero.
800 .Fn libusb20_dev_get_mode
801 returns the current operation mode of the USB entity.
803 Valid return values are:
805 .It LIBUSB20_MODE_HOST
806 .It LIBUSB20_MODE_DEVICE
811 .Fn libusb20_dev_get_speed
812 returns the current speed of the given USB device.
815 .It LIBUSB20_SPEED_UNKNOWN
816 .It LIBUSB20_SPEED_LOW
817 .It LIBUSB20_SPEED_FULL
818 .It LIBUSB20_SPEED_HIGH
819 .It LIBUSB20_SPEED_VARIABLE
820 .It LIBUSB20_SPEED_SUPER
825 .Fn libusb20_dev_get_config_index
826 returns the currently selected config index for the given
831 .Fn libusb20_dev_free
832 will free the given USB device and all associated USB
837 .Fn libusb20_dev_set_debug
838 will set the debug level for the given USB device.
842 .Fn libusb20_dev_wait_process
843 will wait until a pending USB transfer has completed on
844 the given USB device.
846 A timeout value can be specified which is passed on to the
850 .Sh USB BACKEND OPERATIONS
852 .Fn libusb20_be_get_template
853 will return the currently selected global USB device
854 side mode template into the integer pointer
856 This function returns zero on success else a LIBUSB20_ERROR value is
861 .Fn libusb20_be_set_template
862 will set the global USB device side mode template to
864 The new template is not activated until after the next USB
866 The template number decides how the USB device will present itself to
867 the USB Host, like Mass Storage Device, USB Ethernet Device. Also see
871 This function returns zero on success else a LIBUSB20_ERROR value is
876 .Fn libusb20_be_get_dev_quirk
877 will return the device quirk according to
879 into the libusb20_quirk structure pointed to by
881 This function returns zero on success else a LIBUSB20_ERROR value is
884 If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
889 .Fn libusb20_be_get_quirk_name
890 will return the quirk name according to
892 into the libusb20_quirk structure pointed to by
894 This function returns zero on success else a LIBUSB20_ERROR value is
897 If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
902 .Fn libusb20_be_add_dev_quirk
903 will add the libusb20_quirk structure pointed to by the
905 argument into the device quirk list.
907 This function returns zero on success else a LIBUSB20_ERROR value is
910 If the given quirk cannot be added LIBUSB20_ERROR_NO_MEM is
915 .Fn libusb20_be_remove_dev_quirk
916 will remove the quirk matching the libusb20_quirk structure pointed to by the
918 argument from the device quirk list.
920 This function returns zero on success else a LIBUSB20_ERROR value is
923 If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
928 .Fn libusb20_be_alloc_default
929 .Fn libusb20_be_alloc_freebsd
930 .Fn libusb20_be_alloc_linux
931 These functions are used to allocate a specific USB backend or the
932 operating system default USB backend. Allocating a backend is a way to
933 scan for currently present USB devices.
937 .Fn libusb20_be_device_foreach
938 is used to iterate USB devices present in a USB backend.
940 The starting value of
944 This function returns the next USB device in the list.
946 If NULL is returned the end of the USB device list has been reached.
950 .Fn libusb20_be_dequeue_device
951 will dequeue the given USB device pointer from the
952 backend USB device list.
954 Dequeued USB devices will not be freed when the backend is freed.
958 .Fn libusb20_be_enqueue_device
959 will enqueue the given USB device pointer in the backend USB device list.
961 Enqueued USB devices will get freed when the backend is freed.
966 will free the given backend and all USB devices in its device list.
969 .Sh USB DESCRIPTOR PARSING
971 .Fn libusb20_me_get_1 pie offset
972 This function will return a byte at the given byte offset of a message
975 This function is safe against invalid offsets.
979 .Fn libusb20_me_get_2 pie offset
980 This function will return a little endian 16-bit value at the given byte offset of a message
983 This function is safe against invalid offsets.
987 .Fn libusb20_me_encode pbuf len pdecoded
988 This function will encode a so-called *DECODED structure into binary
991 The total encoded length that will fit in the given buffer is
994 If the buffer pointer is NULL no data will be written to the buffer
999 .Fn libusb20_me_decode pbuf len pdecoded
1000 This function will decode a binary structure into a so-called *DECODED
1003 The total decoded length is returned.
1005 The buffer pointer cannot be NULL.
1010 .Fn libusb20_strerror "int code"
1011 Get the ASCII representation of the error given by the
1014 This function does not return NULL.
1017 .Fn libusb20_error_name "int code"
1018 Get the ASCII representation of the error enum given by the
1021 This function does not return NULL.
1039 API derives from the libusb project at sourceforge.