Changes in uspace/lib/usbdev/src/pipesinit.c [9d58539:58563585] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/pipesinit.c
r9d58539 r58563585 34 34 * 35 35 */ 36 #include <usb/usb.h>37 36 #include <usb/dev/pipes.h> 38 37 #include <usb/dev/dp.h> 39 38 #include <usb/dev/request.h> 39 #include <usb/usb.h> 40 #include <usb/descriptor.h> 41 42 #include <assert.h> 40 43 #include <errno.h> 41 #include <assert.h>42 44 43 45 #define DEV_DESCR_MAX_PACKET_SIZE_OFFSET 7 … … 148 150 * @param interface Interface descriptor under which belongs the @p endpoint. 149 151 * @param endpoint Endpoint descriptor. 150 * @param wire Connection backing the endpoint pipes.151 152 * @return Error code. 152 153 */ … … 154 155 usb_endpoint_mapping_t *mapping, size_t mapping_count, 155 156 usb_standard_interface_descriptor_t *interface, 156 usb_standard_endpoint_descriptor_t *endpoint ,157 usb_dev ice_connection_t *wire)157 usb_standard_endpoint_descriptor_t *endpoint_desc, 158 usb_dev_session_t *bus_session) 158 159 { 159 160 … … 163 164 164 165 /* Actual endpoint number is in bits 0..3 */ 165 const usb_endpoint_t ep_no = endpoint ->endpoint_address & 0x0F;166 const usb_endpoint_t ep_no = endpoint_desc->endpoint_address & 0x0F; 166 167 167 168 const usb_endpoint_description_t description = { 168 169 /* Endpoint direction is set by bit 7 */ 169 .direction = (endpoint ->endpoint_address & 128)170 .direction = (endpoint_desc->endpoint_address & 128) 170 171 ? USB_DIRECTION_IN : USB_DIRECTION_OUT, 171 172 /* Transfer type is in bits 0..2 and 172 173 * the enum values corresponds 1:1 */ 173 .transfer_type = endpoint ->attributes & 3,174 .transfer_type = endpoint_desc->attributes & 3, 174 175 175 176 /* Get interface characteristics. */ … … 190 191 191 192 if (ep_mapping->present) { 192 return EEXISTS; 193 } 194 195 int rc = usb_pipe_initialize(&ep_mapping->pipe, wire, 196 ep_no, description.transfer_type, endpoint->max_packet_size, 197 description.direction); 193 return EEXIST; 194 } 195 196 int rc = usb_pipe_initialize(&ep_mapping->pipe, 197 ep_no, description.transfer_type, 198 ED_MPS_PACKET_SIZE_GET( 199 uint16_usb2host(endpoint_desc->max_packet_size)), 200 description.direction, 201 ED_MPS_TRANS_OPPORTUNITIES_GET( 202 uint16_usb2host(endpoint_desc->max_packet_size)), bus_session); 198 203 if (rc != EOK) { 199 204 return rc; … … 201 206 202 207 ep_mapping->present = true; 203 ep_mapping->descriptor = endpoint ;208 ep_mapping->descriptor = endpoint_desc; 204 209 ep_mapping->interface = interface; 205 210 … … 219 224 usb_endpoint_mapping_t *mapping, size_t mapping_count, 220 225 const usb_dp_parser_t *parser, const usb_dp_parser_data_t *parser_data, 221 const uint8_t *interface_descriptor )226 const uint8_t *interface_descriptor, usb_dev_session_t *bus_session) 222 227 { 223 228 const uint8_t *descriptor = usb_dp_get_nested_descriptor(parser, … … 235 240 (usb_standard_endpoint_descriptor_t *) 236 241 descriptor, 237 (usb_device_connection_t *) parser_data->arg);242 bus_session); 238 243 } 239 244 … … 279 284 usb_endpoint_mapping_t *mapping, size_t mapping_count, 280 285 const uint8_t *config_descriptor, size_t config_descriptor_size, 281 usb_device_connection_t *connection) 282 { 283 assert(connection); 284 285 if (config_descriptor == NULL) { 286 usb_dev_session_t *bus_session) 287 { 288 if (config_descriptor == NULL) 286 289 return EBADMEM; 287 }288 if (config_descriptor_size 289 <sizeof(usb_standard_configuration_descriptor_t)) {290 291 if (config_descriptor_size < 292 sizeof(usb_standard_configuration_descriptor_t)) { 290 293 return ERANGE; 291 294 } … … 305 308 .data = config_descriptor, 306 309 .size = config_descriptor_size, 307 .arg = connection308 310 }; 309 311 … … 318 320 do { 319 321 (void) process_interface(mapping, mapping_count, 320 &dp_parser, &dp_data, interface );322 &dp_parser, &dp_data, interface, bus_session); 321 323 interface = usb_dp_get_sibling_descriptor(&dp_parser, &dp_data, 322 324 config_descriptor, interface); … … 339 341 { 340 342 assert(pipe); 341 assert(DEV_DESCR_MAX_PACKET_SIZE_OFFSET < CTRL_PIPE_MIN_PACKET_SIZE);343 static_assert(DEV_DESCR_MAX_PACKET_SIZE_OFFSET < CTRL_PIPE_MIN_PACKET_SIZE); 342 344 343 345 if ((pipe->direction != USB_DIRECTION_BOTH) || … … 346 348 return EINVAL; 347 349 } 348 349 350 usb_pipe_start_long_transfer(pipe);351 350 352 351 uint8_t dev_descr_start[CTRL_PIPE_MIN_PACKET_SIZE]; … … 366 365 } 367 366 } 368 usb_pipe_end_long_transfer(pipe);369 367 if (rc != EOK) { 370 368 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.