Changeset c6cb76d in mainline for uspace/lib/usb/src
- Timestamp:
- 2011-04-08T20:19:48Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 297341b
- Parents:
- 7dfc06fa (diff), 61727bf (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace/lib/usb/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/devpoll.c
r7dfc06fa rc6cb76d 66 66 usb_pipe_t *pipe 67 67 = polling_data->dev->pipes[polling_data->pipe_index].pipe; 68 69 usb_log_debug("Pipe interface number: %d, protocol: %d, subclass: %d, max packet size: %d\n", 70 polling_data->dev->pipes[polling_data->pipe_index].interface_no, 71 polling_data->dev->pipes[polling_data->pipe_index].description->interface_protocol, 72 polling_data->dev->pipes[polling_data->pipe_index].description->interface_subclass, 73 pipe->max_packet_size); 68 74 69 75 size_t failed_attempts = 0; … … 83 89 /* Quit the session regardless of errors. */ 84 90 usb_pipe_end_session(pipe); 91 92 // if (rc == ESTALL) { 93 // usb_log_debug("Seding clear feature...\n"); 94 // usb_request_clear_feature(pipe, USB_REQUEST_TYPE_STANDARD, 95 // USB_REQUEST_RECIPIENT_ENDPOINT, 0, pipe->endpoint_no); 96 // continue; 97 // } 85 98 86 99 if (rc != EOK) { -
uspace/lib/usb/src/hidparser.c
r7dfc06fa rc6cb76d 64 64 int usb_hid_report_reset_local_items(); 65 65 void usb_hid_free_report_list(link_t *head); 66 66 usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item); 67 67 /* 68 68 * Data translation private functions … … 106 106 list_initialize(&(parser->feature)); 107 107 108 list_initialize(&(parser->stack)); 109 110 parser->use_report_id = 0; 108 111 return EOK; 109 112 } … … 186 189 tmp_usage_path = NULL; 187 190 191 usb_hid_report_path_set_report_id(report_item->usage_path, report_item->id); 192 if(report_item->id != 0){ 193 parser->use_report_id = 1; 194 } 188 195 189 196 switch(tag) { … … 215 222 if(!(new_report_item = malloc(sizeof(usb_hid_report_item_t)))) { 216 223 return ENOMEM; 217 } 224 } 218 225 memcpy(new_report_item,report_item, sizeof(usb_hid_report_item_t)); 226 link_initialize(&(new_report_item->link)); 227 219 228 /* reset local items */ 220 229 new_report_item->usage_minimum = 0; 221 230 new_report_item->usage_maximum = 0; 231 new_report_item->designator_index = 0; 232 new_report_item->designator_minimum = 0; 233 new_report_item->designator_maximum = 0; 234 new_report_item->string_index = 0; 235 new_report_item->string_minimum = 0; 236 new_report_item->string_maximum = 0; 237 238 /* reset usage from current usage path */ 239 usb_hid_report_usage_path_t *path = list_get_instance(&usage_path->link, usb_hid_report_usage_path_t, link); 240 path->usage = 0; 222 241 223 link_initialize(&(new_report_item->link));224 242 report_item = new_report_item; 225 243 … … 227 245 case USB_HID_REPORT_TAG_PUSH: 228 246 // push current state to stack 229 // not yet implemented 247 new_report_item = usb_hid_report_item_clone(report_item); 248 list_prepend (&parser->stack, &new_report_item->link); 249 230 250 break; 231 251 case USB_HID_REPORT_TAG_POP: 232 252 // restore current state from stack 233 // not yet implemented 253 if(list_empty (&parser->stack)) { 254 return EINVAL; 255 } 256 257 report_item = list_get_instance(&parser->stack, usb_hid_report_item_t, link); 258 list_remove (parser->stack.next); 259 234 260 break; 235 261 … … 647 673 } 648 674 675 parser->use_report_id = 0; 676 649 677 usb_hid_free_report_list(&parser->input); 650 678 usb_hid_free_report_list(&parser->output); … … 676 704 size_t i=0; 677 705 size_t j=0; 706 uint8_t report_id = 0; 678 707 679 708 if(parser == NULL) { … … 686 715 if(!(keys = malloc(sizeof(uint8_t) * key_count))){ 687 716 return ENOMEM; 717 } 718 719 if(parser->use_report_id != 0) { 720 report_id = data[0]; 721 usb_hid_report_path_set_report_id(path, report_id); 688 722 } 689 723 … … 693 727 694 728 item = list_get_instance(list_item, usb_hid_report_item_t, link); 729 695 730 if(!USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) && 696 731 (usb_hid_report_compare_usage_path(item->usage_path, path, flags) == EOK)) { … … 715 750 } 716 751 717 callbacks->keyboard(keys, key_count, 0, arg);752 callbacks->keyboard(keys, key_count, report_id, arg); 718 753 719 754 free(keys); … … 739 774 int32_t mask; 740 775 const uint8_t *foo; 741 776 742 777 // now only common numbers llowed 743 778 if(item->size > 32) { … … 758 793 (usb_pow(10,(item->unit_exponent)))); 759 794 } 795 760 796 offset = item->offset + (j * item->size); 797 if(item->id != 0) { 798 offset += 8; 799 usb_log_debug("MOVED OFFSET BY 1Byte, REPORT_ID(%d)\n", item->id); 800 } 761 801 762 802 // FIXME … … 942 982 943 983 int only_page; 984 985 if(report_path->report_id != path->report_id) { 986 return 1; 987 } 944 988 945 989 if(path->depth == 0){ … … 1038 1082 else { 1039 1083 path->depth = 0; 1084 path->report_id = 0; 1040 1085 list_initialize(&path->link); 1041 1086 return path; … … 1155 1200 return 0; 1156 1201 } 1157 1202 1158 1203 item = parser->output.next; 1159 1204 while(&parser->output != item) { … … 1195 1240 int length; 1196 1241 int32_t tmp_value; 1242 size_t offset_prefix = 0; 1197 1243 1198 1244 if(parser == NULL) { 1199 1245 return EINVAL; 1246 } 1247 1248 if(parser->use_report_id != 0) { 1249 buffer[0] = path->report_id; 1250 offset_prefix = 8; 1200 1251 } 1201 1252 … … 1218 1269 // // variable item 1219 1270 value = usb_hid_translate_data_reverse(report_item, data[idx++]); 1220 offset = report_item->offset + (i * report_item->size) ;1271 offset = report_item->offset + (i * report_item->size) + offset_prefix; 1221 1272 length = report_item->size; 1222 1273 } … … 1224 1275 //bitmap 1225 1276 value += usb_hid_translate_data_reverse(report_item, data[idx++]); 1226 offset = report_item->offset ;1277 offset = report_item->offset + offset_prefix; 1227 1278 length = report_item->size * report_item->count; 1228 1279 } … … 1323 1374 1324 1375 1376 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, uint8_t report_id) 1377 { 1378 if(path == NULL){ 1379 return EINVAL; 1380 } 1381 1382 path->report_id = report_id; 1383 return EOK; 1384 } 1385 1386 1387 usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item) 1388 { 1389 usb_hid_report_item_t *new_report_item; 1390 1391 if(!(new_report_item = malloc(sizeof(usb_hid_report_item_t)))) { 1392 return NULL; 1393 } 1394 memcpy(new_report_item,item, sizeof(usb_hid_report_item_t)); 1395 link_initialize(&(new_report_item->link)); 1396 1397 return new_report_item; 1398 } 1399 1325 1400 /** 1326 1401 * @} -
uspace/lib/usb/src/hidreport.c
r7dfc06fa rc6cb76d 80 80 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 81 81 dev->descriptors.configuration, d); 82 ++i; 82 83 } 83 84 -
uspace/lib/usb/src/host/batch.c
r7dfc06fa rc6cb76d 79 79 instance->error = EOK; 80 80 instance->ep = ep; 81 endpoint_use(instance->ep); 81 82 } 82 83 /*----------------------------------------------------------------------------*/ … … 86 87 * 87 88 */ 88 void usb_transfer_batch_finish(usb_transfer_batch_t *instance , int error)89 void usb_transfer_batch_finish(usb_transfer_batch_t *instance) 89 90 { 90 91 assert(instance); 91 instance->error = error; 92 assert(instance->ep); 93 endpoint_release(instance->ep); 92 94 instance->next_step(instance); 93 95 } -
uspace/lib/usb/src/host/device_keeper.c
r7dfc06fa rc6cb76d 264 264 return instance->devices[address].speed; 265 265 } 266 /*----------------------------------------------------------------------------*/267 void usb_device_keeper_use_control(268 usb_device_keeper_t *instance, usb_target_t target)269 {270 assert(instance);271 const uint16_t ep = 1 << target.endpoint;272 fibril_mutex_lock(&instance->guard);273 while (instance->devices[target.address].control_used & ep) {274 fibril_condvar_wait(&instance->change, &instance->guard);275 }276 instance->devices[target.address].control_used |= ep;277 fibril_mutex_unlock(&instance->guard);278 }279 /*----------------------------------------------------------------------------*/280 void usb_device_keeper_release_control(281 usb_device_keeper_t *instance, usb_target_t target)282 {283 assert(instance);284 const uint16_t ep = 1 << target.endpoint;285 fibril_mutex_lock(&instance->guard);286 assert((instance->devices[target.address].control_used & ep) != 0);287 instance->devices[target.address].control_used &= ~ep;288 fibril_mutex_unlock(&instance->guard);289 fibril_condvar_signal(&instance->change);290 }291 266 /** 292 267 * @} -
uspace/lib/usb/src/host/endpoint.c
r7dfc06fa rc6cb76d 34 34 */ 35 35 36 #include <assert.h> 36 37 #include <errno.h> 37 38 #include <usb/host/endpoint.h> … … 49 50 instance->max_packet_size = max_packet_size; 50 51 instance->toggle = 0; 52 instance->active = false; 53 fibril_mutex_initialize(&instance->guard); 54 fibril_condvar_initialize(&instance->avail); 51 55 link_initialize(&instance->same_device_eps); 52 56 return EOK; … … 56 60 { 57 61 assert(instance); 62 assert(!instance->active); 58 63 list_remove(&instance->same_device_eps); 59 64 free(instance); 65 } 66 /*----------------------------------------------------------------------------*/ 67 void endpoint_use(endpoint_t *instance) 68 { 69 assert(instance); 70 fibril_mutex_lock(&instance->guard); 71 while (instance->active) 72 fibril_condvar_wait(&instance->avail, &instance->guard); 73 instance->active = true; 74 fibril_mutex_unlock(&instance->guard); 75 } 76 /*----------------------------------------------------------------------------*/ 77 void endpoint_release(endpoint_t *instance) 78 { 79 assert(instance); 80 fibril_mutex_lock(&instance->guard); 81 instance->active = false; 82 fibril_mutex_unlock(&instance->guard); 83 fibril_condvar_signal(&instance->avail); 60 84 } 61 85 /*----------------------------------------------------------------------------*/ -
uspace/lib/usb/src/hub.c
r7dfc06fa rc6cb76d 178 178 * error codes than those listed as return codes by this function itself). 179 179 * 180 * The @p connection representing connection with host controller does not 181 * need to be started. 182 * This function duplicates the connection to allow simultaneous calls of 183 * this function (i.e. from different fibrils). 184 * 180 185 * @param[in] parent Parent device (i.e. the hub device). 181 * @param[in] connection Opened connection to host controller.186 * @param[in] connection Connection to host controller. 182 187 * @param[in] dev_speed New device speed. 183 188 * @param[in] enable_port Function for enabling signaling through the port the … … 206 211 ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun) 207 212 { 208 CHECK_CONNECTION(connection); 213 assert(connection != NULL); 214 // FIXME: this is awful, we are accessing directly the structure. 215 usb_hc_connection_t hc_conn = { 216 .hc_handle = connection->hc_handle, 217 .hc_phone = -1 218 }; 219 220 int rc; 221 222 rc = usb_hc_connection_open(&hc_conn); 223 if (rc != EOK) { 224 return rc; 225 } 226 209 227 210 228 /* 211 229 * Request new address. 212 230 */ 213 usb_address_t dev_addr = usb_hc_request_address( connection, dev_speed);231 usb_address_t dev_addr = usb_hc_request_address(&hc_conn, dev_speed); 214 232 if (dev_addr < 0) { 233 usb_hc_connection_close(&hc_conn); 215 234 return EADDRNOTAVAIL; 216 235 } 217 236 218 int rc;219 237 220 238 /* 221 239 * Reserve the default address. 222 240 */ 223 rc = usb_hc_reserve_default_address( connection, dev_speed);241 rc = usb_hc_reserve_default_address(&hc_conn, dev_speed); 224 242 if (rc != EOK) { 225 243 rc = EBUSY; … … 241 259 usb_device_connection_t dev_conn; 242 260 rc = usb_device_connection_initialize_on_default_address(&dev_conn, 243 connection);261 &hc_conn); 244 262 if (rc != EOK) { 245 263 rc = ENOTCONN; … … 258 276 * endpoint. 259 277 */ 260 rc = usb_pipe_register(&ctrl_pipe, 0, connection);278 rc = usb_pipe_register(&ctrl_pipe, 0, &hc_conn); 261 279 if (rc != EOK) { 262 280 rc = EREFUSED; … … 286 304 * Register the control endpoint for the new device. 287 305 */ 288 rc = usb_pipe_register(&ctrl_pipe, 0, connection);306 rc = usb_pipe_register(&ctrl_pipe, 0, &hc_conn); 289 307 if (rc != EOK) { 290 308 rc = EREFUSED; … … 295 313 * Release the original endpoint. 296 314 */ 297 unregister_control_endpoint_on_default_address( connection);315 unregister_control_endpoint_on_default_address(&hc_conn); 298 316 299 317 /* 300 318 * Once the address is changed, we can return the default address. 301 319 */ 302 usb_hc_release_default_address( connection);320 usb_hc_release_default_address(&hc_conn); 303 321 304 322 … … 325 343 .handle = child_handle 326 344 }; 327 rc = usb_hc_register_device( connection, &new_device);345 rc = usb_hc_register_device(&hc_conn, &new_device); 328 346 if (rc != EOK) { 329 347 rc = EDESTADDRREQ; … … 354 372 355 373 leave_unregister_endpoint: 356 usb_pipe_unregister(&ctrl_pipe, connection);374 usb_pipe_unregister(&ctrl_pipe, &hc_conn); 357 375 358 376 leave_release_default_address: 359 usb_hc_release_default_address( connection);377 usb_hc_release_default_address(&hc_conn); 360 378 361 379 leave_release_free_address: 362 usb_hc_unregister_device(connection, dev_addr); 380 usb_hc_unregister_device(&hc_conn, dev_addr); 381 382 usb_hc_connection_close(&hc_conn); 363 383 364 384 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.