4 #include "hw/usb/desc.h"
7 /* ------------------------------------------------------------------ */
9 static uint8_t usb_lo(uint16_t val
)
14 static uint8_t usb_hi(uint16_t val
)
16 return (val
>> 8) & 0xff;
19 int usb_desc_device(const USBDescID
*id
, const USBDescDevice
*dev
,
20 uint8_t *dest
, size_t len
)
22 uint8_t bLength
= 0x12;
23 USBDescriptor
*d
= (void *)dest
;
30 d
->bDescriptorType
= USB_DT_DEVICE
;
32 d
->u
.device
.bcdUSB_lo
= usb_lo(dev
->bcdUSB
);
33 d
->u
.device
.bcdUSB_hi
= usb_hi(dev
->bcdUSB
);
34 d
->u
.device
.bDeviceClass
= dev
->bDeviceClass
;
35 d
->u
.device
.bDeviceSubClass
= dev
->bDeviceSubClass
;
36 d
->u
.device
.bDeviceProtocol
= dev
->bDeviceProtocol
;
37 d
->u
.device
.bMaxPacketSize0
= dev
->bMaxPacketSize0
;
39 d
->u
.device
.idVendor_lo
= usb_lo(id
->idVendor
);
40 d
->u
.device
.idVendor_hi
= usb_hi(id
->idVendor
);
41 d
->u
.device
.idProduct_lo
= usb_lo(id
->idProduct
);
42 d
->u
.device
.idProduct_hi
= usb_hi(id
->idProduct
);
43 d
->u
.device
.bcdDevice_lo
= usb_lo(id
->bcdDevice
);
44 d
->u
.device
.bcdDevice_hi
= usb_hi(id
->bcdDevice
);
45 d
->u
.device
.iManufacturer
= id
->iManufacturer
;
46 d
->u
.device
.iProduct
= id
->iProduct
;
47 d
->u
.device
.iSerialNumber
= id
->iSerialNumber
;
49 d
->u
.device
.bNumConfigurations
= dev
->bNumConfigurations
;
54 int usb_desc_device_qualifier(const USBDescDevice
*dev
,
55 uint8_t *dest
, size_t len
)
57 uint8_t bLength
= 0x0a;
58 USBDescriptor
*d
= (void *)dest
;
65 d
->bDescriptorType
= USB_DT_DEVICE_QUALIFIER
;
67 d
->u
.device_qualifier
.bcdUSB_lo
= usb_lo(dev
->bcdUSB
);
68 d
->u
.device_qualifier
.bcdUSB_hi
= usb_hi(dev
->bcdUSB
);
69 d
->u
.device_qualifier
.bDeviceClass
= dev
->bDeviceClass
;
70 d
->u
.device_qualifier
.bDeviceSubClass
= dev
->bDeviceSubClass
;
71 d
->u
.device_qualifier
.bDeviceProtocol
= dev
->bDeviceProtocol
;
72 d
->u
.device_qualifier
.bMaxPacketSize0
= dev
->bMaxPacketSize0
;
73 d
->u
.device_qualifier
.bNumConfigurations
= dev
->bNumConfigurations
;
74 d
->u
.device_qualifier
.bReserved
= 0;
79 int usb_desc_config(const USBDescConfig
*conf
, int flags
,
80 uint8_t *dest
, size_t len
)
82 uint8_t bLength
= 0x09;
83 uint16_t wTotalLength
= 0;
84 USBDescriptor
*d
= (void *)dest
;
92 d
->bDescriptorType
= USB_DT_CONFIG
;
94 d
->u
.config
.bNumInterfaces
= conf
->bNumInterfaces
;
95 d
->u
.config
.bConfigurationValue
= conf
->bConfigurationValue
;
96 d
->u
.config
.iConfiguration
= conf
->iConfiguration
;
97 d
->u
.config
.bmAttributes
= conf
->bmAttributes
;
98 d
->u
.config
.bMaxPower
= conf
->bMaxPower
;
99 wTotalLength
+= bLength
;
101 /* handle grouped interfaces if any */
102 for (i
= 0; i
< conf
->nif_groups
; i
++) {
103 rc
= usb_desc_iface_group(&(conf
->if_groups
[i
]), flags
,
112 /* handle normal (ungrouped / no IAD) interfaces if any */
113 for (i
= 0; i
< conf
->nif
; i
++) {
114 rc
= usb_desc_iface(conf
->ifs
+ i
, flags
,
115 dest
+ wTotalLength
, len
- wTotalLength
);
122 d
->u
.config
.wTotalLength_lo
= usb_lo(wTotalLength
);
123 d
->u
.config
.wTotalLength_hi
= usb_hi(wTotalLength
);
127 int usb_desc_iface_group(const USBDescIfaceAssoc
*iad
, int flags
,
128 uint8_t *dest
, size_t len
)
133 /* handle interface association descriptor */
134 uint8_t bLength
= 0x08;
140 dest
[0x00] = bLength
;
141 dest
[0x01] = USB_DT_INTERFACE_ASSOC
;
142 dest
[0x02] = iad
->bFirstInterface
;
143 dest
[0x03] = iad
->bInterfaceCount
;
144 dest
[0x04] = iad
->bFunctionClass
;
145 dest
[0x05] = iad
->bFunctionSubClass
;
146 dest
[0x06] = iad
->bFunctionProtocol
;
147 dest
[0x07] = iad
->iFunction
;
150 /* handle associated interfaces in this group */
151 for (i
= 0; i
< iad
->nif
; i
++) {
152 int rc
= usb_desc_iface(&(iad
->ifs
[i
]), flags
, dest
+ pos
, len
- pos
);
162 int usb_desc_iface(const USBDescIface
*iface
, int flags
,
163 uint8_t *dest
, size_t len
)
165 uint8_t bLength
= 0x09;
167 USBDescriptor
*d
= (void *)dest
;
173 d
->bLength
= bLength
;
174 d
->bDescriptorType
= USB_DT_INTERFACE
;
176 d
->u
.interface
.bInterfaceNumber
= iface
->bInterfaceNumber
;
177 d
->u
.interface
.bAlternateSetting
= iface
->bAlternateSetting
;
178 d
->u
.interface
.bNumEndpoints
= iface
->bNumEndpoints
;
179 d
->u
.interface
.bInterfaceClass
= iface
->bInterfaceClass
;
180 d
->u
.interface
.bInterfaceSubClass
= iface
->bInterfaceSubClass
;
181 d
->u
.interface
.bInterfaceProtocol
= iface
->bInterfaceProtocol
;
182 d
->u
.interface
.iInterface
= iface
->iInterface
;
185 for (i
= 0; i
< iface
->ndesc
; i
++) {
186 rc
= usb_desc_other(iface
->descs
+ i
, dest
+ pos
, len
- pos
);
193 for (i
= 0; i
< iface
->bNumEndpoints
; i
++) {
194 rc
= usb_desc_endpoint(iface
->eps
+ i
, flags
, dest
+ pos
, len
- pos
);
204 int usb_desc_endpoint(const USBDescEndpoint
*ep
, int flags
,
205 uint8_t *dest
, size_t len
)
207 uint8_t bLength
= ep
->is_audio
? 0x09 : 0x07;
208 uint8_t extralen
= ep
->extra
? ep
->extra
[0] : 0;
209 uint8_t superlen
= (flags
& USB_DESC_FLAG_SUPER
) ? 0x06 : 0;
210 USBDescriptor
*d
= (void *)dest
;
212 if (len
< bLength
+ extralen
+ superlen
) {
216 d
->bLength
= bLength
;
217 d
->bDescriptorType
= USB_DT_ENDPOINT
;
219 d
->u
.endpoint
.bEndpointAddress
= ep
->bEndpointAddress
;
220 d
->u
.endpoint
.bmAttributes
= ep
->bmAttributes
;
221 d
->u
.endpoint
.wMaxPacketSize_lo
= usb_lo(ep
->wMaxPacketSize
);
222 d
->u
.endpoint
.wMaxPacketSize_hi
= usb_hi(ep
->wMaxPacketSize
);
223 d
->u
.endpoint
.bInterval
= ep
->bInterval
;
225 d
->u
.endpoint
.bRefresh
= ep
->bRefresh
;
226 d
->u
.endpoint
.bSynchAddress
= ep
->bSynchAddress
;
230 USBDescriptor
*d
= (void *)(dest
+ bLength
);
233 d
->bDescriptorType
= USB_DT_ENDPOINT_COMPANION
;
235 d
->u
.super_endpoint
.bMaxBurst
= ep
->bMaxBurst
;
236 d
->u
.super_endpoint
.bmAttributes
= ep
->bmAttributes_super
;
237 d
->u
.super_endpoint
.wBytesPerInterval_lo
=
238 usb_lo(ep
->wBytesPerInterval
);
239 d
->u
.super_endpoint
.wBytesPerInterval_hi
=
240 usb_hi(ep
->wBytesPerInterval
);
244 memcpy(dest
+ bLength
+ superlen
, ep
->extra
, extralen
);
247 return bLength
+ extralen
+ superlen
;
250 int usb_desc_other(const USBDescOther
*desc
, uint8_t *dest
, size_t len
)
252 int bLength
= desc
->length
? desc
->length
: desc
->data
[0];
258 memcpy(dest
, desc
->data
, bLength
);
262 static int usb_desc_cap_usb2_ext(const USBDesc
*desc
, uint8_t *dest
, size_t len
)
264 uint8_t bLength
= 0x07;
265 USBDescriptor
*d
= (void *)dest
;
271 d
->bLength
= bLength
;
272 d
->bDescriptorType
= USB_DT_DEVICE_CAPABILITY
;
273 d
->u
.cap
.bDevCapabilityType
= USB_DEV_CAP_USB2_EXT
;
275 d
->u
.cap
.u
.usb2_ext
.bmAttributes_1
= (1 << 1); /* LPM */
276 d
->u
.cap
.u
.usb2_ext
.bmAttributes_2
= 0;
277 d
->u
.cap
.u
.usb2_ext
.bmAttributes_3
= 0;
278 d
->u
.cap
.u
.usb2_ext
.bmAttributes_4
= 0;
283 static int usb_desc_cap_super(const USBDesc
*desc
, uint8_t *dest
, size_t len
)
285 uint8_t bLength
= 0x0a;
286 USBDescriptor
*d
= (void *)dest
;
292 d
->bLength
= bLength
;
293 d
->bDescriptorType
= USB_DT_DEVICE_CAPABILITY
;
294 d
->u
.cap
.bDevCapabilityType
= USB_DEV_CAP_SUPERSPEED
;
296 d
->u
.cap
.u
.super
.bmAttributes
= 0;
297 d
->u
.cap
.u
.super
.wSpeedsSupported_lo
= 0;
298 d
->u
.cap
.u
.super
.wSpeedsSupported_hi
= 0;
299 d
->u
.cap
.u
.super
.bFunctionalitySupport
= 0;
300 d
->u
.cap
.u
.super
.bU1DevExitLat
= 0x0a;
301 d
->u
.cap
.u
.super
.wU2DevExitLat_lo
= 0x20;
302 d
->u
.cap
.u
.super
.wU2DevExitLat_hi
= 0;
305 d
->u
.cap
.u
.super
.wSpeedsSupported_lo
|= (1 << 1);
306 d
->u
.cap
.u
.super
.bFunctionalitySupport
= 1;
309 d
->u
.cap
.u
.super
.wSpeedsSupported_lo
|= (1 << 2);
310 if (!d
->u
.cap
.u
.super
.bFunctionalitySupport
) {
311 d
->u
.cap
.u
.super
.bFunctionalitySupport
= 2;
315 d
->u
.cap
.u
.super
.wSpeedsSupported_lo
|= (1 << 3);
316 if (!d
->u
.cap
.u
.super
.bFunctionalitySupport
) {
317 d
->u
.cap
.u
.super
.bFunctionalitySupport
= 3;
324 static int usb_desc_bos(const USBDesc
*desc
, uint8_t *dest
, size_t len
)
326 uint8_t bLength
= 0x05;
327 uint16_t wTotalLength
= 0;
328 uint8_t bNumDeviceCaps
= 0;
329 USBDescriptor
*d
= (void *)dest
;
336 d
->bLength
= bLength
;
337 d
->bDescriptorType
= USB_DT_BOS
;
339 wTotalLength
+= bLength
;
341 if (desc
->high
!= NULL
) {
342 rc
= usb_desc_cap_usb2_ext(desc
, dest
+ wTotalLength
,
351 if (desc
->super
!= NULL
) {
352 rc
= usb_desc_cap_super(desc
, dest
+ wTotalLength
,
361 d
->u
.bos
.wTotalLength_lo
= usb_lo(wTotalLength
);
362 d
->u
.bos
.wTotalLength_hi
= usb_hi(wTotalLength
);
363 d
->u
.bos
.bNumDeviceCaps
= bNumDeviceCaps
;
367 /* ------------------------------------------------------------------ */
369 static void usb_desc_ep_init(USBDevice
*dev
)
371 const USBDescIface
*iface
;
375 for (i
= 0; i
< dev
->ninterfaces
; i
++) {
376 iface
= dev
->ifaces
[i
];
380 for (e
= 0; e
< iface
->bNumEndpoints
; e
++) {
381 pid
= (iface
->eps
[e
].bEndpointAddress
& USB_DIR_IN
) ?
382 USB_TOKEN_IN
: USB_TOKEN_OUT
;
383 ep
= iface
->eps
[e
].bEndpointAddress
& 0x0f;
384 usb_ep_set_type(dev
, pid
, ep
, iface
->eps
[e
].bmAttributes
& 0x03);
385 usb_ep_set_ifnum(dev
, pid
, ep
, iface
->bInterfaceNumber
);
386 usb_ep_set_max_packet_size(dev
, pid
, ep
,
387 iface
->eps
[e
].wMaxPacketSize
);
392 static const USBDescIface
*usb_desc_find_interface(USBDevice
*dev
,
395 const USBDescIface
*iface
;
401 for (g
= 0; g
< dev
->config
->nif_groups
; g
++) {
402 for (i
= 0; i
< dev
->config
->if_groups
[g
].nif
; i
++) {
403 iface
= &dev
->config
->if_groups
[g
].ifs
[i
];
404 if (iface
->bInterfaceNumber
== nif
&&
405 iface
->bAlternateSetting
== alt
) {
410 for (i
= 0; i
< dev
->config
->nif
; i
++) {
411 iface
= &dev
->config
->ifs
[i
];
412 if (iface
->bInterfaceNumber
== nif
&&
413 iface
->bAlternateSetting
== alt
) {
420 static int usb_desc_set_interface(USBDevice
*dev
, int index
, int value
)
422 const USBDescIface
*iface
;
425 iface
= usb_desc_find_interface(dev
, index
, value
);
430 old
= dev
->altsetting
[index
];
431 dev
->altsetting
[index
] = value
;
432 dev
->ifaces
[index
] = iface
;
433 usb_desc_ep_init(dev
);
436 usb_device_set_interface(dev
, index
, old
, value
);
441 static int usb_desc_set_config(USBDevice
*dev
, int value
)
446 dev
->configuration
= 0;
447 dev
->ninterfaces
= 0;
450 for (i
= 0; i
< dev
->device
->bNumConfigurations
; i
++) {
451 if (dev
->device
->confs
[i
].bConfigurationValue
== value
) {
452 dev
->configuration
= value
;
453 dev
->ninterfaces
= dev
->device
->confs
[i
].bNumInterfaces
;
454 dev
->config
= dev
->device
->confs
+ i
;
455 assert(dev
->ninterfaces
<= USB_MAX_INTERFACES
);
458 if (i
< dev
->device
->bNumConfigurations
) {
463 for (i
= 0; i
< dev
->ninterfaces
; i
++) {
464 usb_desc_set_interface(dev
, i
, 0);
466 for (; i
< USB_MAX_INTERFACES
; i
++) {
467 dev
->altsetting
[i
] = 0;
468 dev
->ifaces
[i
] = NULL
;
474 static void usb_desc_setdefaults(USBDevice
*dev
)
476 const USBDesc
*desc
= usb_device_get_usb_desc(dev
);
478 assert(desc
!= NULL
);
479 switch (dev
->speed
) {
482 dev
->device
= desc
->full
;
485 dev
->device
= desc
->high
;
487 case USB_SPEED_SUPER
:
488 dev
->device
= desc
->super
;
491 usb_desc_set_config(dev
, 0);
494 void usb_desc_init(USBDevice
*dev
)
496 const USBDesc
*desc
= usb_device_get_usb_desc(dev
);
498 assert(desc
!= NULL
);
499 dev
->speed
= USB_SPEED_FULL
;
502 dev
->speedmask
|= USB_SPEED_MASK_FULL
;
505 dev
->speedmask
|= USB_SPEED_MASK_HIGH
;
508 dev
->speedmask
|= USB_SPEED_MASK_SUPER
;
510 usb_desc_setdefaults(dev
);
513 void usb_desc_attach(USBDevice
*dev
)
515 const USBDesc
*desc
= usb_device_get_usb_desc(dev
);
517 assert(desc
!= NULL
);
518 if (desc
->super
&& (dev
->port
->speedmask
& USB_SPEED_MASK_SUPER
)) {
519 dev
->speed
= USB_SPEED_SUPER
;
520 } else if (desc
->high
&& (dev
->port
->speedmask
& USB_SPEED_MASK_HIGH
)) {
521 dev
->speed
= USB_SPEED_HIGH
;
522 } else if (desc
->full
&& (dev
->port
->speedmask
& USB_SPEED_MASK_FULL
)) {
523 dev
->speed
= USB_SPEED_FULL
;
525 fprintf(stderr
, "usb: port/device speed mismatch for \"%s\"\n",
526 usb_device_get_product_desc(dev
));
529 usb_desc_setdefaults(dev
);
532 void usb_desc_set_string(USBDevice
*dev
, uint8_t index
, const char *str
)
536 QLIST_FOREACH(s
, &dev
->strings
, next
) {
537 if (s
->index
== index
) {
542 s
= g_malloc0(sizeof(*s
));
544 QLIST_INSERT_HEAD(&dev
->strings
, s
, next
);
547 s
->str
= g_strdup(str
);
551 * This function creates a serial number for a usb device.
552 * The serial number should:
553 * (a) Be unique within the virtual machine.
554 * (b) Be constant, so you don't get a new one each
555 * time the guest is started.
556 * So we are using the physical location to generate a serial number
557 * from it. It has three pieces: First a fixed, device-specific
558 * prefix. Second the device path of the host controller (which is
559 * the pci address in most cases). Third the physical port path.
560 * Results in serial numbers like this: "314159-0000:00:1d.7-3".
562 void usb_desc_create_serial(USBDevice
*dev
)
564 DeviceState
*hcd
= dev
->qdev
.parent_bus
->parent
;
565 const USBDesc
*desc
= usb_device_get_usb_desc(dev
);
566 int index
= desc
->id
.iSerialNumber
;
571 assert(index
!= 0 && desc
->str
[index
] != NULL
);
572 dst
= snprintf(serial
, sizeof(serial
), "%s", desc
->str
[index
]);
573 path
= qdev_get_dev_path(hcd
);
575 dst
+= snprintf(serial
+dst
, sizeof(serial
)-dst
, "-%s", path
);
577 dst
+= snprintf(serial
+dst
, sizeof(serial
)-dst
, "-%s", dev
->port
->path
);
578 usb_desc_set_string(dev
, index
, serial
);
581 const char *usb_desc_get_string(USBDevice
*dev
, uint8_t index
)
585 QLIST_FOREACH(s
, &dev
->strings
, next
) {
586 if (s
->index
== index
) {
593 int usb_desc_string(USBDevice
*dev
, int index
, uint8_t *dest
, size_t len
)
595 uint8_t bLength
, pos
, i
;
605 dest
[1] = USB_DT_STRING
;
611 str
= usb_desc_get_string(dev
, index
);
613 str
= usb_device_get_usb_desc(dev
)->str
[index
];
619 bLength
= strlen(str
) * 2 + 2;
621 dest
[1] = USB_DT_STRING
;
623 while (pos
+1 < bLength
&& pos
+1 < len
) {
624 dest
[pos
++] = str
[i
++];
630 int usb_desc_get_descriptor(USBDevice
*dev
, USBPacket
*p
,
631 int value
, uint8_t *dest
, size_t len
)
633 const USBDesc
*desc
= usb_device_get_usb_desc(dev
);
634 const USBDescDevice
*other_dev
;
636 uint8_t type
= value
>> 8;
637 uint8_t index
= value
& 0xff;
640 if (dev
->speed
== USB_SPEED_HIGH
) {
641 other_dev
= usb_device_get_usb_desc(dev
)->full
;
643 other_dev
= usb_device_get_usb_desc(dev
)->high
;
647 if (dev
->device
->bcdUSB
>= 0x0300) {
648 flags
|= USB_DESC_FLAG_SUPER
;
653 ret
= usb_desc_device(&desc
->id
, dev
->device
, buf
, sizeof(buf
));
654 trace_usb_desc_device(dev
->addr
, len
, ret
);
657 if (index
< dev
->device
->bNumConfigurations
) {
658 ret
= usb_desc_config(dev
->device
->confs
+ index
, flags
,
661 trace_usb_desc_config(dev
->addr
, index
, len
, ret
);
664 ret
= usb_desc_string(dev
, index
, buf
, sizeof(buf
));
665 trace_usb_desc_string(dev
->addr
, index
, len
, ret
);
667 case USB_DT_DEVICE_QUALIFIER
:
668 if (other_dev
!= NULL
) {
669 ret
= usb_desc_device_qualifier(other_dev
, buf
, sizeof(buf
));
671 trace_usb_desc_device_qualifier(dev
->addr
, len
, ret
);
673 case USB_DT_OTHER_SPEED_CONFIG
:
674 if (other_dev
!= NULL
&& index
< other_dev
->bNumConfigurations
) {
675 ret
= usb_desc_config(other_dev
->confs
+ index
, flags
,
677 buf
[0x01] = USB_DT_OTHER_SPEED_CONFIG
;
679 trace_usb_desc_other_speed_config(dev
->addr
, index
, len
, ret
);
682 ret
= usb_desc_bos(desc
, buf
, sizeof(buf
));
683 trace_usb_desc_bos(dev
->addr
, len
, ret
);
687 /* ignore silently */
691 fprintf(stderr
, "%s: %d unknown type %d (len %zd)\n", __FUNCTION__
,
692 dev
->addr
, type
, len
);
700 memcpy(dest
, buf
, ret
);
701 p
->actual_length
= ret
;
707 int usb_desc_handle_control(USBDevice
*dev
, USBPacket
*p
,
708 int request
, int value
, int index
, int length
, uint8_t *data
)
710 const USBDesc
*desc
= usb_device_get_usb_desc(dev
);
713 assert(desc
!= NULL
);
715 case DeviceOutRequest
| USB_REQ_SET_ADDRESS
:
717 trace_usb_set_addr(dev
->addr
);
721 case DeviceRequest
| USB_REQ_GET_DESCRIPTOR
:
722 ret
= usb_desc_get_descriptor(dev
, p
, value
, data
, length
);
725 case DeviceRequest
| USB_REQ_GET_CONFIGURATION
:
727 * 9.4.2: 0 should be returned if the device is unconfigured, otherwise
728 * the non zero value of bConfigurationValue.
730 data
[0] = dev
->config
? dev
->config
->bConfigurationValue
: 0;
731 p
->actual_length
= 1;
734 case DeviceOutRequest
| USB_REQ_SET_CONFIGURATION
:
735 ret
= usb_desc_set_config(dev
, value
);
736 trace_usb_set_config(dev
->addr
, value
, ret
);
739 case DeviceRequest
| USB_REQ_GET_STATUS
: {
740 const USBDescConfig
*config
= dev
->config
?
741 dev
->config
: &dev
->device
->confs
[0];
745 * Default state: Device behavior when this request is received while
746 * the device is in the Default state is not specified.
747 * We return the same value that a configured device would return if
748 * it used the first configuration.
750 if (config
->bmAttributes
& 0x40) {
751 data
[0] |= 1 << USB_DEVICE_SELF_POWERED
;
753 if (dev
->remote_wakeup
) {
754 data
[0] |= 1 << USB_DEVICE_REMOTE_WAKEUP
;
757 p
->actual_length
= 2;
761 case DeviceOutRequest
| USB_REQ_CLEAR_FEATURE
:
762 if (value
== USB_DEVICE_REMOTE_WAKEUP
) {
763 dev
->remote_wakeup
= 0;
766 trace_usb_clear_device_feature(dev
->addr
, value
, ret
);
768 case DeviceOutRequest
| USB_REQ_SET_FEATURE
:
769 if (value
== USB_DEVICE_REMOTE_WAKEUP
) {
770 dev
->remote_wakeup
= 1;
773 trace_usb_set_device_feature(dev
->addr
, value
, ret
);
776 case InterfaceRequest
| USB_REQ_GET_INTERFACE
:
777 if (index
< 0 || index
>= dev
->ninterfaces
) {
780 data
[0] = dev
->altsetting
[index
];
781 p
->actual_length
= 1;
784 case InterfaceOutRequest
| USB_REQ_SET_INTERFACE
:
785 ret
= usb_desc_set_interface(dev
, index
, value
);
786 trace_usb_set_interface(dev
->addr
, index
, value
, ret
);