Sophie

Sophie

distrib > CentOS > 6 > i386 > by-pkgid > 2c51d8eb79f8810ada971ee8c30ce1e5 > files > 1401

kernel-doc-2.6.32-71.14.1.el6.noarch.rpm

<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>struct usb_gadget_driver</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="USB Gadget API for Linux" /><link rel="up" href="ch03s03.html" title="Core Objects and Methods" /><link rel="prev" href="re40.html" title="usb_gadget_disconnect" /><link rel="next" href="re42.html" title="usb_gadget_register_driver" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span>struct usb_gadget_driver</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="re40.html">Prev</a>&#160;</td><th width="60%" align="center">Core Objects and Methods</th><td width="20%" align="right">&#160;<a accesskey="n" href="re42.html">Next</a></td></tr></table><hr /></div><div class="refentry" title="struct usb_gadget_driver"><a id="API-struct-usb-gadget-driver"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct usb_gadget_driver &#8212; 
     driver for usb 'slave' devices
 </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><pre class="programlisting">
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;
};  </pre></div><div class="refsect1" title="Members"><a id="id2995969"></a><h2>Members</h2><div class="variablelist"><dl><dt><span class="term">function</span></dt><dd><p>
   String describing the gadget's function
      </p></dd><dt><span class="term">speed</span></dt><dd><p>
   Highest speed the driver handles.
      </p></dd><dt><span class="term">bind</span></dt><dd><p>
   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.
      </p></dd><dt><span class="term">unbind</span></dt><dd><p>
   Invoked when the driver is unbound from a gadget,
   usually from rmmod (after a disconnect is reported).
   Called in a context that permits sleeping.
      </p></dd><dt><span class="term">setup</span></dt><dd><p>
   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.
      </p></dd><dt><span class="term">disconnect</span></dt><dd><p>
   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.
      </p></dd><dt><span class="term">suspend</span></dt><dd><p>
   Invoked on USB suspend.  May be called in_interrupt.
      </p></dd><dt><span class="term">resume</span></dt><dd><p>
   Invoked on USB resume.  May be called in_interrupt.
      </p></dd><dt><span class="term">driver</span></dt><dd><p>
   Driver model state for this driver.
      </p></dd></dl></div></div><div class="refsect1" title="Description"><a id="id2996097"></a><h2>Description</h2><p>
   Devices are disabled till a gadget driver successfully <code class="function">bind</code>s, which
   means the driver will handle <code class="function">setup</code> requests needed to enumerate (and
   meet <span class="quote">&#8220;<span class="quote">chapter 9</span>&#8221;</span> requirements) then do some useful work.
   </p><p>

   If gadget-&gt;is_otg is true, the gadget driver must provide an OTG
   descriptor during enumeration, or else fail the <code class="function">bind</code> call.  In such
   cases, no USB traffic may flow until both <code class="function">bind</code> returns without
   having called <code class="function">usb_gadget_disconnect</code>, and the USB host stack has
   initialized.
   </p><p>

   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 <code class="function">setup</code> calls.
   </p><p>

   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.
   </p><p>

   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).
   </p><p>

   Accordingly, the driver's <code class="function">setup</code> 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).
   </p><p>

   The driver's <code class="function">setup</code> 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.
   </p><p>

   (Note that only the default control endpoint is supported.  Neither
   hosts nor devices generally support control traffic except to ep0.)
   </p><p>

   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.
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="re40.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch03s03.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="re42.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span>usb_gadget_disconnect</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span>usb_gadget_register_driver</span></td></tr></table></div></body></html>