Lines Matching refs:hdl

74 static	int usb_open_ep0(usb_dev_handle_impl_t *hdl);
75 static void usb_close_ep0(usb_dev_handle_impl_t *hdl);
84 static void usb_set_ep_iface_alts(usb_dev_handle_impl_t *hdl,
87 static int usb_setup_all_configs(usb_dev_handle_impl_t *hdl);
89 static int usb_parse_config(usb_dev_handle_impl_t *hdl, uint_t index);
91 static int usb_parse_interface(usb_dev_handle_impl_t *hdl, uint_t index,
95 static int usb_parse_alternate(usb_dev_handle_impl_t *hdl, uint_t index,
99 static int usb_parse_endpoint(usb_dev_handle_impl_t *hdl, int index,
104 static void usb_close_all_eps(usb_dev_handle_impl_t *hdl);
312 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
314 return ((hdl != NULL) ? hdl->device : NULL);
326 usb_dev_handle_impl_t *hdl;
341 if ((hdl = calloc(sizeof (*hdl), 1)) == NULL) {
345 hdl->device = dev;
347 free(hdl);
352 hdl->info = info;
356 hdl->info->ep_fd[i] = -1;
357 hdl->info->ep_status_fd[i] = -1;
359 hdl->info->ep_interface[i] = -1;
364 if ((rval = usb_open_ep0(hdl)) != 0) {
367 free(hdl);
376 if (usb_setup_all_configs(hdl) != 0) {
377 usb_free_all_configs(hdl->device);
378 usb_close_ep0(hdl);
380 free(hdl);
389 usb_dprintf(DEBUG_FUNCTIONS, "usb_open(): hdl=0x%x\n", (int)hdl);
391 return ((usb_dev_handle *)hdl);
403 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
406 usb_dprintf(DEBUG_FUNCTIONS, "usb_close(): hdl=0x%x\n", hdl);
408 if (hdl) {
409 info = hdl->info;
419 usb_close_all_eps(hdl);
420 usb_close_ep0(hdl);
423 free(hdl);
443 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
450 if ((hdl == NULL) || (size < 0)) {
454 info = hdl->info;
501 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
508 if ((hdl == NULL) || (data == NULL) || (size <= 0)) {
514 info = hdl->info;
543 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
552 if ((hdl == NULL) || (data == NULL) || (size <= 0)) {
558 info = hdl->info;
588 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
595 if ((hdl == NULL) || (data == NULL) || (size <= 0)) {
601 info = hdl->info;
631 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
640 if ((hdl == NULL) || (data == NULL) || (size <= 0)) {
646 info = hdl->info;
834 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
840 "hdl=0x%x alt=%d\n", hdl, alt);
842 if (hdl == NULL) {
849 info = hdl->info;
867 dev_specific = (usb_device_specific_t *)(hdl->device->dev);
869 usb_dprintf(DEBUG_DETAILED, "claimed=%d, cfgvalue=%d, hdl=0x%x\n",
871 dev_specific->claimed_interfaces[iface], hdl);
875 (hdl != dev_specific->claimed_interfaces[iface])) {
880 usb_close_all_eps(hdl);
883 for (index = 0; index < hdl->device->descriptor.bNumConfigurations;
886 hdl->device->config[index].bConfigurationValue) {
894 hdl->device->config[index].interface[iface].num_altsetting);
896 if ((alt < 0) || (alt >= hdl->device->
904 usb_set_ep_iface_alts(hdl, info, index, iface, alt);
921 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
928 if (hdl == NULL) {
934 info = hdl->info;
937 for (index = 0; index < hdl->device->descriptor.bNumConfigurations;
940 hdl->device->config[index].bConfigurationValue) {
945 if (index >= hdl->device->descriptor.bNumConfigurations) {
952 usb_close_all_eps(hdl);
980 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
991 info = hdl->info;
1030 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
1035 if (hdl == NULL) {
1041 info = hdl->info;
1042 dev_specific = (usb_device_specific_t *)(hdl->device->dev);
1044 usb_dprintf(DEBUG_FUNCTIONS, "usb_claim_interface(): hdl=0x%x: "
1045 "interface = %d\n", hdl, interface);
1052 index < hdl->device->descriptor.bNumConfigurations;
1055 hdl->device->config[index].bConfigurationValue) {
1061 hdl->device->config[index].bConfigurationValue;
1069 (interface >= hdl->device->config[index].bNumInterfaces)) {
1075 if (dev_specific->claimed_interfaces[interface] == hdl) {
1090 usb_dprintf(DEBUG_DETAILED, "usb_claim_interface(): hdl=0x%x: "
1091 "interface = %d, claimed by this udev=%d, by hdl=0x%x\n",
1092 hdl, interface, info->claimed_interface,
1098 dev_specific->claimed_interfaces[interface] = hdl;
1100 usb_set_ep_iface_alts(hdl, info, index, interface, 0);
1115 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
1119 if (hdl == NULL) {
1126 info = hdl->info;
1127 dev_specific = (usb_device_specific_t *)(hdl->device->dev);
1129 usb_dprintf(DEBUG_FUNCTIONS, "usb_release_interface(): hdl=0x%x: "
1130 "interface = %d\n", hdl, interface);
1138 usb_dprintf(DEBUG_DETAILED, "usb_release_interface(): hdl=0x%x: "
1139 "interface = %d, claimed by this udev=%d, by hdl=0x%x\n",
1140 hdl, interface, info->claimed_interface,
1302 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
1303 usb_dev_handle_info_t *info = hdl->info;
1305 if (hdl == NULL) {
1309 info = hdl->info;
1312 "hdl=0x%x conf=%d claimed=%d alternate=%d\n",
1313 (int)hdl, info->configuration_value,
1331 usb_set_ep_iface_alts(usb_dev_handle_impl_t *hdl, usb_dev_handle_info_t *info,
1347 if_descr = &hdl->device->config[index].interface[interface].
1355 ep_descr = &hdl->device->config[index].interface[interface].
1380 usb_dev_handle_impl_t *hdl = (usb_dev_handle_impl_t *)dev;
1381 usb_dev_handle_info_t *info = hdl->info;
1449 hdl->device->bus->dirname, hdl->device->filename,
1550 usb_open_ep0(usb_dev_handle_impl_t *hdl)
1554 (usb_device_specific_t *)(hdl->device->dev);
1560 hdl->info->ep_fd[0] = dev_specific->ep0_fd;
1561 hdl->info->ep_status_fd[0] = dev_specific->ep0_fd_stat;
1576 hdl->device->bus->dirname, hdl->device->filename);
1580 hdl->info->ep_fd[0] = open(filename, O_RDWR);
1581 if (hdl->info->ep_fd[0] < 0) {
1583 hdl->info->ep_fd[0]);
1590 hdl->device->bus->dirname, hdl->device->filename);
1594 hdl->info->ep_status_fd[0] = open(filename, O_RDONLY);
1595 if (hdl->info->ep_status_fd[0] < 0) {
1602 dev_specific->ep0_fd = hdl->info->ep_fd[0];
1603 dev_specific->ep0_fd_stat = hdl->info->ep_status_fd[0];
1618 usb_close_ep0(usb_dev_handle_impl_t *hdl)
1621 (usb_device_specific_t *)(hdl->device->dev);
1635 if (hdl->info->ep_fd[0] != -1) {
1636 (void) close(hdl->info->ep_fd[0]);
1637 hdl->info->ep_fd[0] = -1;
1639 if (hdl->info->ep_status_fd[0] != -1) {
1640 (void) close(hdl->info->ep_status_fd[0]);
1641 hdl->info->ep_status_fd[0] = -1;
1652 usb_close_all_eps(usb_dev_handle_impl_t *hdl)
1659 if (hdl->info->ep_fd[i] != -1) {
1660 (void) close(hdl->info->ep_fd[i]);
1661 hdl->info->ep_fd[i] = -1;
1663 if (hdl->info->ep_status_fd[i] != -1) {
1664 (void) close(hdl->info->ep_status_fd[i]);
1665 hdl->info->ep_status_fd[i] = -1;
1677 usb_setup_all_configs(usb_dev_handle_impl_t *hdl)
1683 if (hdl->device->config) {
1691 rval = usb_control_msg((usb_dev_handle *)hdl,
1705 (struct usb_device_descriptor *)&hdl->device->descriptor,
1717 hdl->device->descriptor.bNumConfigurations;
1719 if ((hdl->device->config = calloc(len, 1)) == NULL) {
1725 for (index = 0; index < hdl->device->descriptor.bNumConfigurations;
1727 if ((rval = usb_parse_config(hdl, index)) != 0) {
1766 usb_parse_config(usb_dev_handle_impl_t *hdl, uint_t index)
1778 rval = usb_control_msg((usb_dev_handle *)hdl,
1792 (usb_cfg_descr_t *)&hdl->device->config[index],
1805 hdl->device->config[index].bLength,
1806 hdl->device->config[index].bDescriptorType,
1807 hdl->device->config[index].wTotalLength,
1808 hdl->device->config[index].bNumInterfaces,
1809 hdl->device->config[index].bConfigurationValue);
1811 if ((cloud = malloc(hdl->device->config[index].wTotalLength)) ==
1818 rval = usb_control_msg((usb_dev_handle *)hdl,
1822 hdl->device->config[index].wTotalLength, 0);
1824 if (rval != hdl->device->config[index].wTotalLength) {
1832 hdl->device->config[index].wTotalLength,
1833 (usb_cfg_descr_t *)&hdl->device->config[index],
1842 if ((hdl->device->config[index].extra =
1849 (void) memcpy(hdl->device->config[index].extra, extra,
1851 hdl->device->config[index].extralen = extralen;
1855 len = hdl->device->config[index].bNumInterfaces *
1857 if ((hdl->device->config[index].interface = calloc(len, 1)) ==
1864 for (iface = 0; iface < hdl->device->config[index].bNumInterfaces;
1866 rval = usb_parse_interface(hdl, index, iface, cloud);
1909 usb_parse_interface(usb_dev_handle_impl_t *hdl, uint_t index, uint_t iface,
1924 hdl->device->config[index].wTotalLength,
1944 if ((hdl->device->config[index].interface[iface].altsetting =
1949 hdl->device->config[index].interface[iface].num_altsetting =
1952 rval = usb_parse_alternate(hdl, index, iface, alt, cloud);
1993 usb_parse_alternate(usb_dev_handle_impl_t *hdl, uint_t index, uint_t iface,
2006 hdl->device->config[index].wTotalLength,
2030 &hdl->device->config[index].interface[iface].altsetting[alt],
2039 if ((hdl->device->config[index].interface[iface].
2045 hdl->device->config[index].interface[iface].
2047 hdl->device->config[index].interface[iface].
2059 if ((hdl->device->config[index].interface[iface].altsetting[alt].
2066 rval = usb_parse_endpoint(hdl, index, iface, alt, ep, cloud);
2118 usb_parse_endpoint(usb_dev_handle_impl_t *hdl, int index, int iface,
2131 hdl->device->config[index].wTotalLength,
2148 (void) memcpy(&hdl->device->
2158 if ((hdl->device->config[index].interface[iface].
2164 (void) memcpy(hdl->device->config[index].interface[iface].
2166 hdl->device->config[index].interface[iface].