Skip to contentSkip to conversation

Add Samsung SGH-I500/Android modem ID switch to visor driver

USB Maciej Szmigiero 3 participants 8 messages Feb 5, 2011 – Feb 7, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

[USB]Add Samsung SGH-I500/Android modem ID switch to visor driver

Samsung decided to reuse USB ID of its old CDMA phone SGH-I500 for the modem part of some of their Android phones. At least Galaxy Spica is affected.

This modem needs ACM driver and does not work with visor driver which binds the conflicting ID for SGH-I500.
Because SGH-I500 is pretty an old hardware its best to add switch to visor driver in cause somebody still wants to use that phone with Linux.

Note that this is needed only when using the Android phone as modem, not in USB storage or ADB mode.

drivers/usb/serial/visor.c +10 -0
index 15a5d89..5e56ab3 100644
@@ -52,6 +52,7 @@ static int palm_os_4_probe(struct usb_serial *serial,
 
 /* Parameters that may be passed into the module. */
 static int debug;
+static int enable_i500;
 static __u16 vendor;
 static __u16 product;
 
@@ -479,6 +480,10 @@ static int visor_probe(struct usb_serial *serial,
 
 	dbg("%s", __func__);
 
+	if ((!enable_i500) && (id->idVendor == SAMSUNG_VENDOR_ID) &&
+		(id->idProduct == SAMSUNG_SPH_I500_ID))
+		return -ENODEV;
+
 	if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
 		dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
 			serial->dev->actconfig->desc.bConfigurationValue);
@@ -718,6 +723,11 @@ MODULE_LICENSE("GPL");
 module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Debug enabled or not");
 
+module_param(enable_i500, bool, S_IRUGO);
+MODULE_PARM_DESC(enable_i500, "Enable support for Samsung SPH-I500. "
+				"Causes USBID conflict with modem in Samsung "
+				"Android phones");
+
 module_param(vendor, ushort, 0);
 MODULE_PARM_DESC(vendor, "User specified vendor ID");
 module_param(product, ushort, 0);
#1 lore raw
Quoted 5 lines · Maciej Szmigiero

[USB]Add Samsung SGH-I500/Android modem ID switch to visor driver

Samsung decided to reuse USB ID of its old CDMA phone SGH-I500 for the modem part of some of their Android phones. At least Galaxy Spica is affected.

Ick, no way, that's horrible.

Quoted 7 lines

This modem needs ACM driver and does not work with visor driver which binds the conflicting ID for SGH-I500.
Because SGH-I500 is pretty an old hardware its best to add switch to visor driver in cause somebody still wants to use that phone with Linux.

Note that this is needed only when using the Android phone as modem, not in USB storage or ADB mode.

If the phone switches to modem mode, does it show up as a ACM class device?

Quoted 27 lines
drivers/usb/serial/visor.c +5 -0
index 15a5d89..5e56ab3 100644
@@ -52,6 +52,7 @@ static int palm_os_4_probe(struct usb_serial *serial,
 
 /* Parameters that may be passed into the module. */
 static int debug;
+static int enable_i500;
 static __u16 vendor;
 static __u16 product;
 
@@ -479,6 +480,10 @@ static int visor_probe(struct usb_serial *serial,
 
 	dbg("%s", __func__);
 
+	if ((!enable_i500) && (id->idVendor == SAMSUNG_VENDOR_ID) &&
+		(id->idProduct == SAMSUNG_SPH_I500_ID))
+		return -ENODEV;
+
 	if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
 		dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
 			serial->dev->actconfig->desc.bConfigurationValue);

drivers/usb/serial/visor.c MODULE_LICENSE("GPL"); · line 730

Quoted 8 lines
drivers/usb/serial/visor.c +5 -0
@@ -718,6 +723,11 @@ MODULE_LICENSE("GPL");
 module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Debug enabled or not");
 
+module_param(enable_i500, bool, S_IRUGO);
+MODULE_PARM_DESC(enable_i500, "Enable support for Samsung SPH-I500. "
+				"Causes USBID conflict with modem in Samsung "
+				"Android phones");
+

Is there any way to dynamically detect this? We don't want it to be a module parameter, as we will never know to set it.

Surely the configuration of the device looks different somehow? If it reports itself as an ACM device, we should be able to detect that, right?

thanks,

greg k-h

#2 lore raw

W dniu 05.02.2011 20:28, Greg KH pisze:

Quoted 7 lines

Surely the configuration of the device looks different somehow? If it reports itself as an ACM device, we should be able to detect that, right?

thanks,

greg k-h

I will try to look at it, but the modem likes to reset itself (and the bus) when poked (for example when trying to read configuration strings).

Best regards,
Maciej Szmigiero

#3 lore raw
In reply to Greg KH

New version of patch which autodetects devices with ACM class. Tested on Galaxy Spica.

drivers/usb/serial/visor.c +10 -0
index 15a5d89..e1c4527 100644
@@ -27,6 +27,7 @@
 #include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
+#include <linux/usb/cdc.h>
 #include "visor.h"
 
 /*
@@ -479,6 +480,15 @@ static int visor_probe(struct usb_serial *serial,
 
 	dbg("%s", __func__);
 
+	/* some Samsung Android phones in modem mode have the same ID */
+	/* as SPH-I500, but they are ACM devices, so dont bind to them */
+	if ((id->idVendor == SAMSUNG_VENDOR_ID) &&
+		(id->idProduct == SAMSUNG_SPH_I500_ID) &&
+		(serial->dev->descriptor.bDeviceClass == USB_CLASS_COMM) &&
+		(serial->dev->descriptor.bDeviceSubClass ==
+			USB_CDC_SUBCLASS_ACM))
+		return -ENODEV;
+
 	if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
 		dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
 			serial->dev->actconfig->desc.bConfigurationValue);
#4 lore raw

Hello.

Quoted 9 lines · Maciej Szmigiero

New version of patch which autodetects devices with ACM class. Tested on Galaxy Spica.

drivers/usb/serial/visor.c +0 -0
index 15a5d89..e1c4527 100644

[...]

drivers/usb/serial/visor.c static int visor_probe(struct usb_serial *serial, · line 484

Quoted 6 lines
drivers/usb/serial/visor.c +2 -0
@@ -479,6 +480,15 @@ static int visor_probe(struct usb_serial *serial,
 
  	dbg("%s", __func__);
 
+	/* some Samsung Android phones in modem mode have the same ID */
+	/* as SPH-I500, but they are ACM devices, so dont bind to them */

The preferred style for the multi-line comments is this:

/*
* bla
* bla
*/

drivers/usb/serial/visor.c static int visor_probe(struct usb_serial *serial, · line 489

Quoted 5 lines
drivers/usb/serial/visor.c +5 -0
+	if ((id->idVendor == SAMSUNG_VENDOR_ID)&&
+		(id->idProduct == SAMSUNG_SPH_I500_ID)&&
+		(serial->dev->descriptor.bDeviceClass == USB_CLASS_COMM)&&
+		(serial->dev->descriptor.bDeviceSubClass ==
+			USB_CDC_SUBCLASS_ACM))

Parens around == not necessary...

WBR, Sergei

#5 lore raw

W dniu 06.02.2011 00:29, Sergei Shtylyov pisze:

Quoted 34 lines

Hello.

Quoted 9 lines · Maciej Szmigiero

New version of patch which autodetects devices with ACM class. Tested on Galaxy Spica.

drivers/usb/serial/visor.c +0 -0
index 15a5d89..e1c4527 100644

[...]

drivers/usb/serial/visor.c static int visor_probe(struct usb_serial *serial, · line 484

Quoted 6 lines
drivers/usb/serial/visor.c +2 -0
@@ -479,6 +480,15 @@ static int visor_probe(struct usb_serial *serial,
 
      dbg("%s", __func__);
 
+    /* some Samsung Android phones in modem mode have the same ID */
+    /* as SPH-I500, but they are ACM devices, so dont bind to them */

The preferred style for the multi-line comments is this:

/*
* bla
* bla
*/

drivers/usb/serial/visor.c static int visor_probe(struct usb_serial *serial, · line 489

Quoted 5 lines
drivers/usb/serial/visor.c +5 -0
+    if ((id->idVendor == SAMSUNG_VENDOR_ID)&&
+        (id->idProduct == SAMSUNG_SPH_I500_ID)&&
+        (serial->dev->descriptor.bDeviceClass == USB_CLASS_COMM)&&
+        (serial->dev->descriptor.bDeviceSubClass ==
+            USB_CDC_SUBCLASS_ACM))
Quoted 3 lines
   Parens around == not necessary...

WBR, Sergei

Thanks for comments, new version of this patch with style fixes follows.

Best regards,
Maciej Szmigiero

drivers/usb/serial/visor.c +12 -0
index 15a5d89..0f75948 100644
@@ -27,6 +27,7 @@
 #include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
+#include <linux/usb/cdc.h>
 #include "visor.h"
 
 /*
@@ -479,6 +480,17 @@ static int visor_probe(struct usb_serial *serial,
 
 	dbg("%s", __func__);
 
+	/*
+	 * some Samsung Android phones in modem mode have the same ID
+	 * as SPH-I500, but they are ACM devices, so dont bind to them
+	*/
+	if (id->idVendor == SAMSUNG_VENDOR_ID &&
+		id->idProduct == SAMSUNG_SPH_I500_ID &&
+		serial->dev->descriptor.bDeviceClass == USB_CLASS_COMM &&
+		serial->dev->descriptor.bDeviceSubClass ==
+			USB_CDC_SUBCLASS_ACM)
+		return -ENODEV;
+
 	if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
 		dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
 			serial->dev->actconfig->desc.bConfigurationValue);
#6 lore raw

Hello.

Quoted 45 lines · Maciej Szmigiero
Quoted 30 lines
Quoted 9 lines

New version of patch which autodetects devices with ACM class. Tested on Galaxy Spica.

drivers/usb/serial/visor.c +0 -0
index 15a5d89..e1c4527 100644

[...]

drivers/usb/serial/visor.c static int visor_probe(struct usb_serial *serial, · line 484

Quoted 6 lines
drivers/usb/serial/visor.c +2 -0
@@ -479,6 +480,15 @@ static int visor_probe(struct usb_serial *serial,
 
       dbg("%s", __func__);
 
+    /* some Samsung Android phones in modem mode have the same ID */
+    /* as SPH-I500, but they are ACM devices, so dont bind to them */

The preferred style for the multi-line comments is this:

/*
* bla
* bla
*/

drivers/usb/serial/visor.c static int visor_probe(struct usb_serial *serial, · line 489

Quoted 5 lines
drivers/usb/serial/visor.c +5 -0
+    if ((id->idVendor == SAMSUNG_VENDOR_ID)&&
+        (id->idProduct == SAMSUNG_SPH_I500_ID)&&
+        (serial->dev->descriptor.bDeviceClass == USB_CLASS_COMM)&&
+        (serial->dev->descriptor.bDeviceSubClass ==
+            USB_CDC_SUBCLASS_ACM))
Quoted 3 lines
    Parens around == not necessary...

WBR, Sergei

Thanks for comments, new version of this patch with style fixes follows.

Best regards,
Maciej Szmigiero

drivers/usb/serial/visor.c +0 -0
index 15a5d89..0f75948 100644

[...]

drivers/usb/serial/visor.c static int visor_probe(struct usb_serial *serial, · line 486

Quoted 8 lines
drivers/usb/serial/visor.c +4 -0
@@ -479,6 +480,17 @@ static int visor_probe(struct usb_serial *serial,
 
  	dbg("%s", __func__);
 
+	/*
+	 * some Samsung Android phones in modem mode have the same ID
+	 * as SPH-I500, but they are ACM devices, so dont bind to them
+	*/

Space is missing. You were close. :-)

WBR, Sergei

#7 lore raw

W dniu 07.02.2011 12:25, Sergei Shtylyov pisze:

Quoted 17 lines

Hello.

Quoted 8 lines · Maciej Szmigiero
Quoted 2 lines
Quoted 2 lines

New version of patch which autodetects devices with ACM class. Tested on Galaxy Spica.

drivers/usb/serial/visor.c +0 -0
index 15a5d89..0f75948 100644

[...]

Quoted 4 lines
drivers/usb/serial/visor.c +0 -0
@@ -479,6 +480,17 @@ static int visor_probe(struct usb_serial *serial,
 
      dbg("%s", __func__);
 
Quoted 9 lines

drivers/usb/serial/visor.c static int visor_probe(struct usb_serial *serial, · line 486

Quoted 4 lines
drivers/usb/serial/visor.c +4 -0
+    /*
+     * some Samsung Android phones in modem mode have the same ID
+     * as SPH-I500, but they are ACM devices, so dont bind to them
+    */

Space is missing. You were close. :-)

WBR, Sergei

Damn :)

drivers/usb/serial/visor.c +12 -0
index 15a5d89..1c11959 100644
@@ -27,6 +27,7 @@
 #include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
+#include <linux/usb/cdc.h>
 #include "visor.h"
 
 /*
@@ -479,6 +480,17 @@ static int visor_probe(struct usb_serial *serial,
 
 	dbg("%s", __func__);
 
+	/*
+	 * some Samsung Android phones in modem mode have the same ID
+	 * as SPH-I500, but they are ACM devices, so dont bind to them
+	 */
+	if (id->idVendor == SAMSUNG_VENDOR_ID &&
+		id->idProduct == SAMSUNG_SPH_I500_ID &&
+		serial->dev->descriptor.bDeviceClass == USB_CLASS_COMM &&
+		serial->dev->descriptor.bDeviceSubClass ==
+			USB_CDC_SUBCLASS_ACM)
+		return -ENODEV;
+
 	if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
 		dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
 			serial->dev->actconfig->desc.bConfigurationValue);