[PATCH] USB Bluetooth devices

Maksim Yevmenkin <[email protected]>
Newsgroups gmane.os.freebsd.devel.mobile
Message-ID <20030411202822.59805.qmail__15482.0461561487$1050097701@web40301.mail.yahoo.com>
Dear Hackers,

I would like to ask USB Bluetooth device owners to try the attached
patch for the ng_ubt(4) driver. This patch for is the latest (2003/4/7)
snapshot.

The purpose of the patch is to eliminate hardwired VendorID/ProductID
pairs in the USB_MATCH function. Instead ng_ubt(4) driver now looks at
bDeviceClass, bDeviceSubClass and bDeviceProtocol fields in the device
descriptor and checks if they are equal to UDCLASS_WIRELESS, 
UDPROTO_BLUETOOTH and UDSUBCLASS_RF respectively.

Please try it and let me know if it works for you.

thanks,
max

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com

_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-mobile
To unsubscribe, send any mail to "[email protected]"
ng_ubt.devclass.diff (application/octet-stream, 4.9 KB)
Index: sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
===================================================================
RCS file: /usr/local/cvs/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c,v
retrieving revision 1.10
diff -u -7 -r1.10 ng_ubt.c
--- sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c	9 Apr 2003 18:10:52 -0000	1.10
+++ sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c	11 Apr 2003 20:06:41 -0000
@@ -291,34 +291,25 @@
 
 /*
  * Probe for a USB Bluetooth device
  */
 
 USB_MATCH(ubt)
 {
-	Static struct usb_devno const	ubt_devices[] = {
-		{ USB_VENDOR_3COM,     USB_PRODUCT_3COM_3CREB96 },
-		{ USB_VENDOR_MITSUMI,  USB_PRODUCT_MITSUMI_BT_DONGLE },
-		{ USB_VENDOR_TDK,      USB_PRODUCT_TDK_BT_DONGLE },
-		{ USB_VENDOR_MSI,      USB_PRODUCT_MSI_BT_DONGLE },
-		{ USB_VENDOR_BROADCOM, USB_PRODUCT_DBW_120M_BT_DONGLE },
-		{ USB_VENDOR_EPOX,     USB_PRODUCT_BT_DG02_DONGLE },
-		{ USB_VENDOR_MICROSOFT,USB_PRODUCT_MICROSOFT_BT_TRANS },
-		{ USB_VENDOR_ALPS2,    USB_PRODUCT_ALPS2_UGT },
-		{ USB_VENDOR_ABOCOM,   USB_PRODUCT_ABO_BT_DONGLE },
-		{ 0, 0 }
-	};
-
 	USB_MATCH_START(ubt, uaa);
 
-	if (uaa->iface == NULL || 
-	    usb_lookup(ubt_devices, uaa->vendor, uaa->product) == NULL)
+	usb_device_descriptor_t	*dd = usbd_get_device_descriptor(uaa->device);
+
+	if (uaa->iface == NULL ||
+	    dd->bDeviceClass != UDCLASS_WIRELESS ||
+	    dd->bDeviceSubClass != UDSUBCLASS_RF ||
+	    dd->bDeviceProtocol != UDPROTO_BLUETOOTH)
 		return (UMATCH_NONE);
 
-	return (UMATCH_VENDOR_PRODUCT);
+	return (UMATCH_DEVCLASS_DEVSUBCLASS);
 } /* USB_MATCH(ubt) */
 
 /*
  * Attach the device
  */
 
 USB_ATTACH(ubt)
@@ -428,24 +419,14 @@
 
 	id = usbd_get_interface_descriptor(sc->sc_iface0);
 	if (id == NULL) {
 		printf("%s: Could not get interface 0 descriptor\n",
 			USBDEVNAME(sc->sc_dev));
 		goto bad;
 	}
-	if (id->bInterfaceClass != UICLASS_WIRELESS ||
-	    id->bInterfaceSubClass != UISUBCLASS_RF ||
-	    id->bInterfaceProtocol != UIPROTO_BLUETOOTH) {
-		printf("%s: Interface 0 is not supported, " \
-			"bInterfaceClass=%#x, bInterfaceSubClass=%#x, "\
-			"bInterfaceProtocol=%#x\n", USBDEVNAME(sc->sc_dev),
-			id->bInterfaceClass, id->bInterfaceSubClass, 
-			id->bInterfaceProtocol);
-		goto bad;
-	}
 
 	for (i = 0; i < id->bNumEndpoints; i ++) {
 		ed = usbd_interface2endpoint_descriptor(sc->sc_iface0, i);
 		if (ed == NULL) {
 			printf("%s: Could not read endpoint descriptor for " \
 				"interface 0, i=%d\n", USBDEVNAME(sc->sc_dev),
 				i);
@@ -506,24 +487,14 @@
 		goto bad;
 	}
 
 	id = usbd_get_interface_descriptor(sc->sc_iface1);
 	if (id == NULL) {
 		printf("%s: Could not get interface 1 descriptor\n",
 			USBDEVNAME(sc->sc_dev));
-		goto bad;
-	}
-	if (id->bInterfaceClass != UICLASS_WIRELESS ||
-	    id->bInterfaceSubClass != UISUBCLASS_RF ||
-	    id->bInterfaceProtocol != UIPROTO_BLUETOOTH) {
-		printf("%s: Interface 1 is not supported, " \
-			"bInterfaceClass=%#x, bInterfaceSubClass=%#x, "\
-			"bInterfaceProtocol=%#x\n", USBDEVNAME(sc->sc_dev),
-			id->bInterfaceClass, id->bInterfaceSubClass, 
-			id->bInterfaceProtocol);
 		goto bad;
 	}
 
 	/*
 	 * Scan all alternate configurations for interface 1
 	 */
 
Index: sys/netgraph/bluetooth/include/ng_ubt.h
===================================================================
RCS file: /usr/local/cvs/sys/netgraph/bluetooth/include/ng_ubt.h,v
retrieving revision 1.5
diff -u -7 -r1.5 ng_ubt.h
--- sys/netgraph/bluetooth/include/ng_ubt.h	9 Apr 2003 18:10:54 -0000	1.5
+++ sys/netgraph/bluetooth/include/ng_ubt.h	11 Apr 2003 20:07:58 -0000
@@ -28,29 +28,14 @@
  * $Id: ng_ubt.h,v 1.5 2003/04/09 18:10:54 max Exp $
  * $FreeBSD$
  */
 
 #ifndef _NG_UBT_H_
 #define _NG_UBT_H_
 
-/* XXX FIXME Does not belong here. Move to usbdevs.h later */
-#define USB_VENDOR_MSI			0x0db0 /* MSI www.msi.com.tw */
-#define USB_VENDOR_EPOX			0x0a12 /* EPoX www.epox.com */
-#define USB_VENDOR_ALPS2		0x049f /* ALPS - another ID */
-
-#define USB_PRODUCT_3COM_3CREB96	0x00a0 /* 3Com Bluetooth USB dongle */
-#define USB_PRODUCT_MITSUMI_BT_DONGLE	0x641f /* Mitsumi Bluetooth USB dongle*/
-#define USB_PRODUCT_TDK_BT_DONGLE	0x0309 /* TDK Bluetooth USB dongle */
-#define USB_PRODUCT_MSI_BT_DONGLE	0x1967 /* MSI Bluetooth USB dongle */
-#define USB_PRODUCT_DBW_120M_BT_DONGLE	0x2033 /* D-Link DBW-120M */
-#define USB_PRODUCT_BT_DG02_DONGLE	0x0001 /* EPoX BT-DG02 USB dongle */
-#define USB_PRODUCT_MICROSOFT_BT_TRANS	0x007e /* MS Wireless Transceiver */
-#define USB_PRODUCT_ALPS2_UGT		0x0027 /* Compaq Evo 610c BT module */
-#define USB_PRODUCT_ABO_BT_DONGLE	0xb02a /* AboCom Bluetooth USB dongle */
-
 /**************************************************************************
  **************************************************************************
  **     Netgraph node hook name, type name and type cookie and commands 
  **************************************************************************  
  **************************************************************************/
 
 #define NG_UBT_NODE_TYPE	"ubt"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.