9 #define USB_MAXPATH IPC_MAXPATH_LEN
14 /* Descriptor types */
15 #define USB_DT_DEVICE 0x01
16 #define USB_DT_CONFIG 0x02
17 #define USB_DT_STRING 0x03
18 #define USB_DT_INTERFACE 0x04
19 #define USB_DT_ENDPOINT 0x05
20 #define USB_DT_HID 0x21
21 #define USB_DT_REPORT 0x22
23 /* Standard requests */
24 #define USB_REQ_GETSTATUS 0x00
25 #define USB_REQ_CLEARFEATURE 0x01
26 #define USB_REQ_SETFEATURE 0x03
27 #define USB_REQ_SETADDRESS 0x05
28 #define USB_REQ_GETDESCRIPTOR 0x06
29 #define USB_REQ_SETDESCRIPTOR 0x07
30 #define USB_REQ_GETCONFIG 0x08
31 #define USB_REQ_SETCONFIG 0x09
32 #define USB_REQ_GETINTERFACE 0x0a
33 #define USB_REQ_SETINTERFACE 0x0b
34 #define USB_REQ_SYNCFRAME 0x0c
36 /* Descriptor sizes per descriptor type */
37 #define USB_DT_DEVICE_SIZE 18
38 #define USB_DT_CONFIG_SIZE 9
39 #define USB_DT_INTERFACE_SIZE 9
40 #define USB_DT_ENDPOINT_SIZE 7
41 #define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
42 #define USB_DT_HID_SIZE 9
43 #define USB_DT_HUB_NONVAR_SIZE 7
45 /* control message request type bitmask */
46 #define USB_CTRLTYPE_DIR_HOST2DEVICE (0<<7)
47 #define USB_CTRLTYPE_DIR_DEVICE2HOST (1<<7)
48 #define USB_CTRLTYPE_TYPE_STANDARD (0<<5)
49 #define USB_CTRLTYPE_TYPE_CLASS (1<<5)
50 #define USB_CTRLTYPE_TYPE_VENDOR (2<<5)
51 #define USB_CTRLTYPE_TYPE_RESERVED (3<<5)
52 #define USB_CTRLTYPE_REC_DEVICE 0
53 #define USB_CTRLTYPE_REC_INTERFACE 1
54 #define USB_CTRLTYPE_REC_ENDPOINT 2
55 #define USB_CTRLTYPE_REC_OTHER 3
57 #define USB_FEATURE_ENDPOINT_HALT 0
59 #define USB_ENPOINT_INTERRUPT 0x03
60 #define USB_ENDPOINT_IN 0x80
61 #define USB_ENDPOINT_OUT 0x00
66 #endif /* __cplusplus */
68 typedef struct _usbendpointdesc
76 } ATTRIBUTE_PACKED usb_endpointdesc
;
78 typedef struct _usbinterfacedesc
86 u8 bInterfaceSubClass
;
87 u8 bInterfaceProtocol
;
91 struct _usbendpointdesc
*endpoints
;
92 } ATTRIBUTE_PACKED usb_interfacedesc
;
94 typedef struct _usbconfdesc
100 u8 bConfigurationValue
;
104 struct _usbinterfacedesc
*interfaces
;
105 } ATTRIBUTE_PACKED usb_configurationdesc
;
107 typedef struct _usbdevdesc
122 u8 bNumConfigurations
;
123 struct _usbconfdesc
*configurations
;
124 } ATTRIBUTE_PACKED usb_devdesc
;
126 typedef struct _usbhiddesc
135 u16 wDescriptorLength
;
137 } ATTRIBUTE_PACKED usb_hiddesc
;
139 typedef s32 (*usbcallback
)(s32 result
,void *usrdata
);
141 s32
USB_Initialize();
142 s32
USB_Deinitialize();
144 s32
USB_OpenDevice(const char *device
,u16 vid
,u16 pid
,s32
*fd
);
145 s32
USB_CloseDevice(s32
*fd
);
146 s32
USB_CloseDeviceAsync(s32
*fd
,usbcallback cb
,void *usrdata
);
148 s32
USB_GetDescriptors(s32 fd
, usb_devdesc
*udd
);
149 void USB_FreeDescriptors(usb_devdesc
*udd
);
151 s32
USB_GetHIDDescriptor(s32 fd
, usb_hiddesc
*uhd
);
153 s32
USB_GetDeviceDescription(s32 fd
,usb_devdesc
*devdesc
);
154 s32
USB_DeviceRemovalNotifyAsync(s32 fd
,usbcallback cb
,void *userdata
);
156 void USB_SuspendDevice(s32 fd
);
157 void USB_ResumeDevice(s32 fd
);
159 s32
USB_ReadIntrMsg(s32 fd
,u8 bEndpoint
,u16 wLength
,void *rpData
);
160 s32
USB_ReadIntrMsgAsync(s32 fd
,u8 bEndpoint
,u16 wLength
,void *rpData
,usbcallback cb
,void *usrdata
);
162 s32
USB_ReadBlkMsg(s32 fd
,u8 bEndpoint
,u16 wLength
,void *rpData
);
163 s32
USB_ReadBlkMsgAsync(s32 fd
,u8 bEndpoint
,u16 wLength
,void *rpData
,usbcallback cb
,void *usrdata
);
165 s32
USB_ReadCtrlMsg(s32 fd
,u8 bmRequestType
,u8 bmRequest
,u16 wValue
,u16 wIndex
,u16 wLength
,void *rpData
);
166 s32
USB_ReadCtrlMsgAsync(s32 fd
,u8 bmRequestType
,u8 bmRequest
,u16 wValue
,u16 wIndex
,u16 wLength
,void *rpData
,usbcallback cb
,void *usrdata
);
168 s32
USB_WriteIntrMsg(s32 fd
,u8 bEndpoint
,u16 wLength
,void *rpData
);
169 s32
USB_WriteIntrMsgAsync(s32 fd
,u8 bEndpoint
,u16 wLength
,void *rpData
,usbcallback cb
,void *usrdata
);
171 s32
USB_WriteBlkMsg(s32 fd
,u8 bEndpoint
,u16 wLength
,void *rpData
);
172 s32
USB_WriteBlkMsgAsync(s32 fd
,u8 bEndpoint
,u16 wLength
,void *rpData
,usbcallback cb
,void *usrdata
);
174 s32
USB_WriteCtrlMsg(s32 fd
,u8 bmRequestType
,u8 bmRequest
,u16 wValue
,u16 wIndex
,u16 wLength
,void *rpData
);
175 s32
USB_WriteCtrlMsgAsync(s32 fd
,u8 bmRequestType
,u8 bmRequest
,u16 wValue
,u16 wIndex
,u16 wLength
,void *rpData
,usbcallback cb
,void *usrdata
);
177 s32
USB_GetConfiguration(s32 fd
, u8
*configuration
);
178 s32
USB_SetConfiguration(s32 fd
, u8 configuration
);
179 s32
USB_SetAlternativeInterface(s32 fd
, u8 interface
, u8 alternateSetting
);
180 s32
USB_ClearHalt(s32 fd
, u8 endpointAddress
);
181 s32
USB_GetDeviceList(const char *devpath
,void *descr_buffer
,u8 num_descr
,u8 b0
,u8
*cnt_descr
);
185 #endif /* __cplusplus */
187 #endif /* defined(HW_RVL) */