Lines Matching +full:endpoint +full:- +full:config
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
46 #define N_ALIGN(n) (-((-(n)) & (-8UL)))
60 pdev = dev->os_priv; in libusb_get_device_descriptor()
63 desc->bLength = pdesc->bLength; in libusb_get_device_descriptor()
64 desc->bDescriptorType = pdesc->bDescriptorType; in libusb_get_device_descriptor()
65 desc->bcdUSB = pdesc->bcdUSB; in libusb_get_device_descriptor()
66 desc->bDeviceClass = pdesc->bDeviceClass; in libusb_get_device_descriptor()
67 desc->bDeviceSubClass = pdesc->bDeviceSubClass; in libusb_get_device_descriptor()
68 desc->bDeviceProtocol = pdesc->bDeviceProtocol; in libusb_get_device_descriptor()
69 desc->bMaxPacketSize0 = pdesc->bMaxPacketSize0; in libusb_get_device_descriptor()
70 desc->idVendor = pdesc->idVendor; in libusb_get_device_descriptor()
71 desc->idProduct = pdesc->idProduct; in libusb_get_device_descriptor()
72 desc->bcdDevice = pdesc->bcdDevice; in libusb_get_device_descriptor()
73 desc->iManufacturer = pdesc->iManufacturer; in libusb_get_device_descriptor()
74 desc->iProduct = pdesc->iProduct; in libusb_get_device_descriptor()
75 desc->iSerialNumber = pdesc->iSerialNumber; in libusb_get_device_descriptor()
76 desc->bNumConfigurations = pdesc->bNumConfigurations; in libusb_get_device_descriptor()
83 struct libusb_config_descriptor **config) in libusb_get_active_config_descriptor() argument
88 pdev = dev->os_priv; in libusb_get_active_config_descriptor()
91 return (libusb_get_config_descriptor(dev, config_index, config)); in libusb_get_active_config_descriptor()
96 struct libusb_config_descriptor **config) in libusb_get_config_descriptor() argument
114 if (dev == NULL || config == NULL) in libusb_get_config_descriptor()
117 *config = NULL; in libusb_get_config_descriptor()
119 pdev = dev->os_priv; in libusb_get_config_descriptor()
125 nalt = nif = pconf->num_interface; in libusb_get_config_descriptor()
127 nextra = N_ALIGN(pconf->extra.len); in libusb_get_config_descriptor()
131 pinf = pconf->interface + i; in libusb_get_config_descriptor()
132 nextra += N_ALIGN(pinf->extra.len); in libusb_get_config_descriptor()
133 nep += pinf->num_endpoints; in libusb_get_config_descriptor()
134 k = pinf->num_endpoints; in libusb_get_config_descriptor()
135 pend = pinf->endpoints; in libusb_get_config_descriptor()
136 while (k--) { in libusb_get_config_descriptor()
137 nextra += N_ALIGN(pend->extra.len); in libusb_get_config_descriptor()
141 j = pinf->num_altsetting; in libusb_get_config_descriptor()
142 nalt += pinf->num_altsetting; in libusb_get_config_descriptor()
143 pinf = pinf->altsetting; in libusb_get_config_descriptor()
144 while (j--) { in libusb_get_config_descriptor()
145 nextra += N_ALIGN(pinf->extra.len); in libusb_get_config_descriptor()
146 nep += pinf->num_endpoints; in libusb_get_config_descriptor()
147 k = pinf->num_endpoints; in libusb_get_config_descriptor()
148 pend = pinf->endpoints; in libusb_get_config_descriptor()
149 while (k--) { in libusb_get_config_descriptor()
150 nextra += N_ALIGN(pend->extra.len); in libusb_get_config_descriptor()
174 pconfd->interface = (libusb_interface *) (pconfd + 1); in libusb_get_config_descriptor()
176 ifd = (libusb_interface_descriptor *) (pconfd->interface + nif); in libusb_get_config_descriptor()
180 /* fill in config descriptor */ in libusb_get_config_descriptor()
182 pconfd->bLength = pconf->desc.bLength; in libusb_get_config_descriptor()
183 pconfd->bDescriptorType = pconf->desc.bDescriptorType; in libusb_get_config_descriptor()
184 pconfd->wTotalLength = pconf->desc.wTotalLength; in libusb_get_config_descriptor()
185 pconfd->bNumInterfaces = pconf->desc.bNumInterfaces; in libusb_get_config_descriptor()
186 pconfd->bConfigurationValue = pconf->desc.bConfigurationValue; in libusb_get_config_descriptor()
187 pconfd->iConfiguration = pconf->desc.iConfiguration; in libusb_get_config_descriptor()
188 pconfd->bmAttributes = pconf->desc.bmAttributes; in libusb_get_config_descriptor()
189 pconfd->MaxPower = pconf->desc.bMaxPower; in libusb_get_config_descriptor()
191 if (pconf->extra.len != 0) { in libusb_get_config_descriptor()
192 pconfd->extra_length = pconf->extra.len; in libusb_get_config_descriptor()
193 pconfd->extra = pextra; in libusb_get_config_descriptor()
194 memcpy(pextra, pconf->extra.ptr, pconfd->extra_length); in libusb_get_config_descriptor()
195 pextra += N_ALIGN(pconfd->extra_length); in libusb_get_config_descriptor()
197 /* setup all interface and endpoint pointers */ in libusb_get_config_descriptor()
201 pconfd->interface[i].altsetting = ifd; in libusb_get_config_descriptor()
202 ifd->endpoint = endd; in libusb_get_config_descriptor()
203 endd += pconf->interface[i].num_endpoints; in libusb_get_config_descriptor()
206 for (j = 0; j < pconf->interface[i].num_altsetting; j++) { in libusb_get_config_descriptor()
207 ifd->endpoint = endd; in libusb_get_config_descriptor()
208 endd += pconf->interface[i].altsetting[j].num_endpoints; in libusb_get_config_descriptor()
213 /* fill in all interface and endpoint data */ in libusb_get_config_descriptor()
216 pinf = &pconf->interface[i]; in libusb_get_config_descriptor()
217 pconfd->interface[i].num_altsetting = pinf->num_altsetting + 1; in libusb_get_config_descriptor()
218 for (j = 0; j < pconfd->interface[i].num_altsetting; j++) { in libusb_get_config_descriptor()
220 pinf = &pconf->interface[i].altsetting[j - 1]; in libusb_get_config_descriptor()
221 ifd = &pconfd->interface[i].altsetting[j]; in libusb_get_config_descriptor()
222 ifd->bLength = pinf->desc.bLength; in libusb_get_config_descriptor()
223 ifd->bDescriptorType = pinf->desc.bDescriptorType; in libusb_get_config_descriptor()
224 ifd->bInterfaceNumber = pinf->desc.bInterfaceNumber; in libusb_get_config_descriptor()
225 ifd->bAlternateSetting = pinf->desc.bAlternateSetting; in libusb_get_config_descriptor()
226 ifd->bNumEndpoints = pinf->desc.bNumEndpoints; in libusb_get_config_descriptor()
227 ifd->bInterfaceClass = pinf->desc.bInterfaceClass; in libusb_get_config_descriptor()
228 ifd->bInterfaceSubClass = pinf->desc.bInterfaceSubClass; in libusb_get_config_descriptor()
229 ifd->bInterfaceProtocol = pinf->desc.bInterfaceProtocol; in libusb_get_config_descriptor()
230 ifd->iInterface = pinf->desc.iInterface; in libusb_get_config_descriptor()
231 if (pinf->extra.len != 0) { in libusb_get_config_descriptor()
232 ifd->extra_length = pinf->extra.len; in libusb_get_config_descriptor()
233 ifd->extra = pextra; in libusb_get_config_descriptor()
234 memcpy(pextra, pinf->extra.ptr, pinf->extra.len); in libusb_get_config_descriptor()
235 pextra += N_ALIGN(pinf->extra.len); in libusb_get_config_descriptor()
237 for (k = 0; k < pinf->num_endpoints; k++) { in libusb_get_config_descriptor()
238 pend = &pinf->endpoints[k]; in libusb_get_config_descriptor()
239 endd = &ifd->endpoint[k]; in libusb_get_config_descriptor()
240 endd->bLength = pend->desc.bLength; in libusb_get_config_descriptor()
241 endd->bDescriptorType = pend->desc.bDescriptorType; in libusb_get_config_descriptor()
242 endd->bEndpointAddress = pend->desc.bEndpointAddress; in libusb_get_config_descriptor()
243 endd->bmAttributes = pend->desc.bmAttributes; in libusb_get_config_descriptor()
244 endd->wMaxPacketSize = pend->desc.wMaxPacketSize; in libusb_get_config_descriptor()
245 endd->bInterval = pend->desc.bInterval; in libusb_get_config_descriptor()
246 endd->bRefresh = pend->desc.bRefresh; in libusb_get_config_descriptor()
247 endd->bSynchAddress = pend->desc.bSynchAddress; in libusb_get_config_descriptor()
248 if (pend->extra.len != 0) { in libusb_get_config_descriptor()
249 endd->extra_length = pend->extra.len; in libusb_get_config_descriptor()
250 endd->extra = pextra; in libusb_get_config_descriptor()
251 memcpy(pextra, pend->extra.ptr, pend->extra.len); in libusb_get_config_descriptor()
252 pextra += N_ALIGN(pend->extra.len); in libusb_get_config_descriptor()
260 *config = pconfd; in libusb_get_config_descriptor()
267 uint8_t bConfigurationValue, struct libusb_config_descriptor **config) in libusb_get_config_descriptor_by_value() argument
274 if (dev == NULL || config == NULL) in libusb_get_config_descriptor_by_value()
277 pdev = dev->os_priv; in libusb_get_config_descriptor_by_value()
280 for (i = 0; i < pdesc->bNumConfigurations; i++) { in libusb_get_config_descriptor_by_value()
281 err = libusb_get_config_descriptor(dev, i, config); in libusb_get_config_descriptor_by_value()
285 if ((*config)->bConfigurationValue == bConfigurationValue) in libusb_get_config_descriptor_by_value()
288 libusb_free_config_descriptor(*config); in libusb_get_config_descriptor_by_value()
291 *config = NULL; in libusb_get_config_descriptor_by_value()
297 libusb_free_config_descriptor(struct libusb_config_descriptor *config) in libusb_free_config_descriptor() argument
299 free(config); in libusb_free_config_descriptor()
386 ptr->bLength = LIBUSB_DT_SS_ENDPOINT_COMPANION_SIZE; in libusb_parse_ss_endpoint_comp()
387 ptr->bDescriptorType = dtype; in libusb_parse_ss_endpoint_comp()
388 ptr->bMaxBurst = ((const uint8_t *)buf)[2]; in libusb_parse_ss_endpoint_comp()
389 ptr->bmAttributes = ((const uint8_t *)buf)[3]; in libusb_parse_ss_endpoint_comp()
390 ptr->wBytesPerInterval = ((const uint8_t *)buf)[4] | in libusb_parse_ss_endpoint_comp()
399 len -= dlen; in libusb_parse_ss_endpoint_comp()
415 const struct libusb_endpoint_descriptor *endpoint, in libusb_get_ss_endpoint_companion_descriptor() argument
418 if (endpoint == NULL) in libusb_get_ss_endpoint_companion_descriptor()
420 return (libusb_parse_ss_endpoint_comp(endpoint->extra, endpoint->extra_length, ep_comp)); in libusb_get_ss_endpoint_companion_descriptor()
469 ptr->bLength = LIBUSB_DT_BOS_SIZE; in libusb_parse_bos_descriptor()
470 ptr->bDescriptorType = dtype; in libusb_parse_bos_descriptor()
471 ptr->wTotalLength = ((const uint8_t *)buf)[2] | in libusb_parse_bos_descriptor()
473 ptr->bNumDeviceCapabilities = ((const uint8_t *)buf)[4]; in libusb_parse_bos_descriptor()
474 ptr->usb_2_0_ext_cap = NULL; in libusb_parse_bos_descriptor()
475 ptr->ss_usb_cap = NULL; in libusb_parse_bos_descriptor()
476 ptr->dev_capability = calloc(ptr->bNumDeviceCapabilities, sizeof(void *)); in libusb_parse_bos_descriptor()
477 if (ptr->dev_capability == NULL) { in libusb_parse_bos_descriptor()
488 if (index != ptr->bNumDeviceCapabilities) { in libusb_parse_bos_descriptor()
489 ptr->dev_capability[index] = malloc(dlen); in libusb_parse_bos_descriptor()
490 if (ptr->dev_capability[index] == NULL) { in libusb_parse_bos_descriptor()
494 memcpy(ptr->dev_capability[index], buf, dlen); in libusb_parse_bos_descriptor()
499 if (ptr->usb_2_0_ext_cap != NULL || dcap_20 == NULL) in libusb_parse_bos_descriptor()
504 ptr->usb_2_0_ext_cap = dcap_20; in libusb_parse_bos_descriptor()
506 dcap_20->bLength = LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE; in libusb_parse_bos_descriptor()
507 dcap_20->bDescriptorType = dtype; in libusb_parse_bos_descriptor()
508 dcap_20->bDevCapabilityType = ((const uint8_t *)buf)[2]; in libusb_parse_bos_descriptor()
509 dcap_20->bmAttributes = ((const uint8_t *)buf)[3] | in libusb_parse_bos_descriptor()
516 if (ptr->ss_usb_cap != NULL || ss_cap == NULL) in libusb_parse_bos_descriptor()
521 ptr->ss_usb_cap = ss_cap; in libusb_parse_bos_descriptor()
523 ss_cap->bLength = LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE; in libusb_parse_bos_descriptor()
524 ss_cap->bDescriptorType = dtype; in libusb_parse_bos_descriptor()
525 ss_cap->bDevCapabilityType = ((const uint8_t *)buf)[2]; in libusb_parse_bos_descriptor()
526 ss_cap->bmAttributes = ((const uint8_t *)buf)[3]; in libusb_parse_bos_descriptor()
527 ss_cap->wSpeedSupported = ((const uint8_t *)buf)[4] | in libusb_parse_bos_descriptor()
529 ss_cap->bFunctionalitySupport = ((const uint8_t *)buf)[6]; in libusb_parse_bos_descriptor()
530 ss_cap->bU1DevExitLat = ((const uint8_t *)buf)[7]; in libusb_parse_bos_descriptor()
531 ss_cap->wU2DevExitLat = ((const uint8_t *)buf)[8] | in libusb_parse_bos_descriptor()
541 len -= dlen; in libusb_parse_bos_descriptor()
545 ptr->bNumDeviceCapabilities = index; in libusb_parse_bos_descriptor()
560 for (i = 0; i != bos->bNumDeviceCapabilities; i++) in libusb_free_bos_descriptor()
561 free(bos->dev_capability[i]); in libusb_free_bos_descriptor()
562 free(bos->dev_capability); in libusb_free_bos_descriptor()
611 dev_cap->bDevCapabilityType != LIBUSB_BT_USB_2_0_EXTENSION) in libusb_get_usb_2_0_extension_descriptor()
613 if (dev_cap->bLength < LIBUSB_BT_USB_2_0_EXTENSION_SIZE) in libusb_get_usb_2_0_extension_descriptor()
620 desc->bLength = LIBUSB_BT_USB_2_0_EXTENSION_SIZE; in libusb_get_usb_2_0_extension_descriptor()
621 desc->bDescriptorType = dev_cap->bDescriptorType; in libusb_get_usb_2_0_extension_descriptor()
622 desc->bDevCapabilityType = dev_cap->bDevCapabilityType; in libusb_get_usb_2_0_extension_descriptor()
623 desc->bmAttributes = in libusb_get_usb_2_0_extension_descriptor()
624 (dev_cap->dev_capability_data[0]) | in libusb_get_usb_2_0_extension_descriptor()
625 (dev_cap->dev_capability_data[1] << 8) | in libusb_get_usb_2_0_extension_descriptor()
626 (dev_cap->dev_capability_data[2] << 16) | in libusb_get_usb_2_0_extension_descriptor()
627 (dev_cap->dev_capability_data[3] << 24); in libusb_get_usb_2_0_extension_descriptor()
649 dev_cap->bDevCapabilityType != LIBUSB_BT_SS_USB_DEVICE_CAPABILITY) in libusb_get_ss_usb_device_capability_descriptor()
651 if (dev_cap->bLength < LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE) in libusb_get_ss_usb_device_capability_descriptor()
658 desc->bLength = LIBUSB_BT_SS_USB_DEVICE_CAPABILITY_SIZE; in libusb_get_ss_usb_device_capability_descriptor()
659 desc->bDescriptorType = dev_cap->bDescriptorType; in libusb_get_ss_usb_device_capability_descriptor()
660 desc->bDevCapabilityType = dev_cap->bDevCapabilityType; in libusb_get_ss_usb_device_capability_descriptor()
661 desc->bmAttributes = dev_cap->dev_capability_data[0]; in libusb_get_ss_usb_device_capability_descriptor()
662 desc->wSpeedSupported = dev_cap->dev_capability_data[1] | in libusb_get_ss_usb_device_capability_descriptor()
663 (dev_cap->dev_capability_data[2] << 8); in libusb_get_ss_usb_device_capability_descriptor()
664 desc->bFunctionalitySupport = dev_cap->dev_capability_data[3]; in libusb_get_ss_usb_device_capability_descriptor()
665 desc->bU1DevExitLat = dev_cap->dev_capability_data[4]; in libusb_get_ss_usb_device_capability_descriptor()
666 desc->wU2DevExitLat = dev_cap->dev_capability_data[5] | in libusb_get_ss_usb_device_capability_descriptor()
667 (dev_cap->dev_capability_data[6] << 8); in libusb_get_ss_usb_device_capability_descriptor()
689 dev_cap->bDevCapabilityType != LIBUSB_BT_CONTAINER_ID) in libusb_get_container_id_descriptor()
691 if (dev_cap->bLength < LIBUSB_BT_CONTAINER_ID_SIZE) in libusb_get_container_id_descriptor()
698 desc->bLength = LIBUSB_BT_CONTAINER_ID_SIZE; in libusb_get_container_id_descriptor()
699 desc->bDescriptorType = dev_cap->bDescriptorType; in libusb_get_container_id_descriptor()
700 desc->bDevCapabilityType = dev_cap->bDevCapabilityType; in libusb_get_container_id_descriptor()
701 desc->bReserved = dev_cap->dev_capability_data[0]; in libusb_get_container_id_descriptor()
702 memcpy(desc->ContainerID, dev_cap->dev_capability_data + 1, in libusb_get_container_id_descriptor()
703 sizeof(desc->ContainerID)); in libusb_get_container_id_descriptor()