Lines Matching +full:1 +full:- +full:d
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 // Validation of USB-audio class descriptors
9 #include <linux/usb/audio-v2.h>
10 #include <linux/usb/audio-v3.h>
22 #define UAC_VERSION_ALL (unsigned char)(-1)
28 const struct uac1_ac_header_descriptor *d = p;
30 return d->bLength >= sizeof(*d) &&
31 d->bLength >= sizeof(*d) + d->bInCollection;
38 const struct uac_mixer_unit_descriptor *d = p;
41 if (d->bLength < sizeof(*d) || !d->bNrInPins)
43 len = sizeof(*d) + d->bNrInPins;
48 switch (v->protocol) {
51 len += 2 + 1; /* wChannelConfig, iChannelNames */
53 len += 1; /* iMixer */
56 len += 4 + 1; /* bmChannelConfig, iChannelNames */
58 len += 1 + 1; /* bmControls, iMixer */
65 return d->bLength >= len;
72 const struct uac_processing_unit_descriptor *d = p;
76 if (d->bLength < sizeof(*d))
78 len = sizeof(*d) + d->bNrInPins;
79 if (d->bLength < len)
81 switch (v->protocol) {
85 len += 1 + 2 + 1;
86 if (d->bLength < len + 1) /* bControlSize */
89 len += 1 + m + 1; /* bControlSize, bmControls, iProcessing */
93 len += 1 + 4 + 1;
94 if (v->type == UAC2_PROCESSING_UNIT_V2)
95 len += 2; /* bmControls -- 2 bytes for PU */
97 len += 1; /* bmControls -- 1 byte for EU */
98 len += 1; /* iProcessing */
105 if (d->bLength < len)
108 switch (v->protocol) {
111 if (v->type == UAC1_EXTENSION_UNIT)
113 switch (le16_to_cpu(d->wProcessType)) {
116 if (d->bLength < len + 1) /* bNrModes */
119 len += 1 + m * 2; /* bNrModes, waModes(n) */
126 if (v->type == UAC2_EXTENSION_UNIT_V2)
128 switch (le16_to_cpu(d->wProcessType)) {
131 if (d->bLength < len + 1) /* bNrModes */
134 len += 1 + m * 4; /* bNrModes, daModes(n) */
141 if (v->type == UAC3_EXTENSION_UNIT) {
145 switch (le16_to_cpu(d->wProcessType)) {
147 if (d->bLength < len + 1) /* bNrModes */
150 len += 1 + m * 2; /* bNrModes, waClusterDescrID(n) */
160 if (d->bLength < len)
170 const struct uac_selector_unit_descriptor *d = p;
173 if (d->bLength < sizeof(*d))
175 len = sizeof(*d) + d->bNrInPins;
176 switch (v->protocol) {
179 len += 1; /* iSelector */
182 len += 1 + 1; /* bmControls, iSelector */
188 return d->bLength >= len;
194 const struct uac_feature_unit_descriptor *d = p;
196 if (d->bLength < sizeof(*d) || !d->bControlSize)
199 return d->bLength >= sizeof(*d) + d->bControlSize + 1;
205 const struct uac2_feature_unit_descriptor *d = p;
207 if (d->bLength < sizeof(*d))
210 return d->bLength >= sizeof(*d) + 4 + 1;
216 const struct uac3_feature_unit_descriptor *d = p;
218 if (d->bLength < sizeof(*d))
221 return d->bLength >= sizeof(*d) + 4 + 2;
227 const struct uac3_power_domain_descriptor *d = p;
229 if (d->bLength < sizeof(*d))
232 return d->bLength >= sizeof(*d) + d->bNrEntities + 2;
238 const struct usb_midi_out_jack_descriptor *d = p;
240 return d->bLength >= sizeof(*d) &&
241 d->bLength >= sizeof(*d) + d->bNrInputPins * 2;
269 /* just a stop-gap, it should be a proper function for the array
323 if (hdr[1] != USB_DT_CS_INTERFACE)
326 for (; v->type; v++) {
327 if (v->type == hdr[2] &&
328 (v->protocol == UAC_VERSION_ALL ||
329 v->protocol == protocol)) {
330 if (v->func)
331 return v->func(hdr, v);
333 return hdr[0] >= v->size;
347 print_hex_dump(KERN_ERR, "USB-audio: buggy audio desc: ",
348 DUMP_PREFIX_NONE, 16, 1, c, c[0], true);
361 print_hex_dump(KERN_ERR, "USB-audio: buggy midi desc: ",
362 DUMP_PREFIX_NONE, 16, 1, c, c[0], true);