Changes in uspace/drv/usbhid/hiddev.c [1c6c4092:2f593872] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/hiddev.c
r1c6c4092 r2f593872 135 135 } 136 136 137 hid_dev->report_desc_size = length; 138 137 139 usb_log_debug("Done.\n"); 138 140 … … 149 151 usb_log_info("Processing descriptors...\n"); 150 152 151 // get the first configuration descriptor152 usb_standard_configuration_descriptor_t config_desc;153 154 153 int rc; 155 rc = usb_request_get_bare_configuration_descriptor(&hid_dev->ctrl_pipe, 156 0, &config_desc); 157 158 if (rc != EOK) { 159 usb_log_error("Failed to get bare config descriptor: %s.\n", 160 str_error(rc)); 161 return rc; 162 } 163 164 // prepare space for all underlying descriptors 165 uint8_t *descriptors = (uint8_t *)malloc(config_desc.total_length); 166 if (descriptors == NULL) { 167 usb_log_error("No memory!.\n"); 168 return ENOMEM; 169 } 170 171 size_t transferred = 0; 172 // get full configuration descriptor 173 rc = usb_request_get_full_configuration_descriptor(&hid_dev->ctrl_pipe, 174 0, descriptors, config_desc.total_length, &transferred); 175 176 if (rc != EOK) { 177 usb_log_error("Failed to get full config descriptor: %s.\n", 178 str_error(rc)); 179 free(descriptors); 180 return rc; 181 } 182 183 if (transferred != config_desc.total_length) { 184 usb_log_error("Configuration descriptor has wrong size (%u, " 185 "expected %u).\n", transferred, config_desc.total_length); 186 free(descriptors); 187 return ELIMIT; 154 155 uint8_t *descriptors = NULL; 156 size_t descriptors_size; 157 rc = usb_request_get_full_configuration_descriptor_alloc( 158 &hid_dev->ctrl_pipe, 0, (void **) &descriptors, &descriptors_size); 159 if (rc != EOK) { 160 usb_log_error("Failed to retrieve config descriptor: %s.\n", 161 str_error(rc)); 162 return rc; 188 163 } 189 164 … … 201 176 202 177 rc = usb_endpoint_pipe_initialize_from_configuration( 203 endpoint_mapping, 1, descriptors, config_desc.total_length,178 endpoint_mapping, 1, descriptors, descriptors_size, 204 179 &hid_dev->wire); 205 180 … … 233 208 assert(endpoint_mapping[0].interface != NULL); 234 209 235 rc = usbhid_dev_get_report_descriptor(hid_dev, descriptors, transferred, 210 /* 211 * Save polling interval 212 */ 213 hid_dev->poll_interval = endpoint_mapping[0].descriptor->poll_interval; 214 assert(hid_dev->poll_interval > 0); 215 216 rc = usbhid_dev_get_report_descriptor(hid_dev, 217 descriptors, descriptors_size, 236 218 (uint8_t *)endpoint_mapping[0].interface); 237 219 … … 239 221 240 222 if (rc != EOK) { 241 usb_log_warning("Problem with parsing Report descriptor: %s.\n", 242 str_error(rc)); 243 return rc; 244 } 223 usb_log_warning("Problem with getting Report descriptor: %s.\n", 224 str_error(rc)); 225 return rc; 226 } 227 228 rc = usb_hid_parse_report_descriptor(hid_dev->parser, 229 hid_dev->report_desc, hid_dev->report_desc_size); 230 if (rc != EOK) { 231 usb_log_warning("Problem parsing Report descriptor: %s.\n", 232 str_error(rc)); 233 return rc; 234 } 235 236 usb_hid_descriptor_print(hid_dev->parser); 245 237 246 238 return EOK; … … 263 255 memset(dev, 0, sizeof(usbhid_dev_t)); 264 256 257 dev->parser = (usb_hid_report_parser_t *)(malloc(sizeof( 258 usb_hid_report_parser_t))); 259 if (dev->parser == NULL) { 260 usb_log_fatal("No memory!\n"); 261 free(dev); 262 return NULL; 263 } 264 265 265 dev->initialized = 0; 266 266 … … 339 339 return rc; 340 340 } 341 342 /* 343 * Initialize the report parser. 344 */ 345 rc = usb_hid_parser_init(hid_dev->parser); 346 if (rc != EOK) { 347 usb_log_error("Failed to initialize report parser.\n"); 348 return rc; 349 } 341 350 342 351 /*
Note:
See TracChangeset
for help on using the changeset viewer.