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