Changeset df6ded8 in mainline for uspace/lib/usbhid/src/hidpath.c


Ignore:
Timestamp:
2018-02-28T16:37:50Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b20da0
Parents:
f5e5f73 (diff), b2dca8de (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.
git-author:
Jakub Jermar <jakub@…> (2018-02-28 16:06:42)
git-committer:
Jakub Jermar <jakub@…> (2018-02-28 16:37:50)
Message:

Merge github.com:helenos-xhci-team/helenos

This commit merges support for USB 3 and generally refactors, fixes,
extends and cleans up the existing USB framework.

Notable additions and features:

  • new host controller driver has been implemented to control various xHC models (among others, NEC Renesas uPD720200)
  • isochronous data transfer mode
  • support for explicit USB device removal
  • USB tablet driver
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhid/src/hidpath.c

    rf5e5f73 rdf6ded8  
    7373 * @return Error code
    7474 */
    75 errno_t usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, 
    76                                     int32_t usage_page, int32_t usage)
    77 {       
    78         usb_hid_report_usage_path_t *item
    79                 = malloc(sizeof(usb_hid_report_usage_path_t));
     75errno_t usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path,
     76    int32_t usage_page, int32_t usage)
     77{
     78        usb_hid_report_usage_path_t *item =
     79            malloc(sizeof(usb_hid_report_usage_path_t));
    8080
    8181        if (item == NULL) {
     
    8787        item->usage_page = usage_page;
    8888        item->flags = 0;
    89        
     89
    9090        list_append (&item->rpath_items_link, &usage_path->items);
    9191        usage_path->depth++;
     
    9696/**
    9797 * Removes last item from the usage path structure
    98  * @param usage_path 
     98 * @param usage_path
    9999 * @return void
    100100 */
     
    103103        link_t *item_link;
    104104        usb_hid_report_usage_path_t *item;
    105        
    106         if(!list_empty(&usage_path->items)){
     105
     106        if (!list_empty(&usage_path->items)) {
    107107                item_link = list_last(&usage_path->items);
    108108                item = list_get_instance(item_link,
     
    124124{
    125125        usb_hid_report_usage_path_t *item;
    126        
    127         if(!list_empty(&usage_path->items)){
     126
     127        if (!list_empty(&usage_path->items)) {
    128128                item = list_get_instance(list_last(&usage_path->items),
    129                         usb_hid_report_usage_path_t, rpath_items_link);
     129                    usb_hid_report_usage_path_t, rpath_items_link);
    130130
    131131                memset(item, 0, sizeof(usb_hid_report_usage_path_t));
     
    143143 * @return void
    144144 */
    145 void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, 
    146                                   int32_t tag, int32_t data)
     145void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path,
     146    int32_t tag, int32_t data)
    147147{
    148148        usb_hid_report_usage_path_t *item;
    149        
    150         if(!list_empty(&usage_path->items)){
     149
     150        if (!list_empty(&usage_path->items)) {
    151151                item = list_get_instance(list_last(&usage_path->items),
    152152                     usb_hid_report_usage_path_t, rpath_items_link);
    153153
    154                 switch(tag) {
    155                         case USB_HID_TAG_CLASS_GLOBAL:
    156                                 item->usage_page = data;
    157                                 break;
    158                         case USB_HID_TAG_CLASS_LOCAL:
    159                                 item->usage = data;
    160                                 break;
    161                 }
    162         }
    163        
    164 }
    165 
    166 
    167 /**
    168  *
    169  *
    170  *
    171  *
    172  */
     154                switch (tag) {
     155                case USB_HID_TAG_CLASS_GLOBAL:
     156                        item->usage_page = data;
     157                        break;
     158                case USB_HID_TAG_CLASS_LOCAL:
     159                        item->usage = data;
     160                        break;
     161                }
     162        }
     163}
     164
    173165void usb_hid_print_usage_path(usb_hid_report_path_t *path)
    174166{
    175         usb_log_debug("USAGE_PATH FOR RId(%d):\n", path->report_id);
    176         usb_log_debug("\tLENGTH: %d\n", path->depth);
     167        usb_log_debug("USAGE_PATH FOR RId(%d):", path->report_id);
     168        usb_log_debug("\tLENGTH: %d", path->depth);
    177169
    178170        list_foreach(path->items, rpath_items_link,
    179171            usb_hid_report_usage_path_t, path_item) {
    180172
    181                 usb_log_debug("\tUSAGE_PAGE: %X\n", path_item->usage_page);
    182                 usb_log_debug("\tUSAGE: %X\n", path_item->usage);
    183                 usb_log_debug("\tFLAGS: %d\n", path_item->flags);
     173                usb_log_debug("\tUSAGE_PAGE: %X", path_item->usage_page);
     174                usb_log_debug("\tUSAGE: %X", path_item->usage);
     175                usb_log_debug("\tFLAGS: %d", path_item->flags);
    184176        }
    185177}
     
    199191        usb_hid_report_usage_path_t *report_item;
    200192        usb_hid_report_usage_path_t *path_item;
    201        
     193
    202194        link_t *report_link;
    203195        link_t *path_link;
    204        
     196
    205197        int only_page;
    206        
     198
    207199        if (report_path->report_id != path->report_id) {
    208200                if (path->report_id != 0) {
     
    210202                }
    211203        }
    212        
     204
    213205        // Empty path match all others
    214206        if (path->depth == 0) {
    215207                return 0;
    216208        }
    217        
     209
    218210        if ((only_page = flags & USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY) != 0) {
    219211                flags -= USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY;
    220212        }
    221        
     213
    222214        switch (flags) {
    223215        /* Path is somewhere in report_path */
     
    226218                        return 1;
    227219                }
    228                
     220
    229221                path_link = list_first(&path->items);
    230222                path_item = list_get_instance(path_link,
    231223                    usb_hid_report_usage_path_t, rpath_items_link);
    232                
     224
    233225                list_foreach(report_path->items, rpath_items_link,
    234226                    usb_hid_report_usage_path_t, report_item) {
    235227                        if (USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    236228                            path_item->usage_page)) {
    237                                
     229
    238230                                if (only_page == 0) {
    239231                                        if (USB_HID_SAME_USAGE(report_item->usage,
     
    245237                        }
    246238                }
    247                
     239
    248240                return 1;
    249241                break;
    250        
     242
    251243        /* The paths must be identical */
    252244        case USB_HID_PATH_COMPARE_STRICT:
     
    255247                }
    256248                /* Fallthrough */
    257        
     249
    258250        /* Path is prefix of the report_path */
    259251        case USB_HID_PATH_COMPARE_BEGIN:
    260252                report_link = report_path->items.head.next;
    261253                path_link = path->items.head.next;
    262                
     254
    263255                while ((report_link != &report_path->items.head) &&
    264256                    (path_link != &path->items.head)) {
    265                        
     257
    266258                        report_item = list_get_instance(report_link,
    267259                            usb_hid_report_usage_path_t, rpath_items_link);
    268                        
     260
    269261                        path_item = list_get_instance(path_link,
    270262                            usb_hid_report_usage_path_t, rpath_items_link);
    271                        
     263
    272264                        if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    273265                            path_item->usage_page) || ((only_page == 0) &&
     
    280272                        }
    281273                }
    282                
     274
    283275                if ((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) &&
    284276                    (path_link == &path->items.head)) ||
     
    290282                }
    291283                break;
    292        
     284
    293285        /* Path is suffix of report_path */
    294286        case USB_HID_PATH_COMPARE_END:
    295287                report_link = report_path->items.head.prev;
    296288                path_link = path->items.head.prev;
    297                
     289
    298290                if (list_empty(&path->items)) {
    299291                        return 0;
    300292                }
    301                
     293
    302294                while ((report_link != &report_path->items.head) &&
    303295                      (path_link != &path->items.head)) {
    304296                        report_item = list_get_instance(report_link,
    305297                            usb_hid_report_usage_path_t, rpath_items_link);
    306                        
     298
    307299                        path_item = list_get_instance(path_link,
    308300                            usb_hid_report_usage_path_t, rpath_items_link);
    309                        
     301
    310302                        if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    311303                            path_item->usage_page) || ((only_page == 0) &&
     
    318310                        }
    319311                }
    320                
     312
    321313                if (path_link == &path->items.head) {
    322314                        return 0;
     
    325317                }
    326318                break;
    327        
     319
    328320        default:
    329321                return -1;
     
    340332        usb_hid_report_path_t *path;
    341333        path = malloc(sizeof(usb_hid_report_path_t));
    342         if(path == NULL){
     334        if (path == NULL) {
    343335                return NULL;
    344336        }
     
    363355        if (path == NULL)
    364356                return;
    365         while(!list_empty(&path->items)){
     357        while (!list_empty(&path->items)) {
    366358                usb_hid_report_remove_last_item(path);
    367359        }
     
    379371 */
    380372usb_hid_report_path_t *usb_hid_report_path_clone(
    381         usb_hid_report_path_t *usage_path)
     373    usb_hid_report_path_t *usage_path)
    382374{
    383375        usb_hid_report_usage_path_t *new_path_item;
    384376        usb_hid_report_path_t *new_usage_path = usb_hid_report_path ();
    385377
    386         if(new_usage_path == NULL){
     378        if (new_usage_path == NULL) {
    387379                return NULL;
    388380        }
    389381
    390382        new_usage_path->report_id = usage_path->report_id;
    391        
    392         if(list_empty(&usage_path->items)){
     383
     384        if (list_empty(&usage_path->items)) {
    393385                return new_usage_path;
    394386        }
     
    398390
    399391                new_path_item = malloc(sizeof(usb_hid_report_usage_path_t));
    400                 if(new_path_item == NULL) {
     392                if (new_path_item == NULL) {
    401393                        return NULL;
    402394                }
    403                
     395
    404396                link_initialize(&new_path_item->rpath_items_link);
    405397                new_path_item->usage_page = path_item->usage_page;
    406                 new_path_item->usage = path_item->usage;               
    407                 new_path_item->flags = path_item->flags;               
    408                
     398                new_path_item->usage = path_item->usage;
     399                new_path_item->flags = path_item->flags;
     400
    409401                list_append(&new_path_item->rpath_items_link,
    410402                    &new_usage_path->items);
     
    423415 * @return Error code
    424416 */
    425 errno_t usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, 
    426         uint8_t report_id)
    427 {
    428         if(path == NULL){
     417errno_t usb_hid_report_path_set_report_id(usb_hid_report_path_t *path,
     418    uint8_t report_id)
     419{
     420        if (path == NULL) {
    429421                return EINVAL;
    430422        }
Note: See TracChangeset for help on using the changeset viewer.