Changeset d9b2c73 in mainline for uspace/lib/usbhost/src/hcd.c
- Timestamp:
- 2012-12-20T13:22:34Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d09791e6
- Parents:
- 8f68913f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/hcd.c
r8f68913f rd9b2c73 184 184 } 185 185 186 /** Prepare generic usb_transfer_batch and schedule it. 187 * @param hcd Host controller driver. 188 * @param fun DDF fun 189 * @param target address and endpoint number. 190 * @param setup_data Data to use in setup stage (Control communication type) 191 * @param in Callback for device to host communication. 192 * @param out Callback for host to device communication. 193 * @param arg Callback parameter. 194 * @param name Communication identifier (for nicer output). 195 * @return Error code. 196 */ 197 int hcd_send_batch( 198 hcd_t *hcd, ddf_fun_t *fun, usb_target_t target, usb_direction_t direction, 199 void *data, size_t size, uint64_t setup_data, 200 usbhc_iface_transfer_in_callback_t in, 201 usbhc_iface_transfer_out_callback_t out, void *arg, const char* name) 202 { 203 assert(hcd); 204 205 endpoint_t *ep = usb_endpoint_manager_find_ep(&hcd->ep_manager, 206 target.address, target.endpoint, direction); 207 if (ep == NULL) { 208 usb_log_error("Endpoint(%d:%d) not registered for %s.\n", 209 target.address, target.endpoint, name); 210 return ENOENT; 211 } 212 213 usb_log_debug2("%s %d:%d %zu(%zu).\n", 214 name, target.address, target.endpoint, size, ep->max_packet_size); 215 216 const size_t bw = bandwidth_count_usb11( 217 ep->speed, ep->transfer_type, size, ep->max_packet_size); 218 /* Check if we have enough bandwidth reserved */ 219 if (ep->bandwidth < bw) { 220 usb_log_error("Endpoint(%d:%d) %s needs %zu bw " 221 "but only %zu is reserved.\n", 222 ep->address, ep->endpoint, name, bw, ep->bandwidth); 223 return ENOSPC; 224 } 225 if (!hcd->schedule) { 226 usb_log_error("HCD does not implement scheduler.\n"); 227 return ENOTSUP; 228 } 229 230 /* No private data and no private data dtor */ 231 usb_transfer_batch_t *batch = 232 usb_transfer_batch_create(ep, data, size, setup_data, 233 in, out, arg, fun, NULL, NULL); 234 if (!batch) { 235 return ENOMEM; 236 } 237 238 const int ret = hcd->schedule(hcd, batch); 239 if (ret != EOK) 240 usb_transfer_batch_destroy(batch); 241 242 return ret; 243 } 244 245 186 246 /** Announce root hub to the DDF 187 247 *
Note:
See TracChangeset
for help on using the changeset viewer.