Ignore:
File:
1 edited

Legend:

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

    r48563a3 r30a4301  
    3333 */
    3434#include <errno.h>
    35 #include <str_error.h>
    3635
    3736#include <usb/debug.h>
     
    5251
    5352
    54 batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
     53batch_t * batch_get(device_t *dev, usb_target_t target,
    5554    usb_transfer_type_t transfer_type, size_t max_packet_size,
    56     usb_speed_t speed, char *buffer, size_t size,
     55    dev_speed_t speed, char *buffer, size_t size,
    5756    char* setup_buffer, size_t setup_size,
    5857    usbhc_iface_transfer_in_callback_t func_in,
     
    129128        instance->buffer_size = size;
    130129        instance->setup_size = setup_size;
    131         instance->fun = fun;
     130        instance->dev = dev;
    132131        instance->arg = arg;
    133132        instance->speed = speed;
     
    140139{
    141140        assert(instance);
    142         usb_log_debug2("Batch(%p) checking %d packet(s) for completion.\n",
     141        usb_log_debug("Checking(%p) %d packet for completion.\n",
    143142            instance, instance->packets);
    144143        instance->transfered_size = 0;
     
    152151                        if (i > 0)
    153152                                instance->transfered_size -= instance->setup_size;
    154                         usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
    155                           instance, i, instance->tds[i].status);
    156153                        return true;
    157154                }
     
    159156                    transfer_descriptor_actual_size(&instance->tds[i]);
    160157        }
     158        /* This is just an ugly trick to support the old API */
    161159        instance->transfered_size -= instance->setup_size;
    162160        return true;
     
    170168        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    171169
    172         const bool low_speed = instance->speed == USB_SPEED_LOW;
    173170        int toggle = 0;
    174171        /* setup stage */
    175172        transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    176             instance->setup_size, toggle, false, low_speed,
    177             instance->target, USB_PID_SETUP, instance->setup_buffer,
    178             &instance->tds[1]);
     173            instance->setup_size, toggle, false, instance->target,
     174            USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]);
    179175
    180176        /* data stage */
     
    186182
    187183                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    188                     instance->max_packet_size, toggle++, false, low_speed,
    189                     instance->target, USB_PID_OUT, data, &instance->tds[i + 1]);
     184                    instance->max_packet_size, toggle++, false, instance->target,
     185                    USB_PID_OUT, data, &instance->tds[i + 1]);
    190186        }
    191187
     
    193189        i = instance->packets - 1;
    194190        transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    195             0, 1, false, low_speed, instance->target, USB_PID_IN, NULL, NULL);
     191            0, 1, false, instance->target, USB_PID_IN, NULL, NULL);
    196192
    197193        instance->tds[i].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
    198         usb_log_debug("Control write last TD status: %x.\n",
    199                 instance->tds[i].status);
    200194
    201195        instance->next_step = batch_call_out_and_dispose;
     
    207201        assert(instance);
    208202
    209         const bool low_speed = instance->speed == USB_SPEED_LOW;
    210203        int toggle = 0;
    211204        /* setup stage */
    212205        transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    213             instance->setup_size, toggle, false, low_speed, instance->target,
     206            instance->setup_size, toggle, false, instance->target,
    214207            USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]);
    215208
     
    222215
    223216                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    224                     instance->max_packet_size, toggle, false, low_speed,
    225                                 instance->target, USB_PID_IN, data, &instance->tds[i + 1]);
     217                    instance->max_packet_size, toggle, false, instance->target,
     218                    USB_PID_IN, data, &instance->tds[i + 1]);
    226219        }
    227220
     
    229222        i = instance->packets - 1;
    230223        transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    231             0, 1, false, low_speed, instance->target, USB_PID_OUT, NULL, NULL);
     224            0, 1, false, instance->target, USB_PID_OUT, NULL, NULL);
    232225
    233226        instance->tds[i].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
    234         usb_log_debug("Control read last TD status: %x.\n",
    235                 instance->tds[i].status);
    236227
    237228        instance->next_step = batch_call_in_and_dispose;
     
    243234        assert(instance);
    244235
    245         const bool low_speed = instance->speed == USB_SPEED_LOW;
    246236        int toggle = 1;
    247237        size_t i = 0;
     
    254244
    255245                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    256                     instance->max_packet_size, toggle, false, low_speed,
    257                     instance->target, USB_PID_IN, data, next);
     246                    instance->max_packet_size, toggle, false, instance->target,
     247                    USB_PID_IN, data, next);
    258248        }
    259249
     
    270260        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    271261
    272         const bool low_speed = instance->speed == USB_SPEED_LOW;
    273262        int toggle = 1;
    274263        size_t i = 0;
     
    281270
    282271                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
    283                     instance->max_packet_size, toggle++, false, low_speed,
    284                     instance->target, USB_PID_OUT, data, next);
     272                    instance->max_packet_size, toggle++, false, instance->target,
     273                    USB_PID_OUT, data, next);
    285274        }
    286275
     
    299288
    300289        int err = instance->error;
    301         usb_log_info("Batch(%p) callback IN(type:%d): %s(%d), %zu.\n",
    302             instance, instance->transfer_type, str_error(err), err,
    303             instance->transfered_size);
    304 
    305         instance->callback_in(instance->fun,
     290        usb_log_info("Callback IN(%d): %d, %zu.\n", instance->transfer_type,
     291            err, instance->transfered_size);
     292
     293        instance->callback_in(instance->dev,
    306294            err, instance->transfered_size,
    307295            instance->arg);
     
    314302
    315303        int err = instance->error;
    316         usb_log_info("Batch(%p) callback OUT(type:%d): %s(%d).\n",
    317             instance, instance->transfer_type, str_error(err), err);
    318         instance->callback_out(instance->fun,
     304        usb_log_info("Callback OUT(%d): %d.\n", instance->transfer_type, err);
     305        instance->callback_out(instance->dev,
    319306            err, instance->arg);
    320307}
     
    324311        assert(instance);
    325312        batch_call_in(instance);
    326         usb_log_debug("Batch(%p) disposing.\n", instance);
     313        usb_log_debug("Disposing batch: %p.\n", instance);
    327314        free32(instance->tds);
    328315        free32(instance->qh);
     
    336323        assert(instance);
    337324        batch_call_out(instance);
    338         usb_log_debug("Batch(%p) disposing.\n", instance);
     325        usb_log_debug("Disposing batch: %p.\n", instance);
    339326        free32(instance->tds);
    340327        free32(instance->qh);
     
    347334{
    348335        assert(instance);
    349         uhci_t *hc = fun_to_uhci(instance->fun);
     336        uhci_t *hc = dev_to_uhci(instance->dev);
    350337        assert(hc);
    351338        return uhci_schedule(hc, instance);
     339}
     340/*----------------------------------------------------------------------------*/
     341/* DEPRECATED FUNCTIONS NEEDED BY THE OLD API */
     342void batch_control_setup_old(batch_t *instance)
     343{
     344        assert(instance);
     345        instance->packets = 1;
     346
     347        /* setup stage */
     348        transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
     349            instance->setup_size, 0, false, instance->target,
     350            USB_PID_SETUP, instance->setup_buffer, NULL);
     351
     352        instance->next_step = batch_call_out_and_dispose;
     353        batch_schedule(instance);
     354}
     355/*----------------------------------------------------------------------------*/
     356void batch_control_write_data_old(batch_t *instance)
     357{
     358        assert(instance);
     359        instance->packets -= 2;
     360        batch_interrupt_out(instance);
     361}
     362/*----------------------------------------------------------------------------*/
     363void batch_control_read_data_old(batch_t *instance)
     364{
     365        assert(instance);
     366        instance->packets -= 2;
     367        batch_interrupt_in(instance);
     368}
     369/*----------------------------------------------------------------------------*/
     370void batch_control_write_status_old(batch_t *instance)
     371{
     372        assert(instance);
     373        instance->packets = 1;
     374        transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
     375            0, 1, false, instance->target, USB_PID_IN, NULL, NULL);
     376        instance->next_step = batch_call_in_and_dispose;
     377        batch_schedule(instance);
     378}
     379/*----------------------------------------------------------------------------*/
     380void batch_control_read_status_old(batch_t *instance)
     381{
     382        assert(instance);
     383        instance->packets = 1;
     384        transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
     385            0, 1, false, instance->target, USB_PID_OUT, NULL, NULL);
     386        instance->next_step = batch_call_out_and_dispose;
     387        batch_schedule(instance);
    352388}
    353389/**
Note: See TracChangeset for help on using the changeset viewer.