Changeset 816f5f4 in mainline for uspace/lib/usbdev
- Timestamp:
- 2017-10-15T16:55:48Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9b2f69e
- Parents:
- 2770b66
- Location:
- uspace/lib/usbdev
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/include/usb/dev/pipes.h
r2770b66 r816f5f4 50 50 */ 51 51 typedef struct { 52 /** Endpoint number. */ 53 usb_endpoint_t endpoint_no; 54 55 /** Endpoint transfer type. */ 56 usb_transfer_type_t transfer_type; 57 58 /** Endpoint direction. */ 59 usb_direction_t direction; 60 61 /** Maximum packet size for the endpoint. */ 62 size_t max_packet_size; 63 64 /** Number of packets per frame/uframe. 65 * Only valid for HS INT and ISO transfers. All others should set to 1*/ 66 unsigned packets; 67 52 /** Endpoint description */ 53 usb_endpoint_desc_t desc; 68 54 /** Whether to automatically reset halt on the endpoint. 69 55 * Valid only for control endpoint zero. 70 56 */ 71 57 bool auto_reset_halt; 72 73 58 /** The connection used for sending the data. */ 74 59 usb_dev_session_t *bus_session; -
uspace/lib/usbdev/src/devdrv.c
r2770b66 r816f5f4 56 56 /** Connection to device on USB bus */ 57 57 usb_dev_session_t *bus_session; 58 58 59 59 /** devman handle */ 60 60 devman_handle_t handle; 61 61 62 62 /** The default control pipe. */ 63 63 usb_pipe_t ctrl_pipe; 64 64 65 65 /** Other endpoint pipes. 66 66 * … … 69 69 */ 70 70 usb_endpoint_mapping_t *pipes; 71 71 72 72 /** Number of other endpoint pipes. */ 73 73 size_t pipes_count; 74 74 75 75 /** Current interface. 76 76 * … … 79 79 */ 80 80 int interface_no; 81 81 82 82 /** Alternative interfaces. */ 83 83 usb_alternate_interfaces_t alternate_interfaces; 84 84 85 85 /** Some useful descriptors for USB device. */ 86 86 usb_device_descriptors_t descriptors; 87 87 88 88 /** Generic DDF device backing this one. DO NOT TOUCH! */ 89 89 ddf_dev_t *ddf_dev; 90 90 91 91 /** Custom driver data. 92 92 * … … 146 146 return rc; 147 147 } 148 148 149 149 /* Change current alternative */ 150 150 usb_dev->alternate_interfaces.current = alternate_setting; … … 296 296 assert(usb_dev); 297 297 assert(usb_dev->pipes || usb_dev->pipes_count == 0); 298 298 299 299 /* Destroy the pipes. */ 300 300 for (size_t i = 0; i < usb_dev->pipes_count; ++i) { … … 304 304 usb_pipe_unregister(&usb_dev->pipes[i].pipe); 305 305 } 306 306 307 307 free(usb_dev->pipes); 308 308 usb_dev->pipes = NULL; … … 332 332 assert(usb_dev); 333 333 for (unsigned i = 0; i < usb_dev->pipes_count; ++i) { 334 if (usb_dev->pipes[i].pipe. endpoint_no == ep)334 if (usb_dev->pipes[i].pipe.desc.endpoint_no == ep) 335 335 return &usb_dev->pipes[i]; 336 336 } … … 462 462 assert(handle); 463 463 assert(iface_no); 464 464 465 465 async_exch_t *exch = async_exchange_begin(sess); 466 466 if (!exch) 467 467 return EPARTY; 468 468 469 469 int ret = usb_get_my_device_handle(exch, handle); 470 470 if (ret == EOK) { … … 475 475 } 476 476 } 477 477 478 478 async_exchange_end(exch); 479 479 return ret; … … 504 504 return ENOMEM; 505 505 } 506 506 507 507 return usb_device_init(usb_dev, ddf_dev, desc, err, h, iface_no); 508 508 } -
uspace/lib/usbdev/src/devpoll.c
r2770b66 r816f5f4 96 96 (int) mapping->interface->interface_subclass, 97 97 (int) mapping->interface->interface_protocol, 98 data->request_size, pipe-> max_packet_size);98 data->request_size, pipe->desc.max_packet_size); 99 99 } 100 100 … … 128 128 usb_request_clear_endpoint_halt( 129 129 usb_device_get_default_pipe(data->dev), 130 pipe-> endpoint_no);130 pipe->desc.endpoint_no); 131 131 } 132 132 … … 156 156 157 157 /* Take a rest before next request. */ 158 158 159 159 // FIXME TODO: This is broken, the time is in ms not us. 160 160 // but first we need to fix drivers to actually stop using this, … … 216 216 if (request_size == 0) 217 217 return EINVAL; 218 219 if (!epm || (epm->pipe. transfer_type != USB_TRANSFER_INTERRUPT) ||220 (epm->pipe.d irection != USB_DIRECTION_IN))218 219 if (!epm || (epm->pipe.desc.transfer_type != USB_TRANSFER_INTERRUPT) || 220 (epm->pipe.desc.direction != USB_DIRECTION_IN)) 221 221 return EINVAL; 222 222 223 223 224 224 polling_data_t *polling_data = malloc(sizeof(polling_data_t)); -
uspace/lib/usbdev/src/pipes.c
r2770b66 r816f5f4 51 51 assert(pipe != NULL); 52 52 53 if (!pipe->auto_reset_halt || (pipe-> endpoint_no != 0)) {53 if (!pipe->auto_reset_halt || (pipe->desc.endpoint_no != 0)) { 54 54 return; 55 55 } … … 88 88 } 89 89 90 if ((pipe->d irection != USB_DIRECTION_BOTH)91 || (pipe-> transfer_type != USB_TRANSFER_CONTROL)) {90 if ((pipe->desc.direction != USB_DIRECTION_BOTH) 91 || (pipe->desc.transfer_type != USB_TRANSFER_CONTROL)) { 92 92 return EBADF; 93 93 } … … 98 98 async_exch_t *exch = async_exchange_begin(pipe->bus_session); 99 99 size_t act_size = 0; 100 const int rc = usb_read(exch, pipe-> endpoint_no, setup_packet, buffer,100 const int rc = usb_read(exch, pipe->desc.endpoint_no, setup_packet, buffer, 101 101 buffer_size, &act_size); 102 102 async_exchange_end(exch); … … 142 142 } 143 143 144 if ((pipe->d irection != USB_DIRECTION_BOTH)145 || (pipe-> transfer_type != USB_TRANSFER_CONTROL)) {144 if ((pipe->desc.direction != USB_DIRECTION_BOTH) 145 || (pipe->desc.transfer_type != USB_TRANSFER_CONTROL)) { 146 146 return EBADF; 147 147 } … … 152 152 async_exch_t *exch = async_exchange_begin(pipe->bus_session); 153 153 const int rc = usb_write(exch, 154 pipe-> endpoint_no, setup_packet, buffer, buffer_size);154 pipe->desc.endpoint_no, setup_packet, buffer, buffer_size); 155 155 async_exchange_end(exch); 156 156 … … 183 183 } 184 184 185 if (pipe->d irection != USB_DIRECTION_IN) {186 return EBADF; 187 } 188 189 if (pipe-> transfer_type == USB_TRANSFER_CONTROL) {185 if (pipe->desc.direction != USB_DIRECTION_IN) { 186 return EBADF; 187 } 188 189 if (pipe->desc.transfer_type == USB_TRANSFER_CONTROL) { 190 190 return EBADF; 191 191 } 192 192 193 193 /* Isochronous transfer are not supported (yet) */ 194 if (pipe-> transfer_type != USB_TRANSFER_INTERRUPT &&195 pipe-> transfer_type != USB_TRANSFER_BULK)194 if (pipe->desc.transfer_type != USB_TRANSFER_INTERRUPT && 195 pipe->desc.transfer_type != USB_TRANSFER_BULK) 196 196 return ENOTSUP; 197 197 … … 199 199 size_t act_size = 0; 200 200 const int rc = 201 usb_read(exch, pipe-> endpoint_no, 0, buffer, size, &act_size);201 usb_read(exch, pipe->desc.endpoint_no, 0, buffer, size, &act_size); 202 202 async_exchange_end(exch); 203 203 … … 224 224 } 225 225 226 if (pipe->d irection != USB_DIRECTION_OUT) {227 return EBADF; 228 } 229 230 if (pipe-> transfer_type == USB_TRANSFER_CONTROL) {226 if (pipe->desc.direction != USB_DIRECTION_OUT) { 227 return EBADF; 228 } 229 230 if (pipe->desc.transfer_type == USB_TRANSFER_CONTROL) { 231 231 return EBADF; 232 232 } 233 233 234 234 /* Isochronous transfer are not supported (yet) */ 235 if (pipe-> transfer_type != USB_TRANSFER_INTERRUPT &&236 pipe-> transfer_type != USB_TRANSFER_BULK)235 if (pipe->desc.transfer_type != USB_TRANSFER_INTERRUPT && 236 pipe->desc.transfer_type != USB_TRANSFER_BULK) 237 237 return ENOTSUP; 238 238 239 239 async_exch_t *exch = async_exchange_begin(pipe->bus_session); 240 const int rc = usb_write(exch, pipe-> endpoint_no, 0, buffer, size);240 const int rc = usb_write(exch, pipe->desc.endpoint_no, 0, buffer, size); 241 241 async_exchange_end(exch); 242 242 return rc; … … 258 258 assert(pipe); 259 259 260 pipe-> endpoint_no = endpoint_no;261 pipe-> transfer_type = transfer_type;262 pipe-> packets = packets;263 pipe-> max_packet_size = max_packet_size;264 pipe->d irection = direction;260 pipe->desc.endpoint_no = endpoint_no; 261 pipe->desc.transfer_type = transfer_type; 262 pipe->desc.packets = packets; 263 pipe->desc.max_packet_size = max_packet_size; 264 pipe->desc.direction = direction; 265 265 pipe->auto_reset_halt = false; 266 266 pipe->bus_session = bus_session; … … 297 297 assert(pipe); 298 298 assert(pipe->bus_session); 299 300 pipe->desc.usb2.polling_interval = interval; 299 301 async_exch_t *exch = async_exchange_begin(pipe->bus_session); 300 302 if (!exch) 301 303 return ENOMEM; 302 const int ret = usb_register_endpoint(exch, pipe->endpoint_no, 303 pipe->transfer_type, pipe->direction, pipe->max_packet_size,304 pipe->packets, interval); 304 305 const int ret = usb_register_endpoint(exch, &pipe->desc); 306 305 307 async_exchange_end(exch); 306 308 return ret; … … 319 321 if (!exch) 320 322 return ENOMEM; 321 const int ret = usb_unregister_endpoint(exch, pipe->endpoint_no, 322 pipe->direction); 323 324 const int ret = usb_unregister_endpoint(exch, &pipe->desc); 325 323 326 async_exchange_end(exch); 324 327 return ret; -
uspace/lib/usbdev/src/pipesinit.c
r2770b66 r816f5f4 288 288 if (config_descriptor == NULL) 289 289 return EBADMEM; 290 290 291 291 if (config_descriptor_size < 292 292 sizeof(usb_standard_configuration_descriptor_t)) { … … 343 343 static_assert(DEV_DESCR_MAX_PACKET_SIZE_OFFSET < CTRL_PIPE_MIN_PACKET_SIZE); 344 344 345 if ((pipe->d irection != USB_DIRECTION_BOTH) ||346 (pipe-> transfer_type != USB_TRANSFER_CONTROL) ||347 (pipe-> endpoint_no != 0)) {345 if ((pipe->desc.direction != USB_DIRECTION_BOTH) || 346 (pipe->desc.transfer_type != USB_TRANSFER_CONTROL) || 347 (pipe->desc.endpoint_no != 0)) { 348 348 return EINVAL; 349 349 } … … 369 369 } 370 370 371 pipe-> max_packet_size371 pipe->desc.max_packet_size 372 372 = dev_descr_start[DEV_DESCR_MAX_PACKET_SIZE_OFFSET]; 373 373 -
uspace/lib/usbdev/src/request.c
r2770b66 r816f5f4 844 844 } 845 845 return usb_request_clear_endpoint_halt(ctrl_pipe, 846 target_pipe-> endpoint_no);846 target_pipe->desc.endpoint_no); 847 847 } 848 848 … … 858 858 { 859 859 uint16_t status_tmp; 860 uint16_t pipe_index = (uint16_t) pipe-> endpoint_no;860 uint16_t pipe_index = (uint16_t) pipe->desc.endpoint_no; 861 861 int rc = usb_request_get_status(ctrl_pipe, 862 862 USB_REQUEST_RECIPIENT_ENDPOINT, uint16_host2usb(pipe_index),
Note:
See TracChangeset
for help on using the changeset viewer.