Subject: Product specific code for uplcom.c
To: Current Users <current-users@netbsd.org>
From: Keiichi SHIMA <keiichi@iijlab.net>
List: current-users
Date: 08/30/2006 11:54:52
Hello all,

I have IO-DATA's USB-Serial adapter (USB-RSAQ3) and have found it  
doesn't work with the current USB serial adapter driver (uplcom.c)

The product seems to have PL2303X chipset which is supported by  
uplcom.c, but the chipset detection code is not appropriate for the  
product.  uplcom.c checks bcdDevice value to detect if the chipset is  
PL2303 or PL2303(H)X.  If the value if 0x300, uplcom.c treats it as  
PL2303(H)X, otherwise PL2303.

The problem is, USB-RSAQ3 returns 0x0001 as bcdDevice which is not  
the default value of PL2303X (0x0300).

I wonder if it is OK to add a product specific code in uplcom.c.  The  
current detection code of uplcom.c is:

if (UGEWT(ddesc->bcdDevice == 0x0300)
	sc->sc_type = UPLCOM_TYPE_HX;
else
	sc->sc_type = UPLCOM_TYPE_0;

If we can change it to, for example,

if (UGEWT(ddesc->bcdDevice == 0x0300)
	sc->sc_type = UPLCOM_TYPE_HX;
else if ((uaa->vendor == USB_VENDOR_PROLIFIC)
	&& (uaa->product == XXX_RSAQ3))
	sc->sc_type = UPLCOM_TYPE_HX;
else
	sc->sc_type = UPLCOM_TYPE_0;

then USB-RSAQ3 is properly detected and works (I confirmed it in my  
local environment).

I know such hardcoding is bad in general, but I couldn't find any  
other generic way to insert product specific initialization code.   
Does anyone know?


I checked FreeBSD's driver (it seems it was imported from NetBSD long  
time ago), and found it doesn't autodetect the chipset, but has  
additional static information to inform the driver of the chipset.   
It seems it cannot be directly applied to the current NetBSD USB  
framework, because it requires to extend the USB device number  
structure (usb_devno structure).

---
Keiichi SHIMA
IIJ Research Laboratory <keiichi@iijlab.net>
WIDE Project <shima@wide.ad.jp>