source: mainline/uspace/lib/usbhost/include/usb/host/hcd.h@ ba4a03a5

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since ba4a03a5 was 8d2e251, checked in by Jan Vesely <jano.vesely@…>, 12 years ago

libusbhost: Sanitize headers.

Include what you use.
https://code.google.com/p/include-what-you-use/

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*
2 * Copyright (c) 2011 Jan Vesely
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libusbhost
30 * @{
31 */
32/** @file
33 *
34 */
35
36#ifndef LIBUSBHOST_HOST_HCD_H
37#define LIBUSBHOST_HOST_HCD_H
38
39#include <usb/host/endpoint.h>
40#include <usb/host/usb_bus.h>
41#include <usb/host/usb_transfer_batch.h>
42#include <usb/usb.h>
43
44#include <assert.h>
45#include <usbhc_iface.h>
46#include <sys/types.h>
47
48typedef struct hcd hcd_t;
49
50typedef int (*schedule_hook_t)(hcd_t *, usb_transfer_batch_t *);
51typedef int (*ep_add_hook_t)(hcd_t *, endpoint_t *);
52typedef void (*ep_remove_hook_t)(hcd_t *, endpoint_t *);
53
54typedef struct {
55 /** Device specific driver data. */
56 void *data;
57 /** Transfer scheduling, implement in device driver. */
58 schedule_hook_t schedule;
59 /** Hook called upon registering new endpoint. */
60 ep_add_hook_t ep_add_hook;
61 /** Hook called upon removing of an endpoint. */
62 ep_remove_hook_t ep_remove_hook;
63} hc_driver_t;
64
65/** Generic host controller driver structure. */
66struct hcd {
67 /** Endpoint manager. */
68 usb_bus_t bus;
69
70 /** Driver implementation */
71 hc_driver_t driver;
72};
73
74void hcd_init(hcd_t *hcd, usb_speed_t max_speed, size_t bandwidth,
75 bw_count_func_t bw_count);
76
77static inline void hcd_set_implementation(hcd_t *hcd, void *data,
78 schedule_hook_t schedule, ep_add_hook_t add_hook, ep_remove_hook_t rem_hook)
79{
80 assert(hcd);
81 hcd->driver.data = data;
82 hcd->driver.schedule = schedule;
83 hcd->driver.ep_add_hook = add_hook;
84 hcd->driver.ep_remove_hook = rem_hook;
85}
86
87usb_address_t hcd_request_address(hcd_t *hcd, usb_speed_t speed);
88
89int hcd_release_address(hcd_t *hcd, usb_address_t address);
90
91int hcd_reserve_default_address(hcd_t *hcd, usb_speed_t speed);
92
93static inline int hcd_release_default_address(hcd_t *hcd)
94{
95 return hcd_release_address(hcd, USB_ADDRESS_DEFAULT);
96}
97
98int hcd_add_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir,
99 usb_transfer_type_t type, size_t max_packet_size, size_t size,
100 usb_address_t tt_address, unsigned tt_port);
101
102int hcd_remove_ep(hcd_t *hcd, usb_target_t target, usb_direction_t dir);
103
104int hcd_send_batch(hcd_t *hcd, usb_target_t target, usb_direction_t direction,
105 void *data, size_t size, uint64_t setup_data,
106 usbhc_iface_transfer_in_callback_t in,
107 usbhc_iface_transfer_out_callback_t out, void *arg, const char* name);
108
109ssize_t hcd_send_batch_sync(hcd_t *hcd, usb_target_t target,
110 usb_direction_t dir, void *data, size_t size, uint64_t setup_data,
111 const char* name);
112
113#endif
114/**
115 * @}
116 */
Note: See TracBrowser for help on using the repository browser.