1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>struct usb_configuration</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="USB Gadget API for Linux"><link rel="up" href="composite.html" title="Composite Device Framework"><link rel="prev" href="API-struct-usb-function.html" title="struct usb_function"><link rel="next" href="API-struct-usb-composite-driver.html" title="struct usb_composite_driver"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">struct usb_configuration</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-struct-usb-function.html">Prev</a>&#160;</td><th width="60%" align="center">Composite Device Framework</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-struct-usb-composite-driver.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-struct-usb-configuration"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>struct usb_configuration &#8212; 
2     represents one gadget configuration
3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="programlisting">
4struct usb_configuration {
5  const char * label;
6  struct usb_gadget_strings ** strings;
7  const struct usb_descriptor_header ** descriptors;
8  void (* unbind) (struct usb_configuration *);
9  int (* setup) (struct usb_configuration *,const struct usb_ctrlrequest *);
10  u8 bConfigurationValue;
11  u8 iConfiguration;
12  u8 bmAttributes;
13  u16 MaxPower;
14  struct usb_composite_dev * cdev;
15};  </pre></div><div class="refsect1"><a name="idp1124339756"></a><h2>Members</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">label</span></dt><dd><p>
16   For diagnostics, describes the configuration.
17      </p></dd><dt><span class="term">strings</span></dt><dd><p>
18   Tables of strings, keyed by identifiers assigned during @<code class="function">bind</code>
19   and by language IDs provided in control requests.
20      </p></dd><dt><span class="term">descriptors</span></dt><dd><p>
21   Table of descriptors preceding all function descriptors.
22   Examples include OTG and vendor-specific descriptors.
23      </p></dd><dt><span class="term">unbind</span></dt><dd><p>
24   Reverses <em class="parameter"><code>bind</code></em>; called as a side effect of unregistering the
25   driver which added this configuration.
26      </p></dd><dt><span class="term">setup</span></dt><dd><p>
27   Used to delegate control requests that aren't handled by standard
28   device infrastructure or directed at a specific interface.
29      </p></dd><dt><span class="term">bConfigurationValue</span></dt><dd><p>
30   Copied into configuration descriptor.
31      </p></dd><dt><span class="term">iConfiguration</span></dt><dd><p>
32   Copied into configuration descriptor.
33      </p></dd><dt><span class="term">bmAttributes</span></dt><dd><p>
34   Copied into configuration descriptor.
35      </p></dd><dt><span class="term">MaxPower</span></dt><dd><p>
36   Power consumtion in mA. Used to compute bMaxPower in the
37   configuration descriptor after considering the bus speed.
38      </p></dd><dt><span class="term">cdev</span></dt><dd><p>
39   assigned by @<code class="function">usb_add_config</code> before calling @<code class="function">bind</code>; this is
40   the device associated with this configuration.
41      </p></dd></dl></div></div><div class="refsect1"><a name="idp1124348948"></a><h2>Description</h2><p>
42   Configurations are building blocks for gadget drivers structured around
43   function drivers.  Simple USB gadgets require only one function and one
44   configuration, and handle dual-speed hardware by always providing the same
45   functionality.  Slightly more complex gadgets may have more than one
46   single-function configuration at a given speed; or have configurations
47   that only work at one speed.
48   </p><p>
49
50   Composite devices are, by definition, ones with configurations which
51   include more than one function.
52   </p><p>
53
54   The lifecycle of a usb_configuration includes allocation, initialization
55   of the fields described above, and calling @<code class="function">usb_add_config</code> to set up
56   internal data and bind it to a specific device.  The configuration's
57   @<code class="function">bind</code> method is then used to initialize all the functions and then
58   call @<code class="function">usb_add_function</code> for them.
59   </p><p>
60
61   Those functions would normally be independent of each other, but that's
62   not mandatory.  CDC WMC devices are an example where functions often
63   depend on other functions, with some functions subsidiary to others.
64   Such interdependency may be managed in any way, so long as all of the
65   descriptors complete by the time the composite driver returns from
66   its <code class="function">bind</code> routine.
67</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-struct-usb-function.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="composite.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-struct-usb-composite-driver.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">struct usb_function</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 class="phrase">struct usb_composite_driver</span></td></tr></table></div></body></html>
68