Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

usb_ep_queue(9) [suse man page]

USB_EP_QUEUE(9) 					      Kernel Mode Gadget API						   USB_EP_QUEUE(9)

NAME
usb_ep_queue - queues (submits) an I/O request to an endpoint. SYNOPSIS
int usb_ep_queue(struct usb_ep * ep, struct usb_request * req, gfp_t gfp_flags); ARGUMENTS
ep the endpoint associated with the request req the request being submitted gfp_flags GFP_* flags to use in case the lower level driver couldn't pre-allocate all necessary memory with the request. DESCRIPTION
This tells the device controller to perform the specified request through that endpoint (reading or writing a buffer). When the request completes, including being canceled by usb_ep_dequeue, the request's completion routine is called to return the request to the driver. Any endpoint (except control endpoints like ep0) may have more than one transfer request queued; they complete in FIFO order. Once a gadget driver submits a request, that request may not be examined or modified until it is given back to that driver through the completion callback. Each request is turned into one or more packets. The controller driver never merges adjacent requests into the same packet. OUT transfers will sometimes use data that's already buffered in the hardware. Drivers can rely on the fact that the first byte of the request's buffer always corresponds to the first byte of some USB packet, for both IN and OUT transfers. Bulk endpoints can queue any amount of data; the transfer is packetized automatically. The last packet will be short if the request doesn't fill it out completely. Zero length packets (ZLPs) should be avoided in portable protocols since not all usb hardware can successfully handle zero length packets. (ZLPs may be explicitly written, and may be implicitly written if the request 'zero' flag is set.) Bulk endpoints may also be used for interrupt transfers; but the reverse is not true, and some endpoints won't support every interrupt transfer. (Such as 768 byte packets.) Interrupt-only endpoints are less functional than bulk endpoints, for example by not supporting queueing or not handling buffers that are larger than the endpoint's maxpacket size. They may also treat data toggle differently. Control endpoints ... after getting a setup callback, the driver queues one response (even if it would be zero length). That enables the status ack, after transfering data as specified in the response. Setup functions may return negative error codes to generate protocol stalls. (Note that some USB device controllers disallow protocol stall responses in some cases.) When control responses are deferred (the response is written after the setup callback returns), then usb_ep_set_halt may be used on ep0 to trigger protocol stalls. Depending on the controller, it may not be possible to trigger a status-stage protocol stall when the data stage is over, that is, from within the response's completion routine. For periodic endpoints, like interrupt or isochronous ones, the usb host arranges to poll once per interval, and the gadget driver usually will have queued some data to transfer at that time. Returns zero, or a negative error code. Endpoints that are not enabled report errors; errors will also be reported when the usb peripheral is disconnected. AUTHOR
David Brownell <dbrownell@users.sourceforge.net> Author. COPYRIGHT
Kernel Hackers Manual 2.6. July 2010 USB_EP_QUEUE(9)

Check Out this Related Man Page

STRUCT 
USB_GADGET_DR(9) Kernel Mode Gadget API STRUCT USB_GADGET_DR(9) NAME
struct_usb_gadget_driver - driver for usb 'slave' devices SYNOPSIS
struct usb_gadget_driver { char * function; enum usb_device_speed speed; int (* bind) (struct usb_gadget *); void (* unbind) (struct usb_gadget *); int (* setup) (struct usb_gadget *,const struct usb_ctrlrequest *); void (* disconnect) (struct usb_gadget *); void (* suspend) (struct usb_gadget *); void (* resume) (struct usb_gadget *); struct device_driver driver; }; MEMBERS
function String describing the gadget's function speed Highest speed the driver handles. bind Invoked when the driver is bound to a gadget, usually after registering the driver. At that point, ep0 is fully initialized, and ep_list holds the currently-available endpoints. Called in a context that permits sleeping. unbind Invoked when the driver is unbound from a gadget, usually from rmmod (after a disconnect is reported). Called in a context that permits sleeping. setup Invoked for ep0 control requests that aren't handled by the hardware level driver. Most calls must be handled by the gadget driver, including descriptor and configuration management. The 16 bit members of the setup data are in USB byte order. Called in_interrupt; this may not sleep. Driver queues a response to ep0, or returns negative to stall. disconnect Invoked after all transfers have been stopped, when the host is disconnected. May be called in_interrupt; this may not sleep. Some devices can't detect disconnect, so this might not be called except as part of controller shutdown. suspend Invoked on USB suspend. May be called in_interrupt. resume Invoked on USB resume. May be called in_interrupt. driver Driver model state for this driver. DESCRIPTION
Devices are disabled till a gadget driver successfully binds, which means the driver will handle setup requests needed to enumerate (and meet "chapter 9" requirements) then do some useful work. If gadget->is_otg is true, the gadget driver must provide an OTG descriptor during enumeration, or else fail the bind call. In such cases, no USB traffic may flow until both bind returns without having called usb_gadget_disconnect, and the USB host stack has initialized. Drivers use hardware-specific knowledge to configure the usb hardware. endpoint addressing is only one of several hardware characteristics that are in descriptors the ep0 implementation returns from setup calls. Except for ep0 implementation, most driver code shouldn't need change to run on top of different usb controllers. It'll use endpoints set up by that ep0 implementation. The usb controller driver handles a few standard usb requests. Those include set_address, and feature flags for devices, interfaces, and endpoints (the get_status, set_feature, and clear_feature requests). Accordingly, the driver's setup callback must always implement all get_descriptor requests, returning at least a device descriptor and a configuration descriptor. Drivers must make sure the endpoint descriptors match any hardware constraints. Some hardware also constrains other descriptors. (The pxa250 allows only configurations 1, 2, or 3). The driver's setup callback must also implement set_configuration, and should also implement set_interface, get_configuration, and get_interface. Setting a configuration (or interface) is where endpoints should be activated or (config 0) shut down. (Note that only the default control endpoint is supported. Neither hosts nor devices generally support control traffic except to ep0.) Most devices will ignore USB suspend/resume operations, and so will not provide those callbacks. However, some may need to change modes when the host is not longer directing those activities. For example, local controls (buttons, dials, etc) may need to be re-enabled since the (remote) host can't do that any longer; or an error state might be cleared, to make the device behave identically whether or not power is maintained. AUTHOR
David Brownell <dbrownell@users.sourceforge.net> Author. COPYRIGHT
Kernel Hackers Manual 2.6. July 2010 STRUCT USB_GADGET_DR(9)
Man Page