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_PIPES_H_
00036 #define LIBUSBDEV_PIPES_H_
00037
00038 #include <sys/types.h>
00039 #include <usb/usb.h>
00040 #include <usb/hc.h>
00041 #include <usb/descriptor.h>
00042 #include <ipc/devman.h>
00043 #include <ddf/driver.h>
00044 #include <fibril_synch.h>
00045
00050 typedef struct {
00052 devman_handle_t hc_handle;
00054 usb_address_t address;
00055 } usb_device_connection_t;
00056
00068 typedef struct {
00070 fibril_mutex_t guard;
00071
00073 usb_device_connection_t *wire;
00074
00076 usb_endpoint_t endpoint_no;
00077
00079 usb_transfer_type_t transfer_type;
00080
00082 usb_direction_t direction;
00083
00085 size_t max_packet_size;
00086
00094 int hc_phone;
00095
00097 fibril_mutex_t hc_phone_mutex;
00098
00100 int refcount;
00114 int refcount_soft;
00115
00119 bool auto_reset_halt;
00120 } usb_pipe_t;
00121
00122
00124 typedef struct {
00126 usb_transfer_type_t transfer_type;
00128 usb_direction_t direction;
00130 int interface_class;
00132 int interface_subclass;
00134 int interface_protocol;
00136 unsigned int flags;
00137 } usb_endpoint_description_t;
00138
00140 typedef struct {
00142 usb_pipe_t *pipe;
00144 const usb_endpoint_description_t *description;
00146 int interface_no;
00148 int interface_setting;
00150 usb_standard_endpoint_descriptor_t *descriptor;
00152 usb_standard_interface_descriptor_t *interface;
00154 bool present;
00155 } usb_endpoint_mapping_t;
00156
00157 int usb_device_connection_initialize_on_default_address(
00158 usb_device_connection_t *, usb_hc_connection_t *);
00159 int usb_device_connection_initialize_from_device(usb_device_connection_t *,
00160 ddf_dev_t *);
00161 int usb_device_connection_initialize(usb_device_connection_t *,
00162 devman_handle_t, usb_address_t);
00163
00164 int usb_device_get_assigned_interface(ddf_dev_t *);
00165
00166 int usb_pipe_initialize(usb_pipe_t *, usb_device_connection_t *,
00167 usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t);
00168 int usb_pipe_initialize_default_control(usb_pipe_t *,
00169 usb_device_connection_t *);
00170 int usb_pipe_probe_default_control(usb_pipe_t *);
00171 int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
00172 size_t, uint8_t *, size_t, usb_device_connection_t *);
00173 int usb_pipe_register_with_speed(usb_pipe_t *, usb_speed_t,
00174 unsigned int, usb_hc_connection_t *);
00175 int usb_pipe_register(usb_pipe_t *, unsigned int, usb_hc_connection_t *);
00176 int usb_pipe_unregister(usb_pipe_t *, usb_hc_connection_t *);
00177
00178 void usb_pipe_start_long_transfer(usb_pipe_t *);
00179 void usb_pipe_end_long_transfer(usb_pipe_t *);
00180
00181 int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
00182 int usb_pipe_write(usb_pipe_t *, void *, size_t);
00183
00184 int usb_pipe_control_read(usb_pipe_t *, void *, size_t,
00185 void *, size_t, size_t *);
00186 int usb_pipe_control_write(usb_pipe_t *, void *, size_t,
00187 void *, size_t);
00188
00189 #endif
00190