STRUCT USB_CONFIGURA(9) Kernel Mode Gadget API STRUCT USB_CONFIGURA(9)NAME
struct_usb_configuration - represents one gadget configuration
SYNOPSIS
struct usb_configuration {
const char * label;
struct usb_gadget_strings ** strings;
const struct usb_descriptor_header ** descriptors;
int (* bind) (struct usb_configuration *);
void (* unbind) (struct usb_configuration *);
int (* setup) (struct usb_configuration *,const struct usb_ctrlrequest *);
u8 bConfigurationValue;
u8 iConfiguration;
u8 bmAttributes;
u8 bMaxPower;
struct usb_composite_dev * cdev;
};
MEMBERS
label
For diagnostics, describes the configuration.
strings
Tables of strings, keyed by identifiers assigned during bind() and by language IDs provided in control requests.
descriptors
Table of descriptors preceding all function descriptors. Examples include OTG and vendor-specific descriptors.
bind
Called from usb_add_config() to allocate resources unique to this configuration and to call usb_add_function() for each function used.
unbind
Reverses bind; called as a side effect of unregistering the driver which added this configuration.
setup
Used to delegate control requests that aren't handled by standard device infrastructure or directed at a specific interface.
bConfigurationValue
Copied into configuration descriptor.
iConfiguration
Copied into configuration descriptor.
bmAttributes
Copied into configuration descriptor.
bMaxPower
Copied into configuration descriptor.
cdev
assigned by usb_add_config() before calling bind(); this is the device associated with this configuration.
DESCRIPTION
Configurations are building blocks for gadget drivers structured around function drivers. Simple USB gadgets require only one function and
one configuration, and handle dual-speed hardware by always providing the same functionality. Slightly more complex gadgets may have more
than one single-function configuration at a given speed; or have configurations that only work at one speed.
Composite devices are, by definition, ones with configurations which include more than one function.
The lifecycle of a usb_configuration includes allocation, initialization of the fields described above, and calling usb_add_config() to set
up internal data and bind it to a specific device. The configuration's bind() method is then used to initialize all the functions and then
call usb_add_function() for them.
Those functions would normally be independant of each other, but that's not mandatory. CDC WMC devices are an example where functions often
depend on other functions, with some functions subsidiary to others. Such interdependency may be managed in any way, so long as all of the
descriptors complete by the time the composite driver returns from its bind routine.
AUTHOR
David Brownell <dbrownell@users.sourceforge.net>
Author.
COPYRIGHT Kernel Hackers Manual 2.6. July 2010 STRUCT USB_CONFIGURA(9)
Check Out this Related Man Page
STRUCT USB_FUNCTION(9) Kernel Mode Gadget API STRUCT USB_FUNCTION(9)NAME
struct_usb_function - describes one function of a configuration
SYNOPSIS
struct usb_function {
const char * name;
struct usb_gadget_strings ** strings;
struct usb_descriptor_header ** fs_descriptors;
struct usb_descriptor_header ** hs_descriptors;
struct usb_descriptor_header ** ss_descriptors;
struct usb_configuration * config;
int (* bind) (struct usb_configuration *,struct usb_function *);
void (* unbind) (struct usb_configuration *,struct usb_function *);
void (* free_func) (struct usb_function *f);
struct module * mod;
int (* set_alt) (struct usb_function *,unsigned interface, unsigned alt);
int (* get_alt) (struct usb_function *,unsigned interface);
void (* disable) (struct usb_function *);
int (* setup) (struct usb_function *,const struct usb_ctrlrequest *);
void (* suspend) (struct usb_function *);
void (* resume) (struct usb_function *);
int (* get_status) (struct usb_function *);
int (* func_suspend) (struct usb_function *,u8 suspend_opt);
};
MEMBERS
name
For diagnostics, identifies the function.
strings
tables of strings, keyed by identifiers assigned during bind and by language IDs provided in control requests
fs_descriptors
Table of full (or low) speed descriptors, using interface and string identifiers assigned during bind(). If this pointer is null, the
function will not be available at full speed (or at low speed).
hs_descriptors
Table of high speed descriptors, using interface and string identifiers assigned during bind(). If this pointer is null, the function
will not be available at high speed.
ss_descriptors
Table of super speed descriptors, using interface and string identifiers assigned during bind(). If this pointer is null after
initiation, the function will not be available at super speed.
config
assigned when usb_add_function() is called; this is the configuration with which this function is associated.
bind
Before the gadget can register, all of its functions bind to the available resources including string and interface identifiers used in
interface or class descriptors; endpoints; I/O buffers; and so on.
unbind
Reverses bind; called as a side effect of unregistering the driver which added this function.
free_func
free the struct usb_function.
mod
(internal) points to the module that created this structure.
set_alt
(REQUIRED) Reconfigures altsettings; function drivers may initialize usb_ep.driver data at this time (when it is used). Note that
setting an interface to its current altsetting resets interface state, and that all interfaces have a disabled state.
get_alt
Returns the active altsetting. If this is not provided, then only altsetting zero is supported.
disable
(REQUIRED) Indicates the function should be disabled. Reasons include host resetting or reconfiguring the gadget, and disconnection.
setup
Used for interface-specific control requests.
suspend
Notifies functions when the host stops sending USB traffic.
resume
Notifies functions when the host restarts USB traffic.
get_status
Returns function status as a reply to GetStatus request when the recepient is Interface.
func_suspend
callback to be called when SetFeature(FUNCTION_SUSPEND) is reseived
DESCRIPTION
A single USB function uses one or more interfaces, and should in most cases support operation at both full and high speeds. Each function
is associated by usb_add_function() with a one configuration; that function causes bind() to be called so resources can be allocated as
part of setting up a gadget driver. Those resources include endpoints, which should be allocated using usb_ep_autoconfig().
To support dual speed operation, a function driver provides descriptors for both high and full speed operation. Except in rare cases that
don't involve bulk endpoints, each speed needs different endpoint descriptors.
Function drivers choose their own strategies for managing instance data. The simplest strategy just declares it "static', which means the
function can only be activated once. If the function needs to be exposed in more than one configuration at a given speed, it needs to
support multiple usb_function structures (one for each configuration).
A more complex strategy might encapsulate a usb_function structure inside a driver-specific instance structure to allows multiple
activations. An example of multiple activations might be a CDC ACM function that supports two or more distinct instances within the same
configuration, providing several independent logical data links to a USB host.
AUTHOR
David Brownell <dbrownell@users.sourceforge.net>
Author.
COPYRIGHT Kernel Hackers Manual 3.10 June 2014 STRUCT USB_FUNCTION(9)