Changeset dbf32b1 in mainline for uspace/drv/bus/usb/xhci/endpoint.c
- Timestamp:
- 2017-10-17T10:09:40Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 95c675b
- Parents:
- bb784ae
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/endpoint.c
rbb784ae rdbf32b1 81 81 } 82 82 83 uint8_t xhci_endpoint_ctx_offset(xhci_endpoint_t *ep) 84 { 85 /* 0 is slot ctx, 1 is EP0, then it's EP1 out, in, EP2 out, in, etc. */ 86 87 uint8_t off = 2 * (ep->base.target.endpoint); 88 if (ep->base.direction == USB_DIRECTION_IN || ep->base.target.endpoint == 0) 89 ++off; 90 91 return off; 83 /** Return an index to the endpoint array. The indices are assigned as follows: 84 * 0 EP0 BOTH 85 * 1 EP1 OUT 86 * 2 EP1 IN 87 * 88 * For control endpoints >0, the IN endpoint index is used. 89 * 90 * The index returned must be usually offset by a number of contexts preceding 91 * the endpoint contexts themselves. 92 */ 93 uint8_t xhci_endpoint_index(xhci_endpoint_t *ep) 94 { 95 return (2 * ep->base.target.endpoint) 96 - (ep->base.direction == USB_DIRECTION_OUT); 92 97 } 93 98 … … 211 216 XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, 0); 212 217 213 const uint8_t ep_ offset = xhci_endpoint_ctx_offset(ep);214 XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, ep_ offset);218 const uint8_t ep_idx = xhci_endpoint_index(ep); 219 XHCI_INPUT_CTRL_CTX_ADD_SET(ictx->ctrl_ctx, ep_idx + 1); /* Preceded by slot ctx */ 215 220 216 221 ep_ring = malloc(sizeof(xhci_trb_ring_t)); … … 227 232 switch (ep->base.transfer_type) { 228 233 case USB_TRANSFER_CONTROL: 229 setup_control_ep_ctx(ep, &ictx->endpoint_ctx[ep_ offset - 1], ep_ring);234 setup_control_ep_ctx(ep, &ictx->endpoint_ctx[ep_idx], ep_ring); 230 235 break; 231 236 232 237 case USB_TRANSFER_BULK: 233 setup_bulk_ep_ctx(ep, &ictx->endpoint_ctx[ep_ offset - 1], ep_ring, &ss_desc);238 setup_bulk_ep_ctx(ep, &ictx->endpoint_ctx[ep_idx], ep_ring, &ss_desc); 234 239 break; 235 240 236 241 case USB_TRANSFER_ISOCHRONOUS: 237 setup_isoch_ep_ctx(ep, &ictx->endpoint_ctx[ep_ offset - 1], ep_ring, &ss_desc);242 setup_isoch_ep_ctx(ep, &ictx->endpoint_ctx[ep_idx], ep_ring, &ss_desc); 238 243 break; 239 244 240 245 case USB_TRANSFER_INTERRUPT: 241 setup_interrupt_ep_ctx(ep, &ictx->endpoint_ctx[ep_ offset - 1], ep_ring, &ss_desc);246 setup_interrupt_ep_ctx(ep, &ictx->endpoint_ctx[ep_idx], ep_ring, &ss_desc); 242 247 break; 243 248
Note:
See TracChangeset
for help on using the changeset viewer.