summaryrefslogtreecommitdiff
path: root/firmware/usbstack/usb_class_driver.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/usbstack/usb_class_driver.h')
-rw-r--r--firmware/usbstack/usb_class_driver.h52
1 files changed, 38 insertions, 14 deletions
diff --git a/firmware/usbstack/usb_class_driver.h b/firmware/usbstack/usb_class_driver.h
index 8bd9de0119..df21228480 100644
--- a/firmware/usbstack/usb_class_driver.h
+++ b/firmware/usbstack/usb_class_driver.h
@@ -23,41 +23,65 @@
23/* Common api, implemented by all class drivers */ 23/* Common api, implemented by all class drivers */
24 24
25struct usb_class_driver { 25struct usb_class_driver {
26 /* First some runtime data */
26 bool enabled; 27 bool enabled;
28 int first_interface;
29 int last_interface;
30
31 /* Driver api starts here */
32
33 /* Set this to true if the driver needs exclusive disk access (e.g. usb storage) */
27 bool needs_exclusive_ata; 34 bool needs_exclusive_ata;
28 int usb_endpoint; 35
29 int usb_interface; 36 /* Tells the driver what its first interface number will be. The driver
37 returns the number of the first available interface for the next driver
38 (i.e. a driver with one interface will return interface+1)
39 A driver must have at least one interface
40 Mandatory function */
41 int (*set_first_interface)(int interface);
42
43 /* Tells the driver what its first endpoint pair number will be. The driver
44 returns the number of the first available endpoint pair for the next
45 driver (i.e. a driver with one endpoint pair will return endpoint +1)
46 Mandatory function */
47 int (*set_first_endpoint)(int endpoint);
30 48
31 /* Asks the driver to put the interface descriptor and all other 49 /* Asks the driver to put the interface descriptor and all other
32 needed descriptor for this driver at dest, for the given settings. 50 needed descriptor for this driver at dest.
33 Returns the number of bytes taken by these descriptors. */ 51 Returns the number of bytes taken by these descriptors.
34 int (*get_config_descriptor)(unsigned char *dest, 52 Mandatory function */
35 int max_packet_size, int interface_number, int endpoint); 53 int (*get_config_descriptor)(unsigned char *dest, int max_packet_size);
36 54
37 /* Tells the driver that a usb connection has been set up and is now 55 /* Tells the driver that a usb connection has been set up and is now
38 ready to use. */ 56 ready to use.
39 void (*init_connection)(int interface,int endpoint); 57 Optional function */
58 void (*init_connection)(void);
40 59
41 /* Initialises the driver. This can be called multiple times, 60 /* Initialises the driver. This can be called multiple times,
42 and should not perform any action that can disturb other threads 61 and should not perform any action that can disturb other threads
43 (like getting the audio buffer) */ 62 (like getting the audio buffer)
63 Optional function */
44 void (*init)(void); 64 void (*init)(void);
45 65
46 /* Tells the driver that the usb connection is no longer active */ 66 /* Tells the driver that the usb connection is no longer active
67 Optional function */
47 void (*disconnect)(void); 68 void (*disconnect)(void);
48 69
49 /* Tells the driver that a usb transfer has been completed. Note that "in" 70 /* Tells the driver that a usb transfer has been completed. Note that "in"
50 is relative to the host */ 71 is relative to the host
51 void (*transfer_complete)(bool in, int status, int length); 72 Optional function */
73 void (*transfer_complete)(int ep,bool in, int status, int length);
52 74
53 /* Tells the driver that a control request has come in. If the driver is 75 /* Tells the driver that a control request has come in. If the driver is
54 able to handle it, it should ack the request, and return true. Otherwise 76 able to handle it, it should ack the request, and return true. Otherwise
55 it should return false. */ 77 it should return false.
78 Optional function */
56 bool (*control_request)(struct usb_ctrlrequest* req); 79 bool (*control_request)(struct usb_ctrlrequest* req);
57 80
58#ifdef HAVE_HOTSWAP 81#ifdef HAVE_HOTSWAP
59 /* Tells the driver that a hotswappable disk/card was inserted or 82 /* Tells the driver that a hotswappable disk/card was inserted or
60 extracted */ 83 extracted
84 Optional function */
61 void (*notify_hotswap)(int volume, bool inserted); 85 void (*notify_hotswap)(int volume, bool inserted);
62#endif 86#endif
63}; 87};