Changes in / [11d2e96a:cbdb6457] in mainline


Ignore:
Location:
uspace/drv/usbhid
Files:
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhid/Makefile

    r11d2e96a rcbdb6457  
    4646        generic/hiddev.c \
    4747        mouse/mousedev.c \
    48         lgtch-ultrax/lgtch-ultrax.c \
    4948        $(STOLEN_LAYOUT_SOURCES)
    5049
  • uspace/drv/usbhid/kbd/kbddev.c

    r11d2e96a rcbdb6457  
    176176
    177177/*----------------------------------------------------------------------------*/
    178 
    179 static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count,
    180     uint8_t report_id, void *arg);
    181 
    182 static const usb_hid_report_in_callbacks_t usb_kbd_parser_callbacks = {
    183         .keyboard = usb_kbd_process_keycodes
    184 };
    185 
    186 /*----------------------------------------------------------------------------*/
    187178/* Keyboard layouts                                                           */
    188179/*----------------------------------------------------------------------------*/
     
    639630{
    640631        assert(hid_dev->parser != NULL);
     632       
     633        usb_hid_report_in_callbacks_t *callbacks =
     634            (usb_hid_report_in_callbacks_t *)malloc(
     635                sizeof(usb_hid_report_in_callbacks_t));
     636       
     637        callbacks->keyboard = usb_kbd_process_keycodes;
    641638
    642639        usb_log_debug("Calling usb_hid_parse_report() with "
     
    647644        usb_hid_report_path_t *path = usb_hid_report_path();
    648645        usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0);
    649         //usb_hid_report_path_set_report_id(path, 0);
     646        usb_hid_report_path_set_report_id(path, 0);
    650647       
    651648        int rc = usb_hid_parse_report(hid_dev->parser, buffer,
    652649            actual_size, path,
    653650            USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    654             &usb_kbd_parser_callbacks, hid_dev);
     651            callbacks, hid_dev);
    655652
    656653        usb_hid_report_path_free(path);
  • uspace/drv/usbhid/main.c

    r11d2e96a rcbdb6457  
    7575static int usb_hid_try_add_device(usb_device_t *dev)
    7676{
    77         assert(dev != NULL);
    78        
    7977        /*
    8078         * Initialize device (get and process descriptors, get address, etc.)
     
    180178        usb_log_debug("usb_hid_add_device()\n");
    181179       
    182         if (dev == NULL) {
    183                 usb_log_warning("Wrong parameter given for add_device().\n");
    184                 return EINVAL;
    185         }
    186        
    187180        if (dev->interface_no < 0) {
    188181                usb_log_warning("Device is not a supported HID device.\n");
  • uspace/drv/usbhid/mouse/mousedev.c

    r11d2e96a rcbdb6457  
    157157static void usb_mouse_free(usb_mouse_t **mouse_dev)
    158158{
    159         assert(mouse_dev != NULL && *mouse_dev != NULL);
     159        if (mouse_dev == NULL || *mouse_dev == NULL) {
     160                return;
     161        }
    160162       
    161163        // hangup phone to the console
    162         if ((*mouse_dev)->console_phone >= 0) {
    163                 async_hangup((*mouse_dev)->console_phone);
    164         }
     164        async_hangup((*mouse_dev)->console_phone);
    165165       
    166166        free(*mouse_dev);
  • uspace/drv/usbhid/subdrivers.c

    r11d2e96a rcbdb6457  
    3737#include "usb/classes/hidut.h"
    3838
    39 #include "lgtch-ultrax/lgtch-ultrax.h"
    40 
    41 static usb_hid_subdriver_usage_t path_kbd[] = {
    42         {USB_HIDUT_PAGE_KEYBOARD, 0},
    43         {0, 0}
    44 };
    45 
    46 static usb_hid_subdriver_usage_t lgtch_path[] = {
    47         {0xc, 0},
    48         {0, 0}
    49 };
     39static usb_hid_subdriver_usage_t path_kbd[] = {{USB_HIDUT_PAGE_KEYBOARD, 0}};
    5040
    5141const usb_hid_subdriver_mapping_t usb_hid_subdrivers[] = {
    5242        {
    5343                path_kbd,
    54                 -1,
     44                1,
    5545                USB_HID_PATH_COMPARE_END
    5646                | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    57                 0,
    58                 0,
     47                NULL,
     48                NULL,
    5949                {
    60                         .init = usb_kbd_init,
    61                         .deinit = usb_kbd_deinit,
    62                         .poll = usb_kbd_polling_callback,
    63                         .poll_end = NULL
     50                        usb_kbd_init,
     51                        usb_kbd_deinit,
     52                        usb_kbd_polling_callback,
     53                        NULL
    6454                },
    6555               
    6656        },
    67         {
    68                 lgtch_path,
    69                 1,
    70                 USB_HID_PATH_COMPARE_END
    71                 | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,
    72                 0x046d,
    73                 0xc30e,
    74                 {
    75                         .init = NULL,
    76                         .deinit = NULL,
    77                         .poll = usb_lgtch_polling_callback,
    78                         .poll_end = NULL
    79                 }
    80         },
    81         {NULL, -1, 0, 0, 0, {NULL, NULL, NULL, NULL}}
     57        {NULL, 0, 0, NULL, NULL, {NULL, NULL, NULL, NULL}}
    8258};
    8359
  • uspace/drv/usbhid/subdrivers.h

    r11d2e96a rcbdb6457  
    5454typedef struct usb_hid_subdriver_mapping {
    5555        const usb_hid_subdriver_usage_t *usage_path;
    56         int report_id;
     56        int path_size;
    5757        int compare;
    58         uint16_t vendor_id;
    59         uint16_t product_id;
     58        const char *vendor_id;
     59        const char *product_id;
    6060        usb_hid_subdriver_t subdriver;
    6161} usb_hid_subdriver_mapping_t;
  • uspace/drv/usbhid/usbhid.c

    r11d2e96a rcbdb6457  
    6767static int usb_hid_set_boot_kbd_subdriver(usb_hid_dev_t *hid_dev)
    6868{
    69         assert(hid_dev != NULL && hid_dev->subdriver_count == 0);
     69        assert(hid_dev->subdriver_count == 0);
    7070       
    7171        hid_dev->subdrivers = (usb_hid_subdriver_t *)malloc(
     
    9797static int usb_hid_set_boot_mouse_subdriver(usb_hid_dev_t *hid_dev)
    9898{
    99         assert(hid_dev != NULL && hid_dev->subdriver_count == 0);
     99        assert(hid_dev->subdriver_count == 0);
    100100       
    101101        hid_dev->subdrivers = (usb_hid_subdriver_t *)malloc(
     
    127127static int usb_hid_set_generic_hid_subdriver(usb_hid_dev_t *hid_dev)
    128128{
    129         assert(hid_dev != NULL && hid_dev->subdriver_count == 0);
     129        assert(hid_dev->subdriver_count == 0);
    130130       
    131131        hid_dev->subdrivers = (usb_hid_subdriver_t *)malloc(
     
    164164
    165165static bool usb_hid_path_matches(usb_hid_dev_t *hid_dev,
    166     const usb_hid_subdriver_mapping_t *mapping)
     166    const usb_hid_subdriver_usage_t *path, int path_size, int compare)
    167167{
    168168        assert(hid_dev != NULL);
    169         assert(mapping != NULL);
     169        assert(path != NULL);
    170170       
    171171        usb_hid_report_path_t *usage_path = usb_hid_report_path();
     
    174174                return false;
    175175        }
    176         int i = 0;
    177         while (mapping->usage_path[i].usage != 0
    178             || mapping->usage_path[i].usage_page != 0) {
     176        int i;
     177        for (i = 0; i < path_size; ++i) {
    179178                if (usb_hid_report_path_append_item(usage_path,
    180                     mapping->usage_path[i].usage_page,
    181                     mapping->usage_path[i].usage) != EOK) {
     179                    path[i].usage_page, path[i].usage) != EOK) {
    182180                        usb_log_debug("Failed to append to usage path.\n");
    183181                        usb_hid_report_path_free(usage_path);
    184182                        return false;
    185183                }
    186                 ++i;
    187         }
    188        
    189         if (mapping->report_id >= 0) {
    190                 usb_hid_report_path_set_report_id(usage_path,
    191                     mapping->report_id);
    192184        }
    193185       
    194186        assert(hid_dev->parser != NULL);
    195187       
    196         usb_log_debug("Compare flags: %d\n", mapping->compare);
     188        usb_log_debug("Compare flags: %d\n", compare);
    197189        size_t size = usb_hid_report_input_length(hid_dev->parser, usage_path,
    198             mapping->compare);
     190            compare);
    199191        usb_log_debug("Size of the input report: %d\n", size);
    200192       
     
    239231static int usb_hid_find_subdrivers(usb_hid_dev_t *hid_dev)
    240232{
    241         assert(hid_dev != NULL);
    242        
    243233        const usb_hid_subdriver_t *subdrivers[USB_HID_MAX_SUBDRIVERS];
    244234       
    245235        int i = 0, count = 0;
    246236        const usb_hid_subdriver_mapping_t *mapping = &usb_hid_subdrivers[i];
    247 
    248         bool ids_matched;
    249         bool matched;
    250237       
    251238        while (count < USB_HID_MAX_SUBDRIVERS &&
    252239            (mapping->usage_path != NULL
    253             || mapping->vendor_id != 0 || mapping->product_id != 0)) {
     240            || mapping->vendor_id != NULL
     241            || mapping->product_id != NULL)) {
    254242                // check the vendor & product ID
    255                 if (mapping->vendor_id != 0 && mapping->product_id == 0) {
    256                         usb_log_warning("Missing Product ID for Vendor ID %u\n",
     243                if (mapping->vendor_id != NULL && mapping->product_id == NULL) {
     244                        usb_log_warning("Missing Product ID for Vendor ID %s\n",
    257245                            mapping->vendor_id);
    258246                        return EINVAL;
    259247                }
    260                 if (mapping->product_id != 0 && mapping->vendor_id == 0) {
    261                         usb_log_warning("Missing Vendor ID for Product ID %u\n",
     248                if (mapping->product_id != NULL && mapping->vendor_id == NULL) {
     249                        usb_log_warning("Missing Vendor ID for Product ID %s\n",
    262250                            mapping->product_id);
    263251                        return EINVAL;
    264252                }
    265253               
    266                 ids_matched = false;
    267                 matched = false;
    268                
    269                 if (mapping->vendor_id != 0) {
    270                         assert(mapping->product_id != 0);
    271                         usb_log_debug("Comparing device against vendor ID %u"
    272                             " and product ID %u.\n", mapping->vendor_id,
     254                if (mapping->vendor_id != NULL) {
     255                        assert(mapping->product_id != NULL);
     256                        usb_log_debug("Comparing device against vendor ID %s"
     257                            " and product ID %s.\n", mapping->vendor_id,
    273258                            mapping->product_id);
    274259                        if (usb_hid_ids_match(hid_dev, mapping)) {
    275                                 usb_log_debug("IDs matched.\n");
    276                                 ids_matched = true;
     260                                usb_log_debug("Matched.\n");
     261                                subdrivers[count++] = &mapping->subdriver;
     262                                // skip the checking of usage path
     263                                goto next;
    277264                        }
    278265                }
     
    280267                if (mapping->usage_path != NULL) {
    281268                        usb_log_debug("Comparing device against usage path.\n");
    282                         if (usb_hid_path_matches(hid_dev, mapping)) {
    283                                 // does not matter if IDs were matched
    284                                 matched = true;
     269                        if (usb_hid_path_matches(hid_dev,
     270                            mapping->usage_path, mapping->path_size,
     271                            mapping->compare)) {
     272                                subdrivers[count++] = &mapping->subdriver;
     273                        } else {
     274                                usb_log_debug("Not matched.\n");
    285275                        }
    286                 } else {
    287                         // matched only if IDs were matched and there is no path
    288                         matched = ids_matched;
    289                 }
    290                
    291                 if (matched) {
    292                         subdrivers[count++] = &mapping->subdriver;
    293                 }
    294                
     276                }
     277        next:
    295278                mapping = &usb_hid_subdrivers[++i];
    296279        }
     
    304287static int usb_hid_check_pipes(usb_hid_dev_t *hid_dev, usb_device_t *dev)
    305288{
    306         assert(hid_dev != NULL && dev != NULL);
    307        
    308289        int rc = EOK;
    309290       
Note: See TracChangeset for help on using the changeset viewer.