Changeset 4d31d58 in mainline


Ignore:
Timestamp:
2010-11-21T21:24:15Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c4ba29c7
Parents:
be2ad7cf
Message:

Control transfers ready for local drivers

Location:
uspace/lib/usb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/hcdhubd.h

    rbe2ad7cf r4d31d58  
    159159    void *, size_t, size_t *, usb_handle_t *);
    160160
     161int usb_hc_async_control_write_setup(usb_hc_device_t *, usb_target_t,
     162    void *, size_t, usb_handle_t *);
     163int usb_hc_async_control_write_data(usb_hc_device_t *, usb_target_t,
     164    void *, size_t, usb_handle_t *);
     165int usb_hc_async_control_write_status(usb_hc_device_t *, usb_target_t,
     166    usb_handle_t *);
     167
     168int usb_hc_async_control_read_setup(usb_hc_device_t *, usb_target_t,
     169    void *, size_t, usb_handle_t *);
     170int usb_hc_async_control_read_data(usb_hc_device_t *, usb_target_t,
     171    void *, size_t, size_t *, usb_handle_t *);
     172int usb_hc_async_control_read_status(usb_hc_device_t *, usb_target_t,
     173    usb_handle_t *);
     174
    161175int usb_hc_async_wait_for(usb_handle_t);
    162176
  • uspace/lib/usb/src/localdrv.c

    rbe2ad7cf r4d31d58  
    182182}
    183183
     184static int async_transfer_out(usb_hc_device_t *hc,
     185    usb_target_t target, usb_transfer_type_t transfer_type,
     186    void *data, size_t size,
     187    usb_handle_t *handle)
     188{
     189        if ((hc->transfer_ops == NULL)
     190            || (hc->transfer_ops->transfer_out == NULL)) {
     191                return ENOTSUP;
     192        }
     193
     194        /* This creation of the device on the fly is just a workaround. */
     195
     196        transfer_info_t *transfer = transfer_info_create(
     197            create_attached_device_info(target.address),
     198            create_endpoint_info(target.endpoint,
     199                USB_DIRECTION_OUT, transfer_type));
     200
     201        int rc = hc->transfer_ops->transfer_out(hc,
     202            transfer->device, transfer->endpoint,
     203            data, size,
     204            callback_out, transfer);
     205
     206        if (rc != EOK) {
     207                transfer_info_destroy(transfer);
     208                return rc;
     209        }
     210
     211        *handle = (usb_handle_t)transfer;
     212
     213        return EOK;
     214}
     215
     216static int async_transfer_setup(usb_hc_device_t *hc,
     217    usb_target_t target, usb_transfer_type_t transfer_type,
     218    void *data, size_t size,
     219    usb_handle_t *handle)
     220{
     221        if ((hc->transfer_ops == NULL)
     222            || (hc->transfer_ops->transfer_setup == NULL)) {
     223                return ENOTSUP;
     224        }
     225
     226        /* This creation of the device on the fly is just a workaround. */
     227
     228        transfer_info_t *transfer = transfer_info_create(
     229            create_attached_device_info(target.address),
     230            create_endpoint_info(target.endpoint,
     231                USB_DIRECTION_OUT, transfer_type));
     232
     233        int rc = hc->transfer_ops->transfer_setup(hc,
     234            transfer->device, transfer->endpoint,
     235            data, size,
     236            callback_out, transfer);
     237
     238        if (rc != EOK) {
     239                transfer_info_destroy(transfer);
     240                return rc;
     241        }
     242
     243        *handle = (usb_handle_t)transfer;
     244
     245        return EOK;
     246}
     247
     248static int async_transfer_in(usb_hc_device_t *hc, usb_target_t target,
     249    usb_transfer_type_t transfer_type,
     250    void *buffer, size_t size, size_t *actual_size,
     251    usb_handle_t *handle)
     252{
     253        if ((hc->transfer_ops == NULL)
     254            || (hc->transfer_ops->transfer_in == NULL)) {
     255                return ENOTSUP;
     256        }
     257
     258        /* This creation of the device on the fly is just a workaround. */
     259
     260        transfer_info_t *transfer = transfer_info_create(
     261            create_attached_device_info(target.address),
     262            create_endpoint_info(target.endpoint,
     263                USB_DIRECTION_IN, transfer_type));
     264        transfer->size_transferred = actual_size;
     265
     266        int rc = hc->transfer_ops->transfer_in(hc,
     267            transfer->device, transfer->endpoint,
     268            buffer, size,
     269            callback_in, transfer);
     270
     271        if (rc != EOK) {
     272                transfer_info_destroy(transfer);
     273                return rc;
     274        }
     275
     276        *handle = (usb_handle_t)transfer;
     277
     278        return EOK;
     279}
     280
     281
    184282/** Issue interrupt OUT transfer to HC driven by current task.
    185283 *
     
    195293    usb_handle_t *handle)
    196294{
    197         if ((hc->transfer_ops == NULL)
    198             || (hc->transfer_ops->transfer_out == NULL)) {
    199                 return ENOTSUP;
    200         }
    201 
    202         /* This creation of the device on the fly is just a workaround. */
    203 
    204         transfer_info_t *transfer = transfer_info_create(
    205             create_attached_device_info(target.address),
    206             create_endpoint_info(target.endpoint,
    207                 USB_DIRECTION_OUT, USB_TRANSFER_INTERRUPT));
    208 
    209         int rc = hc->transfer_ops->transfer_out(hc,
    210             transfer->device, transfer->endpoint,
    211             buffer, size,
    212             callback_out, transfer);
    213 
    214         if (rc != EOK) {
    215                 transfer_info_destroy(transfer);
    216                 return rc;
    217         }
    218 
    219         *handle = (usb_handle_t)transfer;
    220 
    221         return EOK;
     295        return async_transfer_out(hc, target,
     296            USB_TRANSFER_INTERRUPT, buffer, size, handle);
    222297}
    223298
     
    240315    usb_handle_t *handle)
    241316{
    242         if ((hc->transfer_ops == NULL)
    243             || (hc->transfer_ops->transfer_in == NULL)) {
    244                 return ENOTSUP;
    245         }
    246 
    247         /* This creation of the device on the fly is just a workaround. */
    248 
    249         transfer_info_t *transfer = transfer_info_create(
    250             create_attached_device_info(target.address),
    251             create_endpoint_info(target.endpoint,
    252                 USB_DIRECTION_IN, USB_TRANSFER_INTERRUPT));
    253         transfer->size_transferred = actual_size;
    254 
    255         int rc = hc->transfer_ops->transfer_in(hc,
    256             transfer->device, transfer->endpoint,
    257             buffer, size,
    258             callback_in, transfer);
    259 
    260         if (rc != EOK) {
    261                 transfer_info_destroy(transfer);
    262                 return rc;
    263         }
    264 
    265         *handle = (usb_handle_t)transfer;
    266 
    267         return EOK;
     317        return async_transfer_in(hc, target,
     318            USB_TRANSFER_INTERRUPT, buffer, size, actual_size, handle);
     319}
     320
     321int usb_hc_async_control_write_setup(usb_hc_device_t *hc, usb_target_t target,
     322    void *data, size_t size, usb_handle_t *handle)
     323{
     324        return async_transfer_setup(hc, target,
     325            USB_TRANSFER_CONTROL, data, size, handle);
     326}
     327
     328int usb_hc_async_control_write_data(usb_hc_device_t *hc, usb_target_t target,
     329    void *data, size_t size, usb_handle_t *handle)
     330{
     331        return async_transfer_out(hc, target,
     332            USB_TRANSFER_CONTROL, data, size, handle);
     333}
     334
     335int usb_hc_async_control_write_status(usb_hc_device_t *hc, usb_target_t target,
     336    usb_handle_t *handle)
     337{
     338        return async_transfer_in(hc, target,
     339            USB_TRANSFER_CONTROL, NULL, 0, NULL, handle);
     340}
     341
     342int usb_hc_async_control_read_setup(usb_hc_device_t *hc, usb_target_t target,
     343    void *data, size_t size, usb_handle_t *handle)
     344{
     345        return async_transfer_setup(hc, target,
     346            USB_TRANSFER_CONTROL, data, size, handle);
     347}
     348
     349int usb_hc_async_control_read_data(usb_hc_device_t *hc, usb_target_t target,
     350    void *buffer, size_t size, size_t *actual_size,
     351    usb_handle_t *handle)
     352{
     353        return async_transfer_in(hc, target,
     354            USB_TRANSFER_CONTROL, buffer, size, actual_size, handle);
     355}
     356
     357int usb_hc_async_control_read_status(usb_hc_device_t *hc, usb_target_t target,
     358    usb_handle_t *handle)
     359{
     360        return async_transfer_out(hc, target,
     361            USB_TRANSFER_CONTROL, NULL, 0, handle);
    268362}
    269363
Note: See TracChangeset for help on using the changeset viewer.