Changeset b4c1c95 in mainline
- Timestamp:
- 2013-01-04T12:55:23Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- daf199f
- Parents:
- 0816c2e
- Location:
- uspace/lib/usbhost
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/hcd.h
r0816c2e rb4c1c95 82 82 } 83 83 84 usb_address_t hcd_request_address(hcd_t *hcd, usb_speed_t speed); 85 86 int hcd_release_address(hcd_t *hcd, usb_address_t address); 87 88 int hcd_reserve_default_address(hcd_t *hcd, usb_speed_t speed); 89 90 static inline int hcd_release_default_address(hcd_t *hcd, usb_address_t address) 91 { 92 return hcd_release_address(hcd, USB_ADDRESS_DEFAULT); 93 } 94 84 95 int hcd_add_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir, 85 96 usb_transfer_type_t type, size_t max_packet_size, size_t size); -
uspace/lib/usbhost/src/hcd.c
r0816c2e rb4c1c95 40 40 #include <usb/request.h> 41 41 42 #include <usb/host/hcd.h> 42 #include "hcd.h" 43 44 /** Calls ep_add_hook upon endpoint registration. 45 * @param ep Endpoint to be registered. 46 * @param arg hcd_t in disguise. 47 * @return Error code. 48 */ 49 static int register_helper(endpoint_t *ep, void *arg) 50 { 51 hcd_t *hcd = arg; 52 assert(ep); 53 assert(hcd); 54 if (hcd->ep_add_hook) 55 return hcd->ep_add_hook(hcd, ep); 56 return EOK; 57 } 58 59 /** Calls ep_remove_hook upon endpoint removal. 60 * @param ep Endpoint to be unregistered. 61 * @param arg hcd_t in disguise. 62 */ 63 static void unregister_helper(endpoint_t *ep, void *arg) 64 { 65 hcd_t *hcd = arg; 66 assert(ep); 67 assert(hcd); 68 if (hcd->ep_remove_hook) 69 hcd->ep_remove_hook(hcd, ep); 70 } 71 72 /** Calls ep_remove_hook upon endpoint removal. Prints warning. 73 * * @param ep Endpoint to be unregistered. 74 * * @param arg hcd_t in disguise. 75 * */ 76 static void unregister_helper_warn(endpoint_t *ep, void *arg) 77 { 78 assert(ep); 79 usb_log_warning("Endpoint %d:%d %s was left behind, removing.\n", 80 ep->address, ep->endpoint, usb_str_direction(ep->direction)); 81 unregister_helper(ep, arg); 82 } 83 43 84 44 85 /** Initialize hcd_t structure. … … 63 104 } 64 105 65 /** Calls ep_add_hook upon endpoint registration. 66 * @param ep Endpoint to be registered. 67 * @param arg hcd_t in disguise. 68 * @return Error code. 69 */ 70 static int register_helper(endpoint_t *ep, void *arg) 71 { 72 hcd_t *hcd = arg; 73 assert(ep); 74 assert(hcd); 75 if (hcd->ep_add_hook) 76 return hcd->ep_add_hook(hcd, ep); 106 usb_address_t hcd_request_address(hcd_t *hcd, usb_speed_t speed) 107 { 108 assert(hcd); 109 usb_address_t address = 0; 110 const int ret = usb_device_manager_request_address( 111 &hcd->dev_manager, &address, false, speed); 112 if (ret != EOK) 113 return ret; 114 return address; 115 } 116 117 int hcd_release_address(hcd_t *hcd, usb_address_t address) 118 { 119 assert(hcd); 120 usb_endpoint_manager_remove_address(&hcd->ep_manager, address, 121 unregister_helper_warn, hcd); 122 usb_device_manager_release_address(&hcd->dev_manager, address); 77 123 return EOK; 78 124 } 79 125 80 81 /** Calls ep_remove_hook upon endpoint removal. 82 * @param ep Endpoint to be unregistered. 83 * @param arg hcd_t in disguise. 84 */ 85 static void unregister_helper(endpoint_t *ep, void *arg) 86 { 87 hcd_t *hcd = arg; 88 assert(ep); 89 assert(hcd); 90 if (hcd->ep_remove_hook) 91 hcd->ep_remove_hook(hcd, ep); 126 int hcd_reserve_default_address(hcd_t *hcd, usb_speed_t speed) 127 { 128 assert(hcd); 129 usb_address_t address = 0; 130 return usb_device_manager_request_address( 131 &hcd->dev_manager, &address, true, speed); 92 132 } 93 133 -
uspace/lib/usbhost/src/iface.c
r0816c2e rb4c1c95 42 42 #include "ddf_helpers.h" 43 43 44 /** Calls ep_remove_hook upon endpoint removal. Prints warning.45 * @param ep Endpoint to be unregistered.46 * @param arg hcd_t in disguise.47 */48 static void unregister_helper_warn(endpoint_t *ep, void *arg)49 {50 hcd_t *hcd = arg;51 assert(ep);52 assert(hcd);53 usb_log_warning("Endpoint %d:%d %s was left behind, removing.\n",54 ep->address, ep->endpoint, usb_str_direction(ep->direction));55 if (hcd->ep_remove_hook)56 hcd->ep_remove_hook(hcd, ep);57 }58 59 44 /** Request address interface function. 60 45 * … … 73 58 assert(hcd); 74 59 assert(address); 75 76 60 usb_log_debug("Address request: speed: %s, address: %d, strict: %s.\n", 77 61 usb_str_speed(speed), *address, strict ? "YES" : "NO"); … … 126 110 assert(fun); 127 111 hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun)); 128 assert(hcd);129 112 usb_log_debug("Address release %d.\n", address); 130 usb_endpoint_manager_remove_address(&hcd->ep_manager, address, 131 unregister_helper_warn, hcd); 132 usb_device_manager_release_address(&hcd->dev_manager, address); 133 return EOK; 113 return hcd_release_address(hcd, address); 134 114 } 135 115 … … 197 177 void *arg) 198 178 { 199 return hcd_send_batch(dev_to_hcd(ddf_fun_get_dev(fun)), target, USB_DIRECTION_IN, 200 data, size, setup_data, callback, NULL, arg, "READ"); 179 return hcd_send_batch(dev_to_hcd(ddf_fun_get_dev(fun)), target, 180 USB_DIRECTION_IN, data, size, setup_data, callback, NULL, arg, 181 "READ"); 201 182 } 202 183
Note:
See TracChangeset
for help on using the changeset viewer.