Changeset 1102eca in mainline for uspace/lib/usbhost/src/endpoint.c


Ignore:
Timestamp:
2018-01-08T17:17:38Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bdd8842c
Parents:
eb928c4
Message:

usbhost: documentation & cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/endpoint.c

    reb928c4 r1102eca  
    4949#include "endpoint.h"
    5050
    51 /** Initialize provided endpoint structure.
     51/**
     52 * Initialize provided endpoint structure.
    5253 */
    5354void endpoint_init(endpoint_t *ep, device_t *dev, const usb_endpoint_descriptors_t *desc)
     
    7879}
    7980
     81/**
     82 * Get the bus endpoint belongs to.
     83 */
    8084static inline const bus_ops_t *get_bus_ops(endpoint_t *ep)
    8185{
     
    8387}
    8488
     89/**
     90 * Increase the reference count on endpoint.
     91 */
    8592void endpoint_add_ref(endpoint_t *ep)
    8693{
     
    8895}
    8996
     97/**
     98 * Call the desctruction callback. Default behavior is to free the memory directly.
     99 */
    90100static inline void endpoint_destroy(endpoint_t *ep)
    91101{
     
    101111}
    102112
     113/**
     114 * Decrease the reference count.
     115 */
    103116void endpoint_del_ref(endpoint_t *ep)
    104117{
     
    110123static void endpoint_toggle_reset(endpoint_t *ep, toggle_reset_mode_t mode);
    111124
    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 *
    113132 * @param ep endpoint_t structure.
     133 * @param batch Transfer batch this endpoint is bocked by.
    114134 */
    115135void endpoint_activate_locked(endpoint_t *ep, usb_transfer_batch_t *batch)
     
    125145}
    126146
    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 *
    128150 * @param ep endpoint_t structure.
    129151 */
     
    140162}
    141163
    142 /** Abort an active batch on endpoint, if any.
     164/**
     165 * Abort an active batch on endpoint, if any.
    143166 *
    144167 * @param[in] ep endpoint_t structure.
     
    157180}
    158181
     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 */
    159189static void endpoint_toggle_reset(endpoint_t *ep, toggle_reset_mode_t mode)
    160190{
     
    168198                return;
    169199
    170         device_t *dev = ep->device;
    171200
    172201        if (mode == RESET_ALL) {
     202                const device_t *dev = ep->device;
    173203                for (usb_endpoint_t i = 0; i < USB_ENDPOINT_MAX; ++i) {
    174204                        if (dev->endpoints[i])
     
    180210}
    181211
    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 */
     218ssize_t endpoint_count_bw(endpoint_t *ep, size_t size)
    183219{
    184220        assert(ep);
     
    188224                return 0;
    189225
    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
    199240 * @param arg Callback parameter.
    200241 * @param name Communication identifier (for nicer output).
    201  * @return Error code.
    202242 */
    203243int endpoint_send_batch(endpoint_t *ep, usb_target_t target,
Note: See TracChangeset for help on using the changeset viewer.