Changeset 9e5b162 in mainline for uspace/lib/usbdev/src/pipes.c
- Timestamp:
- 2018-01-05T22:09:24Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 86650db
- Parents:
- 35c37fc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/pipes.c
r35c37fc r9e5b162 271 271 * 272 272 * @param pipe Endpoint pipe to be initialized. 273 * @param endpoint_no Endpoint number (in USB 1.1 in range 0 to 15). 274 * @param transfer_type Transfer type (e.g. interrupt or bulk). 275 * @param max_packet_size Maximum packet size in bytes. 276 * @param direction Endpoint direction (in/out). 277 * @return Error code. 278 */ 279 int usb_pipe_initialize(usb_pipe_t *pipe, usb_endpoint_t endpoint_no, 280 usb_transfer_type_t transfer_type, size_t max_packet_size, 281 usb_direction_t direction, unsigned packets, 282 unsigned max_burst, unsigned max_streams, unsigned bytes_per_interval, 283 unsigned mult, usb_dev_session_t *bus_session) 273 * @param bus_session Endpoint pipe to be initialized. 274 * @param ep_desc Prepared endpoint descriptor 275 * @return Error code. 276 */ 277 int usb_pipe_initialize(usb_pipe_t *pipe, 278 usb_dev_session_t *bus_session, 279 const usb_endpoint_desc_t *ep_desc) 284 280 { 285 281 int ret = EOK; 286 // FIXME: refactor this function PLEASE 287 assert(pipe); 288 289 pipe->desc.endpoint_no = endpoint_no; 290 pipe->desc.transfer_type = transfer_type; 291 pipe->desc.packets = packets; 292 pipe->desc.max_packet_size = max_packet_size; 293 pipe->desc.direction = direction; 294 pipe->desc.usb3.max_burst = max_burst; 295 pipe->desc.usb3.max_streams = max_streams; 296 pipe->desc.usb3.mult = mult; 297 pipe->desc.usb3.bytes_per_interval = bytes_per_interval; 282 assert(pipe); 283 284 pipe->desc = *ep_desc; 298 285 pipe->auto_reset_halt = false; 299 286 pipe->bus_session = bus_session; 300 287 301 // TODO: hardcoded, remake to receive from device descriptors 302 pipe->desc.interval = 14; 303 304 if (transfer_type == USB_TRANSFER_ISOCHRONOUS) { 288 if (pipe->desc.transfer_type == USB_TRANSFER_ISOCHRONOUS) { 305 289 ret = usb_isoch_session_initialize(pipe); 306 290 } … … 309 293 } 310 294 295 static const usb_endpoint_desc_t default_control_ep_desc = { 296 .max_packet_size = CTRL_PIPE_MIN_PACKET_SIZE, 297 .direction = USB_DIRECTION_BOTH, 298 .packets = 1, 299 }; 300 311 301 /** Initialize USB endpoint pipe as the default zero control pipe. 312 302 * 313 303 * @param pipe Endpoint pipe to be initialized. 314 * @return Error code. 315 */ 316 int usb_pipe_initialize_default_control(usb_pipe_t *pipe, 317 usb_dev_session_t *bus_session) 318 { 319 assert(pipe); 320 321 const int rc = usb_pipe_initialize(pipe, 0, USB_TRANSFER_CONTROL, 322 CTRL_PIPE_MIN_PACKET_SIZE, USB_DIRECTION_BOTH, 1, 0, 0, 0, 0, bus_session); 323 324 pipe->auto_reset_halt = true; 325 326 return rc; 304 * @param bus_session 305 * @return Error code. 306 */ 307 int usb_pipe_initialize_default_control(usb_pipe_t *pipe, usb_dev_session_t *bus_session) 308 { 309 return usb_pipe_initialize(pipe, bus_session, &default_control_ep_desc); 327 310 } 328 311
Note:
See TracChangeset
for help on using the changeset viewer.