Skip to contentSkip to conversation

Support faulty USB IDs on DIBUSB_MC

PATCH In review matthieu castet 4 participants 16 messages Jun 7, 2008 – May 20, 2009 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Support faulty USB IDs on DIBUSB_MC

Hi,

I got a LITE-ON USB2.0 DVB-T Tuner that loose it's cold state vid/pid and got FX2 dev kit one (0x04b4, 0x8613).

This patch introduce an option similar to the DVB_USB_DIBUSB_MB_FAULTY :
it add the FX2 dev kit ids to the DIBUSB_MC driver if DVB_USB_DIBUSB_MC_FAULTY is selected.

drivers/media/dvb/dvb-usb/Kconfig +6 -0
index f00a0eb..a656b9b 100644
@@ -68,6 +68,12 @@ config DVB_USB_DIBUSB_MC
 	  Say Y if you own such a device and want to use it. You should build it as
 	  a module.
 
+config DVB_USB_DIBUSB_MC_FAULTY
+	bool "Support faulty USB IDs"
+	depends on DVB_USB_DIBUSB_MC
+	help
+	  Support for faulty USB IDs due to an invalid EEPROM on some LITE-ON devices.
+
 config DVB_USB_DIB0700
 	tristate "DiBcom DiB0700 USB DVB devices (see help for supported devices)"
 	depends on DVB_USB
drivers/media/dvb/dvb-usb/dibusb-mc.c +22 -0
index 059cec9..ab5766a 100644
@@ -42,6 +42,17 @@ static struct usb_device_id dibusb_dib3000mc_table [] = {
 /* 11 */	{ USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,	USB_PID_ARTEC_T14_WARM) },
 /* 12 */	{ USB_DEVICE(USB_VID_LEADTEK,		USB_PID_WINFAST_DTV_DONGLE_COLD) },
 /* 13 */	{ USB_DEVICE(USB_VID_LEADTEK,		USB_PID_WINFAST_DTV_DONGLE_WARM) },
+/*
+ * XXX: Some LITE-ON devices seem to loose their id after some time. Bad EEPROM ???.
+ *      We don't catch these faulty IDs (namely 'Cypress FX2 USB controller') that
+ *      have been left on the device. If you don't have such a device but an LITE-ON
+ *      device that's supposed to work with this driver but is not detected by it,
+ *      free to enable CONFIG_DVB_USB_DIBUSB_MC_FAULTY via your kernel config.
+ */
+
+#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
+/* 14 */	{ USB_DEVICE(USB_VID_CYPRESS,		USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
+#endif
 			{ }		/* Terminating entry */
 };
 MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table);
@@ -88,7 +99,11 @@ static struct dvb_usb_device_properties dibusb_mc_properties = {
 
 	.generic_bulk_ctrl_endpoint = 0x01,
 
+#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
+	.num_device_descs = 8,
+#else
 	.num_device_descs = 7,
+#endif
 	.devices = {
 		{   "DiBcom USB2.0 DVB-T reference design (MOD3000P)",
 			{ &dibusb_dib3000mc_table[0], NULL },
@@ -119,6 +134,13 @@ static struct dvb_usb_device_properties dibusb_mc_properties = {
 			{ &dibusb_dib3000mc_table[12], NULL },
 			{ &dibusb_dib3000mc_table[13], NULL },
 		},
+#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
+		{   "LITE-ON USB2.0 DVB-T Tuner (faulty USB IDs)",
+		    /* Also rebranded as Intuix S800, Toshiba */
+			{ &dibusb_dib3000mc_table[14], NULL },
+			{ NULL },
+		},
+#endif
 		{ NULL },
 	}
 };

_______________________________________________
linux-dvb mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

#1 lore raw
Quoted 9 lines · matthieu castet

Hi,

I got a LITE-ON USB2.0 DVB-T Tuner that loose it's cold state vid/pid and got FX2 dev kit one (0x04b4, 0x8613).

This patch introduce an option similar to the DVB_USB_DIBUSB_MB_FAULTY :
it add the FX2 dev kit ids to the DIBUSB_MC driver if DVB_USB_DIBUSB_MC_FAULTY is selected.

Ping

drivers/media/dvb/dvb-usb/Kconfig +6 -0
index f00a0eb..a656b9b 100644
@@ -68,6 +68,12 @@ config DVB_USB_DIBUSB_MC
 	  Say Y if you own such a device and want to use it. You should build it as
 	  a module.
 
+config DVB_USB_DIBUSB_MC_FAULTY
+	bool "Support faulty USB IDs"
+	depends on DVB_USB_DIBUSB_MC
+	help
+	  Support for faulty USB IDs due to an invalid EEPROM on some LITE-ON devices.
+
 config DVB_USB_DIB0700
 	tristate "DiBcom DiB0700 USB DVB devices (see help for supported devices)"
 	depends on DVB_USB
drivers/media/dvb/dvb-usb/dibusb-mc.c +22 -0
index 059cec9..ab5766a 100644
@@ -42,6 +42,17 @@ static struct usb_device_id dibusb_dib3000mc_table [] = {
 /* 11 */	{ USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,	USB_PID_ARTEC_T14_WARM) },
 /* 12 */	{ USB_DEVICE(USB_VID_LEADTEK,		USB_PID_WINFAST_DTV_DONGLE_COLD) },
 /* 13 */	{ USB_DEVICE(USB_VID_LEADTEK,		USB_PID_WINFAST_DTV_DONGLE_WARM) },
+/*
+ * XXX: Some LITE-ON devices seem to loose their id after some time. Bad EEPROM ???.
+ *      We don't catch these faulty IDs (namely 'Cypress FX2 USB controller') that
+ *      have been left on the device. If you don't have such a device but an LITE-ON
+ *      device that's supposed to work with this driver but is not detected by it,
+ *      free to enable CONFIG_DVB_USB_DIBUSB_MC_FAULTY via your kernel config.
+ */
+
+#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
+/* 14 */	{ USB_DEVICE(USB_VID_CYPRESS,		USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
+#endif
 			{ }		/* Terminating entry */
 };
 MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table);
@@ -88,7 +99,11 @@ static struct dvb_usb_device_properties dibusb_mc_properties = {
 
 	.generic_bulk_ctrl_endpoint = 0x01,
 
+#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
+	.num_device_descs = 8,
+#else
 	.num_device_descs = 7,
+#endif
 	.devices = {
 		{   "DiBcom USB2.0 DVB-T reference design (MOD3000P)",
 			{ &dibusb_dib3000mc_table[0], NULL },
@@ -119,6 +134,13 @@ static struct dvb_usb_device_properties dibusb_mc_properties = {
 			{ &dibusb_dib3000mc_table[12], NULL },
 			{ &dibusb_dib3000mc_table[13], NULL },
 		},
+#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
+		{   "LITE-ON USB2.0 DVB-T Tuner (faulty USB IDs)",
+		    /* Also rebranded as Intuix S800, Toshiba */
+			{ &dibusb_dib3000mc_table[14], NULL },
+			{ NULL },
+		},
+#endif
 		{ NULL },
 	}
 };
#2 lore raw
Quoted 39 lines · On Mon, 19 Jan 2009 21:38:22 +0100 matthieu castet <[email protected]>…
Quoted 11 lines · matthieu castet

Hi,

I got a LITE-ON USB2.0 DVB-T Tuner that loose it's cold state vid/pid and got FX2 dev kit one (0x04b4, 0x8613).

This patch introduce an option similar to the DVB_USB_DIBUSB_MB_FAULTY :
it add the FX2 dev kit ids to the DIBUSB_MC driver if DVB_USB_DIBUSB_MC_FAULTY is selected.

drivers/media/dvb/dvb-usb/Kconfig +6 -0
index f00a0eb..a656b9b 100644
@@ -68,6 +68,12 @@ config DVB_USB_DIBUSB_MC
 	  Say Y if you own such a device and want to use it. You should build it as
 	  a module.
 
+config DVB_USB_DIBUSB_MC_FAULTY
+	bool "Support faulty USB IDs"
+	depends on DVB_USB_DIBUSB_MC
+	help
+	  Support for faulty USB IDs due to an invalid EEPROM on some LITE-ON devices.
+
 config DVB_USB_DIB0700
 	tristate "DiBcom DiB0700 USB DVB devices (see help for supported devices)"
 	depends on DVB_USB
drivers/media/dvb/dvb-usb/dibusb-mc.c +1 -0
index 059cec9..ab5766a 100644
@@ -42,6 +42,17 @@ static struct usb_device_id dibusb_dib3000mc_table [] = {
 /* 11 */	{ USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,	USB_PID_ARTEC_T14_WARM) },
 /* 12 */	{ USB_DEVICE(USB_VID_LEADTEK,		USB_PID_WINFAST_DTV_DONGLE_COLD) },
 /* 13 */	{ USB_DEVICE(USB_VID_LEADTEK,		USB_PID_WINFAST_DTV_DONGLE_WARM) },
+/*

drivers/media/dvb/dvb-usb/dibusb-mc.c static struct usb_device_id dibusb_dib3000mc_table [] = { · line 55

Quoted 10 lines
drivers/media/dvb/dvb-usb/dibusb-mc.c +10 -0
+ * XXX: Some LITE-ON devices seem to loose their id after some time. Bad EEPROM ???.
+ *      We don't catch these faulty IDs (namely 'Cypress FX2 USB controller') that
+ *      have been left on the device. If you don't have such a device but an LITE-ON
+ *      device that's supposed to work with this driver but is not detected by it,
+ *      free to enable CONFIG_DVB_USB_DIBUSB_MC_FAULTY via your kernel config.
+ */
+
+#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
+/* 14 */	{ USB_DEVICE(USB_VID_CYPRESS,		USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
+#endif

It doesn't sound a very good approach the need of recompiling the driver to allow it to work with a broken card. The better would be to have some modprobe option to force it to accept a certain USB ID as a valid ID for the card.

drivers/media/dvb/dvb-usb/dibusb-mc.c static struct dvb_usb_device_properties dibusb_mc_properties = { · line 106

Quoted 12 lines
drivers/media/dvb/dvb-usb/dibusb-mc.c +4 -0
 			{ }		/* Terminating entry */
 };
 MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table);
@@ -88,7 +99,11 @@ static struct dvb_usb_device_properties dibusb_mc_properties = {
 
 	.generic_bulk_ctrl_endpoint = 0x01,
 
+#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
+	.num_device_descs = 8,
+#else
 	.num_device_descs = 7,
+#endif

The above is really ugly. IMO, we should replace this by ARRAY_SIZE(dibusb_mc_properties.devices). Of course, for this to work, num_device_descs should be bellow devices.

Quoted 7 lines
drivers/media/dvb/dvb-usb/dibusb-mc.c +0 -0
 	.devices = {
 		{   "DiBcom USB2.0 DVB-T reference design (MOD3000P)",
 			{ &dibusb_dib3000mc_table[0], NULL },
@@ -119,6 +134,13 @@ static struct dvb_usb_device_properties dibusb_mc_properties = {
 			{ &dibusb_dib3000mc_table[12], NULL },
 			{ &dibusb_dib3000mc_table[13], NULL },
 		},

drivers/media/dvb/dvb-usb/dibusb-mc.c static struct dvb_usb_device_properties dibusb_mc_properties = { · line 146

Quoted 10 lines
drivers/media/dvb/dvb-usb/dibusb-mc.c +7 -0
+#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
+		{   "LITE-ON USB2.0 DVB-T Tuner (faulty USB IDs)",
+		    /* Also rebranded as Intuix S800, Toshiba */
+			{ &dibusb_dib3000mc_table[14], NULL },
+			{ NULL },
+		},
+#endif
 		{ NULL },
 	}
 };

Patrick,
Comments?

Cheers,
Mauro

#3 lore raw

Hi,

sorry for not answering ealier, recently I became the master of postponing things. :(

Quoted 6 lines · Mauro Carvalho Chehab

drivers/media/dvb/dvb-usb/dibusb-mc.c static struct usb_device_id dibusb_dib3000mc_table [] = { · line 55

Quoted 2 lines
drivers/media/dvb/dvb-usb/dibusb-mc.c +2 -0
+/* 14 */	{ USB_DEVICE(USB_VID_CYPRESS,		USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
+#endif

It doesn't sound a very good approach the need of recompiling the driver to allow it to work with a broken card. The better would be to have some modprobe option to force it to accept a certain USB ID as a valid ID for the card.

The most correct way would be to reprogram the eeprom, by simply writing to 0xa0 (0x50 << 1) I2C address... There was a thread on the linux-dvb some time ago.

Quoted 3 lines

The above is really ugly. IMO, we should replace this by ARRAY_SIZE(dibusb_mc_properties.devices). Of course, for this to work, num_device_descs should be bellow devices.

We could do that, still I'm not sure if ARRAY_SIZE will work in that situation?! Are you sure, Mauro?

Patrick.

--
Mail: [email protected]
WWW: http://www.wi-bw.tfh-wildau.de/~pboettch/

#4 lore raw
Quoted 7 lines · On Thu, 29 Jan 2009 11:19:32 +0100 (CET) Patrick Boettcher…
Quoted 3 lines

It doesn't sound a very good approach the need of recompiling the driver to allow it to work with a broken card. The better would be to have some modprobe option to force it to accept a certain USB ID as a valid ID for the card.

The most correct way would be to reprogram the eeprom, by simply writing to 0xa0 (0x50 << 1) I2C address... There was a thread on the linux-dvb some time ago.

Yes. Yet, it might be interesting to have some option to allow forcing.

Quoted 7 lines
Quoted 3 lines

The above is really ugly. IMO, we should replace this by ARRAY_SIZE(dibusb_mc_properties.devices). Of course, for this to work, num_device_descs should be bellow devices.

We could do that, still I'm not sure if ARRAY_SIZE will work in that situation?! Are you
sure, Mauro?

Well, at least here, it is compiling fine. I can't really test it, since I don't have any dib0700 devices here.

linux/drivers/media/dvb/dvb-usb/dib0700_devices.c +23 -16
diff -r 39a646207d0c linux/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -1447,7 +1447,7 @@
 	}
 
 struct dvb_usb_device_properties dib0700_devices[] = {
-	{
+	[0] = {
 		DIB0700_DEFAULT_DEVICE_PROPERTIES,
 
 		.num_adapters = 1,
@@ -1460,7 +1460,6 @@
 			},
 		},
 
-		.num_device_descs = 8,
 		.devices = {
 			{   "DiBcom STK7700P reference design",
 				{ &dib0700_usb_id_table[0], &dib0700_usb_id_table[1] },
@@ -1496,11 +1495,13 @@
 			}
 		},
 
+		.num_device_descs = ARRAY_SIZE(dib0700_devices[0].devices),
 		.rc_interval      = DEFAULT_RC_INTERVAL,
 		.rc_key_map       = dib0700_rc_keys,
 		.rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
 		.rc_query         = dib0700_rc_query
-	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
+	},
+	[1] = { DIB0700_DEFAULT_DEVICE_PROPERTIES,
 
 		.num_adapters = 2,
 		.adapter = {
@@ -1517,19 +1518,20 @@
 			}
 		},
 
-		.num_device_descs = 1,
 		.devices = {
 			{   "Hauppauge Nova-T 500 Dual DVB-T",
 				{ &dib0700_usb_id_table[2], &dib0700_usb_id_table[3], NULL },
 				{ NULL },
 			},
 		},
+		.num_device_descs = ARRAY_SIZE(dib0700_devices[1].devices),
 
 		.rc_interval      = DEFAULT_RC_INTERVAL,
 		.rc_key_map       = dib0700_rc_keys,
 		.rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
 		.rc_query         = dib0700_rc_query
-	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
+	}, 
+	[2] = { DIB0700_DEFAULT_DEVICE_PROPERTIES,
 
 		.num_adapters = 2,
 		.adapter = {
@@ -1546,7 +1548,6 @@
 			}
 		},
 
-		.num_device_descs = 4,
 		.devices = {
 			{   "Pinnacle PCTV 2000e",
 				{ &dib0700_usb_id_table[11], NULL },
@@ -1566,13 +1567,15 @@
 			},
 
 		},
+		.num_device_descs = ARRAY_SIZE(dib0700_devices[2].devices),
 
 		.rc_interval      = DEFAULT_RC_INTERVAL,
 		.rc_key_map       = dib0700_rc_keys,
 		.rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
 		.rc_query         = dib0700_rc_query
 
-	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
+	},
+	[3] = { DIB0700_DEFAULT_DEVICE_PROPERTIES,
 
 		.num_adapters = 1,
 		.adapter = {
@@ -1584,7 +1587,6 @@
 			},
 		},
 
-		.num_device_descs = 3,
 		.devices = {
 			{   "ASUS My Cinema U3000 Mini DVBT Tuner",
 				{ &dib0700_usb_id_table[23], NULL },
@@ -1599,12 +1601,14 @@
 				{ NULL },
 			}
 		},
+		.num_device_descs = ARRAY_SIZE(dib0700_devices[3].devices),
 
 		.rc_interval      = DEFAULT_RC_INTERVAL,
 		.rc_key_map       = dib0700_rc_keys,
 		.rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
 		.rc_query         = dib0700_rc_query
-	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
+	},
+	[4] = { DIB0700_DEFAULT_DEVICE_PROPERTIES,
 
 		.num_adapters = 1,
 		.adapter = {
@@ -1618,7 +1622,6 @@
 			},
 		},
 
-		.num_device_descs = 9,
 		.devices = {
 			{   "DiBcom STK7070P reference design",
 				{ &dib0700_usb_id_table[15], NULL },
@@ -1657,13 +1660,15 @@
 				{ NULL },
 			},
 		},
+		.num_device_descs = ARRAY_SIZE(dib0700_devices[4].devices),
 
 		.rc_interval      = DEFAULT_RC_INTERVAL,
 		.rc_key_map       = dib0700_rc_keys,
 		.rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
 		.rc_query         = dib0700_rc_query
 
-	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
+	},
+	[5] = { DIB0700_DEFAULT_DEVICE_PROPERTIES,
 
 		.num_adapters = 2,
 		.adapter = {
@@ -1684,7 +1689,6 @@
 			}
 		},
 
-		.num_device_descs = 5,
 		.devices = {
 			{   "DiBcom STK7070PD reference design",
 				{ &dib0700_usb_id_table[17], NULL },
@@ -1707,11 +1711,13 @@
 				{ NULL },
 			}
 		},
+		.num_device_descs = ARRAY_SIZE(dib0700_devices[5].devices),
 		.rc_interval      = DEFAULT_RC_INTERVAL,
 		.rc_key_map       = dib0700_rc_keys,
 		.rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
 		.rc_query         = dib0700_rc_query
-	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
+	}, 
+	[6] = { DIB0700_DEFAULT_DEVICE_PROPERTIES,
 
 		.num_adapters = 1,
 		.adapter = {
@@ -1726,7 +1732,6 @@
 			},
 		},
 
-		.num_device_descs = 5,
 		.devices = {
 			{   "Terratec Cinergy HT USB XE",
 				{ &dib0700_usb_id_table[27], NULL },
@@ -1753,11 +1758,13 @@
 				{ NULL },
 			},
 		},
+		.num_device_descs = ARRAY_SIZE(dib0700_devices[6].devices),
 		.rc_interval      = DEFAULT_RC_INTERVAL,
 		.rc_key_map       = dib0700_rc_keys,
 		.rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
 		.rc_query         = dib0700_rc_query
-	}, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
+	}, 
+	[7] = { DIB0700_DEFAULT_DEVICE_PROPERTIES,
 		.num_adapters = 1,
 		.adapter = {
 			{
@@ -1771,7 +1778,6 @@
 			},
 		},
 
-		.num_device_descs = 2,
 		.devices = {
 			{   "Pinnacle PCTV HD Pro USB Stick",
 				{ &dib0700_usb_id_table[40], NULL },
@@ -1782,6 +1788,7 @@
 				{ NULL },
 			},
 		},
+		.num_device_descs = ARRAY_SIZE(dib0700_devices[7].devices),
 		.rc_interval      = DEFAULT_RC_INTERVAL,
 		.rc_key_map       = dib0700_rc_keys,
 		.rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
#5 lore raw
Quoted 6 lines · Mauro Carvalho Chehab
Quoted 3 lines

We could do that, still I'm not sure if ARRAY_SIZE will work in that situation?! Are you
sure, Mauro?

Well, at least here, it is compiling fine. I can't really test it, since I don't have any dib0700 devices here.

Hmm, your patch is shifting the counting problem to another place. Instead of counting manually the devices-array-elements, one now needs to count the number of device_properties ;) .

With such a patch we would risk to break some device support and as I never saw a patch which broke the current num_device_descs-manual-count I don't see the need to change.

Patrick.

--
Mail: [email protected]
WWW: http://www.wi-bw.tfh-wildau.de/~pboettch/

#6 lore raw
Quoted 8 lines · On Thu, 29 Jan 2009 14:08:01 +0100 (CET) Patrick Boettcher…
Quoted 6 lines · Mauro Carvalho Chehab
Quoted 3 lines

We could do that, still I'm not sure if ARRAY_SIZE will work in that situation?! Are you
sure, Mauro?

Well, at least here, it is compiling fine. I can't really test it, since I don't have any dib0700 devices here.

Quoted 7 lines

Hmm, your patch is shifting the counting problem to another place. Instead of counting manually the devices-array-elements, one now needs to count the number of device_properties ;) .

With such a patch we would risk to break some device support and as I never saw a patch which broke the current num_device_descs-manual-count I don't see the need to change.

Nothing is perfect ;)

I suspect that you have more additions at the number of the devices than on the number of device properties. So, the risk of doing bad things seems lower. Also, a simple board addition won't need to touch at the number of devices.

IMO, it is really bad to have to explicitly say the number of devices at those arrays. Maybe we may use some macro logic here to avoid such risks, or use a NULL terminated list instead.

Quoted 4 lines

--
Mail: [email protected]
WWW: http://www.wi-bw.tfh-wildau.de/~pboettch/

Cheers,
Mauro

#7 lore raw
In reply to Patrick Boettcher

Hi Patrick,

Quoted 14 lines · Patrick Boettcher

Hi,

sorry for not answering ealier, recently I became the master of postponing things. :(

Quoted 7 lines · Mauro Carvalho Chehab
Quoted 3 lines

+/* 14 */ { USB_DEVICE(USB_VID_CYPRESS,
USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
+#endif

It doesn't sound a very good approach the need of recompiling the driver to allow it to work with a broken card. The better would be to have some modprobe option to force it to accept a certain USB ID as a valid ID for the card.

Quoted 2 lines

The most correct way would be to reprogram the eeprom, by simply writing to 0xa0 (0x50 << 1) I2C address... There was a thread on the linux-dvb some time ago.

Why not, I only don't want to maintain a patch for my device.

I wonder why didn't they use WP pin of the eeprom to avoid write.

Do you know what should be written.
After a quick search, I found [1]. Is that ok ?

Matthieu

[1]
EEPROM Address Contents

      0        0xC0
      1        Vendor ID (VID) L
      2        Vendor ID (VID) H
      3        Product ID (PID) L
      4        Product ID (PID) H
      5        Device ID (DID) L
      6        Device ID (DID) H
      7        Configuration byte
#8 lore raw
Quoted 19 lines · matthieu castet

Hi Patrick,

Quoted 16 lines · Patrick Boettcher

Hi,

sorry for not answering ealier, recently I became the master of postponing things. :(

Quoted 7 lines · Mauro Carvalho Chehab
Quoted 3 lines

+/* 14 */ { USB_DEVICE(USB_VID_CYPRESS,
USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
+#endif

It doesn't sound a very good approach the need of recompiling the driver to allow it to work with a broken card. The better would be to have some modprobe option to force it to accept a certain USB ID as a valid ID for the card.

The most correct way would be to reprogram the eeprom, by simply writing to 0xa0 (0x50 << 1) I2C address... There was a thread on the linux-dvb some time ago.

BTW dibusb_i2c_xfer seems to do things very dangerous :
it assumes that it get only write/read request or write request.

That means that read can be understood as write. For example a program doing file = open("/dev/i2c-x", O_RDWR);
ioctl(file, I2C_SLAVE, 0x50)
read(file, data, 10)
will corrupt the eeprom as it will be understood as a write.

Now that I think of that, I run sensors-detect on this machine, may be this is what trash the eeprom ?

Matthieu

#9 lore raw

Hi,

Quoted 20 lines · matthieu castet
Quoted 19 lines · matthieu castet

Hi Patrick,

Quoted 16 lines · Patrick Boettcher

Hi,

sorry for not answering ealier, recently I became the master of postponing things. :(

Quoted 7 lines · Mauro Carvalho Chehab
Quoted 3 lines

+/* 14 */ { USB_DEVICE(USB_VID_CYPRESS,
USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
+#endif

It doesn't sound a very good approach the need of recompiling the driver to allow it to work with a broken card. The better would be to have some modprobe option to force it to accept a certain USB ID as a valid ID for the card.

The most correct way would be to reprogram the eeprom, by simply writing to 0xa0 (0x50 << 1) I2C address... There was a thread on the linux-dvb some time ago.

Quoted 9 lines

BTW dibusb_i2c_xfer seems to do things very dangerous :
it assumes that it get only write/read request or write request.

That means that read can be understood as write. For example a program doing file = open("/dev/i2c-x", O_RDWR);
ioctl(file, I2C_SLAVE, 0x50)
read(file, data, 10)
will corrupt the eeprom as it will be understood as a write.

Patrick, any info about that.

I attach a possible (untested) patch.

Matthieu

drivers/media/dvb/dvb-usb/dibusb-common.c +6 -2
Index: linux-2.6/drivers/media/dvb/dvb-usb/dibusb-common.c
===================================================================
@@ -133,14 +133,18 @@
 
 	for (i = 0; i < num; i++) {
 		/* write/read request */
-		if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
+		if (i+1 < num && (msg[i].flags & I2C_M_RD) == 0
+					  && (msg[i+1].flags & I2C_M_RD)) {
 			if (dibusb_i2c_msg(d, msg[i].addr, msg[i].buf,msg[i].len,
 						msg[i+1].buf,msg[i+1].len) < 0)
 				break;
 			i++;
-		} else
+		} else if ((msg[i].flags & I2C_M_RD) == 0) {
 			if (dibusb_i2c_msg(d, msg[i].addr, msg[i].buf,msg[i].len,NULL,0) < 0)
 				break;
+		}
+		else
+			break;
 	}
 
 	mutex_unlock(&d->i2c_mutex);
#10 lore raw
Quoted 77 lines · matthieu castet

Hi,

Quoted 32 lines · matthieu castet
Quoted 27 lines · matthieu castet

Hi Patrick,

Quoted 23 lines · Patrick Boettcher

Hi,

sorry for not answering ealier, recently I became the master of postponing things. :(

Quoted 10 lines · Mauro Carvalho Chehab

Review

Quoted 3 lines
(quoted diff) +2 -0
+/* 14 */    { USB_DEVICE(USB_VID_CYPRESS,
 USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
+#endif

It doesn't sound a very good approach the need of recompiling the driver to
allow it to work with a broken card. The better would be to have some modprobe
option to force it to accept a certain USB ID as a valid ID for the card.

The most correct way would be to reprogram the eeprom, by simply writing to 0xa0 (0x50 << 1) I2C address... There was a thread on the linux-dvb some time ago.

BTW dibusb_i2c_xfer seems to do things very dangerous :
it assumes that it get only write/read request or write request.

Quoted 7 lines

That means that read can be understood as write. For example a program doing
file = open("/dev/i2c-x", O_RDWR);
ioctl(file, I2C_SLAVE, 0x50)
read(file, data, 10)
will corrupt the eeprom as it will be understood as a write.

Patrick, any info about that.

I attach a possible (untested) patch.

Matthieu

Index: linux-2.6/drivers/media/dvb/dvb-usb/dibusb-common.c
===================================================================
--- linux-2.6.orig/drivers/media/dvb/dvb-usb/dibusb-common.c 2009-02-09
20:36:03.000000000 +0100
+++ linux-2.6/drivers/media/dvb/dvb-usb/dibusb-common.c 2009-02-09 20:38:21.000000000 +0100

drivers/media/dvb/dvb-usb/dibusb-common.c +6 -2
@@ -133,14 +133,18 @@
 
       for (i = 0; i < num; i++) {
               /* write/read request */
-               if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
+               if (i+1 < num && (msg[i].flags & I2C_M_RD) == 0
+                                         && (msg[i+1].flags & I2C_M_RD)) {
                       if (dibusb_i2c_msg(d, msg[i].addr,
 msg[i].buf,msg[i].len,
                                               msg[i+1].buf,msg[i+1].len) <
 0)
                               break;
                       i++;
-               } else
+               } else if ((msg[i].flags & I2C_M_RD) == 0) {
                       if (dibusb_i2c_msg(d, msg[i].addr,
 msg[i].buf,msg[i].len,NULL,0) < 0)
                               break;
+               }
+               else
+                       break;
Quoted 3 lines
       }

       mutex_unlock(&d->i2c_mutex);

The assumption that you can only have write/read or write requests is one of the big things fixed in the 1.20 firmware. If you are running the 1.20 firmware, you just need to add the option to use the new i2c function instead of the legacy i2c transfer function.

Devin

Signature · 3 lines
Devin J. Heitmueller
http://www.devinheitmueller.com
AIM: devinheitmueller
#11 lore raw
Quoted 7 lines · Devin Heitmueller
Quoted 6 lines · matthieu castet

Hi,

Quoted 3 lines · matthieu castet
Quoted 2 lines · matthieu castet

Hi Patrick,

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines · Patrick Boettcher

Hi,

The assumption that you can only have write/read or write requests is one of the big things fixed in the 1.20 firmware. If you are running the 1.20 firmware, you just need to add the option to use the new i2c function instead of the legacy i2c transfer function.

Unfortunamty this is for dib0700 and not dib3000.
dib3000 doesn't got new firmware/i2c API.

But the same patch should be done for dib0700_i2c_xfer_legacy...

Matthieu

#12 lore raw
Quoted 12 lines · matthieu castet
Quoted 11 lines · Devin Heitmueller
Quoted 9 lines · matthieu castet

Hi,

Quoted 6 lines · matthieu castet
Quoted 5 lines · matthieu castet

Hi Patrick,

Quoted 2 lines · Patrick Boettcher

Hi,

Quoted 8 lines
Quoted 4 lines

The assumption that you can only have write/read or write requests is one of the big things fixed in the 1.20 firmware. If you are running the 1.20 firmware, you just need to add the option to use the new i2c function instead of the legacy i2c transfer function.

Unfortunamty this is for dib0700 and not dib3000.
dib3000 doesn't got new firmware/i2c API.

But the same patch should be done for dib0700_i2c_xfer_legacy...

Wow, I totally overlooked that your patch was against dibusb-common.c instead of dib0700_core.c. Yes, you are correct then. However I would still suggest sending an error to the console and returning failure rather than just silently dropping the i2c read request.

Cheers,

Devin

Signature · 3 lines
Devin J. Heitmueller
http://www.devinheitmueller.com
AIM: devinheitmueller
#13 lore raw
In reply to matthieu castet

On Mon, Feb 9, 2009 at 2:40 PM, matthieu castet

Quoted 45 lines
Quoted 10 lines

BTW dibusb_i2c_xfer seems to do things very dangerous :
it assumes that it get only write/read request or write request.

That means that read can be understood as write. For example a program doing
file = open("/dev/i2c-x", O_RDWR);
ioctl(file, I2C_SLAVE, 0x50)
read(file, data, 10)
will corrupt the eeprom as it will be understood as a write.

Patrick, any info about that.

I attach a possible (untested) patch.

Matthieu

Index: linux-2.6/drivers/media/dvb/dvb-usb/dibusb-common.c
===================================================================
--- linux-2.6.orig/drivers/media/dvb/dvb-usb/dibusb-common.c 2009-02-09
20:36:03.000000000 +0100
+++ linux-2.6/drivers/media/dvb/dvb-usb/dibusb-common.c 2009-02-09 20:38:21.000000000 +0100

drivers/media/dvb/dvb-usb/dibusb-common.c +6 -2
@@ -133,14 +133,18 @@
 
       for (i = 0; i < num; i++) {
               /* write/read request */
-               if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
+               if (i+1 < num && (msg[i].flags & I2C_M_RD) == 0
+                                         && (msg[i+1].flags & I2C_M_RD)) {
                       if (dibusb_i2c_msg(d, msg[i].addr,
 msg[i].buf,msg[i].len,
                                               msg[i+1].buf,msg[i+1].len) <
 0)
                               break;
                       i++;
-               } else
+               } else if ((msg[i].flags & I2C_M_RD) == 0) {
                       if (dibusb_i2c_msg(d, msg[i].addr,
 msg[i].buf,msg[i].len,NULL,0) < 0)
                               break;
+               }
+               else
+                       break;
Quoted 4 lines
       }

       mutex_unlock(&d->i2c_mutex);

Regarding the patch itself, it looks ok at face value, but I would rather see it scream loudly that you're trying to do this rather just silently not performing the read. This would help catch cases where the calling driver is doing something the i2c implementation doesn't support (so that the developer knows to either change his i2c code or use the 1.20 version of the function).

I'm just speaking as a developer who got bit by this making the dib0700 work with the xc5000, where I didn't realize the xc5000 driver was doing something that the dib0700 i2c didn't support and it failed silently.

Devin

Signature · 3 lines
Devin J. Heitmueller
http://www.devinheitmueller.com
AIM: devinheitmueller
#14 lore raw

PATCH 1/1 DIBUSB_MC : fix i2c to not corrupt eeprom in case of strange read pattern

In reply to matthieu castet

Hi,

dibusb_i2c_xfer seems to do things very dangerous :
it assumes that it get only write/read request or write request.

That means that read can be understood as write. For example a program doing
file = open("/dev/i2c-x", O_RDWR);
ioctl(file, I2C_SLAVE, 0x50)
read(file, data, 10)
will corrupt the eeprom as it will be understood as a write.

I attach a possible (untested) patch.

Matthieu

drivers/media/dvb/dvb-usb/dibusb-common.c +6 -2
Index: linux-2.6/drivers/media/dvb/dvb-usb/dibusb-common.c
===================================================================
@@ -133,14 +133,18 @@
 
 	for (i = 0; i < num; i++) {
 		/* write/read request */
-		if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
+		if (i+1 < num && (msg[i].flags & I2C_M_RD) == 0
+					  && (msg[i+1].flags & I2C_M_RD)) {
 			if (dibusb_i2c_msg(d, msg[i].addr, msg[i].buf,msg[i].len,
 						msg[i+1].buf,msg[i+1].len) < 0)
 				break;
 			i++;
-		} else
+		} else if ((msg[i].flags & I2C_M_RD) == 0) {
 			if (dibusb_i2c_msg(d, msg[i].addr, msg[i].buf,msg[i].len,NULL,0) < 0)
 				break;
+		}
+		else
+			break;
 	}
 
 	mutex_unlock(&d->i2c_mutex);
#15 lore raw

Re: [PATCH] DIBUSB_MC : fix i2c to not corrupt eeprom in case of strange read pattern

Hi Matthieu,

Quoted 13 lines · matthieu castet

Hi,

dibusb_i2c_xfer seems to do things very dangerous :
it assumes that it get only write/read request or write request.

That means that read can be understood as write. For example a program doing
file = open("/dev/i2c-x", O_RDWR);
ioctl(file, I2C_SLAVE, 0x50)
read(file, data, 10)
will corrupt the eeprom as it will be understood as a write.

Quoted 6 lines

I attach a possible (untested) patch.

Matthieu

thanks a lot for your patch. I applied it, but could not test. But even it is breaks things, it's better to prevent those "false-reads" than not having this protection. Any breakage we will fix later.

Patrick.

--
Mail: [email protected]
WWW: http://www.wi-bw.tfh-wildau.de/~pboettch/