Changeset 22ecbde in mainline
- Timestamp:
- 2011-12-14T15:24:30Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6e3c005
- Parents:
- bdb23c63
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/src/pipes.c
rbdb23c63 r22ecbde 40 40 /** Prepare pipe for a long transfer. 41 41 * 42 * By a long transfer is mean transfer consisting of several 43 * requests to the HC. 44 * Calling such function is optional and it has positive effect of 42 * Long transfer is transfer consisting of several requests to the HC. 43 * Calling this function is optional and it has positive effect of 45 44 * improved performance because IPC session is initiated only once. 46 45 * … … 57 56 /*----------------------------------------------------------------------------*/ 58 57 /** Terminate a long transfer on a pipe. 59 * 58 * @param pipe Pipe where to end the long transfer. 59 * @return Error code. 60 60 * @see usb_pipe_start_long_transfer 61 *62 * @param pipe Pipe where to end the long transfer.63 61 */ 64 62 int usb_pipe_end_long_transfer(usb_pipe_t *pipe) … … 70 68 } 71 69 /*----------------------------------------------------------------------------*/ 72 /** Request an in transfer, no checking of input parameters.73 *74 * @param[in] pipe Pipe used for the transfer.75 * @param[out] buffer Buffer where to store the data.76 * @param[in] size Size of the buffer (in bytes).77 * @param[out] size_transfered Number of bytes that were actually transfered.78 * @return Error code.79 */80 static int usb_pipe_read_no_check(usb_pipe_t *pipe, uint64_t setup,81 void *buffer, size_t size, size_t *size_transfered)82 {83 /* Isochronous transfer are not supported (yet) */84 if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&85 pipe->transfer_type != USB_TRANSFER_BULK &&86 pipe->transfer_type != USB_TRANSFER_CONTROL)87 return ENOTSUP;88 89 return usb_device_control_read(pipe->wire,90 pipe->endpoint_no, setup, buffer, size, size_transfered);91 }92 /*----------------------------------------------------------------------------*/93 /** Request an out transfer, no checking of input parameters.94 *95 * @param[in] pipe Pipe used for the transfer.96 * @param[in] buffer Buffer with data to transfer.97 * @param[in] size Size of the buffer (in bytes).98 * @return Error code.99 */100 static int usb_pipe_write_no_check(usb_pipe_t *pipe, uint64_t setup,101 const void *buffer, size_t size)102 {103 /* Only interrupt and bulk transfers are supported */104 if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&105 pipe->transfer_type != USB_TRANSFER_BULK &&106 pipe->transfer_type != USB_TRANSFER_CONTROL)107 return ENOTSUP;108 109 return usb_device_control_write(pipe->wire,110 pipe->endpoint_no, setup, buffer, size);111 }112 /*----------------------------------------------------------------------------*/113 70 /** Try to clear endpoint halt of default control pipe. 114 71 * … … 122 79 return; 123 80 } 124 125 81 126 82 /* Prevent infinite recursion. */ … … 145 101 int usb_pipe_control_read(usb_pipe_t *pipe, 146 102 const void *setup_buffer, size_t setup_buffer_size, 147 void * data_buffer, size_t data_buffer_size, size_t *data_transfered_size)103 void *buffer, size_t buffer_size, size_t *transfered_size) 148 104 { 149 105 assert(pipe); … … 153 109 } 154 110 155 if (( data_buffer == NULL) || (data_buffer_size == 0)) {111 if ((buffer == NULL) || (buffer_size == 0)) { 156 112 return EINVAL; 157 113 } … … 162 118 } 163 119 120 /* Isochronous transfer are not supported (yet) */ 121 if (pipe->transfer_type != USB_TRANSFER_INTERRUPT && 122 pipe->transfer_type != USB_TRANSFER_BULK && 123 pipe->transfer_type != USB_TRANSFER_CONTROL) 124 return ENOTSUP; 125 164 126 uint64_t setup_packet; 165 127 memcpy(&setup_packet, setup_buffer, 8); 166 128 167 129 size_t act_size = 0; 168 const int rc = usb_ pipe_read_no_check(pipe, setup_packet,169 data_buffer, data_buffer_size, &act_size);130 const int rc = usb_device_control_read(pipe->wire, 131 pipe->endpoint_no, setup_packet, buffer, buffer_size, &act_size); 170 132 171 133 if (rc == ESTALL) { … … 173 135 } 174 136 175 if (rc == EOK && data_transfered_size != NULL) {176 * data_transfered_size = act_size;137 if (rc == EOK && transfered_size != NULL) { 138 *transfered_size = act_size; 177 139 } 178 140 … … 193 155 int usb_pipe_control_write(usb_pipe_t *pipe, 194 156 const void *setup_buffer, size_t setup_buffer_size, 195 const void * data_buffer, size_t data_buffer_size)157 const void *buffer, size_t buffer_size) 196 158 { 197 159 assert(pipe); … … 201 163 } 202 164 203 if (( data_buffer == NULL) && (data_buffer_size > 0)) {204 return EINVAL; 205 } 206 207 if (( data_buffer != NULL) && (data_buffer_size == 0)) {165 if ((buffer == NULL) && (buffer_size > 0)) { 166 return EINVAL; 167 } 168 169 if ((buffer != NULL) && (buffer_size == 0)) { 208 170 return EINVAL; 209 171 } … … 214 176 } 215 177 178 /* Isochronous transfer are not supported (yet) */ 179 if (pipe->transfer_type != USB_TRANSFER_INTERRUPT && 180 pipe->transfer_type != USB_TRANSFER_BULK && 181 pipe->transfer_type != USB_TRANSFER_CONTROL) 182 return ENOTSUP; 183 216 184 uint64_t setup_packet; 217 185 memcpy(&setup_packet, setup_buffer, 8); 218 186 219 const int rc = usb_ pipe_write_no_check(pipe, setup_packet,220 data_buffer, data_buffer_size);187 const int rc = usb_device_control_write(pipe->wire, 188 pipe->endpoint_no, setup_packet, buffer, buffer_size); 221 189 222 190 if (rc == ESTALL) { … … 256 224 } 257 225 226 /* Isochronous transfer are not supported (yet) */ 227 if (pipe->transfer_type != USB_TRANSFER_INTERRUPT && 228 pipe->transfer_type != USB_TRANSFER_BULK && 229 pipe->transfer_type != USB_TRANSFER_CONTROL) 230 return ENOTSUP; 231 258 232 size_t act_size = 0; 259 const int rc = usb_ pipe_read_no_check(pipe, 0, buffer, size, &act_size);260 233 const int rc = usb_device_read(pipe->wire, 234 pipe->endpoint_no, buffer, size, &act_size); 261 235 262 236 if (rc == EOK && size_transfered != NULL) { … … 290 264 } 291 265 292 return usb_pipe_write_no_check(pipe, 0, buffer, size); 266 /* Isochronous transfer are not supported (yet) */ 267 if (pipe->transfer_type != USB_TRANSFER_INTERRUPT && 268 pipe->transfer_type != USB_TRANSFER_BULK && 269 pipe->transfer_type != USB_TRANSFER_CONTROL) 270 return ENOTSUP; 271 272 return usb_device_write(pipe->wire, 273 pipe->endpoint_no, buffer, size); 293 274 } 294 275 /*----------------------------------------------------------------------------*/
Note:
See TracChangeset
for help on using the changeset viewer.