Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset ba2fc2c in mainline


Ignore:
Timestamp:
2017-12-19T22:00:50Z (4 years ago)
Author:
Salmelu <salmelu@…>
Branches:
lfn, master
Children:
83fb72e
Parents:
0bb4738
Message:

usbdev: unique sessions for isochronous EPs

Location:
uspace/lib/usbdev
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/include/usb/dev/pipes.h

    r0bb4738 rba2fc2c  
    5858        /** The connection used for sending the data. */
    5959        usb_dev_session_t *bus_session;
     60        /** The session used for isochronous endpoints.
     61         * Required as isochronous sends/receive can block the session.
     62         */
     63        usb_dev_session_t *isoch_session;
    6064} usb_pipe_t;
    6165
  • uspace/lib/usbdev/src/pipes.c

    r0bb4738 rba2fc2c  
    191191        }
    192192
    193         /* Isochronous transfer are not supported (yet) */
    194         if (pipe->desc.transfer_type != USB_TRANSFER_INTERRUPT &&
    195             pipe->desc.transfer_type != USB_TRANSFER_BULK)
    196             return ENOTSUP;
    197 
    198         async_exch_t *exch = async_exchange_begin(pipe->bus_session);
     193        async_exch_t *exch;
     194        if (pipe->desc.transfer_type == USB_TRANSFER_ISOCHRONOUS)
     195                exch = async_exchange_begin(pipe->isoch_session);
     196        else
     197                exch = async_exchange_begin(pipe->bus_session);
    199198        size_t act_size = 0;
    200199        const int rc =
     
    232231        }
    233232
    234         /* Isochronous transfer are not supported (yet) */
    235         if (pipe->desc.transfer_type != USB_TRANSFER_INTERRUPT &&
    236             pipe->desc.transfer_type != USB_TRANSFER_BULK)
    237             return ENOTSUP;
    238 
    239         async_exch_t *exch = async_exchange_begin(pipe->bus_session);
     233        async_exch_t *exch;
     234        if (pipe->desc.transfer_type == USB_TRANSFER_ISOCHRONOUS)
     235                exch = async_exchange_begin(pipe->isoch_session);
     236        else
     237                exch = async_exchange_begin(pipe->bus_session);
     238
    240239        const int rc = usbhc_write(exch, pipe->desc.endpoint_no, 0, buffer, size);
    241240        async_exchange_end(exch);
    242241        return rc;
     242}
     243
     244/** Setup isochronous session for isochronous communication.
     245 *  Isochronous endpoints need a different session as they might block while waiting for data.
     246 *
     247 * @param pipe Endpoint pipe being initialized.
     248 * @return Error code.
     249 */
     250static int usb_isoch_session_initialize(usb_pipe_t *pipe) {
     251        devman_handle_t handle;
     252
     253        async_exch_t *exch = async_exchange_begin(pipe->bus_session);
     254        if (!exch)
     255                return EPARTY;
     256
     257        int ret = usb_get_my_device_handle(exch, &handle);
     258
     259        async_exchange_end(exch);
     260        if (ret != EOK)
     261                return ret;
     262
     263        pipe->isoch_session = usb_dev_connect(handle);
     264        if (!pipe->isoch_session)
     265                return ENAK;
     266
     267        return EOK;
    243268}
    244269
     
    258283        unsigned mult, usb_dev_session_t *bus_session)
    259284{
     285        int ret = EOK;
    260286        // FIXME: refactor this function PLEASE
    261287        assert(pipe);
     
    273299        pipe->bus_session = bus_session;
    274300
    275         return EOK;
     301        if (transfer_type == USB_TRANSFER_ISOCHRONOUS) {
     302                ret = usb_isoch_session_initialize(pipe);
     303        }
     304
     305        return ret;
    276306}
    277307
Note: See TracChangeset for help on using the changeset viewer.