From toga@puyo.org  Mon May 17 15:38:02 2004
Return-Path: <toga@puyo.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7EBC316A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 May 2004 15:38:02 -0700 (PDT)
Received: from akane.vegalta.org (f1a01-0096.din.or.jp [211.132.31.96])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D0DC243D39
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 May 2004 15:38:00 -0700 (PDT)
	(envelope-from toga@puyo.org)
Received: from localhost (localhost [IPv6:::1])
	by akane.vegalta.org (8.12.8p2/8.12.8) with SMTP id i4HMbw3v025399
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 18 May 2004 07:37:58 +0900 (JST)
	(envelope-from toga@puyo.org)
Message-Id: <200405172237.i4HMbw3v025399@akane.vegalta.org>
Date: Tue, 18 May 2004 07:37:55 +0900
From: TOGAWA Satoshi <toga@puyo.org>
To: FreeBSD-gnats-submit@freebsd.org
Subject: NEW USB device: AH-K3001V

>Number:         66779
>Category:       kern
>Synopsis:       NEW USB device: AH-K3001V
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sanpei
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 17 15:40:08 PDT 2004
>Closed-Date:    Mon May 31 14:46:11 PDT 2004
>Last-Modified:  Mon Jul 05 16:47:20 GMT 2004
>Originator:     Togawa Satoshi
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
>Environment:
System: FreeBSD nayuki.vegalta.org 5.2-CURRENT FreeBSD 5.2-CURRENT #23: Sun May 16 22:24:46 JST 2004 togawa@nayuki.vegalta.org:/usr/obj/usr/src/sys/NAYUKI i386


>Description:
	New USB device, Kyocera AH-K3001V (cellular phone in Japan) has
	released.

	Its bInterfaceSubClass is 0x88 (not UISUBCLASS_ABSTRACT_CONTROL_MODEL).
	But when ignoring bInterfaceSubClass, I can use this with umodem.ko.

>How-To-Repeat:
	1. kldload umodem.ko.
	2. connect AH-K3001V to USB port.

>Fix:
	Apply this patch. And when device is AH-K3001V, USB_MATCH in
	umodem.c returns UMATCH_VENDOR_PRODUCT.

--- usbdevs.orig	Thu May  6 04:39:24 2004
+++ usbdevs	Sat May 15 23:26:56 2004
@@ -112,6 +112,7 @@
 vendor CONNECTIX	0x0478	Connectix
 vendor KENSINGTON	0x047d	Kensington
 vendor LUCENT		0x047e	Lucent
+vendor KYOCERA		0x0482	Kyocera
 vendor STMICRO		0x0483	STMicroelectronics
 vendor YAMAHA		0x0499	YAMAHA
 vendor COMPAQ		0x049f	Compaq Computers
@@ -856,6 +857,9 @@
 product KYE NETSCROLL		0x0003	Genius NetScroll mouse
 product KYE FLIGHT2000		0x1004	Flight 2000 joystick
 product KYE VIVIDPRO		0x2001	ColorPage Vivid-Pro scanner
+
+/* Kyocera products */
+product KYOCERA MODEM		0x0203	Modem
 
 /* LaCie products */
 product LACIE HD		0xa601	Hard Disk
--- umodem.c.orig	Sat May 15 23:30:21 2004
+++ umodem.c	Sun May 16 00:16:41 2004
@@ -115,6 +115,16 @@
 #endif
 #define DPRINTF(x) DPRINTFN(0, x)
 
+Static const struct modem_quirk {
+	u_int16_t	vendor;
+	u_int16_t	product;
+	u_int8_t	interface;
+} modem_quirks[] = {
+	/* Kyocera AH-K3001V*/
+	{ USB_VENDOR_KYOCERA, USB_PRODUCT_KYOCERA_MODEM, 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
@@ -213,25 +223,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 ; modem_quirks[i].vendor != 0 ; i++) {
+		if (modem_quirks[i].vendor == UGETW(dd->idVendor) &&
+		    modem_quirks[i].product == UGETW(dd->idProduct) &&
+		    modem_quirks[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)
--- usbdevs.h.orig	Sun May 16 01:35:41 2004
+++ usbdevs.h	Sun May 16 01:36:35 2004
@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/dev/usb/usbdevs.h,v 1.184 2004/05/05 19:40:02 joe Exp $ */
+/* $FreeBSD$ */
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -119,6 +119,7 @@
 #define	USB_VENDOR_CONNECTIX	0x0478		/* Connectix */
 #define	USB_VENDOR_KENSINGTON	0x047d		/* Kensington */
 #define	USB_VENDOR_LUCENT	0x047e		/* Lucent */
+#define	USB_VENDOR_KYOCERA	0x0482		/* Kyocera */
 #define	USB_VENDOR_STMICRO	0x0483		/* STMicroelectronics */
 #define	USB_VENDOR_YAMAHA	0x0499		/* YAMAHA */
 #define	USB_VENDOR_COMPAQ	0x049f		/* Compaq Computers */
@@ -863,6 +864,9 @@
 #define	USB_PRODUCT_KYE_NETSCROLL	0x0003		/* Genius NetScroll mouse */
 #define	USB_PRODUCT_KYE_FLIGHT2000	0x1004		/* Flight 2000 joystick */
 #define	USB_PRODUCT_KYE_VIVIDPRO	0x2001		/* ColorPage Vivid-Pro scanner */
+
+/* Kyocera products */
+#define	USB_PRODUCT_KYOCERA_MODEM	0x0203		/* Modem */
 
 /* LaCie products */
 #define	USB_PRODUCT_LACIE_HD	0xa601		/* Hard Disk */
--- usbdevs_data.h.orig	Sun May 16 01:35:49 2004
+++ usbdevs_data.h	Sun May 16 01:36:35 2004
@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/dev/usb/usbdevs_data.h,v 1.184 2004/05/05 19:40:03 joe Exp $ */
+/* $FreeBSD$ */
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
@@ -1744,6 +1744,12 @@
 	    "ColorPage Vivid-Pro scanner",
 	},
 	{
+	    USB_VENDOR_KYOCERA, USB_PRODUCT_KYOCERA_MODEM,
+	    0,
+	    "Kyocera",
+	    "Modem",
+	},
+	{
 	    USB_VENDOR_LACIE, USB_PRODUCT_LACIE_HD,
 	    0,
 	    "LaCie",
@@ -3679,6 +3685,12 @@
 	    USB_VENDOR_LUCENT, 0,
 	    USB_KNOWNDEV_NOPROD,
 	    "Lucent",
+	    NULL,
+	},
+	{
+	    USB_VENDOR_KYOCERA, 0,
+	    USB_KNOWNDEV_NOPROD,
+	    "Kyocera",
 	    NULL,
 	},
 	{


-- 
toga@puyo.org
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sanpei 
Responsible-Changed-By: nork 
Responsible-Changed-When: Mon May 17 18:17:30 PDT 2004 
Responsible-Changed-Why:  
Over to USB spcialist. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=66779 

From: MIHIRA Sanpei Yoshiro <sanpei@sanpei.org>
To: freebsd-gnats-submit@FreeBSD.org, toga@puyo.org
Cc:  
Subject: Re: kern/66779: NEW USB device: AH-K3001V
Date: Tue, 18 May 2004 23:55:55 +0900 (JST)

 Hi.
 
   I change your patch:
     - change vendor name and product name
     - use umodem_product not modem_quirks, remove interface
       (why did you add interface?)
 
 comments are welcome.
 
 Cheers
 ---
 MIHIRA, Sanpei Yoshiro
 Tokyo, Japan.
 
 
 Index: usbdevs
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/usb/usbdevs,v
 retrieving revision 1.177
 diff -u -r1.177 usbdevs
 --- usbdevs	5 May 2004 19:39:24 -0000	1.177
 +++ usbdevs	18 May 2004 14:49:25 -0000
 @@ -112,6 +112,7 @@
  vendor CONNECTIX	0x0478	Connectix
  vendor KENSINGTON	0x047d	Kensington
  vendor LUCENT		0x047e	Lucent
 +vendor KYOCERA		0x0482	Kyocera Corp.
  vendor STMICRO		0x0483	STMicroelectronics
  vendor YAMAHA		0x0499	YAMAHA
  vendor COMPAQ		0x049f	Compaq Computers
 @@ -856,6 +857,9 @@
  product KYE NETSCROLL		0x0003	Genius NetScroll mouse
  product KYE FLIGHT2000		0x1004	Flight 2000 joystick
  product KYE VIVIDPRO		0x2001	ColorPage Vivid-Pro scanner
 +
 +/* Kyocera products */
 +product KYOCERA AHK3001V	0x0203	Kyocera Corporation AH-K3001V
  
  /* LaCie products */
  product LACIE HD		0xa601	Hard Disk
 Index: umodem.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/usb/umodem.c,v
 retrieving revision 1.49
 diff -u -r1.49 umodem.c
 --- umodem.c	14 May 2004 15:16:09 -0000	1.49
 +++ umodem.c	18 May 2004 14:49:25 -0000
 @@ -115,6 +115,15 @@
  #endif
  #define DPRINTF(x) DPRINTFN(0, x)
  
 +static const struct umodem_product {
 +	u_int16_t	vendor;
 +	u_int16_t	product;
 +} umodem_products[] = {
 +	/* Kyocera AH-K3001V*/
 +	{ USB_VENDOR_KYOCERA, USB_PRODUCT_KYOCERA_AHK3001V },
 +	{ 0, 0 },
 +};
 +
  /*
   * These are the maximum number of bytes transferred per frame.
   * If some really high speed devices should use this driver they
 @@ -213,25 +222,42 @@
  {
  	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)) {
 +			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)
 
State-Changed-From-To: open->patched 
State-Changed-By: sanpei 
State-Changed-When: Thu May 20 18:38:35 PDT 2004 
State-Changed-Why:  
Commited umodem.c in 1.50, Thanks 

http://www.freebsd.org/cgi/query-pr.cgi?pr=66779 
State-Changed-From-To: patched->closed 
State-Changed-By: sanpei 
State-Changed-When: Mon May 31 14:45:54 PDT 2004 
State-Changed-Why:  
Commited to 4-stable, Thanks 

http://www.freebsd.org/cgi/query-pr.cgi?pr=66779 
>Unformatted:
