From edwin@mavetju.org  Sun Dec 16 05:27:34 2007
Return-Path: <edwin@mavetju.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B305B16A607
	for <freebsd-gnats-submit@freebsd.org>; Sun, 16 Dec 2007 05:27:34 +0000 (UTC)
	(envelope-from edwin@mavetju.org)
Received: from mail5out.barnet.com.au (mail5.barnet.com.au [202.83.178.78])
	by mx1.freebsd.org (Postfix) with ESMTP id 55B5813C44B
	for <freebsd-gnats-submit@freebsd.org>; Sun, 16 Dec 2007 05:27:34 +0000 (UTC)
	(envelope-from edwin@mavetju.org)
Received: by mail5out.barnet.com.au (Postfix, from userid 1001)
	id EBF4D22189E1; Sun, 16 Dec 2007 16:27:32 +1100 (EST)
Received: from mail5auth.barnet.com.au (mail5.barnet.com.au [202.83.178.78])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail5auth.barnet.com.au", Issuer "*.barnet.com.au" (verified OK))
	by mail5.barnet.com.au (Postfix) with ESMTP id B31F721B17A8
	for <freebsd-gnats-submit@freebsd.org>; Sun, 16 Dec 2007 16:27:32 +1100 (EST)
Received: from k7.mavetju (k7.mavetju.org [10.251.1.18])
	by mail5auth.barnet.com.au (Postfix) with ESMTP id 5697D2218803
	for <freebsd-gnats-submit@freebsd.org>; Sun, 16 Dec 2007 16:27:32 +1100 (EST)
Received: by k7.mavetju (Postfix, from userid 1001)
	id 06C7612C; Sun, 16 Dec 2007 16:27:32 +1100 (EST)
Message-Id: <20071216052731.GA68199@k7.mavetju>
Date: Sun, 16 Dec 2007 16:27:31 +1100
From: Edwin Groothuis <edwin@mavetju.org>
To: FreeBSD Gnats Submit <freebsd-gnats-submit@freebsd.org>
In-Reply-To: <20071215225831.GO40967@k7.mavetju>
Subject: Re; kern/118686: [patch] teach usbdevs / ubsa(4) about Huawei E220 G3
References: <20071215125514.GA33989@k7.mavetju> <200712151408.00440.hselasky@c2i.net> <20071215225831.GO40967@k7.mavetju>

>Number:         118740
>Category:       kern
>Synopsis:       Re: kern/118686: [patch] teach usbdevs / ubsa(4) about Huawei E220 G3
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 16 05:30:00 UTC 2007
>Closed-Date:    Sun Dec 16 05:36:38 UTC 2007
>Last-Modified:  Sun Dec 16 05:36:38 UTC 2007
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 This one does do the full trick:
 - It adds a function usbd_set_feature, which does do the trick to
   put the right feature set in action.
 - It adds a quirk called UQ_FEATURE2.
 - It adds the implementation of the quirk in usbd_probe_and_attach
   when the device isn't found at the end of the function.
 
 diff -ur usb-old/ubsa.c usb/ubsa.c
 --- usb-old/ubsa.c	Sun Jun 17 19:38:26 2007
 +++ usb/ubsa.c	Sun Dec 16 16:00:51 2007
 @@ -232,6 +232,8 @@
  	{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GQUAD },
  	/* Huawei Mobile */
  	{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE },
 +	/* Huawei E220 G3 Modem */
 +	{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220 },
  	{ 0, 0 }
  };
  
 diff -ur usb-old/usb_quirks.c usb/usb_quirks.c
 --- usb-old/usb_quirks.c	Sun Apr 29 06:31:30 2007
 +++ usb/usb_quirks.c	Sun Dec 16 16:02:49 2007
 @@ -131,6 +131,8 @@
   /* Devices which should be ignored by both ukbd and uhid */
   { USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_WISPY,
  	ANY, { UQ_KBD_IGNORE }},
 + { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220,
 +	ANY, { UQ_FEATURE2 }},
   { 0, 0, 0, { 0 } }
  };
  
 diff -ur usb-old/usb_quirks.h usb/usb_quirks.h
 --- usb-old/usb_quirks.h	Wed Dec 13 02:44:13 2006
 +++ usb/usb_quirks.h	Sun Dec 16 16:03:03 2007
 @@ -54,6 +54,7 @@
  #define UQ_AU_INP_ASYNC	0x0800	/* input is async despite claim of adaptive */
  #define UQ_ASSUME_CM_OVER_DATA 0x1000 /* modem device breaks on cm over data */
  #define UQ_BROKEN_BIDIR	0x2000	/* printer has broken bidir mode */
 +#define UQ_FEATURE2	0x4000	/* requires the enabling of feature 2 */
  #define UQ_HID_IGNORE	0x8000	/* device should be ignored by hid class */
  #define UQ_KBD_IGNORE  0x18000	/* device should be ignored by both kbd and hid class */
  					
 diff -ur usb-old/usb_subr.c usb/usb_subr.c
 --- usb-old/usb_subr.c	Wed Mar  1 12:59:05 2006
 +++ usb/usb_subr.c	Sun Dec 16 16:10:39 2007
 @@ -538,6 +538,19 @@
  }
  
  Static usbd_status
 +usbd_set_feature(usbd_device_handle dev, int feature)
 +{
 +	usb_device_request_t req;
 +
 +	req.bmRequestType = UT_WRITE;
 +	req.bRequest = UR_SET_FEATURE;
 +	USETW(req.wValue, 1);
 +	USETW(req.wIndex, feature);
 +	USETW(req.wLength, 0);
 +	return (usbd_do_request(dev, &req, 0));
 +}
 +
 +Static usbd_status
  usbd_set_config(usbd_device_handle dev, int conf)
  {
  	usb_device_request_t req;
 @@ -983,6 +996,12 @@
  	 * fully operational and not harming anyone.
  	 */
  	DPRINTF(("usbd_probe_and_attach: generic attach failed\n"));
 +
 +	if (dev->quirks->uq_flags & UQ_FEATURE2) {
 +		printf("%s: Enabling feature 2\n", USBDEVPTRNAME(parent));
 +		usbd_set_feature(dev, 2);
 +	}
 +
   	return (USBD_NORMAL_COMPLETION);
  }
  
 diff -ur usb-old/usbdevs usb/usbdevs
 --- usb-old/usbdevs	Sun Nov  4 14:28:31 2007
 +++ usb/usbdevs	Sun Dec 16 15:32:41 2007
 @@ -1044,6 +1044,7 @@
  
  /* HUAWEI products */
  product HUAWEI MOBILE		0x1001	Huawei Mobile
 +product HUAWEI E220		0x1003	Huawei E220 HSDPA USB Modem
  
  /* IBM Corporation */
  product IBM USBCDROMDRIVE	0x4427	USB CD-ROM Drive
 
 Edwin
 
 -- 
 Edwin Groothuis      |            Personal website: http://www.mavetju.org
 edwin@mavetju.org    |              Weblog: http://www.mavetju.org/weblog/
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Sun Dec 16 05:35:53 UTC 2007 
State-Changed-Why:  
Misfiled followup to kern/118686; content migrated. 


Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Dec 16 05:35:53 UTC 2007 
Responsible-Changed-Why:  

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