Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/iface.c

    r92d6868 rc61338a  
    3636
    3737#include <usb/debug.h>
    38 #include <usb/host/endpoint.h>
    3938
    4039#include "iface.h"
     
    5554        usb_device_keeper_reserve_default_address(&hc->manager, speed);
    5655        return EOK;
    57 #if 0
    58         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 #endif
    7656}
    7757/*----------------------------------------------------------------------------*/
     
    8767        assert(hc);
    8868        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);
    9169        usb_device_keeper_release_default_address(&hc->manager);
    9270        return EOK;
     
    150128}
    151129/*----------------------------------------------------------------------------*/
    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_INTERRUPT
    163             || 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 /*----------------------------------------------------------------------------*/
    202130/** Interrupt out transaction interface function
    203131 *
     
    218146        hc_t *hc = fun_to_hc(fun);
    219147        assert(hc);
     148        usb_speed_t speed =
     149            usb_device_keeper_get_speed(&hc->manager, target.address);
    220150
    221151        usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n",
    222152            target.address, target.endpoint, size, max_packet_size);
    223153
    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);
    249157        if (!batch)
    250158                return ENOMEM;
     
    275183        hc_t *hc = fun_to_hc(fun);
    276184        assert(hc);
    277 
     185        usb_speed_t speed =
     186            usb_device_keeper_get_speed(&hc->manager, target.address);
    278187        usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n",
    279188            target.address, target.endpoint, size, max_packet_size);
    280189
    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);
    307193        if (!batch)
    308194                return ENOMEM;
     
    333219        hc_t *hc = fun_to_hc(fun);
    334220        assert(hc);
     221        usb_speed_t speed =
     222            usb_device_keeper_get_speed(&hc->manager, target.address);
    335223
    336224        usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n",
    337225            target.address, target.endpoint, size, max_packet_size);
    338226
    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);
    354230        if (!batch)
    355231                return ENOMEM;
     
    380256        hc_t *hc = fun_to_hc(fun);
    381257        assert(hc);
     258        usb_speed_t speed =
     259            usb_device_keeper_get_speed(&hc->manager, target.address);
    382260        usb_log_debug("Bulk IN %d:%d %zu(%zu).\n",
    383261            target.address, target.endpoint, size, max_packet_size);
    384262
    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);
    400266        if (!batch)
    401267                return ENOMEM;
     
    433299        usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n",
    434300            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         }
    441301
    442302        if (setup_size != 8)
     
    445305        usb_transfer_batch_t *batch =
    446306            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);
    448309        if (!batch)
    449310                return ENOMEM;
     
    483344        usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n",
    484345            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         }
    491346        usb_transfer_batch_t *batch =
    492347            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);
    494350        if (!batch)
    495351                return ENOMEM;
     
    509365        .release_address = release_address,
    510366
    511         .register_endpoint = register_endpoint,
    512         .unregister_endpoint = unregister_endpoint,
    513 
    514367        .interrupt_out = interrupt_out,
    515368        .interrupt_in = interrupt_in,
Note: See TracChangeset for help on using the changeset viewer.