00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00035 #ifndef LIBUSBDEV_DRIVER_H_
00036 #define LIBUSBDEV_DRIVER_H_
00037
00038 #include <usb/dev/pipes.h>
00039
00041 typedef struct {
00043 usb_standard_device_descriptor_t device;
00045 uint8_t *configuration;
00046 size_t configuration_size;
00047 } usb_device_descriptors_t;
00048
00053 typedef struct {
00055 usb_standard_interface_descriptor_t *interface;
00057 uint8_t *nested_descriptors;
00059 size_t nested_descriptors_size;
00060 } usb_alternate_interface_descriptors_t;
00061
00063 typedef struct {
00065 usb_alternate_interface_descriptors_t *alternatives;
00067 size_t alternative_count;
00069 size_t current;
00070 } usb_alternate_interfaces_t;
00071
00073 typedef struct {
00075 usb_pipe_t ctrl_pipe;
00080 usb_endpoint_mapping_t *pipes;
00082 size_t pipes_count;
00087 int interface_no;
00088
00093 usb_alternate_interfaces_t *alternate_interfaces;
00094
00096 usb_device_descriptors_t descriptors;
00097
00099 ddf_dev_t *ddf_dev;
00104 void *driver_data;
00105
00109 usb_device_connection_t wire;
00110 } usb_device_t;
00111
00113 typedef struct {
00115 int (*add_device)(usb_device_t *);
00116 } usb_driver_ops_t;
00117
00119 typedef struct {
00124 const char *name;
00154 usb_endpoint_description_t **endpoints;
00156 usb_driver_ops_t *ops;
00157 } usb_driver_t;
00158
00159 int usb_driver_main(usb_driver_t *);
00160
00161 int usb_device_select_interface(usb_device_t *, uint8_t,
00162 usb_endpoint_description_t **);
00163
00164 int usb_device_retrieve_descriptors(usb_pipe_t *, usb_device_descriptors_t *);
00165 int usb_device_create_pipes(ddf_dev_t *, usb_device_connection_t *,
00166 usb_endpoint_description_t **, uint8_t *, size_t, int, int,
00167 usb_endpoint_mapping_t **, size_t *);
00168 int usb_device_destroy_pipes(ddf_dev_t *, usb_endpoint_mapping_t *, size_t);
00169 int usb_device_create(ddf_dev_t *, usb_endpoint_description_t **, usb_device_t **, const char **);
00170 void usb_device_destroy(usb_device_t *);
00171
00172 size_t usb_interface_count_alternates(uint8_t *, size_t, uint8_t);
00173 int usb_alternate_interfaces_create(uint8_t *, size_t, int,
00174 usb_alternate_interfaces_t **);
00175
00176 #endif
00177