Changeset 1102eca in mainline for uspace/lib/usbhost/src/endpoint.c
- Timestamp:
- 2018-01-08T17:17:38Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bdd8842c
- Parents:
- eb928c4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/endpoint.c
reb928c4 r1102eca 49 49 #include "endpoint.h" 50 50 51 /** Initialize provided endpoint structure. 51 /** 52 * Initialize provided endpoint structure. 52 53 */ 53 54 void endpoint_init(endpoint_t *ep, device_t *dev, const usb_endpoint_descriptors_t *desc) … … 78 79 } 79 80 81 /** 82 * Get the bus endpoint belongs to. 83 */ 80 84 static inline const bus_ops_t *get_bus_ops(endpoint_t *ep) 81 85 { … … 83 87 } 84 88 89 /** 90 * Increase the reference count on endpoint. 91 */ 85 92 void endpoint_add_ref(endpoint_t *ep) 86 93 { … … 88 95 } 89 96 97 /** 98 * Call the desctruction callback. Default behavior is to free the memory directly. 99 */ 90 100 static inline void endpoint_destroy(endpoint_t *ep) 91 101 { … … 101 111 } 102 112 113 /** 114 * Decrease the reference count. 115 */ 103 116 void endpoint_del_ref(endpoint_t *ep) 104 117 { … … 110 123 static void endpoint_toggle_reset(endpoint_t *ep, toggle_reset_mode_t mode); 111 124 112 /** Mark the endpoint as active and block access for further fibrils. 125 /** 126 * Mark the endpoint as active and block access for further fibrils. If the 127 * endpoint is already active, it will block on ep->avail condvar. 128 * 129 * Call only under endpoint guard. After you activate the endpoint and release 130 * the guard, you must assume that particular transfer is already finished/aborted. 131 * 113 132 * @param ep endpoint_t structure. 133 * @param batch Transfer batch this endpoint is bocked by. 114 134 */ 115 135 void endpoint_activate_locked(endpoint_t *ep, usb_transfer_batch_t *batch) … … 125 145 } 126 146 127 /** Mark the endpoint as inactive and allow access for further fibrils. 147 /** 148 * Mark the endpoint as inactive and allow access for further fibrils. 149 * 128 150 * @param ep endpoint_t structure. 129 151 */ … … 140 162 } 141 163 142 /** Abort an active batch on endpoint, if any. 164 /** 165 * Abort an active batch on endpoint, if any. 143 166 * 144 167 * @param[in] ep endpoint_t structure. … … 157 180 } 158 181 182 /** 183 * The transfer on an endpoint can trigger a reset of the toggle bit. This 184 * function calls the respective bus callbacks to resolve it. 185 * 186 * @param ep The endpoint that triggered the reset 187 * @param mode Whether to reset no, one or all endpoints on a device. 188 */ 159 189 static void endpoint_toggle_reset(endpoint_t *ep, toggle_reset_mode_t mode) 160 190 { … … 168 198 return; 169 199 170 device_t *dev = ep->device;171 200 172 201 if (mode == RESET_ALL) { 202 const device_t *dev = ep->device; 173 203 for (usb_endpoint_t i = 0; i < USB_ENDPOINT_MAX; ++i) { 174 204 if (dev->endpoints[i]) … … 180 210 } 181 211 182 ssize_t endpoint_count_bw(endpoint_t *ep, size_t packet_size) 212 /** 213 * Call the bus operation to count bandwidth. 214 * 215 * @param ep Endpoint on which the transfer will take place. 216 * @param size The payload size. 217 */ 218 ssize_t endpoint_count_bw(endpoint_t *ep, size_t size) 183 219 { 184 220 assert(ep); … … 188 224 return 0; 189 225 190 return ops->endpoint_count_bw(ep, packet_size); 191 } 192 193 /** Prepare generic usb_transfer_batch and schedule it. 194 * @param ep Endpoint for which the batch shall be created. 195 * @param target address and endpoint number. 196 * @param setup_data Data to use in setup stage (Control communication type) 197 * @param in Callback for device to host communication. 198 * @param out Callback for host to device communication. 226 return ops->endpoint_count_bw(ep, size); 227 } 228 229 /** 230 * Initiate a transfer on an endpoint. Creates a transfer batch, checks the 231 * bandwidth requirements and schedules the batch. 232 * 233 * @param endpoint Endpoint for which to send the batch 234 * @param target The target of the transfer. 235 * @param direction A direction of the transfer. 236 * @param data A pointer to the data buffer. 237 * @param size Size of the data buffer. 238 * @param setup_data Data to use in the setup stage (Control communication type) 239 * @param on_complete Callback which is called after the batch is complete 199 240 * @param arg Callback parameter. 200 241 * @param name Communication identifier (for nicer output). 201 * @return Error code.202 242 */ 203 243 int endpoint_send_batch(endpoint_t *ep, usb_target_t target,
Note:
See TracChangeset
for help on using the changeset viewer.