Changes in uspace/lib/usbhost/include/usb/host/hcd.h [8b54fe6:5e07cbc0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/hcd.h
r8b54fe6 r5e07cbc0 37 37 38 38 #include <assert.h> 39 #include <usbhc_iface.h> 40 39 41 #include <usb/host/usb_device_manager.h> 40 42 #include <usb/host/usb_endpoint_manager.h> 41 43 #include <usb/host/usb_transfer_batch.h> 42 #include <usbhc_iface.h>43 44 44 45 typedef struct hcd hcd_t; 45 46 47 /** Generic host controller driver structure. */ 46 48 struct hcd { 49 /** Device manager storing handles and addresses. */ 47 50 usb_device_manager_t dev_manager; 51 /** Endpoint manager. */ 48 52 usb_endpoint_manager_t ep_manager; 53 54 /** Device specific driver data. */ 49 55 void *private_data; 50 56 /** Transfer scheduling, implement in device driver. */ 51 57 int (*schedule)(hcd_t *, usb_transfer_batch_t *); 58 /** Hook called upon registering new endpoint. */ 52 59 int (*ep_add_hook)(hcd_t *, endpoint_t *); 60 /** Hook called upon removing of an endpoint. */ 61 void (*ep_remove_hook)(hcd_t *, endpoint_t *); 53 62 }; 54 63 /*----------------------------------------------------------------------------*/ 55 static inline int hcd_init(hcd_t *hcd, size_t bandwidth, 64 /** Initialize hcd_t structure. 65 * Initializes device and endpoint managers. Sets data nd hook pointer to NULL. 66 * @param hcd hcd_t structure to initialize, non-null. 67 * @param bandwidth Available bandwidth, passed to endpoint manager. 68 * @param bw_count Bandwidth compute function, passed to endpoint manager. 69 */ 70 static inline void hcd_init(hcd_t *hcd, usb_speed_t max_speed, size_t bandwidth, 56 71 size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t)) 57 72 { 58 73 assert(hcd); 59 usb_device_manager_init(&hcd->dev_manager); 60 return usb_endpoint_manager_init(&hcd->ep_manager, bandwidth, bw_count); 74 usb_device_manager_init(&hcd->dev_manager, max_speed); 75 usb_endpoint_manager_init(&hcd->ep_manager, bandwidth, bw_count); 76 hcd->private_data = NULL; 77 hcd->schedule = NULL; 78 hcd->ep_add_hook = NULL; 79 hcd->ep_remove_hook = NULL; 61 80 } 62 81 /*----------------------------------------------------------------------------*/ 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 /** Check registered endpoints and reset toggle bit if necessary. 83 * @param hcd hcd_t structure, non-null. 84 * @param target Control communication target. 85 * @param setup_data Setup packet of the control communication. 86 */ 87 static inline void reset_ep_if_need(hcd_t *hcd, usb_target_t target, 88 const char setup_data[8]) 70 89 { 71 90 assert(hcd); 72 usb_endpoint_manager_reset_ if_need(91 usb_endpoint_manager_reset_eps_if_need( 73 92 &hcd->ep_manager, target, (const uint8_t *)setup_data); 74 93 } 75 94 /*----------------------------------------------------------------------------*/ 76 static inline hcd_t * fun_to_hcd(ddf_fun_t *fun) 95 /** Data retrieve wrapper. 96 * @param fun ddf function, non-null. 97 * @return pointer cast to hcd_t*. 98 */ 99 static inline hcd_t * fun_to_hcd(const ddf_fun_t *fun) 77 100 { 78 101 assert(fun);
Note:
See TracChangeset
for help on using the changeset viewer.