Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 84439d7 in mainline for uspace/drv/vhc/connhost.c


Ignore:
Timestamp:
2010-12-05T09:34:46Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
75732da
Parents:
56b962d (diff), 35537a7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge with development/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/vhc/connhost.c

    r56b962d r84439d7  
    4343typedef struct {
    4444        usb_direction_t direction;
    45         usb_hcd_transfer_callback_out_t out_callback;
    46         usb_hcd_transfer_callback_in_t in_callback;
    47         usb_hc_device_t *hc;
     45        usbhc_iface_transfer_out_callback_t out_callback;
     46        usbhc_iface_transfer_in_callback_t in_callback;
     47        device_t *dev;
    4848        void *arg;
    4949} transfer_info_t;
     
    5656        switch (transfer->direction) {
    5757                case USB_DIRECTION_IN:
    58                         transfer->in_callback(transfer->hc,
     58                        transfer->in_callback(transfer->dev,
    5959                            size, outcome,
    6060                            transfer->arg);
    6161                        break;
    6262                case USB_DIRECTION_OUT:
    63                         transfer->out_callback(transfer->hc,
     63                        transfer->out_callback(transfer->dev,
    6464                            outcome,
    6565                            transfer->arg);
     
    7373}
    7474
    75 static transfer_info_t *create_transfer_info(usb_hc_device_t *hc,
     75static transfer_info_t *create_transfer_info(device_t *dev,
    7676    usb_direction_t direction, void *arg)
    7777{
     
    8282        transfer->out_callback = NULL;
    8383        transfer->arg = arg;
    84         transfer->hc = hc;
     84        transfer->dev = dev;
    8585
    8686        return transfer;
    8787}
    8888
    89 static int enqueue_transfer_out(usb_hc_device_t *hc,
    90     usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint,
     89static int enqueue_transfer_out(device_t *dev,
     90    usb_target_t target, usb_transfer_type_t transfer_type,
    9191    void *buffer, size_t size,
    92     usb_hcd_transfer_callback_out_t callback, void *arg)
     92    usbhc_iface_transfer_out_callback_t callback, void *arg)
    9393{
    9494        printf(NAME ": transfer OUT [%d.%d (%s); %u]\n",
    95             dev->address, endpoint->endpoint,
    96             usb_str_transfer_type(endpoint->transfer_type),
     95            target.address, target.endpoint,
     96            usb_str_transfer_type(transfer_type),
    9797            size);
    9898
    9999        transfer_info_t *transfer
    100             = create_transfer_info(hc, USB_DIRECTION_OUT, arg);
     100            = create_transfer_info(dev, USB_DIRECTION_OUT, arg);
    101101        transfer->out_callback = callback;
    102 
    103         usb_target_t target = {
    104                 .address = dev->address,
    105                 .endpoint = endpoint->endpoint
    106         };
    107102
    108103        hc_add_transaction_to_device(false, target, buffer, size,
     
    112107}
    113108
    114 static int enqueue_transfer_setup(usb_hc_device_t *hc,
    115     usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint,
     109static int enqueue_transfer_setup(device_t *dev,
     110    usb_target_t target, usb_transfer_type_t transfer_type,
    116111    void *buffer, size_t size,
    117     usb_hcd_transfer_callback_out_t callback, void *arg)
     112    usbhc_iface_transfer_out_callback_t callback, void *arg)
    118113{
    119114        printf(NAME ": transfer SETUP [%d.%d (%s); %u]\n",
    120             dev->address, endpoint->endpoint,
    121             usb_str_transfer_type(endpoint->transfer_type),
     115            target.address, target.endpoint,
     116            usb_str_transfer_type(transfer_type),
    122117            size);
    123118
    124119        transfer_info_t *transfer
    125             = create_transfer_info(hc, USB_DIRECTION_OUT, arg);
     120            = create_transfer_info(dev, USB_DIRECTION_OUT, arg);
    126121        transfer->out_callback = callback;
    127 
    128         usb_target_t target = {
    129                 .address = dev->address,
    130                 .endpoint = endpoint->endpoint
    131         };
    132122
    133123        hc_add_transaction_to_device(true, target, buffer, size,
     
    137127}
    138128
    139 static int enqueue_transfer_in(usb_hc_device_t *hc,
    140     usb_hcd_attached_device_info_t *dev, usb_hc_endpoint_info_t *endpoint,
     129static int enqueue_transfer_in(device_t *dev,
     130    usb_target_t target, usb_transfer_type_t transfer_type,
    141131    void *buffer, size_t size,
    142     usb_hcd_transfer_callback_in_t callback, void *arg)
     132    usbhc_iface_transfer_in_callback_t callback, void *arg)
    143133{
    144134        printf(NAME ": transfer IN [%d.%d (%s); %u]\n",
    145             dev->address, endpoint->endpoint,
    146             usb_str_transfer_type(endpoint->transfer_type),
     135            target.address, target.endpoint,
     136            usb_str_transfer_type(transfer_type),
    147137            size);
    148138
    149139        transfer_info_t *transfer
    150             = create_transfer_info(hc, USB_DIRECTION_IN, arg);
     140            = create_transfer_info(dev, USB_DIRECTION_IN, arg);
    151141        transfer->in_callback = callback;
    152 
    153         usb_target_t target = {
    154                 .address = dev->address,
    155                 .endpoint = endpoint->endpoint
    156         };
    157142
    158143        hc_add_transaction_from_device(target, buffer, size,
     
    163148
    164149
    165 usb_hcd_transfer_ops_t vhc_transfer_ops = {
    166         .transfer_out = enqueue_transfer_out,
    167         .transfer_in = enqueue_transfer_in,
    168         .transfer_setup = enqueue_transfer_setup
     150static int interrupt_out(device_t *dev, usb_target_t target,
     151    void *data, size_t size,
     152    usbhc_iface_transfer_out_callback_t callback, void *arg)
     153{
     154        return enqueue_transfer_out(dev, target, USB_TRANSFER_INTERRUPT,
     155            data, size,
     156            callback, arg);
     157}
     158
     159static int interrupt_in(device_t *dev, usb_target_t target,
     160    void *data, size_t size,
     161    usbhc_iface_transfer_in_callback_t callback, void *arg)
     162{
     163        return enqueue_transfer_in(dev, target, USB_TRANSFER_INTERRUPT,
     164            data, size,
     165            callback, arg);
     166}
     167
     168static int control_write_setup(device_t *dev, usb_target_t target,
     169    void *data, size_t size,
     170    usbhc_iface_transfer_out_callback_t callback, void *arg)
     171{
     172        return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL,
     173            data, size,
     174            callback, arg);
     175}
     176
     177static int control_write_data(device_t *dev, usb_target_t target,
     178    void *data, size_t size,
     179    usbhc_iface_transfer_out_callback_t callback, void *arg)
     180{
     181        return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL,
     182            data, size,
     183            callback, arg);
     184}
     185
     186static int control_write_status(device_t *dev, usb_target_t target,
     187    usbhc_iface_transfer_in_callback_t callback, void *arg)
     188{
     189        return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL,
     190            NULL, 0,
     191            callback, arg);
     192}
     193
     194static int control_read_setup(device_t *dev, usb_target_t target,
     195    void *data, size_t size,
     196    usbhc_iface_transfer_out_callback_t callback, void *arg)
     197{
     198        return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL,
     199            data, size,
     200            callback, arg);
     201}
     202
     203static int control_read_data(device_t *dev, usb_target_t target,
     204    void *data, size_t size,
     205    usbhc_iface_transfer_in_callback_t callback, void *arg)
     206{
     207        return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL,
     208            data, size,
     209            callback, arg);
     210}
     211
     212static int control_read_status(device_t *dev, usb_target_t target,
     213    usbhc_iface_transfer_out_callback_t callback, void *arg)
     214{
     215        return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL,
     216            NULL, 0,
     217            callback, arg);
     218}
     219
     220
     221usbhc_iface_t vhc_iface = {
     222        .tell_address = tell_address,
     223
     224        .reserve_default_address = reserve_default_address,
     225        .release_default_address = release_default_address,
     226        .request_address = request_address,
     227        .bind_address = bind_address,
     228        .release_address = release_address,
     229
     230        .interrupt_out = interrupt_out,
     231        .interrupt_in = interrupt_in,
     232
     233        .control_write_setup = control_write_setup,
     234        .control_write_data = control_write_data,
     235        .control_write_status = control_write_status,
     236
     237        .control_read_setup = control_read_setup,
     238        .control_read_data = control_read_data,
     239        .control_read_status = control_read_status
    169240};
    170241
Note: See TracChangeset for help on using the changeset viewer.