4 #include <ddekit/ddekit.h>
5 #include <ddekit/types.h>
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
14 #define DDEKIT_USB_TRANSFER_BLK 3
16 #define DDEKIT_USB_IN 1
17 #define DDEKIT_USB_OUT 0
19 struct ddekit_usb_dev
;
20 struct ddekit_usb_urb
;
22 struct ddekit_usb_device_id
{
23 ddekit_uint16_t idVendor
;
24 ddekit_uint16_t idProduct
;
25 ddekit_uint32_t bcdDevice
;
27 ddekit_uint8_t bDeviceClass
;
28 ddekit_uint8_t bDeviceSubClass
;
29 ddekit_uint8_t bDeviceProtocol
;
31 ddekit_uint8_t bInterfaceClass
;
32 ddekit_uint8_t bInterfaceSubClass
;
33 ddekit_uint8_t bInterfaceProtocol
;
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
;
44 typedef void (*ddekit_usb_completion_cb
)(void* priv
);
46 typedef void (*ddekit_usb_connect_cb
)(struct ddekit_usb_dev
*dev
,
47 unsigned int interfaces
);
49 typedef void (*ddekit_usb_disconnect_cb
)(struct ddekit_usb_dev
*dev
);
51 typedef void *(*ddekit_usb_malloc_fn
)(unsigned size
);
52 typedef void (*ddekit_usb_free_fn
)(void *ptr
);
54 struct ddekit_usb_driver
{
55 ddekit_usb_completion_cb completion
;
56 ddekit_usb_connect_cb connect
;
57 ddekit_usb_disconnect_cb disconnect
;
61 struct ddekit_usb_urb
{
62 struct ddekit_usb_dev
*dev
;
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
;
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
;
76 struct ddekit_usb_iso_packet_desc
*iso_desc
;
81 /* USB message types */
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 */
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);
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.
103 int ddekit_usb_init(struct ddekit_usb_driver
*drv
, ddekit_usb_malloc_fn
104 *_m
, ddekit_usb_free_fn
*_f
);