USBD_OPEN_PIPE(9) | Kernel Developer's Manual | USBD_OPEN_PIPE(9)

# NAME

`usbd_open_pipe`, `usbd_open_pipe_intr` — create USB pipe

# SYNOPSIS

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

usbd_status
`usbd_open_pipe`(struct usbd_interface *iface, uint8_t address, uint8_t flags, struct usbd_pipe **pipe);

usbd_status
`usbd_open_pipe_intr`(struct usbd_interface *iface, uint8_t address, uint8_t flags, struct usbd_pipe **pipe, void *priv, void *buffer, uint32_t len, usbd_callback cb, int ival);

# DESCRIPTION

The `usbd_open_pipe`() and `usbd_open_pipe_intr`() functions create pipes. A pipe is a logical connection between the host and an endpoint on a USB device. USB drivers use pipes to manage transfers to or from a USB endpoint.

The `usbd_open_pipe`() function takes the following arguments:

iface
  The USB interface for which the pipe is to be created.
address
  The address of the endpoint in that interface to which the pipe should be connected.
flags
  A bitmask of flags. Currently there is only one flag bit defined:
  `USBD_EXCLUSIVE_USE`
    Do not allow other pipes to use this endpoint while this pipe exists.
pipe
  A pointer to where the resulting struct usbd_pipe * should be stored if the call is successful.

The `usbd_open_pipe_intr`() function takes the following arguments:

iface
  The USB interface for which the pipe is to be created.
address
  The endpoint in that interface to which the pipe should be connected.
flags
  A bitmask of flags. These flags are not interpreted in the same way as the flags passed to `usbd_open_pipe`(). Instead, `usbd_open_pipe_intr`() implicitly turns on the `USBD_EXCLUSIVE_USE` bit for the pipe, disallowing multiple interrupt pipes for the same endpoint. The flags argument in this case is instead passed directly to usbd_setup_xfer(9) as its flags argument, whose interpretation is documented in its man page.
pipe
  A pointer to where the resulting struct usbd_pipe * should be stored if the call is successful.
priv
  A pointer to a private cookie untouched by the USB stack for reuse in the callback specified by the cb argument.
buffer
  A pointer to the data buffer for use by the implicit transfer (see below).
len
  The length in bytes of buffer.
cb
  A callback invoked every time the interrupt transfer completes.
ival
  The interval in milliseconds with which the interrupt pipe should be polled by the USB stack.

Pipes created by `usbd_open_pipe_intr`() implicitly have a repeating transfer queued on them which is run every ival milliseconds. This implicit transfer is not automatically removed from the list of transfers maintained by the pipe, unlike normal transfers, and will continue to be processed every ival milliseconds.

# CONTEXT

`usbd_open_pipe`() and `usbd_open_pipe_intr`() can be called during autoconf or from process context.

# SEE ALSO

usb(4), usbd_close_pipe(9), usbd_transfer(9)

March 29, 2022 | Debian