checkpatch.pl: don't complain about old lines with tabs
[qemu/mdroth.git] / hw / usb-desc.h
blobac734ab088b961cb8766f7385948df5cdda7216e
1 #ifndef QEMU_HW_USB_DESC_H
2 #define QEMU_HW_USB_DESC_H
4 #include <inttypes.h>
6 struct USBDescID {
7 uint16_t idVendor;
8 uint16_t idProduct;
9 uint16_t bcdDevice;
10 uint8_t iManufacturer;
11 uint8_t iProduct;
12 uint8_t iSerialNumber;
15 struct USBDescDevice {
16 uint16_t bcdUSB;
17 uint8_t bDeviceClass;
18 uint8_t bDeviceSubClass;
19 uint8_t bDeviceProtocol;
20 uint8_t bMaxPacketSize0;
21 uint8_t bNumConfigurations;
23 const USBDescConfig *confs;
26 struct USBDescConfig {
27 uint8_t bNumInterfaces;
28 uint8_t bConfigurationValue;
29 uint8_t iConfiguration;
30 uint8_t bmAttributes;
31 uint8_t bMaxPower;
33 uint8_t nif;
34 const USBDescIface *ifs;
37 struct USBDescIface {
38 uint8_t bInterfaceNumber;
39 uint8_t bAlternateSetting;
40 uint8_t bNumEndpoints;
41 uint8_t bInterfaceClass;
42 uint8_t bInterfaceSubClass;
43 uint8_t bInterfaceProtocol;
44 uint8_t iInterface;
46 uint8_t ndesc;
47 USBDescOther *descs;
48 USBDescEndpoint *eps;
51 struct USBDescEndpoint {
52 uint8_t bEndpointAddress;
53 uint8_t bmAttributes;
54 uint16_t wMaxPacketSize;
55 uint8_t bInterval;
58 struct USBDescOther {
59 uint8_t length;
60 uint8_t *data;
63 typedef const char *USBDescStrings[256];
65 struct USBDesc {
66 USBDescID id;
67 const USBDescDevice *full;
68 const USBDescDevice *high;
69 const char* const *str;
72 /* generate usb packages from structs */
73 int usb_desc_device(const USBDescID *id, const USBDescDevice *dev,
74 uint8_t *dest, size_t len);
75 int usb_desc_device_qualifier(const USBDescDevice *dev,
76 uint8_t *dest, size_t len);
77 int usb_desc_config(const USBDescConfig *conf, uint8_t *dest, size_t len);
78 int usb_desc_iface(const USBDescIface *iface, uint8_t *dest, size_t len);
79 int usb_desc_endpoint(const USBDescEndpoint *ep, uint8_t *dest, size_t len);
80 int usb_desc_other(const USBDescOther *desc, uint8_t *dest, size_t len);
82 /* control message emulation helpers */
83 void usb_desc_init(USBDevice *dev);
84 void usb_desc_attach(USBDevice *dev);
85 void usb_desc_set_string(USBDevice *dev, uint8_t index, const char *str);
86 const char *usb_desc_get_string(USBDevice *dev, uint8_t index);
87 int usb_desc_string(USBDevice *dev, int index, uint8_t *dest, size_t len);
88 int usb_desc_get_descriptor(USBDevice *dev, int value, uint8_t *dest, size_t len);
89 int usb_desc_handle_control(USBDevice *dev, int request, int value,
90 int index, int length, uint8_t *data);
92 #endif /* QEMU_HW_USB_DESC_H */