Changeset fa8d346 in mainline
- Timestamp:
- 2011-05-24T22:19:26Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8d3f198
- Parents:
- 9dddb3d
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkbd/main.c
r9dddb3d rfa8d346 60 60 static int dev_phone = -1; 61 61 62 static int initialize_report_parser(int dev_phone, usb_hid_report_t *report) 63 { 64 report = (usb_hid_report_t *)malloc(sizeof(usb_hid_report_t)); 65 if (report == NULL) { 66 return ENOMEM; 67 } 68 69 int rc = usb_hid_report_init(report); 70 if (rc != EOK) { 71 usb_hid_free_report(report); 62 static int initialize_report_parser(int dev_phone, usb_hid_report_t **report) 63 { 64 *report = (usb_hid_report_t *)malloc(sizeof(usb_hid_report_t)); 65 if (*report == NULL) { 66 return ENOMEM; 67 } 68 69 int rc = usb_hid_report_init(*report); 70 if (rc != EOK) { 71 usb_hid_free_report(*report); 72 *report = NULL; 73 printf("usb_hid_report_init() failed.\n"); 72 74 return rc; 73 75 } … … 78 80 dev_phone, &report_desc_size); 79 81 if (rc != EOK) { 80 usb_hid_free_report(report); 82 usb_hid_free_report(*report); 83 *report = NULL; 84 printf("usbhid_dev_get_report_descriptor_length() failed.\n"); 81 85 return rc; 82 86 } 83 87 84 88 if (report_desc_size == 0) { 85 usb_hid_free_report(report); 89 usb_hid_free_report(*report); 90 *report = NULL; 91 printf("usbhid_dev_get_report_descriptor_length() returned 0.\n"); 86 92 return EINVAL; // TODO: other error code? 87 93 } … … 89 95 uint8_t *desc = (uint8_t *)malloc(report_desc_size); 90 96 if (desc == NULL) { 91 usb_hid_free_report(report); 97 usb_hid_free_report(*report); 98 *report = NULL; 92 99 return ENOMEM; 93 100 } … … 98 105 &actual_size); 99 106 if (rc != EOK) { 100 usb_hid_free_report(report); 107 usb_hid_free_report(*report); 108 *report = NULL; 101 109 free(desc); 110 printf("usbhid_dev_get_report_descriptor() failed.\n"); 102 111 return rc; 103 112 } 104 113 105 114 if (actual_size != report_desc_size) { 106 usb_hid_free_report(report); 115 usb_hid_free_report(*report); 116 *report = NULL; 107 117 free(desc); 118 printf("usbhid_dev_get_report_descriptor() returned wrong size:" 119 " %zu, expected: %zu.\n", actual_size, report_desc_size); 108 120 return EINVAL; // TODO: other error code? 109 121 } … … 111 123 // initialize the report parser 112 124 113 rc = usb_hid_parse_report_descriptor( report, desc, report_desc_size);125 rc = usb_hid_parse_report_descriptor(*report, desc, report_desc_size); 114 126 free(desc); 115 127 116 128 if (rc != EOK) { 117 129 free(desc); 130 printf("usb_hid_parse_report_descriptor() failed.\n"); 118 131 return rc; 119 132 } … … 215 228 216 229 usb_hid_report_t *report = NULL; 217 rc = initialize_report_parser(dev_phone, report);230 rc = initialize_report_parser(dev_phone, &report); 218 231 if (rc != EOK) { 219 232 printf("Failed to initialize report parser: %s\n", -
uspace/drv/usbhid/generic/hiddev.c
r9dddb3d rfa8d346 153 153 usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)fun->driver_data; 154 154 155 printf("hid_dev->report_desc_size = %zu\n", hid_dev->report_desc_size); 156 155 157 return hid_dev->report_desc_size; 156 158 } -
uspace/drv/usbhid/usbhid.c
r9dddb3d rfa8d346 443 443 /* Get the report descriptor and parse it. */ 444 444 rc = usb_hid_process_report_descriptor(hid_dev->usb_dev, 445 hid_dev->report );445 hid_dev->report, &hid_dev->report_desc, &hid_dev->report_desc_size); 446 446 447 447 bool fallback = false; -
uspace/lib/usbhid/include/usb/hid/hidreport.h
r9dddb3d rfa8d346 44 44 * report parser. 45 45 * 46 * \param dev USB device representing a HID device. 47 * \param parser HID Report parser. 46 * \param[in] dev USB device representing a HID device. 47 * \param[in/out] parser HID Report parser. 48 * \param[out] report_desc Place to save report descriptor into. 49 * \param[out] report_size 48 50 * 49 51 * \retval EOK if successful. … … 57 59 */ 58 60 int usb_hid_process_report_descriptor(usb_device_t *dev, 59 usb_hid_report_t *report );61 usb_hid_report_t *report, uint8_t **report_desc, size_t *report_size); 60 62 61 63 #endif /* LIBUSB_HIDREPORT_H_ */ -
uspace/lib/usbhid/src/hidreport.c
r9dddb3d rfa8d346 164 164 165 165 int usb_hid_process_report_descriptor(usb_device_t *dev, 166 usb_hid_report_t *report )166 usb_hid_report_t *report, uint8_t **report_desc, size_t *report_size) 167 167 { 168 168 if (dev == NULL || report == NULL) { … … 172 172 } 173 173 174 uint8_t *report_desc = NULL; 175 size_t report_size; 176 177 int rc = usb_hid_get_report_descriptor(dev, &report_desc, 178 &report_size); 174 // uint8_t *report_desc = NULL; 175 // size_t report_size; 176 177 int rc = usb_hid_get_report_descriptor(dev, report_desc, report_size); 179 178 180 179 if (rc != EOK) { 181 180 usb_log_error("Problem with getting Report descriptor: %s.\n", 182 181 str_error(rc)); 183 if (report_desc != NULL) { 184 free(report_desc); 182 if (*report_desc != NULL) { 183 free(*report_desc); 184 *report_desc = NULL; 185 185 } 186 186 return rc; 187 187 } 188 188 189 assert( report_desc != NULL);190 191 rc = usb_hid_parse_report_descriptor(report, report_desc,report_size);189 assert(*report_desc != NULL); 190 191 rc = usb_hid_parse_report_descriptor(report, *report_desc, *report_size); 192 192 if (rc != EOK) { 193 193 usb_log_error("Problem parsing Report descriptor: %s.\n", 194 194 str_error(rc)); 195 free(report_desc); 195 free(*report_desc); 196 *report_desc = NULL; 196 197 return rc; 197 198 } 198 199 199 200 usb_hid_descriptor_print(report); 200 free(report_desc);201 201 202 202 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.