Changeset 58563585 in mainline for uspace/lib/usbdev
- Timestamp:
- 2016-08-31T11:15:39Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 10cb47e
- Parents:
- 7a67416
- Location:
- uspace/lib/usbdev
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/include/usb/dev/poll.h
r7a67416 r58563585 94 94 typedef void (*usb_polling_terminted_callback_t)(usb_device_t *, bool, void *); 95 95 96 int usb_device_auto_polling(usb_device_t *, usb_endpoint_t,96 extern int usb_device_auto_polling(usb_device_t *, usb_endpoint_t, 97 97 const usb_device_auto_polling_t *, size_t); 98 98 99 int usb_device_auto_poll(usb_device_t *, usb_endpoint_t,99 extern int usb_device_auto_poll(usb_device_t *, usb_endpoint_t, 100 100 usb_polling_callback_t, size_t, int, usb_polling_terminted_callback_t, void *); 101 101 102 int usb_device_auto_polling_desc(usb_device_t *,102 extern int usb_device_auto_polling_desc(usb_device_t *, 103 103 const usb_endpoint_description_t *, const usb_device_auto_polling_t *, 104 104 size_t); 105 105 106 int usb_device_auto_poll_desc(usb_device_t *,106 extern int usb_device_auto_poll_desc(usb_device_t *, 107 107 const usb_endpoint_description_t *, usb_polling_callback_t, size_t, int, 108 108 usb_polling_terminted_callback_t, void *); -
uspace/lib/usbdev/include/usb/dev/recognise.h
r7a67416 r58563585 50 50 51 51 extern int usb_device_create_match_ids(usb_pipe_t *, match_id_list_t *); 52 52 53 #endif 53 54 -
uspace/lib/usbdev/src/devdrv.c
r7a67416 r58563585 27 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 */ 29 29 30 /** @addtogroup libusbdev 30 31 * @{ … … 55 56 /** Connection to device on USB bus */ 56 57 usb_dev_session_t *bus_session; 58 57 59 /** devman handle */ 58 60 devman_handle_t handle; 61 59 62 /** The default control pipe. */ 60 63 usb_pipe_t ctrl_pipe; 61 64 62 65 /** Other endpoint pipes. 66 * 63 67 * This is an array of other endpoint pipes in the same order as 64 68 * in usb_driver_t. 65 69 */ 66 70 usb_endpoint_mapping_t *pipes; 71 67 72 /** Number of other endpoint pipes. */ 68 73 size_t pipes_count; 74 69 75 /** Current interface. 76 * 70 77 * Usually, drivers operate on single interface only. 71 78 * This item contains the value of the interface or -1 for any. 72 79 */ 73 80 int interface_no; 81 74 82 /** Alternative interfaces. */ 75 83 usb_alternate_interfaces_t alternate_interfaces; 84 76 85 /** Some useful descriptors for USB device. */ 77 86 usb_device_descriptors_t descriptors; 87 78 88 /** Generic DDF device backing this one. DO NOT TOUCH! */ 79 89 ddf_dev_t *ddf_dev; 90 80 91 /** Custom driver data. 92 * 81 93 * Do not use the entry in generic device, that is already used 82 94 * by the framework. 83 95 */ 84 96 void *driver_data; 85 86 97 } usb_device_t; 87 98 … … 135 146 return rc; 136 147 } 137 148 138 149 /* Change current alternative */ 139 150 usb_dev->alternate_interfaces.current = alternate_setting; … … 279 290 * 280 291 * @param[in] usb_dev USB device. 292 * 281 293 */ 282 294 void usb_device_destroy_pipes(usb_device_t *usb_dev) … … 284 296 assert(usb_dev); 285 297 assert(usb_dev->pipes || usb_dev->pipes_count == 0); 298 286 299 /* Destroy the pipes. */ 287 300 for (size_t i = 0; i < usb_dev->pipes_count; ++i) { … … 291 304 usb_pipe_unregister(&usb_dev->pipes[i].pipe); 292 305 } 306 293 307 free(usb_dev->pipes); 294 308 usb_dev->pipes = NULL; … … 448 462 assert(handle); 449 463 assert(iface_no); 464 450 465 async_exch_t *exch = async_exchange_begin(sess); 451 466 if (!exch) 452 467 return EPARTY; 468 453 469 int ret = usb_get_my_device_handle(exch, handle); 454 470 if (ret == EOK) { … … 459 475 } 460 476 } 477 461 478 async_exchange_end(exch); 462 479 return ret; -
uspace/lib/usbdev/src/devpoll.c
r7a67416 r58563585 33 33 * USB device driver framework - automatic interrupt polling. 34 34 */ 35 35 36 #include <usb/dev/device.h> 36 37 #include <usb/dev/pipes.h> … … 85 86 86 87 if (params->debug > 0) { 87 const usb_endpoint_mapping_t *mapping 88 =data->polling_mapping;88 const usb_endpoint_mapping_t *mapping = 89 data->polling_mapping; 89 90 usb_log_debug("Poll (%p): started polling of `%s' - " \ 90 91 "interface %d (%s,%d,%d), %zuB/%zu.\n", … … 154 155 155 156 /* Take a rest before next request. */ 156 //TODO: This is broken, the time is in ms not us. 157 158 // FIXME TODO: This is broken, the time is in ms not us. 157 159 // but first we need to fix drivers to actually stop using this, 158 // since polling de aly should be implemented in HC schedule160 // since polling delay should be implemented in HC schedule 159 161 async_usleep(params->delay); 160 162 } … … 213 215 if (request_size == 0) 214 216 return EINVAL; 215 217 216 218 if (!epm || (epm->pipe.transfer_type != USB_TRANSFER_INTERRUPT) || 217 219 (epm->pipe.direction != USB_DIRECTION_IN)) 218 220 return EINVAL; 219 221 220 222 221 223 polling_data_t *polling_data = malloc(sizeof(polling_data_t)); -
uspace/lib/usbdev/src/pipes.c
r7a67416 r58563585 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, 101 pipe->endpoint_no, setup_packet, buffer,buffer_size, &act_size);100 const int rc = usb_read(exch, pipe->endpoint_no, setup_packet, buffer, 101 buffer_size, &act_size); 102 102 async_exchange_end(exch); 103 103 -
uspace/lib/usbdev/src/pipesinit.c
r7a67416 r58563585 286 286 usb_dev_session_t *bus_session) 287 287 { 288 289 if (config_descriptor == NULL) { 288 if (config_descriptor == NULL) 290 289 return EBADMEM; 291 }292 if (config_descriptor_size 293 <sizeof(usb_standard_configuration_descriptor_t)) {290 291 if (config_descriptor_size < 292 sizeof(usb_standard_configuration_descriptor_t)) { 294 293 return ERANGE; 295 294 } -
uspace/lib/usbdev/src/recognise.c
r7a67416 r58563585 234 234 (int) device_descriptor->product_id, 235 235 BCD_ARGS(device_descriptor->device_version)); 236 236 237 237 /* Next, without release number. */ 238 238 ADD_MATCHID_OR_RETURN(matches, 90, … … 245 245 ADD_MATCHID_OR_RETURN(matches, 50, "usb&class=%s", 246 246 usb_str_class(device_descriptor->device_class)); 247 247 248 248 /* As a last resort, try fallback driver. */ 249 249 ADD_MATCHID_OR_RETURN(matches, 10, "usb&fallback"); -
uspace/lib/usbdev/src/request.c
r7a67416 r58563585 50 50 * @see usb_pipe_control_write 51 51 * 52 * @param pipe Pipe used for the communication.52 * @param pipe Pipe used for the communication. 53 53 * @param request_type Request type (standard/class/vendor). 54 * @param recipient Request recipient (e.g. device or endpoint). 55 * @param request Actual request (e.g. GET_DESCRIPTOR). 56 * @param value Value of @c wValue field of setup packet 57 * (must be in USB endianness). 58 * @param index Value of @c wIndex field of setup packet 59 * (must be in USB endianness). 60 * @param data Data to be sent during DATA stage 61 * (expected to be in USB endianness). 62 * @param data_size Size of the @p data buffer (in native endianness). 54 * @param recipient Request recipient (e.g. device or endpoint). 55 * @param request Actual request (e.g. GET_DESCRIPTOR). 56 * @param value Value of @c wValue field of setup packet 57 * (must be in USB endianness). 58 * @param index Value of @c wIndex field of setup packet 59 * (must be in USB endianness). 60 * @param data Data to be sent during DATA stage 61 * (expected to be in USB endianness). 62 * @param data_size Size of the @p data buffer (in native endianness). 63 * 63 64 * @return Error code. 64 65 * @retval EBADMEM @p pipe is NULL. 65 66 * @retval EBADMEM @p data is NULL and @p data_size is not zero. 66 67 * @retval ERANGE Data buffer too large. 68 * 67 69 */ 68 70 int usb_control_request_set(usb_pipe_t *pipe, … … 100 102 } 101 103 102 /** Generic wrapper for GET requests using standard control request format. 103 * 104 * @see usb_pipe_control_read 105 * 106 * @param pipe Pipe used for the communication. 107 * @param request_type Request type (standard/class/vendor). 108 * @param recipient Request recipient (e.g. device or endpoint). 109 * @param request Actual request (e.g. GET_DESCRIPTOR). 110 * @param value Value of @c wValue field of setup packet 111 * (must be in USB endianness). 112 * @param index Value of @c wIndex field of setup packet 113 * (must be in USB endianness). 114 * @param data Buffer where to store data accepted during the DATA stage. 115 * (they will come in USB endianness). 116 * @param data_size Size of the @p data buffer 117 * (in native endianness). 118 * @param actual_data_size Actual size of transfered data 119 * (in native endianness). 120 * @return Error code. 121 * @retval EBADMEM @p pipe is NULL. 122 * @retval EBADMEM @p data is NULL and @p data_size is not zero. 123 * @retval ERANGE Data buffer too large. 124 */ 104 /** Generic wrapper for GET requests using standard control request format. 105 * 106 * @see usb_pipe_control_read 107 * 108 * @param pipe Pipe used for the communication. 109 * @param request_type Request type (standard/class/vendor). 110 * @param recipient Request recipient (e.g. device or endpoint). 111 * @param request Actual request (e.g. GET_DESCRIPTOR). 112 * @param value Value of @c wValue field of setup packet 113 * (must be in USB endianness). 114 * @param index Value of @c wIndex field of setup packet 115 * (must be in USB endianness). 116 * @param data Buffer where to store data accepted during 117 * the DATA stage (they will come in USB endianness). 118 * @param data_size Size of the @p data buffer 119 * (in native endianness). 120 * @param actual_data_size Actual size of transfered data 121 * (in native endianness). 122 * 123 * @return Error code. 124 * @retval EBADMEM @p pipe is NULL. 125 * @retval EBADMEM @p data is NULL and @p data_size is not zero. 126 * @retval ERANGE Data buffer too large. 127 * 128 */ 125 129 int usb_control_request_get(usb_pipe_t *pipe, 126 130 usb_request_type_t request_type, usb_request_recipient_t recipient, … … 209 213 { 210 214 if (request_type == USB_REQUEST_TYPE_STANDARD) { 211 if ((recipient == USB_REQUEST_RECIPIENT_DEVICE) && (index != 0)) 212 { 215 if ((recipient == USB_REQUEST_RECIPIENT_DEVICE) && (index != 0)) { 213 216 return EINVAL; 214 217 } … … 234 237 { 235 238 if (request_type == USB_REQUEST_TYPE_STANDARD) { 236 if ((recipient == USB_REQUEST_RECIPIENT_DEVICE) && (index != 0)) 237 { 239 if ((recipient == USB_REQUEST_RECIPIENT_DEVICE) && (index != 0)) { 238 240 return EINVAL; 239 241 } … … 271 273 } 272 274 273 /* The wValue field specifies the descriptor type in the high byte 275 /* 276 * The wValue field specifies the descriptor type in the high byte 274 277 * and the descriptor index in the low byte. USB 1.1 spec p. 189 275 278 */
Note:
See TracChangeset
for help on using the changeset viewer.