| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: usbdi.9,v 1.24 2012/07/20 07:55:44 mrg Exp $ | | 1 | .\" $NetBSD: usbdi.9,v 1.25 2013/01/22 15:35:08 jmcneill Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 2012 Matthew R. Green | | 3 | .\" Copyright (c) 2012 Matthew R. Green |
4 | .\" All rights reserved. | | 4 | .\" All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" Redistribution and use in source and binary forms, with or without | | 6 | .\" Redistribution and use in source and binary forms, with or without |
7 | .\" modification, are permitted provided that the following conditions | | 7 | .\" modification, are permitted provided that the following conditions |
8 | .\" are met: | | 8 | .\" are met: |
9 | .\" 1. Redistributions of source code must retain the above copyright | | 9 | .\" 1. Redistributions of source code must retain the above copyright |
10 | .\" notice, this list of conditions and the following disclaimer. | | 10 | .\" notice, this list of conditions and the following disclaimer. |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 11 | .\" 2. Redistributions in binary form must reproduce the above copyright |
12 | .\" notice, this list of conditions and the following disclaimer in the | | 12 | .\" notice, this list of conditions and the following disclaimer in the |
13 | .\" documentation and/or other materials provided with the distribution. | | 13 | .\" documentation and/or other materials provided with the distribution. |
14 | .\" 3. The name of the author may not be used to endorse or promote products | | 14 | .\" 3. The name of the author may not be used to endorse or promote products |
| @@ -44,27 +44,27 @@ | | | @@ -44,27 +44,27 @@ |
44 | .\" | | 44 | .\" |
45 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 45 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
46 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 46 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
47 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 47 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
48 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 48 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
49 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 49 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
50 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 50 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
51 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 51 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
52 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 52 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
53 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 53 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
54 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 54 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
55 | .\" POSSIBILITY OF SUCH DAMAGE. | | 55 | .\" POSSIBILITY OF SUCH DAMAGE. |
56 | .\" | | 56 | .\" |
57 | .Dd July 20, 2012 | | 57 | .Dd January 22, 2013 |
58 | .Dt USBDI 9 | | 58 | .Dt USBDI 9 |
59 | .Os | | 59 | .Os |
60 | .Sh NAME | | 60 | .Sh NAME |
61 | .Nm usbdi | | 61 | .Nm usbdi |
62 | .Nd USB device drivers interface | | 62 | .Nd USB device drivers interface |
63 | .Sh SYNOPSIS | | 63 | .Sh SYNOPSIS |
64 | .In dev/usb/usb.h | | 64 | .In dev/usb/usb.h |
65 | .In dev/usb/usbdi.h | | 65 | .In dev/usb/usbdi.h |
66 | .In dev/usb/usbdi_util.h | | 66 | .In dev/usb/usbdi_util.h |
67 | .Ss Functions offered by usbdi.h | | 67 | .Ss Functions offered by usbdi.h |
68 | .Ft usbd_status | | 68 | .Ft usbd_status |
69 | .Fn usbd_open_pipe "usbd_interface_handle iface" "uint8_t address" \ | | 69 | .Fn usbd_open_pipe "usbd_interface_handle iface" "uint8_t address" \ |
70 | "uint8_t flags" "usbd_pipe_handle *pipe" | | 70 | "uint8_t flags" "usbd_pipe_handle *pipe" |
| @@ -189,27 +189,27 @@ | | | @@ -189,27 +189,27 @@ |
189 | .Fn usbd_get_string0 "usbd_device_handle iface" "int" si "char *buf" \ | | 189 | .Fn usbd_get_string0 "usbd_device_handle iface" "int" si "char *buf" \ |
190 | "int unicode" | | 190 | "int unicode" |
191 | .Ft void | | 191 | .Ft void |
192 | .Fn usb_desc_iter_init "usbd_device_handle iface" "usbd_desc_iter_t *iter" | | 192 | .Fn usb_desc_iter_init "usbd_device_handle iface" "usbd_desc_iter_t *iter" |
193 | .Ft const usb_descriptor_t * | | 193 | .Ft const usb_descriptor_t * |
194 | .Fn usb_desc_iter_next "usbd_desc_iter_t *iter" | | 194 | .Fn usb_desc_iter_next "usbd_desc_iter_t *iter" |
195 | .Ft void | | 195 | .Ft void |
196 | .Fn usb_add_task "usbd_device_handle iface" "struct usb_task *task" \ | | 196 | .Fn usb_add_task "usbd_device_handle iface" "struct usb_task *task" \ |
197 | "int queue" | | 197 | "int queue" |
198 | .Ft void | | 198 | .Ft void |
199 | .Fn usb_rem_task "usbd_device_handle iface" "struct usb_task *task" | | 199 | .Fn usb_rem_task "usbd_device_handle iface" "struct usb_task *task" |
200 | .Ft void | | 200 | .Ft void |
201 | .Fn usb_init_task "struct usb_task *task" "void (*func)(void *)" \ | | 201 | .Fn usb_init_task "struct usb_task *task" "void (*func)(void *)" \ |
202 | "void *arg" | | 202 | "void *arg" uint8_t flags |
203 | .Ft const struct usb_devno * | | 203 | .Ft const struct usb_devno * |
204 | .Fn usb_lookup "const struct usb_devno *tbl" \ | | 204 | .Fn usb_lookup "const struct usb_devno *tbl" \ |
205 | "u_int16_t vendor" "u_int16_t product" | | 205 | "u_int16_t vendor" "u_int16_t product" |
206 | .Ss Utilities from usbdi_util.h | | 206 | .Ss Utilities from usbdi_util.h |
207 | Based on the routines in | | 207 | Based on the routines in |
208 | .Dv usbdi.h | | 208 | .Dv usbdi.h |
209 | a number of utility functions have been defined that are accessible | | 209 | a number of utility functions have been defined that are accessible |
210 | through | | 210 | through |
211 | .Dv usbdi_util.h . | | 211 | .Dv usbdi_util.h . |
212 | .Ft usbd_status | | 212 | .Ft usbd_status |
213 | .Fn usbd_get_desc "usbd_device_handle dev" "int type" "int index" \ | | 213 | .Fn usbd_get_desc "usbd_device_handle dev" "int type" "int index" \ |
214 | "int len" "void *desc" | | 214 | "int len" "void *desc" |
215 | .Ft usbd_status | | 215 | .Ft usbd_status |
| @@ -480,29 +480,32 @@ macro can be used to match any USB produ | | | @@ -480,29 +480,32 @@ macro can be used to match any USB produ |
480 | .Sh PIPES | | 480 | .Sh PIPES |
481 | Pipes are created and destroyed by using the | | 481 | Pipes are created and destroyed by using the |
482 | .Fn usbd_open_pipe , | | 482 | .Fn usbd_open_pipe , |
483 | .Fn usbd_open_pipe_intr | | 483 | .Fn usbd_open_pipe_intr |
484 | and | | 484 | and |
485 | .Fn usbd_close_pipe | | 485 | .Fn usbd_close_pipe |
486 | functions. | | 486 | functions. |
487 | The open functions take the interface handle | | 487 | The open functions take the interface handle |
488 | .Fa iface , | | 488 | .Fa iface , |
489 | the | | 489 | the |
490 | .Fa address | | 490 | .Fa address |
491 | of this pipe and | | 491 | of this pipe and |
492 | .Fa flags | | 492 | .Fa flags |
493 | for this pipe which currently may be 0 or | | 493 | for this pipe which currently may be 0, or a combination of |
494 | .Dv USBD_EXCLUSIVE_USE , | | 494 | .Dv USBD_EXCLUSIVE_USE , |
495 | to enable exclusive access to this interface and address. | | 495 | to enable exclusive access to this interface and address, and |
| | | 496 | .Dv USBD_MPSAFE , |
| | | 497 | to allow running transfer callbacks on this pipe without first acquiring |
| | | 498 | .Dv kernel_lock . |
496 | The | | 499 | The |
497 | .Fn usbd_open_pipe_intr | | 500 | .Fn usbd_open_pipe_intr |
498 | takes additional arguments | | 501 | takes additional arguments |
499 | .Fa priv | | 502 | .Fa priv |
500 | to set the default private handle. | | 503 | to set the default private handle. |
501 | .Fa buffer | | 504 | .Fa buffer |
502 | and | | 505 | and |
503 | .Fa len | | 506 | .Fa len |
504 | to describe the buffer to be used, | | 507 | to describe the buffer to be used, |
505 | .Fa callback | | 508 | .Fa callback |
506 | for the function to call at interrupt time, and finally the | | 509 | for the function to call at interrupt time, and finally the |
507 | .Fa interval | | 510 | .Fa interval |
508 | for interrupts to be delivered in milliseconds. | | 511 | for interrupts to be delivered in milliseconds. |
| @@ -913,29 +916,39 @@ function works like | | | @@ -913,29 +916,39 @@ function works like |
913 | .Sh USB TASK MANAGEMENT | | 916 | .Sh USB TASK MANAGEMENT |
914 | The USB stack provides a task management framework to execute tasks | | 917 | The USB stack provides a task management framework to execute tasks |
915 | in a thread context at the soonest opportunity. | | 918 | in a thread context at the soonest opportunity. |
916 | Typically this is used by network drivers to handle periodic updates | | 919 | Typically this is used by network drivers to handle periodic updates |
917 | or status change requests, or other operations that need to run in | | 920 | or status change requests, or other operations that need to run in |
918 | a normal context. | | 921 | a normal context. |
919 | .Pp | | 922 | .Pp |
920 | The | | 923 | The |
921 | .Fn usb_init_task | | 924 | .Fn usb_init_task |
922 | function takes a pointer to a | | 925 | function takes a pointer to a |
923 | .Ft struct usb_task | | 926 | .Ft struct usb_task |
924 | that will be initalised, a function to call for this task | | 927 | that will be initalised, a function to call for this task |
925 | .Fa func , | | 928 | .Fa func , |
926 | and the argument to pass to | | 929 | the argument to pass to |
927 | .Fa func , | | 930 | .Fa func , |
928 | .Fa arg . | | 931 | .Fa arg , |
| | | 932 | and the task flags |
| | | 933 | .Fa flags . |
| | | 934 | If the |
| | | 935 | .Fa flags |
| | | 936 | argument is |
| | | 937 | .Dt USB_TASKQ_MPSAFE , |
| | | 938 | the |
| | | 939 | .Fa func |
| | | 940 | function will be called without first acquiring |
| | | 941 | .Dt kernel_lock . |
929 | .Pp | | 942 | .Pp |
930 | To invoke the task callback the | | 943 | To invoke the task callback the |
931 | .Fn usb_add_task | | 944 | .Fn usb_add_task |
932 | function should be called with the | | 945 | function should be called with the |
933 | .Fa iface | | 946 | .Fa iface |
934 | associated with this device, the task structure | | 947 | associated with this device, the task structure |
935 | .Fa task , | | 948 | .Fa task , |
936 | and the | | 949 | and the |
937 | .Fa queue | | 950 | .Fa queue |
938 | to run against, either | | 951 | to run against, either |
939 | .Dv USB_TASKQ_HC | | 952 | .Dv USB_TASKQ_HC |
940 | for operations initiated by host controllers or | | 953 | for operations initiated by host controllers or |
941 | .Dv USB_TASKQ_DRIVER | | 954 | .Dv USB_TASKQ_DRIVER |