Changes in uspace/drv/uhci-hcd/iface.c [92d6868:c61338a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/iface.c
r92d6868 rc61338a 36 36 37 37 #include <usb/debug.h> 38 #include <usb/host/endpoint.h>39 38 40 39 #include "iface.h" … … 55 54 usb_device_keeper_reserve_default_address(&hc->manager, speed); 56 55 return EOK; 57 #if 058 endpoint_t *ep = malloc(sizeof(endpoint_t));59 if (ep == NULL)60 return ENOMEM;61 const size_t max_packet_size = speed == USB_SPEED_LOW ? 8 : 64;62 endpoint_init(ep, USB_TRANSFER_CONTROL, speed, max_packet_size);63 int ret;64 try_retgister:65 ret = usb_endpoint_manager_register_ep(&hc->ep_manager,66 USB_ADDRESS_DEFAULT, 0, USB_DIRECTION_BOTH, ep, endpoint_destroy, 0);67 if (ret == EEXISTS) {68 async_usleep(1000);69 goto try_retgister;70 }71 if (ret != EOK) {72 endpoint_destroy(ep);73 }74 return ret;75 #endif76 56 } 77 57 /*----------------------------------------------------------------------------*/ … … 87 67 assert(hc); 88 68 usb_log_debug("Default address release.\n"); 89 // return usb_endpoint_manager_unregister_ep(&hc->ep_manager,90 // USB_ADDRESS_DEFAULT, 0, USB_DIRECTION_BOTH);91 69 usb_device_keeper_release_default_address(&hc->manager); 92 70 return EOK; … … 150 128 } 151 129 /*----------------------------------------------------------------------------*/ 152 static int register_endpoint(153 ddf_fun_t *fun, usb_address_t address, usb_endpoint_t endpoint,154 usb_transfer_type_t transfer_type, usb_direction_t direction,155 size_t max_packet_size, unsigned int interval)156 {157 hc_t *hc = fun_to_hc(fun);158 assert(hc);159 const usb_speed_t speed =160 usb_device_keeper_get_speed(&hc->manager, address);161 const size_t size =162 (transfer_type == USB_TRANSFER_INTERRUPT163 || transfer_type == USB_TRANSFER_ISOCHRONOUS) ?164 max_packet_size : 0;165 int ret;166 167 endpoint_t *ep = malloc(sizeof(endpoint_t));168 if (ep == NULL)169 return ENOMEM;170 ret = endpoint_init(ep, address, endpoint, direction,171 transfer_type, speed, max_packet_size);172 if (ret != EOK) {173 free(ep);174 return ret;175 }176 177 usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n",178 address, endpoint, usb_str_transfer_type(transfer_type),179 usb_str_speed(speed), direction, size, max_packet_size, interval);180 181 ret = usb_endpoint_manager_register_ep(&hc->ep_manager, ep, size);182 if (ret != EOK) {183 endpoint_destroy(ep);184 } else {185 usb_device_keeper_add_ep(&hc->manager, address, ep);186 }187 return ret;188 }189 /*----------------------------------------------------------------------------*/190 static int unregister_endpoint(191 ddf_fun_t *fun, usb_address_t address,192 usb_endpoint_t endpoint, usb_direction_t direction)193 {194 hc_t *hc = fun_to_hc(fun);195 assert(hc);196 usb_log_debug("Unregister endpoint %d:%d %d.\n",197 address, endpoint, direction);198 return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address,199 endpoint, direction);200 }201 /*----------------------------------------------------------------------------*/202 130 /** Interrupt out transaction interface function 203 131 * … … 218 146 hc_t *hc = fun_to_hc(fun); 219 147 assert(hc); 148 usb_speed_t speed = 149 usb_device_keeper_get_speed(&hc->manager, target.address); 220 150 221 151 usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n", 222 152 target.address, target.endpoint, size, max_packet_size); 223 153 224 size_t res_bw; 225 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 226 target.address, target.endpoint, USB_DIRECTION_OUT, &res_bw); 227 if (ep == NULL) { 228 usb_log_error("Endpoint(%d:%d) not registered for INT OUT.\n", 229 target.address, target.endpoint); 230 return ENOENT; 231 } 232 const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type, 233 size, ep->max_packet_size); 234 if (res_bw < bw) 235 { 236 usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw " 237 "but only %zu is reserved.\n", 238 target.address, target.endpoint, bw, res_bw); 239 return ENOENT; 240 } 241 assert(ep->speed == 242 usb_device_keeper_get_speed(&hc->manager, target.address)); 243 assert(ep->max_packet_size == max_packet_size); 244 assert(ep->transfer_type == USB_TRANSFER_INTERRUPT); 245 246 usb_transfer_batch_t *batch = 247 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 248 ep->speed, data, size, NULL, 0, NULL, callback, arg, ep); 154 usb_transfer_batch_t *batch = 155 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size, 156 speed, data, size, NULL, 0, NULL, callback, arg, &hc->manager); 249 157 if (!batch) 250 158 return ENOMEM; … … 275 183 hc_t *hc = fun_to_hc(fun); 276 184 assert(hc); 277 185 usb_speed_t speed = 186 usb_device_keeper_get_speed(&hc->manager, target.address); 278 187 usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n", 279 188 target.address, target.endpoint, size, max_packet_size); 280 189 281 size_t res_bw; 282 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 283 target.address, target.endpoint, USB_DIRECTION_IN, &res_bw); 284 if (ep == NULL) { 285 usb_log_error("Endpoint(%d:%d) not registered for INT IN.\n", 286 target.address, target.endpoint); 287 return ENOENT; 288 } 289 const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type, 290 size, ep->max_packet_size); 291 if (res_bw < bw) 292 { 293 usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw " 294 "but only %zu bw is reserved.\n", 295 target.address, target.endpoint, bw, res_bw); 296 return ENOENT; 297 } 298 299 assert(ep->speed == 300 usb_device_keeper_get_speed(&hc->manager, target.address)); 301 assert(ep->max_packet_size == max_packet_size); 302 assert(ep->transfer_type == USB_TRANSFER_INTERRUPT); 303 304 usb_transfer_batch_t *batch = 305 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 306 ep->speed, data, size, NULL, 0, callback, NULL, arg, ep); 190 usb_transfer_batch_t *batch = 191 batch_get(fun, target, USB_TRANSFER_INTERRUPT, max_packet_size, 192 speed, data, size, NULL, 0, callback, NULL, arg, &hc->manager); 307 193 if (!batch) 308 194 return ENOMEM; … … 333 219 hc_t *hc = fun_to_hc(fun); 334 220 assert(hc); 221 usb_speed_t speed = 222 usb_device_keeper_get_speed(&hc->manager, target.address); 335 223 336 224 usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n", 337 225 target.address, target.endpoint, size, max_packet_size); 338 226 339 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 340 target.address, target.endpoint, USB_DIRECTION_OUT, NULL); 341 if (ep == NULL) { 342 usb_log_error("Endpoint(%d:%d) not registered for BULK OUT.\n", 343 target.address, target.endpoint); 344 return ENOENT; 345 } 346 assert(ep->speed == 347 usb_device_keeper_get_speed(&hc->manager, target.address)); 348 assert(ep->max_packet_size == max_packet_size); 349 assert(ep->transfer_type == USB_TRANSFER_BULK); 350 351 usb_transfer_batch_t *batch = 352 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 353 ep->speed, data, size, NULL, 0, NULL, callback, arg, ep); 227 usb_transfer_batch_t *batch = 228 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed, 229 data, size, NULL, 0, NULL, callback, arg, &hc->manager); 354 230 if (!batch) 355 231 return ENOMEM; … … 380 256 hc_t *hc = fun_to_hc(fun); 381 257 assert(hc); 258 usb_speed_t speed = 259 usb_device_keeper_get_speed(&hc->manager, target.address); 382 260 usb_log_debug("Bulk IN %d:%d %zu(%zu).\n", 383 261 target.address, target.endpoint, size, max_packet_size); 384 262 385 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager, 386 target.address, target.endpoint, USB_DIRECTION_IN, NULL); 387 if (ep == NULL) { 388 usb_log_error("Endpoint(%d:%d) not registered for BULK IN.\n", 389 target.address, target.endpoint); 390 return ENOENT; 391 } 392 assert(ep->speed == 393 usb_device_keeper_get_speed(&hc->manager, target.address)); 394 assert(ep->max_packet_size == max_packet_size); 395 assert(ep->transfer_type == USB_TRANSFER_BULK); 396 397 usb_transfer_batch_t *batch = 398 batch_get(fun, target, ep->transfer_type, ep->max_packet_size, 399 ep->speed, data, size, NULL, 0, callback, NULL, arg, ep); 263 usb_transfer_batch_t *batch = 264 batch_get(fun, target, USB_TRANSFER_BULK, max_packet_size, speed, 265 data, size, NULL, 0, callback, NULL, arg, &hc->manager); 400 266 if (!batch) 401 267 return ENOMEM; … … 433 299 usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n", 434 300 speed, target.address, target.endpoint, size, max_packet_size); 435 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,436 target.address, target.endpoint, USB_DIRECTION_BOTH, NULL);437 if (ep == NULL) {438 usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n",439 target.address, target.endpoint);440 }441 301 442 302 if (setup_size != 8) … … 445 305 usb_transfer_batch_t *batch = 446 306 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed, 447 data, size, setup_data, setup_size, NULL, callback, arg, ep); 307 data, size, setup_data, setup_size, NULL, callback, arg, 308 &hc->manager); 448 309 if (!batch) 449 310 return ENOMEM; … … 483 344 usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n", 484 345 speed, target.address, target.endpoint, size, max_packet_size); 485 endpoint_t *ep = usb_endpoint_manager_get_ep(&hc->ep_manager,486 target.address, target.endpoint, USB_DIRECTION_BOTH, NULL);487 if (ep == NULL) {488 usb_log_warning("Endpoint(%d:%d) not registered for CONTROL.\n",489 target.address, target.endpoint);490 }491 346 usb_transfer_batch_t *batch = 492 347 batch_get(fun, target, USB_TRANSFER_CONTROL, max_packet_size, speed, 493 data, size, setup_data, setup_size, callback, NULL, arg, ep); 348 data, size, setup_data, setup_size, callback, NULL, arg, 349 &hc->manager); 494 350 if (!batch) 495 351 return ENOMEM; … … 509 365 .release_address = release_address, 510 366 511 .register_endpoint = register_endpoint,512 .unregister_endpoint = unregister_endpoint,513 514 367 .interrupt_out = interrupt_out, 515 368 .interrupt_in = interrupt_in,
Note:
See TracChangeset
for help on using the changeset viewer.