Changes in / [80fdffe:03f7952] in mainline


Ignore:
Location:
uspace/drv/uhci-hcd
Files:
4 edited

Legend:

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

    r80fdffe r03f7952  
    4949static void batch_control(
    5050    batch_t *instance, int data_stage, int status_stage);
    51 static void batch_data(batch_t *instance, int pid);
    5251static void batch_call_in(batch_t *instance);
    5352static void batch_call_out(batch_t *instance);
     
    193192{
    194193        assert(instance);
    195         batch_data(instance, USB_PID_IN);
     194
     195        const bool low_speed = instance->speed == USB_SPEED_LOW;
     196        int toggle = 1;
     197        size_t i = 0;
     198        for (;i < instance->packets; ++i) {
     199                char *data =
     200                    instance->transport_buffer + (i  * instance->max_packet_size);
     201                transfer_descriptor_t *next = (i + 1) < instance->packets ?
     202                    &instance->tds[i + 1] : NULL;
     203                toggle = 1 - toggle;
     204
     205                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
     206                    instance->max_packet_size, toggle, false, low_speed,
     207                    instance->target, USB_PID_IN, data, next);
     208        }
     209
     210        instance->tds[i - 1].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
     211
    196212        instance->next_step = batch_call_in_and_dispose;
    197213        usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance);
     
    203219        assert(instance);
    204220        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    205         batch_data(instance, USB_PID_OUT);
     221
     222        const bool low_speed = instance->speed == USB_SPEED_LOW;
     223        int toggle = 1;
     224        size_t i = 0;
     225        for (;i < instance->packets; ++i) {
     226                char *data =
     227                    instance->transport_buffer + (i  * instance->max_packet_size);
     228                transfer_descriptor_t *next = (i + 1) < instance->packets ?
     229                    &instance->tds[i + 1] : NULL;
     230                toggle = 1 - toggle;
     231
     232                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
     233                    instance->max_packet_size, toggle++, false, low_speed,
     234                    instance->target, USB_PID_OUT, data, next);
     235        }
     236
     237        instance->tds[i - 1].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
     238
    206239        instance->next_step = batch_call_out_and_dispose;
    207240        usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance);
    208241        batch_schedule(instance);
    209 }
    210 /*----------------------------------------------------------------------------*/
    211 void batch_bulk_in(batch_t *instance)
    212 {
    213         assert(instance);
    214         batch_data(instance, USB_PID_IN);
    215         instance->next_step = batch_call_in_and_dispose;
    216         usb_log_debug("Batch(%p) BULK IN initialized.\n", instance);
    217         batch_schedule(instance);
    218 }
    219 /*----------------------------------------------------------------------------*/
    220 void batch_bulk_out(batch_t *instance)
    221 {
    222         assert(instance);
    223         memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    224         batch_data(instance, USB_PID_OUT);
    225         instance->next_step = batch_call_out_and_dispose;
    226         usb_log_debug("Batch(%p) BULK OUT initialized.\n", instance);
    227         batch_schedule(instance);
    228 }
    229 /*----------------------------------------------------------------------------*/
    230 static void batch_data(batch_t *instance, int pid)
    231 {
    232         assert(instance);
    233         const bool low_speed = instance->speed == USB_SPEED_LOW;
    234         int toggle = 1;
    235 
    236         size_t packet = 0;
    237         size_t remain_size = instance->buffer_size;
    238         while (remain_size > 0) {
    239                 char *data =
    240                     instance->transport_buffer + instance->buffer_size
    241                     - remain_size;
    242 
    243                 toggle = 1 - toggle;
    244 
    245                 const size_t packet_size =
    246                     (instance->max_packet_size > remain_size) ?
    247                     remain_size : instance->max_packet_size;
    248 
    249                 transfer_descriptor_init(&instance->tds[packet],
    250                     DEFAULT_ERROR_COUNT, packet_size, toggle, false, low_speed,
    251                     instance->target, pid, data,
    252                     &instance->tds[packet + 1]);
    253 
    254                 ++packet;
    255                 assert(packet <= instance->packets);
    256                 assert(packet_size <= remain_size);
    257                 remain_size -= packet_size;
    258         }
    259 
    260         instance->tds[packet - 1].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
    261         instance->tds[packet - 1].next = 0 | LINK_POINTER_TERMINATE_FLAG;
    262242}
    263243/*----------------------------------------------------------------------------*/
  • uspace/drv/uhci-hcd/batch.h

    r80fdffe r03f7952  
    8686void batch_interrupt_out(batch_t *instance);
    8787
    88 void batch_bulk_in(batch_t *instance);
     88/* DEPRECATED FUNCTIONS NEEDED BY THE OLD API */
     89void batch_control_setup_old(batch_t *instance);
    8990
    90 void batch_bulk_out(batch_t *instance);
     91void batch_control_write_data_old(batch_t *instance);
     92
     93void batch_control_read_data_old(batch_t *instance);
     94
     95void batch_control_write_status_old(batch_t *instance);
     96
     97void batch_control_read_status_old(batch_t *instance);
    9198#endif
    9299/**
  • uspace/drv/uhci-hcd/iface.c

    r80fdffe r03f7952  
    140140}
    141141/*----------------------------------------------------------------------------*/
    142 static int bulk_out(ddf_fun_t *fun, usb_target_t target,
    143     size_t max_packet_size, void *data, size_t size,
    144     usbhc_iface_transfer_out_callback_t callback, void *arg)
    145 {
    146         assert(fun);
    147         uhci_t *hc = fun_to_uhci(fun);
    148         assert(hc);
    149         usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
    150 
    151         usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n",
    152             target.address, target.endpoint, size, max_packet_size);
    153 
    154         batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
    155             max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
    156         if (!batch)
    157                 return ENOMEM;
    158         batch_bulk_out(batch);
    159         return EOK;
    160 }
    161 /*----------------------------------------------------------------------------*/
    162 static int bulk_in(ddf_fun_t *fun, usb_target_t target,
    163     size_t max_packet_size, void *data, size_t size,
    164     usbhc_iface_transfer_in_callback_t callback, void *arg)
    165 {
    166         assert(fun);
    167         uhci_t *hc = fun_to_uhci(fun);
    168         assert(hc);
    169         usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
    170         usb_log_debug("Bulk IN %d:%d %zu(%zu).\n",
    171             target.address, target.endpoint, size, max_packet_size);
    172 
    173         batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
    174             max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg);
    175         if (!batch)
    176                 return ENOMEM;
    177         batch_bulk_in(batch);
    178         return EOK;
    179 }
    180 /*----------------------------------------------------------------------------*/
    181142static int control_write(ddf_fun_t *fun, usb_target_t target,
    182143    size_t max_packet_size,
     
    220181        return EOK;
    221182}
     183
     184
    222185/*----------------------------------------------------------------------------*/
    223186usbhc_iface_t uhci_iface = {
     
    231194        .interrupt_in = interrupt_in,
    232195
    233         .bulk_in = bulk_in,
    234         .bulk_out = bulk_out,
    235 
    236196        .control_read = control_read,
    237197        .control_write = control_write,
  • uspace/drv/uhci-hcd/uhci.c

    r80fdffe r03f7952  
    336336                uhci_interrupt(instance, status);
    337337                pio_write_16(&instance->registers->usbsts, 0x1f);
    338                 async_usleep(UHCI_CLEANER_TIMEOUT);
     338                async_usleep(UHCI_CLEANER_TIMEOUT * 5);
    339339        }
    340340        return EOK;
Note: See TracChangeset for help on using the changeset viewer.