Changeset 4c03793 in mainline
- Timestamp:
- 2018-01-19T22:17:23Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b5c92d7
- Parents:
- 726af29
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-01-19 22:17:21)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-01-19 22:17:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/utility.c
r726af29 r4c03793 211 211 } 212 212 213 /** How many toggles need to be reset */214 typedef enum {215 RESET_NONE,216 RESET_EP,217 RESET_ALL218 } toggle_reset_mode_t;219 220 213 /** 221 214 * Check setup packet data for signs of toggle reset. 222 215 * 223 216 * @param[in] batch USB batch 224 */ 225 static toggle_reset_mode_t get_request_toggle_reset_mode(const usb_transfer_batch_t *batch) 217 * @param[in] reset_cb Callback to reset an endpoint 218 */ 219 void hc_reset_toggles(const usb_transfer_batch_t *batch, endpoint_reset_toggle_t reset_cb) 226 220 { 227 221 if (batch->ep->transfer_type != USB_TRANSFER_CONTROL 228 222 || batch->dir != USB_DIRECTION_OUT) 229 return RESET_NONE;223 return; 230 224 231 225 const usb_device_request_setup_packet_t *request = &batch->setup.packet; 226 device_t * const dev = batch->ep->device; 232 227 233 228 switch (request->request) … … 237 232 /* 0x2 ( HOST to device | STANDART | TO ENPOINT) */ 238 233 if ((request->request_type == 0x2) && 239 (request->value == USB_FEATURE_ENDPOINT_HALT)) 240 return RESET_EP; 234 (request->value == USB_FEATURE_ENDPOINT_HALT)) { 235 const unsigned index = uint16_usb2host(request->index); 236 const unsigned ep_num = index & 0xf; 237 const usb_direction_t dir = (index >> 7) ? USB_DIRECTION_IN : USB_DIRECTION_OUT; 238 239 endpoint_t *ep = bus_find_endpoint(dev, ep_num, dir); 240 reset_cb(ep); 241 } 241 242 break; 242 243 case USB_DEVREQ_SET_CONFIGURATION: … … 248 249 * interface of an already setup device. */ 249 250 if (!(request->request_type & SETUP_REQUEST_TYPE_DEVICE_TO_HOST)) 250 return RESET_ALL; 251 for (usb_endpoint_t i = 0; i < 2 * USB_ENDPOINT_MAX; ++i) 252 if (dev->endpoints[i]) 253 reset_cb(dev->endpoints[i]); 251 254 break; 252 255 default: 253 256 break; 254 257 } 255 256 return RESET_NONE;257 }258 259 void hc_reset_toggles(const usb_transfer_batch_t *batch, endpoint_reset_toggle_t reset_cb)260 {261 assert(reset_cb);262 assert(batch->ep);263 assert(batch->ep->device);264 265 if (batch->error != EOK)266 return;267 268 toggle_reset_mode_t mode = get_request_toggle_reset_mode(batch);269 270 if (mode == RESET_NONE)271 return;272 273 if (mode == RESET_ALL) {274 const device_t *dev = batch->ep->device;275 for (usb_endpoint_t i = 0; i < 2 * USB_ENDPOINT_MAX; ++i) {276 if (dev->endpoints[i])277 reset_cb(dev->endpoints[i]);278 }279 } else {280 reset_cb(batch->ep);281 }282 258 } 283 259
Note:
See TracChangeset
for help on using the changeset viewer.