6 * USB human interface devices (HID)
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
14 /** Class code for human interface devices */
15 #define USB_CLASS_HID 3
17 /** Subclass code for boot devices */
18 #define USB_SUBCLASS_HID_BOOT 1
21 #define USBHID_SET_PROTOCOL \
22 ( USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
23 USB_REQUEST_TYPE ( 0x0b ) )
26 #define USBHID_PROTOCOL_BOOT 0
28 /** Report protocol */
29 #define USBHID_PROTOCOL_REPORT 1
32 #define USBHID_SET_IDLE \
33 ( USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE | \
34 USB_REQUEST_TYPE ( 0x0a ) )
36 /** A USB human interface device */
39 struct usb_function *func;
40 /** Interrupt IN endpoint */
41 struct usb_endpoint in;
42 /** Interrupt OUT endpoint (optional) */
43 struct usb_endpoint out;
47 * Initialise USB human interface device
49 * @v hid USB human interface device
50 * @v func USB function
51 * @v in Interrupt IN endpoint operations
52 * @v out Interrupt OUT endpoint operations (or NULL)
54 static inline __attribute__ (( always_inline )) void
55 usbhid_init ( struct usb_hid *hid, struct usb_function *func,
56 struct usb_endpoint_driver_operations *in,
57 struct usb_endpoint_driver_operations *out ) {
58 struct usb_device *usb = func->usb;
61 usb_endpoint_init ( &hid->in, usb, in );
63 usb_endpoint_init ( &hid->out, usb, out );
70 * @v interface Interface number
71 * @v protocol HID protocol
72 * @ret rc Return status code
74 static inline __attribute__ (( always_inline )) int
75 usbhid_set_protocol ( struct usb_device *usb, unsigned int interface,
76 unsigned int protocol ) {
78 return usb_control ( usb, USBHID_SET_PROTOCOL, protocol, interface,
86 * @v interface Interface number
88 * @v duration Duration (in 4ms units)
89 * @ret rc Return status code
91 static inline __attribute__ (( always_inline )) int
92 usbhid_set_idle ( struct usb_device *usb, unsigned int interface,
93 unsigned int report, unsigned int duration ) {
95 return usb_control ( usb, USBHID_SET_IDLE,
96 ( ( duration << 8 ) | report ),
100 extern int usbhid_open ( struct usb_hid *hid );
101 extern void usbhid_close ( struct usb_hid *hid );
102 extern int usbhid_refill ( struct usb_hid *hid );
103 extern int usbhid_describe ( struct usb_hid *hid,
104 struct usb_configuration_descriptor *config );
106 #endif /* _IPXE_USBHID_H */