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

Changeset 243cb86 in mainline for uspace/drv/vhc/connhost.c


Ignore:
Timestamp:
2010-12-12T10:50:19Z (11 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master
Children:
8365533
Parents:
101ef25c (diff), ebb98c5 (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 from development + several changes to hid driver.

Changes to hid driver:

  • copied some code to usbkbd_get_descriptors() function
  • base structure for hid descriptor and report parser (files uspace/lib/usb/include/usb/classes/hidparser.h

and uspace/lib/usb/src/hidparser.c)

File:
1 edited

Legend:

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

    r101ef25c r243cb86  
    3636#include <errno.h>
    3737#include <usb/usb.h>
     38#include <usb/hcd.h>
    3839
    3940#include "vhcd.h"
     
    4344typedef struct {
    4445        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;
     46        usbhc_iface_transfer_out_callback_t out_callback;
     47        usbhc_iface_transfer_in_callback_t in_callback;
     48        device_t *dev;
    4849        void *arg;
    4950} transfer_info_t;
     
    5657        switch (transfer->direction) {
    5758                case USB_DIRECTION_IN:
    58                         transfer->in_callback(transfer->hc,
    59                             size, outcome,
     59                        transfer->in_callback(transfer->dev,
     60                            outcome, size,
    6061                            transfer->arg);
    6162                        break;
    6263                case USB_DIRECTION_OUT:
    63                         transfer->out_callback(transfer->hc,
     64                        transfer->out_callback(transfer->dev,
    6465                            outcome,
    6566                            transfer->arg);
     
    7374}
    7475
    75 static transfer_info_t *create_transfer_info(usb_hc_device_t *hc,
     76static transfer_info_t *create_transfer_info(device_t *dev,
    7677    usb_direction_t direction, void *arg)
    7778{
     
    8283        transfer->out_callback = NULL;
    8384        transfer->arg = arg;
    84         transfer->hc = hc;
     85        transfer->dev = dev;
    8586
    8687        return transfer;
    8788}
    8889
    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,
     90static int enqueue_transfer_out(device_t *dev,
     91    usb_target_t target, usb_transfer_type_t transfer_type,
    9192    void *buffer, size_t size,
    92     usb_hcd_transfer_callback_out_t callback, void *arg)
    93 {
    94         printf(NAME ": transfer OUT [%d.%d (%s); %u]\n",
    95             dev->address, endpoint->endpoint,
    96             usb_str_transfer_type(endpoint->transfer_type),
     93    usbhc_iface_transfer_out_callback_t callback, void *arg)
     94{
     95        printf(NAME ": transfer OUT [%d.%d (%s); %zu]\n",
     96            target.address, target.endpoint,
     97            usb_str_transfer_type(transfer_type),
    9798            size);
    9899
    99100        transfer_info_t *transfer
    100             = create_transfer_info(hc, USB_DIRECTION_OUT, arg);
     101            = create_transfer_info(dev, USB_DIRECTION_OUT, arg);
    101102        transfer->out_callback = callback;
    102 
    103         usb_target_t target = {
    104                 .address = dev->address,
    105                 .endpoint = endpoint->endpoint
    106         };
    107103
    108104        hc_add_transaction_to_device(false, target, buffer, size,
     
    112108}
    113109
    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,
     110static int enqueue_transfer_setup(device_t *dev,
     111    usb_target_t target, usb_transfer_type_t transfer_type,
    116112    void *buffer, size_t size,
    117     usb_hcd_transfer_callback_out_t callback, void *arg)
    118 {
    119         printf(NAME ": transfer SETUP [%d.%d (%s); %u]\n",
    120             dev->address, endpoint->endpoint,
    121             usb_str_transfer_type(endpoint->transfer_type),
     113    usbhc_iface_transfer_out_callback_t callback, void *arg)
     114{
     115        printf(NAME ": transfer SETUP [%d.%d (%s); %zu]\n",
     116            target.address, target.endpoint,
     117            usb_str_transfer_type(transfer_type),
    122118            size);
    123119
    124120        transfer_info_t *transfer
    125             = create_transfer_info(hc, USB_DIRECTION_OUT, arg);
     121            = create_transfer_info(dev, USB_DIRECTION_OUT, arg);
    126122        transfer->out_callback = callback;
    127 
    128         usb_target_t target = {
    129                 .address = dev->address,
    130                 .endpoint = endpoint->endpoint
    131         };
    132123
    133124        hc_add_transaction_to_device(true, target, buffer, size,
     
    137128}
    138129
    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,
     130static int enqueue_transfer_in(device_t *dev,
     131    usb_target_t target, usb_transfer_type_t transfer_type,
    141132    void *buffer, size_t size,
    142     usb_hcd_transfer_callback_in_t callback, void *arg)
    143 {
    144         printf(NAME ": transfer IN [%d.%d (%s); %u]\n",
    145             dev->address, endpoint->endpoint,
    146             usb_str_transfer_type(endpoint->transfer_type),
     133    usbhc_iface_transfer_in_callback_t callback, void *arg)
     134{
     135        printf(NAME ": transfer IN [%d.%d (%s); %zu]\n",
     136            target.address, target.endpoint,
     137            usb_str_transfer_type(transfer_type),
    147138            size);
    148139
    149140        transfer_info_t *transfer
    150             = create_transfer_info(hc, USB_DIRECTION_IN, arg);
     141            = create_transfer_info(dev, USB_DIRECTION_IN, arg);
    151142        transfer->in_callback = callback;
    152 
    153         usb_target_t target = {
    154                 .address = dev->address,
    155                 .endpoint = endpoint->endpoint
    156         };
    157143
    158144        hc_add_transaction_from_device(target, buffer, size,
     
    163149
    164150
    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
     151static int interrupt_out(device_t *dev, usb_target_t target,
     152    void *data, size_t size,
     153    usbhc_iface_transfer_out_callback_t callback, void *arg)
     154{
     155        return enqueue_transfer_out(dev, target, USB_TRANSFER_INTERRUPT,
     156            data, size,
     157            callback, arg);
     158}
     159
     160static int interrupt_in(device_t *dev, usb_target_t target,
     161    void *data, size_t size,
     162    usbhc_iface_transfer_in_callback_t callback, void *arg)
     163{
     164        return enqueue_transfer_in(dev, target, USB_TRANSFER_INTERRUPT,
     165            data, size,
     166            callback, arg);
     167}
     168
     169static int control_write_setup(device_t *dev, usb_target_t target,
     170    void *data, size_t size,
     171    usbhc_iface_transfer_out_callback_t callback, void *arg)
     172{
     173        return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL,
     174            data, size,
     175            callback, arg);
     176}
     177
     178static int control_write_data(device_t *dev, usb_target_t target,
     179    void *data, size_t size,
     180    usbhc_iface_transfer_out_callback_t callback, void *arg)
     181{
     182        return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL,
     183            data, size,
     184            callback, arg);
     185}
     186
     187static int control_write_status(device_t *dev, usb_target_t target,
     188    usbhc_iface_transfer_in_callback_t callback, void *arg)
     189{
     190        return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL,
     191            NULL, 0,
     192            callback, arg);
     193}
     194
     195static int control_read_setup(device_t *dev, usb_target_t target,
     196    void *data, size_t size,
     197    usbhc_iface_transfer_out_callback_t callback, void *arg)
     198{
     199        return enqueue_transfer_setup(dev, target, USB_TRANSFER_CONTROL,
     200            data, size,
     201            callback, arg);
     202}
     203
     204static int control_read_data(device_t *dev, usb_target_t target,
     205    void *data, size_t size,
     206    usbhc_iface_transfer_in_callback_t callback, void *arg)
     207{
     208        return enqueue_transfer_in(dev, target, USB_TRANSFER_CONTROL,
     209            data, size,
     210            callback, arg);
     211}
     212
     213static int control_read_status(device_t *dev, usb_target_t target,
     214    usbhc_iface_transfer_out_callback_t callback, void *arg)
     215{
     216        return enqueue_transfer_out(dev, target, USB_TRANSFER_CONTROL,
     217            NULL, 0,
     218            callback, arg);
     219}
     220
     221static usb_address_keeping_t addresses;
     222
     223
     224static int reserve_default_address(device_t *dev)
     225{
     226        usb_address_keeping_reserve_default(&addresses);
     227        return EOK;
     228}
     229
     230static int release_default_address(device_t *dev)
     231{
     232        usb_address_keeping_release_default(&addresses);
     233        return EOK;
     234}
     235
     236static int request_address(device_t *dev, usb_address_t *address)
     237{
     238        usb_address_t addr = usb_address_keeping_request(&addresses);
     239        if (addr < 0) {
     240                return (int)addr;
     241        }
     242
     243        *address = addr;
     244        return EOK;
     245}
     246
     247static int release_address(device_t *dev, usb_address_t address)
     248{
     249        return usb_address_keeping_release(&addresses, address);
     250}
     251
     252static int bind_address(device_t *dev, usb_address_t address,
     253    devman_handle_t handle)
     254{
     255        usb_address_keeping_devman_bind(&addresses, address, handle);
     256        return EOK;
     257}
     258
     259static int tell_address(device_t *dev, devman_handle_t handle,
     260    usb_address_t *address)
     261{
     262        usb_address_t addr = usb_address_keeping_find(&addresses, handle);
     263        if (addr < 0) {
     264                return addr;
     265        }
     266
     267        *address = addr;
     268        return EOK;
     269}
     270
     271void address_init(void)
     272{
     273        usb_address_keeping_init(&addresses, 50);
     274}
     275
     276usbhc_iface_t vhc_iface = {
     277        .tell_address = tell_address,
     278
     279        .reserve_default_address = reserve_default_address,
     280        .release_default_address = release_default_address,
     281        .request_address = request_address,
     282        .bind_address = bind_address,
     283        .release_address = release_address,
     284
     285        .interrupt_out = interrupt_out,
     286        .interrupt_in = interrupt_in,
     287
     288        .control_write_setup = control_write_setup,
     289        .control_write_data = control_write_data,
     290        .control_write_status = control_write_status,
     291
     292        .control_read_setup = control_read_setup,
     293        .control_read_data = control_read_data,
     294        .control_read_status = control_read_status
    169295};
    170296
Note: See TracChangeset for help on using the changeset viewer.