Lines 607-628
static int
Link Here
|
607 |
ubt_probe(device_t dev) |
607 |
ubt_probe(device_t dev) |
608 |
{ |
608 |
{ |
609 |
struct usb_attach_arg *uaa = device_get_ivars(dev); |
609 |
struct usb_attach_arg *uaa = device_get_ivars(dev); |
610 |
int error; |
610 |
const struct usb_device_id *id; |
611 |
|
611 |
|
612 |
if (uaa->usb_mode != USB_MODE_HOST) |
612 |
if (uaa->usb_mode != USB_MODE_HOST) |
613 |
return (ENXIO); |
613 |
return (ENXIO); |
614 |
|
614 |
|
615 |
if (uaa->info.bIfaceIndex != 0) |
|
|
616 |
return (ENXIO); |
617 |
|
618 |
if (usbd_lookup_id_by_uaa(ubt_ignore_devs, |
615 |
if (usbd_lookup_id_by_uaa(ubt_ignore_devs, |
619 |
sizeof(ubt_ignore_devs), uaa) == 0) |
616 |
sizeof(ubt_ignore_devs), uaa) == 0) |
620 |
return (ENXIO); |
617 |
return (ENXIO); |
621 |
|
618 |
|
622 |
error = usbd_lookup_id_by_uaa(ubt_devs, sizeof(ubt_devs), uaa); |
619 |
id = usbd_lookup_id_by_info(ubt_devs, |
623 |
if (error == 0) |
620 |
sizeof(ubt_devs), &uaa->info); |
|
|
621 |
if (id == NULL) |
622 |
return (ENXIO); |
623 |
|
624 |
if (uaa->info.bIfaceIndex != 0) { |
625 |
/* make sure we are matching the interface */ |
626 |
if (id->match_flag_int_class && |
627 |
id->match_flag_int_subclass && |
628 |
id->match_flag_int_protocol) |
629 |
return (BUS_PROBE_GENERIC); |
630 |
else |
631 |
return (ENXIO); |
632 |
} else { |
624 |
return (BUS_PROBE_GENERIC); |
633 |
return (BUS_PROBE_GENERIC); |
625 |
return (error); |
634 |
} |
626 |
} /* ubt_probe */ |
635 |
} /* ubt_probe */ |
627 |
|
636 |
|
628 |
/* |
637 |
/* |
Lines 637-652
ubt_attach(device_t dev)
Link Here
|
637 |
struct ubt_softc *sc = device_get_softc(dev); |
646 |
struct ubt_softc *sc = device_get_softc(dev); |
638 |
struct usb_endpoint_descriptor *ed; |
647 |
struct usb_endpoint_descriptor *ed; |
639 |
struct usb_interface_descriptor *id; |
648 |
struct usb_interface_descriptor *id; |
640 |
struct usb_interface *iface; |
649 |
struct usb_interface *iface[2]; |
641 |
uint32_t wMaxPacketSize; |
650 |
uint32_t wMaxPacketSize; |
642 |
uint8_t alt_index, i, j; |
651 |
uint8_t alt_index, i, j; |
643 |
uint8_t iface_index[2] = { 0, 1 }; |
652 |
uint8_t iface_index[2]; |
644 |
|
653 |
|
645 |
device_set_usb_desc(dev); |
654 |
device_set_usb_desc(dev); |
646 |
|
655 |
|
|
|
656 |
iface_index[0] = uaa->info.bIfaceIndex; |
657 |
iface_index[1] = uaa->info.bIfaceIndex + 1; |
658 |
|
659 |
iface[0] = usbd_get_iface(uaa->device, iface_index[0]); |
660 |
iface[1] = usbd_get_iface(uaa->device, iface_index[1]); |
661 |
|
647 |
sc->sc_dev = dev; |
662 |
sc->sc_dev = dev; |
648 |
sc->sc_debug = NG_UBT_WARN_LEVEL; |
663 |
sc->sc_debug = NG_UBT_WARN_LEVEL; |
649 |
|
664 |
|
|
|
665 |
/* |
666 |
* Sanity checks. |
667 |
*/ |
668 |
|
669 |
if (iface[0] == NULL || iface[1] == NULL || |
670 |
iface[0]->idesc == NULL || iface[1]->idesc == NULL) { |
671 |
UBT_ALERT(sc, "could not get two interfaces\n"); |
672 |
return (ENXIO); |
673 |
} |
674 |
|
650 |
/* |
675 |
/* |
651 |
* Create Netgraph node |
676 |
* Create Netgraph node |
652 |
*/ |
677 |
*/ |
Lines 720-732
ubt_attach(device_t dev)
Link Here
|
720 |
if ((ed->bDescriptorType == UDESC_INTERFACE) && |
745 |
if ((ed->bDescriptorType == UDESC_INTERFACE) && |
721 |
(ed->bLength >= sizeof(*id))) { |
746 |
(ed->bLength >= sizeof(*id))) { |
722 |
id = (struct usb_interface_descriptor *)ed; |
747 |
id = (struct usb_interface_descriptor *)ed; |
723 |
i = id->bInterfaceNumber; |
748 |
i = (id->bInterfaceNumber == iface[1]->idesc->bInterfaceNumber); |
724 |
j = id->bAlternateSetting; |
749 |
j = id->bAlternateSetting; |
725 |
} |
750 |
} |
726 |
|
751 |
|
727 |
if ((ed->bDescriptorType == UDESC_ENDPOINT) && |
752 |
if ((ed->bDescriptorType == UDESC_ENDPOINT) && |
728 |
(ed->bLength >= sizeof(*ed)) && |
753 |
(ed->bLength >= sizeof(*ed)) && |
729 |
(i == 1)) { |
754 |
(i != 0)) { |
730 |
uint32_t temp; |
755 |
uint32_t temp; |
731 |
|
756 |
|
732 |
temp = usbd_get_max_frame_length( |
757 |
temp = usbd_get_max_frame_length( |
Lines 740-746
ubt_attach(device_t dev)
Link Here
|
740 |
|
765 |
|
741 |
/* Set alt configuration on interface #1 only if we found it */ |
766 |
/* Set alt configuration on interface #1 only if we found it */ |
742 |
if (wMaxPacketSize > 0 && |
767 |
if (wMaxPacketSize > 0 && |
743 |
usbd_set_alt_interface_index(uaa->device, 1, alt_index)) { |
768 |
usbd_set_alt_interface_index(uaa->device, iface_index[1], alt_index)) { |
744 |
UBT_ALERT(sc, "could not set alternate setting %d " \ |
769 |
UBT_ALERT(sc, "could not set alternate setting %d " \ |
745 |
"for interface 1!\n", alt_index); |
770 |
"for interface 1!\n", alt_index); |
746 |
goto detach; |
771 |
goto detach; |
Lines 754-774
ubt_attach(device_t dev)
Link Here
|
754 |
goto detach; |
779 |
goto detach; |
755 |
} |
780 |
} |
756 |
|
781 |
|
757 |
/* Claim all interfaces belonging to the Bluetooth part */ |
782 |
/* Claim second interface belonging to the Bluetooth part */ |
758 |
for (i = 1;; i++) { |
783 |
usbd_set_parent_iface(uaa->device, iface_index[1], uaa->info.bIfaceIndex); |
759 |
iface = usbd_get_iface(uaa->device, i); |
784 |
|
760 |
if (iface == NULL) |
|
|
761 |
break; |
762 |
id = usbd_get_interface_descriptor(iface); |
763 |
|
764 |
if ((id != NULL) && |
765 |
(id->bInterfaceClass == UICLASS_WIRELESS) && |
766 |
(id->bInterfaceSubClass == UISUBCLASS_RF) && |
767 |
(id->bInterfaceProtocol == UIPROTO_BLUETOOTH)) { |
768 |
usbd_set_parent_iface(uaa->device, i, |
769 |
uaa->info.bIfaceIndex); |
770 |
} |
771 |
} |
772 |
return (0); /* success */ |
785 |
return (0); /* success */ |
773 |
|
786 |
|
774 |
detach: |
787 |
detach: |