1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
.\" $OpenBSD: usbd_open_pipe.9,v 1.4 2016/06/27 23:38:01 jmatthew Exp $
.\"
.\" Copyright (c) 2015 Sean Levy <attila@stalphonsos.com>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: June 27 2016 $
.Dt USBD_OPEN_PIPE 9
.Os
.Sh NAME
.Nm usbd_open_pipe , usbd_open_pipe_intr
.Nd create USB pipe
.Sh SYNOPSIS
.In dev/usb/usb.h
.In dev/usb/usbdi.h
.Ft usbd_status
.Fn usbd_open_pipe "struct usbd_interface *iface" "uint8_t address" "uint8_t flags" "struct usbd_pipe **pipe"
.Ft usbd_status
.Fn 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"
.Sh DESCRIPTION
The
.Fn usbd_open_pipe
and
.Fn 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.
.Pp
The
.Fn usbd_open_pipe
function takes the following arguments:
.Bl -tag -width callback
.It Fa iface
The USB interface for which the pipe is to be created.
.It Fa address
The address of the endpoint in that interface to which the pipe should be
connected.
.It Fa flags
A bitmask of flags.
Currently there is only one flag bit defined:
.Bl -tag -width xxx -offset indent
.It Dv USBD_EXCLUSIVE_USE
Do not allow other pipes to use this endpoint while this pipe exists.
.El
.It Fa pipe
A pointer to where the resulting
.Vt struct usbd_pipe *
should be stored if the call is successful.
.El
.Pp
The
.Fn usbd_open_pipe_intr
takes the following arguments:
.Bl -tag -width callback
.It Fa iface
The USB interface for which the pipe is to be created.
.It Fa address
The endpoint in that interface to which the pipe should be connected.
.It Fa flags
A bitmask of flags.
These flags are not interpreted in the same way as the
.Fa flags
passed to
.Fn usbd_open_pipe .
Instead,
.Fn usbd_open_pipe_intr
implicitly turns on the
.Dv USBD_EXCLUSIVE_USE
bit for the pipe, disallowing multiple interrupt pipes for
the same endpoint.
The
.Fa flags
argument in this case is instead passed directly to
.Xr usbd_setup_xfer 9
as its
.Fa flags
argument, whose interpretation is documented in
its man page.
.It Fa pipe
A pointer to where the resulting
.Vt struct usbd_pipe *
should be stored if the call is successful.
.It Fa priv
A pointer to a private cookie untouched by the USB stack for reuse in
the callback specified by the
.Fa cb
argument.
.It Fa buffer
A pointer to the data buffer for use by the implicit transfer
(see below).
.It Fa len
The length in bytes of
.Fa buffer .
.It Fa cb
A callback invoked every time the interrupt transfer completes.
.It Fa ival
The interval in milliseconds with which the interrupt pipe
should be polled by the USB stack.
.El
.Pp
Pipes created by
.Fn usbd_open_pipe_intr
implicitly have a repeating transfer queued on them which
is run every
.Fa 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
.Fa ival
milliseconds.
.Sh CONTEXT
.Fn usbd_open_pipe
and
.Fn usbd_open_pipe_intr
can be called during autoconf or from process context.
.Sh SEE ALSO
.Xr usb 4 ,
.Xr usbd_close_pipe 9 ,
.Xr usbd_transfer 9
|