4 #include "hw/usb/desc.h"
7 /* ------------------------------------------------------------------ */
9 int usb_desc_device(const USBDescID
*id
, const USBDescDevice
*dev
,
10 uint8_t *dest
, size_t len
)
12 uint8_t bLength
= 0x12;
13 USBDescriptor
*d
= (void *)dest
;
20 d
->bDescriptorType
= USB_DT_DEVICE
;
22 d
->u
.device
.bcdUSB_lo
= usb_lo(dev
->bcdUSB
);
23 d
->u
.device
.bcdUSB_hi
= usb_hi(dev
->bcdUSB
);
24 d
->u
.device
.bDeviceClass
= dev
->bDeviceClass
;
25 d
->u
.device
.bDeviceSubClass
= dev
->bDeviceSubClass
;
26 d
->u
.device
.bDeviceProtocol
= dev
->bDeviceProtocol
;
27 d
->u
.device
.bMaxPacketSize0
= dev
->bMaxPacketSize0
;
29 d
->u
.device
.idVendor_lo
= usb_lo(id
->idVendor
);
30 d
->u
.device
.idVendor_hi
= usb_hi(id
->idVendor
);
31 d
->u
.device
.idProduct_lo
= usb_lo(id
->idProduct
);
32 d
->u
.device
.idProduct_hi
= usb_hi(id
->idProduct
);
33 d
->u
.device
.bcdDevice_lo
= usb_lo(id
->bcdDevice
);
34 d
->u
.device
.bcdDevice_hi
= usb_hi(id
->bcdDevice
);
35 d
->u
.device
.iManufacturer
= id
->iManufacturer
;
36 d
->u
.device
.iProduct
= id
->iProduct
;
37 d
->u
.device
.iSerialNumber
= id
->iSerialNumber
;
39 d
->u
.device
.bNumConfigurations
= dev
->bNumConfigurations
;
44 int usb_desc_device_qualifier(const USBDescDevice
*dev
,
45 uint8_t *dest
, size_t len
)
47 uint8_t bLength
= 0x0a;
48 USBDescriptor
*d
= (void *)dest
;
55 d
->bDescriptorType
= USB_DT_DEVICE_QUALIFIER
;
57 d
->u
.device_qualifier
.bcdUSB_lo
= usb_lo(dev
->bcdUSB
);
58 d
->u
.device_qualifier
.bcdUSB_hi
= usb_hi(dev
->bcdUSB
);
59 d
->u
.device_qualifier
.bDeviceClass
= dev
->bDeviceClass
;
60 d
->u
.device_qualifier
.bDeviceSubClass
= dev
->bDeviceSubClass
;
61 d
->u
.device_qualifier
.bDeviceProtocol
= dev
->bDeviceProtocol
;
62 d
->u
.device_qualifier
.bMaxPacketSize0
= dev
->bMaxPacketSize0
;
63 d
->u
.device_qualifier
.bNumConfigurations
= dev
->bNumConfigurations
;
64 d
->u
.device_qualifier
.bReserved
= 0;
69 int usb_desc_config(const USBDescConfig
*conf
, int flags
,
70 uint8_t *dest
, size_t len
)
72 uint8_t bLength
= 0x09;
73 uint16_t wTotalLength
= 0;
74 USBDescriptor
*d
= (void *)dest
;
82 d
->bDescriptorType
= USB_DT_CONFIG
;
84 d
->u
.config
.bNumInterfaces
= conf
->bNumInterfaces
;
85 d
->u
.config
.bConfigurationValue
= conf
->bConfigurationValue
;
86 d
->u
.config
.iConfiguration
= conf
->iConfiguration
;
87 d
->u
.config
.bmAttributes
= conf
->bmAttributes
;
88 d
->u
.config
.bMaxPower
= conf
->bMaxPower
;
89 wTotalLength
+= bLength
;
91 /* handle grouped interfaces if any */
92 for (i
= 0; i
< conf
->nif_groups
; i
++) {
93 rc
= usb_desc_iface_group(&(conf
->if_groups
[i
]), flags
,
102 /* handle normal (ungrouped / no IAD) interfaces if any */
103 for (i
= 0; i
< conf
->nif
; i
++) {
104 rc
= usb_desc_iface(conf
->ifs
+ i
, flags
,
105 dest
+ wTotalLength
, len
- wTotalLength
);
112 d
->u
.config
.wTotalLength_lo
= usb_lo(wTotalLength
);
113 d
->u
.config
.wTotalLength_hi
= usb_hi(wTotalLength
);
117 int usb_desc_iface_group(const USBDescIfaceAssoc
*iad
, int flags
,
118 uint8_t *dest
, size_t len
)
123 /* handle interface association descriptor */
124 uint8_t bLength
= 0x08;
130 dest
[0x00] = bLength
;
131 dest
[0x01] = USB_DT_INTERFACE_ASSOC
;
132 dest
[0x02] = iad
->bFirstInterface
;
133 dest
[0x03] = iad
->bInterfaceCount
;
134 dest
[0x04] = iad
->bFunctionClass
;
135 dest
[0x05] = iad
->bFunctionSubClass
;
136 dest
[0x06] = iad
->bFunctionProtocol
;
137 dest
[0x07] = iad
->iFunction
;
140 /* handle associated interfaces in this group */
141 for (i
= 0; i
< iad
->nif
; i
++) {
142 int rc
= usb_desc_iface(&(iad
->ifs
[i
]), flags
, dest
+ pos
, len
- pos
);
152 int usb_desc_iface(const USBDescIface
*iface
, int flags
,
153 uint8_t *dest
, size_t len
)
155 uint8_t bLength
= 0x09;
157 USBDescriptor
*d
= (void *)dest
;
163 d
->bLength
= bLength
;
164 d
->bDescriptorType
= USB_DT_INTERFACE
;
166 d
->u
.interface
.bInterfaceNumber
= iface
->bInterfaceNumber
;
167 d
->u
.interface
.bAlternateSetting
= iface
->bAlternateSetting
;
168 d
->u
.interface
.bNumEndpoints
= iface
->bNumEndpoints
;
169 d
->u
.interface
.bInterfaceClass
= iface
->bInterfaceClass
;
170 d
->u
.interface
.bInterfaceSubClass
= iface
->bInterfaceSubClass
;
171 d
->u
.interface
.bInterfaceProtocol
= iface
->bInterfaceProtocol
;
172 d
->u
.interface
.iInterface
= iface
->iInterface
;
175 for (i
= 0; i
< iface
->ndesc
; i
++) {
176 rc
= usb_desc_other(iface
->descs
+ i
, dest
+ pos
, len
- pos
);
183 for (i
= 0; i
< iface
->bNumEndpoints
; i
++) {
184 rc
= usb_desc_endpoint(iface
->eps
+ i
, flags
, dest
+ pos
, len
- pos
);
194 int usb_desc_endpoint(const USBDescEndpoint
*ep
, int flags
,
195 uint8_t *dest
, size_t len
)
197 uint8_t bLength
= ep
->is_audio
? 0x09 : 0x07;
198 uint8_t extralen
= ep
->extra
? ep
->extra
[0] : 0;
199 uint8_t superlen
= (flags
& USB_DESC_FLAG_SUPER
) ? 0x06 : 0;
200 USBDescriptor
*d
= (void *)dest
;
202 if (len
< bLength
+ extralen
+ superlen
) {
206 d
->bLength
= bLength
;
207 d
->bDescriptorType
= USB_DT_ENDPOINT
;
209 d
->u
.endpoint
.bEndpointAddress
= ep
->bEndpointAddress
;
210 d
->u
.endpoint
.bmAttributes
= ep
->bmAttributes
;
211 d
->u
.endpoint
.wMaxPacketSize_lo
= usb_lo(ep
->wMaxPacketSize
);
212 d
->u
.endpoint
.wMaxPacketSize_hi
= usb_hi(ep
->wMaxPacketSize
);
213 d
->u
.endpoint
.bInterval
= ep
->bInterval
;
215 d
->u
.endpoint
.bRefresh
= ep
->bRefresh
;
216 d
->u
.endpoint
.bSynchAddress
= ep
->bSynchAddress
;
220 USBDescriptor
*d
= (void *)(dest
+ bLength
);
223 d
->bDescriptorType
= USB_DT_ENDPOINT_COMPANION
;
225 d
->u
.super_endpoint
.bMaxBurst
= ep
->bMaxBurst
;
226 d
->u
.super_endpoint
.bmAttributes
= ep
->bmAttributes_super
;
227 d
->u
.super_endpoint
.wBytesPerInterval_lo
=
228 usb_lo(ep
->wBytesPerInterval
);
229 d
->u
.super_endpoint
.wBytesPerInterval_hi
=
230 usb_hi(ep
->wBytesPerInterval
);
234 memcpy(dest
+ bLength
+ superlen
, ep
->extra
, extralen
);
237 return bLength
+ extralen
+ superlen
;
240 int usb_desc_other(const USBDescOther
*desc
, uint8_t *dest
, size_t len
)
242 int bLength
= desc
->length
? desc
->length
: desc
->data
[0];
248 memcpy(dest
, desc
->data
, bLength
);
252 static int usb_desc_cap_usb2_ext(const USBDesc
*desc
, uint8_t *dest
, size_t len
)
254 uint8_t bLength
= 0x07;
255 USBDescriptor
*d
= (void *)dest
;
261 d
->bLength
= bLength
;
262 d
->bDescriptorType
= USB_DT_DEVICE_CAPABILITY
;
263 d
->u
.cap
.bDevCapabilityType
= USB_DEV_CAP_USB2_EXT
;
265 d
->u
.cap
.u
.usb2_ext
.bmAttributes_1
= (1 << 1); /* LPM */
266 d
->u
.cap
.u
.usb2_ext
.bmAttributes_2
= 0;
267 d
->u
.cap
.u
.usb2_ext
.bmAttributes_3
= 0;
268 d
->u
.cap
.u
.usb2_ext
.bmAttributes_4
= 0;
273 static int usb_desc_cap_super(const USBDesc
*desc
, uint8_t *dest
, size_t len
)
275 uint8_t bLength
= 0x0a;
276 USBDescriptor
*d
= (void *)dest
;
282 d
->bLength
= bLength
;
283 d
->bDescriptorType
= USB_DT_DEVICE_CAPABILITY
;
284 d
->u
.cap
.bDevCapabilityType
= USB_DEV_CAP_SUPERSPEED
;
286 d
->u
.cap
.u
.super
.bmAttributes
= 0;
287 d
->u
.cap
.u
.super
.wSpeedsSupported_lo
= 0;
288 d
->u
.cap
.u
.super
.wSpeedsSupported_hi
= 0;
289 d
->u
.cap
.u
.super
.bFunctionalitySupport
= 0;
290 d
->u
.cap
.u
.super
.bU1DevExitLat
= 0x0a;
291 d
->u
.cap
.u
.super
.wU2DevExitLat_lo
= 0x20;
292 d
->u
.cap
.u
.super
.wU2DevExitLat_hi
= 0;
295 d
->u
.cap
.u
.super
.wSpeedsSupported_lo
|= (1 << 1);
296 d
->u
.cap
.u
.super
.bFunctionalitySupport
= 1;
299 d
->u
.cap
.u
.super
.wSpeedsSupported_lo
|= (1 << 2);
300 if (!d
->u
.cap
.u
.super
.bFunctionalitySupport
) {
301 d
->u
.cap
.u
.super
.bFunctionalitySupport
= 2;
305 d
->u
.cap
.u
.super
.wSpeedsSupported_lo
|= (1 << 3);
306 if (!d
->u
.cap
.u
.super
.bFunctionalitySupport
) {
307 d
->u
.cap
.u
.super
.bFunctionalitySupport
= 3;
314 static int usb_desc_bos(const USBDesc
*desc
, uint8_t *dest
, size_t len
)
316 uint8_t bLength
= 0x05;
317 uint16_t wTotalLength
= 0;
318 uint8_t bNumDeviceCaps
= 0;
319 USBDescriptor
*d
= (void *)dest
;
326 d
->bLength
= bLength
;
327 d
->bDescriptorType
= USB_DT_BOS
;
329 wTotalLength
+= bLength
;
331 if (desc
->high
!= NULL
) {
332 rc
= usb_desc_cap_usb2_ext(desc
, dest
+ wTotalLength
,
341 if (desc
->super
!= NULL
) {
342 rc
= usb_desc_cap_super(desc
, dest
+ wTotalLength
,
351 d
->u
.bos
.wTotalLength_lo
= usb_lo(wTotalLength
);
352 d
->u
.bos
.wTotalLength_hi
= usb_hi(wTotalLength
);
353 d
->u
.bos
.bNumDeviceCaps
= bNumDeviceCaps
;
357 /* ------------------------------------------------------------------ */
359 static void usb_desc_ep_init(USBDevice
*dev
)
361 const USBDescIface
*iface
;
365 for (i
= 0; i
< dev
->ninterfaces
; i
++) {
366 iface
= dev
->ifaces
[i
];
370 for (e
= 0; e
< iface
->bNumEndpoints
; e
++) {
371 pid
= (iface
->eps
[e
].bEndpointAddress
& USB_DIR_IN
) ?
372 USB_TOKEN_IN
: USB_TOKEN_OUT
;
373 ep
= iface
->eps
[e
].bEndpointAddress
& 0x0f;
374 usb_ep_set_type(dev
, pid
, ep
, iface
->eps
[e
].bmAttributes
& 0x03);
375 usb_ep_set_ifnum(dev
, pid
, ep
, iface
->bInterfaceNumber
);
376 usb_ep_set_max_packet_size(dev
, pid
, ep
,
377 iface
->eps
[e
].wMaxPacketSize
);
378 usb_ep_set_max_streams(dev
, pid
, ep
,
379 iface
->eps
[e
].bmAttributes_super
);
384 static const USBDescIface
*usb_desc_find_interface(USBDevice
*dev
,
387 const USBDescIface
*iface
;
393 for (g
= 0; g
< dev
->config
->nif_groups
; g
++) {
394 for (i
= 0; i
< dev
->config
->if_groups
[g
].nif
; i
++) {
395 iface
= &dev
->config
->if_groups
[g
].ifs
[i
];
396 if (iface
->bInterfaceNumber
== nif
&&
397 iface
->bAlternateSetting
== alt
) {
402 for (i
= 0; i
< dev
->config
->nif
; i
++) {
403 iface
= &dev
->config
->ifs
[i
];
404 if (iface
->bInterfaceNumber
== nif
&&
405 iface
->bAlternateSetting
== alt
) {
412 static int usb_desc_set_interface(USBDevice
*dev
, int index
, int value
)
414 const USBDescIface
*iface
;
417 iface
= usb_desc_find_interface(dev
, index
, value
);
422 old
= dev
->altsetting
[index
];
423 dev
->altsetting
[index
] = value
;
424 dev
->ifaces
[index
] = iface
;
425 usb_desc_ep_init(dev
);
428 usb_device_set_interface(dev
, index
, old
, value
);
433 static int usb_desc_set_config(USBDevice
*dev
, int value
)
438 dev
->configuration
= 0;
439 dev
->ninterfaces
= 0;
442 for (i
= 0; i
< dev
->device
->bNumConfigurations
; i
++) {
443 if (dev
->device
->confs
[i
].bConfigurationValue
== value
) {
444 dev
->configuration
= value
;
445 dev
->ninterfaces
= dev
->device
->confs
[i
].bNumInterfaces
;
446 dev
->config
= dev
->device
->confs
+ i
;
447 assert(dev
->ninterfaces
<= USB_MAX_INTERFACES
);
450 if (i
< dev
->device
->bNumConfigurations
) {
455 for (i
= 0; i
< dev
->ninterfaces
; i
++) {
456 usb_desc_set_interface(dev
, i
, 0);
458 for (; i
< USB_MAX_INTERFACES
; i
++) {
459 dev
->altsetting
[i
] = 0;
460 dev
->ifaces
[i
] = NULL
;
466 static void usb_desc_setdefaults(USBDevice
*dev
)
468 const USBDesc
*desc
= usb_device_get_usb_desc(dev
);
470 assert(desc
!= NULL
);
471 switch (dev
->speed
) {
474 dev
->device
= desc
->full
;
477 dev
->device
= desc
->high
;
479 case USB_SPEED_SUPER
:
480 dev
->device
= desc
->super
;
483 usb_desc_set_config(dev
, 0);
486 void usb_desc_init(USBDevice
*dev
)
488 const USBDesc
*desc
= usb_device_get_usb_desc(dev
);
490 assert(desc
!= NULL
);
491 dev
->speed
= USB_SPEED_FULL
;
494 dev
->speedmask
|= USB_SPEED_MASK_FULL
;
497 dev
->speedmask
|= USB_SPEED_MASK_HIGH
;
500 dev
->speedmask
|= USB_SPEED_MASK_SUPER
;
502 usb_desc_setdefaults(dev
);
505 void usb_desc_attach(USBDevice
*dev
)
507 const USBDesc
*desc
= usb_device_get_usb_desc(dev
);
509 assert(desc
!= NULL
);
510 if (desc
->super
&& (dev
->port
->speedmask
& USB_SPEED_MASK_SUPER
)) {
511 dev
->speed
= USB_SPEED_SUPER
;
512 } else if (desc
->high
&& (dev
->port
->speedmask
& USB_SPEED_MASK_HIGH
)) {
513 dev
->speed
= USB_SPEED_HIGH
;
514 } else if (desc
->full
&& (dev
->port
->speedmask
& USB_SPEED_MASK_FULL
)) {
515 dev
->speed
= USB_SPEED_FULL
;
519 usb_desc_setdefaults(dev
);
522 void usb_desc_set_string(USBDevice
*dev
, uint8_t index
, const char *str
)
526 QLIST_FOREACH(s
, &dev
->strings
, next
) {
527 if (s
->index
== index
) {
532 s
= g_malloc0(sizeof(*s
));
534 QLIST_INSERT_HEAD(&dev
->strings
, s
, next
);
537 s
->str
= g_strdup(str
);
541 * This function creates a serial number for a usb device.
542 * The serial number should:
543 * (a) Be unique within the virtual machine.
544 * (b) Be constant, so you don't get a new one each
545 * time the guest is started.
546 * So we are using the physical location to generate a serial number
547 * from it. It has three pieces: First a fixed, device-specific
548 * prefix. Second the device path of the host controller (which is
549 * the pci address in most cases). Third the physical port path.
550 * Results in serial numbers like this: "314159-0000:00:1d.7-3".
552 void usb_desc_create_serial(USBDevice
*dev
)
554 DeviceState
*hcd
= dev
->qdev
.parent_bus
->parent
;
555 const USBDesc
*desc
= usb_device_get_usb_desc(dev
);
556 int index
= desc
->id
.iSerialNumber
;
562 /* 'serial' usb bus property has priority if present */
563 usb_desc_set_string(dev
, index
, dev
->serial
);
567 assert(index
!= 0 && desc
->str
[index
] != NULL
);
568 dst
= snprintf(serial
, sizeof(serial
), "%s", desc
->str
[index
]);
569 path
= qdev_get_dev_path(hcd
);
571 dst
+= snprintf(serial
+dst
, sizeof(serial
)-dst
, "-%s", path
);
573 dst
+= snprintf(serial
+dst
, sizeof(serial
)-dst
, "-%s", dev
->port
->path
);
574 usb_desc_set_string(dev
, index
, serial
);
577 const char *usb_desc_get_string(USBDevice
*dev
, uint8_t index
)
581 QLIST_FOREACH(s
, &dev
->strings
, next
) {
582 if (s
->index
== index
) {
589 int usb_desc_string(USBDevice
*dev
, int index
, uint8_t *dest
, size_t len
)
591 uint8_t bLength
, pos
, i
;
601 dest
[1] = USB_DT_STRING
;
607 str
= usb_desc_get_string(dev
, index
);
609 str
= usb_device_get_usb_desc(dev
)->str
[index
];
615 bLength
= strlen(str
) * 2 + 2;
617 dest
[1] = USB_DT_STRING
;
619 while (pos
+1 < bLength
&& pos
+1 < len
) {
620 dest
[pos
++] = str
[i
++];
626 int usb_desc_get_descriptor(USBDevice
*dev
, USBPacket
*p
,
627 int value
, uint8_t *dest
, size_t len
)
629 const USBDesc
*desc
= usb_device_get_usb_desc(dev
);
630 const USBDescDevice
*other_dev
;
632 uint8_t type
= value
>> 8;
633 uint8_t index
= value
& 0xff;
636 if (dev
->speed
== USB_SPEED_HIGH
) {
637 other_dev
= usb_device_get_usb_desc(dev
)->full
;
639 other_dev
= usb_device_get_usb_desc(dev
)->high
;
643 if (dev
->device
->bcdUSB
>= 0x0300) {
644 flags
|= USB_DESC_FLAG_SUPER
;
649 ret
= usb_desc_device(&desc
->id
, dev
->device
, buf
, sizeof(buf
));
650 trace_usb_desc_device(dev
->addr
, len
, ret
);
653 if (index
< dev
->device
->bNumConfigurations
) {
654 ret
= usb_desc_config(dev
->device
->confs
+ index
, flags
,
657 trace_usb_desc_config(dev
->addr
, index
, len
, ret
);
660 ret
= usb_desc_string(dev
, index
, buf
, sizeof(buf
));
661 trace_usb_desc_string(dev
->addr
, index
, len
, ret
);
663 case USB_DT_DEVICE_QUALIFIER
:
664 if (other_dev
!= NULL
) {
665 ret
= usb_desc_device_qualifier(other_dev
, buf
, sizeof(buf
));
667 trace_usb_desc_device_qualifier(dev
->addr
, len
, ret
);
669 case USB_DT_OTHER_SPEED_CONFIG
:
670 if (other_dev
!= NULL
&& index
< other_dev
->bNumConfigurations
) {
671 ret
= usb_desc_config(other_dev
->confs
+ index
, flags
,
673 buf
[0x01] = USB_DT_OTHER_SPEED_CONFIG
;
675 trace_usb_desc_other_speed_config(dev
->addr
, index
, len
, ret
);
678 ret
= usb_desc_bos(desc
, buf
, sizeof(buf
));
679 trace_usb_desc_bos(dev
->addr
, len
, ret
);
683 /* ignore silently */
687 fprintf(stderr
, "%s: %d unknown type %d (len %zd)\n", __FUNCTION__
,
688 dev
->addr
, type
, len
);
696 memcpy(dest
, buf
, ret
);
697 p
->actual_length
= ret
;
703 int usb_desc_handle_control(USBDevice
*dev
, USBPacket
*p
,
704 int request
, int value
, int index
, int length
, uint8_t *data
)
706 const USBDesc
*desc
= usb_device_get_usb_desc(dev
);
709 assert(desc
!= NULL
);
711 case DeviceOutRequest
| USB_REQ_SET_ADDRESS
:
713 trace_usb_set_addr(dev
->addr
);
717 case DeviceRequest
| USB_REQ_GET_DESCRIPTOR
:
718 ret
= usb_desc_get_descriptor(dev
, p
, value
, data
, length
);
721 case DeviceRequest
| USB_REQ_GET_CONFIGURATION
:
723 * 9.4.2: 0 should be returned if the device is unconfigured, otherwise
724 * the non zero value of bConfigurationValue.
726 data
[0] = dev
->config
? dev
->config
->bConfigurationValue
: 0;
727 p
->actual_length
= 1;
730 case DeviceOutRequest
| USB_REQ_SET_CONFIGURATION
:
731 ret
= usb_desc_set_config(dev
, value
);
732 trace_usb_set_config(dev
->addr
, value
, ret
);
735 case DeviceRequest
| USB_REQ_GET_STATUS
: {
736 const USBDescConfig
*config
= dev
->config
?
737 dev
->config
: &dev
->device
->confs
[0];
741 * Default state: Device behavior when this request is received while
742 * the device is in the Default state is not specified.
743 * We return the same value that a configured device would return if
744 * it used the first configuration.
746 if (config
->bmAttributes
& 0x40) {
747 data
[0] |= 1 << USB_DEVICE_SELF_POWERED
;
749 if (dev
->remote_wakeup
) {
750 data
[0] |= 1 << USB_DEVICE_REMOTE_WAKEUP
;
753 p
->actual_length
= 2;
757 case DeviceOutRequest
| USB_REQ_CLEAR_FEATURE
:
758 if (value
== USB_DEVICE_REMOTE_WAKEUP
) {
759 dev
->remote_wakeup
= 0;
762 trace_usb_clear_device_feature(dev
->addr
, value
, ret
);
764 case DeviceOutRequest
| USB_REQ_SET_FEATURE
:
765 if (value
== USB_DEVICE_REMOTE_WAKEUP
) {
766 dev
->remote_wakeup
= 1;
769 trace_usb_set_device_feature(dev
->addr
, value
, ret
);
772 case InterfaceRequest
| USB_REQ_GET_INTERFACE
:
773 if (index
< 0 || index
>= dev
->ninterfaces
) {
776 data
[0] = dev
->altsetting
[index
];
777 p
->actual_length
= 1;
780 case InterfaceOutRequest
| USB_REQ_SET_INTERFACE
:
781 ret
= usb_desc_set_interface(dev
, index
, value
);
782 trace_usb_set_interface(dev
->addr
, index
, value
, ret
);