Changeset 1d758fc in mainline for uspace/lib/usbhost/src/endpoint.c
- Timestamp:
- 2018-02-12T10:11:47Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5fe3f954
- Parents:
- 2f762a7
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-02-05 03:28:50)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-02-12 10:11:47)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/endpoint.c
r2f762a7 r1d758fc 75 75 ep->max_transfer_size = ep->max_packet_size * ep->packets_per_uframe; 76 76 ep->transfer_buffer_policy = DMA_POLICY_STRICT; 77 ep->required_transfer_buffer_policy = DMA_POLICY_STRICT; 77 78 } 78 79 … … 207 208 * 208 209 * @param endpoint Endpoint for which to send the batch 209 * @param target The target of the transfer. 210 * @param direction A direction of the transfer. 211 * @param data A pointer to the data buffer. 212 * @param size Size of the data buffer. 213 * @param setup_data Data to use in the setup stage (Control communication type) 214 * @param on_complete Callback which is called after the batch is complete 215 * @param arg Callback parameter. 216 * @param name Communication identifier (for nicer output). 217 */ 218 errno_t endpoint_send_batch(endpoint_t *ep, usb_target_t target, 219 usb_direction_t direction, char *data, size_t size, uint64_t setup_data, 220 usbhc_iface_transfer_callback_t on_complete, void *arg, const char *name) 221 { 222 if (!ep) 223 return EBADMEM; 210 */ 211 errno_t endpoint_send_batch(endpoint_t *ep, const transfer_request_t *req) 212 { 213 assert(ep); 214 assert(req); 224 215 225 216 if (ep->transfer_type == USB_TRANSFER_CONTROL) { 226 usb_log_debug("%s %d:%d %zu/%zuB, setup %#016" PRIx64, name, 227 target.address, target.endpoint, size, ep->max_packet_size, 228 setup_data); 217 usb_log_debug("%s %d:%d %zu/%zuB, setup %#016" PRIx64, req->name, 218 req->target.address, req->target.endpoint, 219 req->size, ep->max_packet_size, 220 req->setup); 229 221 } else { 230 usb_log_debug("%s %d:%d %zu/%zuB", name, target.address, 231 target.endpoint, size, ep->max_packet_size); 222 usb_log_debug("%s %d:%d %zu/%zuB", req->name, 223 req->target.address, req->target.endpoint, 224 req->size, ep->max_packet_size); 232 225 } 233 226 … … 244 237 } 245 238 239 size_t size = req->size; 246 240 /* 247 241 * Limit transfers with reserved bandwidth to the amount reserved. 248 242 * OUT transfers are rejected, IN can be just trimmed in advance. 249 243 */ 250 if ((ep->transfer_type == USB_TRANSFER_INTERRUPT || ep->transfer_type == USB_TRANSFER_ISOCHRONOUS) && size > ep->max_transfer_size) { 251 if (direction == USB_DIRECTION_OUT) 244 if (size > ep->max_transfer_size && 245 (ep->transfer_type == USB_TRANSFER_INTERRUPT 246 || ep->transfer_type == USB_TRANSFER_ISOCHRONOUS)) { 247 if (req->dir == USB_DIRECTION_OUT) 252 248 return ENOSPC; 253 249 else 254 250 size = ep->max_transfer_size; 255 256 251 } 257 252 … … 266 261 } 267 262 268 batch->target = target; 269 batch->setup.packed = setup_data; 270 batch->dir = direction; 271 batch->buffer_size = size; 272 273 errno_t err; 274 if ((err = usb_transfer_batch_prepare_buffer(batch, data))) { 275 usb_log_warning("Failed to prepare buffer for batch: %s", str_error(err)); 276 usb_transfer_batch_destroy(batch); 277 return err; 278 } 279 280 batch->on_complete = on_complete; 281 batch->on_complete_data = arg; 263 batch->target = req->target; 264 batch->setup.packed = req->setup; 265 batch->dir = req->dir; 266 batch->size = size; 267 batch->offset = req->offset; 268 batch->dma_buffer = req->buffer; 269 270 dma_buffer_acquire(&batch->dma_buffer); 271 272 if (batch->offset != 0) { 273 usb_log_debug("A transfer with nonzero offset requested."); 274 usb_transfer_batch_bounce(batch); 275 } 276 277 if (usb_transfer_batch_bounce_required(batch)) 278 usb_transfer_batch_bounce(batch); 279 280 batch->on_complete = req->on_complete; 281 batch->on_complete_data = req->arg; 282 282 283 283 const int ret = ops->batch_schedule(batch);
Note:
See TracChangeset
for help on using the changeset viewer.