Changes in / [2176ed6:39f780e] in mainline


Ignore:
Location:
uspace
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/mkbd/main.c

    r2176ed6 r39f780e  
    7171                usb_hid_free_report(*report);
    7272                *report = NULL;
    73                 //printf("usb_hid_report_init() failed.\n");
     73                printf("usb_hid_report_init() failed.\n");
    7474                return rc;
    7575        }
     
    8282                usb_hid_free_report(*report);
    8383                *report = NULL;
    84                 //printf("usbhid_dev_get_report_descriptor_length() failed.\n");
     84                printf("usbhid_dev_get_report_descriptor_length() failed.\n");
    8585                return rc;
    8686        }
     
    8989                usb_hid_free_report(*report);
    9090                *report = NULL;
    91                 //printf("usbhid_dev_get_report_descriptor_length() returned 0.\n");
     91                printf("usbhid_dev_get_report_descriptor_length() returned 0.\n");
    9292                return EINVAL;  // TODO: other error code?
    9393        }
     
    108108                *report = NULL;
    109109                free(desc);
    110                 //printf("usbhid_dev_get_report_descriptor() failed.\n");
     110                printf("usbhid_dev_get_report_descriptor() failed.\n");
    111111                return rc;
    112112        }
     
    116116                *report = NULL;
    117117                free(desc);
    118 //              printf("usbhid_dev_get_report_descriptor() returned wrong size:"
    119 //                  " %zu, expected: %zu.\n", actual_size, report_desc_size);
     118                printf("usbhid_dev_get_report_descriptor() returned wrong size:"
     119                    " %zu, expected: %zu.\n", actual_size, report_desc_size);
    120120                return EINVAL;  // TODO: other error code?
    121121        }
     
    128128        if (rc != EOK) {
    129129                free(desc);
    130 //              printf("usb_hid_parse_report_descriptor() failed.\n");
     130                printf("usb_hid_parse_report_descriptor() failed.\n");
    131131                return rc;
    132132        }
  • uspace/drv/usbhid/usbhid.c

    r2176ed6 r39f780e  
    7878        }
    7979       
    80         assert(hid_dev->subdriver_count >= 0);
    81        
    8280        // set the init callback
    83         hid_dev->subdrivers[hid_dev->subdriver_count].init = usb_kbd_init;
     81        hid_dev->subdrivers[0].init = usb_kbd_init;
    8482       
    8583        // set the polling callback
    86         hid_dev->subdrivers[hid_dev->subdriver_count].poll =
    87             usb_kbd_polling_callback;
     84        hid_dev->subdrivers[0].poll = usb_kbd_polling_callback;
    8885       
    8986        // set the polling ended callback
    90         hid_dev->subdrivers[hid_dev->subdriver_count].poll_end = NULL;
     87        hid_dev->subdrivers[0].poll_end = NULL;
    9188       
    9289        // set the deinit callback
    93         hid_dev->subdrivers[hid_dev->subdriver_count].deinit = usb_kbd_deinit;
     90        hid_dev->subdrivers[0].deinit = usb_kbd_deinit;
    9491       
    9592        // set subdriver count
    96         ++hid_dev->subdriver_count;
     93        hid_dev->subdriver_count = 1;
    9794       
    9895        return EOK;
     
    111108        }
    112109       
    113         assert(hid_dev->subdriver_count >= 0);
    114        
    115110        // set the init callback
    116         hid_dev->subdrivers[hid_dev->subdriver_count].init = usb_mouse_init;
     111        hid_dev->subdrivers[0].init = usb_mouse_init;
    117112       
    118113        // set the polling callback
    119         hid_dev->subdrivers[hid_dev->subdriver_count].poll =
    120             usb_mouse_polling_callback;
     114        hid_dev->subdrivers[0].poll = usb_mouse_polling_callback;
    121115       
    122116        // set the polling ended callback
    123         hid_dev->subdrivers[hid_dev->subdriver_count].poll_end = NULL;
     117        hid_dev->subdrivers[0].poll_end = NULL;
    124118       
    125119        // set the deinit callback
    126         hid_dev->subdrivers[hid_dev->subdriver_count].deinit = usb_mouse_deinit;
     120        hid_dev->subdrivers[0].deinit = usb_mouse_deinit;
    127121       
    128122        // set subdriver count
    129         ++hid_dev->subdriver_count;
     123        hid_dev->subdriver_count = 1;
    130124       
    131125        return EOK;
     
    144138        }
    145139       
    146         assert(hid_dev->subdriver_count >= 0);
    147        
    148140        // set the init callback
    149         hid_dev->subdrivers[hid_dev->subdriver_count].init =
    150             usb_generic_hid_init;
     141        hid_dev->subdrivers[0].init = usb_generic_hid_init;
    151142       
    152143        // set the polling callback
    153         hid_dev->subdrivers[hid_dev->subdriver_count].poll =
    154             usb_generic_hid_polling_callback;
     144        hid_dev->subdrivers[0].poll = usb_generic_hid_polling_callback;
    155145       
    156146        // set the polling ended callback
    157         hid_dev->subdrivers[hid_dev->subdriver_count].poll_end = NULL;
     147        hid_dev->subdrivers[0].poll_end = NULL;
    158148       
    159149        // set the deinit callback
    160         hid_dev->subdrivers[hid_dev->subdriver_count].deinit = NULL;
     150        hid_dev->subdrivers[0].deinit = NULL;
    161151       
    162152        // set subdriver count
    163         ++hid_dev->subdriver_count;
     153        hid_dev->subdriver_count = 1;
    164154       
    165155        return EOK;
     
    206196        }
    207197       
    208 //      if (mapping->report_id >= 0) {
    209 //              usb_hid_report_path_set_report_id(usage_path,
    210 //                  mapping->report_id);
    211 //      }
     198        if (mapping->report_id >= 0) {
     199                usb_hid_report_path_set_report_id(usage_path,
     200                    mapping->report_id);
     201        }
    212202       
    213203        assert(hid_dev->report != NULL);
     
    216206//      size_t size = usb_hid_report_size(hid_dev->report, 0,
    217207//          USB_HID_REPORT_TYPE_INPUT);
    218 //      size_t size = 0;
    219        
    220         bool matches = false;
    221 
    222 //      usb_hid_report_description_t *report_des =
    223 //              usb_hid_report_find_description(hid_dev->report,
    224 //              mapping->report_id, USB_HID_REPORT_TYPE_INPUT);
    225         uint8_t report_id = mapping->report_id;
    226 
    227         /*while(report_des != NULL)*/do {
    228 
    229 //              if((mapping->report_id) == 0 && (report_des->report_id != 0)) {
    230 //                      usb_hid_report_path_set_report_id(usage_path,
    231 //                              report_des->report_id);
    232 //              }
    233                                              
    234                 usb_log_debug("Trying report id %u\n", report_id);
    235                
    236                 if (report_id != 0) {
     208        size_t size = 0;
     209
     210        usb_hid_report_description_t *report_des =
     211                usb_hid_report_find_description(hid_dev->report,
     212                mapping->report_id, USB_HID_REPORT_TYPE_INPUT);
     213
     214        while(report_des != NULL) {
     215
     216                if((mapping->report_id) == 0 && (report_des->report_id != 0)) {
    237217                        usb_hid_report_path_set_report_id(usage_path,
    238                                 report_id);
    239                 }
    240 
    241                 usb_hid_report_field_t *field = usb_hid_report_get_sibling(
    242                     hid_dev->report,
    243                     NULL, usage_path, mapping->compare,
    244                     USB_HID_REPORT_TYPE_INPUT);
    245                
    246                 usb_log_debug("Field: %p\n", field);
    247 
    248                 if (field != NULL) {
    249 //                      size++;
    250 //                      field = usb_hid_report_get_sibling(hid_dev->report,
    251 //                          field, usage_path, mapping->compare,
    252 //                          USB_HID_REPORT_TYPE_INPUT);
    253                         matches = true;
     218                                report_des->report_id);
     219                }
     220
     221                usb_hid_report_field_t *field = usb_hid_report_get_sibling (
     222                        hid_dev->report,
     223                        NULL, usage_path, mapping->compare,
     224                        USB_HID_REPORT_TYPE_INPUT);
     225
     226                while(field != NULL) {
     227                        size++;
     228                        field = usb_hid_report_get_sibling (hid_dev->report,
     229                                        field, usage_path, mapping->compare,
     230                            USB_HID_REPORT_TYPE_INPUT);
     231                }
     232
     233                if((mapping->report_id == 0) && (report_des->report_id != 0)) {
     234                        uint8_t report_id = usb_hid_get_next_report_id(
     235                                hid_dev->report, report_des->report_id,
     236                                USB_HID_REPORT_TYPE_INPUT);
     237
     238                        if(report_id == 0) {
     239                                break;
     240                        }
     241
     242                        report_des = usb_hid_report_find_description(
     243                                hid_dev->report, report_id,
     244                                USB_HID_REPORT_TYPE_INPUT);
     245                }
     246                else {
    254247                        break;
    255248                }
    256                
    257                 report_id = usb_hid_get_next_report_id(
    258                     hid_dev->report, report_id,
    259                     USB_HID_REPORT_TYPE_INPUT);
    260 
    261 //              if((mapping->report_id == 0) && (report_des->report_id != 0)) {
    262 //                      uint8_t report_id = usb_hid_get_next_report_id(
    263 //                              hid_dev->report, report_des->report_id,
    264 //                              USB_HID_REPORT_TYPE_INPUT);
    265 
    266 //                      if(report_id == 0) {
    267 //                              break;
    268 //                      }
    269 
    270 //                      report_des = usb_hid_report_find_description(
    271 //                              hid_dev->report, report_id,
    272 //                              USB_HID_REPORT_TYPE_INPUT);
    273 //              }
    274 //              else {
    275 //                      break;
    276 //              }
    277         } while (!matches && report_id != 0);
    278        
    279 //      usb_log_debug("Size of the input report: %zu\n", size);
     249        }
     250       
     251        usb_log_debug("Size of the input report: %zuB\n", size);
    280252        usb_hid_report_path_free(usage_path);
    281253       
    282         return matches;
     254        return (size > 0);
    283255}
    284256
     
    429401       
    430402        do {
    431                 usb_log_debug("Getting size of the report.\n");
    432403                size = usb_hid_report_byte_size(hid_dev->report, report_id,
    433404                    USB_HID_REPORT_TYPE_INPUT);
    434405                usb_log_debug("Report ID: %u, size: %zu\n", report_id, size);
    435406                max_size = (size > max_size) ? size : max_size;
    436                 usb_log_debug("Getting next report ID\n");
    437407                report_id = usb_hid_get_next_report_id(hid_dev->report,
    438408                    report_id, USB_HID_REPORT_TYPE_INPUT);
     
    564534                    hid_dev->subdriver_count);
    565535                //usb_hid_free(&hid_dev);
    566                
    567536        } else {
    568537                bool ok = false;
     
    591560        }
    592561       
    593        
    594         if (rc == EOK) {
    595                 // save max input report size and allocate space for the report
    596                 rc = usb_hid_init_report(hid_dev);
    597                 if (rc != EOK) {
    598                         usb_log_error("Failed to initialize input report buffer"
    599                             ".\n");
    600                 }
    601         }
    602        
     562        // save max input report size and allocate space for the report
     563        rc = usb_hid_init_report(hid_dev);
     564        if (rc != EOK) {
     565                usb_log_error("Failed to initialize input report buffer.\n");
     566        }
    603567       
    604568        return rc;
     
    623587        usb_log_debug("Max input report size: %zu, buffer size: %zu\n",
    624588            hid_dev->max_input_report_size, buffer_size);
    625         //assert(hid_dev->max_input_report_size >= buffer_size);
    626         if (hid_dev->max_input_report_size >= buffer_size) {
    627                 /*! @todo This should probably be atomic. */
    628                 memcpy(hid_dev->input_report, buffer, buffer_size);
    629                 hid_dev->input_report_size = buffer_size;
    630                 usb_hid_new_report(hid_dev);
    631         }
     589        assert(hid_dev->max_input_report_size >= buffer_size);
     590       
     591//      if (/*!allocated*/
     592//          /*|| *//*hid_dev->input_report_size < buffer_size*/) {
     593//              uint8_t *input_old = hid_dev->input_report;
     594//              uint8_t *input_new = (uint8_t *)malloc(buffer_size);
     595               
     596//              if (input_new == NULL) {
     597//                      usb_log_error("Failed to allocate space for input "
     598//                          "buffer. This event may not be reported\n");
     599//                      memset(hid_dev->input_report, 0,
     600//                          hid_dev->input_report_size);
     601//              } else {
     602//                      memcpy(input_new, input_old,
     603//                          hid_dev->input_report_size);
     604//                      hid_dev->input_report = input_new;
     605//                      if (allocated) {
     606//                              free(input_old);
     607//                      }
     608//                      usb_hid_new_report();
     609//              }
     610//      }
     611       
     612        /*! @todo This should probably be atomic. */
     613        memcpy(hid_dev->input_report, buffer, buffer_size);
     614        hid_dev->input_report_size = buffer_size;
     615        usb_hid_new_report(hid_dev);
    632616       
    633617        bool cont = false;
Note: See TracChangeset for help on using the changeset viewer.