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_descriptor_header ** ssp_descriptors;
struct usb_configuration * config;
struct usb_os_desc_table * os_desc_table;
unsigned os_desc_n;
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 *);
bool (* req_match) (struct usb_function *,const struct usb_ctrlrequest *,bool config0);
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¶
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_descriptor_header ** ssp_descriptors
struct usb_configuration * config
struct usb_os_desc_table * os_desc_table
unsigned os_desc_n
int (*)(struct usb_configuration *,struct usb_function *) bind
void (*)(struct usb_configuration *,struct usb_function *) unbind
void (*)(struct usb_function *f) free_func
struct module * mod
int (*)(struct usb_function *,unsigned interface, unsigned alt) set_alt
int (*)(struct usb_function *,unsigned interface) get_alt
void (*)(struct usb_function *) disable
int (*)(struct usb_function *,const struct usb_ctrlrequest *) setup
bool (*)(struct usb_function *,const struct usb_ctrlrequest *,bool config0) req_match
void (*)(struct usb_function *) suspend
void (*)(struct usb_function *) resume
int (*)(struct usb_function *) get_status
int (*)(struct usb_function *,u8 suspend_opt) func_suspend
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>
COPYRIGHT¶
June 2017 | Kernel Hackers Manual 4.11 |