Changeset 1af4c00 in mainline for uspace/drv/bus/usb/xhci/streams.c


Ignore:
Timestamp:
2018-01-17T13:28:34Z (8 years ago)
Author:
Salmelu <salmelu@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4cc0c2e0
Parents:
61e27e80
Message:

xhci: fixed transition to and from streams

Added remove streams function to transition the endpoint back to single ring no streams mode.
Requesting streams now stops the endpoint, clears the ring and executes update endpoint command.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/streams.c

    r61e27e80 r1af4c00  
    110110        dma_buffer_free(&xhci_ep->primary_stream_ctx_dma);
    111111        free(xhci_ep->primary_stream_data_array);
     112
     113        xhci_ep->primary_stream_data_array = NULL;
     114        xhci_ep->primary_stream_data_size = 0;
    112115}
    113116
     
    312315}
    313316
     317/** Cancels streams and reconfigures endpoint back to single ring no stream endpoint.
     318 * @param[in] hc Host controller of the endpoint.
     319 * @param[in] dev Used device.
     320 * @param[in] xhci_ep Associated XHCI bulk endpoint.
     321 */
     322int xhci_endpoint_remove_streams(xhci_hc_t *hc, xhci_device_t *dev, xhci_endpoint_t *xhci_ep)
     323{
     324        if (!xhci_ep->primary_stream_data_size) {
     325                usb_log_warning("There are no streams enabled on the endpoint, doing nothing.");
     326                return EOK;
     327        }
     328
     329        hc_stop_endpoint(hc, dev->slot_id, xhci_endpoint_index(xhci_ep));
     330        xhci_endpoint_free_transfer_ds(xhci_ep);
     331
     332        /* Streams are now removed, proceed with reconfiguring endpoint. */
     333        int err;
     334        if ((err = xhci_trb_ring_init(&xhci_ep->ring))) {
     335                usb_log_error("Failed to initialize a transfer ring.");
     336                return err;
     337        }
     338
     339        xhci_ep_ctx_t ep_ctx;
     340        memset(&ep_ctx, 0, sizeof(ep_ctx));
     341        xhci_setup_endpoint_context(xhci_ep, &ep_ctx);
     342        return hc_update_endpoint(hc, dev->slot_id, xhci_endpoint_index(xhci_ep), &ep_ctx);
     343}
     344
    314345/** Initialize, setup and register primary streams.
    315346 * @param[in] hc Host controller of the endpoint.
     
    325356                return err;
    326357        }
     358
     359        /*
     360         * We have passed the checks.
     361         * Stop the endpoint, destroy the ring, and transition to streams.
     362         */
     363        hc_stop_endpoint(hc, dev->slot_id, xhci_endpoint_index(xhci_ep));
     364        xhci_endpoint_free_transfer_ds(xhci_ep);
    327365
    328366        err = initialize_primary_structures(xhci_ep, count);
     
    343381        setup_stream_context(xhci_ep, &ep_ctx, pstreams, 1);
    344382
    345         // FIXME: do we add endpoint? do we need to destroy previous configuration?
    346         return hc_add_endpoint(hc, dev->slot_id, xhci_endpoint_index(xhci_ep), &ep_ctx);
     383        return hc_update_endpoint(hc, dev->slot_id, xhci_endpoint_index(xhci_ep), &ep_ctx);
    347384}
    348385
     
    393430        }
    394431
     432        /*
     433         * We have passed all checks.
     434         * Stop the endpoint, destroy the ring, and transition to streams.
     435         */
     436        hc_stop_endpoint(hc, dev->slot_id, xhci_endpoint_index(xhci_ep));
     437        xhci_endpoint_free_transfer_ds(xhci_ep);
     438
    395439        err = initialize_primary_structures(xhci_ep, count);
    396440        if (err) {
     
    411455        setup_stream_context(xhci_ep, &ep_ctx, pstreams, 0);
    412456
    413         // FIXME: do we add endpoint? do we need to destroy previous configuration?
    414         return hc_add_endpoint(hc, dev->slot_id, xhci_endpoint_index(xhci_ep), &ep_ctx);
     457        return hc_update_endpoint(hc, dev->slot_id, xhci_endpoint_index(xhci_ep), &ep_ctx);
    415458
    416459err_init:
Note: See TracChangeset for help on using the changeset viewer.