Subject: kern/25954: Add support for AH-K3001V, Personal Handy Phone by Kyocera Corp.
To: None <gnats-bugs@gnats.NetBSD.org>
From: Takahiro Kambe <taca@back-street.net>
List: netbsd-bugs
Date: 06/18/2004 00:57:44
>Number:         25954
>Category:       kern
>Synopsis:       Add support for AH-K3001V, Personal Handy Phone by Kyocera Corp.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 17 15:59:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Takahiro Kambe
>Release:        NetBSD 2.0F
>Organization:
Takahiro Kambe
>Environment:
	
	
System: NetBSD edge.back-street.net 2.0F NetBSD 2.0F (CF-R1) #134: Thu Jun 17 22:44:55 JST 2004 taca@edge.back-street.net:/var/obj/sys/arch/i386/compile/CF-R1 i386
Architecture: i386
Machine: i386
>Description:
	AH-K3001V is a Personal Handy Phone (another kind of celler phone
	in Thai-land, Chinese, Taiwan and Japan).  It could be recognized
	as umodem(4) with some patches from FreeBSD.
>How-To-Repeat:
	
>Fix:
	Apply these patches.

Index: sys/dev/usb/umodem.c
===================================================================
RCS file: /usr/local/share/cvs/src/sys/dev/usb/umodem.c,v
retrieving revision 1.1.1.1.2.2
diff -u -r1.1.1.1.2.2 umodem.c
--- sys/dev/usb/umodem.c	25 Apr 2004 01:23:07 -0000	1.1.1.1.2.2
+++ sys/dev/usb/umodem.c	17 Jun 2004 13:41:45 -0000
@@ -85,6 +85,16 @@
 #endif
 #define DPRINTF(x) DPRINTFN(0, x)
 
+static const struct umodem_product {
+	u_int16_t	vendor;
+	u_int16_t	product;
+	u_int8_t	interface;
+} umodem_products[] = {
+	/* Kyocera AH-K3001V*/
+	{ USB_VENDOR_KYOCERA, USB_PRODUCT_KYOCERA_AHK3001V, 0 },
+	{ 0, 0, 0 },
+};
+
 /*
  * These are the maximum number of bytes transferred per frame.
  * If some really high speed devices should use this driver they
@@ -161,25 +171,43 @@
 {
 	USB_MATCH_START(umodem, uaa);
 	usb_interface_descriptor_t *id;
-	int cm, acm;
+	usb_device_descriptor_t *dd;
+	int cm, acm, i, ret;
 
 	if (uaa->iface == NULL)
 		return (UMATCH_NONE);
 
 	id = usbd_get_interface_descriptor(uaa->iface);
-	if (id == NULL ||
-	    id->bInterfaceClass != UICLASS_CDC ||
-	    id->bInterfaceSubClass != UISUBCLASS_ABSTRACT_CONTROL_MODEL ||
-	    id->bInterfaceProtocol != UIPROTO_CDC_AT)
+	dd = usbd_get_device_descriptor(uaa->device);
+	if (id == NULL || dd == NULL)
 		return (UMATCH_NONE);
 
+	ret = UMATCH_NONE;
+	for (i = 0; umodem_products[i].vendor != 0; i++) {
+		if (umodem_products[i].vendor == UGETW(dd->idVendor) &&
+		    umodem_products[i].product == UGETW(dd->idProduct) &&
+		    umodem_products[i].interface == id->bInterfaceNumber) {
+			ret = UMATCH_VENDOR_PRODUCT;
+			break;
+		}
+	}
+
+	if (ret == UMATCH_NONE &&
+	    id->bInterfaceClass == UICLASS_CDC &&
+	    id->bInterfaceSubClass == UISUBCLASS_ABSTRACT_CONTROL_MODEL &&
+	    id->bInterfaceProtocol == UIPROTO_CDC_AT)
+		ret = UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO;
+
+	if (ret == UMATCH_NONE)
+		return (ret);
+
 	umodem_get_caps(uaa->device, &cm, &acm);
 	if (!(cm & USB_CDC_CM_DOES_CM) ||
 	    !(cm & USB_CDC_CM_OVER_DATA) ||
 	    !(acm & USB_CDC_ACM_HAS_LINE))
 		return (UMATCH_NONE);
 
-	return (UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO);
+	return ret;
 }
 
 USB_ATTACH(umodem)
Index: sys/dev/usb/usbdevs
===================================================================
RCS file: /usr/local/share/cvs/src/sys/dev/usb/usbdevs,v
retrieving revision 1.1.1.1.2.54
diff -u -r1.1.1.1.2.54 usbdevs
--- sys/dev/usb/usbdevs	7 Jun 2004 09:37:40 -0000	1.1.1.1.2.54
+++ sys/dev/usb/usbdevs	17 Jun 2004 13:38:33 -0000
@@ -96,6 +96,7 @@
 vendor CONNECTIX	0x0478	Connectix
 vendor KENSINGTON	0x047d	Kensington
 vendor LUCENT		0x047e	Lucent
+vendor KYOCERA		0x482	Kyocera Corp.
 vendor PLANTRONICS	0x047f	Plantronics
 vendor STMICRO		0x0483	STMicroelectronics
 vendor YAMAHA		0x0499	YAMAHA
@@ -1023,6 +1024,9 @@
 product LACIE CDRW		0xa602	CD R/W
 product LACIE PKTDRV            0x0211  PocketDrive
 
+/* Kyocera products */
+product KYOCERA AHK3001V	0x0203	AH-K3001V
+
 /* Lexar products */
 product LEXAR JUMPSHOT		0x0001	jumpSHOT CompactFlash Reader
 product LEXAR MCR		0xb018	Multi-Card Reader
Index: sys/dev/usb/usbdevs.h
===================================================================
RCS file: /usr/local/share/cvs/src/sys/dev/usb/usbdevs.h,v
retrieving revision 1.1.1.1.2.54
diff -u -r1.1.1.1.2.54 usbdevs.h
--- sys/dev/usb/usbdevs.h	7 Jun 2004 09:37:41 -0000	1.1.1.1.2.54
+++ sys/dev/usb/usbdevs.h	17 Jun 2004 13:39:24 -0000
@@ -103,6 +103,7 @@
 #define	USB_VENDOR_CONNECTIX	0x0478		/* Connectix */
 #define	USB_VENDOR_KENSINGTON	0x047d		/* Kensington */
 #define	USB_VENDOR_LUCENT	0x047e		/* Lucent */
+#define	USB_VENDOR_KYOCERA	0x482		/* Kyocera Corp. */
 #define	USB_VENDOR_PLANTRONICS	0x047f		/* Plantronics */
 #define	USB_VENDOR_STMICRO	0x0483		/* STMicroelectronics */
 #define	USB_VENDOR_YAMAHA	0x0499		/* YAMAHA */
@@ -1030,6 +1031,9 @@
 #define	USB_PRODUCT_LACIE_CDRW	0xa602		/* CD R/W */
 #define	USB_PRODUCT_LACIE_PKTDRV	0x0211		/* PocketDrive */
 
+/* Kyocera products */
+#define	USB_PRODUCT_KYOCERA_AHK3001V	0x0203		/* AH-K3001V */
+
 /* Lexar products */
 #define	USB_PRODUCT_LEXAR_JUMPSHOT	0x0001		/* jumpSHOT CompactFlash Reader */
 #define	USB_PRODUCT_LEXAR_MCR	0xb018		/* Multi-Card Reader */
Index: sys/dev/usb/usbdevs_data.h
===================================================================
RCS file: /usr/local/share/cvs/src/sys/dev/usb/usbdevs_data.h,v
retrieving revision 1.1.1.1.2.54
diff -u -r1.1.1.1.2.54 usbdevs_data.h
--- sys/dev/usb/usbdevs_data.h	7 Jun 2004 09:37:41 -0000	1.1.1.1.2.54
+++ sys/dev/usb/usbdevs_data.h	17 Jun 2004 13:39:41 -0000
@@ -2428,6 +2428,12 @@
 	    "PocketDrive",
 	},
 	{
+	    USB_VENDOR_KYOCERA, USB_PRODUCT_KYOCERA_AHK3001V,
+	    0,
+	    "Kyocera Corp.",
+	    "AH-K3001V",
+	},
+	{
 	    USB_VENDOR_LEXAR, USB_PRODUCT_LEXAR_JUMPSHOT,
 	    0,
 	    "Lexar Media",
@@ -5134,6 +5140,12 @@
 	    NULL,
 	},
 	{
+	    USB_VENDOR_KYOCERA, 0,
+	    USB_KNOWNDEV_NOPROD,
+	    "Kyocera Corp.",
+	    NULL,
+	},
+	{
 	    USB_VENDOR_PLANTRONICS, 0,
 	    USB_KNOWNDEV_NOPROD,
 	    "Plantronics",
>Release-Note:
>Audit-Trail:
>Unformatted: