public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* FTDI SIO patch to allow custom vendor/product IDs.
@ 2004-12-02 12:48 Rogier Wolff
  2004-12-02 13:34 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Rogier Wolff @ 2004-12-02 12:48 UTC (permalink / raw)
  To: kuba, greg, bryder, linux-kernel; +Cc: edwin

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]


To prevent XP from hijacking devices that require a different driver,
some people flash a different Vendor/Product ID into their FTDI based
device. 

Also some "new" devices may come out which are perfectly valid to be
driven by the ftdi_sio driver, but happen to have a vendor/product
id which is not (yet) included in the driver.  I've built a patch
that allows you to tell the driver "vendor=... product=...." to 
make it accept such devices.

Does this patch make sense?

I've built this patch for 2.4.28, but I'll port it for inclusion into
2.6 if people agree that this is useful.

	Roger. 

-- 
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2600998 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
Q: It doesn't work. A: Look buddy, doesn't work is an ambiguous statement. 
Does it sit on the couch all day? Is it unemployed? Please be specific! 
Define 'it' and what it isn't doing. --------- Adapted from lxrbot FAQ

[-- Attachment #2: ftdi_sio.patch --]
[-- Type: text/plain, Size: 3840 bytes --]

diff -ur hdr/linux-2.4.28-rc1/drivers/usb/serial/ftdi_sio.c linux-2.4.28-testftdi/drivers/usb/serial/ftdi_sio.c
--- hdr/linux-2.4.28-rc1/drivers/usb/serial/ftdi_sio.c	Wed Oct 27 15:45:22 2004
+++ linux-2.4.28-testftdi/drivers/usb/serial/ftdi_sio.c	Thu Dec  2 13:25:45 2004
@@ -449,6 +449,12 @@
 };
 
 
+static struct usb_device_id id_table_userdev [] = {
+	{ USB_DEVICE(-1, -1) },
+	{ }						/* Terminating entry */
+};
+
+
 static __devinitdata struct usb_device_id id_table_combined [] = {
 	{ USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
@@ -548,6 +554,10 @@
 #define BUFSZ 512
 #define PKTSZ 64
 
+static int vendor =-1, product = -1, baud_base = 48000000/2; 
+    /* User specified VID and Product ID and baud base.  */ 
+
+
 struct ftdi_private {
 	ftdi_chip_type_t chip_type;
 				/* type of the device, either SIO or FT8U232AM */
@@ -584,6 +594,7 @@
 static int  ftdi_FT232BM_startup	(struct usb_serial *serial);
 static int  ftdi_USB_UIRT_startup	(struct usb_serial *serial);
 static int  ftdi_HE_TIRA1_startup	(struct usb_serial *serial);
+static int  ftdi_userdev_startup	(struct usb_serial *serial);
 static void ftdi_shutdown		(struct usb_serial *serial);
 static int  ftdi_open			(struct usb_serial_port *port, struct file *filp);
 static void ftdi_close			(struct usb_serial_port *port, struct file *filp);
@@ -727,6 +738,28 @@
 
 
 
+
+static struct usb_serial_device_type ftdi_userdev_device = {
+	.owner =		THIS_MODULE,
+	.name =			"FTDI SIO compatible",
+	.id_table =		id_table_userdev,
+	.num_interrupt_in =	0,
+	.num_bulk_in =		1,
+	.num_bulk_out =		1,
+	.num_ports =		1,
+	.open =			ftdi_open,
+	.close =		ftdi_close,
+	.write =		ftdi_write,
+	.write_room =		ftdi_write_room,
+	.read_bulk_callback =	ftdi_read_bulk_callback,
+	.write_bulk_callback =	ftdi_write_bulk_callback,
+	.ioctl =		ftdi_ioctl,
+	.set_termios =		ftdi_set_termios,
+	.break_ctl =		ftdi_break_ctl,
+	.startup =		ftdi_userdev_startup,
+	.shutdown =		ftdi_shutdown,
+};
+
 #define WDR_TIMEOUT (HZ * 5 ) /* default urb timeout */
 
 /* High and low are for DTR, RTS etc etc */
@@ -1216,6 +1249,30 @@
  */
 
 
+/* Startup for the 8U232AM chip */
+static int ftdi_userdev_startup (struct usb_serial *serial)
+{
+	struct ftdi_private *priv;
+
+	priv = serial->port->private = kmalloc(sizeof(struct ftdi_private), GFP_KERNEL);
+	if (!priv){
+		err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private));
+		return -ENOMEM;
+	}
+
+	priv->chip_type = FT8U232AM; /* XXX: Hmm. Keep this.... -- REW */
+	priv->baud_base = baud_base; 
+	priv->custom_divisor = 0;
+	priv->write_offset = 0;
+        init_waitqueue_head(&priv->delta_msr_wait);
+	/* This will push the characters through immediately rather
+	   than queue a task to deliver them */
+	priv->flags = ASYNC_LOW_LATENCY;
+	
+	return (0);
+}
+
+
 static void ftdi_shutdown (struct usb_serial *serial)
 { /* ftdi_shutdown */
 	
@@ -2134,6 +2191,14 @@
 	usb_serial_register (&ftdi_USB_UIRT_device);
 	usb_serial_register (&ftdi_HE_TIRA1_device);
 
+	if (vendor != -1) {
+		/* User specified USB vendor and device id */
+		/* The macro initialized "matchvendor" as the matching flags */
+		id_table_userdev[0].idVendor = vendor; 
+		id_table_userdev[0].idProduct = product;
+		usb_serial_register (&ftdi_userdev_device);
+	}
+	
 
 	info(DRIVER_VERSION ":" DRIVER_DESC);
 	return 0;
@@ -2164,3 +2229,8 @@
 MODULE_PARM(debug, "i");
 MODULE_PARM_DESC(debug, "Debug enabled or not");
 
+MODULE_PARM(vendor, "i");
+MODULE_PARM_DESC(vendor, "User specified USB idVendor");
+
+MODULE_PARM(product, "i");
+MODULE_PARM_DESC(product, "User specified USB idProduct");
Only in linux-2.4.28-testftdi/drivers/usb/serial: ftdi_sio.c.orig
Only in linux-2.4.28-testftdi/drivers/usb/serial: ftdi_sio.c.rej
Only in linux-2.4.28-testftdi/drivers/usb/serial: ftdi_sio.c~

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FTDI SIO patch to allow custom vendor/product IDs.
  2004-12-02 12:48 FTDI SIO patch to allow custom vendor/product IDs Rogier Wolff
@ 2004-12-02 13:34 ` Christoph Hellwig
  2004-12-02 18:00   ` Greg KH
  2004-12-02 13:57 ` Jan Dittmer
  2004-12-02 18:00 ` Greg KH
  2 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2004-12-02 13:34 UTC (permalink / raw)
  To: Rogier Wolff; +Cc: kuba, greg, bryder, linux-kernel, edwin

On Thu, Dec 02, 2004 at 01:48:31PM +0100, Rogier Wolff wrote:
> 
> To prevent XP from hijacking devices that require a different driver,
> some people flash a different Vendor/Product ID into their FTDI based
> device. 
> 
> Also some "new" devices may come out which are perfectly valid to be
> driven by the ftdi_sio driver, but happen to have a vendor/product
> id which is not (yet) included in the driver.  I've built a patch
> that allows you to tell the driver "vendor=... product=...." to 
> make it accept such devices.
> 
> Does this patch make sense?

I think it would be much better to have something like the dynamic PCI IDs
support to USB aswell.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FTDI SIO patch to allow custom vendor/product IDs.
  2004-12-02 12:48 FTDI SIO patch to allow custom vendor/product IDs Rogier Wolff
  2004-12-02 13:34 ` Christoph Hellwig
@ 2004-12-02 13:57 ` Jan Dittmer
  2004-12-02 14:02   ` Jan Dittmer
  2004-12-02 18:00 ` Greg KH
  2 siblings, 1 reply; 6+ messages in thread
From: Jan Dittmer @ 2004-12-02 13:57 UTC (permalink / raw)
  To: Rogier Wolff; +Cc: kuba, greg, bryder, linux-kernel, edwin

Rogier Wolff wrote:
> +MODULE_PARM(vendor, "i");
> +MODULE_PARM_DESC(vendor, "User specified USB idVendor");
> +
> +MODULE_PARM(product, "i");
> +MODULE_PARM_DESC(product, "User specified USB idProduct");

Use module_param instead.

Jan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FTDI SIO patch to allow custom vendor/product IDs.
  2004-12-02 13:57 ` Jan Dittmer
@ 2004-12-02 14:02   ` Jan Dittmer
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Dittmer @ 2004-12-02 14:02 UTC (permalink / raw)
  To: Jan Dittmer; +Cc: Rogier Wolff, kuba, greg, bryder, linux-kernel, edwin

Jan Dittmer wrote:
> Rogier Wolff wrote:
> 
>>+MODULE_PARM(vendor, "i");
>>+MODULE_PARM_DESC(vendor, "User specified USB idVendor");
>>+
>>+MODULE_PARM(product, "i");
>>+MODULE_PARM_DESC(product, "User specified USB idProduct");
> 
> 
> Use module_param instead.

Sorry, I didn't see that it's an 2.4 patch ;-)

Jan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FTDI SIO patch to allow custom vendor/product IDs.
  2004-12-02 13:34 ` Christoph Hellwig
@ 2004-12-02 18:00   ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2004-12-02 18:00 UTC (permalink / raw)
  To: Christoph Hellwig, Rogier Wolff, kuba, bryder, linux-kernel,
	edwin

On Thu, Dec 02, 2004 at 01:34:37PM +0000, Christoph Hellwig wrote:
> On Thu, Dec 02, 2004 at 01:48:31PM +0100, Rogier Wolff wrote:
> > 
> > To prevent XP from hijacking devices that require a different driver,
> > some people flash a different Vendor/Product ID into their FTDI based
> > device. 
> > 
> > Also some "new" devices may come out which are perfectly valid to be
> > driven by the ftdi_sio driver, but happen to have a vendor/product
> > id which is not (yet) included in the driver.  I've built a patch
> > that allows you to tell the driver "vendor=... product=...." to 
> > make it accept such devices.
> > 
> > Does this patch make sense?
> 
> I think it would be much better to have something like the dynamic PCI IDs
> support to USB aswell.

I agree, and this is what I have stated a number of times already.  But
it's going to take some driver core rework to get correct, and I'm
finding less time than I expected in order to do that work...

Hopefully soon...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: FTDI SIO patch to allow custom vendor/product IDs.
  2004-12-02 12:48 FTDI SIO patch to allow custom vendor/product IDs Rogier Wolff
  2004-12-02 13:34 ` Christoph Hellwig
  2004-12-02 13:57 ` Jan Dittmer
@ 2004-12-02 18:00 ` Greg KH
  2 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2004-12-02 18:00 UTC (permalink / raw)
  To: Rogier Wolff; +Cc: kuba, bryder, linux-kernel, edwin

On Thu, Dec 02, 2004 at 01:48:31PM +0100, Rogier Wolff wrote:
> 
> To prevent XP from hijacking devices that require a different driver,
> some people flash a different Vendor/Product ID into their FTDI based
> device. 
> 
> Also some "new" devices may come out which are perfectly valid to be
> driven by the ftdi_sio driver, but happen to have a vendor/product
> id which is not (yet) included in the driver.  I've built a patch
> that allows you to tell the driver "vendor=... product=...." to 
> make it accept such devices.
> 
> Does this patch make sense?
> 
> I've built this patch for 2.4.28, but I'll port it for inclusion into
> 2.6 if people agree that this is useful.

Looks fine to me for 2.4, care to make a 2.6 patch too?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-12-02 18:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-02 12:48 FTDI SIO patch to allow custom vendor/product IDs Rogier Wolff
2004-12-02 13:34 ` Christoph Hellwig
2004-12-02 18:00   ` Greg KH
2004-12-02 13:57 ` Jan Dittmer
2004-12-02 14:02   ` Jan Dittmer
2004-12-02 18:00 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox