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_REQUEST_H_
00036 #define LIBUSBDEV_REQUEST_H_
00037
00038 #include <sys/types.h>
00039 #include <l18n/langs.h>
00040 #include <usb/usb.h>
00041 #include <usb/dev/pipes.h>
00042 #include <usb/descriptor.h>
00043
00045 #define USB_DEVICE_STATUS_SELF_POWERED ((uint16_t)(1 << 0))
00046
00048 #define USB_DEVICE_STATUS_REMOTE_WAKEUP ((uint16_t)(1 << 1))
00049
00051 #define USB_ENDPOINT_STATUS_HALTED ((uint16_t)(1 << 0))
00052
00054 #define USB_FEATURE_SELECTOR_ENDPOINT_HALT (0)
00055
00057 #define USB_FEATURE_SELECTOR_REMOTE_WAKEUP (1)
00058
00060 typedef enum {
00061 USB_DEVREQ_GET_STATUS = 0,
00062 USB_DEVREQ_CLEAR_FEATURE = 1,
00063 USB_DEVREQ_SET_FEATURE = 3,
00064 USB_DEVREQ_SET_ADDRESS = 5,
00065 USB_DEVREQ_GET_DESCRIPTOR = 6,
00066 USB_DEVREQ_SET_DESCRIPTOR = 7,
00067 USB_DEVREQ_GET_CONFIGURATION = 8,
00068 USB_DEVREQ_SET_CONFIGURATION = 9,
00069 USB_DEVREQ_GET_INTERFACE = 10,
00070 USB_DEVREQ_SET_INTERFACE = 11,
00071 USB_DEVREQ_SYNCH_FRAME = 12,
00072 USB_DEVREQ_LAST_STD
00073 } usb_stddevreq_t;
00074
00078 typedef struct {
00083 uint8_t request_type;
00085 uint8_t request;
00087 union {
00088 uint16_t value;
00089
00090 struct {
00091 uint8_t value_low;
00092 uint8_t value_high;
00093 };
00094 };
00098 uint16_t index;
00100 uint16_t length;
00101 } __attribute__ ((packed)) usb_device_request_setup_packet_t;
00102
00103 int usb_control_request_set(usb_pipe_t *,
00104 usb_request_type_t, usb_request_recipient_t, uint8_t,
00105 uint16_t, uint16_t, void *, size_t);
00106
00107 int usb_control_request_get(usb_pipe_t *,
00108 usb_request_type_t, usb_request_recipient_t, uint8_t,
00109 uint16_t, uint16_t, void *, size_t, size_t *);
00110
00111 int usb_request_get_status(usb_pipe_t *, usb_request_recipient_t,
00112 uint16_t, uint16_t *);
00113 int usb_request_clear_feature(usb_pipe_t *, usb_request_type_t,
00114 usb_request_recipient_t, uint16_t, uint16_t);
00115 int usb_request_set_feature(usb_pipe_t *, usb_request_type_t,
00116 usb_request_recipient_t, uint16_t, uint16_t);
00117 int usb_request_set_address(usb_pipe_t *, usb_address_t);
00118 int usb_request_get_descriptor(usb_pipe_t *, usb_request_type_t,
00119 usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t,
00120 size_t *);
00121 int usb_request_get_descriptor_alloc(usb_pipe_t *, usb_request_type_t,
00122 usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void **, size_t *);
00123 int usb_request_get_device_descriptor(usb_pipe_t *,
00124 usb_standard_device_descriptor_t *);
00125 int usb_request_get_bare_configuration_descriptor(usb_pipe_t *, int,
00126 usb_standard_configuration_descriptor_t *);
00127 int usb_request_get_full_configuration_descriptor(usb_pipe_t *, int,
00128 void *, size_t, size_t *);
00129 int usb_request_get_full_configuration_descriptor_alloc(usb_pipe_t *,
00130 int, void **, size_t *);
00131 int usb_request_set_descriptor(usb_pipe_t *, usb_request_type_t,
00132 usb_request_recipient_t, uint8_t, uint8_t, uint16_t, void *, size_t);
00133 int usb_request_get_configuration(usb_pipe_t *, uint8_t *);
00134 int usb_request_set_configuration(usb_pipe_t *, uint8_t);
00135 int usb_request_get_interface(usb_pipe_t *, uint8_t, uint8_t *);
00136 int usb_request_set_interface(usb_pipe_t *, uint8_t, uint8_t);
00137
00138 int usb_request_get_supported_languages(usb_pipe_t *,
00139 l18_win_locales_t **, size_t *);
00140 int usb_request_get_string(usb_pipe_t *, size_t, l18_win_locales_t,
00141 char **);
00142
00143 int usb_request_clear_endpoint_halt(usb_pipe_t *, uint16_t);
00144 int usb_pipe_clear_halt(usb_pipe_t *, usb_pipe_t *);
00145 int usb_request_get_endpoint_status(usb_pipe_t *, usb_pipe_t *, uint16_t *);
00146
00147 #endif
00148