Changeset ae3a941 in mainline for uspace/lib
- Timestamp:
- 2018-02-26T16:51:40Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e773f58
- Parents:
- 3692678
- Location:
- uspace/lib
- Files:
-
- 25 edited
-
drv/generic/remote_usb.c (modified) (2 diffs)
-
drv/generic/remote_usbdiag.c (modified) (9 diffs)
-
drv/include/usb_iface.h (modified) (1 diff)
-
drv/include/usbdiag_iface.h (modified) (1 diff)
-
usb/include/usb/classes/hub.h (modified) (2 diffs)
-
usb/include/usb/descriptor.h (modified) (8 diffs)
-
usb/include/usb/port.h (modified) (1 diff)
-
usb/include/usb/usb.h (modified) (3 diffs)
-
usbdev/include/usb/dev/device.h (modified) (3 diffs)
-
usbdev/include/usb/dev/pipes.h (modified) (2 diffs)
-
usbdev/include/usb/dev/poll.h (modified) (4 diffs)
-
usbdev/src/dp.c (modified) (2 diffs)
-
usbdev/src/pipes.c (modified) (5 diffs)
-
usbhid/src/hidparser.c (modified) (29 diffs)
-
usbhid/src/hidpath.c (modified) (20 diffs)
-
usbhid/src/hidreport.c (modified) (2 diffs)
-
usbhid/src/hidreq.c (modified) (15 diffs)
-
usbhost/include/usb/host/bus.h (modified) (1 diff)
-
usbhost/include/usb/host/endpoint.h (modified) (2 diffs)
-
usbhost/include/usb/host/hcd.h (modified) (2 diffs)
-
usbhost/include/usb/host/usb2_bus.h (modified) (1 diff)
-
usbhost/src/bandwidth.c (modified) (2 diffs)
-
usbhost/src/hcd.c (modified) (4 diffs)
-
usbvirt/src/ipc_hc.c (modified) (4 diffs)
-
usbvirt/src/transfer.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usb.c
r3692678 rae3a941 52 52 usb_dev_session_t *usb_dev_connect_to_self(ddf_dev_t *dev) 53 53 { 54 return devman_parent_device_connect(ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING); 54 return devman_parent_device_connect(ddf_dev_get_handle(dev), 55 IPC_FLAG_BLOCKING); 55 56 } 56 57 … … 90 91 } 91 92 92 static void remote_usb_get_my_description(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 93 static void remote_usb_get_my_description(ddf_fun_t *, void *, 94 ipc_callid_t, ipc_call_t *); 93 95 94 96 /** Remote USB interface operations. */ -
uspace/lib/drv/generic/remote_usbdiag.c
r3692678 rae3a941 58 58 } 59 59 60 errno_t usbdiag_test_in(async_exch_t *exch, const usbdiag_test_params_t *params, usbdiag_test_results_t *results) 60 errno_t usbdiag_test_in(async_exch_t *exch, 61 const usbdiag_test_params_t *params, usbdiag_test_results_t *results) 61 62 { 62 63 if (!exch) … … 64 65 65 66 ipc_call_t answer; 66 aid_t req = async_send_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_TEST_IN, &answer); 67 68 errno_t rc = async_data_write_start(exch, params, sizeof(usbdiag_test_params_t)); 69 if (rc != EOK) { 70 async_exchange_end(exch); 71 async_forget(req); 72 return rc; 73 } 74 75 rc = async_data_read_start(exch, results, sizeof(usbdiag_test_results_t)); 67 aid_t req = async_send_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), 68 IPC_M_USBDIAG_TEST_IN, &answer); 69 70 errno_t rc = async_data_write_start(exch, params, 71 sizeof(usbdiag_test_params_t)); 72 if (rc != EOK) { 73 async_exchange_end(exch); 74 async_forget(req); 75 return rc; 76 } 77 78 rc = async_data_read_start(exch, results, 79 sizeof(usbdiag_test_results_t)); 76 80 if (rc != EOK) { 77 81 async_exchange_end(exch); … … 88 92 } 89 93 90 errno_t usbdiag_test_out(async_exch_t *exch, const usbdiag_test_params_t *params, usbdiag_test_results_t *results) 94 errno_t usbdiag_test_out(async_exch_t *exch, 95 const usbdiag_test_params_t *params, usbdiag_test_results_t *results) 91 96 { 92 97 if (!exch) … … 94 99 95 100 ipc_call_t answer; 96 aid_t req = async_send_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_TEST_OUT, &answer); 97 98 errno_t rc = async_data_write_start(exch, params, sizeof(usbdiag_test_params_t)); 99 if (rc != EOK) { 100 async_exchange_end(exch); 101 async_forget(req); 102 return rc; 103 } 104 105 rc = async_data_read_start(exch, results, sizeof(usbdiag_test_results_t)); 101 aid_t req = async_send_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), 102 IPC_M_USBDIAG_TEST_OUT, &answer); 103 104 errno_t rc = async_data_write_start(exch, params, 105 sizeof(usbdiag_test_params_t)); 106 if (rc != EOK) { 107 async_exchange_end(exch); 108 async_forget(req); 109 return rc; 110 } 111 112 rc = async_data_read_start(exch, results, 113 sizeof(usbdiag_test_results_t)); 106 114 if (rc != EOK) { 107 115 async_exchange_end(exch); … … 118 126 } 119 127 120 static void remote_usbdiag_test_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 121 static void remote_usbdiag_test_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 128 static void remote_usbdiag_test_in(ddf_fun_t *, void *, 129 ipc_callid_t, ipc_call_t *); 130 static void remote_usbdiag_test_out(ddf_fun_t *, void *, 131 ipc_callid_t, ipc_call_t *); 122 132 123 133 /** Remote USB diagnostic interface operations. */ … … 133 143 }; 134 144 135 void remote_usbdiag_test_in(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call) 145 void remote_usbdiag_test_in(ddf_fun_t *fun, void *iface, 146 ipc_callid_t callid, ipc_call_t *call) 136 147 { 137 148 const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface; … … 158 169 159 170 usbdiag_test_results_t results; 160 const errno_t ret = !diag_iface->test_in ? ENOTSUP : diag_iface->test_in(fun, ¶ms, &results); 171 const errno_t ret = !diag_iface->test_in ? ENOTSUP 172 : diag_iface->test_in(fun, ¶ms, &results); 161 173 162 174 if (ret != EOK) { … … 185 197 } 186 198 187 void remote_usbdiag_test_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call) 199 void remote_usbdiag_test_out(ddf_fun_t *fun, void *iface, 200 ipc_callid_t callid, ipc_call_t *call) 188 201 { 189 202 const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface; … … 210 223 211 224 usbdiag_test_results_t results; 212 const errno_t ret = !diag_iface->test_out ? ENOTSUP : diag_iface->test_out(fun, ¶ms, &results); 225 const errno_t ret = !diag_iface->test_out ? ENOTSUP 226 : diag_iface->test_out(fun, ¶ms, &results); 213 227 214 228 if (ret != EOK) { -
uspace/lib/drv/include/usb_iface.h
r3692678 rae3a941 46 46 47 47 typedef struct { 48 usb_address_t address; /** Current USB address */ 49 uint8_t depth; /** Depth in the hub hiearchy */ 50 usb_speed_t speed; /** Speed of the device */ 51 devman_handle_t handle; /** Handle to DDF function of the HC driver */ 52 int iface; /** Interface set by multi interface driver, -1 if none */ 48 usb_address_t address; /**< Current USB address */ 49 uint8_t depth; /**< Depth in the hub hiearchy */ 50 usb_speed_t speed; /**< Speed of the device */ 51 devman_handle_t handle; /**< Handle to DDF function of the HC driver */ 52 /** Interface set by multi interface driver, -1 if none */ 53 int iface; 53 54 } usb_device_desc_t; 54 55 -
uspace/lib/drv/include/usbdiag_iface.h
r3692678 rae3a941 63 63 64 64 async_sess_t *usbdiag_connect(devman_handle_t); 65 void usbdiag_disconnect(async_sess_t *);65 void usbdiag_disconnect(async_sess_t *); 66 66 67 errno_t usbdiag_test_in(async_exch_t*, const usbdiag_test_params_t *, usbdiag_test_results_t *); 68 errno_t usbdiag_test_out(async_exch_t*, const usbdiag_test_params_t *, usbdiag_test_results_t *); 67 errno_t usbdiag_test_in(async_exch_t *, 68 const usbdiag_test_params_t *, usbdiag_test_results_t *); 69 errno_t usbdiag_test_out(async_exch_t*, 70 const usbdiag_test_params_t *, usbdiag_test_results_t *); 69 71 70 72 /** USB diagnostic device communication interface. */ 71 73 typedef struct { 72 errno_t (*test_in)(ddf_fun_t*, const usbdiag_test_params_t *, usbdiag_test_results_t *); 73 errno_t (*test_out)(ddf_fun_t*, const usbdiag_test_params_t *, usbdiag_test_results_t *); 74 errno_t (*test_in)(ddf_fun_t *, 75 const usbdiag_test_params_t *, usbdiag_test_results_t *); 76 errno_t (*test_out)(ddf_fun_t*, 77 const usbdiag_test_params_t *, usbdiag_test_results_t *); 74 78 } usbdiag_iface_t; 75 79 -
uspace/lib/usb/include/usb/classes/hub.h
r3692678 rae3a941 178 178 */ 179 179 uint8_t max_current; 180 } __attribute__ ((packed)) usb_hub_descriptor_header_t;180 } __attribute__((packed)) usb_hub_descriptor_header_t; 181 181 182 182 /** One bit for the device and one bit for every port */ … … 187 187 */ 188 188 typedef enum { 189 /** This request resets a value reported in the hub status. */190 USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20,191 /** This request resets a value reported in the port status. */192 USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23,193 /**194 * This is an optional per-port diagnostic request that returns the bus195 * state value, as sampled at the last EOF2 point.196 */197 USB_HUB_REQ_TYPE_GET_STATE = 0xA3,198 /** This request returns the hub descriptor. */199 USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,200 /**201 * This request returns the current hub status and the states that have202 * changed since the previous acknowledgment.203 */204 USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0,205 /**206 * This request returns the current port status and the current value of the207 * port status change bits.208 */209 USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3,210 /** This request overwrites the hub descriptor. */211 USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20,212 /** This request sets a value reported in the hub status. */213 USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,214 /**215 * This request sets the value that the hub uses to determine the index216 * into the Route String Index for the hub.217 */218 USB_HUB_REQ_TYPE_SET_HUB_DEPTH = 0x20,219 /** This request sets a value reported in the port status. */220 USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23,189 /** This request resets a value reported in the hub status. */ 190 USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20, 191 /** This request resets a value reported in the port status. */ 192 USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23, 193 /** 194 * This is an optional per-port diagnostic request that returns the bus 195 * state value, as sampled at the last EOF2 point. 196 */ 197 USB_HUB_REQ_TYPE_GET_STATE = 0xA3, 198 /** This request returns the hub descriptor. */ 199 USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0, 200 /** 201 * This request returns the current hub status and the states that have 202 * changed since the previous acknowledgment. 203 */ 204 USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0, 205 /** 206 * This request returns the current port status and the current value of the 207 * port status change bits. 208 */ 209 USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3, 210 /** This request overwrites the hub descriptor. */ 211 USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20, 212 /** This request sets a value reported in the hub status. */ 213 USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20, 214 /** 215 * This request sets the value that the hub uses to determine the index 216 * into the Route String Index for the hub. 217 */ 218 USB_HUB_REQ_TYPE_SET_HUB_DEPTH = 0x20, 219 /** This request sets a value reported in the port status. */ 220 USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23, 221 221 } usb_hub_bm_request_type_t; 222 222 223 /** @brief hub class request codes*/ 224 /// \TODO these are duplicit to standart descriptors 223 /** 224 * @brief hub class request codes 225 */ 225 226 typedef enum { 226 /** */ 227 USB_HUB_REQUEST_GET_STATUS = 0, 228 /** */ 229 USB_HUB_REQUEST_CLEAR_FEATURE = 1, 230 /** USB 1.0 only */ 231 USB_HUB_REQUEST_GET_STATE = 2, 232 /** */ 233 USB_HUB_REQUEST_SET_FEATURE = 3, 234 /** */ 235 USB_HUB_REQUEST_GET_DESCRIPTOR = 6, 236 /** */ 237 USB_HUB_REQUEST_SET_DESCRIPTOR = 7, 238 /** */ 239 USB_HUB_REQUEST_CLEAR_TT_BUFFER = 8, 240 /** */ 241 USB_HUB_REQUEST_RESET_TT = 9, 242 /** */ 243 USB_HUB_GET_TT_STATE = 10, 244 /** */ 245 USB_HUB_STOP_TT = 11, 246 /** USB 3+ only */ 247 USB_HUB_REQUEST_SET_HUB_DEPTH = 12, 227 USB_HUB_REQUEST_GET_STATUS = 0, 228 USB_HUB_REQUEST_CLEAR_FEATURE = 1, 229 /** USB 1.0 only */ 230 USB_HUB_REQUEST_GET_STATE = 2, 231 USB_HUB_REQUEST_SET_FEATURE = 3, 232 USB_HUB_REQUEST_GET_DESCRIPTOR = 6, 233 USB_HUB_REQUEST_SET_DESCRIPTOR = 7, 234 USB_HUB_REQUEST_CLEAR_TT_BUFFER = 8, 235 USB_HUB_REQUEST_RESET_TT = 9, 236 USB_HUB_GET_TT_STATE = 10, 237 USB_HUB_STOP_TT = 11, 238 /** USB 3+ only */ 239 USB_HUB_REQUEST_SET_HUB_DEPTH = 12, 248 240 } usb_hub_request_t; 249 241 -
uspace/lib/usb/include/usb/descriptor.h
r3692678 rae3a941 101 101 /** Number of possible configurations. */ 102 102 uint8_t configuration_count; 103 } __attribute__ ((packed)) usb_standard_device_descriptor_t;103 } __attribute__((packed)) usb_standard_device_descriptor_t; 104 104 105 105 /** USB device qualifier decriptor is basically a cut down version of the device … … 129 129 uint8_t configuration_count; 130 130 uint8_t reserved; 131 } __attribute__ ((packed)) usb_standard_device_qualifier_descriptor_t;131 } __attribute__((packed)) usb_standard_device_qualifier_descriptor_t; 132 132 133 133 /** Standard USB configuration descriptor. … … 156 156 */ 157 157 uint8_t max_power; 158 } __attribute__ ((packed)) usb_standard_configuration_descriptor_t;158 } __attribute__((packed)) usb_standard_configuration_descriptor_t; 159 159 160 160 /** USB Other Speed Configuration descriptor shows values that would change … … 191 191 /** String descriptor describing this interface. */ 192 192 uint8_t str_interface; 193 } __attribute__ ((packed)) usb_standard_interface_descriptor_t;193 } __attribute__((packed)) usb_standard_interface_descriptor_t; 194 194 195 195 /** Standard USB endpoint descriptor. … … 223 223 */ 224 224 uint8_t poll_interval; 225 } __attribute__ ((packed)) usb_standard_endpoint_descriptor_t;225 } __attribute__((packed)) usb_standard_endpoint_descriptor_t; 226 226 227 227 /** Superspeed USB endpoint companion descriptor. … … 254 254 */ 255 255 uint16_t bytes_per_interval; 256 } __attribute__ ((packed)) usb_superspeed_endpoint_companion_descriptor_t;256 } __attribute__((packed)) usb_superspeed_endpoint_companion_descriptor_t; 257 257 258 258 /** Part of standard USB HID descriptor specifying one class descriptor. … … 265 265 /** Length of class-specific descriptor in bytes. */ 266 266 uint16_t length; 267 } __attribute__ ((packed)) usb_standard_hid_class_descriptor_info_t;267 } __attribute__((packed)) usb_standard_hid_class_descriptor_info_t; 268 268 269 269 /** Standard USB HID descriptor. … … 296 296 /** First mandatory class descriptor (Report) info. */ 297 297 usb_standard_hid_class_descriptor_info_t report_desc_info; 298 } __attribute__ ((packed)) usb_standard_hid_descriptor_t;298 } __attribute__((packed)) usb_standard_hid_descriptor_t; 299 299 300 300 #endif -
uspace/lib/usb/include/usb/port.h
r3692678 rae3a941 90 90 91 91 /* And these are to be called from the connected handler. */ 92 int usb_port_condvar_wait_timeout(usb_port_t *port, fibril_condvar_t *, suseconds_t); 92 int usb_port_condvar_wait_timeout(usb_port_t *port, 93 fibril_condvar_t *, suseconds_t); 93 94 94 95 /** -
uspace/lib/usb/include/usb/usb.h
r3692678 rae3a941 54 54 #define uint32_usb2host(n) uint32_t_le2host((n)) 55 55 56 const char * usb_str_transfer_type(usb_transfer_type_tt);57 const char * usb_str_transfer_type_short(usb_transfer_type_tt);56 const char *usb_str_transfer_type(usb_transfer_type_t); 57 const char *usb_str_transfer_type_short(usb_transfer_type_t); 58 58 59 59 const char *usb_str_direction(usb_direction_t); … … 149 149 static inline bool usb_target_same(usb_target_t a, usb_target_t b) 150 150 { 151 return (a.address == b.address) 152 && (a.endpoint == b.endpoint); 151 return (a.address == b.address) && (a.endpoint == b.endpoint); 153 152 } 154 153 … … 167 166 USB_PID_SETUP = _MAKE_PID(3, 1), 168 167 169 USB_PID_DATA0 = _MAKE_PID(0 ,3),170 USB_PID_DATA1 = _MAKE_PID(2 ,3),168 USB_PID_DATA0 = _MAKE_PID(0, 3), 169 USB_PID_DATA1 = _MAKE_PID(2, 3), 171 170 172 USB_PID_ACK = _MAKE_PID(0 ,2),173 USB_PID_NAK = _MAKE_PID(2 ,2),174 USB_PID_STALL = _MAKE_PID(3 ,2),171 USB_PID_ACK = _MAKE_PID(0, 2), 172 USB_PID_NAK = _MAKE_PID(2, 2), 173 USB_PID_STALL = _MAKE_PID(3, 2), 175 174 176 USB_PID_PRE = _MAKE_PID(3 ,0),175 USB_PID_PRE = _MAKE_PID(3, 0), 177 176 /* USB_PID_ = _MAKE_PID( ,), */ 178 177 #undef _MAKE_PID -
uspace/lib/usbdev/include/usb/dev/device.h
r3692678 rae3a941 59 59 60 60 /* DDF parts */ 61 errno_t usb_device_create_ddf(ddf_dev_t *, const usb_endpoint_description_t **, const char **); 61 errno_t usb_device_create_ddf(ddf_dev_t *, 62 const usb_endpoint_description_t **, const char **); 62 63 void usb_device_destroy_ddf(ddf_dev_t *); 63 64 … … 68 69 } 69 70 70 usb_device_t * usb_device_create(devman_handle_t);71 usb_device_t *usb_device_create(devman_handle_t); 71 72 void usb_device_destroy(usb_device_t *); 72 73 73 const char * usb_device_get_name(usb_device_t *);74 const char *usb_device_get_name(usb_device_t *); 74 75 ddf_fun_t *usb_device_ddf_fun_create(usb_device_t *, fun_type_t, const char *); 75 76 76 async_exch_t * usb_device_bus_exchange_begin(usb_device_t *);77 async_exch_t *usb_device_bus_exchange_begin(usb_device_t *); 77 78 void usb_device_bus_exchange_end(async_exch_t *); 78 79 … … 95 96 devman_handle_t usb_device_get_devman_handle(const usb_device_t *); 96 97 97 const usb_device_descriptors_t * usb_device_descriptors(usb_device_t *);98 const usb_device_descriptors_t *usb_device_descriptors(usb_device_t *); 98 99 99 const usb_alternate_interfaces_t * usb_device_get_alternative_ifaces(100 const usb_alternate_interfaces_t *usb_device_get_alternative_ifaces( 100 101 usb_device_t *); 101 102 102 void * usb_device_data_alloc(usb_device_t *, size_t);103 void * usb_device_data_get(usb_device_t *);103 void *usb_device_data_alloc(usb_device_t *, size_t); 104 void *usb_device_data_get(usb_device_t *); 104 105 105 106 #endif -
uspace/lib/usbdev/include/usb/dev/pipes.h
r3692678 rae3a941 92 92 const usb_standard_endpoint_descriptor_t *descriptor; 93 93 /** Relevant superspeed companion descriptor. */ 94 const usb_superspeed_endpoint_companion_descriptor_t *companion_descriptor; 94 const usb_superspeed_endpoint_companion_descriptor_t 95 *companion_descriptor; 95 96 /** Interface descriptor the endpoint belongs to. */ 96 97 const usb_standard_interface_descriptor_t *interface; … … 105 106 size_t, const uint8_t *, size_t, usb_dev_session_t *); 106 107 107 errno_t usb_pipe_register(usb_pipe_t *, const usb_standard_endpoint_descriptor_t *, const usb_superspeed_endpoint_companion_descriptor_t *); 108 errno_t usb_pipe_register(usb_pipe_t *, 109 const usb_standard_endpoint_descriptor_t *, 110 const usb_superspeed_endpoint_companion_descriptor_t *); 108 111 errno_t usb_pipe_unregister(usb_pipe_t *); 109 112 -
uspace/lib/usbdev/include/usb/dev/poll.h
r3692678 rae3a941 60 60 size_t request_size; 61 61 62 /** Data buffer of at least `request_size`. User is responsible for its allocation. */ 62 /** 63 * Data buffer of at least `request_size`. User is responsible for its 64 * allocation. 65 */ 63 66 uint8_t *buffer; 64 67 … … 75 78 76 79 77 /** Optional parameters - user can customize them, but they are defaulted to 78 * some reasonable values. 80 /** 81 * Optional parameters - user can customize them, but they are 82 * defaulted to some reasonable values. 79 83 */ 80 84 … … 86 90 int debug; 87 91 88 /** Maximum number of consecutive errors before polling termination (default 3). */ 92 /** 93 * Maximum number of consecutive errors before polling termination 94 * (default 3). 95 */ 89 96 size_t max_failures; 90 97 … … 121 128 122 129 123 /** Internal parameters - user is not expected to set them. Messing with them 124 * can result in unexpected behavior if you do not know what you are doing. 130 /** 131 * Internal parameters - user is not expected to set them. Messing with 132 * them can result in unexpected behavior if you do not know what you 133 * are doing. 125 134 */ 126 135 -
uspace/lib/usbdev/src/dp.c
r3692678 rae3a941 127 127 * @retval -1 Invalid input. 128 128 */ 129 static int get_descriptor_type(const usb_dp_parser_data_t *data, const uint8_t *start) 129 static int get_descriptor_type(const usb_dp_parser_data_t *data, 130 const uint8_t *start) 130 131 { 131 132 if (start == NULL) { … … 258 259 int parent_type = get_descriptor_type(data, parent); 259 260 int possible_sibling_type = get_descriptor_type(data, possible_sibling); 260 if (is_nested_descriptor_type(parser, possible_sibling_type, parent_type)) { 261 if (is_nested_descriptor_type(parser, 262 possible_sibling_type, parent_type)) { 261 263 return possible_sibling; 262 264 } else { -
uspace/lib/usbdev/src/pipes.c
r3692678 rae3a941 338 338 * @return Error code. 339 339 */ 340 errno_t usb_pipe_write_dma(usb_pipe_t *pipe, void *base, void * ptr,size_t size)340 errno_t usb_pipe_write_dma(usb_pipe_t *pipe, void *base, void *ptr, size_t size) 341 341 { 342 342 assert(pipe); … … 377 377 /** Initialize USB default control pipe. 378 378 * 379 * This one is special because it must not be registered, it is registered automatically. 379 * This one is special because it must not be registered, it is registered 380 * automatically. 380 381 * 381 382 * @param pipe Endpoint pipe to be initialized. … … 383 384 * @return Error code. 384 385 */ 385 errno_t usb_pipe_initialize_default_control(usb_pipe_t *pipe, usb_dev_session_t *bus_session) 386 errno_t usb_pipe_initialize_default_control(usb_pipe_t *pipe, 387 usb_dev_session_t *bus_session) 386 388 { 387 389 const errno_t ret = usb_pipe_initialize(pipe, bus_session); … … 402 404 * @return Error code. 403 405 */ 404 errno_t usb_pipe_register(usb_pipe_t *pipe, const usb_standard_endpoint_descriptor_t *ep_desc, const usb_superspeed_endpoint_companion_descriptor_t *comp_desc) 406 errno_t usb_pipe_register(usb_pipe_t *pipe, 407 const usb_standard_endpoint_descriptor_t *ep_desc, 408 const usb_superspeed_endpoint_companion_descriptor_t *comp_desc) 405 409 { 406 410 assert(pipe); … … 429 433 #undef COPY 430 434 431 const errno_t ret = usbhc_register_endpoint(exch, &pipe->desc, &descriptors); 435 const errno_t ret = usbhc_register_endpoint(exch, 436 &pipe->desc, &descriptors); 432 437 async_exchange_end(exch); 433 438 return ret; -
uspace/lib/usbhid/src/hidparser.c
r3692678 rae3a941 52 52 int usb_hid_translate_data(usb_hid_report_field_t *item, const uint8_t *data); 53 53 54 uint32_t usb_hid_translate_data_reverse(usb_hid_report_field_t *item, 55 int32_t value);54 uint32_t usb_hid_translate_data_reverse(usb_hid_report_field_t *item, 55 int32_t value); 56 56 57 57 … … 76 76 * 77 77 * @param parser Opaque report parser structure 78 * @param report_id 78 * @param report_id 79 79 * @param type 80 80 * @return Number of items in specified report 81 81 */ 82 size_t usb_hid_report_size(usb_hid_report_t *report, uint8_t report_id, 82 size_t usb_hid_report_size(usb_hid_report_t *report, uint8_t report_id, 83 83 usb_hid_report_type_t type) 84 84 { … … 100 100 * 101 101 * @param parser Opaque report parser structure 102 * @param report_id 102 * @param report_id 103 103 * @param type 104 104 * @return Number of items in specified report 105 105 */ 106 size_t usb_hid_report_byte_size(usb_hid_report_t *report, uint8_t report_id, 106 size_t usb_hid_report_byte_size(usb_hid_report_t *report, uint8_t report_id, 107 107 usb_hid_report_type_t type) 108 108 { … … 117 117 return 0; 118 118 } else { 119 return ((report_des->bit_length + 7) / 8) ;119 return ((report_des->bit_length + 7) / 8); 120 120 } 121 121 } … … 129 129 * @param data Data for the report. 130 130 * @return Error code. 131 */ 132 errno_t usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data, 131 */ 132 errno_t usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data, 133 133 size_t size, uint8_t *report_id) 134 134 { 135 135 usb_hid_report_description_t *report_des; 136 136 usb_hid_report_type_t type = USB_HID_REPORT_TYPE_INPUT; 137 137 138 138 if (report == NULL) { 139 139 return EINVAL; … … 146 146 } 147 147 148 report_des = usb_hid_report_find_description(report, *report_id, 148 report_des = usb_hid_report_find_description(report, *report_id, 149 149 type); 150 150 … … 158 158 159 159 if (USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) { 160 160 161 161 if (USB_HID_ITEM_FLAG_VARIABLE(item->item_flags) == 0) { 162 162 /* array */ 163 item->value = 164 usb_hid_translate_data(item, data);165 163 item->value = 164 usb_hid_translate_data(item, data); 165 166 166 item->usage = USB_HID_EXTENDED_USAGE( 167 167 item->usages[item->value - 168 168 item->physical_minimum]); 169 169 170 item->usage_page = 170 item->usage_page = 171 171 USB_HID_EXTENDED_USAGE_PAGE( 172 172 item->usages[item->value - … … 174 174 175 175 usb_hid_report_set_last_item( 176 item->collection_path, 177 USB_HID_TAG_CLASS_GLOBAL, 176 item->collection_path, 177 USB_HID_TAG_CLASS_GLOBAL, 178 178 item->usage_page); 179 179 180 180 usb_hid_report_set_last_item( 181 item->collection_path, 181 item->collection_path, 182 182 USB_HID_TAG_CLASS_LOCAL, item->usage); 183 183 } else { 184 184 /* variable item */ 185 item->value = usb_hid_translate_data(item, 185 item->value = usb_hid_translate_data(item, 186 186 data); 187 187 } 188 188 } 189 189 } 190 190 191 191 return EOK; 192 192 } … … 214 214 int resolution; 215 215 if (item->physical_maximum == item->physical_minimum) { 216 resolution = 1;217 } else { 218 resolution = (item->logical_maximum - item->logical_minimum) /219 ((item->physical_maximum - item->physical_minimum) *220 (usb_pow(10, (item->unit_exponent))));216 resolution = 1; 217 } else { 218 resolution = (item->logical_maximum - item->logical_minimum) / 219 ((item->physical_maximum - item->physical_minimum) * 220 (usb_pow(10, (item->unit_exponent)))); 221 221 } 222 222 … … 255 255 } 256 256 257 return (int) (((value - item->logical_minimum) / resolution) + 257 return (int) (((value - item->logical_minimum) / resolution) + 258 258 item->physical_minimum); 259 259 } … … 262 262 /* OUTPUT API */ 263 263 264 /** 264 /** 265 265 * Allocates output report buffer for output report 266 266 * … … 270 270 * @return Returns allocated output buffer for specified output 271 271 */ 272 uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size, 272 uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size, 273 273 uint8_t report_id) 274 274 { … … 322 322 * @return Error code 323 323 */ 324 errno_t usb_hid_report_output_translate(usb_hid_report_t *report, 324 errno_t usb_hid_report_output_translate(usb_hid_report_t *report, 325 325 uint8_t report_id, uint8_t *buffer, size_t size) 326 326 { … … 329 329 int length; 330 330 int32_t tmp_value; 331 331 332 332 if (report == NULL) { 333 333 return EINVAL; … … 339 339 340 340 usb_hid_report_description_t *report_des; 341 report_des = usb_hid_report_find_description(report, report_id, 341 report_des = usb_hid_report_find_description(report, report_id, 342 342 USB_HID_REPORT_TYPE_OUTPUT); 343 343 344 344 if (report_des == NULL) { 345 345 return EINVAL; … … 348 348 list_foreach(report_des->report_items, ritems_link, 349 349 usb_hid_report_field_t, report_item) { 350 value = usb_hid_translate_data_reverse(report_item, 350 value = usb_hid_translate_data_reverse(report_item, 351 351 report_item->value); 352 352 353 353 offset = report_des->bit_length - report_item->offset - 1; 354 354 length = report_item->size; 355 355 356 356 usb_log_debug("\ttranslated value: %x", value); 357 357 358 358 if ((offset / 8) == ((offset + length - 1) / 8)) { 359 if (((size_t) (offset / 8) >= size) || 359 if (((size_t) (offset / 8) >= size) || 360 360 ((size_t) (offset + length - 1) / 8) >= size) { 361 361 break; // TODO ErrorCode … … 364 364 value = value << shift; 365 365 value = value & (((1 << length) - 1) << shift); 366 366 367 367 uint8_t mask = 0; 368 368 mask = 0xff - (((1 << length) - 1) << shift); … … 376 376 if (i == (offset / 8)) { 377 377 tmp_value = value; 378 tmp_value = tmp_value & 378 tmp_value = tmp_value & 379 379 ((1 << (8 - (offset % 8))) - 1); 380 380 381 381 tmp_value = tmp_value << (offset % 8); 382 382 383 383 mask = ~(((1 << (8 - (offset % 8))) - 1) 384 384 << (offset % 8)); 385 385 386 buffer[i] = (buffer[i] & mask) | 386 buffer[i] = (buffer[i] & mask) | 387 387 tmp_value; 388 388 } else if (i == ((offset + length - 1) / 8)) { 389 390 value = value >> (length - 389 390 value = value >> (length - 391 391 ((offset + length) % 8)); 392 392 393 value = value & ((1 << (length - 393 value = value & ((1 << (length - 394 394 ((offset + length) % 8))) - 1); 395 396 mask = (1 << (length - 395 396 mask = (1 << (length - 397 397 ((offset + length) % 8))) - 1; 398 398 … … 407 407 report_item->value = 0; 408 408 } 409 409 410 410 return EOK; 411 411 } … … 418 418 * @return ranslated value 419 419 */ 420 uint32_t usb_hid_translate_data_reverse(usb_hid_report_field_t *item, 420 uint32_t usb_hid_translate_data_reverse(usb_hid_report_field_t *item, 421 421 int value) 422 422 { … … 430 430 if ((item->physical_minimum == 0) && (item->physical_maximum == 0)) { 431 431 item->physical_minimum = item->logical_minimum; 432 item->physical_maximum = item->logical_maximum; 433 } 434 432 item->physical_maximum = item->logical_maximum; 433 } 434 435 435 /* variable item */ 436 436 if (item->physical_maximum == item->physical_minimum) { 437 resolution = 1;438 } else { 439 resolution = (item->logical_maximum - item->logical_minimum) /440 ((item->physical_maximum - item->physical_minimum) *441 (usb_pow(10, (item->unit_exponent))));442 } 443 444 ret = ((value - item->physical_minimum) * resolution) + 437 resolution = 1; 438 } else { 439 resolution = (item->logical_maximum - item->logical_minimum) / 440 ((item->physical_maximum - item->physical_minimum) * 441 (usb_pow(10, (item->unit_exponent)))); 442 } 443 444 ret = ((value - item->physical_minimum) * resolution) + 445 445 item->logical_minimum; 446 446 447 447 usb_log_debug("\tvalue(%x), resolution(%x), phymin(%x) logmin(%x), " 448 "ret(%x)\n", value, resolution, item->physical_minimum, 448 "ret(%x)\n", value, resolution, item->physical_minimum, 449 449 item->logical_minimum, ret); 450 450 451 451 if ((item->logical_minimum < 0) || (item->logical_maximum < 0)) { 452 452 return USB_HID_INT32_TO_UINT32(ret, item->size); … … 467 467 { 468 468 usb_hid_report_item_t *new_report_item; 469 469 470 470 if (!(new_report_item = malloc(sizeof(usb_hid_report_item_t)))) { 471 471 return NULL; 472 } 472 } 473 473 memcpy(new_report_item,item, sizeof(usb_hid_report_item_t)); 474 474 link_initialize(&(new_report_item->link)); … … 485 485 * @param field Current field. If NULL is given, the first one in the report 486 486 * is returned. Otherwise the next one i nthe list is returned. 487 * @param path Usage path specifying which fields wa are interested in. 487 * @param path Usage path specifying which fields wa are interested in. 488 488 * @param flags Flags defining mode of usage paths comparison 489 489 * @param type Type of report we search. … … 491 491 * @retval Pointer to the founded report structure when founded 492 492 */ 493 usb_hid_report_field_t *usb_hid_report_get_sibling(usb_hid_report_t *report, 494 usb_hid_report_field_t *field, usb_hid_report_path_t *path, int flags, 493 usb_hid_report_field_t *usb_hid_report_get_sibling(usb_hid_report_t *report, 494 usb_hid_report_field_t *field, usb_hid_report_path_t *path, int flags, 495 495 usb_hid_report_type_t type) 496 496 { 497 usb_hid_report_description_t *report_des = 497 usb_hid_report_description_t *report_des = 498 498 usb_hid_report_find_description(report, path->report_id, type); 499 499 500 500 link_t *field_it; 501 501 502 502 if (report_des == NULL) { 503 503 return NULL; … … 511 511 512 512 while (field_it != &report_des->report_items.head) { 513 field = list_get_instance(field_it, usb_hid_report_field_t, 513 field = list_get_instance(field_it, usb_hid_report_field_t, 514 514 ritems_link); 515 515 … … 553 553 usb_hid_report_description_t *report_des; 554 554 link_t *report_it; 555 555 556 556 if (report_id > 0) { 557 report_des = usb_hid_report_find_description(report, report_id, 557 report_des = usb_hid_report_find_description(report, report_id, 558 558 type); 559 559 if (report_des == NULL) { … … 561 561 } else { 562 562 report_it = report_des->reports_link.next; 563 } 563 } 564 564 } else { 565 565 report_it = report->reports.head.next; … … 567 567 568 568 while (report_it != &report->reports.head) { 569 report_des = list_get_instance(report_it, 569 report_des = list_get_instance(report_it, 570 570 usb_hid_report_description_t, reports_link); 571 571 … … 594 594 return; 595 595 } 596 596 597 597 report_item->usages_count = 0; 598 598 memset(report_item->usages, 0, USB_HID_MAX_USAGES); 599 599 600 600 report_item->extended_usage_page = 0; 601 601 report_item->usage_minimum = 0; -
uspace/lib/usbhid/src/hidpath.c
r3692678 rae3a941 73 73 * @return Error code 74 74 */ 75 errno_t usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, 76 int32_t usage_page, int32_t usage)77 { 78 usb_hid_report_usage_path_t *item 79 =malloc(sizeof(usb_hid_report_usage_path_t));75 errno_t usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, 76 int32_t usage_page, int32_t usage) 77 { 78 usb_hid_report_usage_path_t *item = 79 malloc(sizeof(usb_hid_report_usage_path_t)); 80 80 81 81 if (item == NULL) { … … 87 87 item->usage_page = usage_page; 88 88 item->flags = 0; 89 89 90 90 list_append (&item->rpath_items_link, &usage_path->items); 91 91 usage_path->depth++; … … 96 96 /** 97 97 * Removes last item from the usage path structure 98 * @param usage_path 98 * @param usage_path 99 99 * @return void 100 100 */ … … 103 103 link_t *item_link; 104 104 usb_hid_report_usage_path_t *item; 105 106 if (!list_empty(&usage_path->items)){105 106 if (!list_empty(&usage_path->items)) { 107 107 item_link = list_last(&usage_path->items); 108 108 item = list_get_instance(item_link, … … 124 124 { 125 125 usb_hid_report_usage_path_t *item; 126 127 if (!list_empty(&usage_path->items)){126 127 if (!list_empty(&usage_path->items)) { 128 128 item = list_get_instance(list_last(&usage_path->items), 129 usb_hid_report_usage_path_t, rpath_items_link);129 usb_hid_report_usage_path_t, rpath_items_link); 130 130 131 131 memset(item, 0, sizeof(usb_hid_report_usage_path_t)); … … 143 143 * @return void 144 144 */ 145 void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, 146 int32_t tag, int32_t data)145 void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, 146 int32_t tag, int32_t data) 147 147 { 148 148 usb_hid_report_usage_path_t *item; 149 150 if (!list_empty(&usage_path->items)){149 150 if (!list_empty(&usage_path->items)) { 151 151 item = list_get_instance(list_last(&usage_path->items), 152 152 usb_hid_report_usage_path_t, rpath_items_link); 153 153 154 switch(tag) { 155 case USB_HID_TAG_CLASS_GLOBAL: 156 item->usage_page = data; 157 break; 158 case USB_HID_TAG_CLASS_LOCAL: 159 item->usage = data; 160 break; 161 } 162 } 163 164 } 165 166 167 /** 168 * 169 * 170 * 171 * 172 */ 154 switch (tag) { 155 case USB_HID_TAG_CLASS_GLOBAL: 156 item->usage_page = data; 157 break; 158 case USB_HID_TAG_CLASS_LOCAL: 159 item->usage = data; 160 break; 161 } 162 } 163 } 164 173 165 void usb_hid_print_usage_path(usb_hid_report_path_t *path) 174 166 { … … 199 191 usb_hid_report_usage_path_t *report_item; 200 192 usb_hid_report_usage_path_t *path_item; 201 193 202 194 link_t *report_link; 203 195 link_t *path_link; 204 196 205 197 int only_page; 206 198 207 199 if (report_path->report_id != path->report_id) { 208 200 if (path->report_id != 0) { … … 210 202 } 211 203 } 212 204 213 205 // Empty path match all others 214 206 if (path->depth == 0) { 215 207 return 0; 216 208 } 217 209 218 210 if ((only_page = flags & USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY) != 0) { 219 211 flags -= USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY; 220 212 } 221 213 222 214 switch (flags) { 223 215 /* Path is somewhere in report_path */ … … 226 218 return 1; 227 219 } 228 220 229 221 path_link = list_first(&path->items); 230 222 path_item = list_get_instance(path_link, 231 223 usb_hid_report_usage_path_t, rpath_items_link); 232 224 233 225 list_foreach(report_path->items, rpath_items_link, 234 226 usb_hid_report_usage_path_t, report_item) { 235 227 if (USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 236 228 path_item->usage_page)) { 237 229 238 230 if (only_page == 0) { 239 231 if (USB_HID_SAME_USAGE(report_item->usage, … … 245 237 } 246 238 } 247 239 248 240 return 1; 249 241 break; 250 242 251 243 /* The paths must be identical */ 252 244 case USB_HID_PATH_COMPARE_STRICT: … … 255 247 } 256 248 /* Fallthrough */ 257 249 258 250 /* Path is prefix of the report_path */ 259 251 case USB_HID_PATH_COMPARE_BEGIN: 260 252 report_link = report_path->items.head.next; 261 253 path_link = path->items.head.next; 262 254 263 255 while ((report_link != &report_path->items.head) && 264 256 (path_link != &path->items.head)) { 265 257 266 258 report_item = list_get_instance(report_link, 267 259 usb_hid_report_usage_path_t, rpath_items_link); 268 260 269 261 path_item = list_get_instance(path_link, 270 262 usb_hid_report_usage_path_t, rpath_items_link); 271 263 272 264 if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 273 265 path_item->usage_page) || ((only_page == 0) && … … 280 272 } 281 273 } 282 274 283 275 if ((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) && 284 276 (path_link == &path->items.head)) || … … 290 282 } 291 283 break; 292 284 293 285 /* Path is suffix of report_path */ 294 286 case USB_HID_PATH_COMPARE_END: 295 287 report_link = report_path->items.head.prev; 296 288 path_link = path->items.head.prev; 297 289 298 290 if (list_empty(&path->items)) { 299 291 return 0; 300 292 } 301 293 302 294 while ((report_link != &report_path->items.head) && 303 295 (path_link != &path->items.head)) { 304 296 report_item = list_get_instance(report_link, 305 297 usb_hid_report_usage_path_t, rpath_items_link); 306 298 307 299 path_item = list_get_instance(path_link, 308 300 usb_hid_report_usage_path_t, rpath_items_link); 309 301 310 302 if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 311 303 path_item->usage_page) || ((only_page == 0) && … … 318 310 } 319 311 } 320 312 321 313 if (path_link == &path->items.head) { 322 314 return 0; … … 325 317 } 326 318 break; 327 319 328 320 default: 329 321 return -1; … … 340 332 usb_hid_report_path_t *path; 341 333 path = malloc(sizeof(usb_hid_report_path_t)); 342 if (path == NULL){334 if (path == NULL) { 343 335 return NULL; 344 336 } … … 363 355 if (path == NULL) 364 356 return; 365 while (!list_empty(&path->items)){357 while (!list_empty(&path->items)) { 366 358 usb_hid_report_remove_last_item(path); 367 359 } … … 379 371 */ 380 372 usb_hid_report_path_t *usb_hid_report_path_clone( 381 usb_hid_report_path_t *usage_path)373 usb_hid_report_path_t *usage_path) 382 374 { 383 375 usb_hid_report_usage_path_t *new_path_item; 384 376 usb_hid_report_path_t *new_usage_path = usb_hid_report_path (); 385 377 386 if (new_usage_path == NULL){378 if (new_usage_path == NULL) { 387 379 return NULL; 388 380 } 389 381 390 382 new_usage_path->report_id = usage_path->report_id; 391 392 if (list_empty(&usage_path->items)){383 384 if (list_empty(&usage_path->items)) { 393 385 return new_usage_path; 394 386 } … … 398 390 399 391 new_path_item = malloc(sizeof(usb_hid_report_usage_path_t)); 400 if (new_path_item == NULL) {392 if (new_path_item == NULL) { 401 393 return NULL; 402 394 } 403 395 404 396 link_initialize(&new_path_item->rpath_items_link); 405 397 new_path_item->usage_page = path_item->usage_page; 406 new_path_item->usage = path_item->usage; 407 new_path_item->flags = path_item->flags; 408 398 new_path_item->usage = path_item->usage; 399 new_path_item->flags = path_item->flags; 400 409 401 list_append(&new_path_item->rpath_items_link, 410 402 &new_usage_path->items); … … 423 415 * @return Error code 424 416 */ 425 errno_t usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, 426 uint8_t report_id)427 { 428 if (path == NULL){417 errno_t usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, 418 uint8_t report_id) 419 { 420 if (path == NULL) { 429 421 return EINVAL; 430 422 } -
uspace/lib/usbhid/src/hidreport.c
r3692678 rae3a941 71 71 const uint8_t *d = 72 72 usb_dp_get_nested_descriptor(&parser, &parser_data, 73 usb_device_descriptors(dev)->full_config);73 usb_device_descriptors(dev)->full_config); 74 74 75 75 /* … … 163 163 164 164 165 errno_t usb_hid_process_report_descriptor(usb_device_t *dev, 165 errno_t usb_hid_process_report_descriptor(usb_device_t *dev, 166 166 usb_hid_report_t *report, uint8_t **report_desc, size_t *report_size) 167 167 { -
uspace/lib/usbhid/src/hidreq.c
r3692678 rae3a941 65 65 return EINVAL; 66 66 } 67 68 if (iface_no < 0) { 69 usb_log_warning("usbhid_req_set_report(): no interface given." 70 "\n"); 71 return EINVAL; 72 } 73 74 /* 75 * No need for checking other parameters, as they are checked in 76 * the called function (usb_control_request_set()). 77 */ 78 79 errno_t rc; 80 67 68 if (iface_no < 0) { 69 usb_log_warning("usbhid_req_set_report(): no interface given." 70 "\n"); 71 return EINVAL; 72 } 73 74 /* 75 * No need for checking other parameters, as they are checked in 76 * the called function (usb_control_request_set()). 77 */ 78 79 errno_t rc; 80 81 81 uint16_t value = 0; 82 82 value |= (type << 8); 83 83 84 84 usb_log_debug("Sending Set Report request to the device."); 85 85 86 86 rc = usb_control_request_set(ctrl_pipe, 87 87 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, … … 93 93 return rc; 94 94 } 95 95 96 96 return EOK; 97 97 } … … 115 115 return EINVAL; 116 116 } 117 118 if (iface_no < 0) { 119 usb_log_warning("usbhid_req_set_report(): no interface given." 120 "\n"); 121 return EINVAL; 122 } 123 124 /* 125 * No need for checking other parameters, as they are checked in 126 * the called function (usb_control_request_set()). 127 */ 128 117 118 if (iface_no < 0) { 119 usb_log_warning("usbhid_req_set_report(): no interface given." 120 "\n"); 121 return EINVAL; 122 } 123 124 /* 125 * No need for checking other parameters, as they are checked in 126 * the called function (usb_control_request_set()). 127 */ 128 129 129 errno_t rc; 130 130 131 131 usb_log_debug("Sending Set Protocol request to the device (" 132 132 "protocol: %d, iface: %d).\n", protocol, iface_no); 133 134 rc = usb_control_request_set(ctrl_pipe, 135 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 133 134 rc = usb_control_request_set(ctrl_pipe, 135 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 136 136 USB_HIDREQ_SET_PROTOCOL, protocol, iface_no, NULL, 0); 137 137 … … 141 141 return rc; 142 142 } 143 143 144 144 return EOK; 145 145 } … … 163 163 return EINVAL; 164 164 } 165 166 if (iface_no < 0) { 167 usb_log_warning("usbhid_req_set_report(): no interface given." 168 "\n"); 169 return EINVAL; 170 } 171 172 /* 173 * No need for checking other parameters, as they are checked in 174 * the called function (usb_control_request_set()). 175 */ 176 165 166 if (iface_no < 0) { 167 usb_log_warning("usbhid_req_set_report(): no interface given." 168 "\n"); 169 return EINVAL; 170 } 171 172 /* 173 * No need for checking other parameters, as they are checked in 174 * the called function (usb_control_request_set()). 175 */ 176 177 177 errno_t rc; 178 178 179 179 usb_log_debug("Sending Set Idle request to the device (" 180 180 "duration: %u, iface: %d).\n", duration, iface_no); 181 181 182 182 uint16_t value = duration << 8; 183 183 184 184 rc = usb_control_request_set(ctrl_pipe, 185 185 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, … … 191 191 return rc; 192 192 } 193 193 194 194 return EOK; 195 195 } … … 203 203 * @param[in][out] buffer Buffer for the report data. 204 204 * @param[in] buf_size Size of the buffer (in bytes). 205 * @param[out] actual_size Actual size of report received from the device 205 * @param[out] actual_size Actual size of report received from the device 206 206 * (in bytes). 207 207 * … … 210 210 * @return Other value inherited from function usb_control_request_set(). 211 211 */ 212 errno_t usbhid_req_get_report(usb_pipe_t *ctrl_pipe, int iface_no, 213 usb_hid_report_type_t type, uint8_t *buffer, size_t buf_size, 212 errno_t usbhid_req_get_report(usb_pipe_t *ctrl_pipe, int iface_no, 213 usb_hid_report_type_t type, uint8_t *buffer, size_t buf_size, 214 214 size_t *actual_size) 215 215 { … … 218 218 return EINVAL; 219 219 } 220 221 if (iface_no < 0) { 222 usb_log_warning("usbhid_req_set_report(): no interface given." 223 "\n"); 224 return EINVAL; 225 } 226 227 /* 228 * No need for checking other parameters, as they are checked in 229 * the called function (usb_control_request_set()). 230 */ 231 220 221 if (iface_no < 0) { 222 usb_log_warning("usbhid_req_set_report(): no interface given." 223 "\n"); 224 return EINVAL; 225 } 226 227 /* 228 * No need for checking other parameters, as they are checked in 229 * the called function (usb_control_request_set()). 230 */ 231 232 232 errno_t rc; 233 233 234 234 uint16_t value = 0; 235 235 value |= (type << 8); 236 236 237 237 usb_log_debug("Sending Get Report request to the device."); 238 239 rc = usb_control_request_get(ctrl_pipe, 240 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 238 239 rc = usb_control_request_get(ctrl_pipe, 240 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 241 241 USB_HIDREQ_GET_REPORT, value, iface_no, buffer, buf_size, 242 242 actual_size); … … 247 247 return rc; 248 248 } 249 249 250 250 return EOK; 251 251 } … … 262 262 * @return Other value inherited from function usb_control_request_set(). 263 263 */ 264 errno_t usbhid_req_get_protocol(usb_pipe_t *ctrl_pipe, int iface_no, 264 errno_t usbhid_req_get_protocol(usb_pipe_t *ctrl_pipe, int iface_no, 265 265 usb_hid_protocol_t *protocol) 266 266 { … … 269 269 return EINVAL; 270 270 } 271 272 if (iface_no < 0) { 273 usb_log_warning("usbhid_req_set_report(): no interface given." 274 "\n"); 275 return EINVAL; 276 } 277 278 /* 279 * No need for checking other parameters, as they are checked in 280 * the called function (usb_control_request_set()). 281 */ 282 283 errno_t rc; 271 272 if (iface_no < 0) { 273 usb_log_warning("usbhid_req_set_report(): no interface given." 274 "\n"); 275 return EINVAL; 276 } 277 278 /* 279 * No need for checking other parameters, as they are checked in 280 * the called function (usb_control_request_set()). 281 */ 282 283 errno_t rc; 284 284 285 285 usb_log_debug("Sending Get Protocol request to the device (" 286 286 "iface: %d).\n", iface_no); 287 287 288 288 uint8_t buffer[1]; 289 289 size_t actual_size = 0; 290 291 rc = usb_control_request_get(ctrl_pipe, 292 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 290 291 rc = usb_control_request_get(ctrl_pipe, 292 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 293 293 USB_HIDREQ_GET_PROTOCOL, 0, iface_no, buffer, 1, &actual_size); 294 294 … … 298 298 return rc; 299 299 } 300 300 301 301 if (actual_size != 1) { 302 302 usb_log_warning("Wrong data size: %zu, expected: 1.", 303 actual_size);303 actual_size); 304 304 return ELIMIT; 305 305 } 306 306 307 307 *protocol = buffer[0]; 308 308 309 309 return EOK; 310 310 } … … 320 320 * @retval EOK if successful. 321 321 * @retval EINVAL if no HID device is given. 322 * @return Other value inherited from one of functions 322 * @return Other value inherited from one of functions 323 323 * usb_pipe_start_session(), usb_pipe_end_session(), 324 324 * usb_control_request_set(). 325 325 */ 326 errno_t usbhid_req_get_idle(usb_pipe_t *ctrl_pipe, int iface_no, uint8_t *duration) 327 { 328 if (ctrl_pipe == NULL) { 329 usb_log_warning("usbhid_req_set_report(): no pipe given."); 330 return EINVAL; 331 } 332 333 if (iface_no < 0) { 334 usb_log_warning("usbhid_req_set_report(): no interface given." 335 "\n"); 336 return EINVAL; 337 } 338 339 /* 340 * No need for checking other parameters, as they are checked in 341 * the called function (usb_control_request_set()). 342 */ 343 326 errno_t usbhid_req_get_idle(usb_pipe_t *ctrl_pipe, int iface_no, 327 uint8_t *duration) 328 { 329 if (ctrl_pipe == NULL) { 330 usb_log_warning("usbhid_req_set_report(): no pipe given."); 331 return EINVAL; 332 } 333 334 if (iface_no < 0) { 335 usb_log_warning("usbhid_req_set_report(): no interface given." 336 "\n"); 337 return EINVAL; 338 } 339 340 /* 341 * No need for checking other parameters, as they are checked in 342 * the called function (usb_control_request_set()). 343 */ 344 344 345 errno_t rc; 345 346 346 347 usb_log_debug("Sending Get Idle request to the device (" 347 348 "iface: %d).\n", iface_no); 348 349 349 350 uint16_t value = 0; 350 351 uint8_t buffer[1]; 351 352 size_t actual_size = 0; 352 353 rc = usb_control_request_get(ctrl_pipe, 354 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 355 USB_HIDREQ_GET_IDLE, value, iface_no, buffer, 1, 353 354 rc = usb_control_request_get(ctrl_pipe, 355 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 356 USB_HIDREQ_GET_IDLE, value, iface_no, buffer, 1, 356 357 &actual_size); 357 358 … … 361 362 return rc; 362 363 } 363 364 364 365 if (actual_size != 1) { 365 366 usb_log_warning("Wrong data size: %zu, expected: 1.", 366 actual_size);367 actual_size); 367 368 return ELIMIT; 368 369 } 369 370 370 371 *duration = buffer[0]; 371 372 372 373 return EOK; 373 374 } -
uspace/lib/usbhost/include/usb/host/bus.h
r3692678 rae3a941 111 111 int (*device_online)(device_t *); /**< Optional */ 112 112 void (*device_offline)(device_t *); /**< Optional */ 113 endpoint_t *(*endpoint_create)(device_t *, const usb_endpoint_descriptors_t *); 113 endpoint_t *(*endpoint_create)(device_t *, 114 const usb_endpoint_descriptors_t *); 114 115 115 116 /* Operations on endpoint */ -
uspace/lib/usbhost/include/usb/host/endpoint.h
r3692678 rae3a941 102 102 103 103 /* Policies for transfer buffers */ 104 dma_policy_t transfer_buffer_policy; /**< A hint for optimal performance. */ 105 dma_policy_t required_transfer_buffer_policy; /**< Enforced by the library. */ 104 /** A hint for optimal performance. */ 105 dma_policy_t transfer_buffer_policy; 106 /** Enforced by the library. */ 107 dma_policy_t required_transfer_buffer_policy; 106 108 107 109 /** … … 114 116 } endpoint_t; 115 117 116 extern void endpoint_init(endpoint_t *, device_t *, const usb_endpoint_descriptors_t *); 118 extern void endpoint_init(endpoint_t *, device_t *, 119 const usb_endpoint_descriptors_t *); 117 120 118 121 extern void endpoint_add_ref(endpoint_t *); -
uspace/lib/usbhost/include/usb/host/hcd.h
r3692678 rae3a941 78 78 79 79 /** Generate IRQ code to handle interrupts. */ 80 int (*irq_code_gen)(irq_code_t *, hc_device_t *, const hw_res_list_parsed_t *, int *); 80 int (*irq_code_gen)(irq_code_t *, hc_device_t *, 81 const hw_res_list_parsed_t *, int *); 81 82 82 83 /** Claim device from BIOS. */ … … 100 101 101 102 /* Drivers should call this before leaving hc_add */ 102 static inline void hc_device_setup(hc_device_t *hcd, bus_t *bus) { 103 static inline void hc_device_setup(hc_device_t *hcd, bus_t *bus) 104 { 103 105 hcd->bus = bus; 104 106 } -
uspace/lib/usbhost/include/usb/host/usb2_bus.h
r3692678 rae3a941 61 61 } usb2_bus_helper_t; 62 62 63 extern void usb2_bus_helper_init(usb2_bus_helper_t *, const bandwidth_accounting_t *); 63 extern void usb2_bus_helper_init(usb2_bus_helper_t *, 64 const bandwidth_accounting_t *); 64 65 65 66 extern int usb2_bus_device_enumerate(usb2_bus_helper_t *, device_t *); -
uspace/lib/usbhost/src/bandwidth.c
r3692678 rae3a941 73 73 * transaction, but I did not find text in USB spec to confirm this */ 74 74 /* NOTE: All data packets will be considered to be max_packet_size */ 75 switch (ep->device->speed) 76 { 75 switch (ep->device->speed) { 77 76 case USB_SPEED_LOW: 78 77 assert(type == USB_TRANSFER_INTERRUPT); … … 143 142 case USB_SPEED_LOW: 144 143 if (ep->direction == USB_DIRECTION_IN) 145 return 64060 + (2 * hub_ls_setup) + (677 * base_time) + host_delay; 144 return 64060 + (2 * hub_ls_setup) + 145 (677 * base_time) + host_delay; 146 146 else 147 return 64107 + (2 * hub_ls_setup) + (667 * base_time) + host_delay; 147 return 64107 + (2 * hub_ls_setup) + 148 (667 * base_time) + host_delay; 148 149 149 150 case USB_SPEED_FULL: -
uspace/lib/usbhost/src/hcd.c
r3692678 rae3a941 155 155 * @return Negative error code. 156 156 */ 157 static errno_t hcd_ddf_setup_interrupts(hc_device_t *hcd, const hw_res_list_parsed_t *hw_res) 157 static errno_t hcd_ddf_setup_interrupts(hc_device_t *hcd, 158 const hw_res_list_parsed_t *hw_res) 158 159 { 159 160 assert(hcd); 160 irq_code_t irq_code = { 0};161 irq_code_t irq_code = { 0 }; 161 162 162 163 if (!hc_driver->irq_code_gen) … … 174 175 /* Register handler to avoid interrupt lockup */ 175 176 int irq_cap; 176 ret = register_interrupt_handler(hcd->ddf_dev, irq, irq_handler, &irq_code, &irq_cap); 177 ret = register_interrupt_handler(hcd->ddf_dev, irq, irq_handler, 178 &irq_code, &irq_cap); 177 179 irq_code_clean(&irq_code); 178 180 if (ret != EOK) { … … 212 214 213 215 if (!hc_driver->hc_add) { 214 usb_log_error("Driver '%s' does not support adding devices.", hc_driver->name); 216 usb_log_error("Driver '%s' does not support adding devices.", 217 hc_driver->name); 215 218 return ENOTSUP; 216 219 } … … 292 295 293 296 usb_log_info("Controlling new `%s' device `%s'.", 294 hc_driver->name, ddf_dev_get_name(device));297 hc_driver->name, ddf_dev_get_name(device)); 295 298 return EOK; 296 299 -
uspace/lib/usbvirt/src/ipc_hc.c
r3692678 rae3a941 77 77 } 78 78 79 errno_t rc = async_data_write_start(exch, setup_buffer, setup_buffer_size); 79 errno_t rc = async_data_write_start(exch, setup_buffer, 80 setup_buffer_size); 80 81 if (rc != EOK) { 81 82 async_exchange_end(exch); … … 85 86 86 87 ipc_call_t data_request_call; 87 aid_t data_request = async_data_read(exch, data_buffer, data_buffer_size,88 &data_request_call);88 aid_t data_request = async_data_read(exch, data_buffer, 89 data_buffer_size, &data_request_call); 89 90 90 91 async_exchange_end(exch); … … 150 151 } 151 152 152 errno_t rc = async_data_write_start(exch, setup_buffer, setup_buffer_size); 153 errno_t rc = async_data_write_start(exch, setup_buffer, 154 setup_buffer_size); 153 155 if (rc != EOK) { 154 156 async_exchange_end(exch); … … 158 160 159 161 if (data_buffer_size > 0) { 160 rc = async_data_write_start(exch, data_buffer, data_buffer_size); 162 rc = async_data_write_start(exch, data_buffer, 163 data_buffer_size); 161 164 if (rc != EOK) { 162 165 async_exchange_end(exch); -
uspace/lib/usbvirt/src/transfer.c
r3692678 rae3a941 119 119 * @return Error code. 120 120 */ 121 errno_t usbvirt_control_read(usbvirt_device_t *dev, const void *setup, size_t setup_size, 121 errno_t usbvirt_control_read(usbvirt_device_t *dev, 122 const void *setup, size_t setup_size, 122 123 void *data, size_t data_size, size_t *data_size_sent) 123 124 {
Note:
See TracChangeset
for help on using the changeset viewer.
