Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/hcd.h

    r8b54fe6 r77ad86c  
    3333 *
    3434 */
     35
    3536#ifndef LIBUSBHOST_HOST_HCD_H
    3637#define LIBUSBHOST_HOST_HCD_H
    3738
    3839#include <assert.h>
     40#include <usbhc_iface.h>
     41
    3942#include <usb/host/usb_device_manager.h>
    4043#include <usb/host/usb_endpoint_manager.h>
    4144#include <usb/host/usb_transfer_batch.h>
    42 #include <usbhc_iface.h>
    4345
    4446typedef struct hcd hcd_t;
    4547
     48/** Generic host controller driver structure. */
    4649struct hcd {
     50        /** Device manager storing handles and addresses. */
    4751        usb_device_manager_t dev_manager;
     52        /** Endpoint manager. */
    4853        usb_endpoint_manager_t ep_manager;
     54
     55        /** Device specific driver data. */
    4956        void *private_data;
     57        /** Transfer scheduling, implement in device driver. */
     58        int (*schedule)(hcd_t *, usb_transfer_batch_t *);
     59        /** Hook called upon registering new endpoint. */
     60        int (*ep_add_hook)(hcd_t *, endpoint_t *);
     61        /** Hook called upon removing of an endpoint. */
     62        void (*ep_remove_hook)(hcd_t *, endpoint_t *);
     63};
    5064
    51         int (*schedule)(hcd_t *, usb_transfer_batch_t *);
    52         int (*ep_add_hook)(hcd_t *, endpoint_t *);
    53 };
    54 /*----------------------------------------------------------------------------*/
    55 static inline int hcd_init(hcd_t *hcd, size_t bandwidth,
     65/** Initialize hcd_t structure.
     66 * Initializes device and endpoint managers. Sets data and hook pointer to NULL.
     67 * @param hcd hcd_t structure to initialize, non-null.
     68 * @param bandwidth Available bandwidth, passed to endpoint manager.
     69 * @param bw_count Bandwidth compute function, passed to endpoint manager.
     70 */
     71static inline void hcd_init(hcd_t *hcd, usb_speed_t max_speed, size_t bandwidth,
    5672    size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t))
    5773{
    5874        assert(hcd);
    59         usb_device_manager_init(&hcd->dev_manager);
    60         return usb_endpoint_manager_init(&hcd->ep_manager, bandwidth, bw_count);
     75        usb_device_manager_init(&hcd->dev_manager, max_speed);
     76        usb_endpoint_manager_init(&hcd->ep_manager, bandwidth, bw_count);
     77        hcd->private_data = NULL;
     78        hcd->schedule = NULL;
     79        hcd->ep_add_hook = NULL;
     80        hcd->ep_remove_hook = NULL;
    6181}
    62 /*----------------------------------------------------------------------------*/
    63 static inline void hcd_destroy(hcd_t *hcd)
    64 {
    65         usb_endpoint_manager_destroy(&hcd->ep_manager);
    66 }
    67 /*----------------------------------------------------------------------------*/
    68 static inline void reset_ep_if_need(
    69     hcd_t *hcd, usb_target_t target, const char* setup_data)
     82
     83/** Check registered endpoints and reset toggle bit if necessary.
     84 * @param hcd hcd_t structure, non-null.
     85 * @param target Control communication target.
     86 * @param setup_data Setup packet of the control communication.
     87 */
     88static inline void reset_ep_if_need(hcd_t *hcd, usb_target_t target,
     89    const char setup_data[8])
    7090{
    7191        assert(hcd);
    72         usb_endpoint_manager_reset_if_need(
     92        usb_endpoint_manager_reset_eps_if_need(
    7393            &hcd->ep_manager, target, (const uint8_t *)setup_data);
    7494}
    75 /*----------------------------------------------------------------------------*/
    76 static inline hcd_t * fun_to_hcd(ddf_fun_t *fun)
     95
     96/** Data retrieve wrapper.
     97 * @param fun ddf function, non-null.
     98 * @return pointer cast to hcd_t*.
     99 */
     100static inline hcd_t * fun_to_hcd(const ddf_fun_t *fun)
    77101{
    78102        assert(fun);
    79103        return fun->driver_data;
    80104}
    81 /*----------------------------------------------------------------------------*/
     105
    82106extern usbhc_iface_t hcd_iface;
    83107
    84108#endif
     109
    85110/**
    86111 * @}
Note: See TracChangeset for help on using the changeset viewer.