root / lab4 / .minix-src / include / ddekit / usb.h @ 13
History | View | Annotate | Download (2.78 KB)
1 | 13 | up20180614 | #ifndef _DDEKIT_USB_H
|
---|---|---|---|
2 | #define _DDEKIT_USB_H
|
||
3 | |||
4 | #include <ddekit/ddekit.h> |
||
5 | #include <ddekit/types.h> |
||
6 | |||
7 | /** isochronous transfer */
|
||
8 | #define DDEKIT_USB_TRANSFER_ISO 0 |
||
9 | /** interrupt transfer */
|
||
10 | #define DDEKIT_USB_TRANSFER_INT 1 |
||
11 | /** control transfer */
|
||
12 | #define DDEKIT_USB_TRANSFER_CTL 2 |
||
13 | /** bulk transfer */
|
||
14 | #define DDEKIT_USB_TRANSFER_BLK 3 |
||
15 | |||
16 | #define DDEKIT_USB_IN 1 |
||
17 | #define DDEKIT_USB_OUT 0 |
||
18 | |||
19 | struct ddekit_usb_dev;
|
||
20 | struct ddekit_usb_urb;
|
||
21 | |||
22 | struct ddekit_usb_device_id {
|
||
23 | ddekit_uint16_t idVendor; |
||
24 | ddekit_uint16_t idProduct; |
||
25 | ddekit_uint32_t bcdDevice; |
||
26 | |||
27 | ddekit_uint8_t bDeviceClass; |
||
28 | ddekit_uint8_t bDeviceSubClass; |
||
29 | ddekit_uint8_t bDeviceProtocol; |
||
30 | |||
31 | ddekit_uint8_t bInterfaceClass; |
||
32 | ddekit_uint8_t bInterfaceSubClass; |
||
33 | ddekit_uint8_t bInterfaceProtocol; |
||
34 | |||
35 | }; |
||
36 | |||
37 | struct ddekit_usb_iso_packet_desc {
|
||
38 | ddekit_int32_t offset; |
||
39 | ddekit_int32_t length; /* expected length */
|
||
40 | ddekit_int32_t actual_length; |
||
41 | ddekit_int32_t status; |
||
42 | }; |
||
43 | |||
44 | typedef void (*ddekit_usb_completion_cb)(void* priv); |
||
45 | |||
46 | typedef void (*ddekit_usb_connect_cb)(struct ddekit_usb_dev *dev, |
||
47 | unsigned int interfaces); |
||
48 | |||
49 | typedef void (*ddekit_usb_disconnect_cb)(struct ddekit_usb_dev *dev); |
||
50 | |||
51 | typedef void *(*ddekit_usb_malloc_fn)(unsigned size); |
||
52 | typedef void (*ddekit_usb_free_fn)(void *ptr); |
||
53 | |||
54 | struct ddekit_usb_driver {
|
||
55 | ddekit_usb_completion_cb completion; |
||
56 | ddekit_usb_connect_cb connect; |
||
57 | ddekit_usb_disconnect_cb disconnect; |
||
58 | }; |
||
59 | |||
60 | |||
61 | struct ddekit_usb_urb {
|
||
62 | struct ddekit_usb_dev *dev;
|
||
63 | ddekit_int32_t type; |
||
64 | ddekit_int32_t endpoint; |
||
65 | ddekit_int32_t direction; |
||
66 | ddekit_int32_t status; |
||
67 | ddekit_int32_t interval; |
||
68 | ddekit_uint32_t transfer_flags; |
||
69 | ddekit_uint32_t size; |
||
70 | ddekit_uint32_t actual_length; |
||
71 | ddekit_int32_t number_of_packets; |
||
72 | ddekit_int32_t error_count; |
||
73 | ddekit_int32_t start_frame; |
||
74 | char *setup_packet;
|
||
75 | char *data;
|
||
76 | struct ddekit_usb_iso_packet_desc *iso_desc;
|
||
77 | void *priv;
|
||
78 | void *ddekit_priv;
|
||
79 | }; |
||
80 | |||
81 | /* USB message types */
|
||
82 | typedef enum { |
||
83 | |||
84 | DDEKIT_HUB_PORT_LS_CONN, /* Low speed device connected */
|
||
85 | DDEKIT_HUB_PORT_FS_CONN, /* Full speed device connected */
|
||
86 | DDEKIT_HUB_PORT_HS_CONN, /* High speed device connected */
|
||
87 | DDEKIT_HUB_PORT_DISCONN /* Device disconnected */
|
||
88 | } |
||
89 | ddekit_msg_type_t; |
||
90 | |||
91 | int ddekit_usb_dev_set_data(struct ddekit_usb_dev *dev, void *data); |
||
92 | void *ddekit_usb_dev_get_data(struct ddekit_usb_dev *dev); |
||
93 | void ddekit_usb_get_device_id(struct ddekit_usb_dev *dev, struct |
||
94 | ddekit_usb_device_id *id); |
||
95 | int ddekit_usb_submit_urb(struct ddekit_usb_urb *d_urb); |
||
96 | int ddekit_usb_cancle_urb(struct ddekit_usb_urb *d_urb); |
||
97 | long ddekit_usb_info(struct ddekit_usb_dev *, long, long); |
||
98 | |||
99 | /*
|
||
100 | * This one is only implemented for the client side. For the server side is
|
||
101 | * has to be implemented in the DDELinux/FBSD part.
|
||
102 | */
|
||
103 | int ddekit_usb_init(struct ddekit_usb_driver *drv, ddekit_usb_malloc_fn |
||
104 | *_m, ddekit_usb_free_fn *_f); |
||
105 | |||
106 | #endif |