USBDI(9) | NetBSD Kernel Developer's Manual | USBDI(9)

# NAME

usbdi — USB device drivers interface

# SYNOPSIS

#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>

# DESCRIPTION

Device driver access to the USB bus centers around transfers. A transfer describes a communication with a USB device. A transfer is an abstract concept that can result in several physical packets being transferred to or from a device. A transfer is described by a usbd_xfer_handle. It is allocated by usbd_alloc_xfer and the data describing the transfer is filled by usbd_setup_default_xfer for control pipe transfers, by usbd_setup_xfer for bulk and interrupt transfers, and by usbd_setup_isoc_xfer for isochronous transfers.

describe usbd_do_request

describe pipes

describe usbd_status

## Functions offered by usbdi

usbd_status usbd_open_pipe(usbd_interface_handle iface, uint8_t address,
  uint8_t flags,
  usbd_pipe_handle *pipe)
usbd_status usbd_close_pipe(usbd_pipe_handle pipe)
usbd_status usbd_transfer(usbd_xfer_handle req)
usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle)
usbd_status usbd_free_xfer(usbd_xfer_handle xfer)
void usbd_setup_xfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
  usbd_private_handle priv, void *buffer,
  uint32_t length, uint16_t flags, uint32_t timeout,
  usbd_callback)
void usbd_setup_default_xfer(usbd_xfer_handle xfer,
  usbd_device_handle dev,
  usbd_private_handle priv, uint32_t timeout,
  usb_device_request_t *req, void *buffer,
  uint32_t length, uint16_t flags, usbd_callback)
void usbd_setup_isoc_xfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
  usbd_private_handle priv, uint16_t *frlengths,
  uint32_t nframes, uint16_t flags, usbd_callback)
void usbd_get_xfer_status(usbd_xfer_handle xfer, usbd_private_handle *priv,
  void **buffer, uint32_t *count, usbd_status *status)
usb_endpoint_descriptor_t *usbd_interface2endpoint_descriptor(usbd_interface_handle iface, uint8_t address)
usbd_status usbd_abort_pipe(usbd_pipe_handle pipe)
usbd_status usbd_clear_endpoint_stall(usbd_pipe_handle pipe)
usbd_status usbd_clear_endpoint_stall_async(usbd_pipe_handle pipe)
usbd_status usbd_endpoint_count(usbd_interface_handle dev, uint8_t *count)
usbd_status usbd_interface_count(usbd_device_handle dev, uint8_t *count)
usbd_status usbd_interface2device_handle(usbd_interface_handle iface, usbd_device_handle *dev)
usbd_status usbd_device2interface_handle(usbd_device_handle dev, uint8_t ifaceno, usbd_interface_handle *iface)

usbd_device_handle usbd_pipe2device_handle(usbd_pipe_handle)
void *usbd_alloc_buffer(usbd_xfer_handle req, uint32_t size)
void usbd_free_buffer(usbd_xfer_handle req)
void *usbd_get_buffer(usbd_xfer_handle xfer)
usbd_status usbd_sync_transfer(usbd_xfer_handle req)
usbd_status usbd_open_pipe_intr(usbd_interface_handle iface, uint8_t address,
  uint8_t flags, usbd_pipe_handle *pipe,
  usbd_private_handle priv, void *buffer,
  uint32_t length, usbd_callback)
usbd_status usbd_do_request(usbd_device_handle pipe, usb_device_request_t *req, void *data)
usbd_status usbd_do_request_async(usbd_device_handle pipe, usb_device_request_t *req, void *data)
usbd_status usbd_do_request_flags(usbd_device_handle pipe, usb_device_request_t *req,
  void *data, uint16_t flags, int *)
usb_interface_descriptor_t *usbd_get_interface_descriptor(usbd_interface_handle iface)
usb_config_descriptor_t *usbd_get_config_descriptor(usbd_device_handle dev)
usb_device_descriptor_t *usbd_get_device_descriptor(usbd_device_handle dev)
usbd_status usbd_set_interface(usbd_interface_handle, int)
int usbd_get_no_alts(usb_config_descriptor_t *, int)
usbd_status usbd_get_interface(usbd_interface_handle iface, uint8_t *aiface)
void usbd_fill_deviceinfo (usbd_device_handle dev, struct usb_device_info *di)
int usbd_get_interface_altindex(usbd_interface_handle iface)
usb_interface_descriptor_t *usbd_find_idesc(usb_config_descriptor_t *cd, int iindex, int ano)
usb_endpoint_descriptor_t *usbd_find_edesc(usb_config_descriptor_t *cd, int ifaceidx, int altidx,
  int endptidx)
const char *usbd_errstr(usbd_status err)

## Utilities from usbdi_util.h

Based on the routines in usbdi.h a number of utility functions have been defined that are accessible through usbdi_util.h

usbd_status usbd_get_desc(usbd_device_handle dev, int type,
  int index, int len, void *desc)
usbd_status usbd_get_config_desc(usbd_device_handle, int,
  usb_config_descriptor_t *)
usbd_status usbd_get_config_desc_full(usbd_device_handle, int,
  void *, int)
usbd_status usbd_get_device_desc(usbd_device_handle dev,
  usb_device_descriptor_t *d)
usbd_status usbd_set_address(usbd_device_handle dev, int addr)
usbd_status usbd_get_port_status(usbd_device_handle,
  int, usb_port_status_t *)
usbd_status usbd_set_hub_feature(usbd_device_handle dev, int)
usbd_status usbd_clear_hub_feature(usbd_device_handle, int)
usbd_status usbd_set_port_feature(usbd_device_handle dev, int, int)
usbd_status usbd_clear_port_feature(usbd_device_handle, int, int)
usbd_status usbd_get_device_status(usbd_device_handle,usb_status_t*)
usbd_status usbd_get_hub_status(usbd_device_handle dev,
  usb_hub_status_t *st)
usbd_status usbd_set_protocol(usbd_interface_handle dev, int report)
usbd_status usbd_get_report_descriptor
  (usbd_device_handle dev, int ifcno, int repid, int size, void *d)
struct usb_hid_descriptor *usbd_get_hid_descriptor
  (usbd_interface_handle ifc)
usbd_status usbd_set_report
  (usbd_interface_handle iface,int type,int id,void *data,int len)
usbd_status usbd_set_report_async
  (usbd_interface_handle iface,int type,int id,void *data,int len)
usbd_status usbd_get_report
  (usbd_interface_handle iface,int type,int id,void *data,int len)
usbd_status usbd_set_idle
  (usbd_interface_handle iface, int duration, int id)
usbd_status usbd_alloc_report_desc
  (usbd_interface_handle ifc, void **descp, int *sizep, int mem)
usbd_status usbd_get_config
  (usbd_device_handle dev, uint8_t *conf)
usbd_status usbd_get_string_desc
  (usbd_device_handle dev, int sindex, int langid, usb_string_descriptor_t *sdesc)
void usbd_delay_ms(usbd_device_handle, u_int)
usbd_status usbd_set_config_no
  (usbd_device_handle dev, int no, int msg)
usbd_status usbd_set_config_index
  (usbd_device_handle dev, int index, int msg)
usbd_status usbd_bulk_transfer
  (usbd_xfer_handle xfer, usbd_pipe_handle pipe, uint16_t flags, uint32_t timeout, void *buf, uint32_t *size, char *lbl)
void usb_detach_wait(device_ptr_t)
void usb_detach_wakeup(device_ptr_t)

# SEE ALSO

usb(4)

# HISTORY

This usbdi interface first appeared in NetBSD 1.4. The interface is based on an early definition from the OpenUSBDI group within the USB organisation. Right after this definition the OpenUSBDI development got closed for open source developers, so this interface has not followed the further changes. The OpenUSBDI specification is now available again, but looks different.

# BUGS

This man page is under development, so its biggest shortcoming is incompleteness.

December 3, 1999 | NetBSD 5.99