Changes in / [7205209:cc5908e] in mainline
- Location:
- uspace
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/kbd/kbddev.c
r7205209 rcc5908e 700 700 701 701 while (field != NULL) { 702 usb_log_debug2("FIELD (%p) - VALUE(%d) USAGE(%u)\n",703 field, field->value, field->usage);702 //usb_log_debug2("FIELD (%p) - VALUE(%d) USAGE(%u)\n", 703 // field, field->value, field->usage); 704 704 705 705 assert(i < kbd_dev->key_count); … … 865 865 usb_hid_report_path_set_report_id(path, 0); 866 866 867 kbd_dev->key_count = usb_hid_report_input_length( 868 hid_dev->report, path, 869 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY); 867 kbd_dev->key_count = usb_hid_report_size( 868 hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT); 870 869 usb_hid_report_path_free(path); 871 870 … … 908 907 kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0); 909 908 910 kbd_dev->led_output_size = usb_hid_report_output_size(hid_dev->report, 911 kbd_dev->led_path, 912 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY); 909 kbd_dev->led_output_size = usb_hid_report_size(hid_dev->report, 0, 910 USB_HID_REPORT_TYPE_OUTPUT); 913 911 914 912 usb_log_debug("Output report size (in items): %zu\n", -
uspace/drv/usbhid/lgtch-ultrax/lgtch-ultrax.c
r7205209 rcc5908e 300 300 usb_hid_report_path_set_report_id(path, 1); 301 301 302 lgtch_dev->key_count = usb_hid_report_ input_length(303 hid_dev->report, path,304 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY);302 lgtch_dev->key_count = usb_hid_report_size(hid_dev->report, 1, 303 USB_HID_REPORT_TYPE_INPUT); 304 305 305 usb_hid_report_path_free(path); 306 306 -
uspace/drv/usbhid/usbhid.c
r7205209 rcc5908e 203 203 204 204 usb_log_debug("Compare flags: %d\n", mapping->compare); 205 size_t size = usb_hid_report_ input_length(hid_dev->report, usage_path,206 mapping->compare);205 size_t size = usb_hid_report_size(hid_dev->report, mapping->report_id, 206 USB_HID_REPORT_TYPE_INPUT); 207 207 usb_log_debug("Size of the input report: %zuB\n", size); 208 208 -
uspace/drv/usbkbd/kbddev.c
r7205209 rcc5908e 771 771 usb_hid_report_path_set_report_id(path, 0); 772 772 773 kbd_dev->key_count = usb_hid_report_ input_length(774 kbd_dev->parser, path, USB_HID_PATH_COMPARE_END);773 kbd_dev->key_count = usb_hid_report_size( 774 kbd_dev->parser, 0, USB_HID_REPORT_TYPE_INPUT); 775 775 usb_hid_report_path_free (path); 776 776 … … 803 803 usb_hid_report_path_set_report_id(kbd_dev->led_path, 0x00); 804 804 805 kbd_dev->led_output_size = usb_hid_report_output_size(kbd_dev->parser, 806 kbd_dev->led_path, 807 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY); 805 kbd_dev->led_output_size = usb_hid_report_size(kbd_dev->parser, 0, 806 USB_HID_REPORT_TYPE_OUTPUT); 808 807 809 808 usb_log_debug("Output report size (in items): %zu\n", -
uspace/lib/usb/include/usb/classes/hid_report_items.h
r7205209 rcc5908e 46 46 #define USB_HID_ITEM_IS_LONG(data) (data == 0xFE) 47 47 48 49 /** 50 * Extended usage macros 51 */ 52 #define USB_HID_IS_EXTENDED_USAGE(usage) ((usage & 0xFFFF0000) != 0) 53 #define USB_HID_EXTENDED_USAGE_PAGE(usage) ((usage & 0xFFFF0000) >> 16) 54 #define USB_HID_EXTENDED_USAGE(usage) (usage & 0xFFFF) 48 55 49 56 /** -
uspace/lib/usb/include/usb/classes/hidparser.h
r7205209 rcc5908e 51 51 size_t size, uint8_t *report_id); 52 52 53 /** */54 size_t usb_hid_report_input_length(const usb_hid_report_t *report,55 usb_hid_report_path_t *path, int flags);56 57 53 /* 58 54 * Output report parser functions … … 65 61 void usb_hid_report_output_free(uint8_t *output); 66 62 67 /** Returns size of output for given usage path*/68 size_t usb_hid_report_ output_size(usb_hid_report_t *report,69 usb_hid_report_path_t *path, int flags);63 /** Returns size of report in items */ 64 size_t usb_hid_report_size(usb_hid_report_t *report, uint8_t report_id, 65 usb_hid_report_type_t type); 70 66 71 67 /** Makes the output report buffer by translated given data */ -
uspace/lib/usb/include/usb/classes/hidtypes.h
r7205209 rcc5908e 39 39 #include <adt/list.h> 40 40 41 #define USB_HID_MAX_USAGES 2041 #define USB_HID_MAX_USAGES 0xffff 42 42 43 43 #define USB_HID_UINT32_TO_INT32(x, size) ((((x) & (1 << ((size) - 1))) != 0) ? -(~(x - 1) & ((1 << size) - 1)) : (x)) //(-(~((x) - 1))) … … 92 92 int32_t physical_minimum; 93 93 int32_t physical_maximum; 94 uint32_t usage_minimum;95 uint32_t usage_maximum;94 int32_t usage_minimum; 95 int32_t usage_maximum; 96 96 uint32_t unit; 97 97 uint32_t unit_exponent; 98 98 99 uint32_t *usages; 100 size_t usages_count; 99 101 100 102 int32_t value; … … 121 123 122 124 /** */ 123 uint32_t usage_minimum;124 /** */ 125 uint32_t usage_maximum;125 int32_t usage_minimum; 126 /** */ 127 int32_t usage_maximum; 126 128 /** */ 127 129 int32_t logical_minimum; -
uspace/lib/usb/src/hiddescriptor.c
r7205209 rcc5908e 116 116 int i; 117 117 118 for(i=0; i<report_item->usages_count; i++){ 119 usb_log_debug("usages (%d) - %x\n", i, report_item->usages[i]); 120 } 121 118 usb_log_debug("usages_count - %zu\n", report_item->usages_count); 119 120 uint32_t *usages; 121 int usages_used=0; 122 if(report_item->usages_count > 0){ 123 usages = malloc(sizeof(int32_t) * report_item->usages_count); 124 memcpy(usages, report_item->usages, sizeof(int32_t) * report_item->usages_count); 125 } 126 else { 127 usages = NULL; 128 } 129 122 130 usb_hid_report_path_t *path = report_item->usage_path; 123 131 for(i=0; i<report_item->count; i++){ … … 133 141 field->physical_maximum = report_item->physical_maximum; 134 142 135 field->usage_minimum = report_item->usage_minimum; 136 field->usage_maximum = report_item->usage_maximum; 137 if(report_item->extended_usage_page != 0){ 138 field->usage_page = report_item->extended_usage_page; 143 if(USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) == 0){ 144 /* 145 Store usage array. The Correct Usage Page and Usage is depending 146 on data in report and will be filled later 147 */ 148 field->usage = 0; 149 field->usage_page = report_item->usage_page; 150 151 field->usages_count = report_item->usages_count; 152 field->usages = usages; 153 usages_used = 1; 139 154 } 140 155 else { 141 field->usage_page = report_item->usage_page; 142 } 143 144 if(report_item->usages_count > 0 && ((report_item->usage_minimum == 0) && (report_item->usage_maximum == 0))) { 145 uint32_t usage; 146 if(i < report_item->usages_count){ 156 /* Fill the correct Usage and Usage Page */ 157 int32_t usage; 158 if(i < report_item->usages_count) { 147 159 usage = report_item->usages[i]; 148 160 } … … 151 163 } 152 164 153 154 if((usage & 0xFFFF0000) != 0){ 155 field->usage_page = (usage >> 16); 156 field->usage = (usage & 0xFFFF); 165 if(USB_HID_IS_EXTENDED_USAGE(usage)){ 166 field->usage = USB_HID_EXTENDED_USAGE(usage); 167 field->usage_page = USB_HID_EXTENDED_USAGE_PAGE(usage); 157 168 } 158 169 else { 159 170 field->usage = usage; 160 } 161 162 163 } 164 165 if((USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) != 0) && (!((report_item->usage_minimum == 0) && (report_item->usage_maximum == 0)))) { 166 field->usage = report_item->usage_minimum + i; 171 field->usage_page = report_item->usage_page; 172 } 167 173 } 168 174 … … 209 215 } 210 216 217 // free only when not used!!! 218 if(usages && usages_used == 0) { 219 free(usages); 220 } 211 221 212 222 return EOK; … … 565 575 } 566 576 break; 567 case USB_HID_REPORT_TAG_USAGE_MINIMUM: 577 case USB_HID_REPORT_TAG_USAGE_MINIMUM: 568 578 if (item_size == 3) { 569 579 // usage extended usages … … 577 587 case USB_HID_REPORT_TAG_USAGE_MAXIMUM: 578 588 if (item_size == 3) { 589 590 if(report_item->extended_usage_page != ((usb_hid_report_tag_data_uint32(data,item_size) & 0xFF00) >> 16)) { 591 return EINVAL; 592 } 593 579 594 // usage extended usages 580 595 report_item->extended_usage_page = (usb_hid_report_tag_data_uint32(data,item_size) & 0xFF00) >> 16; … … 584 599 report_item->usage_maximum = usb_hid_report_tag_data_uint32(data,item_size); 585 600 } 601 602 // vlozit zaznamy do pole usages 603 int32_t i; 604 for(i=report_item->usage_minimum; i<=report_item->usage_maximum; i++) { 605 if(report_item->extended_usage_page) { 606 report_item->usages[report_item->usages_count++] = (report_item->extended_usage_page << 16) + i; 607 } 608 else { 609 report_item->usages[report_item->usages_count++] = i; 610 } 611 } 612 report_item->extended_usage_page = 0; 613 586 614 break; 587 615 case USB_HID_REPORT_TAG_DESIGNATOR_INDEX: -
uspace/lib/usb/src/hidparser.c
r7205209 rcc5908e 69 69 70 70 71 /** Returns size of report of specified report id and type in items 72 * 73 * @param parser Opaque report parser structure 74 * @param report_id 75 * @param type 76 * @return Number of items in specified report 77 */ 78 size_t usb_hid_report_size(usb_hid_report_t *report, uint8_t report_id, 79 usb_hid_report_type_t type) 80 { 81 usb_hid_report_description_t *report_des; 82 83 if(report == NULL) { 84 return 0; 85 } 86 87 report_des = usb_hid_report_find_description (report, report_id, type); 88 if(report_des == NULL){ 89 return 0; 90 } 91 else { 92 return report_des->item_length; 93 } 94 } 71 95 72 96 … … 114 138 // array 115 139 item->value = usb_hid_translate_data(item, data); 116 item->usage = (item->value - item->physical_minimum) + item->usage_minimum; 140 141 item->usage = USB_HID_EXTENDED_USAGE(item->usages[item->value - item->physical_minimum]); 142 item->usage_page = USB_HID_EXTENDED_USAGE_PAGE(item->usages[item->value - item->physical_minimum]); 143 117 144 } 118 145 else { … … 206 233 } 207 234 208 /**209 * Returns number of items in input report which are accessible by given usage path210 *211 * @param parser Opaque report descriptor structure212 * @param path Usage path specification213 * @param flags Usage path comparison flags214 * @return Number of items in input report215 */216 size_t usb_hid_report_input_length(const usb_hid_report_t *report,217 usb_hid_report_path_t *path, int flags)218 {219 220 size_t ret = 0;221 222 if(report == NULL) {223 return 0;224 }225 226 usb_hid_report_description_t *report_des;227 report_des = usb_hid_report_find_description (report, path->report_id, USB_HID_REPORT_TYPE_INPUT);228 if(report_des == NULL) {229 return 0;230 }231 232 link_t *field_it = report_des->report_items.next;233 usb_hid_report_field_t *field;234 while(field_it != &report_des->report_items) {235 236 field = list_get_instance(field_it, usb_hid_report_field_t, link);237 if(USB_HID_ITEM_FLAG_CONSTANT(field->item_flags) == 0) {238 239 usb_hid_report_path_append_item (field->collection_path, field->usage_page, field->usage);240 if(usb_hid_report_compare_usage_path (field->collection_path, path, flags) == EOK) {241 ret++;242 }243 usb_hid_report_remove_last_item (field->collection_path);244 }245 246 field_it = field_it->next;247 }248 249 return ret;250 }251 252 235 /*** OUTPUT API **/ 253 236 … … 302 285 free (output); 303 286 } 304 }305 306 /** Returns size of output for given usage path307 *308 * @param parser Opaque report parser structure309 * @param path Usage path specified which items will be thought for the output310 * @param flags Flags of usage path structure comparison311 * @return Number of items matching the given usage path312 */313 size_t usb_hid_report_output_size(usb_hid_report_t *report,314 usb_hid_report_path_t *path, int flags)315 {316 size_t ret = 0;317 usb_hid_report_description_t *report_des;318 319 if(report == NULL) {320 return 0;321 }322 323 report_des = usb_hid_report_find_description (report, path->report_id, USB_HID_REPORT_TYPE_OUTPUT);324 if(report_des == NULL){325 return 0;326 }327 328 link_t *field_it = report_des->report_items.next;329 usb_hid_report_field_t *field;330 while(field_it != &report_des->report_items) {331 332 field = list_get_instance(field_it, usb_hid_report_field_t, link);333 if(USB_HID_ITEM_FLAG_CONSTANT(field->item_flags) == 0){334 usb_hid_report_path_append_item (field->collection_path, field->usage_page, field->usage);335 if(usb_hid_report_compare_usage_path (field->collection_path, path, flags) == EOK) {336 ret++;337 }338 usb_hid_report_remove_last_item (field->collection_path);339 }340 341 field_it = field_it->next;342 }343 344 return ret;345 346 287 } 347 288
Note:
See TracChangeset
for help on using the changeset viewer.