1STRUCT USB_CONFIGURA(9) Kernel Mode Gadget API STRUCT USB_CONFIGURA(9)
2
3
4
6 struct_usb_configuration - represents one gadget configuration
7
9 struct usb_configuration {
10 const char * label;
11 struct usb_gadget_strings ** strings;
12 const struct usb_descriptor_header ** descriptors;
13 void (* unbind) (struct usb_configuration *);
14 int (* setup) (struct usb_configuration *,const struct usb_ctrlrequest *);
15 u8 bConfigurationValue;
16 u8 iConfiguration;
17 u8 bmAttributes;
18 u16 MaxPower;
19 struct usb_composite_dev * cdev;
20 };
21
23 label
24 For diagnostics, describes the configuration.
25
26 strings
27 Tables of strings, keyed by identifiers assigned during bind() and
28 by language IDs provided in control requests.
29
30 descriptors
31 Table of descriptors preceding all function descriptors. Examples
32 include OTG and vendor-specific descriptors.
33
34 unbind
35 Reverses bind; called as a side effect of unregistering the driver
36 which added this configuration.
37
38 setup
39 Used to delegate control requests that aren't handled by standard
40 device infrastructure or directed at a specific interface.
41
42 bConfigurationValue
43 Copied into configuration descriptor.
44
45 iConfiguration
46 Copied into configuration descriptor.
47
48 bmAttributes
49 Copied into configuration descriptor.
50
51 MaxPower
52 Power consumtion in mA. Used to compute bMaxPower in the
53 configuration descriptor after considering the bus speed.
54
55 cdev
56 assigned by usb_add_config() before calling bind(); this is the
57 device associated with this configuration.
58
60 Configurations are building blocks for gadget drivers structured around
61 function drivers. Simple USB gadgets require only one function and one
62 configuration, and handle dual-speed hardware by always providing the
63 same functionality. Slightly more complex gadgets may have more than
64 one single-function configuration at a given speed; or have
65 configurations that only work at one speed.
66
67 Composite devices are, by definition, ones with configurations which
68 include more than one function.
69
70 The lifecycle of a usb_configuration includes allocation,
71 initialization of the fields described above, and calling
72 usb_add_config() to set up internal data and bind it to a specific
73 device. The configuration's bind() method is then used to initialize
74 all the functions and then call usb_add_function() for them.
75
76 Those functions would normally be independent of each other, but that's
77 not mandatory. CDC WMC devices are an example where functions often
78 depend on other functions, with some functions subsidiary to others.
79 Such interdependency may be managed in any way, so long as all of the
80 descriptors complete by the time the composite driver returns from its
81 bind routine.
82
84 David Brownell <dbrownell@users.sourceforge.net>
85 Author.
86
88Kernel Hackers Manual 3.10 June 2019 STRUCT USB_CONFIGURA(9)