Revision 6e625fc7 hw/usb-desc.c
b/hw/usb-desc.c | ||
---|---|---|
91 | 91 |
dest[0x08] = conf->bMaxPower; |
92 | 92 |
wTotalLength += bLength; |
93 | 93 |
|
94 |
/* handle grouped interfaces if any*/ |
|
95 |
for (i = 0; i < conf->nif_groups; i++) { |
|
96 |
rc = usb_desc_iface_group(&(conf->if_groups[i]), |
|
97 |
dest + wTotalLength, |
|
98 |
len - wTotalLength); |
|
99 |
if (rc < 0) { |
|
100 |
return rc; |
|
101 |
} |
|
102 |
wTotalLength += rc; |
|
103 |
} |
|
104 |
|
|
105 |
/* handle normal (ungrouped / no IAD) interfaces if any */ |
|
94 | 106 |
for (i = 0; i < conf->nif; i++) { |
95 | 107 |
rc = usb_desc_iface(conf->ifs + i, dest + wTotalLength, len - wTotalLength); |
96 | 108 |
if (rc < 0) { |
... | ... | |
104 | 116 |
return wTotalLength; |
105 | 117 |
} |
106 | 118 |
|
119 |
int usb_desc_iface_group(const USBDescIfaceAssoc *iad, uint8_t *dest, |
|
120 |
size_t len) |
|
121 |
{ |
|
122 |
int pos = 0; |
|
123 |
int i = 0; |
|
124 |
|
|
125 |
/* handle interface association descriptor */ |
|
126 |
uint8_t bLength = 0x08; |
|
127 |
|
|
128 |
if (len < bLength) { |
|
129 |
return -1; |
|
130 |
} |
|
131 |
|
|
132 |
dest[0x00] = bLength; |
|
133 |
dest[0x01] = USB_DT_INTERFACE_ASSOC; |
|
134 |
dest[0x02] = iad->bFirstInterface; |
|
135 |
dest[0x03] = iad->bInterfaceCount; |
|
136 |
dest[0x04] = iad->bFunctionClass; |
|
137 |
dest[0x05] = iad->bFunctionSubClass; |
|
138 |
dest[0x06] = iad->bFunctionProtocol; |
|
139 |
dest[0x07] = iad->iFunction; |
|
140 |
pos += bLength; |
|
141 |
|
|
142 |
/* handle associated interfaces in this group */ |
|
143 |
for (i = 0; i < iad->nif; i++) { |
|
144 |
int rc = usb_desc_iface(&(iad->ifs[i]), dest + pos, len - pos); |
|
145 |
if (rc < 0) { |
|
146 |
return rc; |
|
147 |
} |
|
148 |
pos += rc; |
|
149 |
} |
|
150 |
|
|
151 |
return pos; |
|
152 |
} |
|
153 |
|
|
107 | 154 |
int usb_desc_iface(const USBDescIface *iface, uint8_t *dest, size_t len) |
108 | 155 |
{ |
109 | 156 |
uint8_t bLength = 0x09; |
Also available in: Unified diff