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 int ddekit_usb_dev_set_data(struct ddekit_usb_dev
*dev
, void *data
);
82 void *ddekit_usb_dev_get_data(struct ddekit_usb_dev
*dev
);
83 void ddekit_usb_get_device_id(struct ddekit_usb_dev
*dev
, struct
84 ddekit_usb_device_id
*id
);
85 int ddekit_usb_submit_urb(struct ddekit_usb_urb
*d_urb
);
86 int ddekit_usb_cancle_urb(struct ddekit_usb_urb
*d_urb
);
89 * This one is only implemented for the client side. For the server side is
90 * has to be implemented in the DDELinux/FBSD part.
92 int ddekit_usb_init(struct ddekit_usb_driver
*drv
, ddekit_usb_malloc_fn
93 *_m
, ddekit_usb_free_fn
*_f
);